1/* libc/sys/linux/sys/cdefs.h - Helper macros for K&R vs. ANSI C compat. */ 2 3/* Written 2000 by Werner Almesberger */ 4 5/*- 6 * Copyright (c) 1991, 1993 7 * The Regents of the University of California. All rights reserved. 8 * 9 * This code is derived from software contributed to Berkeley by 10 * Berkeley Software Design, Inc. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 4. Neither the name of the University nor the names of its contributors 21 * may be used to endorse or promote products derived from this software 22 * without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 37 * $FreeBSD$ 38 */ 39 40#ifndef _SYS_CDEFS_H_ 41#define _SYS_CDEFS_H_ 42 43#include <sys/features.h> 44#include <stddef.h> 45#include <stdint.h> 46 47#define __PMT(args) args 48#define __DOTS , ... 49#define __THROW 50 51#ifdef __GNUC__ 52# define __ASMNAME(cname) __XSTRING (__USER_LABEL_PREFIX__) cname 53#endif 54 55#define __ptr_t void * 56#define __long_double_t long double 57 58#define __attribute_malloc__ 59#define __attribute_pure__ 60#define __attribute_format_strfmon__(a,b) 61#define __flexarr [0] 62 63#ifndef __BOUNDED_POINTERS__ 64# define __bounded /* nothing */ 65# define __unbounded /* nothing */ 66# define __ptrvalue /* nothing */ 67#endif 68 69#if defined(__cplusplus) 70#define __BEGIN_DECLS extern "C" { 71#define __END_DECLS } 72#else 73#define __BEGIN_DECLS 74#define __END_DECLS 75#endif 76 77/* 78 * This code has been put in place to help reduce the addition of 79 * compiler specific defines in FreeBSD code. It helps to aid in 80 * having a compiler-agnostic source tree. 81 */ 82 83#if defined(__GNUC__) || defined(__INTEL_COMPILER) 84 85#if __GNUC__ >= 3 || defined(__INTEL_COMPILER) 86#define __GNUCLIKE_ASM 3 87#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS 88#else 89#define __GNUCLIKE_ASM 2 90#endif 91#define __GNUCLIKE___TYPEOF 1 92#define __GNUCLIKE___OFFSETOF 1 93#define __GNUCLIKE___SECTION 1 94 95#ifndef __INTEL_COMPILER 96# define __GNUCLIKE_CTOR_SECTION_HANDLING 1 97#endif 98 99#define __GNUCLIKE_BUILTIN_CONSTANT_P 1 100# if defined(__INTEL_COMPILER) && defined(__cplusplus) \ 101 && __INTEL_COMPILER < 800 102# undef __GNUCLIKE_BUILTIN_CONSTANT_P 103# endif 104 105#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER) 106# define __GNUCLIKE_BUILTIN_VARARGS 1 107# define __GNUCLIKE_BUILTIN_STDARG 1 108# define __GNUCLIKE_BUILTIN_VAALIST 1 109#endif 110 111#if defined(__GNUC__) 112# define __GNUC_VA_LIST_COMPATIBILITY 1 113#endif 114 115/* 116 * Compiler memory barriers, specific to gcc and clang. 117 */ 118#if defined(__GNUC__) 119#define __compiler_membar() __asm __volatile(" " : : : "memory") 120#endif 121 122#ifndef __INTEL_COMPILER 123# define __GNUCLIKE_BUILTIN_NEXT_ARG 1 124# define __GNUCLIKE_MATH_BUILTIN_RELOPS 125#endif 126 127#define __GNUCLIKE_BUILTIN_MEMCPY 1 128 129/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */ 130#define __CC_SUPPORTS_INLINE 1 131#define __CC_SUPPORTS___INLINE 1 132#define __CC_SUPPORTS___INLINE__ 1 133 134#define __CC_SUPPORTS___FUNC__ 1 135#define __CC_SUPPORTS_WARNING 1 136 137#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */ 138 139#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1 140 141#endif /* __GNUC__ || __INTEL_COMPILER */ 142 143/* 144 * The __CONCAT macro is used to concatenate parts of symbol names, e.g. 145 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. 146 * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI 147 * mode -- there must be no spaces between its arguments, and for nested 148 * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also 149 * concatenate double-quoted strings produced by the __STRING macro, but 150 * this only works with ANSI C. 151 * 152 * __XSTRING is like __STRING, but it expands any macros in its argument 153 * first. It is only available with ANSI C. 154 */ 155#if defined(__STDC__) || defined(__cplusplus) 156#define __P(protos) protos /* full-blown ANSI C */ 157#define __CONCAT1(x,y) x ## y 158#define __CONCAT(x,y) __CONCAT1(x,y) 159#define __STRING(x) #x /* stringify without expanding x */ 160#define __XSTRING(x) __STRING(x) /* expand x, then stringify */ 161 162#define __const const /* define reserved names to standard */ 163#define __signed signed 164#define __volatile volatile 165#if defined(__cplusplus) 166#define __inline inline /* convert to C++ keyword */ 167#else 168#if !(defined(__CC_SUPPORTS___INLINE)) 169#define __inline /* delete GCC keyword */ 170#endif /* ! __CC_SUPPORTS___INLINE */ 171#endif /* !__cplusplus */ 172 173#else /* !(__STDC__ || __cplusplus) */ 174#define __P(protos) () /* traditional C preprocessor */ 175#define __CONCAT(x,y) x/**/y 176#define __STRING(x) "x" 177 178#if !defined(__CC_SUPPORTS___INLINE) 179#define __const /* delete pseudo-ANSI C keywords */ 180#define __inline 181#define __signed 182#define __volatile 183/* 184 * In non-ANSI C environments, new programs will want ANSI-only C keywords 185 * deleted from the program and old programs will want them left alone. 186 * When using a compiler other than gcc, programs using the ANSI C keywords 187 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. 188 * When using "gcc -traditional", we assume that this is the intent; if 189 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. 190 */ 191#ifndef NO_ANSI_KEYWORDS 192#define const /* delete ANSI C keywords */ 193#define inline 194#define signed 195#define volatile 196#endif /* !NO_ANSI_KEYWORDS */ 197#endif /* !__CC_SUPPORTS___INLINE */ 198#endif /* !(__STDC__ || __cplusplus) */ 199 200/* 201 * Compiler-dependent macros to help declare dead (non-returning) and 202 * pure (no side effects) functions, and unused variables. They are 203 * null except for versions of gcc that are known to support the features 204 * properly (old versions of gcc-2 supported the dead and pure features 205 * in a different (wrong) way). If we do not provide an implementation 206 * for a given compiler, let the compile fail if it is told to use 207 * a feature that we cannot live without. 208 */ 209#ifdef lint 210#define __dead2 211#define __pure2 212#define __unused 213#define __packed 214#define __aligned(x) 215#define __section(x) 216#else 217#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER) 218#define __dead2 219#define __pure2 220#define __unused 221#endif 222#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER) 223#define __dead2 __attribute__((__noreturn__)) 224#define __pure2 __attribute__((__const__)) 225#define __unused 226/* XXX Find out what to do for __packed, __aligned and __section */ 227#endif 228#if __GNUC_PREREQ__(2, 7) 229#define __dead2 __attribute__((__noreturn__)) 230#define __pure2 __attribute__((__const__)) 231#define __unused __attribute__((__unused__)) 232#define __used __attribute__((__used__)) 233#define __packed __attribute__((__packed__)) 234#define __aligned(x) __attribute__((__aligned__(x))) 235#define __section(x) __attribute__((__section__(x))) 236#endif 237#if defined(__INTEL_COMPILER) 238#define __dead2 __attribute__((__noreturn__)) 239#define __pure2 __attribute__((__const__)) 240#define __unused __attribute__((__unused__)) 241#define __used __attribute__((__used__)) 242#define __packed __attribute__((__packed__)) 243#define __aligned(x) __attribute__((__aligned__(x))) 244#define __section(x) __attribute__((__section__(x))) 245#endif 246#endif 247 248#if !__GNUC_PREREQ__(2, 95) 249#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b) 250#endif 251 252/* 253 * Keywords added in C11. 254 */ 255#if defined(__cplusplus) && __cplusplus >= 201103L 256#define _Alignas(e) alignas(e) 257#define _Alignof(e) alignof(e) 258#define _Noreturn [[noreturn]] 259#define _Static_assert(e, s) static_assert(e, s) 260/* FIXME: change this to thread_local when clang in base supports it */ 261#define _Thread_local __thread 262#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L 263/* Do nothing. They are language keywords. */ 264#else 265/* Not supported. Implement them using our versions. */ 266#define _Alignas(x) __aligned(x) 267#define _Alignof(x) __alignof(x) 268#define _Noreturn __dead2 269#define _Thread_local __thread 270#if __GNUC_PREREQ__(4, 6) && !defined(__cplusplus) 271/* Do nothing: _Static_assert() works as per C11 */ 272#elif defined(__COUNTER__) 273#define _Static_assert(x, y) __Static_assert(x, __COUNTER__) 274#define __Static_assert(x, y) ___Static_assert(x, y) 275#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] 276#else 277#define _Static_assert(x, y) struct __hack 278#endif 279#endif 280 281/* 282 * Emulation of C11 _Generic(). Unlike the previously defined C11 283 * keywords, it is not possible to implement this using exactly the same 284 * syntax. Therefore implement something similar under the name 285 * __generic(). Unlike _Generic(), this macro can only distinguish 286 * between a single type, so it requires nested invocations to 287 * distinguish multiple cases. 288 */ 289 290#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L 291#define __generic(expr, t, yes, no) \ 292 _Generic(expr, t: yes, default: no) 293#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus) 294#define __generic(expr, t, yes, no) \ 295 __builtin_choose_expr( \ 296 __builtin_types_compatible_p(__typeof(expr), t), yes, no) 297#endif 298 299#if __GNUC_PREREQ__(2, 96) 300#define __malloc_like __attribute__((__malloc__)) 301#define __pure __attribute__((__pure__)) 302#else 303#define __malloc_like 304#define __pure 305#endif 306 307#if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800) 308#define __always_inline __attribute__((__always_inline__)) 309#else 310#define __always_inline 311#endif 312 313#if __GNUC_PREREQ__(3, 1) 314#define __noinline __attribute__ ((__noinline__)) 315#else 316#define __noinline 317#endif 318 319#if __GNUC_PREREQ__(3, 3) 320#define __nonnull(x) __attribute__((__nonnull__(x))) 321#else 322#define __nonnull(x) 323#endif 324 325#if __GNUC_PREREQ__(3, 4) 326#define __fastcall __attribute__((__fastcall__)) 327#else 328#define __fastcall 329#endif 330 331#if __GNUC_PREREQ__(4, 1) 332#define __returns_twice __attribute__((__returns_twice__)) 333#else 334#define __returns_twice 335#endif 336 337/* XXX: should use `#if __STDC_VERSION__ < 199901'. */ 338#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) 339#define __func__ NULL 340#endif 341 342/* 343 * GCC 2.95 provides `__restrict' as an extension to C90 to support the 344 * C99-specific `restrict' type qualifier. We happen to use `__restrict' as 345 * a way to define the `restrict' type qualifier without disturbing older 346 * software that is unaware of C99 keywords. 347 */ 348#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95) 349#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint) 350#define __restrict 351#else 352#define __restrict restrict 353#endif 354#endif 355 356/* 357 * GNU C version 2.96 adds explicit branch prediction so that 358 * the CPU back-end can hint the processor and also so that 359 * code blocks can be reordered such that the predicted path 360 * sees a more linear flow, thus improving cache behavior, etc. 361 * 362 * The following two macros provide us with a way to utilize this 363 * compiler feature. Use __predict_true() if you expect the expression 364 * to evaluate to true, and __predict_false() if you expect the 365 * expression to evaluate to false. 366 * 367 * A few notes about usage: 368 * 369 * * Generally, __predict_false() error condition checks (unless 370 * you have some _strong_ reason to do otherwise, in which case 371 * document it), and/or __predict_true() `no-error' condition 372 * checks, assuming you want to optimize for the no-error case. 373 * 374 * * Other than that, if you don't know the likelihood of a test 375 * succeeding from empirical or other `hard' evidence, don't 376 * make predictions. 377 * 378 * * These are meant to be used in places that are run `a lot'. 379 * It is wasteful to make predictions in code that is run 380 * seldomly (e.g. at subsystem initialization time) as the 381 * basic block reordering that this affects can often generate 382 * larger code. 383 */ 384#if __GNUC_PREREQ__(2, 96) 385#define __predict_true(exp) __builtin_expect((exp), 1) 386#define __predict_false(exp) __builtin_expect((exp), 0) 387#else 388#define __predict_true(exp) (exp) 389#define __predict_false(exp) (exp) 390#endif 391 392#if __GNUC_PREREQ__(4, 2) 393#define __hidden __attribute__((__visibility__("hidden"))) 394#define __exported __attribute__((__visibility__("default"))) 395#else 396#define __hidden 397#define __exported 398#endif 399 400#define __offsetof(type, field) offsetof(type, field) 401#define __rangeof(type, start, end) \ 402 (__offsetof(type, end) - __offsetof(type, start)) 403 404/* 405 * Given the pointer x to the member m of the struct s, return 406 * a pointer to the containing structure. When using GCC, we first 407 * assign pointer x to a local variable, to check that its type is 408 * compatible with member m. 409 */ 410#if __GNUC_PREREQ__(3, 1) 411#define __containerof(x, s, m) ({ \ 412 const volatile __typeof__(((s *)0)->m) *__x = (x); \ 413 __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\ 414}) 415#else 416#define __containerof(x, s, m) \ 417 __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m)) 418#endif 419 420/* 421 * Compiler-dependent macros to declare that functions take printf-like 422 * or scanf-like arguments. They are null except for versions of gcc 423 * that are known to support the features properly (old versions of gcc-2 424 * didn't permit keeping the keywords out of the application namespace). 425 */ 426#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) 427#define __printflike(fmtarg, firstvararg) 428#define __scanflike(fmtarg, firstvararg) 429#define __format_arg(fmtarg) 430#define __strfmonlike(fmtarg, firstvararg) 431#define __strftimelike(fmtarg, firstvararg) 432#else 433#define __printflike(fmtarg, firstvararg) \ 434 __attribute__((__format__ (__printf__, fmtarg, firstvararg))) 435#define __scanflike(fmtarg, firstvararg) \ 436 __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) 437#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg))) 438#define __strfmonlike(fmtarg, firstvararg) \ 439 __attribute__((__format__ (__strfmon__, fmtarg, firstvararg))) 440#define __strftimelike(fmtarg, firstvararg) \ 441 __attribute__((__format__ (__strftime__, fmtarg, firstvararg))) 442#endif 443 444/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */ 445#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \ 446 defined(__GNUC__) && !defined(__INTEL_COMPILER) 447#define __printf0like(fmtarg, firstvararg) \ 448 __attribute__((__format__ (__printf0__, fmtarg, firstvararg))) 449#else 450#define __printf0like(fmtarg, firstvararg) 451#endif 452 453#if defined(__GNUC__) || defined(__INTEL_COMPILER) 454#ifndef __INTEL_COMPILER 455#define __strong_reference(sym,aliassym) \ 456 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))) 457#endif 458#ifdef __ELF__ 459#ifdef __STDC__ 460#define __weak_reference(sym,alias) \ 461 __asm__(".weak " #alias); \ 462 __asm__(".equ " #alias ", " #sym) 463#define __warn_references(sym,msg) \ 464 __asm__(".section .gnu.warning." #sym); \ 465 __asm__(".asciz \"" msg "\""); \ 466 __asm__(".previous") 467#define __sym_compat(sym,impl,verid) \ 468 __asm__(".symver " #impl ", " #sym "@" #verid) 469#define __sym_default(sym,impl,verid) \ 470 __asm__(".symver " #impl ", " #sym "@@" #verid) 471#else 472#define __weak_reference(sym,alias) \ 473 __asm__(".weak alias"); \ 474 __asm__(".equ alias, sym") 475#define __warn_references(sym,msg) \ 476 __asm__(".section .gnu.warning.sym"); \ 477 __asm__(".asciz \"msg\""); \ 478 __asm__(".previous") 479#define __sym_compat(sym,impl,verid) \ 480 __asm__(".symver impl, sym@verid") 481#define __sym_default(impl,sym,verid) \ 482 __asm__(".symver impl, sym@@verid") 483#endif /* __STDC__ */ 484#else /* !__ELF__ */ 485#ifdef __STDC__ 486#define __weak_reference(sym,alias) \ 487 __asm__(".stabs \"_" #alias "\",11,0,0,0"); \ 488 __asm__(".stabs \"_" #sym "\",1,0,0,0") 489#define __warn_references(sym,msg) \ 490 __asm__(".stabs \"" msg "\",30,0,0,0"); \ 491 __asm__(".stabs \"_" #sym "\",1,0,0,0") 492#else 493#define __weak_reference(sym,alias) \ 494 __asm__(".stabs \"_/**/alias\",11,0,0,0"); \ 495 __asm__(".stabs \"_/**/sym\",1,0,0,0") 496#define __warn_references(sym,msg) \ 497 __asm__(".stabs msg,30,0,0,0"); \ 498 __asm__(".stabs \"_/**/sym\",1,0,0,0") 499#endif /* __STDC__ */ 500#endif /* __ELF__ */ 501#endif /* __GNUC__ || __INTEL_COMPILER */ 502 503#ifndef __FBSDID 504#define __FBSDID(s) struct __hack 505#endif 506 507#ifndef __RCSID 508#define __RCSID(s) struct __hack 509#endif 510 511#ifndef __RCSID_SOURCE 512#define __RCSID_SOURCE(s) struct __hack 513#endif 514 515#ifndef __SCCSID 516#define __SCCSID(s) struct __hack 517#endif 518 519#ifndef __COPYRIGHT 520#define __COPYRIGHT(s) struct __hack 521#endif 522 523#ifndef __DECONST 524#define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var)) 525#endif 526 527#ifndef __DEVOLATILE 528#define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var)) 529#endif 530 531#ifndef __DEQUALIFY 532#define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var)) 533#endif 534 535/*- 536 * The following definitions are an extension of the behavior originally 537 * implemented in <sys/_posix.h>, but with a different level of granularity. 538 * POSIX.1 requires that the macros we test be defined before any standard 539 * header file is included. 540 * 541 * Here's a quick run-down of the versions: 542 * defined(_POSIX_SOURCE) 1003.1-1988 543 * _POSIX_C_SOURCE == 1 1003.1-1990 544 * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option 545 * _POSIX_C_SOURCE == 199309 1003.1b-1993 546 * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, 547 * and the omnibus ISO/IEC 9945-1: 1996 548 * _POSIX_C_SOURCE == 200112 1003.1-2001 549 * _POSIX_C_SOURCE == 200809 1003.1-2008 550 * 551 * In addition, the X/Open Portability Guide, which is now the Single UNIX 552 * Specification, defines a feature-test macro which indicates the version of 553 * that specification, and which subsumes _POSIX_C_SOURCE. 554 * 555 * Our macros begin with two underscores to avoid namespace screwage. 556 */ 557 558/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */ 559#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1 560#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */ 561#define _POSIX_C_SOURCE 199009 562#endif 563 564/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */ 565#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2 566#undef _POSIX_C_SOURCE 567#define _POSIX_C_SOURCE 199209 568#endif 569 570/* Deal with various X/Open Portability Guides and Single UNIX Spec. */ 571#ifdef _XOPEN_SOURCE 572#if _XOPEN_SOURCE - 0 >= 700 573#define __XSI_VISIBLE 700 574#undef _POSIX_C_SOURCE 575#define _POSIX_C_SOURCE 200809 576#elif _XOPEN_SOURCE - 0 >= 600 577#define __XSI_VISIBLE 600 578#undef _POSIX_C_SOURCE 579#define _POSIX_C_SOURCE 200112 580#elif _XOPEN_SOURCE - 0 >= 500 581#define __XSI_VISIBLE 500 582#undef _POSIX_C_SOURCE 583#define _POSIX_C_SOURCE 199506 584#endif 585#endif 586 587/* 588 * Deal with all versions of POSIX. The ordering relative to the tests above is 589 * important. 590 */ 591#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) 592#define _POSIX_C_SOURCE 198808 593#endif 594#ifdef _POSIX_C_SOURCE 595#if _POSIX_C_SOURCE >= 200809 596#define __POSIX_VISIBLE 200809 597#define __ISO_C_VISIBLE 1999 598#elif _POSIX_C_SOURCE >= 200112 599#define __POSIX_VISIBLE 200112 600#define __ISO_C_VISIBLE 1999 601#elif _POSIX_C_SOURCE >= 199506 602#define __POSIX_VISIBLE 199506 603#define __ISO_C_VISIBLE 1990 604#elif _POSIX_C_SOURCE >= 199309 605#define __POSIX_VISIBLE 199309 606#define __ISO_C_VISIBLE 1990 607#elif _POSIX_C_SOURCE >= 199209 608#define __POSIX_VISIBLE 199209 609#define __ISO_C_VISIBLE 1990 610#elif _POSIX_C_SOURCE >= 199009 611#define __POSIX_VISIBLE 199009 612#define __ISO_C_VISIBLE 1990 613#else 614#define __POSIX_VISIBLE 198808 615#define __ISO_C_VISIBLE 0 616#endif /* _POSIX_C_SOURCE */ 617#else 618/*- 619 * Deal with _ANSI_SOURCE: 620 * If it is defined, and no other compilation environment is explicitly 621 * requested, then define our internal feature-test macros to zero. This 622 * makes no difference to the preprocessor (undefined symbols in preprocessing 623 * expressions are defined to have value zero), but makes it more convenient for 624 * a test program to print out the values. 625 * 626 * If a program mistakenly defines _ANSI_SOURCE and some other macro such as 627 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation 628 * environment (and in fact we will never get here). 629 */ 630#if defined(_ANSI_SOURCE) /* Hide almost everything. */ 631#define __POSIX_VISIBLE 0 632#define __XSI_VISIBLE 0 633#define __BSD_VISIBLE 0 634#define __ISO_C_VISIBLE 1990 635#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */ 636#define __POSIX_VISIBLE 0 637#define __XSI_VISIBLE 0 638#define __BSD_VISIBLE 0 639#define __ISO_C_VISIBLE 1999 640#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */ 641#define __POSIX_VISIBLE 0 642#define __XSI_VISIBLE 0 643#define __BSD_VISIBLE 0 644#define __ISO_C_VISIBLE 2011 645#else /* Default environment: show everything. */ 646#define __POSIX_VISIBLE 200809 647#define __XSI_VISIBLE 700 648#define __BSD_VISIBLE 1 649#define __ISO_C_VISIBLE 2011 650#endif 651#endif 652 653#ifndef __has_extension 654#define __has_extension __has_feature 655#endif 656#ifndef __has_feature 657#define __has_feature(x) 0 658#endif 659#ifndef __has_include 660#define __has_include(x) 0 661#endif 662#ifndef __has_builtin 663#define __has_builtin(x) 0 664#endif 665 666#endif /* !_SYS_CDEFS_H_ */ 667