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