bsd_cdefs.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. /*-
  2. * Copyright (c) 1991, 1993
  3. * The Regents of the University of California. All rights reserved.
  4. *
  5. * This code is derived from software contributed to Berkeley by
  6. * Berkeley Software Design, Inc.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * 4. Neither the name of the University nor the names of its contributors
  17. * may be used to endorse or promote products derived from this software
  18. * without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  21. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  24. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  26. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
  33. * $FreeBSD: src/sys/sys/cdefs.h,v 1.114 2011/02/18 21:44:53 nwhitehorn Exp $
  34. */
  35. #ifndef _SYS_CDEFS_H_
  36. #define _SYS_CDEFS_H_
  37. #if defined(__cplusplus)
  38. #define __BEGIN_DECLS extern "C" {
  39. #define __END_DECLS }
  40. #else
  41. #define __BEGIN_DECLS
  42. #define __END_DECLS
  43. #endif
  44. /*
  45. * This code has been put in place to help reduce the addition of
  46. * compiler specific defines in FreeBSD code. It helps to aid in
  47. * having a compiler-agnostic source tree.
  48. */
  49. #if defined(__GNUC__) || defined(__INTEL_COMPILER)
  50. #if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
  51. #define __GNUCLIKE_ASM 3
  52. #define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
  53. #else
  54. #define __GNUCLIKE_ASM 2
  55. #endif
  56. #define __GNUCLIKE___TYPEOF 1
  57. #define __GNUCLIKE___OFFSETOF 1
  58. #define __GNUCLIKE___SECTION 1
  59. #ifndef __INTEL_COMPILER
  60. # define __GNUCLIKE_CTOR_SECTION_HANDLING 1
  61. #endif
  62. #define __GNUCLIKE_BUILTIN_CONSTANT_P 1
  63. # if defined(__INTEL_COMPILER) && defined(__cplusplus) \
  64. && __INTEL_COMPILER < 800
  65. # undef __GNUCLIKE_BUILTIN_CONSTANT_P
  66. # endif
  67. #if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER)
  68. # define __GNUCLIKE_BUILTIN_VARARGS 1
  69. # define __GNUCLIKE_BUILTIN_STDARG 1
  70. # define __GNUCLIKE_BUILTIN_VAALIST 1
  71. #endif
  72. #if defined(__GNUC__)
  73. # define __GNUC_VA_LIST_COMPATIBILITY 1
  74. #endif
  75. #ifndef __INTEL_COMPILER
  76. # define __GNUCLIKE_BUILTIN_NEXT_ARG 1
  77. # define __GNUCLIKE_MATH_BUILTIN_RELOPS
  78. #endif
  79. #define __GNUCLIKE_BUILTIN_MEMCPY 1
  80. /* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
  81. #define __CC_SUPPORTS_INLINE 1
  82. #define __CC_SUPPORTS___INLINE 1
  83. #define __CC_SUPPORTS___INLINE__ 1
  84. #define __CC_SUPPORTS___FUNC__ 1
  85. #define __CC_SUPPORTS_WARNING 1
  86. #define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
  87. #define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
  88. #endif /* __GNUC__ || __INTEL_COMPILER */
  89. /*
  90. * Macro to test if we're using a specific version of gcc or later.
  91. */
  92. #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
  93. #define __GNUC_PREREQ__(ma, mi) \
  94. (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
  95. #else
  96. #define __GNUC_PREREQ__(ma, mi) 0
  97. #endif
  98. /*
  99. * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
  100. * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
  101. * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
  102. * mode -- there must be no spaces between its arguments, and for nested
  103. * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also
  104. * concatenate double-quoted strings produced by the __STRING macro, but
  105. * this only works with ANSI C.
  106. *
  107. * __XSTRING is like __STRING, but it expands any macros in its argument
  108. * first. It is only available with ANSI C.
  109. */
  110. #if defined(__STDC__) || defined(__cplusplus)
  111. #define __P(protos) protos /* full-blown ANSI C */
  112. #define __CONCAT1(x,y) x ## y
  113. #define __CONCAT(x,y) __CONCAT1(x,y)
  114. #define __STRING(x) #x /* stringify without expanding x */
  115. #define __XSTRING(x) __STRING(x) /* expand x, then stringify */
  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. #if !(defined(__CC_SUPPORTS___INLINE))
  123. #define __inline /* delete GCC keyword */
  124. #endif /* ! __CC_SUPPORTS___INLINE */
  125. #endif /* !__cplusplus */
  126. #else /* !(__STDC__ || __cplusplus) */
  127. #define __P(protos) () /* traditional C preprocessor */
  128. #define __CONCAT(x,y) x/**/y
  129. #define __STRING(x) "x"
  130. #if !defined(__CC_SUPPORTS___INLINE)
  131. #define __const /* delete pseudo-ANSI C keywords */
  132. #define __inline
  133. #define __signed
  134. #define __volatile
  135. /*
  136. * In non-ANSI C environments, new programs will want ANSI-only C keywords
  137. * deleted from the program and old programs will want them left alone.
  138. * When using a compiler other than gcc, programs using the ANSI C keywords
  139. * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
  140. * When using "gcc -traditional", we assume that this is the intent; if
  141. * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
  142. */
  143. #ifndef NO_ANSI_KEYWORDS
  144. #define const /* delete ANSI C keywords */
  145. #define inline
  146. #define signed
  147. #define volatile
  148. #endif /* !NO_ANSI_KEYWORDS */
  149. #endif /* !__CC_SUPPORTS___INLINE */
  150. #endif /* !(__STDC__ || __cplusplus) */
  151. /*
  152. * Compiler-dependent macros to help declare dead (non-returning) and
  153. * pure (no side effects) functions, and unused variables. They are
  154. * null except for versions of gcc that are known to support the features
  155. * properly (old versions of gcc-2 supported the dead and pure features
  156. * in a different (wrong) way). If we do not provide an implementation
  157. * for a given compiler, let the compile fail if it is told to use
  158. * a feature that we cannot live without.
  159. */
  160. #ifdef lint
  161. #define __dead2
  162. #define __pure2
  163. #define __unused
  164. #define __packed
  165. #define __aligned(x)
  166. #define __section(x)
  167. #else
  168. #if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
  169. #define __dead2
  170. #define __pure2
  171. #define __unused
  172. #endif
  173. #if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
  174. #define __dead2 __attribute__((__noreturn__))
  175. #define __pure2 __attribute__((__const__))
  176. #define __unused
  177. /* XXX Find out what to do for __packed, __aligned and __section */
  178. #endif
  179. #if __GNUC_PREREQ__(2, 7)
  180. #define __dead2 __attribute__((__noreturn__))
  181. #define __pure2 __attribute__((__const__))
  182. #define __unused __attribute__((__unused__))
  183. #define __used __attribute__((__used__))
  184. #define __packed __attribute__((__packed__))
  185. #define __aligned(x) __attribute__((__aligned__(x)))
  186. #define __section(x) __attribute__((__section__(x)))
  187. #endif
  188. #if defined(__INTEL_COMPILER)
  189. #define __dead2 __attribute__((__noreturn__))
  190. #define __pure2 __attribute__((__const__))
  191. #define __unused __attribute__((__unused__))
  192. #define __used __attribute__((__used__))
  193. #define __packed __attribute__((__packed__))
  194. #define __aligned(x) __attribute__((__aligned__(x)))
  195. #define __section(x) __attribute__((__section__(x)))
  196. #endif
  197. #endif
  198. #if __GNUC_PREREQ__(2, 96)
  199. #define __malloc_like __attribute__((__malloc__))
  200. #define __pure __attribute__((__pure__))
  201. #else
  202. #define __malloc_like
  203. #define __pure
  204. #endif
  205. #if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
  206. #define __always_inline __attribute__((__always_inline__))
  207. #else
  208. #define __always_inline
  209. #endif
  210. #if __GNUC_PREREQ__(3, 1)
  211. #define __noinline __attribute__ ((__noinline__))
  212. #else
  213. #define __noinline
  214. #endif
  215. #if __GNUC_PREREQ__(3, 3)
  216. #define __nonnull(x) __attribute__((__nonnull__(x)))
  217. #else
  218. #define __nonnull(x)
  219. #endif
  220. /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
  221. #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
  222. #define __func__ NULL
  223. #endif
  224. #if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
  225. #define __LONG_LONG_SUPPORTED
  226. #endif
  227. /*
  228. * GCC 2.95 provides `__restrict' as an extension to C90 to support the
  229. * C99-specific `restrict' type qualifier. We happen to use `__restrict' as
  230. * a way to define the `restrict' type qualifier without disturbing older
  231. * software that is unaware of C99 keywords.
  232. */
  233. #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
  234. #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint)
  235. #define __restrict
  236. #else
  237. #define __restrict restrict
  238. #endif
  239. #endif
  240. /*
  241. * GNU C version 2.96 adds explicit branch prediction so that
  242. * the CPU back-end can hint the processor and also so that
  243. * code blocks can be reordered such that the predicted path
  244. * sees a more linear flow, thus improving cache behavior, etc.
  245. *
  246. * The following two macros provide us with a way to utilize this
  247. * compiler feature. Use __predict_true() if you expect the expression
  248. * to evaluate to true, and __predict_false() if you expect the
  249. * expression to evaluate to false.
  250. *
  251. * A few notes about usage:
  252. *
  253. * * Generally, __predict_false() error condition checks (unless
  254. * you have some _strong_ reason to do otherwise, in which case
  255. * document it), and/or __predict_true() `no-error' condition
  256. * checks, assuming you want to optimize for the no-error case.
  257. *
  258. * * Other than that, if you don't know the likelihood of a test
  259. * succeeding from empirical or other `hard' evidence, don't
  260. * make predictions.
  261. *
  262. * * These are meant to be used in places that are run `a lot'.
  263. * It is wasteful to make predictions in code that is run
  264. * seldomly (e.g. at subsystem initialization time) as the
  265. * basic block reordering that this affects can often generate
  266. * larger code.
  267. */
  268. #if __GNUC_PREREQ__(2, 96)
  269. #define __predict_true(exp) __builtin_expect((exp), 1)
  270. #define __predict_false(exp) __builtin_expect((exp), 0)
  271. #else
  272. #define __predict_true(exp) (exp)
  273. #define __predict_false(exp) (exp)
  274. #endif
  275. #if __GNUC_PREREQ__(4, 2)
  276. #define __hidden __attribute__((__visibility__("hidden")))
  277. #define __exported __attribute__((__visibility__("default")))
  278. #else
  279. #define __hidden
  280. #define __exported
  281. #endif
  282. /*
  283. * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
  284. * require it.
  285. */
  286. #if __GNUC_PREREQ__(4, 1)
  287. #define __offsetof(type, field) __builtin_offsetof(type, field)
  288. #else
  289. #ifndef __cplusplus
  290. #define __offsetof(type, field) ((size_t)(&((type *)0)->field))
  291. #else
  292. #define __offsetof(type, field) \
  293. (__offsetof__ (reinterpret_cast <size_t> \
  294. (&reinterpret_cast <const volatile char &> \
  295. (static_cast<type *> (0)->field))))
  296. #endif
  297. #endif
  298. #define __rangeof(type, start, end) \
  299. (__offsetof(type, end) - __offsetof(type, start))
  300. /*
  301. * Compiler-dependent macros to declare that functions take printf-like
  302. * or scanf-like arguments. They are null except for versions of gcc
  303. * that are known to support the features properly (old versions of gcc-2
  304. * didn't permit keeping the keywords out of the application namespace).
  305. */
  306. #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
  307. #define __printflike(fmtarg, firstvararg)
  308. #define __scanflike(fmtarg, firstvararg)
  309. #define __format_arg(fmtarg)
  310. #else
  311. #define __printflike(fmtarg, firstvararg) \
  312. __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
  313. #define __scanflike(fmtarg, firstvararg) \
  314. __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
  315. #define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg)))
  316. #endif
  317. /* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
  318. #if __FreeBSD_cc_version >= 300001 && defined(__GNUC__) && !defined(__INTEL_COMPILER)
  319. #define __printf0like(fmtarg, firstvararg) \
  320. __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
  321. #else
  322. #define __printf0like(fmtarg, firstvararg)
  323. #endif
  324. #if defined(__GNUC__) || defined(__INTEL_COMPILER)
  325. #ifndef __INTEL_COMPILER
  326. #define __strong_reference(sym,aliassym) \
  327. extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
  328. #endif
  329. #ifdef __STDC__
  330. #define __weak_reference(sym,alias) \
  331. __asm__(".weak " #alias); \
  332. __asm__(".equ " #alias ", " #sym)
  333. #define __warn_references(sym,msg) \
  334. __asm__(".section .gnu.warning." #sym); \
  335. __asm__(".asciz \"" msg "\""); \
  336. __asm__(".previous")
  337. #define __sym_compat(sym,impl,verid) \
  338. __asm__(".symver " #impl ", " #sym "@" #verid)
  339. #define __sym_default(sym,impl,verid) \
  340. __asm__(".symver " #impl ", " #sym "@@" #verid)
  341. #else
  342. #define __weak_reference(sym,alias) \
  343. __asm__(".weak alias"); \
  344. __asm__(".equ alias, sym")
  345. #define __warn_references(sym,msg) \
  346. __asm__(".section .gnu.warning.sym"); \
  347. __asm__(".asciz \"msg\""); \
  348. __asm__(".previous")
  349. #define __sym_compat(sym,impl,verid) \
  350. __asm__(".symver impl, sym@verid")
  351. #define __sym_default(impl,sym,verid) \
  352. __asm__(".symver impl, sym@@verid")
  353. #endif /* __STDC__ */
  354. #endif /* __GNUC__ || __INTEL_COMPILER */
  355. #define __GLOBL1(sym) __asm__(".globl " #sym)
  356. #define __GLOBL(sym) __GLOBL1(sym)
  357. #if defined(__GNUC__) || defined(__INTEL_COMPILER)
  358. #define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
  359. #else
  360. /*
  361. * The following definition might not work well if used in header files,
  362. * but it should be better than nothing. If you want a "do nothing"
  363. * version, then it should generate some harmless declaration, such as:
  364. * #define __IDSTRING(name,string) struct __hack
  365. */
  366. #define __IDSTRING(name,string) static const char name[] __unused = string
  367. #endif
  368. /*
  369. * Embed the rcs id of a source file in the resulting library. Note that in
  370. * more recent ELF binutils, we use .ident allowing the ID to be stripped.
  371. * Usage:
  372. * __FBSDID("$FreeBSD: src/sys/sys/cdefs.h,v 1.114 2011/02/18 21:44:53 nwhitehorn Exp $");
  373. */
  374. #ifndef __FBSDID
  375. #if !defined(lint) && !defined(STRIP_FBSDID)
  376. #define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
  377. #else
  378. #define __FBSDID(s) struct __hack
  379. #endif
  380. #endif
  381. #ifndef __RCSID
  382. #ifndef NO__RCSID
  383. #define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
  384. #else
  385. #define __RCSID(s) struct __hack
  386. #endif
  387. #endif
  388. #ifndef __RCSID_SOURCE
  389. #ifndef NO__RCSID_SOURCE
  390. #define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
  391. #else
  392. #define __RCSID_SOURCE(s) struct __hack
  393. #endif
  394. #endif
  395. #ifndef __SCCSID
  396. #ifndef NO__SCCSID
  397. #define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
  398. #else
  399. #define __SCCSID(s) struct __hack
  400. #endif
  401. #endif
  402. #ifndef __COPYRIGHT
  403. #ifndef NO__COPYRIGHT
  404. #define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
  405. #else
  406. #define __COPYRIGHT(s) struct __hack
  407. #endif
  408. #endif
  409. #ifndef __DECONST
  410. #define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
  411. #endif
  412. #ifndef __DEVOLATILE
  413. #define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var))
  414. #endif
  415. #ifndef __DEQUALIFY
  416. #define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var))
  417. #endif
  418. /*-
  419. * The following definitions are an extension of the behavior originally
  420. * implemented in <sys/_posix.h>, but with a different level of granularity.
  421. * POSIX.1 requires that the macros we test be defined before any standard
  422. * header file is included.
  423. *
  424. * Here's a quick run-down of the versions:
  425. * defined(_POSIX_SOURCE) 1003.1-1988
  426. * _POSIX_C_SOURCE == 1 1003.1-1990
  427. * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
  428. * _POSIX_C_SOURCE == 199309 1003.1b-1993
  429. * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
  430. * and the omnibus ISO/IEC 9945-1: 1996
  431. * _POSIX_C_SOURCE == 200112 1003.1-2001
  432. * _POSIX_C_SOURCE == 200809 1003.1-2008
  433. *
  434. * In addition, the X/Open Portability Guide, which is now the Single UNIX
  435. * Specification, defines a feature-test macro which indicates the version of
  436. * that specification, and which subsumes _POSIX_C_SOURCE.
  437. *
  438. * Our macros begin with two underscores to avoid namespace screwage.
  439. */
  440. /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
  441. #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
  442. #undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
  443. #define _POSIX_C_SOURCE 199009
  444. #endif
  445. /* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
  446. #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
  447. #undef _POSIX_C_SOURCE
  448. #define _POSIX_C_SOURCE 199209
  449. #endif
  450. /* Deal with various X/Open Portability Guides and Single UNIX Spec. */
  451. #ifdef _XOPEN_SOURCE
  452. #if _XOPEN_SOURCE - 0 >= 700
  453. #define __XSI_VISIBLE 700
  454. #undef _POSIX_C_SOURCE
  455. #define _POSIX_C_SOURCE 200809
  456. #elif _XOPEN_SOURCE - 0 >= 600
  457. #define __XSI_VISIBLE 600
  458. #undef _POSIX_C_SOURCE
  459. #define _POSIX_C_SOURCE 200112
  460. #elif _XOPEN_SOURCE - 0 >= 500
  461. #define __XSI_VISIBLE 500
  462. #undef _POSIX_C_SOURCE
  463. #define _POSIX_C_SOURCE 199506
  464. #endif
  465. #endif
  466. /*
  467. * Deal with all versions of POSIX. The ordering relative to the tests above is
  468. * important.
  469. */
  470. #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
  471. #define _POSIX_C_SOURCE 198808
  472. #endif
  473. #ifdef _POSIX_C_SOURCE
  474. #if _POSIX_C_SOURCE >= 200809
  475. #define __POSIX_VISIBLE 200809
  476. #define __ISO_C_VISIBLE 1999
  477. #elif _POSIX_C_SOURCE >= 200112
  478. #define __POSIX_VISIBLE 200112
  479. #define __ISO_C_VISIBLE 1999
  480. #elif _POSIX_C_SOURCE >= 199506
  481. #define __POSIX_VISIBLE 199506
  482. #define __ISO_C_VISIBLE 1990
  483. #elif _POSIX_C_SOURCE >= 199309
  484. #define __POSIX_VISIBLE 199309
  485. #define __ISO_C_VISIBLE 1990
  486. #elif _POSIX_C_SOURCE >= 199209
  487. #define __POSIX_VISIBLE 199209
  488. #define __ISO_C_VISIBLE 1990
  489. #elif _POSIX_C_SOURCE >= 199009
  490. #define __POSIX_VISIBLE 199009
  491. #define __ISO_C_VISIBLE 1990
  492. #else
  493. #define __POSIX_VISIBLE 198808
  494. #define __ISO_C_VISIBLE 0
  495. #endif /* _POSIX_C_SOURCE */
  496. #else
  497. /*-
  498. * Deal with _ANSI_SOURCE:
  499. * If it is defined, and no other compilation environment is explicitly
  500. * requested, then define our internal feature-test macros to zero. This
  501. * makes no difference to the preprocessor (undefined symbols in preprocessing
  502. * expressions are defined to have value zero), but makes it more convenient for
  503. * a test program to print out the values.
  504. *
  505. * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
  506. * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
  507. * environment (and in fact we will never get here).
  508. */
  509. #if defined(_ANSI_SOURCE) /* Hide almost everything. */
  510. #define __POSIX_VISIBLE 0
  511. #define __XSI_VISIBLE 0
  512. #define __BSD_VISIBLE 0
  513. #define __ISO_C_VISIBLE 1990
  514. #elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
  515. #define __POSIX_VISIBLE 0
  516. #define __XSI_VISIBLE 0
  517. #define __BSD_VISIBLE 0
  518. #define __ISO_C_VISIBLE 1999
  519. #else /* Default environment: show everything. */
  520. #define __POSIX_VISIBLE 200809
  521. #define __XSI_VISIBLE 700
  522. #define __BSD_VISIBLE 1
  523. #define __ISO_C_VISIBLE 1999
  524. #endif
  525. #endif
  526. #endif /* !_SYS_CDEFS_H_ */