features.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. /* Copyright (C) 1991-1993,1995-2003,2004,2005 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. /* For uClibc, always optimize for size -- this should disable
  18. * a lot of expensive inlining... */
  19. #define __OPTIMIZE_SIZE__ 1
  20. /* These are defined by the user (or the compiler)
  21. to specify the desired environment:
  22. __STRICT_ANSI__ ISO Standard C.
  23. _ISOC99_SOURCE Extensions to ISO C89 from ISO C99.
  24. _POSIX_SOURCE IEEE Std 1003.1.
  25. _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;
  26. if >=199309L, add IEEE Std 1003.1b-1993;
  27. if >=199506L, add IEEE Std 1003.1c-1995;
  28. if >=200112L, all of IEEE 1003.1-2004
  29. _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if
  30. Single Unix conformance is wanted, to 600 for the
  31. upcoming sixth revision.
  32. _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
  33. _LARGEFILE_SOURCE Some more functions for correct standard I/O.
  34. _LARGEFILE64_SOURCE Additional functionality from LFS for large files.
  35. _FILE_OFFSET_BITS=N Select default filesystem interface.
  36. _BSD_SOURCE ISO C, POSIX, and 4.3BSD things.
  37. _SVID_SOURCE ISO C, POSIX, and SVID things.
  38. _GNU_SOURCE All of the above, plus GNU extensions.
  39. _REENTRANT Select additionally reentrant object.
  40. _THREAD_SAFE Same as _REENTRANT, often used by other systems.
  41. _FORTIFY_SOURCE If set to numeric value > 0 additional security
  42. measures are defined, according to level.
  43. The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__.
  44. If none of these are defined, the default is to have _SVID_SOURCE,
  45. _BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
  46. 199506L. If more than one of these are defined, they accumulate.
  47. For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE
  48. together give you ISO C, 1003.1, and 1003.2, but nothing else.
  49. These are defined by this file and are used by the
  50. header files to decide what to declare or define:
  51. __USE_ISOC99 Define ISO C99 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_LARGEFILE Define correct standard I/O things.
  61. __USE_LARGEFILE64 Define LFS things with separate names.
  62. __USE_FILE_OFFSET64 Define 64bit interface as default.
  63. __USE_BSD Define 4.3BSD things.
  64. __USE_SVID Define SVID things.
  65. __USE_MISC Define things common to BSD and System V Unix.
  66. __USE_GNU Define GNU extensions.
  67. __USE_REENTRANT Define reentrant/thread-safe *_r functions.
  68. __USE_FORTIFY_LEVEL Additional security measures used, according to level.
  69. __FAVOR_BSD Favor 4.3BSD things in cases of conflict.
  70. The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are
  71. defined by this file unconditionally. `__GNU_LIBRARY__' is provided
  72. only for compatibility. All new code should use the other symbols
  73. to test for features.
  74. All macros listed above as possibly being defined by this file are
  75. explicitly undefined if they are not explicitly defined.
  76. Feature-test macros that are not defined by the user or compiler
  77. but are implied by the other feature-test macros defined (or by the
  78. lack of any definitions) are defined by the file. */
  79. /* Undefine everything, so we get a clean slate. */
  80. #undef __USE_ISOC99
  81. #undef __USE_POSIX
  82. #undef __USE_POSIX2
  83. #undef __USE_POSIX199309
  84. #undef __USE_POSIX199506
  85. #undef __USE_XOPEN
  86. #undef __USE_XOPEN_EXTENDED
  87. #undef __USE_UNIX98
  88. #undef __USE_XOPEN2K
  89. #undef __USE_LARGEFILE
  90. #undef __USE_LARGEFILE64
  91. #undef __USE_FILE_OFFSET64
  92. #undef __USE_BSD
  93. #undef __USE_SVID
  94. #undef __USE_MISC
  95. #undef __USE_GNU
  96. #undef __USE_REENTRANT
  97. #undef __USE_FORTIFY_LEVEL
  98. #undef __FAVOR_BSD
  99. #undef __KERNEL_STRICT_NAMES
  100. /* Suppress kernel-name space pollution unless user expressedly asks
  101. for it. */
  102. #ifndef _LOOSE_KERNEL_NAMES
  103. # define __KERNEL_STRICT_NAMES
  104. #endif
  105. /* Always use ISO C things. */
  106. #define __USE_ANSI 1
  107. /* Convenience macros to test the versions of glibc and gcc.
  108. Use them like this:
  109. #if __GNUC_PREREQ (2,8)
  110. ... code requiring gcc 2.8 or later ...
  111. #endif
  112. Note - they won't work for gcc1 or glibc1, since the _MINOR macros
  113. were not defined then. */
  114. #if defined __GNUC__ && defined __GNUC_MINOR__
  115. # define __GNUC_PREREQ(maj, min) \
  116. ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
  117. #else
  118. # define __GNUC_PREREQ(maj, min) 0
  119. #endif
  120. /* If _BSD_SOURCE was defined by the user, favor BSD over POSIX. */
  121. #if defined _BSD_SOURCE && \
  122. !(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \
  123. defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \
  124. defined _GNU_SOURCE || defined _SVID_SOURCE)
  125. # define __FAVOR_BSD 1
  126. #endif
  127. /* If _GNU_SOURCE was defined by the user, turn on all the other features. */
  128. #ifdef _GNU_SOURCE
  129. # undef _ISOC99_SOURCE
  130. # define _ISOC99_SOURCE 1
  131. # undef _POSIX_SOURCE
  132. # define _POSIX_SOURCE 1
  133. # undef _POSIX_C_SOURCE
  134. # define _POSIX_C_SOURCE 199506L
  135. # undef _XOPEN_SOURCE
  136. # define _XOPEN_SOURCE 600
  137. # undef _XOPEN_SOURCE_EXTENDED
  138. # define _XOPEN_SOURCE_EXTENDED 1
  139. # undef _LARGEFILE64_SOURCE
  140. # define _LARGEFILE64_SOURCE 1
  141. # undef _BSD_SOURCE
  142. # define _BSD_SOURCE 1
  143. # undef _SVID_SOURCE
  144. # define _SVID_SOURCE 1
  145. #endif
  146. /* If nothing (other than _GNU_SOURCE) is defined,
  147. define _BSD_SOURCE and _SVID_SOURCE. */
  148. #if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \
  149. !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \
  150. !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \
  151. !defined _BSD_SOURCE && !defined _SVID_SOURCE)
  152. # define _BSD_SOURCE 1
  153. # define _SVID_SOURCE 1
  154. #endif
  155. /* This is to enable the ISO C99 extension. Also recognize the old macro
  156. which was used prior to the standard acceptance. This macro will
  157. eventually go away and the features enabled by default once the ISO C99
  158. standard is widely adopted. */
  159. #if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \
  160. || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
  161. # define __USE_ISOC99 1
  162. #endif
  163. /* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
  164. (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */
  165. #if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \
  166. !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
  167. # define _POSIX_SOURCE 1
  168. # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
  169. # define _POSIX_C_SOURCE 2
  170. # else
  171. # define _POSIX_C_SOURCE 199506L
  172. # endif
  173. #endif
  174. #if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
  175. # define __USE_POSIX 1
  176. #endif
  177. #if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
  178. # define __USE_POSIX2 1
  179. #endif
  180. #if (_POSIX_C_SOURCE - 0) >= 199309L
  181. # define __USE_POSIX199309 1
  182. #endif
  183. #if (_POSIX_C_SOURCE - 0) >= 199506L
  184. # define __USE_POSIX199506 1
  185. #endif
  186. #if (_POSIX_C_SOURCE - 0) >= 200112L
  187. # define __USE_XOPEN2K 1
  188. #endif
  189. #ifdef _XOPEN_SOURCE
  190. # define __USE_XOPEN 1
  191. # if (_XOPEN_SOURCE - 0) >= 500
  192. # define __USE_XOPEN_EXTENDED 1
  193. # define __USE_UNIX98 1
  194. # undef _LARGEFILE_SOURCE
  195. # define _LARGEFILE_SOURCE 1
  196. # if (_XOPEN_SOURCE - 0) >= 600
  197. # define __USE_XOPEN2K 1
  198. # undef __USE_ISOC99
  199. # define __USE_ISOC99 1
  200. # endif
  201. # else
  202. # ifdef _XOPEN_SOURCE_EXTENDED
  203. # define __USE_XOPEN_EXTENDED 1
  204. # endif
  205. # endif
  206. #endif
  207. #ifdef _LARGEFILE_SOURCE
  208. # define __USE_LARGEFILE 1
  209. #endif
  210. #ifdef _LARGEFILE64_SOURCE
  211. # define __USE_LARGEFILE64 1
  212. #endif
  213. #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
  214. # define __USE_FILE_OFFSET64 1
  215. #endif
  216. #if defined _BSD_SOURCE || defined _SVID_SOURCE
  217. # define __USE_MISC 1
  218. #endif
  219. #ifdef _BSD_SOURCE
  220. # define __USE_BSD 1
  221. #endif
  222. #ifdef _SVID_SOURCE
  223. # define __USE_SVID 1
  224. #endif
  225. #ifdef _GNU_SOURCE
  226. # define __USE_GNU 1
  227. #endif
  228. #if defined _REENTRANT || defined _THREAD_SAFE
  229. # define __USE_REENTRANT 1
  230. #endif
  231. #if _FORTIFY_SOURCE > 0 && __GNUC_PREREQ (4, 1) && defined(__OPTIMIZE__)
  232. # if _FORTIFY_SOURCE == 1
  233. # define __USE_FORTIFY_LEVEL 1
  234. # elif _FORTIFY_SOURCE > 1
  235. # define __USE_FORTIFY_LEVEL 2
  236. # endif
  237. #endif
  238. /* We do support the IEC 559 math functionality, real and complex. */
  239. #define __STDC_IEC_559__ 1
  240. #define __STDC_IEC_559_COMPLEX__ 1
  241. /* This macro indicates that the installed library is uClibc. Use
  242. * __UCLIBC_MAJOR__ and __UCLIBC_MINOR__ to test for the features in
  243. * specific releases. */
  244. #define __UCLIBC__ 1
  245. /* Load up the current set of uClibc supported features along
  246. * with the current uClibc major and minor version numbers.
  247. * For uClibc release 0.9.26, these numbers would be:
  248. * #define __UCLIBC_MAJOR__ 0
  249. * #define __UCLIBC_MINOR__ 9
  250. * #define __UCLIBC_SUBLEVEL__ 26
  251. */
  252. #define __need_uClibc_config_h
  253. #include <bits/uClibc_config.h>
  254. #undef __need_uClibc_config_h
  255. #ifdef __UCLIBC_HAS_WCHAR__
  256. /* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.0. */
  257. # define __STDC_ISO_10646__ 200009L
  258. #endif
  259. /* There is an unwholesomely huge amount of code out there that depends on the
  260. * presence of GNU libc header files. We have GNU libc header files. So here
  261. * we commit a horrible sin. At this point, we _lie_ and claim to be GNU libc
  262. * to make things like /usr/include/linux/socket.h and lots of apps work as
  263. * their developers intended. This is IMHO, pardonable, since these defines
  264. * are not really intended to check for the presence of a particular library,
  265. * but rather are used to define an _interface_. */
  266. #if !defined __FORCE_NOGLIBC && (!defined _LIBC || defined __FORCE_GLIBC)
  267. # define __GNU_LIBRARY__ 6
  268. # define __GLIBC__ 2
  269. # define __GLIBC_MINOR__ 2
  270. #endif
  271. #define __GLIBC_PREREQ(maj, min) \
  272. ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
  273. /* This is here only because every header file already includes this one. */
  274. #ifndef __ASSEMBLER__
  275. # ifndef _SYS_CDEFS_H
  276. # include <sys/cdefs.h>
  277. # endif
  278. /* If we don't have __REDIRECT, prototypes will be missing if
  279. __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
  280. # if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
  281. # define __USE_LARGEFILE 1
  282. # define __USE_LARGEFILE64 1
  283. # endif
  284. #endif /* !ASSEMBLER */
  285. /* Decide whether we can define 'extern inline' functions in headers. */
  286. #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
  287. && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
  288. # define __USE_EXTERN_INLINES 1
  289. #endif
  290. /* Make sure users large file options agree with uClibc's configuration. */
  291. #ifndef __UCLIBC_HAS_LFS__
  292. /* If uClibc was built without large file support, output an error if
  293. * and 64-bit file offsets were requested, output an error.
  294. * NOTE: This is probably incorrect on a 64-bit arch... */
  295. #ifdef __USE_FILE_OFFSET64
  296. #error It appears you have defined _FILE_OFFSET_BITS=64. Unfortunately, \
  297. uClibc was built without large file support enabled.
  298. #endif
  299. /* If uClibc was built without large file support and _LARGEFILE64_SOURCE
  300. * is defined, undefine it. */
  301. #if defined(_LARGEFILE64_SOURCE)
  302. #undef _LARGEFILE64_SOURCE
  303. #undef __USE_LARGEFILE64
  304. #endif
  305. /* If we're actually building uClibc with large file support,
  306. * define __USE_LARGEFILE64 and __USE_LARGEFILE. */
  307. #elif defined(_LIBC)
  308. #undef _LARGEFILE_SOURCE
  309. #undef _LARGEFILE64_SOURCE
  310. #undef _FILE_OFFSET_BITS
  311. #undef __USE_LARGEFILE
  312. #undef __USE_LARGEFILE64
  313. #undef __USE_FILE_OFFSET64
  314. #define _LARGEFILE_SOURCE 1
  315. #define _LARGEFILE64_SOURCE 1
  316. #define __USE_LARGEFILE 1
  317. #define __USE_LARGEFILE64 1
  318. #endif
  319. #ifdef _LIBC
  320. # include <libc-internal.h>
  321. #endif
  322. #ifndef __linux__
  323. # define __linux__ 1
  324. #endif
  325. /* Disable __user, which shows up in 2.6.x include asm headers
  326. * that get pulled in by signal.h */
  327. #define __user
  328. #endif /* features.h */