OSDN Git Service

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