]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | * Ceph - scalable distributed file system | |
3 | * | |
4 | * Copyright (C) 2011 Stanislav Sedov <stas@FreeBSD.org> | |
5 | * | |
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. | |
10 | */ | |
11 | ||
12 | #ifndef CEPH_COMPAT_H | |
13 | #define CEPH_COMPAT_H | |
14 | ||
15 | #include "acconfig.h" | |
28e407b8 | 16 | #include <sys/types.h> |
7c673cae FG |
17 | |
18 | #if defined(__linux__) | |
19 | #define PROCPREFIX | |
20 | #endif | |
21 | ||
22 | #if defined(__FreeBSD__) | |
23 | ||
24 | // FreeBSD supports Linux procfs with its compatibility module | |
25 | // And all compatibility stuff is standard mounted on this | |
26 | #define PROCPREFIX "/compat/linux" | |
27 | ||
28 | /* Make sure that ENODATA is defined in the correct way */ | |
29 | #ifndef ENODATA | |
30 | #define ENODATA ENOATTR | |
31 | #else | |
32 | #if (ENODATA == 9919) | |
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. | |
36 | // | |
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 | |
44 | #elif (ENODATA != 87) | |
45 | #warning ENODATA already defined to a value different from 87 (ENOATRR), refining to fix | |
46 | #endif | |
47 | #undef ENODATA | |
48 | #define ENODATA ENOATTR | |
49 | #endif | |
50 | #ifndef MSG_MORE | |
51 | #define MSG_MORE 0 | |
52 | #endif | |
53 | ||
54 | #ifndef O_DSYNC | |
55 | #define O_DSYNC O_SYNC | |
56 | #endif | |
57 | ||
58 | // Fix clock accuracy | |
59 | #if !defined(CLOCK_MONOTONIC_COARSE) | |
60 | #if defined(CLOCK_MONOTONIC_FAST) | |
61 | #define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST | |
62 | #else | |
63 | #define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC | |
64 | #endif | |
65 | #endif | |
66 | #if !defined(CLOCK_REALTIME_COARSE) | |
67 | #if defined(CLOCK_REALTIME_FAST) | |
68 | #define CLOCK_REALTIME_COARSE CLOCK_REALTIME_FAST | |
69 | #else | |
70 | #define CLOCK_REALTIME_COARSE CLOCK_REALTIME | |
71 | #endif | |
72 | #endif | |
73 | ||
74 | /* And include the extra required include file */ | |
75 | #include <pthread_np.h> | |
76 | ||
77 | #endif /* !__FreeBSD__ */ | |
78 | ||
79 | #if defined(__APPLE__) || defined(__FreeBSD__) | |
80 | /* get PATH_MAX */ | |
81 | #include <limits.h> | |
82 | ||
83 | #ifndef EREMOTEIO | |
84 | #define EREMOTEIO 121 | |
85 | #endif | |
86 | ||
87 | #ifndef HOST_NAME_MAX | |
88 | #ifdef MAXHOSTNAMELEN | |
89 | #define HOST_NAME_MAX MAXHOSTNAMELEN | |
90 | #else | |
91 | #define HOST_NAME_MAX 255 | |
92 | #endif | |
93 | #endif | |
94 | ||
95 | #endif /* __APPLE__ */ | |
96 | ||
97 | /* O_LARGEFILE is not defined/required on OSX/FreeBSD */ | |
98 | #ifndef O_LARGEFILE | |
99 | #define O_LARGEFILE 0 | |
100 | #endif | |
101 | ||
102 | /* Could be relevant for other platforms */ | |
103 | #ifndef ERESTART | |
104 | #define ERESTART EINTR | |
105 | #endif | |
106 | ||
107 | #ifndef TEMP_FAILURE_RETRY | |
108 | #define TEMP_FAILURE_RETRY(expression) ({ \ | |
109 | __typeof(expression) __result; \ | |
110 | do { \ | |
111 | __result = (expression); \ | |
112 | } while (__result == -1 && errno == EINTR); \ | |
113 | __result; }) | |
114 | #endif | |
115 | ||
116 | #ifdef __cplusplus | |
117 | # define VOID_TEMP_FAILURE_RETRY(expression) \ | |
118 | static_cast<void>(TEMP_FAILURE_RETRY(expression)) | |
119 | #else | |
120 | # define VOID_TEMP_FAILURE_RETRY(expression) \ | |
121 | do { (void)TEMP_FAILURE_RETRY(expression); } while (0) | |
122 | #endif | |
123 | ||
124 | #if defined(__FreeBSD__) || defined(__APPLE__) | |
125 | #define lseek64(fd, offset, whence) lseek(fd, offset, whence) | |
126 | #endif | |
127 | ||
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) | |
133 | #endif | |
134 | ||
135 | #if defined(_AIX) | |
136 | #define MSG_DONTWAIT MSG_NONBLOCK | |
137 | #endif | |
138 | ||
139 | #if defined(HAVE_PTHREAD_SETNAME_NP) | |
140 | #if defined(__APPLE__) | |
141 | #define ceph_pthread_setname(thread, name) ({ \ | |
142 | int __result = 0; \ | |
143 | if (thread == pthread_self()) \ | |
144 | __result = pthread_setname_np(name); \ | |
145 | __result; }) | |
146 | #else | |
147 | #define ceph_pthread_setname pthread_setname_np | |
148 | #endif | |
149 | #elif defined(HAVE_PTHREAD_SET_NAME_NP) | |
150 | /* Fix a small name diff */ | |
151 | #define ceph_pthread_setname pthread_set_name_np | |
152 | #else | |
153 | /* compiler warning free success noop */ | |
154 | #define ceph_pthread_setname(thread, name) ({ \ | |
155 | int __i = 0; \ | |
156 | __i; }) | |
157 | #endif | |
158 | ||
159 | #if defined(HAVE_PTHREAD_GETNAME_NP) | |
160 | #define ceph_pthread_getname pthread_getname_np | |
161 | #else | |
162 | /* compiler warning free success noop */ | |
163 | #define ceph_pthread_getname(thread, name, len) ({ \ | |
164 | if (name != NULL) \ | |
165 | *name = '\0'; \ | |
166 | 0; }) | |
167 | #endif | |
168 | ||
28e407b8 AA |
169 | int ceph_posix_fallocate(int fd, off_t offset, off_t len); |
170 | ||
7c673cae | 171 | #endif /* !CEPH_COMPAT_H */ |