features.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. /* Copyright (C) 1991-2016 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #ifndef _FEATURES_H
  15. #define _FEATURES_H 1
  16. /* These are defined by the user (or the compiler)
  17. to specify the desired environment:
  18. __STRICT_ANSI__ ISO Standard C.
  19. _ISOC99_SOURCE Extensions to ISO C89 from ISO C99.
  20. _ISOC11_SOURCE Extensions to ISO C99 from ISO C11.
  21. _POSIX_SOURCE IEEE Std 1003.1.
  22. _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;
  23. if >=199309L, add IEEE Std 1003.1b-1993;
  24. if >=199506L, add IEEE Std 1003.1c-1995;
  25. if >=200112L, all of IEEE 1003.1-2004
  26. if >=200809L, all of IEEE 1003.1-2008
  27. _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if
  28. Single Unix conformance is wanted, to 600 for the
  29. sixth revision, to 700 for the seventh revision.
  30. _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
  31. _LARGEFILE_SOURCE Some more functions for correct standard I/O.
  32. _LARGEFILE64_SOURCE Additional functionality from LFS for large files.
  33. _FILE_OFFSET_BITS=N Select default filesystem interface.
  34. _ATFILE_SOURCE Additional *at interfaces.
  35. _GNU_SOURCE All of the above, plus GNU extensions.
  36. _DEFAULT_SOURCE The default set of features (taking precedence over
  37. __STRICT_ANSI__).
  38. _REENTRANT Select additionally reentrant object.
  39. _THREAD_SAFE Same as _REENTRANT, often used by other systems.
  40. _FORTIFY_SOURCE If set to numeric value > 0 additional security
  41. measures are defined, according to level.
  42. The `-ansi' switch to the GNU C compiler, and standards conformance
  43. options such as `-std=c99', define __STRICT_ANSI__. If none of
  44. these are defined, or if _DEFAULT_SOURCE is defined, the default is
  45. to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
  46. 200809L, as well as enabling miscellaneous functions from BSD and
  47. SVID. If more than one of these are defined, they accumulate. For
  48. example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together
  49. give you ISO C, 1003.1, and 1003.2, but nothing else.
  50. These are defined by this file and are used by the
  51. header files to decide what to declare or define:
  52. __USE_ISOC11 Define ISO C11 things.
  53. __USE_ISOC99 Define ISO C99 things.
  54. __USE_ISOC95 Define ISO C90 AMD1 (C95) things.
  55. __USE_POSIX Define IEEE Std 1003.1 things.
  56. __USE_POSIX2 Define IEEE Std 1003.2 things.
  57. __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things.
  58. __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things.
  59. __USE_XOPEN Define XPG things.
  60. __USE_XOPEN_EXTENDED Define X/Open Unix things.
  61. __USE_UNIX98 Define Single Unix V2 things.
  62. __USE_XOPEN2K Define XPG6 things.
  63. __USE_XOPEN2KXSI Define XPG6 XSI things.
  64. __USE_XOPEN2K8 Define XPG7 things.
  65. __USE_XOPEN2K8XSI Define XPG7 XSI things.
  66. __USE_LARGEFILE Define correct standard I/O things.
  67. __USE_LARGEFILE64 Define LFS things with separate names.
  68. __USE_FILE_OFFSET64 Define 64bit interface as default.
  69. __USE_MISC Define things from 4.3BSD or System V Unix.
  70. __USE_ATFILE Define *at interfaces and AT_* constants for them.
  71. __USE_GNU Define GNU extensions.
  72. __USE_REENTRANT Define reentrant/thread-safe *_r functions.
  73. __USE_FORTIFY_LEVEL Additional security measures used, according to level.
  74. The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are
  75. defined by this file unconditionally. `__GNU_LIBRARY__' is provided
  76. only for compatibility. All new code should use the other symbols
  77. to test for features.
  78. All macros listed above as possibly being defined by this file are
  79. explicitly undefined if they are not explicitly defined.
  80. Feature-test macros that are not defined by the user or compiler
  81. but are implied by the other feature-test macros defined (or by the
  82. lack of any definitions) are defined by the file. */
  83. /* Undefine everything, so we get a clean slate. */
  84. #undef __USE_ISOC11
  85. #undef __USE_ISOC99
  86. #undef __USE_ISOC95
  87. #undef __USE_ISOCXX11
  88. #undef __USE_POSIX
  89. #undef __USE_POSIX2
  90. #undef __USE_POSIX199309
  91. #undef __USE_POSIX199506
  92. #undef __USE_XOPEN
  93. #undef __USE_XOPEN_EXTENDED
  94. #undef __USE_UNIX98
  95. #undef __USE_XOPEN2K
  96. #undef __USE_XOPEN2KXSI
  97. #undef __USE_XOPEN2K8
  98. #undef __USE_XOPEN2K8XSI
  99. #undef __USE_LARGEFILE
  100. #undef __USE_LARGEFILE64
  101. #undef __USE_FILE_OFFSET64
  102. #undef __USE_MISC
  103. #undef __USE_ATFILE
  104. #undef __USE_GNU
  105. #undef __USE_REENTRANT
  106. #undef __USE_FORTIFY_LEVEL
  107. #undef __KERNEL_STRICT_NAMES
  108. /* Suppress kernel-name space pollution unless user expressedly asks
  109. for it. */
  110. #ifndef _LOOSE_KERNEL_NAMES
  111. # define __KERNEL_STRICT_NAMES
  112. #endif
  113. /* Convenience macros to test the versions of glibc and gcc.
  114. Use them like this:
  115. #if __GNUC_PREREQ (2,8)
  116. ... code requiring gcc 2.8 or later ...
  117. #endif
  118. Note - they won't work for gcc1 or glibc1, since the _MINOR macros
  119. were not defined then. */
  120. #if defined __GNUC__ && defined __GNUC_MINOR__
  121. # define __GNUC_PREREQ(maj, min) \
  122. ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
  123. #else
  124. # define __GNUC_PREREQ(maj, min) 0
  125. #endif
  126. /* _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for
  127. _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not
  128. issue a warning; the expectation is that the source is being
  129. transitioned to use the new macro. */
  130. #if (defined _BSD_SOURCE || defined _SVID_SOURCE) \
  131. && !defined _DEFAULT_SOURCE
  132. # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
  133. # undef _DEFAULT_SOURCE
  134. # define _DEFAULT_SOURCE 1
  135. #endif
  136. /* If _GNU_SOURCE was defined by the user, turn on all the other features. */
  137. #ifdef _GNU_SOURCE
  138. # undef _ISOC95_SOURCE
  139. # define _ISOC95_SOURCE 1
  140. # undef _ISOC99_SOURCE
  141. # define _ISOC99_SOURCE 1
  142. # undef _ISOC11_SOURCE
  143. # define _ISOC11_SOURCE 1
  144. # undef _POSIX_SOURCE
  145. # define _POSIX_SOURCE 1
  146. # undef _POSIX_C_SOURCE
  147. # define _POSIX_C_SOURCE 200809L
  148. # undef _XOPEN_SOURCE
  149. # define _XOPEN_SOURCE 700
  150. # undef _XOPEN_SOURCE_EXTENDED
  151. # define _XOPEN_SOURCE_EXTENDED 1
  152. # undef _LARGEFILE64_SOURCE
  153. # define _LARGEFILE64_SOURCE 1
  154. # undef _DEFAULT_SOURCE
  155. # define _DEFAULT_SOURCE 1
  156. # undef _ATFILE_SOURCE
  157. # define _ATFILE_SOURCE 1
  158. #endif
  159. /* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined,
  160. define _DEFAULT_SOURCE. */
  161. #if (defined _DEFAULT_SOURCE \
  162. || (!defined __STRICT_ANSI__ \
  163. && !defined _ISOC99_SOURCE \
  164. && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE \
  165. && !defined _XOPEN_SOURCE))
  166. # undef _DEFAULT_SOURCE
  167. # define _DEFAULT_SOURCE 1
  168. #endif
  169. /* This is to enable the ISO C11 extension. */
  170. #if (defined _ISOC11_SOURCE \
  171. || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L))
  172. # define __USE_ISOC11 1
  173. #endif
  174. /* This is to enable the ISO C99 extension. */
  175. #if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \
  176. || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
  177. # define __USE_ISOC99 1
  178. #endif
  179. /* This is to enable the ISO C90 Amendment 1:1995 extension. */
  180. #if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \
  181. || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L))
  182. # define __USE_ISOC95 1
  183. #endif
  184. /* This is to enable compatibility for ISO C++11.
  185. So far g++ does not provide a macro. Check the temporary macro for
  186. now, too. */
  187. #if ((defined __cplusplus && __cplusplus >= 201103L) \
  188. || defined __GXX_EXPERIMENTAL_CXX0X__)
  189. # define __USE_ISOCXX11 1
  190. #endif
  191. /* If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE
  192. is defined, use POSIX.1-2008 (or another version depending on
  193. _XOPEN_SOURCE). */
  194. #ifdef _DEFAULT_SOURCE
  195. # if !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE
  196. # define __USE_POSIX_IMPLICITLY 1
  197. # endif
  198. # undef _POSIX_SOURCE
  199. # define _POSIX_SOURCE 1
  200. # undef _POSIX_C_SOURCE
  201. # define _POSIX_C_SOURCE 200809L
  202. #endif
  203. #if ((!defined __STRICT_ANSI__ \
  204. || (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500)) \
  205. && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
  206. # define _POSIX_SOURCE 1
  207. # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
  208. # define _POSIX_C_SOURCE 2
  209. # elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 600
  210. # define _POSIX_C_SOURCE 199506L
  211. # elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 700
  212. # define _POSIX_C_SOURCE 200112L
  213. # else
  214. # define _POSIX_C_SOURCE 200809L
  215. # endif
  216. # define __USE_POSIX_IMPLICITLY 1
  217. #endif
  218. #if (defined _POSIX_SOURCE \
  219. || (defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 1) \
  220. || defined _XOPEN_SOURCE)
  221. # define __USE_POSIX 1
  222. #endif
  223. #if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
  224. # define __USE_POSIX2 1
  225. #endif
  226. #if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199309L
  227. # define __USE_POSIX199309 1
  228. #endif
  229. #if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199506L
  230. # define __USE_POSIX199506 1
  231. #endif
  232. #if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200112L
  233. # define __USE_XOPEN2K 1
  234. # undef __USE_ISOC95
  235. # define __USE_ISOC95 1
  236. # undef __USE_ISOC99
  237. # define __USE_ISOC99 1
  238. #endif
  239. #if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200809L
  240. # define __USE_XOPEN2K8 1
  241. # undef _ATFILE_SOURCE
  242. # define _ATFILE_SOURCE 1
  243. #endif
  244. #ifdef _XOPEN_SOURCE
  245. # define __USE_XOPEN 1
  246. # if (_XOPEN_SOURCE - 0) >= 500
  247. # define __USE_XOPEN_EXTENDED 1
  248. # define __USE_UNIX98 1
  249. # undef _LARGEFILE_SOURCE
  250. # define _LARGEFILE_SOURCE 1
  251. # if (_XOPEN_SOURCE - 0) >= 600
  252. # if (_XOPEN_SOURCE - 0) >= 700
  253. # define __USE_XOPEN2K8 1
  254. # define __USE_XOPEN2K8XSI 1
  255. # endif
  256. # define __USE_XOPEN2K 1
  257. # define __USE_XOPEN2KXSI 1
  258. # undef __USE_ISOC95
  259. # define __USE_ISOC95 1
  260. # undef __USE_ISOC99
  261. # define __USE_ISOC99 1
  262. # endif
  263. # else
  264. # ifdef _XOPEN_SOURCE_EXTENDED
  265. # define __USE_XOPEN_EXTENDED 1
  266. # endif
  267. # endif
  268. #endif
  269. #ifdef _LARGEFILE_SOURCE
  270. # define __USE_LARGEFILE 1
  271. #endif
  272. #ifdef _LARGEFILE64_SOURCE
  273. # define __USE_LARGEFILE64 1
  274. #endif
  275. #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
  276. # define __USE_FILE_OFFSET64 1
  277. #endif
  278. #if defined _DEFAULT_SOURCE
  279. # define __USE_MISC 1
  280. #endif
  281. #ifdef _ATFILE_SOURCE
  282. # define __USE_ATFILE 1
  283. #endif
  284. #ifdef _GNU_SOURCE
  285. # define __USE_GNU 1
  286. #endif
  287. #if defined _REENTRANT || defined _THREAD_SAFE
  288. # define __USE_REENTRANT 1
  289. #endif
  290. #if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0
  291. # if !defined __OPTIMIZE__ || __OPTIMIZE__ <= 0
  292. # warning _FORTIFY_SOURCE requires compiling with optimization (-O)
  293. # elif !__GNUC_PREREQ (4, 1)
  294. # warning _FORTIFY_SOURCE requires GCC 4.1 or later
  295. # elif _FORTIFY_SOURCE > 1
  296. # define __USE_FORTIFY_LEVEL 2
  297. # else
  298. # define __USE_FORTIFY_LEVEL 1
  299. # endif
  300. #endif
  301. #ifndef __USE_FORTIFY_LEVEL
  302. # define __USE_FORTIFY_LEVEL 0
  303. #endif
  304. /* Get definitions of __STDC_* predefined macros, if the compiler has
  305. not preincluded this header automatically. */
  306. #include <stdc-predef.h>
  307. /* This macro indicates that the installed library is the GNU C Library.
  308. For historic reasons the value now is 6 and this will stay from now
  309. on. The use of this variable is deprecated. Use __GLIBC__ and
  310. __GLIBC_MINOR__ now (see below) when you want to test for a specific
  311. GNU C library version and use the values in <gnu/lib-names.h> to get
  312. the sonames of the shared libraries. */
  313. #undef __GNU_LIBRARY__
  314. #define __GNU_LIBRARY__ 6
  315. /* Major and minor version number of the GNU C library package. Use
  316. these macros to test for features in specific releases. */
  317. #define __GLIBC__ 2
  318. #define __GLIBC_MINOR__ 23
  319. #define __GLIBC_PREREQ(maj, min) \
  320. ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
  321. /* This is here only because every header file already includes this one. */
  322. #ifndef __ASSEMBLER__
  323. # ifndef _SYS_CDEFS_H
  324. # include <sys/cdefs.h>
  325. # endif
  326. /* If we don't have __REDIRECT, prototypes will be missing if
  327. __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
  328. # if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
  329. # define __USE_LARGEFILE 1
  330. # define __USE_LARGEFILE64 1
  331. # endif
  332. #endif /* !ASSEMBLER */
  333. /* Decide whether we can define 'extern inline' functions in headers. */
  334. #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
  335. && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \
  336. && defined __extern_inline
  337. # define __USE_EXTERN_INLINES 1
  338. #endif
  339. /* This is here only because every header file already includes this one.
  340. Get the definitions of all the appropriate `__stub_FUNCTION' symbols.
  341. <gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub
  342. that will always return failure (and set errno to ENOSYS). */
  343. #include <gnu/stubs.h>
  344. #endif /* features.h */