OSDN Git Service

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