2 * Ceph - scalable distributed file system
4 * Copyright (C) 2011 Stanislav Sedov <stas@FreeBSD.org>
6 * This is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software
9 * Foundation. See file COPYING.
17 #if defined(__linux__)
21 #if defined(__FreeBSD__)
23 // FreeBSD supports Linux procfs with its compatibility module
24 // And all compatibility stuff is standard mounted on this
25 #define PROCPREFIX "/compat/linux"
27 /* Make sure that ENODATA is defined in the correct way */
29 #define ENODATA ENOATTR
32 // #warning ENODATA already defined to be 9919, redefining to fix
33 // Silencing this warning because it fires at all files where compat.h
34 // is included after boost files.
36 // This value stems from the definition in the boost library
37 // And when this case occurs it is due to the fact that boost files
38 // are included before this file. Redefinition might not help in this
39 // case since already parsed code has evaluated to the wrong value.
40 // This would warrrant for d definition that would actually be evaluated
41 // at the location of usage and report a possible confict.
42 // This is left up to a future improvement
44 #warning ENODATA already defined to a value different from 87 (ENOATRR), refining to fix
47 #define ENODATA ENOATTR
54 #define O_DSYNC O_SYNC
58 #if !defined(CLOCK_MONOTONIC_COARSE)
59 #if defined(CLOCK_MONOTONIC_FAST)
60 #define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST
62 #define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
65 #if !defined(CLOCK_REALTIME_COARSE)
66 #if defined(CLOCK_REALTIME_FAST)
67 #define CLOCK_REALTIME_COARSE CLOCK_REALTIME_FAST
69 #define CLOCK_REALTIME_COARSE CLOCK_REALTIME
73 /* And include the extra required include file */
74 #include <pthread_np.h>
76 #endif /* !__FreeBSD__ */
78 #if defined(__APPLE__) || defined(__FreeBSD__)
88 #define HOST_NAME_MAX MAXHOSTNAMELEN
90 #define HOST_NAME_MAX 255
94 #endif /* __APPLE__ */
96 /* O_LARGEFILE is not defined/required on OSX/FreeBSD */
101 /* Could be relevant for other platforms */
103 #define ERESTART EINTR
106 #ifndef TEMP_FAILURE_RETRY
107 #define TEMP_FAILURE_RETRY(expression) ({ \
108 __typeof(expression) __result; \
110 __result = (expression); \
111 } while (__result == -1 && errno == EINTR); \
116 # define VOID_TEMP_FAILURE_RETRY(expression) \
117 static_cast<void>(TEMP_FAILURE_RETRY(expression))
119 # define VOID_TEMP_FAILURE_RETRY(expression) \
120 do { (void)TEMP_FAILURE_RETRY(expression); } while (0)
123 #if defined(__FreeBSD__) || defined(__APPLE__)
124 #define lseek64(fd, offset, whence) lseek(fd, offset, whence)
127 #if defined(__sun) || defined(_AIX)
128 #define LOG_AUTHPRIV (10<<3)
129 #define LOG_FTP (11<<3)
130 #define __STRING(x) "x"
131 #define IFTODT(mode) (((mode) & 0170000) >> 12)
135 #define MSG_DONTWAIT MSG_NONBLOCK
138 #if defined(HAVE_PTHREAD_SETNAME_NP)
139 #if defined(__APPLE__)
140 #define ceph_pthread_setname(thread, name) ({ \
142 if (thread == pthread_self()) \
143 __result = pthread_setname_np(name); \
146 #define ceph_pthread_setname pthread_setname_np
148 #elif defined(HAVE_PTHREAD_SET_NAME_NP)
149 /* Fix a small name diff */
150 #define ceph_pthread_setname pthread_set_name_np
152 /* compiler warning free success noop */
153 #define ceph_pthread_setname(thread, name) ({ \
158 #if defined(HAVE_PTHREAD_GETNAME_NP)
159 #define ceph_pthread_getname pthread_getname_np
161 /* compiler warning free success noop */
162 #define ceph_pthread_getname(thread, name, len) ({ \
168 #endif /* !CEPH_COMPAT_H */