features.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. /* Copyright (C) 1991-1993,1995-2006,2007,2009 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, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #ifndef _FEATURES_H
  16. #define _FEATURES_H 1
  17. /* These are defined by the user (or the compiler)
  18. to specify the desired environment:
  19. __STRICT_ANSI__ ISO Standard C.
  20. _ISOC99_SOURCE Extensions to ISO C89 from ISO C99.
  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. _BSD_SOURCE ISO C, POSIX, and 4.3BSD things.
  35. _SVID_SOURCE ISO C, POSIX, and SVID things.
  36. _ATFILE_SOURCE Additional *at interfaces.
  37. _GNU_SOURCE All of the above, plus GNU extensions.
  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 defines __STRICT_ANSI__.
  43. If none of these are defined, the default is to have _SVID_SOURCE,
  44. _BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
  45. 200112L. If more than one of these are defined, they accumulate.
  46. For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE
  47. together give you ISO C, 1003.1, and 1003.2, but nothing else.
  48. These are defined by this file and are used by the
  49. header files to decide what to declare or define:
  50. __USE_ISOC99 Define ISO C99 things.
  51. __USE_ISOC95 Define ISO C90 AMD1 (C95) things.
  52. __USE_POSIX Define IEEE Std 1003.1 things.
  53. __USE_POSIX2 Define IEEE Std 1003.2 things.
  54. __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things.
  55. __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things.
  56. __USE_XOPEN Define XPG things.
  57. __USE_XOPEN_EXTENDED Define X/Open Unix things.
  58. __USE_UNIX98 Define Single Unix V2 things.
  59. __USE_XOPEN2K Define XPG6 things.
  60. __USE_XOPEN2K8 Define XPG7 things.
  61. __USE_LARGEFILE Define correct standard I/O things.
  62. __USE_LARGEFILE64 Define LFS things with separate names.
  63. __USE_FILE_OFFSET64 Define 64bit interface as default.
  64. __USE_BSD Define 4.3BSD things.
  65. __USE_SVID Define SVID things.
  66. __USE_MISC Define things common to BSD and System V Unix.
  67. __USE_ATFILE Define *at interfaces and AT_* constants for them.
  68. __USE_GNU Define GNU extensions.
  69. __USE_REENTRANT Define reentrant/thread-safe *_r functions.
  70. __USE_FORTIFY_LEVEL Additional security measures used, according to level.
  71. __FAVOR_BSD Favor 4.3BSD things in cases of conflict.
  72. The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are
  73. defined by this file unconditionally. `__GNU_LIBRARY__' is provided
  74. only for compatibility. All new code should use the other symbols
  75. to test for features.
  76. All macros listed above as possibly being defined by this file are
  77. explicitly undefined if they are not explicitly defined.
  78. Feature-test macros that are not defined by the user or compiler
  79. but are implied by the other feature-test macros defined (or by the
  80. lack of any definitions) are defined by the file. */
  81. /* Undefine everything, so we get a clean slate. */
  82. #undef __USE_ISOC99
  83. #undef __USE_ISOC95
  84. #undef __USE_POSIX
  85. #undef __USE_POSIX2
  86. #undef __USE_POSIX199309
  87. #undef __USE_POSIX199506
  88. #undef __USE_XOPEN
  89. #undef __USE_XOPEN_EXTENDED
  90. #undef __USE_UNIX98
  91. #undef __USE_XOPEN2K
  92. #undef __USE_XOPEN2K8
  93. #undef __USE_LARGEFILE
  94. #undef __USE_LARGEFILE64
  95. #undef __USE_FILE_OFFSET64
  96. #undef __USE_BSD
  97. #undef __USE_SVID
  98. #undef __USE_MISC
  99. #undef __USE_ATFILE
  100. #undef __USE_GNU
  101. #undef __USE_REENTRANT
  102. #undef __USE_FORTIFY_LEVEL
  103. #undef __FAVOR_BSD
  104. #undef __KERNEL_STRICT_NAMES
  105. /* Suppress kernel-name space pollution unless user expressedly asks
  106. for it. */
  107. #ifndef _LOOSE_KERNEL_NAMES
  108. # define __KERNEL_STRICT_NAMES
  109. #endif
  110. /* Always use ISO C things. */
  111. #define __USE_ANSI 1
  112. /* Convenience macros to test the versions of glibc and gcc.
  113. Use them like this:
  114. #if __GNUC_PREREQ (2,8)
  115. ... code requiring gcc 2.8 or later ...
  116. #endif
  117. Note - they won't work for gcc1 or glibc1, since the _MINOR macros
  118. were not defined then. */
  119. #if defined __GNUC__ && defined __GNUC_MINOR__
  120. # define __GNUC_PREREQ(maj, min) \
  121. ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
  122. #else
  123. # define __GNUC_PREREQ(maj, min) 0
  124. #endif
  125. /* If _BSD_SOURCE was defined by the user, favor BSD over POSIX. */
  126. #if defined _BSD_SOURCE && \
  127. !(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \
  128. defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \
  129. defined _GNU_SOURCE || defined _SVID_SOURCE)
  130. # define __FAVOR_BSD 1
  131. #endif
  132. /* If _GNU_SOURCE was defined by the user, turn on all the other features. */
  133. #ifdef _GNU_SOURCE
  134. # undef _ISOC99_SOURCE
  135. # define _ISOC99_SOURCE 1
  136. # undef _POSIX_SOURCE
  137. # define _POSIX_SOURCE 1
  138. # undef _POSIX_C_SOURCE
  139. # define _POSIX_C_SOURCE 200809L
  140. # undef _XOPEN_SOURCE
  141. # define _XOPEN_SOURCE 700
  142. # undef _XOPEN_SOURCE_EXTENDED
  143. # define _XOPEN_SOURCE_EXTENDED 1
  144. # undef _LARGEFILE64_SOURCE
  145. # define _LARGEFILE64_SOURCE 1
  146. # undef _BSD_SOURCE
  147. # define _BSD_SOURCE 1
  148. # undef _SVID_SOURCE
  149. # define _SVID_SOURCE 1
  150. # undef _ATFILE_SOURCE
  151. # define _ATFILE_SOURCE 1
  152. #endif
  153. /* This macro indicates that the installed library is uClibc. Use
  154. * __UCLIBC_MAJOR__ and __UCLIBC_MINOR__ to test for the features in
  155. * specific releases. */
  156. #define __UCLIBC__ 1
  157. #ifdef __UCLIBC__
  158. /* Load up the current set of uClibc supported features along
  159. * with the current uClibc major and minor version numbers.
  160. * For uClibc release 0.9.26, these numbers would be:
  161. * #define __UCLIBC_MAJOR__ 0
  162. * #define __UCLIBC_MINOR__ 9
  163. * #define __UCLIBC_SUBLEVEL__ 26
  164. */
  165. # define __need_uClibc_config_h
  166. # include <bits/uClibc_config.h>
  167. # undef __need_uClibc_config_h
  168. /* For uClibc, always optimize for size -- this should disable
  169. * a lot of expensive inlining...
  170. * TODO: this is wrong! __OPTIMIZE_SIZE__ is an indicator of
  171. * gcc -Os compile. We should not mess with compiler inlines.
  172. * We should instead disable __USE_EXTERN_INLINES unconditionally,
  173. * or maybe actually audit and test uclibc to work correctly
  174. * with __USE_EXTERN_INLINES on.
  175. */
  176. # define __OPTIMIZE_SIZE__ 1
  177. /* disable unsupported features */
  178. # undef __LDBL_COMPAT
  179. # ifndef __UCLIBC_HAS_FORTIFY__
  180. # undef _FORTIFY_SOURCE
  181. # endif
  182. # ifndef __UCLIBC_HAS_THREADS__
  183. # if defined _REENTRANT || defined _THREAD_SAFE
  184. # warning requested reentrant code, but thread support was disabled
  185. # undef _REENTRANT
  186. # undef _THREAD_SAFE
  187. # endif
  188. # endif
  189. # ifndef __UCLIBC_HAS_LFS__
  190. # undef _LARGEFILE64_SOURCE
  191. /* NOTE: This is probably incorrect on a 64-bit arch... */
  192. # if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
  193. # error It appears you have defined _FILE_OFFSET_BITS=64. Unfortunately, \
  194. uClibc was built without large file support enabled.
  195. # endif
  196. # elif defined __BCC__
  197. # error BCC does not support LFS, please disable it
  198. # endif
  199. #endif /* __UCLIBC__ */
  200. /* If nothing (other than _GNU_SOURCE) is defined,
  201. define _BSD_SOURCE and _SVID_SOURCE. */
  202. #if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \
  203. !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \
  204. !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \
  205. !defined _BSD_SOURCE && !defined _SVID_SOURCE)
  206. # define _BSD_SOURCE 1
  207. # define _SVID_SOURCE 1
  208. #endif
  209. /* This is to enable the ISO C99 extension. Also recognize the old macro
  210. which was used prior to the standard acceptance. This macro will
  211. eventually go away and the features enabled by default once the ISO C99
  212. standard is widely adopted. */
  213. #if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \
  214. || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
  215. # define __USE_ISOC99 1
  216. #endif
  217. /* This is to enable the ISO C90 Amendment 1:1995 extension. */
  218. #if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \
  219. || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L))
  220. # define __USE_ISOC95 1
  221. #endif
  222. /* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
  223. (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */
  224. #if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \
  225. !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
  226. # define _POSIX_SOURCE 1
  227. # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
  228. # define _POSIX_C_SOURCE 2
  229. # elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 600
  230. # define _POSIX_C_SOURCE 199506L
  231. # elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 700
  232. # define _POSIX_C_SOURCE 200112L
  233. # else
  234. # define _POSIX_C_SOURCE 200809L
  235. # endif
  236. # define __USE_POSIX_IMPLICITLY 1
  237. #endif
  238. #if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
  239. # define __USE_POSIX 1
  240. #endif
  241. #if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
  242. # define __USE_POSIX2 1
  243. #endif
  244. #if (_POSIX_C_SOURCE - 0) >= 199309L
  245. # define __USE_POSIX199309 1
  246. #endif
  247. #if (_POSIX_C_SOURCE - 0) >= 199506L
  248. # define __USE_POSIX199506 1
  249. #endif
  250. #if (_POSIX_C_SOURCE - 0) >= 200112L
  251. # define __USE_XOPEN2K 1
  252. # undef __USE_ISOC99
  253. # define __USE_ISOC99 1
  254. #endif
  255. #if (_POSIX_C_SOURCE - 0) >= 200809L
  256. # define __USE_XOPEN2K8 1
  257. # undef _ATFILE_SOURCE
  258. # define _ATFILE_SOURCE 1
  259. #endif
  260. #ifdef _XOPEN_SOURCE
  261. # define __USE_XOPEN 1
  262. # if (_XOPEN_SOURCE - 0) >= 500
  263. # define __USE_XOPEN_EXTENDED 1
  264. # define __USE_UNIX98 1
  265. # undef _LARGEFILE_SOURCE
  266. # define _LARGEFILE_SOURCE 1
  267. # if (_XOPEN_SOURCE - 0) >= 600
  268. # if (_XOPEN_SOURCE - 0) >= 700
  269. # define __USE_XOPEN2K8 1
  270. # endif
  271. # define __USE_XOPEN2K 1
  272. # undef __USE_ISOC99
  273. # define __USE_ISOC99 1
  274. # endif
  275. # else
  276. # ifdef _XOPEN_SOURCE_EXTENDED
  277. # define __USE_XOPEN_EXTENDED 1
  278. # endif
  279. # endif
  280. #endif
  281. #ifdef _LARGEFILE_SOURCE
  282. # define __USE_LARGEFILE 1
  283. #endif
  284. #ifdef _LARGEFILE64_SOURCE
  285. # define __USE_LARGEFILE64 1
  286. #endif
  287. #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
  288. # define __USE_FILE_OFFSET64 1
  289. #endif
  290. #if defined _BSD_SOURCE || defined _SVID_SOURCE
  291. # define __USE_MISC 1
  292. #endif
  293. #ifdef _BSD_SOURCE
  294. # define __USE_BSD 1
  295. #endif
  296. #ifdef _SVID_SOURCE
  297. # define __USE_SVID 1
  298. #endif
  299. #ifdef _ATFILE_SOURCE
  300. # define __USE_ATFILE 1
  301. #endif
  302. #ifdef _GNU_SOURCE
  303. # define __USE_GNU 1
  304. #endif
  305. #if defined _REENTRANT || defined _THREAD_SAFE
  306. # define __USE_REENTRANT 1
  307. #endif
  308. #if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \
  309. && __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
  310. # if _FORTIFY_SOURCE > 1
  311. # define __USE_FORTIFY_LEVEL 2
  312. # else
  313. # define __USE_FORTIFY_LEVEL 1
  314. # endif
  315. #else
  316. # define __USE_FORTIFY_LEVEL 0
  317. #endif
  318. /* We do support the IEC 559 math functionality, real and complex. */
  319. #ifdef __UCLIBC_HAS_FLOATS__
  320. #define __STDC_IEC_559__ 1
  321. #define __STDC_IEC_559_COMPLEX__ 1
  322. #endif
  323. #ifdef __UCLIBC_HAS_WCHAR__
  324. /* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.1. */
  325. #define __STDC_ISO_10646__ 200009L
  326. #endif
  327. /* There is an unwholesomely huge amount of code out there that depends on the
  328. * presence of GNU libc header files. We have GNU libc header files. So here
  329. * we commit a horrible sin. At this point, we _lie_ and claim to be GNU libc
  330. * to make things like /usr/include/linux/socket.h and lots of apps work as
  331. * their developers intended. This is IMHO, pardonable, since these defines
  332. * are not really intended to check for the presence of a particular library,
  333. * but rather are used to define an _interface_. */
  334. #if !defined __FORCE_NOGLIBC && (!defined _LIBC || defined __FORCE_GLIBC)
  335. /* This macro indicates that the installed library is the GNU C Library.
  336. For historic reasons the value now is 6 and this will stay from now
  337. on. The use of this variable is deprecated. */
  338. /* uClibc WARNING: leave these aligned to the left, don't put a space after '#', else
  339. * broken apps could fail the check. */
  340. #undef __GNU_LIBRARY__
  341. #define __GNU_LIBRARY__ 6
  342. /* Major and minor version number of the GNU C library package. Use
  343. these macros to test for features in specific releases. */
  344. /* Don't do it, if you want to keep uClibc happy. */
  345. #define __GLIBC__ 2
  346. #define __GLIBC_MINOR__ 2
  347. #endif
  348. #define __GLIBC_PREREQ(maj, min) \
  349. ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
  350. #ifndef __UCLIBC__
  351. /* Decide whether a compiler supports the long long datatypes. */
  352. #if defined __GNUC__ \
  353. || (defined __PGI && defined __i386__ ) \
  354. || (defined __INTEL_COMPILER && (defined __i386__ || defined __ia64__)) \
  355. || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
  356. # define __GLIBC_HAVE_LONG_LONG 1
  357. #endif
  358. #endif
  359. /* This is here only because every header file already includes this one. */
  360. #ifndef __ASSEMBLER__
  361. # ifndef _SYS_CDEFS_H
  362. # include <sys/cdefs.h>
  363. # endif
  364. /* If we don't have __REDIRECT, prototypes will be missing if
  365. __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
  366. # if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
  367. # define __USE_LARGEFILE 1
  368. # ifdef __UCLIBC_HAS_LFS__
  369. # define __USE_LARGEFILE64 1
  370. # endif
  371. # endif
  372. #endif /* !ASSEMBLER */
  373. /* Decide whether we can, and are willing to define extern inline
  374. * functions in headers, even if this results in a slightly bigger
  375. * code for user programs built against uclibc.
  376. * Enabled only in -O2 compiles, not -Os.
  377. * uclibc itself is usually built without __USE_EXTERN_INLINES,
  378. * remove "&& !defined __OPTIMIZE_SIZE__" part to do otherwise.
  379. */
  380. #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
  381. && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \
  382. && (defined __extern_inline || defined __GNUC_GNU_INLINE__ || defined __GNUC_STDC_INLINE__)
  383. # define __USE_EXTERN_INLINES 1
  384. #endif
  385. #ifdef _LIBC
  386. # ifdef __UCLIBC_HAS_LFS__
  387. # undef _FILE_OFFSET_BITS
  388. # undef __USE_FILE_OFFSET64
  389. # endif
  390. # include <libc-internal.h>
  391. #endif
  392. #endif /* features.h */