source: trunk/src/emx/include/features.h@ 1505

Last change on this file since 1505 was 1299, checked in by bird, 21 years ago

Check if stuff is defined before accessing it in #if. Stops -Wundef from bitching.

  • Property cvs2svn:cvs-rev set to 1.7
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 12.5 KB
Line 
1/* Copyright (C) 1991-1993,1995-2000,2001,2002 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/** @file
20 * GLIBC v2.3.2
21 * @changed bird: don't define *LARGEFILE64*, but make sure to indicate that
22 * off_t is 64bits.
23 * @changed bird: not GLIBC version numbers.
24 * @changed bird: _GNU_SOURCE should not set _POSIX_SOURCE or _POSIX_C_SOURCE as that
25 * means somewhat imporatant exclusions in EMX and BSD style headers.
26 * Some of this have been fixed by __USE_EMX/_EMX_SOURCE, but that's
27 * not gonna help enough.
28 * @changed bird: Check if stuff is defined before accessing it in #if. Stops -Wundef
29 * from bitching.
30 */
31
32#ifndef _FEATURES_H
33#define _FEATURES_H 1
34
35/* These are defined by the user (or the compiler)
36 to specify the desired environment:
37
38 __STRICT_ANSI__ ISO Standard C.
39 _ISOC99_SOURCE Extensions to ISO C89 from ISO C99.
40 _POSIX_SOURCE IEEE Std 1003.1.
41 _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;
42 if >=199309L, add IEEE Std 1003.1b-1993;
43 if >=199506L, add IEEE Std 1003.1c-1995
44 _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if
45 Single Unix conformance is wanted, to 600 for the
46 upcoming sixth revision.
47 _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
48 _LARGEFILE_SOURCE Some more functions for correct standard I/O.
49 _LARGEFILE64_SOURCE Additional functionality from LFS for large files.
50 _FILE_OFFSET_BITS=N Select default filesystem interface.
51 _BSD_SOURCE ISO C, POSIX, and 4.3BSD things.
52 _SVID_SOURCE ISO C, POSIX, and SVID things.
53 _GNU_SOURCE All of the above, plus GNU extensions.
54 _REENTRANT Select additionally reentrant object.
55 _THREAD_SAFE Same as _REENTRANT, often used by other systems.
56
57 The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__.
58 If none of these are defined, the default is to have _SVID_SOURCE,
59 _BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
60 199506L. If more than one of these are defined, they accumulate.
61 For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE
62 together give you ISO C, 1003.1, and 1003.2, but nothing else.
63
64 These are defined by this file and are used by the
65 header files to decide what to declare or define:
66
67 __USE_ISOC99 Define ISO C99 things.
68 __USE_POSIX Define IEEE Std 1003.1 things.
69 __USE_POSIX2 Define IEEE Std 1003.2 things.
70 __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things.
71 __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things.
72 __USE_XOPEN Define XPG things.
73 __USE_XOPEN_EXTENDED Define X/Open Unix things.
74 __USE_UNIX98 Define Single Unix V2 things.
75 __USE_XOPEN2K Define XPG6 things.
76 __USE_LARGEFILE Define correct standard I/O things.
77 __USE_LARGEFILE64 Define LFS things with separate names.
78 __USE_FILE_OFFSET64 Define 64bit interface as default.
79 __USE_BSD Define 4.3BSD things.
80 __USE_SVID Define SVID things.
81 __USE_MISC Define things common to BSD and System V Unix.
82 __USE_GNU Define GNU extensions.
83 __USE_REENTRANT Define reentrant/thread-safe *_r functions.
84 __FAVOR_BSD Favor 4.3BSD things in cases of conflict.
85
86 The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are
87 defined by this file unconditionally. `__GNU_LIBRARY__' is provided
88 only for compatibility. All new code should use the other symbols
89 to test for features.
90
91 All macros listed above as possibly being defined by this file are
92 explicitly undefined if they are not explicitly defined.
93 Feature-test macros that are not defined by the user or compiler
94 but are implied by the other feature-test macros defined (or by the
95 lack of any definitions) are defined by the file. */
96
97
98/* Undefine everything, so we get a clean slate. */
99#undef __USE_ISOC99
100#undef __USE_POSIX
101#undef __USE_POSIX2
102#undef __USE_POSIX199309
103#undef __USE_POSIX199506
104#undef __USE_XOPEN
105#undef __USE_XOPEN_EXTENDED
106#undef __USE_UNIX98
107#undef __USE_XOPEN2K
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_GNU
115#undef __USE_REENTRANT
116#undef __FAVOR_BSD
117#undef __KERNEL_STRICT_NAMES
118#ifdef __EMX__ /* bird */
119#undef __USE_EMX /* bird */
120#endif /* bird */
121
122/* Suppress kernel-name space pollution unless user expressedly asks
123 for it. */
124#ifndef _LOOSE_KERNEL_NAMES
125# define __KERNEL_STRICT_NAMES
126#endif
127
128/* Always use ISO C things. */
129#define __USE_ANSI 1
130
131
132/* If _BSD_SOURCE was defined by the user, favor BSD over POSIX. */
133#if defined _BSD_SOURCE && \
134 !(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \
135 defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \
136 defined _GNU_SOURCE || defined _SVID_SOURCE)
137# define __FAVOR_BSD 1
138#endif
139
140/* If _GNU_SOURCE was defined by the user, turn on all the other features. */
141#ifdef _GNU_SOURCE
142# undef _ISOC99_SOURCE
143# define _ISOC99_SOURCE 1
144/* bird: sorry, but this isn't causing huge exclusions for BSD or EMX headers. */
145#ifndef __EMX__ /* bird */
146# undef _POSIX_SOURCE
147# define _POSIX_SOURCE 1
148# undef _POSIX_C_SOURCE
149# define _POSIX_C_SOURCE 199506L
150#else /* bird */
151# define __USE_POSIX199309 1 /* bird */
152# define __USE_POSIX199506 1 /* bird */
153#endif /* bird */
154# undef _XOPEN_SOURCE
155# define _XOPEN_SOURCE 600
156# undef _XOPEN_SOURCE_EXTENDED
157# define _XOPEN_SOURCE_EXTENDED 1
158# undef _LARGEFILE64_SOURCE
159#ifndef __EMX__ /* bird */
160# define _LARGEFILE64_SOURCE 1
161#endif /* bird */
162# undef _BSD_SOURCE
163# define _BSD_SOURCE 1
164# undef _SVID_SOURCE
165# define _SVID_SOURCE 1
166# ifdef __EMX__
167# define _EMX_SOURCE 1
168# endif
169#endif
170
171/* If nothing (other than _GNU_SOURCE) is defined,
172 define _BSD_SOURCE and _SVID_SOURCE. */
173#if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \
174 !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \
175 !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \
176 !defined _BSD_SOURCE && !defined _SVID_SOURCE)
177# define _BSD_SOURCE 1
178# define _SVID_SOURCE 1
179#endif
180
181/* This is to enable the ISO C99 extension. Also recognize the old macro
182 which was used prior to the standard acceptance. This macro will
183 eventually go away and the features enabled by default once the ISO C99
184 standard is widely adopted. */
185#if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \
186 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
187# define __USE_ISOC99 1
188#endif
189
190#ifndef __EMX__ /* bird: this messes up lot's of EMX legacy declarations. */
191/* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
192 (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */
193#if (!defined __STRICT_ANSI__ && !defined _POSIX_SOURCE && \
194 !defined _POSIX_C_SOURCE)
195# define _POSIX_SOURCE 1
196# if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
197# define _POSIX_C_SOURCE 2
198# else
199# define _POSIX_C_SOURCE 199506L
200# endif
201#endif
202#endif /* bird */
203
204#if defined _POSIX_SOURCE || (defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 1) || defined _XOPEN_SOURCE /* bird: check if defined, -Wundef. */
205# define __USE_POSIX 1
206#endif
207
208#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
209# define __USE_POSIX2 1
210#endif
211
212#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199309L /* bird: check if defined, -Wundef. */
213# define __USE_POSIX199309 1
214#endif
215
216#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199506L /* bird: check if defined, -Wundef. */
217# define __USE_POSIX199506 1
218#endif
219
220#ifdef _XOPEN_SOURCE
221# define __USE_XOPEN 1
222# if (_XOPEN_SOURCE - 0) >= 500
223# define __USE_XOPEN_EXTENDED 1
224# define __USE_UNIX98 1
225# undef _LARGEFILE_SOURCE
226# define _LARGEFILE_SOURCE 1
227# if (_XOPEN_SOURCE - 0) >= 600
228# define __USE_XOPEN2K 1
229# undef __USE_ISOC99
230# define __USE_ISOC99 1
231# endif
232# else
233# ifdef _XOPEN_SOURCE_EXTENDED
234# define __USE_XOPEN_EXTENDED 1
235# endif
236# endif
237#endif
238
239#ifdef _LARGEFILE_SOURCE
240# define __USE_LARGEFILE 1
241#endif
242
243#ifndef __EMX__ /* bird */
244#ifdef _LARGEFILE64_SOURCE
245# define __USE_LARGEFILE64 1
246#endif
247#endif /* bird */
248
249#ifndef __EMX__ /* bird */
250#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
251# define __USE_FILE_OFFSET64 1
252#endif
253#else
254# define __USE_FILE_OFFSET64 1
255#endif /* bird */
256
257#if defined _BSD_SOURCE || defined _SVID_SOURCE
258# define __USE_MISC 1
259#endif
260
261#ifdef _BSD_SOURCE
262# define __USE_BSD 1
263/* bird: __USE_BSD == __BSD_VISIBLE, make sure it's defined. */
264# ifdef __EMX__
265# undef __BSD_VISIBLE
266# define __BSD_VISIBLE 1
267# endif
268/* bird: end */
269#endif
270
271#ifdef _SVID_SOURCE
272# define __USE_SVID 1
273#endif
274
275#ifdef _GNU_SOURCE
276# define __USE_GNU 1
277#endif
278
279#if defined(__EMX__) && defined(_EMX_SOURCE) /* bird */
280# define __USE_EMX 1 /* bird */
281#endif /* bird */
282
283#if defined _REENTRANT || defined _THREAD_SAFE
284# define __USE_REENTRANT 1
285#endif
286
287/* We do support the IEC 559 math functionality, real and complex. */
288#define __STDC_IEC_559__ 1
289#define __STDC_IEC_559_COMPLEX__ 1
290
291/* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.1. */
292#define __STDC_ISO_10646__ 200009L
293
294#ifndef __EMX__ /*bird: we're not GLIBC */
295/* This macro indicates that the installed library is the GNU C Library.
296 For historic reasons the value now is 6 and this will stay from now
297 on. The use of this variable is deprecated. Use __GLIBC__ and
298 __GLIBC_MINOR__ now (see below) when you want to test for a specific
299 GNU C library version and use the values in <gnu/lib-names.h> to get
300 the sonames of the shared libraries. */
301#undef __GNU_LIBRARY__
302#define __GNU_LIBRARY__ 6
303
304/* Major and minor version number of the GNU C library package. Use
305 these macros to test for features in specific releases. */
306#define __GLIBC__ 2
307#define __GLIBC_MINOR__ 3
308#endif /*bird*/
309
310/* Convenience macros to test the versions of glibc and gcc.
311 Use them like this:
312 #if __GNUC_PREREQ (2,8)
313 ... code requiring gcc 2.8 or later ...
314 #endif
315 Note - they won't work for gcc1 or glibc1, since the _MINOR macros
316 were not defined then. */
317#if defined __GNUC__ && defined __GNUC_MINOR__
318# define __GNUC_PREREQ(maj, min) \
319 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
320#else
321# define __GNUC_PREREQ(maj, min) 0
322#endif
323
324#define __GLIBC_PREREQ(maj, min) \
325 ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
326
327/* Decide whether a compiler supports the long long datatypes. */
328#if defined __GNUC__ \
329 || (defined __PGI && defined __i386__ ) \
330 || (defined __INTEL_COMPILER && (defined __i386__ || defined __ia64__)) \
331 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
332# define __GLIBC_HAVE_LONG_LONG 1
333#endif
334
335/* This is here only because every header file already includes this one. */
336#ifndef __ASSEMBLER__
337# ifndef _SYS_CDEFS_H
338# include <sys/cdefs.h>
339# endif
340
341/* If we don't have __REDIRECT, prototypes will be missing if
342 __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
343# if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
344# define __USE_LARGEFILE 1
345#ifndef __EMX__ /* bird */
346# define __USE_LARGEFILE64 1
347#endif /* bird */
348# endif
349
350#endif /* !ASSEMBLER */
351
352/* Decide whether we can define 'extern inline' functions in headers. */
353#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
354 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
355# define __USE_EXTERN_INLINES 1
356#endif
357
358
359#ifndef __EMX__ /* bird */
360/* This is here only because every header file already includes this one.
361 Get the definitions of all the appropriate `__stub_FUNCTION' symbols.
362 <gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub
363 that will always return failure (and set errno to ENOSYS). */
364#include <gnu/stubs.h>
365#endif /* bird */
366
367
368#endif /* features.h */
Note: See TracBrowser for help on using the repository browser.