OSDN Git Service

cut out _FORTIFY_SOURCE
[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 # undef  _LARGEFILE64_SOURCE
180 # define _LARGEFILE64_SOURCE    1
181 # undef  _BSD_SOURCE
182 # define _BSD_SOURCE    1
183 # undef  _SVID_SOURCE
184 # define _SVID_SOURCE   1
185 # undef  _ATFILE_SOURCE
186 # define _ATFILE_SOURCE 1
187 #endif
188
189 /* If nothing (other than _GNU_SOURCE) is defined,
190    define _BSD_SOURCE and _SVID_SOURCE.  */
191 #if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \
192      !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \
193      !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \
194      !defined _BSD_SOURCE && !defined _SVID_SOURCE)
195 # define _BSD_SOURCE    1
196 # define _SVID_SOURCE   1
197 #endif
198
199 /* This is to enable the ISO C99 extension.  Also recognize the old macro
200    which was used prior to the standard acceptance.  This macro will
201    eventually go away and the features enabled by default once the ISO C99
202    standard is widely adopted.  */
203 #if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \
204      || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
205 # define __USE_ISOC99   1
206 #endif
207
208 /* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
209    (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined).  */
210 #if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \
211      !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
212 # define _POSIX_SOURCE  1
213 # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
214 #  define _POSIX_C_SOURCE       2
215 # else
216 #  define _POSIX_C_SOURCE       199506L
217 # endif
218 #endif
219
220 #if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
221 # define __USE_POSIX    1
222 #endif
223
224 #if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
225 # define __USE_POSIX2   1
226 #endif
227
228 #if (_POSIX_C_SOURCE - 0) >= 199309L
229 # define __USE_POSIX199309      1
230 #endif
231
232 #if (_POSIX_C_SOURCE - 0) >= 199506L
233 # define __USE_POSIX199506      1
234 #endif
235
236 #if (_POSIX_C_SOURCE - 0) >= 200112L
237 # define __USE_XOPEN2K          1
238 #endif
239
240 #ifdef  _XOPEN_SOURCE
241 # define __USE_XOPEN    1
242 # if (_XOPEN_SOURCE - 0) >= 500
243 #  define __USE_XOPEN_EXTENDED  1
244 #  define __USE_UNIX98  1
245 #  undef _LARGEFILE_SOURCE
246 #  define _LARGEFILE_SOURCE     1
247 #  if (_XOPEN_SOURCE - 0) >= 600
248 #   define __USE_XOPEN2K        1
249 #   undef __USE_ISOC99
250 #   define __USE_ISOC99         1
251 #  endif
252 # else
253 #  ifdef _XOPEN_SOURCE_EXTENDED
254 #   define __USE_XOPEN_EXTENDED 1
255 #  endif
256 # endif
257 #endif
258
259 #ifdef _LARGEFILE_SOURCE
260 # define __USE_LARGEFILE        1
261 #endif
262
263 #ifdef _LARGEFILE64_SOURCE
264 # define __USE_LARGEFILE64      1
265 #endif
266
267 #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
268 # define __USE_FILE_OFFSET64    1
269 #endif
270
271 #if defined _BSD_SOURCE || defined _SVID_SOURCE
272 # define __USE_MISC     1
273 #endif
274
275 #ifdef  _BSD_SOURCE
276 # define __USE_BSD      1
277 #endif
278
279 #ifdef  _SVID_SOURCE
280 # define __USE_SVID     1
281 #endif
282
283 #ifdef  _ATFILE_SOURCE
284 # define __USE_ATFILE   1
285 #endif
286
287 #ifdef  _GNU_SOURCE
288 # define __USE_GNU      1
289 #endif
290
291 #if defined _REENTRANT || defined _THREAD_SAFE
292 # define __USE_REENTRANT        1
293 #endif
294
295 /* uClibc does not support _FORTIFY_SOURCE */
296 #undef _FORTIFY_SOURCE
297 #if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \
298     && __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
299 # if _FORTIFY_SOURCE > 1
300 #  define __USE_FORTIFY_LEVEL 2
301 # else
302 #  define __USE_FORTIFY_LEVEL 1
303 # endif
304 #else
305 # define __USE_FORTIFY_LEVEL 0
306 #endif
307
308 /* We do support the IEC 559 math functionality, real and complex.  */
309 #define __STDC_IEC_559__                1
310 #define __STDC_IEC_559_COMPLEX__        1
311
312 #ifdef __UCLIBC_HAS_WCHAR__
313 /* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.1.  */
314 # define __STDC_ISO_10646__             200009L
315 #endif
316
317 /*  There is an unwholesomely huge amount of code out there that depends on the
318  *  presence of GNU libc header files.  We have GNU libc header files.  So here
319  *  we commit a horrible sin.  At this point, we _lie_ and claim to be GNU libc
320  *  to make things like /usr/include/linux/socket.h and lots of apps work as
321  *  their developers intended.  This is IMHO, pardonable, since these defines
322  *  are not really intended to check for the presence of a particular library,
323  *  but rather are used to define an _interface_.  */
324 #if !defined __FORCE_NOGLIBC && (!defined _LIBC || defined __FORCE_GLIBC)
325 /* This macro indicates that the installed library is the GNU C Library.
326    For historic reasons the value now is 6 and this will stay from now
327    on.  The use of this variable is deprecated.  */
328 # undef  __GNU_LIBRARY__
329 # define __GNU_LIBRARY__ 6
330
331 /* Major and minor version number of the GNU C library package.  Use
332    these macros to test for features in specific releases.  */
333 /* Don't do it, if you want to keep uClibc happy.  */
334 # define        __GLIBC__       2
335 # define        __GLIBC_MINOR__ 2
336 #endif
337
338 #define __GLIBC_PREREQ(maj, min) \
339         ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
340
341 #ifndef __UCLIBC__
342 /* Decide whether a compiler supports the long long datatypes.  */
343 #if defined __GNUC__ \
344     || (defined __PGI && defined __i386__ ) \
345     || (defined __INTEL_COMPILER && (defined __i386__ || defined __ia64__)) \
346     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
347 # define __GLIBC_HAVE_LONG_LONG 1
348 #endif
349 #endif
350
351 /* This is here only because every header file already includes this one.  */
352 #ifndef __ASSEMBLER__
353 # ifndef _SYS_CDEFS_H
354 #  include <sys/cdefs.h>
355 # endif
356
357 /* If we don't have __REDIRECT, prototypes will be missing if
358    __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
359 # if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
360 #  define __USE_LARGEFILE       1
361 #  define __USE_LARGEFILE64     1
362 # endif
363
364 #endif  /* !ASSEMBLER */
365
366 /* Decide whether we can define 'extern inline' functions in headers.  */
367 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
368     && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
369 # define __USE_EXTERN_INLINES   1
370 #endif
371
372
373 /* Make sure users large file options agree with uClibc's configuration. */
374 #ifndef __UCLIBC_HAS_LFS__
375
376 /* If uClibc was built without large file support, output an error if
377  * 64-bit file offsets were requested.
378  * NOTE: This is probably incorrect on a 64-bit arch... */
379 # ifdef __USE_FILE_OFFSET64
380 #  error It appears you have defined _FILE_OFFSET_BITS=64.  Unfortunately, \
381 uClibc was built without large file support enabled.
382 # endif
383
384 /* If uClibc was built without large file support and _LARGEFILE64_SOURCE
385  * is defined, undefine it. */
386 # ifdef _LARGEFILE64_SOURCE
387 #  undef _LARGEFILE64_SOURCE
388 #  undef __USE_LARGEFILE64
389 # endif
390
391 /* If we're actually building uClibc with large file support,
392  * define __USE_LARGEFILE64 and __USE_LARGEFILE. */
393 #elif defined _LIBC
394 # undef _LARGEFILE_SOURCE
395 # undef _LARGEFILE64_SOURCE
396 # undef _FILE_OFFSET_BITS
397 # undef __USE_LARGEFILE
398 # undef __USE_LARGEFILE64
399 # undef __USE_FILE_OFFSET64
400 # define _LARGEFILE_SOURCE       1
401 # define _LARGEFILE64_SOURCE     1
402 # define __USE_LARGEFILE         1
403 # define __USE_LARGEFILE64       1
404 #endif
405
406 /* uClibc does not support *at interfaces. */
407 #undef _ATFILE_SOURCE
408 #undef __USE_ATFILE
409
410 #ifdef _LIBC
411 # include <libc-internal.h>
412 #endif
413
414 #ifndef __linux__
415 # define __linux__ 1
416 #endif
417
418 /* Disable __user, which shows up in 2.6.x include asm headers
419  * that get pulled in by signal.h */
420 #define __user
421
422 #endif  /* features.h  */