]>
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__)
24 #define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
27 #if defined(__FreeBSD__)
29 // FreeBSD supports Linux procfs with its compatibility module
30 // And all compatibility stuff is standard mounted on this
31 #define PROCPREFIX "/compat/linux"
38 #define O_DSYNC O_SYNC
41 /* And include the extra required include file */
42 #include <pthread_np.h>
44 #include <sys/param.h>
45 #include <sys/cpuset.h>
46 #define cpu_set_t cpuset_t
47 int sched_setaffinity(pid_t pid
, size_t cpusetsize
,
50 #endif /* __FreeBSD__ */
52 #if defined(__APPLE__) || defined(__FreeBSD__)
53 /* Make sure that ENODATA is defined in the correct way */
56 // #warning ENODATA already defined to be 9919, redefining to fix
57 // Silencing this warning because it fires at all files where compat.h
58 // is included after boost files.
60 // This value stems from the definition in the boost library
61 // And when this case occurs it is due to the fact that boost files
62 // are included before this file. Redefinition might not help in this
63 // case since already parsed code has evaluated to the wrong value.
64 // This would warrrant for d definition that would actually be evaluated
65 // at the location of usage and report a possible conflict.
66 // This is left up to a future improvement
68 // #warning ENODATA already defined to a value different from 87 (ENOATRR), refining to fix
72 #define ENODATA ENOATTR
75 #if !defined(CLOCK_MONOTONIC_COARSE)
76 #if defined(CLOCK_MONOTONIC_FAST)
77 #define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST
79 #define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
82 #if !defined(CLOCK_REALTIME_COARSE)
83 #if defined(CLOCK_REALTIME_FAST)
84 #define CLOCK_REALTIME_COARSE CLOCK_REALTIME_FAST
86 #define CLOCK_REALTIME_COARSE CLOCK_REALTIME
100 #define EKEYREJECTED 129
103 #define XATTR_CREATE 1
106 #ifndef HOST_NAME_MAX
107 #ifdef MAXHOSTNAMELEN
108 #define HOST_NAME_MAX MAXHOSTNAMELEN
110 #define HOST_NAME_MAX 255
114 #endif /* __APPLE__ */
116 /* O_LARGEFILE is not defined/required on OSX/FreeBSD */
118 #define O_LARGEFILE 0
121 /* Could be relevant for other platforms */
123 #define ERESTART EINTR
126 #ifndef TEMP_FAILURE_RETRY
127 #define TEMP_FAILURE_RETRY(expression) ({ \
128 __typeof(expression) __result; \
130 __result = (expression); \
131 } while (__result == -1 && errno == EINTR); \
136 # define VOID_TEMP_FAILURE_RETRY(expression) \
137 static_cast<void>(TEMP_FAILURE_RETRY(expression))
139 # define VOID_TEMP_FAILURE_RETRY(expression) \
140 do { (void)TEMP_FAILURE_RETRY(expression); } while (0)
143 #if defined(__FreeBSD__) || defined(__APPLE__)
144 #define lseek64(fd, offset, whence) lseek(fd, offset, whence)
147 #if defined(__sun) || defined(_AIX)
148 #define LOG_AUTHPRIV (10<<3)
149 #define LOG_FTP (11<<3)
150 #define __STRING(x) "x"
151 #define IFTODT(mode) (((mode) & 0170000) >> 12)
155 #define MSG_DONTWAIT MSG_NONBLOCK
158 #if defined(HAVE_PTHREAD_SETNAME_NP)
159 #if defined(__APPLE__)
160 #define ceph_pthread_setname(thread, name) ({ \
162 if (thread == pthread_self()) \
163 __result = pthread_setname_np(name); \
166 #define ceph_pthread_setname pthread_setname_np
168 #elif defined(HAVE_PTHREAD_SET_NAME_NP)
169 /* Fix a small name diff and return 0 */
170 #define ceph_pthread_setname(thread, name) ({ \
171 pthread_set_name_np(thread, name); \
174 /* compiler warning free success noop */
175 #define ceph_pthread_setname(thread, name) ({ \
180 #if defined(HAVE_PTHREAD_GETNAME_NP)
181 #define ceph_pthread_getname pthread_getname_np
182 #elif defined(HAVE_PTHREAD_GET_NAME_NP)
183 #define ceph_pthread_getname(thread, name, len) ({ \
184 pthread_get_name_np(thread, name, len); \
187 /* compiler warning free success noop */
188 #define ceph_pthread_getname(thread, name, len) ({ \
194 int ceph_posix_fallocate(int fd
, off_t offset
, off_t len
);
196 int pipe_cloexec(int pipefd
[2]);
198 #endif /* !CEPH_COMPAT_H */