]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
d9a64523 | 2 | * Copyright (c) 2000-2018 Apple Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* Copyright 1995 NeXT Computer, Inc. All rights reserved. */ | |
29 | /* | |
30 | * Copyright (c) 1991, 1993 | |
31 | * The Regents of the University of California. All rights reserved. | |
32 | * | |
33 | * This code is derived from software contributed to Berkeley by | |
34 | * Berkeley Software Design, Inc. | |
35 | * | |
36 | * Redistribution and use in source and binary forms, with or without | |
37 | * modification, are permitted provided that the following conditions | |
38 | * are met: | |
39 | * 1. Redistributions of source code must retain the above copyright | |
40 | * notice, this list of conditions and the following disclaimer. | |
41 | * 2. Redistributions in binary form must reproduce the above copyright | |
42 | * notice, this list of conditions and the following disclaimer in the | |
43 | * documentation and/or other materials provided with the distribution. | |
44 | * 3. All advertising materials mentioning features or use of this software | |
45 | * must display the following acknowledgement: | |
46 | * This product includes software developed by the University of | |
47 | * California, Berkeley and its contributors. | |
48 | * 4. Neither the name of the University nor the names of its contributors | |
49 | * may be used to endorse or promote products derived from this software | |
50 | * without specific prior written permission. | |
51 | * | |
52 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
53 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
54 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
55 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
56 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
57 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
58 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
60 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
61 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
62 | * SUCH DAMAGE. | |
63 | * | |
64 | * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 | |
65 | */ | |
66 | ||
67 | #ifndef _CDEFS_H_ | |
68 | #define _CDEFS_H_ | |
69 | ||
70 | #if defined(__cplusplus) | |
71 | #define __BEGIN_DECLS extern "C" { | |
72 | #define __END_DECLS } | |
73 | #else | |
74 | #define __BEGIN_DECLS | |
75 | #define __END_DECLS | |
76 | #endif | |
77 | ||
316670eb A |
78 | /* This SDK is designed to work with clang and specific versions of |
79 | * gcc >= 4.0 with Apple's patch sets */ | |
80 | #if !defined(__GNUC__) || __GNUC__ < 4 | |
81 | #warning "Unsupported compiler detected" | |
82 | #endif | |
83 | ||
3e170ce0 A |
84 | /* |
85 | * Compatibility with compilers and environments that don't support compiler | |
86 | * feature checking function-like macros. | |
87 | */ | |
88 | #ifndef __has_builtin | |
89 | #define __has_builtin(x) 0 | |
90 | #endif | |
91 | #ifndef __has_include | |
92 | #define __has_include(x) 0 | |
93 | #endif | |
94 | #ifndef __has_feature | |
95 | #define __has_feature(x) 0 | |
96 | #endif | |
97 | #ifndef __has_attribute | |
98 | #define __has_attribute(x) 0 | |
99 | #endif | |
100 | #ifndef __has_extension | |
101 | #define __has_extension(x) 0 | |
102 | #endif | |
103 | ||
1c79356b A |
104 | /* |
105 | * The __CONCAT macro is used to concatenate parts of symbol names, e.g. | |
106 | * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. | |
107 | * The __CONCAT macro is a bit tricky -- make sure you don't put spaces | |
108 | * in between its arguments. __CONCAT can also concatenate double-quoted | |
109 | * strings produced by the __STRING macro, but this only works with ANSI C. | |
110 | */ | |
111 | #if defined(__STDC__) || defined(__cplusplus) | |
112 | #define __P(protos) protos /* full-blown ANSI C */ | |
113 | #define __CONCAT(x,y) x ## y | |
114 | #define __STRING(x) #x | |
115 | ||
116 | #define __const const /* define reserved names to standard */ | |
117 | #define __signed signed | |
118 | #define __volatile volatile | |
119 | #if defined(__cplusplus) | |
120 | #define __inline inline /* convert to C++ keyword */ | |
121 | #else | |
122 | #ifndef __GNUC__ | |
123 | #define __inline /* delete GCC keyword */ | |
124 | #endif /* !__GNUC__ */ | |
125 | #endif /* !__cplusplus */ | |
126 | ||
127 | #else /* !(__STDC__ || __cplusplus) */ | |
128 | #define __P(protos) () /* traditional C preprocessor */ | |
129 | #define __CONCAT(x,y) x/**/y | |
130 | #define __STRING(x) "x" | |
131 | ||
132 | #ifndef __GNUC__ | |
133 | #define __const /* delete pseudo-ANSI C keywords */ | |
134 | #define __inline | |
135 | #define __signed | |
136 | #define __volatile | |
137 | #endif /* !__GNUC__ */ | |
138 | ||
139 | /* | |
140 | * In non-ANSI C environments, new programs will want ANSI-only C keywords | |
141 | * deleted from the program and old programs will want them left alone. | |
142 | * When using a compiler other than gcc, programs using the ANSI C keywords | |
143 | * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. | |
144 | * When using "gcc -traditional", we assume that this is the intent; if | |
145 | * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. | |
146 | */ | |
147 | #ifndef NO_ANSI_KEYWORDS | |
148 | #define const __const /* convert ANSI C keywords */ | |
149 | #define inline __inline | |
150 | #define signed __signed | |
151 | #define volatile __volatile | |
152 | #endif /* !NO_ANSI_KEYWORDS */ | |
153 | #endif /* !(__STDC__ || __cplusplus) */ | |
154 | ||
316670eb A |
155 | #define __dead2 __attribute__((noreturn)) |
156 | #define __pure2 __attribute__((const)) | |
157 | ||
158 | /* __unused denotes variables and functions that may not be used, preventing | |
159 | * the compiler from warning about it if not used. | |
1c79356b | 160 | */ |
316670eb A |
161 | #define __unused __attribute__((unused)) |
162 | ||
163 | /* __used forces variables and functions to be included even if it appears | |
164 | * to the compiler that they are not used (and would thust be discarded). | |
165 | */ | |
166 | #define __used __attribute__((used)) | |
167 | ||
168 | /* __deprecated causes the compiler to produce a warning when encountering | |
39236c6e A |
169 | * code using the deprecated functionality. |
170 | * __deprecated_msg() does the same, and compilers that support it will print | |
171 | * a message along with the deprecation warning. | |
172 | * This may require turning on such warning with the -Wdeprecated flag. | |
173 | * __deprecated_enum_msg() should be used on enums, and compilers that support | |
174 | * it will print the deprecation warning. | |
316670eb A |
175 | */ |
176 | #define __deprecated __attribute__((deprecated)) | |
177 | ||
3e170ce0 A |
178 | #if __has_extension(attribute_deprecated_with_message) || \ |
179 | (defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)))) | |
180 | #define __deprecated_msg(_msg) __attribute__((deprecated(_msg))) | |
39236c6e | 181 | #else |
3e170ce0 | 182 | #define __deprecated_msg(_msg) __attribute__((deprecated)) |
39236c6e A |
183 | #endif |
184 | ||
3e170ce0 A |
185 | #if __has_extension(enumerator_attributes) |
186 | #define __deprecated_enum_msg(_msg) __deprecated_msg(_msg) | |
39236c6e | 187 | #else |
3e170ce0 | 188 | #define __deprecated_enum_msg(_msg) |
39236c6e A |
189 | #endif |
190 | ||
316670eb A |
191 | /* __unavailable causes the compiler to error out when encountering |
192 | * code using the tagged function of variable. | |
193 | */ | |
194 | #define __unavailable __attribute__((unavailable)) | |
1c79356b A |
195 | |
196 | /* Delete pseudo-keywords wherever they are not available or needed. */ | |
197 | #ifndef __dead | |
198 | #define __dead | |
199 | #define __pure | |
200 | #endif | |
6d2010ae | 201 | |
91447636 | 202 | /* |
316670eb A |
203 | * We use `__restrict' as a way to define the `restrict' type qualifier |
204 | * without disturbing older software that is unaware of C99 keywords. | |
91447636 | 205 | */ |
91447636 A |
206 | #if __STDC_VERSION__ < 199901 |
207 | #define __restrict | |
208 | #else | |
209 | #define __restrict restrict | |
210 | #endif | |
91447636 | 211 | |
3e170ce0 A |
212 | /* Compatibility with compilers and environments that don't support the |
213 | * nullability feature. | |
214 | */ | |
215 | ||
216 | #if !__has_feature(nullability) | |
217 | #ifndef __nullable | |
218 | #define __nullable | |
219 | #endif | |
220 | #ifndef __nonnull | |
221 | #define __nonnull | |
222 | #endif | |
223 | #ifndef __null_unspecified | |
224 | #define __null_unspecified | |
225 | #endif | |
39037602 A |
226 | #ifndef _Nullable |
227 | #define _Nullable | |
228 | #endif | |
229 | #ifndef _Nonnull | |
230 | #define _Nonnull | |
231 | #endif | |
232 | #ifndef _Null_unspecified | |
233 | #define _Null_unspecified | |
234 | #endif | |
235 | #endif | |
236 | ||
237 | /* | |
238 | * __disable_tail_calls causes the compiler to not perform tail call | |
239 | * optimization inside the marked function. | |
240 | */ | |
241 | #if __has_attribute(disable_tail_calls) | |
242 | #define __disable_tail_calls __attribute__((__disable_tail_calls__)) | |
243 | #else | |
244 | #define __disable_tail_calls | |
245 | #endif | |
246 | ||
247 | /* | |
248 | * __not_tail_called causes the compiler to prevent tail call optimization | |
249 | * on statically bound calls to the function. It has no effect on indirect | |
250 | * calls. Virtual functions, objective-c methods, and functions marked as | |
251 | * "always_inline" cannot be marked as __not_tail_called. | |
252 | */ | |
253 | #if __has_attribute(not_tail_called) | |
254 | #define __not_tail_called __attribute__((__not_tail_called__)) | |
255 | #else | |
256 | #define __not_tail_called | |
257 | #endif | |
258 | ||
259 | /* | |
260 | * __result_use_check warns callers of a function that not using the function | |
261 | * return value is a bug, i.e. dismissing malloc() return value results in a | |
262 | * memory leak. | |
263 | */ | |
264 | #if __has_attribute(warn_unused_result) | |
265 | #define __result_use_check __attribute__((__warn_unused_result__)) | |
266 | #else | |
267 | #define __result_use_check | |
268 | #endif | |
269 | ||
270 | /* | |
271 | * __swift_unavailable causes the compiler to mark a symbol as specifically | |
272 | * unavailable in Swift, regardless of any other availability in C. | |
273 | */ | |
274 | #if __has_feature(attribute_availability_swift) | |
275 | #define __swift_unavailable(_msg) __attribute__((__availability__(swift, unavailable, message=_msg))) | |
276 | #else | |
277 | #define __swift_unavailable(_msg) | |
3e170ce0 A |
278 | #endif |
279 | ||
39236c6e A |
280 | /* Declaring inline functions within headers is error-prone due to differences |
281 | * across various versions of the C language and extensions. __header_inline | |
282 | * can be used to declare inline functions within system headers. In cases | |
283 | * where you want to force inlining instead of letting the compiler make | |
284 | * the decision, you can use __header_always_inline. | |
285 | * | |
286 | * Be aware that using inline for functions which compilers may also provide | |
287 | * builtins can behave differently under various compilers. If you intend to | |
288 | * provide an inline version of such a function, you may want to use a macro | |
289 | * instead. | |
290 | * | |
291 | * The check for !__GNUC__ || __clang__ is because gcc doesn't correctly | |
292 | * support c99 inline in some cases: | |
293 | * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 | |
294 | */ | |
295 | ||
15129b1c A |
296 | #if defined(__cplusplus) || \ |
297 | (__STDC_VERSION__ >= 199901L && \ | |
298 | !defined(__GNUC_GNU_INLINE__) && \ | |
299 | (!defined(__GNUC__) || defined(__clang__))) | |
39236c6e A |
300 | # define __header_inline inline |
301 | #elif defined(__GNUC__) && defined(__GNUC_STDC_INLINE__) | |
302 | # define __header_inline extern __inline __attribute__((__gnu_inline__)) | |
303 | #elif defined(__GNUC__) | |
304 | # define __header_inline extern __inline | |
305 | #else | |
306 | /* If we land here, we've encountered an unsupported compiler, | |
307 | * so hopefully it understands static __inline as a fallback. | |
308 | */ | |
309 | # define __header_inline static __inline | |
310 | #endif | |
311 | ||
312 | #ifdef __GNUC__ | |
313 | # define __header_always_inline __header_inline __attribute__ ((__always_inline__)) | |
314 | #else | |
315 | /* Unfortunately, we're using a compiler that we don't know how to force to | |
316 | * inline. Oh well. | |
317 | */ | |
318 | # define __header_always_inline __header_inline | |
319 | #endif | |
320 | ||
fe8ab488 A |
321 | /* |
322 | * Compiler-dependent macros that bracket portions of code where the | |
323 | * "-Wunreachable-code" warning should be ignored. Please use sparingly. | |
324 | */ | |
325 | #if defined(__clang__) | |
326 | # define __unreachable_ok_push \ | |
327 | _Pragma("clang diagnostic push") \ | |
328 | _Pragma("clang diagnostic ignored \"-Wunreachable-code\"") | |
329 | # define __unreachable_ok_pop \ | |
330 | _Pragma("clang diagnostic pop") | |
331 | #elif defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) | |
332 | # define __unreachable_ok_push \ | |
333 | _Pragma("GCC diagnostic push") \ | |
334 | _Pragma("GCC diagnostic ignored \"-Wunreachable-code\"") | |
335 | # define __unreachable_ok_pop \ | |
336 | _Pragma("GCC diagnostic pop") | |
337 | #else | |
338 | # define __unreachable_ok_push | |
339 | # define __unreachable_ok_pop | |
340 | #endif | |
341 | ||
91447636 A |
342 | /* |
343 | * Compiler-dependent macros to declare that functions take printf-like | |
344 | * or scanf-like arguments. They are null except for versions of gcc | |
345 | * that are known to support the features properly. Functions declared | |
346 | * with these attributes will cause compilation warnings if there is a | |
347 | * mismatch between the format string and subsequent function parameter | |
348 | * types. | |
349 | */ | |
91447636 A |
350 | #define __printflike(fmtarg, firstvararg) \ |
351 | __attribute__((__format__ (__printf__, fmtarg, firstvararg))) | |
39037602 A |
352 | #define __printf0like(fmtarg, firstvararg) \ |
353 | __attribute__((__format__ (__printf0__, fmtarg, firstvararg))) | |
91447636 A |
354 | #define __scanflike(fmtarg, firstvararg) \ |
355 | __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) | |
91447636 | 356 | |
6d2010ae | 357 | #define __IDSTRING(name,string) static const char name[] __used = string |
1c79356b A |
358 | |
359 | #ifndef __COPYRIGHT | |
360 | #define __COPYRIGHT(s) __IDSTRING(copyright,s) | |
361 | #endif | |
362 | ||
363 | #ifndef __RCSID | |
364 | #define __RCSID(s) __IDSTRING(rcsid,s) | |
365 | #endif | |
366 | ||
367 | #ifndef __SCCSID | |
368 | #define __SCCSID(s) __IDSTRING(sccsid,s) | |
369 | #endif | |
370 | ||
371 | #ifndef __PROJECT_VERSION | |
372 | #define __PROJECT_VERSION(s) __IDSTRING(project_version,s) | |
373 | #endif | |
374 | ||
316670eb A |
375 | /* Source compatibility only, ID string not emitted in object file */ |
376 | #ifndef __FBSDID | |
377 | #define __FBSDID(s) | |
378 | #endif | |
379 | ||
39236c6e A |
380 | #ifndef __DECONST |
381 | #define __DECONST(type, var) __CAST_AWAY_QUALIFIER(var, const, type) | |
382 | #endif | |
383 | ||
384 | #ifndef __DEVOLATILE | |
385 | #define __DEVOLATILE(type, var) __CAST_AWAY_QUALIFIER(var, volatile, type) | |
386 | #endif | |
387 | ||
388 | #ifndef __DEQUALIFY | |
389 | #define __DEQUALIFY(type, var) __CAST_AWAY_QUALIFIER(var, const volatile, type) | |
390 | #endif | |
316670eb | 391 | |
d9a64523 A |
392 | /* |
393 | * __alloc_size can be used to label function arguments that represent the | |
394 | * size of memory that the function allocates and returns. The one-argument | |
395 | * form labels a single argument that gives the allocation size (where the | |
396 | * arguments are numbered from 1): | |
397 | * | |
398 | * void *malloc(size_t __size) __alloc_size(1); | |
399 | * | |
400 | * The two-argument form handles the case where the size is calculated as the | |
401 | * product of two arguments: | |
402 | * | |
403 | * void *calloc(size_t __count, size_t __size) __alloc_size(1,2); | |
404 | */ | |
405 | #ifndef __alloc_size | |
406 | #if __has_attribute(alloc_size) | |
407 | #define __alloc_size(...) __attribute__((alloc_size(__VA_ARGS__))) | |
408 | #else | |
409 | #define __alloc_size(...) | |
410 | #endif | |
411 | #endif // __alloc_size | |
412 | ||
91447636 | 413 | /* |
6d2010ae | 414 | * COMPILATION ENVIRONMENTS -- see compat(5) for additional detail |
2d21ac55 A |
415 | * |
416 | * DEFAULT By default newly complied code will get POSIX APIs plus | |
417 | * Apple API extensions in scope. | |
418 | * | |
419 | * Most users will use this compilation environment to avoid | |
b0d623f7 | 420 | * behavioral differences between 32 and 64 bit code. |
2d21ac55 A |
421 | * |
422 | * LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple | |
423 | * API extensions in scope. | |
424 | * | |
425 | * This is generally equivalent to the Tiger release compilation | |
426 | * environment, except that it cannot be applied to 64 bit code; | |
427 | * its use is discouraged. | |
428 | * | |
429 | * We expect this environment to be deprecated in the future. | |
430 | * | |
431 | * STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the | |
432 | * available APIs to exactly the set of APIs defined by the | |
433 | * corresponding standard, based on the value defined. | |
91447636 | 434 | * |
2d21ac55 A |
435 | * A correct, portable definition for _POSIX_C_SOURCE is 200112L. |
436 | * A correct, portable definition for _XOPEN_SOURCE is 600L. | |
437 | * | |
438 | * Apple API extensions are not visible in this environment, | |
439 | * which can cause Apple specific code to fail to compile, | |
440 | * or behave incorrectly if prototypes are not in scope or | |
441 | * warnings about missing prototypes are not enabled or ignored. | |
442 | * | |
443 | * In any compilation environment, for correct symbol resolution to occur, | |
444 | * function prototypes must be in scope. It is recommended that all Apple | |
b0d623f7 | 445 | * tools users add either the "-Wall" or "-Wimplicit-function-declaration" |
2d21ac55 A |
446 | * compiler flags to their projects to be warned when a function is being |
447 | * used without a prototype in scope. | |
448 | */ | |
449 | ||
593a1d5f A |
450 | /* These settings are particular to each product. */ |
451 | #ifdef KERNEL | |
452 | #define __DARWIN_ONLY_64_BIT_INO_T 0 | |
453 | #define __DARWIN_ONLY_UNIX_CONFORMANCE 0 | |
454 | #define __DARWIN_ONLY_VERS_1050 0 | |
fe8ab488 A |
455 | #if defined(__x86_64__) |
456 | #define __DARWIN_SUF_DARWIN14 "_darwin14" | |
457 | #define __DARWIN14_ALIAS(sym) __asm("_" __STRING(sym) __DARWIN_SUF_DARWIN14) | |
458 | #else | |
459 | #define __DARWIN14_ALIAS(sym) | |
460 | #endif | |
593a1d5f | 461 | #else /* !KERNEL */ |
6d2010ae A |
462 | #ifdef PLATFORM_iPhoneOS |
463 | /* Platform: iPhoneOS */ | |
593a1d5f A |
464 | #define __DARWIN_ONLY_64_BIT_INO_T 1 |
465 | #define __DARWIN_ONLY_UNIX_CONFORMANCE 1 | |
466 | #define __DARWIN_ONLY_VERS_1050 1 | |
6d2010ae A |
467 | #endif /* PLATFORM_iPhoneOS */ |
468 | #ifdef PLATFORM_iPhoneSimulator | |
469 | /* Platform: iPhoneSimulator */ | |
593a1d5f A |
470 | #define __DARWIN_ONLY_64_BIT_INO_T 1 |
471 | #define __DARWIN_ONLY_UNIX_CONFORMANCE 1 | |
472 | #define __DARWIN_ONLY_VERS_1050 1 | |
6d2010ae | 473 | #endif /* PLATFORM_iPhoneSimulator */ |
3e170ce0 A |
474 | #ifdef PLATFORM_tvOS |
475 | /* Platform: tvOS */ | |
476 | #define __DARWIN_ONLY_64_BIT_INO_T 1 | |
477 | #define __DARWIN_ONLY_UNIX_CONFORMANCE 1 | |
478 | #define __DARWIN_ONLY_VERS_1050 1 | |
479 | #endif /* PLATFORM_tvOS */ | |
480 | #ifdef PLATFORM_AppleTVOS | |
481 | /* Platform: AppleTVOS */ | |
482 | #define __DARWIN_ONLY_64_BIT_INO_T 1 | |
483 | #define __DARWIN_ONLY_UNIX_CONFORMANCE 1 | |
484 | #define __DARWIN_ONLY_VERS_1050 1 | |
485 | #endif /* PLATFORM_AppleTVOS */ | |
486 | #ifdef PLATFORM_tvSimulator | |
487 | /* Platform: tvSimulator */ | |
488 | #define __DARWIN_ONLY_64_BIT_INO_T 1 | |
489 | #define __DARWIN_ONLY_UNIX_CONFORMANCE 1 | |
490 | #define __DARWIN_ONLY_VERS_1050 1 | |
491 | #endif /* PLATFORM_tvSimulator */ | |
492 | #ifdef PLATFORM_AppleTVSimulator | |
493 | /* Platform: AppleTVSimulator */ | |
494 | #define __DARWIN_ONLY_64_BIT_INO_T 1 | |
495 | #define __DARWIN_ONLY_UNIX_CONFORMANCE 1 | |
496 | #define __DARWIN_ONLY_VERS_1050 1 | |
497 | #endif /* PLATFORM_AppleTVSimulator */ | |
fe8ab488 A |
498 | #ifdef PLATFORM_iPhoneOSNano |
499 | /* Platform: iPhoneOSNano */ | |
500 | #define __DARWIN_ONLY_64_BIT_INO_T 1 | |
501 | #define __DARWIN_ONLY_UNIX_CONFORMANCE 1 | |
502 | #define __DARWIN_ONLY_VERS_1050 1 | |
503 | #endif /* PLATFORM_iPhoneOSNano */ | |
504 | #ifdef PLATFORM_iPhoneNanoSimulator | |
505 | /* Platform: iPhoneNanoSimulator */ | |
506 | #define __DARWIN_ONLY_64_BIT_INO_T 1 | |
507 | #define __DARWIN_ONLY_UNIX_CONFORMANCE 1 | |
508 | #define __DARWIN_ONLY_VERS_1050 1 | |
509 | #endif /* PLATFORM_iPhoneNanoSimulator */ | |
3e170ce0 A |
510 | #ifdef PLATFORM_WatchOS |
511 | /* Platform: WatchOS */ | |
512 | #define __DARWIN_ONLY_64_BIT_INO_T 1 | |
513 | #define __DARWIN_ONLY_UNIX_CONFORMANCE 1 | |
514 | #define __DARWIN_ONLY_VERS_1050 1 | |
515 | #endif /* PLATFORM_WatchOS */ | |
516 | #ifdef PLATFORM_WatchSimulator | |
517 | /* Platform: WatchSimulator */ | |
518 | #define __DARWIN_ONLY_64_BIT_INO_T 1 | |
519 | #define __DARWIN_ONLY_UNIX_CONFORMANCE 1 | |
520 | #define __DARWIN_ONLY_VERS_1050 1 | |
521 | #endif /* PLATFORM_WatchSimulator */ | |
5ba3f43e A |
522 | #ifdef PLATFORM_BridgeOS |
523 | /* Platform: BridgeOS */ | |
524 | #define __DARWIN_ONLY_64_BIT_INO_T 1 | |
525 | #define __DARWIN_ONLY_UNIX_CONFORMANCE 1 | |
526 | #define __DARWIN_ONLY_VERS_1050 1 | |
527 | #endif /* PLATFORM_BridgeOS */ | |
6d2010ae A |
528 | #ifdef PLATFORM_MacOSX |
529 | /* Platform: MacOSX */ | |
593a1d5f A |
530 | #define __DARWIN_ONLY_64_BIT_INO_T 0 |
531 | /* #undef __DARWIN_ONLY_UNIX_CONFORMANCE (automatically set for 64-bit) */ | |
532 | #define __DARWIN_ONLY_VERS_1050 0 | |
6d2010ae | 533 | #endif /* PLATFORM_MacOSX */ |
593a1d5f A |
534 | #endif /* KERNEL */ |
535 | ||
2d21ac55 A |
536 | /* |
537 | * The __DARWIN_ALIAS macros are used to do symbol renaming; they allow | |
b0d623f7 | 538 | * legacy code to use the old symbol, thus maintaining binary compatibility |
2d21ac55 | 539 | * while new code can use a standards compliant version of the same function. |
91447636 A |
540 | * |
541 | * __DARWIN_ALIAS is used by itself if the function signature has not | |
542 | * changed, it is used along with a #ifdef check for __DARWIN_UNIX03 | |
b0d623f7 A |
543 | * if the signature has changed. Because the __LP64__ environment |
544 | * only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be | |
91447636 | 545 | * defined, but causes __DARWIN_ALIAS to do no symbol mangling. |
2d21ac55 A |
546 | * |
547 | * As a special case, when XCode is used to target a specific version of the | |
548 | * OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ | |
549 | * will be defined by the compiler, with the digits representing major version | |
b0d623f7 | 550 | * time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting |
2d21ac55 A |
551 | * pre-10.5, and it is the default compilation environment, revert the |
552 | * compilation environment to pre-__DARWIN_UNIX03. | |
91447636 | 553 | */ |
593a1d5f A |
554 | #if !defined(__DARWIN_ONLY_UNIX_CONFORMANCE) |
555 | # if defined(__LP64__) | |
556 | # define __DARWIN_ONLY_UNIX_CONFORMANCE 1 | |
557 | # else /* !__LP64__ */ | |
558 | # define __DARWIN_ONLY_UNIX_CONFORMANCE 0 | |
559 | # endif /* __LP64__ */ | |
560 | #endif /* !__DARWIN_ONLY_UNIX_CONFORMANCE */ | |
561 | ||
91447636 | 562 | #if !defined(__DARWIN_UNIX03) |
593a1d5f A |
563 | # if defined(KERNEL) |
564 | # define __DARWIN_UNIX03 0 | |
565 | # elif __DARWIN_ONLY_UNIX_CONFORMANCE | |
2d21ac55 | 566 | # if defined(_NONSTD_SOURCE) |
593a1d5f | 567 | # error "Can't define _NONSTD_SOURCE when only UNIX conformance is available." |
2d21ac55 A |
568 | # endif /* _NONSTD_SOURCE */ |
569 | # define __DARWIN_UNIX03 1 | |
6d2010ae A |
570 | # elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1040) |
571 | # define __DARWIN_UNIX03 0 | |
593a1d5f A |
572 | # elif defined(_DARWIN_C_SOURCE) || defined(_XOPEN_SOURCE) || defined(_POSIX_C_SOURCE) |
573 | # if defined(_NONSTD_SOURCE) | |
574 | # error "Can't define both _NONSTD_SOURCE and any of _DARWIN_C_SOURCE, _XOPEN_SOURCE or _POSIX_C_SOURCE." | |
575 | # endif /* _NONSTD_SOURCE */ | |
576 | # define __DARWIN_UNIX03 1 | |
577 | # elif defined(_NONSTD_SOURCE) | |
2d21ac55 A |
578 | # define __DARWIN_UNIX03 0 |
579 | # else /* default */ | |
580 | # if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1050) | |
581 | # define __DARWIN_UNIX03 0 | |
582 | # else /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 */ | |
583 | # define __DARWIN_UNIX03 1 | |
584 | # endif /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 */ | |
585 | # endif /* _DARWIN_C_SOURCE || _XOPEN_SOURCE || _POSIX_C_SOURCE || __LP64__ */ | |
91447636 A |
586 | #endif /* !__DARWIN_UNIX03 */ |
587 | ||
2d21ac55 | 588 | #if !defined(__DARWIN_64_BIT_INO_T) |
593a1d5f A |
589 | # if defined(KERNEL) |
590 | # define __DARWIN_64_BIT_INO_T 0 | |
591 | # elif defined(_DARWIN_USE_64_BIT_INODE) | |
592 | # if defined(_DARWIN_NO_64_BIT_INODE) | |
593 | # error "Can't define both _DARWIN_USE_64_BIT_INODE and _DARWIN_NO_64_BIT_INODE." | |
594 | # endif /* _DARWIN_NO_64_BIT_INODE */ | |
2d21ac55 | 595 | # define __DARWIN_64_BIT_INO_T 1 |
593a1d5f A |
596 | # elif defined(_DARWIN_NO_64_BIT_INODE) |
597 | # if __DARWIN_ONLY_64_BIT_INO_T | |
598 | # error "Can't define _DARWIN_NO_64_BIT_INODE when only 64-bit inodes are available." | |
599 | # endif /* __DARWIN_ONLY_64_BIT_INO_T */ | |
2d21ac55 A |
600 | # define __DARWIN_64_BIT_INO_T 0 |
601 | # else /* default */ | |
593a1d5f A |
602 | # if __DARWIN_ONLY_64_BIT_INO_T |
603 | # define __DARWIN_64_BIT_INO_T 1 | |
b0d623f7 | 604 | # elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1060) || __DARWIN_UNIX03 == 0 |
593a1d5f | 605 | # define __DARWIN_64_BIT_INO_T 0 |
b0d623f7 A |
606 | # else /* default */ |
607 | # define __DARWIN_64_BIT_INO_T 1 | |
593a1d5f | 608 | # endif /* __DARWIN_ONLY_64_BIT_INO_T */ |
2d21ac55 A |
609 | # endif |
610 | #endif /* !__DARWIN_64_BIT_INO_T */ | |
611 | ||
593a1d5f | 612 | #if !defined(__DARWIN_VERS_1050) |
2d21ac55 | 613 | # if defined(KERNEL) |
593a1d5f A |
614 | # define __DARWIN_VERS_1050 0 |
615 | # elif __DARWIN_ONLY_VERS_1050 | |
616 | # define __DARWIN_VERS_1050 1 | |
b0d623f7 | 617 | # elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) < 1050) || __DARWIN_UNIX03 == 0 |
593a1d5f | 618 | # define __DARWIN_VERS_1050 0 |
b0d623f7 A |
619 | # else /* default */ |
620 | # define __DARWIN_VERS_1050 1 | |
2d21ac55 | 621 | # endif |
593a1d5f | 622 | #endif /* !__DARWIN_VERS_1050 */ |
2d21ac55 | 623 | |
593a1d5f A |
624 | #if !defined(__DARWIN_NON_CANCELABLE) |
625 | # if defined(KERNEL) | |
626 | # define __DARWIN_NON_CANCELABLE 0 | |
2d21ac55 | 627 | # else /* default */ |
593a1d5f | 628 | # define __DARWIN_NON_CANCELABLE 0 |
2d21ac55 A |
629 | # endif |
630 | #endif /* !__DARWIN_NON_CANCELABLE */ | |
631 | ||
632 | /* | |
633 | * symbol suffixes used for symbol versioning | |
634 | */ | |
635 | #if __DARWIN_UNIX03 | |
593a1d5f | 636 | # if __DARWIN_ONLY_UNIX_CONFORMANCE |
2d21ac55 | 637 | # define __DARWIN_SUF_UNIX03 /* nothing */ |
593a1d5f A |
638 | # else /* !__DARWIN_ONLY_UNIX_CONFORMANCE */ |
639 | # define __DARWIN_SUF_UNIX03 "$UNIX2003" | |
640 | # endif /* __DARWIN_ONLY_UNIX_CONFORMANCE */ | |
2d21ac55 A |
641 | |
642 | # if __DARWIN_64_BIT_INO_T | |
593a1d5f A |
643 | # if __DARWIN_ONLY_64_BIT_INO_T |
644 | # define __DARWIN_SUF_64_BIT_INO_T /* nothing */ | |
645 | # else /* !__DARWIN_ONLY_64_BIT_INO_T */ | |
646 | # define __DARWIN_SUF_64_BIT_INO_T "$INODE64" | |
647 | # endif /* __DARWIN_ONLY_64_BIT_INO_T */ | |
2d21ac55 A |
648 | # else /* !__DARWIN_64_BIT_INO_T */ |
649 | # define __DARWIN_SUF_64_BIT_INO_T /* nothing */ | |
593a1d5f A |
650 | # endif /* __DARWIN_64_BIT_INO_T */ |
651 | ||
652 | # if __DARWIN_VERS_1050 | |
653 | # if __DARWIN_ONLY_VERS_1050 | |
654 | # define __DARWIN_SUF_1050 /* nothing */ | |
655 | # else /* !__DARWIN_ONLY_VERS_1050 */ | |
656 | # define __DARWIN_SUF_1050 "$1050" | |
657 | # endif /* __DARWIN_ONLY_VERS_1050 */ | |
658 | # else /* !__DARWIN_VERS_1050 */ | |
659 | # define __DARWIN_SUF_1050 /* nothing */ | |
660 | # endif /* __DARWIN_VERS_1050 */ | |
2d21ac55 A |
661 | |
662 | # if __DARWIN_NON_CANCELABLE | |
663 | # define __DARWIN_SUF_NON_CANCELABLE "$NOCANCEL" | |
664 | # else /* !__DARWIN_NON_CANCELABLE */ | |
665 | # define __DARWIN_SUF_NON_CANCELABLE /* nothing */ | |
666 | # endif /* __DARWIN_NON_CANCELABLE */ | |
667 | ||
2d21ac55 A |
668 | #else /* !__DARWIN_UNIX03 */ |
669 | # define __DARWIN_SUF_UNIX03 /* nothing */ | |
2d21ac55 A |
670 | # define __DARWIN_SUF_64_BIT_INO_T /* nothing */ |
671 | # define __DARWIN_SUF_NON_CANCELABLE /* nothing */ | |
672 | # define __DARWIN_SUF_1050 /* nothing */ | |
673 | #endif /* __DARWIN_UNIX03 */ | |
674 | ||
675 | #define __DARWIN_SUF_EXTSN "$DARWIN_EXTSN" | |
676 | ||
677 | /* | |
678 | * symbol versioning macros | |
679 | */ | |
680 | #define __DARWIN_ALIAS(sym) __asm("_" __STRING(sym) __DARWIN_SUF_UNIX03) | |
681 | #define __DARWIN_ALIAS_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03) | |
682 | #define __DARWIN_ALIAS_I(sym) __asm("_" __STRING(sym) __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03) | |
fe8ab488 | 683 | #define __DARWIN_NOCANCEL(sym) __asm("_" __STRING(sym) __DARWIN_SUF_NON_CANCELABLE) |
2d21ac55 A |
684 | #define __DARWIN_INODE64(sym) __asm("_" __STRING(sym) __DARWIN_SUF_64_BIT_INO_T) |
685 | ||
686 | #define __DARWIN_1050(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050) | |
687 | #define __DARWIN_1050ALIAS(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_UNIX03) | |
688 | #define __DARWIN_1050ALIAS_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03) | |
689 | #define __DARWIN_1050ALIAS_I(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03) | |
690 | #define __DARWIN_1050INODE64(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_64_BIT_INO_T) | |
691 | ||
692 | #define __DARWIN_EXTSN(sym) __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN) | |
693 | #define __DARWIN_EXTSN_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN __DARWIN_SUF_NON_CANCELABLE) | |
91447636 | 694 | |
b0d623f7 A |
695 | /* |
696 | * symbol release macros | |
697 | */ | |
6d2010ae A |
698 | #ifdef KERNEL |
699 | #define __DARWIN_ALIAS_STARTING(_mac, _iphone, x) | |
700 | #else | |
701 | #include <sys/_symbol_aliasing.h> | |
702 | ||
316670eb | 703 | #if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) |
6d2010ae A |
704 | #define __DARWIN_ALIAS_STARTING(_mac, _iphone, x) __DARWIN_ALIAS_STARTING_IPHONE_##_iphone(x) |
705 | #elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) | |
706 | #define __DARWIN_ALIAS_STARTING(_mac, _iphone, x) __DARWIN_ALIAS_STARTING_MAC_##_mac(x) | |
707 | #else | |
3e170ce0 | 708 | #define __DARWIN_ALIAS_STARTING(_mac, _iphone, x) x |
b0d623f7 | 709 | #endif |
6d2010ae | 710 | #endif /* KERNEL */ |
b0d623f7 | 711 | |
91447636 A |
712 | |
713 | /* | |
714 | * POSIX.1 requires that the macros we test be defined before any standard | |
715 | * header file is included. This permits us to convert values for feature | |
716 | * testing, as necessary, using only _POSIX_C_SOURCE. | |
717 | * | |
718 | * Here's a quick run-down of the versions: | |
719 | * defined(_POSIX_SOURCE) 1003.1-1988 | |
720 | * _POSIX_C_SOURCE == 1L 1003.1-1990 | |
721 | * _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option | |
722 | * _POSIX_C_SOURCE == 199309L 1003.1b-1993 | |
723 | * _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, | |
724 | * and the omnibus ISO/IEC 9945-1: 1996 | |
725 | * _POSIX_C_SOURCE == 200112L 1003.1-2001 | |
6d2010ae | 726 | * _POSIX_C_SOURCE == 200809L 1003.1-2008 |
91447636 A |
727 | * |
728 | * In addition, the X/Open Portability Guide, which is now the Single UNIX | |
729 | * Specification, defines a feature-test macro which indicates the version of | |
730 | * that specification, and which subsumes _POSIX_C_SOURCE. | |
731 | */ | |
732 | ||
733 | /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. */ | |
734 | #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1L | |
735 | #undef _POSIX_C_SOURCE | |
736 | #define _POSIX_C_SOURCE 199009L | |
737 | #endif | |
738 | ||
739 | /* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. */ | |
740 | #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2L | |
741 | #undef _POSIX_C_SOURCE | |
742 | #define _POSIX_C_SOURCE 199209L | |
743 | #endif | |
744 | ||
745 | /* Deal with various X/Open Portability Guides and Single UNIX Spec. */ | |
746 | #ifdef _XOPEN_SOURCE | |
6d2010ae A |
747 | #if _XOPEN_SOURCE - 0L >= 700L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 200809L) |
748 | #undef _POSIX_C_SOURCE | |
749 | #define _POSIX_C_SOURCE 200809L | |
750 | #elif _XOPEN_SOURCE - 0L >= 600L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 200112L) | |
91447636 A |
751 | #undef _POSIX_C_SOURCE |
752 | #define _POSIX_C_SOURCE 200112L | |
6d2010ae | 753 | #elif _XOPEN_SOURCE - 0L >= 500L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 199506L) |
91447636 A |
754 | #undef _POSIX_C_SOURCE |
755 | #define _POSIX_C_SOURCE 199506L | |
756 | #endif | |
757 | #endif | |
758 | ||
759 | /* | |
760 | * Deal with all versions of POSIX. The ordering relative to the tests above is | |
761 | * important. | |
762 | */ | |
763 | #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) | |
764 | #define _POSIX_C_SOURCE 198808L | |
765 | #endif | |
766 | ||
6d2010ae A |
767 | /* POSIX C deprecation macros */ |
768 | #ifdef KERNEL | |
769 | #define __POSIX_C_DEPRECATED(ver) | |
770 | #else | |
771 | #include <sys/_posix_availability.h> | |
772 | ||
773 | #define __POSIX_C_DEPRECATED(ver) ___POSIX_C_DEPRECATED_STARTING_##ver | |
774 | #endif | |
775 | ||
776 | /* | |
777 | * Set a single macro which will always be defined and can be used to determine | |
778 | * the appropriate namespace. For POSIX, these values will correspond to | |
779 | * _POSIX_C_SOURCE value. Currently there are two additional levels corresponding | |
780 | * to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) | |
781 | */ | |
782 | #define __DARWIN_C_ANSI 010000L | |
783 | #define __DARWIN_C_FULL 900000L | |
784 | ||
785 | #if defined(_ANSI_SOURCE) | |
786 | #define __DARWIN_C_LEVEL __DARWIN_C_ANSI | |
787 | #elif defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE) && !defined(_NONSTD_SOURCE) | |
788 | #define __DARWIN_C_LEVEL _POSIX_C_SOURCE | |
789 | #else | |
790 | #define __DARWIN_C_LEVEL __DARWIN_C_FULL | |
791 | #endif | |
792 | ||
39236c6e A |
793 | /* If the developer has neither requested a strict language mode nor a version |
794 | * of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part | |
795 | * of __DARWIN_C_FULL. | |
796 | */ | |
797 | #if !defined(__STDC_WANT_LIB_EXT1__) && !defined(__STRICT_ANSI__) && __DARWIN_C_LEVEL >= __DARWIN_C_FULL | |
798 | #define __STDC_WANT_LIB_EXT1__ 1 | |
799 | #endif | |
6d2010ae | 800 | |
91447636 A |
801 | /* |
802 | * long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and | |
803 | * c99 still want long longs. While not perfect, we allow long longs for | |
804 | * g++. | |
805 | */ | |
a39ff7e2 A |
806 | #if (defined(__STRICT_ANSI__) && (__STDC_VERSION__-0 < 199901L) && !defined(__GNUG__)) |
807 | #define __DARWIN_NO_LONG_LONG 1 | |
808 | #else | |
809 | #define __DARWIN_NO_LONG_LONG 0 | |
810 | #endif | |
91447636 | 811 | |
2d21ac55 A |
812 | /***************************************** |
813 | * Public darwin-specific feature macros | |
814 | *****************************************/ | |
815 | ||
593a1d5f A |
816 | /* |
817 | * _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and | |
818 | * structures modified for 64-bit inodes (like struct stat) will be used. | |
819 | */ | |
820 | #if __DARWIN_64_BIT_INO_T | |
821 | #define _DARWIN_FEATURE_64_BIT_INODE 1 | |
822 | #endif | |
823 | ||
2d21ac55 | 824 | /* |
593a1d5f A |
825 | * _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only |
826 | * be 64-bit; there is no support for 32-bit ino_t when this macro is defined | |
827 | * (and non-zero). There is no struct stat64 either, as the regular | |
828 | * struct stat will already be the 64-bit version. | |
2d21ac55 | 829 | */ |
593a1d5f A |
830 | #if __DARWIN_ONLY_64_BIT_INO_T |
831 | #define _DARWIN_FEATURE_ONLY_64_BIT_INODE 1 | |
2d21ac55 A |
832 | #endif |
833 | ||
834 | /* | |
593a1d5f A |
835 | * _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated |
836 | * in 10.5 exists; no pre-10.5 variants are available. | |
2d21ac55 | 837 | */ |
593a1d5f A |
838 | #if __DARWIN_ONLY_VERS_1050 |
839 | #define _DARWIN_FEATURE_ONLY_VERS_1050 1 | |
840 | #endif | |
841 | ||
842 | /* | |
843 | * _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API | |
844 | * are available (the legacy BSD APIs are not available) | |
845 | */ | |
846 | #if __DARWIN_ONLY_UNIX_CONFORMANCE | |
847 | #define _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE 1 | |
848 | #endif | |
849 | ||
850 | /* | |
851 | * _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, | |
852 | * and specifies the conformance level (3 is SUSv3) | |
853 | */ | |
854 | #if __DARWIN_UNIX03 | |
855 | #define _DARWIN_FEATURE_UNIX_CONFORMANCE 3 | |
2d21ac55 A |
856 | #endif |
857 | ||
b0d623f7 A |
858 | /* |
859 | * This macro casts away the qualifier from the variable | |
860 | * | |
861 | * Note: use at your own risk, removing qualifiers can result in | |
862 | * catastrophic run-time failures. | |
863 | */ | |
864 | #ifndef __CAST_AWAY_QUALIFIER | |
6d2010ae | 865 | #define __CAST_AWAY_QUALIFIER(variable, qualifier, type) (type) (long)(variable) |
b0d623f7 A |
866 | #endif |
867 | ||
39236c6e A |
868 | /* |
869 | * __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be | |
870 | * used from other compilation units, but not other libraries or executables. | |
871 | */ | |
872 | #ifndef __XNU_PRIVATE_EXTERN | |
873 | #define __XNU_PRIVATE_EXTERN __attribute__((visibility("hidden"))) | |
874 | #endif | |
875 | ||
876 | /* | |
877 | * Architecture validation for current SDK | |
878 | */ | |
879 | #if !defined(__sys_cdefs_arch_unknown__) && defined(__i386__) | |
880 | #elif !defined(__sys_cdefs_arch_unknown__) && defined(__x86_64__) | |
5ba3f43e A |
881 | #elif !defined(__sys_cdefs_arch_unknown__) && defined(__arm__) |
882 | #elif !defined(__sys_cdefs_arch_unknown__) && defined(__arm64__) | |
39236c6e A |
883 | #else |
884 | #error Unsupported architecture | |
885 | #endif | |
886 | ||
3e170ce0 A |
887 | #ifdef XNU_KERNEL_PRIVATE |
888 | /* | |
889 | * Selectively ignore cast alignment warnings | |
890 | */ | |
891 | #define __IGNORE_WCASTALIGN(x) _Pragma("clang diagnostic push") \ | |
892 | _Pragma("clang diagnostic ignored \"-Wcast-align\"") \ | |
893 | x; \ | |
894 | _Pragma("clang diagnostic pop") | |
895 | #endif | |
896 | ||
d9a64523 A |
897 | #if defined(PRIVATE) || defined(KERNEL) |
898 | /* | |
899 | * Check if __probable and __improbable have already been defined elsewhere. | |
900 | * These macros inform the compiler (and humans) about which branches are likely | |
901 | * to be taken. | |
902 | */ | |
903 | #if !defined(__probable) && !defined(__improbable) | |
904 | #define __probable(x) __builtin_expect(!!(x), 1) | |
905 | #define __improbable(x) __builtin_expect(!!(x), 0) | |
906 | #endif /* !defined(__probable) && !defined(__improbable) */ | |
907 | ||
908 | #define __container_of(ptr, type, field) ({ \ | |
909 | const typeof(((type *)0)->field) *__ptr = (ptr); \ | |
910 | (type *)((uintptr_t)__ptr - offsetof(type, field)); \ | |
911 | }) | |
912 | ||
913 | #endif /* KERNEL || PRIVATE */ | |
914 | ||
915 | #define __compiler_barrier() __asm__ __volatile__("" ::: "memory") | |
916 | ||
1c79356b | 917 | #endif /* !_CDEFS_H_ */ |