]>
git.proxmox.com Git - ceph.git/blob - ceph/src/include/compat.h
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.
16 #include <sys/types.h>
18 #if defined(__linux__)
22 #if defined(__FreeBSD__)
24 // FreeBSD supports Linux procfs with its compatibility module
25 // And all compatibility stuff is standard mounted on this
26 #define PROCPREFIX "/compat/linux"
28 /* Make sure that ENODATA is defined in the correct way */
30 #define ENODATA ENOATTR
33 // #warning ENODATA already defined to be 9919, redefining to fix
34 // Silencing this warning because it fires at all files where compat.h
35 // is included after boost files.
37 // This value stems from the definition in the boost library
38 // And when this case occurs it is due to the fact that boost files
39 // are included before this file. Redefinition might not help in this
40 // case since already parsed code has evaluated to the wrong value.
41 // This would warrrant for d definition that would actually be evaluated
42 // at the location of usage and report a possible confict.
43 // This is left up to a future improvement
45 #warning ENODATA already defined to a value different from 87 (ENOATRR), refining to fix
48 #define ENODATA ENOATTR
55 #define O_DSYNC O_SYNC
59 #if !defined(CLOCK_MONOTONIC_COARSE)
60 #if defined(CLOCK_MONOTONIC_FAST)
61 #define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST
63 #define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
66 #if !defined(CLOCK_REALTIME_COARSE)
67 #if defined(CLOCK_REALTIME_FAST)
68 #define CLOCK_REALTIME_COARSE CLOCK_REALTIME_FAST
70 #define CLOCK_REALTIME_COARSE CLOCK_REALTIME
74 /* And include the extra required include file */
75 #include <pthread_np.h>
77 #endif /* !__FreeBSD__ */
79 #if defined(__APPLE__) || defined(__FreeBSD__)
89 #define HOST_NAME_MAX MAXHOSTNAMELEN
91 #define HOST_NAME_MAX 255
95 #endif /* __APPLE__ */
97 /* O_LARGEFILE is not defined/required on OSX/FreeBSD */
102 /* Could be relevant for other platforms */
104 #define ERESTART EINTR
107 #ifndef TEMP_FAILURE_RETRY
108 #define TEMP_FAILURE_RETRY(expression) ({ \
109 __typeof(expression) __result; \
111 __result = (expression); \
112 } while (__result == -1 && errno == EINTR); \
117 # define VOID_TEMP_FAILURE_RETRY(expression) \
118 static_cast<void>(TEMP_FAILURE_RETRY(expression))
120 # define VOID_TEMP_FAILURE_RETRY(expression) \
121 do { (void)TEMP_FAILURE_RETRY(expression); } while (0)
124 #if defined(__FreeBSD__) || defined(__APPLE__)
125 #define lseek64(fd, offset, whence) lseek(fd, offset, whence)
128 #if defined(__sun) || defined(_AIX)
129 #define LOG_AUTHPRIV (10<<3)
130 #define LOG_FTP (11<<3)
131 #define __STRING(x) "x"
132 #define IFTODT(mode) (((mode) & 0170000) >> 12)
136 #define MSG_DONTWAIT MSG_NONBLOCK
139 #if defined(HAVE_PTHREAD_SETNAME_NP)
140 #if defined(__APPLE__)
141 #define ceph_pthread_setname(thread, name) ({ \
143 if (thread == pthread_self()) \
144 __result = pthread_setname_np(name); \
147 #define ceph_pthread_setname pthread_setname_np
149 #elif defined(HAVE_PTHREAD_SET_NAME_NP)
150 /* Fix a small name diff */
151 #define ceph_pthread_setname pthread_set_name_np
153 /* compiler warning free success noop */
154 #define ceph_pthread_setname(thread, name) ({ \
159 #if defined(HAVE_PTHREAD_GETNAME_NP)
160 #define ceph_pthread_getname pthread_getname_np
162 /* compiler warning free success noop */
163 #define ceph_pthread_getname(thread, name, len) ({ \
169 int ceph_posix_fallocate(int fd
, off_t offset
, off_t len
);
171 int pipe_cloexec(int pipefd
[2]);
173 #endif /* !CEPH_COMPAT_H */