features.h 14 KB

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