1 /* Copyright (C) 1991-1993,1995-2003,2004,2005 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 /* For uClibc, always optimize for size -- this should disable
23 * a lot of expensive inlining... */
24 #define __OPTIMIZE_SIZE__ 1
26 /* These are defined by the user (or the compiler)
27 to specify the desired environment:
29 __STRICT_ANSI__ ISO Standard C.
30 _ISOC99_SOURCE Extensions to ISO C89 from ISO C99.
31 _POSIX_SOURCE IEEE Std 1003.1.
32 _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;
33 if >=199309L, add IEEE Std 1003.1b-1993;
34 if >=199506L, add IEEE Std 1003.1c-1995;
35 if >=200112L, all of IEEE 1003.1-2004
36 _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if
37 Single Unix conformance is wanted, to 600 for the
38 upcoming sixth revision.
39 _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
40 _LARGEFILE_SOURCE Some more functions for correct standard I/O.
41 _LARGEFILE64_SOURCE Additional functionality from LFS for large files.
42 _FILE_OFFSET_BITS=N Select default filesystem interface.
43 _BSD_SOURCE ISO C, POSIX, and 4.3BSD things.
44 _SVID_SOURCE ISO C, POSIX, and SVID things.
45 _GNU_SOURCE All of the above, plus GNU extensions.
46 _REENTRANT Select additionally reentrant object.
47 _THREAD_SAFE Same as _REENTRANT, often used by other systems.
48 _FORTIFY_SOURCE If set to numeric value > 0 additional security
49 measures are defined, according to level.
51 The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__.
52 If none of these are defined, the default is to have _SVID_SOURCE,
53 _BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
54 199506L. If more than one of these are defined, they accumulate.
55 For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE
56 together give you ISO C, 1003.1, and 1003.2, but nothing else.
58 These are defined by this file and are used by the
59 header files to decide what to declare or define:
61 __USE_ISOC99 Define ISO C99 things.
62 __USE_POSIX Define IEEE Std 1003.1 things.
63 __USE_POSIX2 Define IEEE Std 1003.2 things.
64 __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things.
65 __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things.
66 __USE_XOPEN Define XPG things.
67 __USE_XOPEN_EXTENDED Define X/Open Unix things.
68 __USE_UNIX98 Define Single Unix V2 things.
69 __USE_XOPEN2K Define XPG6 things.
70 __USE_LARGEFILE Define correct standard I/O things.
71 __USE_LARGEFILE64 Define LFS things with separate names.
72 __USE_FILE_OFFSET64 Define 64bit interface as default.
73 __USE_BSD Define 4.3BSD things.
74 __USE_SVID Define SVID things.
75 __USE_MISC Define things common to BSD and System V Unix.
76 __USE_GNU Define GNU extensions.
77 __USE_REENTRANT Define reentrant/thread-safe *_r functions.
78 __USE_FORTIFY_LEVEL Additional security measures used, according to level.
79 __FAVOR_BSD Favor 4.3BSD things in cases of conflict.
81 The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are
82 defined by this file unconditionally. `__GNU_LIBRARY__' is provided
83 only for compatibility. All new code should use the other symbols
86 All macros listed above as possibly being defined by this file are
87 explicitly undefined if they are not explicitly defined.
88 Feature-test macros that are not defined by the user or compiler
89 but are implied by the other feature-test macros defined (or by the
90 lack of any definitions) are defined by the file. */
93 /* Undefine everything, so we get a clean slate. */
97 #undef __USE_POSIX199309
98 #undef __USE_POSIX199506
100 #undef __USE_XOPEN_EXTENDED
103 #undef __USE_LARGEFILE
104 #undef __USE_LARGEFILE64
105 #undef __USE_FILE_OFFSET64
110 #undef __USE_REENTRANT
111 #undef __USE_FORTIFY_LEVEL
113 #undef __KERNEL_STRICT_NAMES
115 /* Suppress kernel-name space pollution unless user expressedly asks
117 #ifndef _LOOSE_KERNEL_NAMES
118 # define __KERNEL_STRICT_NAMES
121 /* Always use ISO C things. */
124 /* Convenience macros to test the versions of glibc and gcc.
126 #if __GNUC_PREREQ (2,8)
127 ... code requiring gcc 2.8 or later ...
129 Note - they won't work for gcc1 or glibc1, since the _MINOR macros
130 were not defined then. */
131 #if defined __GNUC__ && defined __GNUC_MINOR__
132 # define __GNUC_PREREQ(maj, min) \
133 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
135 # define __GNUC_PREREQ(maj, min) 0
139 /* If _BSD_SOURCE was defined by the user, favor BSD over POSIX. */
140 #if defined _BSD_SOURCE && \
141 !(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \
142 defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \
143 defined _GNU_SOURCE || defined _SVID_SOURCE)
144 # define __FAVOR_BSD 1
147 /* If _GNU_SOURCE was defined by the user, turn on all the other features. */
149 # undef _ISOC99_SOURCE
150 # define _ISOC99_SOURCE 1
151 # undef _POSIX_SOURCE
152 # define _POSIX_SOURCE 1
153 # undef _POSIX_C_SOURCE
154 # define _POSIX_C_SOURCE 199506L
155 # undef _XOPEN_SOURCE
156 # define _XOPEN_SOURCE 600
157 # undef _XOPEN_SOURCE_EXTENDED
158 # define _XOPEN_SOURCE_EXTENDED 1
159 # undef _LARGEFILE64_SOURCE
160 # define _LARGEFILE64_SOURCE 1
162 # define _BSD_SOURCE 1
164 # define _SVID_SOURCE 1
167 /* If nothing (other than _GNU_SOURCE) is defined,
168 define _BSD_SOURCE and _SVID_SOURCE. */
169 #if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \
170 !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \
171 !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \
172 !defined _BSD_SOURCE && !defined _SVID_SOURCE)
173 # define _BSD_SOURCE 1
174 # define _SVID_SOURCE 1
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
186 /* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
187 (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */
188 #if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \
189 !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
190 # define _POSIX_SOURCE 1
191 # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
192 # define _POSIX_C_SOURCE 2
194 # define _POSIX_C_SOURCE 199506L
198 #if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
199 # define __USE_POSIX 1
202 #if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
203 # define __USE_POSIX2 1
206 #if (_POSIX_C_SOURCE - 0) >= 199309L
207 # define __USE_POSIX199309 1
210 #if (_POSIX_C_SOURCE - 0) >= 199506L
211 # define __USE_POSIX199506 1
214 #if (_POSIX_C_SOURCE - 0) >= 200112L
215 # define __USE_XOPEN2K 1
219 # define __USE_XOPEN 1
220 # if (_XOPEN_SOURCE - 0) >= 500
221 # define __USE_XOPEN_EXTENDED 1
222 # define __USE_UNIX98 1
223 # undef _LARGEFILE_SOURCE
224 # define _LARGEFILE_SOURCE 1
225 # if (_XOPEN_SOURCE - 0) >= 600
226 # define __USE_XOPEN2K 1
228 # define __USE_ISOC99 1
231 # ifdef _XOPEN_SOURCE_EXTENDED
232 # define __USE_XOPEN_EXTENDED 1
237 #ifdef _LARGEFILE_SOURCE
238 # define __USE_LARGEFILE 1
241 #ifdef _LARGEFILE64_SOURCE
242 # define __USE_LARGEFILE64 1
245 #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
246 # define __USE_FILE_OFFSET64 1
249 #if defined _BSD_SOURCE || defined _SVID_SOURCE
250 # define __USE_MISC 1
258 # define __USE_SVID 1
265 #if defined _REENTRANT || defined _THREAD_SAFE
266 # define __USE_REENTRANT 1
269 #if _FORTIFY_SOURCE > 0 && __GNUC_PREREQ (4, 1) && defined(__OPTIMIZE__)
270 # if _FORTIFY_SOURCE == 1
271 # define __USE_FORTIFY_LEVEL 1
272 # elif _FORTIFY_SOURCE > 1
273 # define __USE_FORTIFY_LEVEL 2
277 /* We do support the IEC 559 math functionality, real and complex. */
278 #define __STDC_IEC_559__ 1
279 #define __STDC_IEC_559_COMPLEX__ 1
281 /* This macro indicates that the installed library is uClibc. Use
282 * __UCLIBC_MAJOR__ and __UCLIBC_MINOR__ to test for the features in
283 * specific releases. */
286 /* Load up the current set of uClibc supported features along
287 * with the current uClibc major and minor version numbers.
288 * For uClibc release 0.9.26, these numbers would be:
289 * #define __UCLIBC_MAJOR__ 0
290 * #define __UCLIBC_MINOR__ 9
291 * #define __UCLIBC_SUBLEVEL__ 26
293 #define __need_uClibc_config_h
294 #include <bits/uClibc_config.h>
295 #undef __need_uClibc_config_h
297 #ifdef __UCLIBC_HAS_WCHAR__
298 /* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.0. */
299 # define __STDC_ISO_10646__ 200009L
302 /* There is an unwholesomely huge amount of code out there that depends on the
303 * presence of GNU libc header files. We have GNU libc header files. So here
304 * we commit a horrible sin. At this point, we _lie_ and claim to be GNU libc
305 * to make things like /usr/include/linux/socket.h and lots of apps work as
306 * their developers intended. This is IMHO, pardonable, since these defines
307 * are not really intended to check for the presence of a particular library,
308 * but rather are used to define an _interface_. */
309 #if !defined __FORCE_NOGLIBC && (!defined _LIBC || defined __FORCE_GLIBC)
310 # define __GNU_LIBRARY__ 6
312 # define __GLIBC_MINOR__ 2
315 #define __GLIBC_PREREQ(maj, min) \
316 ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
318 /* This is here only because every header file already includes this one. */
319 #ifndef __ASSEMBLER__
320 # ifndef _SYS_CDEFS_H
321 # include <sys/cdefs.h>
324 /* If we don't have __REDIRECT, prototypes will be missing if
325 __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
326 # if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
327 # define __USE_LARGEFILE 1
328 # define __USE_LARGEFILE64 1
331 #endif /* !ASSEMBLER */
333 /* Decide whether we can define 'extern inline' functions in headers. */
334 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
335 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
336 # define __USE_EXTERN_INLINES 1
340 /* Make sure users large file options agree with uClibc's configuration. */
341 #ifndef __UCLIBC_HAS_LFS__
343 /* If uClibc was built without large file support, output an error if
344 * and 64-bit file offsets were requested, output an error.
345 * NOTE: This is probably incorrect on a 64-bit arch... */
346 #ifdef __USE_FILE_OFFSET64
347 #error It appears you have defined _FILE_OFFSET_BITS=64. Unfortunately, \
348 uClibc was built without large file support enabled.
351 /* If uClibc was built without large file support and _LARGEFILE64_SOURCE
352 * is defined, undefine it. */
353 #if defined(_LARGEFILE64_SOURCE)
354 #undef _LARGEFILE64_SOURCE
355 #undef __USE_LARGEFILE64
358 /* If we're actually building uClibc with large file support,
359 * define __USE_LARGEFILE64 and __USE_LARGEFILE. */
361 #undef _LARGEFILE_SOURCE
362 #undef _LARGEFILE64_SOURCE
363 #undef _FILE_OFFSET_BITS
364 #undef __USE_LARGEFILE
365 #undef __USE_LARGEFILE64
366 #undef __USE_FILE_OFFSET64
367 #define _LARGEFILE_SOURCE 1
368 #define _LARGEFILE64_SOURCE 1
369 #define __USE_LARGEFILE 1
370 #define __USE_LARGEFILE64 1
374 # include <libc-internal.h>
381 /* Disable __user, which shows up in 2.6.x include asm headers
382 * that get pulled in by signal.h */
385 #endif /* features.h */