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