OSDN Git Service

Change __OPTIMIZE__ > 0 to defined(__OPTIMIZE__) as in glibc-2.3.5.
[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 /* For uClibc, always optimize for size -- this should disable
23  * a lot of expensive inlining... */
24 #define __OPTIMIZE_SIZE__   1
25
26 /* These are defined by the user (or the compiler)
27    to specify the desired environment:
28
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.
50
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.
57
58    These are defined by this file and are used by the
59    header files to decide what to declare or define:
60
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.
80
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
84    to test for features.
85
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.  */
91
92
93 /* Undefine everything, so we get a clean slate.  */
94 #undef  __USE_ISOC99
95 #undef  __USE_POSIX
96 #undef  __USE_POSIX2
97 #undef  __USE_POSIX199309
98 #undef  __USE_POSIX199506
99 #undef  __USE_XOPEN
100 #undef  __USE_XOPEN_EXTENDED
101 #undef  __USE_UNIX98
102 #undef  __USE_XOPEN2K
103 #undef  __USE_LARGEFILE
104 #undef  __USE_LARGEFILE64
105 #undef  __USE_FILE_OFFSET64
106 #undef  __USE_BSD
107 #undef  __USE_SVID
108 #undef  __USE_MISC
109 #undef  __USE_GNU
110 #undef  __USE_REENTRANT
111 #undef  __USE_FORTIFY_LEVEL
112 #undef  __FAVOR_BSD
113 #undef  __KERNEL_STRICT_NAMES
114
115 /* Suppress kernel-name space pollution unless user expressedly asks
116    for it.  */
117 #ifndef _LOOSE_KERNEL_NAMES
118 # define __KERNEL_STRICT_NAMES
119 #endif
120
121 /* Always use ISO C things.  */
122 #define __USE_ANSI      1
123
124 /* Convenience macros to test the versions of glibc and gcc.
125    Use them like this:
126    #if __GNUC_PREREQ (2,8)
127    ... code requiring gcc 2.8 or later ...
128    #endif
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))
134 #else
135 # define __GNUC_PREREQ(maj, min) 0
136 #endif
137
138
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
145 #endif
146
147 /* If _GNU_SOURCE was defined by the user, turn on all the other features.  */
148 #ifdef _GNU_SOURCE
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
161 # undef  _BSD_SOURCE
162 # define _BSD_SOURCE    1
163 # undef  _SVID_SOURCE
164 # define _SVID_SOURCE   1
165 #endif
166
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
175 #endif
176
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
184 #endif
185
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
193 # else
194 #  define _POSIX_C_SOURCE       199506L
195 # endif
196 #endif
197
198 #if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
199 # define __USE_POSIX    1
200 #endif
201
202 #if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
203 # define __USE_POSIX2   1
204 #endif
205
206 #if (_POSIX_C_SOURCE - 0) >= 199309L
207 # define __USE_POSIX199309      1
208 #endif
209
210 #if (_POSIX_C_SOURCE - 0) >= 199506L
211 # define __USE_POSIX199506      1
212 #endif
213
214 #if (_POSIX_C_SOURCE - 0) >= 200112L
215 # define __USE_XOPEN2K          1
216 #endif
217
218 #ifdef  _XOPEN_SOURCE
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
227 #   undef __USE_ISOC99
228 #   define __USE_ISOC99         1
229 #  endif
230 # else
231 #  ifdef _XOPEN_SOURCE_EXTENDED
232 #   define __USE_XOPEN_EXTENDED 1
233 #  endif
234 # endif
235 #endif
236
237 #ifdef _LARGEFILE_SOURCE
238 # define __USE_LARGEFILE        1
239 #endif
240
241 #ifdef _LARGEFILE64_SOURCE
242 # define __USE_LARGEFILE64      1
243 #endif
244
245 #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
246 # define __USE_FILE_OFFSET64    1
247 #endif
248
249 #if defined _BSD_SOURCE || defined _SVID_SOURCE
250 # define __USE_MISC     1
251 #endif
252
253 #ifdef  _BSD_SOURCE
254 # define __USE_BSD      1
255 #endif
256
257 #ifdef  _SVID_SOURCE
258 # define __USE_SVID     1
259 #endif
260
261 #ifdef  _GNU_SOURCE
262 # define __USE_GNU      1
263 #endif
264
265 #if defined _REENTRANT || defined _THREAD_SAFE
266 # define __USE_REENTRANT        1
267 #endif
268
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
274 # endif
275 #endif
276
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
280
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.  */
284 #define __UCLIBC__              1
285
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
292  */
293 #define __need_uClibc_config_h
294 #include <bits/uClibc_config.h>
295 #undef __need_uClibc_config_h
296
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
300 #endif
301
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
311 #   define __GLIBC__       2
312 #   define __GLIBC_MINOR__ 2
313 #endif
314
315 #define __GLIBC_PREREQ(maj, min) \
316         ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
317
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>
322 # endif
323
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
329 # endif
330
331 #endif  /* !ASSEMBLER */
332
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
337 #endif
338
339
340 /* Make sure users large file options agree with uClibc's configuration. */
341 #ifndef __UCLIBC_HAS_LFS__
342
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.
349 #endif
350
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
356 #endif
357
358 /* If we're actually building uClibc with large file support,
359  * define __USE_LARGEFILE64 and __USE_LARGEFILE. */
360 #elif defined(_LIBC)
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
371 #endif
372
373 #ifdef _LIBC
374 # include <libc-internal.h>
375 #endif
376
377 #ifndef __linux__
378 # define __linux__ 1
379 #endif
380
381 /* Disable __user, which shows up in 2.6.x include asm headers
382  * that get pulled in by signal.h */
383 #define __user
384
385 #endif  /* features.h  */