1 /* 2 * Copyright (c) 2000-2018 Apple Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 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. 14 * 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 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 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. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 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 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 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 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 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. 160 */ 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 /* __cold marks code used for debugging or that is rarely taken 169 * and tells the compiler to optimize for size and outline code. 170 */ 171 #if __has_attribute(cold) 172 #define __cold __attribute__((__cold__)) 173 #else 174 #define __cold 175 #endif 176 177 /* __exported denotes symbols that should be exported even when symbols 178 * are hidden by default. 179 * __exported_push/_exported_pop are pragmas used to delimit a range of 180 * symbols that should be exported even when symbols are hidden by default. 181 */ 182 #define __exported __attribute__((__visibility__("default"))) 183 #define __exported_push _Pragma("GCC visibility push(default)") 184 #define __exported_pop _Pragma("GCC visibility pop") 185 186 /* __deprecated causes the compiler to produce a warning when encountering 187 * code using the deprecated functionality. 188 * __deprecated_msg() does the same, and compilers that support it will print 189 * a message along with the deprecation warning. 190 * This may require turning on such warning with the -Wdeprecated flag. 191 * __deprecated_enum_msg() should be used on enums, and compilers that support 192 * it will print the deprecation warning. 193 * __kpi_deprecated() specifically indicates deprecation of kernel programming 194 * interfaces in Kernel.framework used by KEXTs. 195 */ 196 #define __deprecated __attribute__((__deprecated__)) 197 198 #if __has_extension(attribute_deprecated_with_message) || \ 199 (defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)))) 200 #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg))) 201 #else 202 #define __deprecated_msg(_msg) __attribute__((__deprecated__)) 203 #endif 204 205 #if __has_extension(enumerator_attributes) 206 #define __deprecated_enum_msg(_msg) __deprecated_msg(_msg) 207 #else 208 #define __deprecated_enum_msg(_msg) 209 #endif 210 211 #define __kpi_deprecated(_msg) 212 213 /* __unavailable causes the compiler to error out when encountering 214 * code using the tagged function 215 */ 216 #if __has_attribute(unavailable) 217 #define __unavailable __attribute__((__unavailable__)) 218 #else 219 #define __unavailable 220 #endif 221 222 #define __kpi_unavailable 223 224 #define __kpi_deprecated_arm64_macos_unavailable 225 226 /* Delete pseudo-keywords wherever they are not available or needed. */ 227 #ifndef __dead 228 #define __dead 229 #define __pure 230 #endif 231 232 /* 233 * We use `__restrict' as a way to define the `restrict' type qualifier 234 * without disturbing older software that is unaware of C99 keywords. 235 */ 236 #if __STDC_VERSION__ < 199901 237 #define __restrict 238 #else 239 #define __restrict restrict 240 #endif 241 242 /* Compatibility with compilers and environments that don't support the 243 * nullability feature. 244 */ 245 246 #if !__has_feature(nullability) 247 #ifndef __nullable 248 #define __nullable 249 #endif 250 #ifndef __nonnull 251 #define __nonnull 252 #endif 253 #ifndef __null_unspecified 254 #define __null_unspecified 255 #endif 256 #ifndef _Nullable 257 #define _Nullable 258 #endif 259 #ifndef _Nonnull 260 #define _Nonnull 261 #endif 262 #ifndef _Null_unspecified 263 #define _Null_unspecified 264 #endif 265 #endif 266 267 /* 268 * __disable_tail_calls causes the compiler to not perform tail call 269 * optimization inside the marked function. 270 */ 271 #if __has_attribute(disable_tail_calls) 272 #define __disable_tail_calls __attribute__((__disable_tail_calls__)) 273 #else 274 #define __disable_tail_calls 275 #endif 276 277 /* 278 * __not_tail_called causes the compiler to prevent tail call optimization 279 * on statically bound calls to the function. It has no effect on indirect 280 * calls. Virtual functions, objective-c methods, and functions marked as 281 * "always_inline" cannot be marked as __not_tail_called. 282 */ 283 #if __has_attribute(not_tail_called) 284 #define __not_tail_called __attribute__((__not_tail_called__)) 285 #else 286 #define __not_tail_called 287 #endif 288 289 /* 290 * __result_use_check warns callers of a function that not using the function 291 * return value is a bug, i.e. dismissing malloc() return value results in a 292 * memory leak. 293 */ 294 #if __has_attribute(warn_unused_result) 295 #define __result_use_check __attribute__((__warn_unused_result__)) 296 #else 297 #define __result_use_check 298 #endif 299 300 /* 301 * __swift_unavailable causes the compiler to mark a symbol as specifically 302 * unavailable in Swift, regardless of any other availability in C. 303 */ 304 #if __has_feature(attribute_availability_swift) 305 #define __swift_unavailable(_msg) __attribute__((__availability__(swift, unavailable, message=_msg))) 306 #else 307 #define __swift_unavailable(_msg) 308 #endif 309 310 /* 311 * __abortlike is the attribute to put on functions like abort() that are 312 * typically used to mark assertions. These optimize the codegen 313 * for outlining while still maintaining debugability. 314 */ 315 #ifndef __abortlike 316 #define __abortlike __dead2 __cold __not_tail_called 317 #endif 318 319 /* Declaring inline functions within headers is error-prone due to differences 320 * across various versions of the C language and extensions. __header_inline 321 * can be used to declare inline functions within system headers. In cases 322 * where you want to force inlining instead of letting the compiler make 323 * the decision, you can use __header_always_inline. 324 * 325 * Be aware that using inline for functions which compilers may also provide 326 * builtins can behave differently under various compilers. If you intend to 327 * provide an inline version of such a function, you may want to use a macro 328 * instead. 329 * 330 * The check for !__GNUC__ || __clang__ is because gcc doesn't correctly 331 * support c99 inline in some cases: 332 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 333 */ 334 335 #if defined(__cplusplus) || \ 336 (__STDC_VERSION__ >= 199901L && \ 337 !defined(__GNUC_GNU_INLINE__) && \ 338 (!defined(__GNUC__) || defined(__clang__))) 339 # define __header_inline inline 340 #elif defined(__GNUC__) && defined(__GNUC_STDC_INLINE__) 341 # define __header_inline extern __inline __attribute__((__gnu_inline__)) 342 #elif defined(__GNUC__) 343 # define __header_inline extern __inline 344 #else 345 /* If we land here, we've encountered an unsupported compiler, 346 * so hopefully it understands static __inline as a fallback. 347 */ 348 # define __header_inline static __inline 349 #endif 350 351 #ifdef __GNUC__ 352 # define __header_always_inline __header_inline __attribute__ ((__always_inline__)) 353 #else 354 /* Unfortunately, we're using a compiler that we don't know how to force to 355 * inline. Oh well. 356 */ 357 # define __header_always_inline __header_inline 358 #endif 359 360 /* 361 * Compiler-dependent macros that bracket portions of code where the 362 * "-Wunreachable-code" warning should be ignored. Please use sparingly. 363 */ 364 #if defined(__clang__) 365 # define __unreachable_ok_push \ 366 _Pragma("clang diagnostic push") \ 367 _Pragma("clang diagnostic ignored \"-Wunreachable-code\"") 368 # define __unreachable_ok_pop \ 369 _Pragma("clang diagnostic pop") 370 #elif defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) 371 # define __unreachable_ok_push \ 372 _Pragma("GCC diagnostic push") \ 373 _Pragma("GCC diagnostic ignored \"-Wunreachable-code\"") 374 # define __unreachable_ok_pop \ 375 _Pragma("GCC diagnostic pop") 376 #else 377 # define __unreachable_ok_push 378 # define __unreachable_ok_pop 379 #endif 380 381 /* 382 * Compiler-dependent macros to declare that functions take printf-like 383 * or scanf-like arguments. They are null except for versions of gcc 384 * that are known to support the features properly. Functions declared 385 * with these attributes will cause compilation warnings if there is a 386 * mismatch between the format string and subsequent function parameter 387 * types. 388 */ 389 #define __printflike(fmtarg, firstvararg) \ 390 __attribute__((__format__ (__printf__, fmtarg, firstvararg))) 391 #define __printf0like(fmtarg, firstvararg) \ 392 __attribute__((__format__ (__printf0__, fmtarg, firstvararg))) 393 #define __scanflike(fmtarg, firstvararg) \ 394 __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) 395 396 #define __IDSTRING(name, string) static const char name[] __used = string 397 398 #ifndef __COPYRIGHT 399 #define __COPYRIGHT(s) __IDSTRING(copyright,s) 400 #endif 401 402 #ifndef __RCSID 403 #define __RCSID(s) __IDSTRING(rcsid,s) 404 #endif 405 406 #ifndef __SCCSID 407 #define __SCCSID(s) __IDSTRING(sccsid,s) 408 #endif 409 410 #ifndef __PROJECT_VERSION 411 #define __PROJECT_VERSION(s) __IDSTRING(project_version,s) 412 #endif 413 414 /* Source compatibility only, ID string not emitted in object file */ 415 #ifndef __FBSDID 416 #define __FBSDID(s) 417 #endif 418 419 #ifndef __DECONST 420 #define __DECONST(type, var) __CAST_AWAY_QUALIFIER(var, const, type) 421 #endif 422 423 #ifndef __DEVOLATILE 424 #define __DEVOLATILE(type, var) __CAST_AWAY_QUALIFIER(var, volatile, type) 425 #endif 426 427 #ifndef __DEQUALIFY 428 #define __DEQUALIFY(type, var) __CAST_AWAY_QUALIFIER(var, const volatile, type) 429 #endif 430 431 /* 432 * __alloc_size can be used to label function arguments that represent the 433 * size of memory that the function allocates and returns. The one-argument 434 * form labels a single argument that gives the allocation size (where the 435 * arguments are numbered from 1): 436 * 437 * void *malloc(size_t __size) __alloc_size(1); 438 * 439 * The two-argument form handles the case where the size is calculated as the 440 * product of two arguments: 441 * 442 * void *calloc(size_t __count, size_t __size) __alloc_size(1,2); 443 */ 444 #ifndef __alloc_size 445 #if __has_attribute(alloc_size) 446 #define __alloc_size(...) __attribute__((alloc_size(__VA_ARGS__))) 447 #else 448 #define __alloc_size(...) 449 #endif 450 #endif // __alloc_size 451 452 /* 453 * COMPILATION ENVIRONMENTS -- see compat(5) for additional detail 454 * 455 * DEFAULT By default newly complied code will get POSIX APIs plus 456 * Apple API extensions in scope. 457 * 458 * Most users will use this compilation environment to avoid 459 * behavioral differences between 32 and 64 bit code. 460 * 461 * LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple 462 * API extensions in scope. 463 * 464 * This is generally equivalent to the Tiger release compilation 465 * environment, except that it cannot be applied to 64 bit code; 466 * its use is discouraged. 467 * 468 * We expect this environment to be deprecated in the future. 469 * 470 * STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the 471 * available APIs to exactly the set of APIs defined by the 472 * corresponding standard, based on the value defined. 473 * 474 * A correct, portable definition for _POSIX_C_SOURCE is 200112L. 475 * A correct, portable definition for _XOPEN_SOURCE is 600L. 476 * 477 * Apple API extensions are not visible in this environment, 478 * which can cause Apple specific code to fail to compile, 479 * or behave incorrectly if prototypes are not in scope or 480 * warnings about missing prototypes are not enabled or ignored. 481 * 482 * In any compilation environment, for correct symbol resolution to occur, 483 * function prototypes must be in scope. It is recommended that all Apple 484 * tools users add either the "-Wall" or "-Wimplicit-function-declaration" 485 * compiler flags to their projects to be warned when a function is being 486 * used without a prototype in scope. 487 */ 488 489 /* These settings are particular to each product. */ 490 /* Platform: MacOSX */ 491 #if defined(__i386__) 492 #define __DARWIN_ONLY_64_BIT_INO_T 0 493 #define __DARWIN_ONLY_UNIX_CONFORMANCE 0 494 #define __DARWIN_ONLY_VERS_1050 0 495 #elif defined(__x86_64__) 496 #define __DARWIN_ONLY_64_BIT_INO_T 0 497 #define __DARWIN_ONLY_UNIX_CONFORMANCE 1 498 #define __DARWIN_ONLY_VERS_1050 0 499 #else 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 504 505 /* 506 * The __DARWIN_ALIAS macros are used to do symbol renaming; they allow 507 * legacy code to use the old symbol, thus maintaining binary compatibility 508 * while new code can use a standards compliant version of the same function. 509 * 510 * __DARWIN_ALIAS is used by itself if the function signature has not 511 * changed, it is used along with a #ifdef check for __DARWIN_UNIX03 512 * if the signature has changed. Because the __LP64__ environment 513 * only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be 514 * defined, but causes __DARWIN_ALIAS to do no symbol mangling. 515 * 516 * As a special case, when XCode is used to target a specific version of the 517 * OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 518 * will be defined by the compiler, with the digits representing major version 519 * time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting 520 * pre-10.5, and it is the default compilation environment, revert the 521 * compilation environment to pre-__DARWIN_UNIX03. 522 */ 523 #if !defined(__DARWIN_UNIX03) 524 # if __DARWIN_ONLY_UNIX_CONFORMANCE 525 # if defined(_NONSTD_SOURCE) 526 # error "Can't define _NONSTD_SOURCE when only UNIX conformance is available." 527 # endif /* _NONSTD_SOURCE */ 528 # define __DARWIN_UNIX03 1 529 # elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - 0) < 1040) 530 # define __DARWIN_UNIX03 0 531 # elif defined(_DARWIN_C_SOURCE) || defined(_XOPEN_SOURCE) || defined(_POSIX_C_SOURCE) 532 # if defined(_NONSTD_SOURCE) 533 # error "Can't define both _NONSTD_SOURCE and any of _DARWIN_C_SOURCE, _XOPEN_SOURCE or _POSIX_C_SOURCE." 534 # endif /* _NONSTD_SOURCE */ 535 # define __DARWIN_UNIX03 1 536 # elif defined(_NONSTD_SOURCE) 537 # define __DARWIN_UNIX03 0 538 # else /* default */ 539 # if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - 0) < 1050) 540 # define __DARWIN_UNIX03 0 541 # else /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 */ 542 # define __DARWIN_UNIX03 1 543 # endif /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 */ 544 # endif /* _DARWIN_C_SOURCE || _XOPEN_SOURCE || _POSIX_C_SOURCE || __LP64__ */ 545 #endif /* !__DARWIN_UNIX03 */ 546 547 #if !defined(__DARWIN_64_BIT_INO_T) 548 # if defined(_DARWIN_USE_64_BIT_INODE) 549 # if defined(_DARWIN_NO_64_BIT_INODE) 550 # error "Can't define both _DARWIN_USE_64_BIT_INODE and _DARWIN_NO_64_BIT_INODE." 551 # endif /* _DARWIN_NO_64_BIT_INODE */ 552 # define __DARWIN_64_BIT_INO_T 1 553 # elif defined(_DARWIN_NO_64_BIT_INODE) 554 # if __DARWIN_ONLY_64_BIT_INO_T 555 # error "Can't define _DARWIN_NO_64_BIT_INODE when only 64-bit inodes are available." 556 # endif /* __DARWIN_ONLY_64_BIT_INO_T */ 557 # define __DARWIN_64_BIT_INO_T 0 558 # else /* default */ 559 # if __DARWIN_ONLY_64_BIT_INO_T 560 # define __DARWIN_64_BIT_INO_T 1 561 # elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - 0) < 1060) || __DARWIN_UNIX03 == 0 562 # define __DARWIN_64_BIT_INO_T 0 563 # else /* default */ 564 # define __DARWIN_64_BIT_INO_T 1 565 # endif /* __DARWIN_ONLY_64_BIT_INO_T */ 566 # endif 567 #endif /* !__DARWIN_64_BIT_INO_T */ 568 569 #if !defined(__DARWIN_VERS_1050) 570 # if __DARWIN_ONLY_VERS_1050 571 # define __DARWIN_VERS_1050 1 572 # elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - 0) < 1050) || __DARWIN_UNIX03 == 0 573 # define __DARWIN_VERS_1050 0 574 # else /* default */ 575 # define __DARWIN_VERS_1050 1 576 # endif 577 #endif /* !__DARWIN_VERS_1050 */ 578 579 #if !defined(__DARWIN_NON_CANCELABLE) 580 # define __DARWIN_NON_CANCELABLE 0 581 #endif /* !__DARWIN_NON_CANCELABLE */ 582 583 /* 584 * symbol suffixes used for symbol versioning 585 */ 586 #if __DARWIN_UNIX03 587 # if __DARWIN_ONLY_UNIX_CONFORMANCE 588 # define __DARWIN_SUF_UNIX03 /* nothing */ 589 # else /* !__DARWIN_ONLY_UNIX_CONFORMANCE */ 590 # define __DARWIN_SUF_UNIX03 "$UNIX2003" 591 # endif /* __DARWIN_ONLY_UNIX_CONFORMANCE */ 592 593 # if __DARWIN_64_BIT_INO_T 594 # if __DARWIN_ONLY_64_BIT_INO_T 595 # define __DARWIN_SUF_64_BIT_INO_T /* nothing */ 596 # else /* !__DARWIN_ONLY_64_BIT_INO_T */ 597 # define __DARWIN_SUF_64_BIT_INO_T "$INODE64" 598 # endif /* __DARWIN_ONLY_64_BIT_INO_T */ 599 # else /* !__DARWIN_64_BIT_INO_T */ 600 # define __DARWIN_SUF_64_BIT_INO_T /* nothing */ 601 # endif /* __DARWIN_64_BIT_INO_T */ 602 603 # if __DARWIN_VERS_1050 604 # if __DARWIN_ONLY_VERS_1050 605 # define __DARWIN_SUF_1050 /* nothing */ 606 # else /* !__DARWIN_ONLY_VERS_1050 */ 607 # define __DARWIN_SUF_1050 "$1050" 608 # endif /* __DARWIN_ONLY_VERS_1050 */ 609 # else /* !__DARWIN_VERS_1050 */ 610 # define __DARWIN_SUF_1050 /* nothing */ 611 # endif /* __DARWIN_VERS_1050 */ 612 613 # if __DARWIN_NON_CANCELABLE 614 # define __DARWIN_SUF_NON_CANCELABLE "$NOCANCEL" 615 # else /* !__DARWIN_NON_CANCELABLE */ 616 # define __DARWIN_SUF_NON_CANCELABLE /* nothing */ 617 # endif /* __DARWIN_NON_CANCELABLE */ 618 619 #else /* !__DARWIN_UNIX03 */ 620 # define __DARWIN_SUF_UNIX03 /* nothing */ 621 # define __DARWIN_SUF_64_BIT_INO_T /* nothing */ 622 # define __DARWIN_SUF_NON_CANCELABLE /* nothing */ 623 # define __DARWIN_SUF_1050 /* nothing */ 624 #endif /* __DARWIN_UNIX03 */ 625 626 #define __DARWIN_SUF_EXTSN "$DARWIN_EXTSN" 627 628 /* 629 * symbol versioning macros 630 */ 631 #define __DARWIN_ALIAS(sym) __asm("_" __STRING(sym) __DARWIN_SUF_UNIX03) 632 #define __DARWIN_ALIAS_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03) 633 #define __DARWIN_ALIAS_I(sym) __asm("_" __STRING(sym) __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03) 634 #define __DARWIN_NOCANCEL(sym) __asm("_" __STRING(sym) __DARWIN_SUF_NON_CANCELABLE) 635 #define __DARWIN_INODE64(sym) __asm("_" __STRING(sym) __DARWIN_SUF_64_BIT_INO_T) 636 637 #define __DARWIN_1050(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050) 638 #define __DARWIN_1050ALIAS(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_UNIX03) 639 #define __DARWIN_1050ALIAS_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03) 640 #define __DARWIN_1050ALIAS_I(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03) 641 #define __DARWIN_1050INODE64(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_64_BIT_INO_T) 642 643 #define __DARWIN_EXTSN(sym) __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN) 644 #define __DARWIN_EXTSN_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN __DARWIN_SUF_NON_CANCELABLE) 645 646 /* 647 * symbol release macros 648 */ 649 #include <sys/_symbol_aliasing.h> 650 651 #if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) 652 #define __DARWIN_ALIAS_STARTING(_mac, _iphone, x) __DARWIN_ALIAS_STARTING_IPHONE_##_iphone(x) 653 #elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) 654 #define __DARWIN_ALIAS_STARTING(_mac, _iphone, x) __DARWIN_ALIAS_STARTING_MAC_##_mac(x) 655 #else 656 #define __DARWIN_ALIAS_STARTING(_mac, _iphone, x) x 657 #endif 658 659 660 /* 661 * POSIX.1 requires that the macros we test be defined before any standard 662 * header file is included. This permits us to convert values for feature 663 * testing, as necessary, using only _POSIX_C_SOURCE. 664 * 665 * Here's a quick run-down of the versions: 666 * defined(_POSIX_SOURCE) 1003.1-1988 667 * _POSIX_C_SOURCE == 1L 1003.1-1990 668 * _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option 669 * _POSIX_C_SOURCE == 199309L 1003.1b-1993 670 * _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, 671 * and the omnibus ISO/IEC 9945-1: 1996 672 * _POSIX_C_SOURCE == 200112L 1003.1-2001 673 * _POSIX_C_SOURCE == 200809L 1003.1-2008 674 * 675 * In addition, the X/Open Portability Guide, which is now the Single UNIX 676 * Specification, defines a feature-test macro which indicates the version of 677 * that specification, and which subsumes _POSIX_C_SOURCE. 678 */ 679 680 /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. */ 681 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1L 682 #undef _POSIX_C_SOURCE 683 #define _POSIX_C_SOURCE 199009L 684 #endif 685 686 /* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. */ 687 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2L 688 #undef _POSIX_C_SOURCE 689 #define _POSIX_C_SOURCE 199209L 690 #endif 691 692 /* Deal with various X/Open Portability Guides and Single UNIX Spec. */ 693 #ifdef _XOPEN_SOURCE 694 #if _XOPEN_SOURCE - 0L >= 700L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 200809L) 695 #undef _POSIX_C_SOURCE 696 #define _POSIX_C_SOURCE 200809L 697 #elif _XOPEN_SOURCE - 0L >= 600L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 200112L) 698 #undef _POSIX_C_SOURCE 699 #define _POSIX_C_SOURCE 200112L 700 #elif _XOPEN_SOURCE - 0L >= 500L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 199506L) 701 #undef _POSIX_C_SOURCE 702 #define _POSIX_C_SOURCE 199506L 703 #endif 704 #endif 705 706 /* 707 * Deal with all versions of POSIX. The ordering relative to the tests above is 708 * important. 709 */ 710 #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) 711 #define _POSIX_C_SOURCE 198808L 712 #endif 713 714 /* POSIX C deprecation macros */ 715 #include <sys/_posix_availability.h> 716 717 #define __POSIX_C_DEPRECATED(ver) ___POSIX_C_DEPRECATED_STARTING_##ver 718 719 /* 720 * Set a single macro which will always be defined and can be used to determine 721 * the appropriate namespace. For POSIX, these values will correspond to 722 * _POSIX_C_SOURCE value. Currently there are two additional levels corresponding 723 * to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) 724 */ 725 #define __DARWIN_C_ANSI 010000L 726 #define __DARWIN_C_FULL 900000L 727 728 #if defined(_ANSI_SOURCE) 729 #define __DARWIN_C_LEVEL __DARWIN_C_ANSI 730 #elif defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE) && !defined(_NONSTD_SOURCE) 731 #define __DARWIN_C_LEVEL _POSIX_C_SOURCE 732 #else 733 #define __DARWIN_C_LEVEL __DARWIN_C_FULL 734 #endif 735 736 /* If the developer has neither requested a strict language mode nor a version 737 * of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part 738 * of __DARWIN_C_FULL. 739 */ 740 #if !defined(__STDC_WANT_LIB_EXT1__) && !defined(__STRICT_ANSI__) && __DARWIN_C_LEVEL >= __DARWIN_C_FULL 741 #define __STDC_WANT_LIB_EXT1__ 1 742 #endif 743 744 /* 745 * long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and 746 * c99 still want long longs. While not perfect, we allow long longs for 747 * g++. 748 */ 749 #if (defined(__STRICT_ANSI__) && (__STDC_VERSION__ - 0 < 199901L) && !defined(__GNUG__)) 750 #define __DARWIN_NO_LONG_LONG 1 751 #else 752 #define __DARWIN_NO_LONG_LONG 0 753 #endif 754 755 /***************************************** 756 * Public darwin-specific feature macros 757 *****************************************/ 758 759 /* 760 * _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and 761 * structures modified for 64-bit inodes (like struct stat) will be used. 762 */ 763 #if __DARWIN_64_BIT_INO_T 764 #define _DARWIN_FEATURE_64_BIT_INODE 1 765 #endif 766 767 /* 768 * _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only 769 * be 64-bit; there is no support for 32-bit ino_t when this macro is defined 770 * (and non-zero). There is no struct stat64 either, as the regular 771 * struct stat will already be the 64-bit version. 772 */ 773 #if __DARWIN_ONLY_64_BIT_INO_T 774 #define _DARWIN_FEATURE_ONLY_64_BIT_INODE 1 775 #endif 776 777 /* 778 * _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated 779 * in 10.5 exists; no pre-10.5 variants are available. 780 */ 781 #if __DARWIN_ONLY_VERS_1050 782 #define _DARWIN_FEATURE_ONLY_VERS_1050 1 783 #endif 784 785 /* 786 * _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API 787 * are available (the legacy BSD APIs are not available) 788 */ 789 #if __DARWIN_ONLY_UNIX_CONFORMANCE 790 #define _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE 1 791 #endif 792 793 /* 794 * _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, 795 * and specifies the conformance level (3 is SUSv3) 796 */ 797 #if __DARWIN_UNIX03 798 #define _DARWIN_FEATURE_UNIX_CONFORMANCE 3 799 #endif 800 801 802 /* 803 * This macro casts away the qualifier from the variable 804 * 805 * Note: use at your own risk, removing qualifiers can result in 806 * catastrophic run-time failures. 807 */ 808 #ifndef __CAST_AWAY_QUALIFIER 809 #define __CAST_AWAY_QUALIFIER(variable, qualifier, type) (type) (long)(variable) 810 #endif 811 812 /* 813 * __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be 814 * used from other compilation units, but not other libraries or executables. 815 */ 816 #ifndef __XNU_PRIVATE_EXTERN 817 #define __XNU_PRIVATE_EXTERN __attribute__((visibility("hidden"))) 818 #endif 819 820 /* 821 * Architecture validation for current SDK 822 */ 823 #if !defined(__sys_cdefs_arch_unknown__) && defined(__i386__) 824 #elif !defined(__sys_cdefs_arch_unknown__) && defined(__x86_64__) 825 #elif !defined(__sys_cdefs_arch_unknown__) && defined(__arm__) 826 #elif !defined(__sys_cdefs_arch_unknown__) && defined(__arm64__) 827 #else 828 #error Unsupported architecture 829 #endif 830 831 832 833 #define __compiler_barrier() __asm__ __volatile__("" ::: "memory") 834 835 #if __has_attribute(enum_extensibility) 836 #define __enum_open __attribute__((__enum_extensibility__(open))) 837 #define __enum_closed __attribute__((__enum_extensibility__(closed))) 838 #else 839 #define __enum_open 840 #define __enum_closed 841 #endif // __has_attribute(enum_extensibility) 842 843 #if __has_attribute(flag_enum) 844 #define __enum_options __attribute__((__flag_enum__)) 845 #else 846 #define __enum_options 847 #endif 848 849 /* 850 * Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS 851 * 852 * This provides more advanced type checking on compilers supporting 853 * the proper extensions, even in C. 854 */ 855 #if __has_feature(objc_fixed_enum) || __has_extension(cxx_fixed_enum) || \ 856 __has_extension(cxx_strong_enums) 857 #define __enum_decl(_name, _type, ...) \ 858 typedef enum : _type __VA_ARGS__ __enum_open _name 859 #define __enum_closed_decl(_name, _type, ...) \ 860 typedef enum : _type __VA_ARGS__ __enum_closed _name 861 #define __options_decl(_name, _type, ...) \ 862 typedef enum : _type __VA_ARGS__ __enum_open __enum_options _name 863 #define __options_closed_decl(_name, _type, ...) \ 864 typedef enum : _type __VA_ARGS__ __enum_closed __enum_options _name 865 #else 866 #define __enum_decl(_name, _type, ...) \ 867 typedef _type _name; enum __VA_ARGS__ __enum_open 868 #define __enum_closed_decl(_name, _type, ...) \ 869 typedef _type _name; enum __VA_ARGS__ __enum_closed 870 #define __options_decl(_name, _type, ...) \ 871 typedef _type _name; enum __VA_ARGS__ __enum_open __enum_options 872 #define __options_closed_decl(_name, _type, ...) \ 873 typedef _type _name; enum __VA_ARGS__ __enum_closed __enum_options 874 #endif 875 876 #endif /* !_CDEFS_H_ */