features.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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. # undef _LARGEFILE64_SOURCE
  158. # define _LARGEFILE64_SOURCE 1
  159. # undef _BSD_SOURCE
  160. # define _BSD_SOURCE 1
  161. # undef _SVID_SOURCE
  162. # define _SVID_SOURCE 1
  163. # undef _ATFILE_SOURCE
  164. # define _ATFILE_SOURCE 1
  165. #endif
  166. /* If nothing (other than _GNU_SOURCE) is defined,
  167. define _BSD_SOURCE and _SVID_SOURCE. */
  168. #if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \
  169. !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \
  170. !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \
  171. !defined _BSD_SOURCE && !defined _SVID_SOURCE)
  172. # define _BSD_SOURCE 1
  173. # define _SVID_SOURCE 1
  174. #endif
  175. /* This is to enable the ISO C99 extension. Also recognize the old macro
  176. which was used prior to the standard acceptance. This macro will
  177. eventually go away and the features enabled by default once the ISO C99
  178. standard is widely adopted. */
  179. #if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \
  180. || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
  181. # define __USE_ISOC99 1
  182. #endif
  183. /* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
  184. (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */
  185. #if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \
  186. !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
  187. # define _POSIX_SOURCE 1
  188. # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
  189. # define _POSIX_C_SOURCE 2
  190. # else
  191. # define _POSIX_C_SOURCE 199506L
  192. # endif
  193. #endif
  194. #if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
  195. # define __USE_POSIX 1
  196. #endif
  197. #if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
  198. # define __USE_POSIX2 1
  199. #endif
  200. #if (_POSIX_C_SOURCE - 0) >= 199309L
  201. # define __USE_POSIX199309 1
  202. #endif
  203. #if (_POSIX_C_SOURCE - 0) >= 199506L
  204. # define __USE_POSIX199506 1
  205. #endif
  206. #if (_POSIX_C_SOURCE - 0) >= 200112L
  207. # define __USE_XOPEN2K 1
  208. #endif
  209. #ifdef _XOPEN_SOURCE
  210. # define __USE_XOPEN 1
  211. # if (_XOPEN_SOURCE - 0) >= 500
  212. # define __USE_XOPEN_EXTENDED 1
  213. # define __USE_UNIX98 1
  214. # undef _LARGEFILE_SOURCE
  215. # define _LARGEFILE_SOURCE 1
  216. # if (_XOPEN_SOURCE - 0) >= 600
  217. # define __USE_XOPEN2K 1
  218. # undef __USE_ISOC99
  219. # define __USE_ISOC99 1
  220. # endif
  221. # else
  222. # ifdef _XOPEN_SOURCE_EXTENDED
  223. # define __USE_XOPEN_EXTENDED 1
  224. # endif
  225. # endif
  226. #endif
  227. #ifdef _LARGEFILE_SOURCE
  228. # define __USE_LARGEFILE 1
  229. #endif
  230. #ifdef _LARGEFILE64_SOURCE
  231. # define __USE_LARGEFILE64 1
  232. #endif
  233. #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
  234. # define __USE_FILE_OFFSET64 1
  235. #endif
  236. #if defined _BSD_SOURCE || defined _SVID_SOURCE
  237. # define __USE_MISC 1
  238. #endif
  239. #ifdef _BSD_SOURCE
  240. # define __USE_BSD 1
  241. #endif
  242. #ifdef _SVID_SOURCE
  243. # define __USE_SVID 1
  244. #endif
  245. #ifdef _ATFILE_SOURCE
  246. # define __USE_ATFILE 1
  247. #endif
  248. #ifdef _GNU_SOURCE
  249. # define __USE_GNU 1
  250. #endif
  251. #if defined _REENTRANT || defined _THREAD_SAFE
  252. # define __USE_REENTRANT 1
  253. #endif
  254. #if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \
  255. && __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
  256. # if _FORTIFY_SOURCE > 1
  257. # define __USE_FORTIFY_LEVEL 2
  258. # else
  259. # define __USE_FORTIFY_LEVEL 1
  260. # endif
  261. #else
  262. # define __USE_FORTIFY_LEVEL 0
  263. #endif
  264. /* We do support the IEC 559 math functionality, real and complex. */
  265. #define __STDC_IEC_559__ 1
  266. #define __STDC_IEC_559_COMPLEX__ 1
  267. #ifdef __UCLIBC_HAS_WCHAR__
  268. /* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.1. */
  269. # define __STDC_ISO_10646__ 200009L
  270. #endif
  271. /* There is an unwholesomely huge amount of code out there that depends on the
  272. * presence of GNU libc header files. We have GNU libc header files. So here
  273. * we commit a horrible sin. At this point, we _lie_ and claim to be GNU libc
  274. * to make things like /usr/include/linux/socket.h and lots of apps work as
  275. * their developers intended. This is IMHO, pardonable, since these defines
  276. * are not really intended to check for the presence of a particular library,
  277. * but rather are used to define an _interface_. */
  278. #if !defined __FORCE_NOGLIBC && (!defined _LIBC || defined __FORCE_GLIBC)
  279. /* This macro indicates that the installed library is the GNU C Library.
  280. For historic reasons the value now is 6 and this will stay from now
  281. on. The use of this variable is deprecated. */
  282. # undef __GNU_LIBRARY__
  283. # define __GNU_LIBRARY__ 6
  284. /* Major and minor version number of the GNU C library package. Use
  285. these macros to test for features in specific releases. */
  286. /* Don't do it, if you want to keep uClibc happy. */
  287. # define __GLIBC__ 2
  288. # define __GLIBC_MINOR__ 2
  289. #endif
  290. #define __GLIBC_PREREQ(maj, min) \
  291. ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
  292. #ifndef __UCLIBC__
  293. /* Decide whether a compiler supports the long long datatypes. */
  294. #if defined __GNUC__ \
  295. || (defined __PGI && defined __i386__ ) \
  296. || (defined __INTEL_COMPILER && (defined __i386__ || defined __ia64__)) \
  297. || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
  298. # define __GLIBC_HAVE_LONG_LONG 1
  299. #endif
  300. #endif
  301. /* This is here only because every header file already includes this one. */
  302. #ifndef __ASSEMBLER__
  303. # ifndef _SYS_CDEFS_H
  304. # include <sys/cdefs.h>
  305. # endif
  306. /* If we don't have __REDIRECT, prototypes will be missing if
  307. __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
  308. # if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
  309. # define __USE_LARGEFILE 1
  310. # define __USE_LARGEFILE64 1
  311. # endif
  312. #endif /* !ASSEMBLER */
  313. /* Decide whether we can define 'extern inline' functions in headers. */
  314. #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
  315. && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
  316. # define __USE_EXTERN_INLINES 1
  317. #endif
  318. /* Make sure users large file options agree with uClibc's configuration. */
  319. #ifndef __UCLIBC_HAS_LFS__
  320. /* If uClibc was built without large file support, output an error if
  321. * 64-bit file offsets were requested.
  322. * NOTE: This is probably incorrect on a 64-bit arch... */
  323. # ifdef __USE_FILE_OFFSET64
  324. # error It appears you have defined _FILE_OFFSET_BITS=64. Unfortunately, \
  325. uClibc was built without large file support enabled.
  326. # endif
  327. /* If uClibc was built without large file support and _LARGEFILE64_SOURCE
  328. * is defined, undefine it. */
  329. # ifdef _LARGEFILE64_SOURCE
  330. # undef _LARGEFILE64_SOURCE
  331. # undef __USE_LARGEFILE64
  332. # endif
  333. /* If we're actually building uClibc with large file support,
  334. * define __USE_LARGEFILE64 and __USE_LARGEFILE. */
  335. #elif defined _LIBC
  336. # undef _LARGEFILE_SOURCE
  337. # undef _LARGEFILE64_SOURCE
  338. # undef _FILE_OFFSET_BITS
  339. # undef __USE_LARGEFILE
  340. # undef __USE_LARGEFILE64
  341. # undef __USE_FILE_OFFSET64
  342. # define _LARGEFILE_SOURCE 1
  343. # define _LARGEFILE64_SOURCE 1
  344. # define __USE_LARGEFILE 1
  345. # define __USE_LARGEFILE64 1
  346. #endif
  347. /* uClibc does not support *at interfaces. */
  348. #undef _ATFILE_SOURCE
  349. #undef __USE_ATFILE
  350. #ifdef _LIBC
  351. # include <libc-internal.h>
  352. #endif
  353. #ifndef __linux__
  354. # define __linux__ 1
  355. #endif
  356. /* Disable __user, which shows up in 2.6.x include asm headers
  357. * that get pulled in by signal.h */
  358. #define __user
  359. #endif /* features.h */