From: Yan, Zheng Date: Fri, 31 Jul 2015 02:01:01 +0000 (+0800) Subject: compat: move definitions in porting.h into include/compat.h X-Git-Tag: v9.1.0~259^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f6fa4a28d1ef3ff8f1ed84b64fc10d083a4b336c;p=ceph.git compat: move definitions in porting.h into include/compat.h Signed-off-by: Yan, Zheng --- diff --git a/src/Makefile.am b/src/Makefile.am index 5cf555707f3a..502f83a014fc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -211,8 +211,7 @@ noinst_HEADERS += \ bash_completion/radosgw-admin \ mount/canonicalize.c \ mount/mtab.c \ - objclass/objclass.h \ - porting.h + objclass/objclass.h # coverage diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 6369312d8e6f..a364b295d6c2 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -61,6 +61,7 @@ noinst_HEADERS += \ include/cmp.h \ include/color.h \ include/compat.h \ + include/sock_compat.h \ include/crc32c.h \ include/encoding.h \ include/err.h \ diff --git a/src/include/compat.h b/src/include/compat.h index caabe10df0e3..9cb4f61b5327 100644 --- a/src/include/compat.h +++ b/src/include/compat.h @@ -17,6 +17,21 @@ #define MSG_MORE 0 #endif /* !__FreeBSD__ */ +#if defined(__APPLE__) +/* PATH_MAX */ +#include + +/* O_LARGEFILE is not defined/required on OS X */ +#ifndef O_LARGEFILE +#define O_LARGEFILE 0 +#endif + +/* Could be relevant for other platforms */ +#ifndef ERESTART +#define ERESTART EINTR +#endif +#endif /* __APPLE__ */ + #ifndef TEMP_FAILURE_RETRY #define TEMP_FAILURE_RETRY(expression) ({ \ typeof(expression) __result; \ diff --git a/src/include/sock_compat.h b/src/include/sock_compat.h new file mode 100644 index 000000000000..5faacc343edc --- /dev/null +++ b/src/include/sock_compat.h @@ -0,0 +1,26 @@ +#ifndef CEPH_SOCK_COMPAT_H +#define CEPH_SOCK_COMPAT_H + +#include "include/compat.h" + +/* + * This optimization may not be available on all platforms (e.g. OSX). + * Apparently a similar approach based on TCP_CORK can be used. + */ +#ifndef MSG_MORE +# define MSG_MORE 0 +#endif + +/* + * On BSD SO_NOSIGPIPE can be set via setsockopt to block SIGPIPE. + */ +#ifndef MSG_NOSIGNAL +# define MSG_NOSIGNAL 0 +# ifdef SO_NOSIGPIPE +# define CEPH_USE_SO_NOSIGPIPE +# else +# error "Cannot block SIGPIPE!" +# endif +#endif + +#endif diff --git a/src/librbd/AsyncRequest.h b/src/librbd/AsyncRequest.h index b6594bf8898e..c0a60131106b 100644 --- a/src/librbd/AsyncRequest.h +++ b/src/librbd/AsyncRequest.h @@ -9,7 +9,7 @@ #include "include/xlist.h" /* DARWIN Missing ERESTART */ -#include "porting.h" +#include "include/compat.h" namespace librbd { diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index a8a47e568dca..97bb17ab20de 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -23,7 +23,7 @@ #include "AsyncMessenger.h" #include "AsyncConnection.h" -#include "porting.h" +#include "include/sock_compat.h" // Constant to limit starting sequence number to 2^31. Nothing special about it, just a big number. PLR #define SEQ_MASK 0x7fffffff diff --git a/src/msg/simple/Pipe.cc b/src/msg/simple/Pipe.cc index 42995840d45a..2292af9a54dd 100644 --- a/src/msg/simple/Pipe.cc +++ b/src/msg/simple/Pipe.cc @@ -32,7 +32,7 @@ #include "auth/cephx/CephxProtocol.h" #include "auth/AuthSessionHandler.h" -#include "porting.h" +#include "include/sock_compat.h" // Constant to limit starting sequence number to 2^31. Nothing special about it, just a big number. PLR #define SEQ_MASK 0x7fffffff diff --git a/src/porting.h b/src/porting.h deleted file mode 100644 index 1528ffb0f020..000000000000 --- a/src/porting.h +++ /dev/null @@ -1,43 +0,0 @@ - -#ifndef PORTING_H -#define PORTING_H -#include "acconfig.h" - -/* TODO: move these into include/compat.h */ - -#if defined(DARWIN) -#include - -/* O_LARGEFILE is not defined/required on OS X */ -#define O_LARGEFILE 0 - -/* Wonder why this is missing */ -#define PATH_MAX 1024 - -/* Could be relevant for other platforms */ -#ifndef ERESTART -#define ERESTART EINTR -#endif - -/* - * This optimization may not be available on all platforms (e.g. OSX). - * Apparently a similar approach based on TCP_CORK can be used. - */ -#ifndef MSG_MORE -# define MSG_MORE 0 -#endif - -/* - * On BSD SO_NOSIGPIPE can be set via setsockopt to block SIGPIPE. - */ -#ifndef MSG_NOSIGNAL -# define MSG_NOSIGNAL 0 -# ifdef SO_NOSIGPIPE -# define CEPH_USE_SO_NOSIGPIPE -# else -# error "Cannot block SIGPIPE!" -# endif -#endif - -#endif /* DARWIN */ -#endif /* PORTING_H */ diff --git a/src/rbd_fuse/rbd-fuse.cc b/src/rbd_fuse/rbd-fuse.cc index f7ac46c76778..5cc89002c4f9 100644 --- a/src/rbd_fuse/rbd-fuse.cc +++ b/src/rbd_fuse/rbd-fuse.cc @@ -11,12 +11,7 @@ #include #include #include -#if defined(DARWIN) #include -#include "porting.h" -#else -#include -#endif #include #include #include @@ -24,6 +19,7 @@ #include #include +#include "include/compat.h" #include "include/rbd/librbd.h" static int gotrados = 0; diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index dd29779fd7b8..a2dbccbc5fc2 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -36,7 +36,6 @@ #include "json_spirit/json_spirit_reader.h" #include "ceph_objectstore_tool.h" -#include "porting.h" namespace po = boost::program_options; using namespace std;