]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
compat.h: added a set of extras for FreeBSD <> Linux compatability
authorWillem Jan Withagen <wjw@digiware.nl>
Tue, 17 May 2016 10:01:31 +0000 (12:01 +0200)
committerWillem Jan Withagen <wjw@digiware.nl>
Wed, 25 May 2016 10:12:43 +0000 (12:12 +0200)
If this file is used, it is wise to include it a fist include file
at the top of the code.

Things added to compat.h:
 - ENODATA versus ENOATTR
   This is a very tricky one since ENOATTR is also defined in boost,
   but with a totally diferent value again. We need to make sure
   that the same value is used alt all places.
 - O_DSYNC(freeBSD) versus O_SYNC(Linux)
   fortunately they have the same value.
 - HOST_NAME_MAX is undefined in FreeBSD
   So hardcoded to the value that Linux uses
 - pthread_set_name_np(FreeBSD) versus pthread_setname_np(Linux)
   and the NON-Posix code lives in a separate include file
 - Some compatiblility code for CLOCK_MONOTONIC_COARSE to rewite
   to the FreeBSD equivalent CLOCK_MONOTONIC_FAST

compat.h is added to:
 * src/common/Thread.cc
 * src/common/obj_bencher.cc
 * src/crush/CrushLocation.cc
 * src/include/compat.h
 * src/include/rados/librados.h
 * src/os/filestore/FileStore.cc
 * src/test/system/systest_runnable.cc

Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
src/common/Thread.cc
src/common/obj_bencher.cc
src/crush/CrushLocation.cc
src/include/compat.h
src/include/rados/librados.h
src/os/filestore/FileStore.cc
src/test/system/systest_runnable.cc

index c1c3be5bf7e241dc93e5806afb281f1434054995..16591157d113e4102c17fdd8ddaacc21aa807356 100644 (file)
@@ -12,6 +12,7 @@
  *
  */
 
+#include "include/compat.h"
 #include "common/Thread.h"
 #include "common/code_environment.h"
 #include "common/debug.h"
@@ -22,6 +23,7 @@
 #include <errno.h>
 #include <iostream>
 #include <pthread.h>
+
 #include <signal.h>
 #include <sstream>
 #include <stdlib.h>
index 0971ec9c0c96d1693f7f7f77fb12db0a875e7c32..b4ebc03183f5bc61962d262d00c7a03b22830a3f 100644 (file)
@@ -15,6 +15,7 @@
  * try and bench on a pool you don't have permission to access
  * it will just loop forever.
  */
+#include "include/compat.h"
 #include "common/Cond.h"
 #include "obj_bencher.h"
 
index de648bc6241d099c0d3e447867a88c486e5acf27..310f14879deb6b4dba220fb1dbb3e09d6a35ceb4 100644 (file)
@@ -1,6 +1,7 @@
 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 
+#include "include/compat.h"
 #include "CrushLocation.h"
 #include "CrushWrapper.h"
 #include "common/config.h"
index ec5905c82cda79d8ab23d7821b21b1742c664061..1df098bc42f5ef507d0605a179a53a7c068f6c8f 100644 (file)
 #define CEPH_COMPAT_H
 
 #if defined(__FreeBSD__)
+
+/* Make sure that ENODATA is defined in the correct way */
+#ifndef ENODATA
 #define        ENODATA ENOATTR
+#else
+#if (ENODATA == 9919)
+// #warning ENODATA already defined to be 9919, redefining to fix
+// Silencing this warning because it fires at all files where compat.h
+// is included after boost files.
+//
+// This value stems from the definition in the boost library
+// And when this case occurs it is due to the fact that boost files
+// are included before this file. Redefinition might not help in this
+// case since already parsed code has evaluated to the wrong value.
+// This would warrrant for d definition that would actually be evaluated
+// at the location of usage and report a possible confict.
+// This is left up to a future improvement
+#elif (ENODATA != 87)
+#warning ENODATA already defined to a value different from 87 (ENOATRR), refining to fix
+#endif
+#undef ENODATA
+#define ENODATA ENOATTR
+#endif
+
+#ifndef MSG_MORE
 #define        MSG_MORE 0
+#endif
+
+#ifndef O_DSYNC
+#define O_DSYNC O_SYNC
+#endif
+
+#ifndef HOST_NAME_MAX
+#define HOST_NAME_MAX 64
+#endif
+
+// Fix clock accuracy
+#if !defined(CLOCK_MONOTONIC_COARSE)
+#if defined(CLOCK_MONOTONIC_FAST)
+#define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST
+#else
+#define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
+#endif
+#endif
+
+/* Fix a small name diff */
+#define pthread_setname_np pthread_set_name_np
+/* And include the extra required include file */
+#include <pthread_np.h>
+
 #endif /* !__FreeBSD__ */
 
 #if defined(__APPLE__)
index b3d4818374eaff838ffda03740514baab7223a26..d72f9e602f89af57e2ce72d36b06cbd7eda5debf 100644 (file)
@@ -19,6 +19,7 @@
 extern "C" {
 #endif
 
+#include "../compat.h"
 #include <netinet/in.h>
 #if defined(__linux__)
 #include <linux/types.h>
index 7939dfc195f911ee9055241cc3f3203d67f9d33d..c34a722f01a6be2e785e7ee5b649aa80a929a2bd 100644 (file)
@@ -12,6 +12,7 @@
  * Foundation.  See file COPYING.
  *
  */
+#include "include/compat.h"
 #include "include/int_types.h"
 
 #include <unistd.h>
@@ -31,7 +32,6 @@
 #include <iostream>
 #include <map>
 
-#include "include/compat.h"
 #include "include/linux_fiemap.h"
 
 #include "common/xattr.h"
index c7ed6aa72a2dc8d27adb94ada35a4d4abf8cfcfc..95453391207a549d308772fc2a4296d4dc17133e 100644 (file)
@@ -12,6 +12,7 @@
  *
  */
 
+#include "include/compat.h"
 #include "common/errno.h"
 #include "include/atomic.h"
 #include "systest_runnable.h"
 #include <unistd.h>
 #include <vector>
 
-#if defined(__FreeBSD__)
-#include <pthread_np.h>
-#endif
-
 using std::ostringstream;
 using std::string;