features.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. /* Copyright (C) 1991,92,93,95,96,97,98,99,2000,2001 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. _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if
  26. Single Unix conformance is wanted, to 600 for the
  27. upcoming sixth revision.
  28. _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
  29. _LARGEFILE_SOURCE Some more functions for correct standard I/O.
  30. _LARGEFILE64_SOURCE Additional functionality from LFS for large files.
  31. _FILE_OFFSET_BITS=N Select default filesystem interface.
  32. _BSD_SOURCE ISO C, POSIX, and 4.3BSD things.
  33. _SVID_SOURCE ISO C, POSIX, and SVID things.
  34. _GNU_SOURCE All of the above, plus GNU extensions.
  35. _REENTRANT Select additionally reentrant object.
  36. _THREAD_SAFE Same as _REENTRANT, often used by other systems.
  37. The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__.
  38. If none of these are defined, the default is to have _SVID_SOURCE,
  39. _BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
  40. 199506L. If more than one of these are defined, they accumulate.
  41. For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE
  42. together give you ISO C, 1003.1, and 1003.2, but nothing else.
  43. These are defined by this file and are used by the
  44. header files to decide what to declare or define:
  45. __USE_ISOC99 Define ISO C99 things.
  46. __USE_POSIX Define IEEE Std 1003.1 things.
  47. __USE_POSIX2 Define IEEE Std 1003.2 things.
  48. __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things.
  49. __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things.
  50. __USE_XOPEN Define XPG things.
  51. __USE_XOPEN_EXTENDED Define X/Open Unix things.
  52. __USE_UNIX98 Define Single Unix V2 things.
  53. __USE_XOPEN2K Define XPG6 things.
  54. __USE_LARGEFILE Define correct standard I/O things.
  55. __USE_LARGEFILE64 Define LFS things with separate names.
  56. __USE_FILE_OFFSET64 Define 64bit interface as default.
  57. __USE_BSD Define 4.3BSD things.
  58. __USE_SVID Define SVID things.
  59. __USE_MISC Define things common to BSD and System V Unix.
  60. __USE_GNU Define GNU extensions.
  61. __USE_REENTRANT Define reentrant/thread-safe *_r functions.
  62. __FAVOR_BSD Favor 4.3BSD things in cases of conflict.
  63. The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are
  64. defined by this file unconditionally. `__GNU_LIBRARY__' is provided
  65. only for compatibility. All new code should use the other symbols
  66. to test for features.
  67. All macros listed above as possibly being defined by this file are
  68. explicitly undefined if they are not explicitly defined.
  69. Feature-test macros that are not defined by the user or compiler
  70. but are implied by the other feature-test macros defined (or by the
  71. lack of any definitions) are defined by the file. */
  72. /* Undefine everything, so we get a clean slate. */
  73. #undef __USE_ISOC99
  74. #undef __USE_POSIX
  75. #undef __USE_POSIX2
  76. #undef __USE_POSIX199309
  77. #undef __USE_POSIX199506
  78. #undef __USE_XOPEN
  79. #undef __USE_XOPEN_EXTENDED
  80. #undef __USE_UNIX98
  81. #undef __USE_XOPEN2K
  82. #undef __USE_LARGEFILE
  83. #undef __USE_LARGEFILE64
  84. #undef __USE_FILE_OFFSET64
  85. #undef __USE_BSD
  86. #undef __USE_SVID
  87. #undef __USE_MISC
  88. #undef __USE_GNU
  89. #undef __USE_REENTRANT
  90. #undef __FAVOR_BSD
  91. #undef __KERNEL_STRICT_NAMES
  92. /* Suppress kernel-name space pollution unless user expressedly asks
  93. for it. */
  94. #ifndef _LOOSE_KERNEL_NAMES
  95. # define __KERNEL_STRICT_NAMES
  96. #endif
  97. /* Always use ISO C things. */
  98. #define __USE_ANSI 1
  99. /* If _BSD_SOURCE was defined by the user, favor BSD over POSIX. */
  100. #if defined _BSD_SOURCE && \
  101. !(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \
  102. defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \
  103. defined _GNU_SOURCE || defined _SVID_SOURCE)
  104. # define __FAVOR_BSD 1
  105. #endif
  106. /* If _GNU_SOURCE was defined by the user, turn on all the other features. */
  107. #ifdef _GNU_SOURCE
  108. # undef _ISOC99_SOURCE
  109. # define _ISOC99_SOURCE 1
  110. # undef _POSIX_SOURCE
  111. # define _POSIX_SOURCE 1
  112. # undef _POSIX_C_SOURCE
  113. # define _POSIX_C_SOURCE 199506L
  114. # undef _XOPEN_SOURCE
  115. # define _XOPEN_SOURCE 600
  116. # undef _XOPEN_SOURCE_EXTENDED
  117. # define _XOPEN_SOURCE_EXTENDED 1
  118. # undef _LARGEFILE64_SOURCE
  119. # define _LARGEFILE64_SOURCE 1
  120. # undef _BSD_SOURCE
  121. # define _BSD_SOURCE 1
  122. # undef _SVID_SOURCE
  123. # define _SVID_SOURCE 1
  124. #endif
  125. /* If nothing (other than _GNU_SOURCE) is defined,
  126. define _BSD_SOURCE and _SVID_SOURCE. */
  127. #if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \
  128. !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \
  129. !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \
  130. !defined _BSD_SOURCE && !defined _SVID_SOURCE)
  131. # define _BSD_SOURCE 1
  132. # define _SVID_SOURCE 1
  133. #endif
  134. /* This is to enable the ISO C99 extension. Also recognize the old macro
  135. which was used prior to the standard acceptance. This macro will
  136. eventually go away and the features enabled by default once the ISO C99
  137. standard is widely adopted. */
  138. #if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \
  139. || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
  140. # define __USE_ISOC99 1
  141. #endif
  142. /* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
  143. (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */
  144. #if (!defined __STRICT_ANSI__ && !defined _POSIX_SOURCE && \
  145. !defined _POSIX_C_SOURCE)
  146. # define _POSIX_SOURCE 1
  147. # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
  148. # define _POSIX_C_SOURCE 2
  149. # else
  150. # define _POSIX_C_SOURCE 199506L
  151. # endif
  152. #endif
  153. #if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
  154. # define __USE_POSIX 1
  155. #endif
  156. #if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
  157. # define __USE_POSIX2 1
  158. #endif
  159. #if (_POSIX_C_SOURCE - 0) >= 199309L
  160. # define __USE_POSIX199309 1
  161. #endif
  162. #if (_POSIX_C_SOURCE - 0) >= 199506L
  163. # define __USE_POSIX199506 1
  164. #endif
  165. #ifdef _XOPEN_SOURCE
  166. # define __USE_XOPEN 1
  167. # if (_XOPEN_SOURCE - 0) >= 500
  168. # define __USE_XOPEN_EXTENDED 1
  169. # define __USE_UNIX98 1
  170. # undef _LARGEFILE_SOURCE
  171. # define _LARGEFILE_SOURCE 1
  172. # if (_XOPEN_SOURCE - 0) >= 600
  173. # define __USE_XOPEN2K 1
  174. # undef __USE_ISOC99
  175. # define __USE_ISOC99 1
  176. # endif
  177. # else
  178. # ifdef _XOPEN_SOURCE_EXTENDED
  179. # define __USE_XOPEN_EXTENDED 1
  180. # endif
  181. # endif
  182. #endif
  183. #ifdef _LARGEFILE_SOURCE
  184. # define __USE_LARGEFILE 1
  185. #endif
  186. #ifdef _LARGEFILE64_SOURCE
  187. # define __USE_LARGEFILE64 1
  188. #endif
  189. #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
  190. # define __USE_FILE_OFFSET64 1
  191. #endif
  192. #if defined _BSD_SOURCE || defined _SVID_SOURCE
  193. # define __USE_MISC 1
  194. #endif
  195. #ifdef _BSD_SOURCE
  196. # define __USE_BSD 1
  197. #endif
  198. #ifdef _SVID_SOURCE
  199. # define __USE_SVID 1
  200. #endif
  201. #ifdef _GNU_SOURCE
  202. # define __USE_GNU 1
  203. #endif
  204. #if defined _REENTRANT || defined _THREAD_SAFE
  205. # define __USE_REENTRANT 1
  206. #endif
  207. /* We do support the IEC 559 math functionality, real and complex. */
  208. #define __STDC_IEC_559__ 1
  209. #define __STDC_IEC_559_COMPLEX__ 1
  210. /* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.0. */
  211. #define __STDC_ISO_10646__ 200009L
  212. /* Major and minor version number of the uClibc library package. Use
  213. these macros to test for features in specific releases. */
  214. #define __UCLIBC__ 0
  215. #define __UCLIBC_MAJOR__ 9
  216. #define __UCLIBC_MINOR__ 5
  217. /* There is an unwholesomely huge amount of code out there that depends on the
  218. * presence of GNU libc header files. We have GNU libc header files. So here
  219. * we commit a horrible sin. At this point, we _lie_ and claim to be GNU libc
  220. * to make things like /usr/include/linux/socket.h and lots of apps work as
  221. * their developers intended. This is IMHO, pardonable, since these defines
  222. * are not really intended to check for the presence of a particular library,
  223. * but rather are used to define an _interface_. */
  224. #if !defined _LIBC || defined __FORCE_GLIBC__
  225. # define __GNU_LIBRARY__ 6
  226. # define __GLIBC__ 2
  227. # define __GLIBC_MINOR__ 2
  228. #endif
  229. /* Convenience macros to test the versions of glibc and gcc.
  230. Use them like this:
  231. #if __GNUC_PREREQ (2,8)
  232. ... code requiring gcc 2.8 or later ...
  233. #endif
  234. Note - they won't work for gcc1 or glibc1, since the _MINOR macros
  235. were not defined then. */
  236. #if defined __GNUC__ && defined __GNUC_MINOR__
  237. # define __GNUC_PREREQ(maj, min) \
  238. ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
  239. #else
  240. # define __GNUC_PREREQ(maj, min) 0
  241. #endif
  242. #define __GLIBC_PREREQ(maj, min) \
  243. ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
  244. /* This is here only because every header file already includes this one. */
  245. #ifndef __ASSEMBLER__
  246. #ifndef _SYS_CDEFS_H
  247. # include <sys/cdefs.h>
  248. #endif
  249. /* If we don't have __REDIRECT, prototypes will be missing if
  250. __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
  251. # if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
  252. # define __USE_LARGEFILE 1
  253. # define __USE_LARGEFILE64 1
  254. # endif
  255. #endif /* !ASSEMBLER */
  256. /* Decide whether we can define 'extern inline' functions in headers. */
  257. #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
  258. && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
  259. # define __USE_EXTERN_INLINES 1
  260. #endif
  261. /* This is here only because every header file already includes this one. */
  262. #if 0
  263. //#ifndef _LIBC
  264. /* Get the definitions of all the appropriate `__stub_FUNCTION' symbols.
  265. <gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub
  266. which will always return failure (and set errno to ENOSYS).
  267. We avoid including <gnu/stubs.h> when compiling the C library itself to
  268. avoid a dependency loop. stubs.h depends on every object file. If
  269. this #include were done for the library source code, then every object
  270. file would depend on stubs.h. */
  271. # include <gnu/stubs.h>
  272. #endif
  273. /* Load up the current set of uClibc supported features */
  274. #define __need_uClibc_config_h
  275. #include <bits/uClibc_config.h>
  276. #undef __need_uClibc_config_h
  277. /* Some nice features only work properly with ELF */
  278. #if defined HAVE_ELF
  279. # define link_warning(symbol, msg) \
  280. asm (".section " ".gnu.warning." #symbol "\n\t.previous"); \
  281. static const char __evoke_link_warning_##symbol[] \
  282. __attribute__ ((section (".gnu.warning." #symbol "\n\t#"))) = msg;
  283. # define weak_alias(name, aliasname) \
  284. asm(".global " #name ";.weak " #aliasname ";" #aliasname "=" #name ";");
  285. #else
  286. # define link_warning(symbol, msg) \
  287. asm (".stabs \"" msg "\",30,0,0,0\n\t" \
  288. ".stabs \"" #symbol "\",1,0,0,0\n");
  289. # define weak_alias(name, aliasname) \
  290. __asm__(".global alias\n.set alias,original");
  291. #endif
  292. #endif /* features.h */