OSDN Git Service

Merge in the pthread library. This is the linuxthreads library taken from
[uclinux-h8/uClibc.git] / include / features.h
1 /* Copyright (C) 1991,92,93,95,96,97,98,99,2000,2001 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    _XOPEN_SOURCE        Includes POSIX and XPG things.  Set to 500 if
36                         Single Unix conformance is wanted, to 600 for the
37                         upcoming sixth revision.
38    _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
39    _LARGEFILE_SOURCE    Some more functions for correct standard I/O.
40    _LARGEFILE64_SOURCE  Additional functionality from LFS for large files.
41    _FILE_OFFSET_BITS=N  Select default filesystem interface.
42    _BSD_SOURCE          ISO C, POSIX, and 4.3BSD things.
43    _SVID_SOURCE         ISO C, POSIX, and SVID things.
44    _GNU_SOURCE          All of the above, plus GNU extensions.
45    _REENTRANT           Select additionally reentrant object.
46    _THREAD_SAFE         Same as _REENTRANT, often used by other systems.
47
48    The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__.
49    If none of these are defined, the default is to have _SVID_SOURCE,
50    _BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
51    199506L.  If more than one of these are defined, they accumulate.
52    For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE
53    together give you ISO C, 1003.1, and 1003.2, but nothing else.
54
55    These are defined by this file and are used by the
56    header files to decide what to declare or define:
57
58    __USE_ISOC99         Define ISO C99 things.
59    __USE_POSIX          Define IEEE Std 1003.1 things.
60    __USE_POSIX2         Define IEEE Std 1003.2 things.
61    __USE_POSIX199309    Define IEEE Std 1003.1, and .1b things.
62    __USE_POSIX199506    Define IEEE Std 1003.1, .1b, .1c and .1i things.
63    __USE_XOPEN          Define XPG things.
64    __USE_XOPEN_EXTENDED Define X/Open Unix things.
65    __USE_UNIX98         Define Single Unix V2 things.
66    __USE_XOPEN2K        Define XPG6 things.
67    __USE_LARGEFILE      Define correct standard I/O things.
68    __USE_LARGEFILE64    Define LFS things with separate names.
69    __USE_FILE_OFFSET64  Define 64bit interface as default.
70    __USE_BSD            Define 4.3BSD things.
71    __USE_SVID           Define SVID things.
72    __USE_MISC           Define things common to BSD and System V Unix.
73    __USE_GNU            Define GNU extensions.
74    __USE_REENTRANT      Define reentrant/thread-safe *_r functions.
75    __FAVOR_BSD          Favor 4.3BSD things in cases of conflict.
76
77    The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are
78    defined by this file unconditionally.  `__GNU_LIBRARY__' is provided
79    only for compatibility.  All new code should use the other symbols
80    to test for features.
81
82    All macros listed above as possibly being defined by this file are
83    explicitly undefined if they are not explicitly defined.
84    Feature-test macros that are not defined by the user or compiler
85    but are implied by the other feature-test macros defined (or by the
86    lack of any definitions) are defined by the file.  */
87
88 /* First, record if user requested some form of large file support. */
89 #if defined(_LARGEFILE_SOURCE) || defined(_LARGEFILE64_SOURCE) \
90     || (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
91 # define __USER_REQUESTED_LFS_OPTION 1
92 #endif
93
94 /* Undefine everything, so we get a clean slate.  */
95 #undef  __USE_ISOC99
96 #undef  __USE_POSIX
97 #undef  __USE_POSIX2
98 #undef  __USE_POSIX199309
99 #undef  __USE_POSIX199506
100 #undef  __USE_XOPEN
101 #undef  __USE_XOPEN_EXTENDED
102 #undef  __USE_UNIX98
103 #undef  __USE_XOPEN2K
104 #undef  __USE_LARGEFILE
105 #undef  __USE_LARGEFILE64
106 #undef  __USE_FILE_OFFSET64
107 #undef  __USE_BSD
108 #undef  __USE_SVID
109 #undef  __USE_MISC
110 #undef  __USE_GNU
111 #undef  __USE_REENTRANT
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
125 /* If _BSD_SOURCE was defined by the user, favor BSD over POSIX.  */
126 #if defined _BSD_SOURCE && \
127     !(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \
128       defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \
129       defined _GNU_SOURCE || defined _SVID_SOURCE)
130 # define __FAVOR_BSD    1
131 #endif
132
133 /* If _GNU_SOURCE was defined by the user, turn on all the other features.  */
134 #ifdef _GNU_SOURCE
135 # undef  _ISOC99_SOURCE
136 # define _ISOC99_SOURCE 1
137 # undef  _POSIX_SOURCE
138 # define _POSIX_SOURCE  1
139 # undef  _POSIX_C_SOURCE
140 # define _POSIX_C_SOURCE        199506L
141 # undef  _XOPEN_SOURCE
142 # define _XOPEN_SOURCE  600
143 # undef  _XOPEN_SOURCE_EXTENDED
144 # define _XOPEN_SOURCE_EXTENDED 1
145 # undef  _LARGEFILE64_SOURCE
146 # define _LARGEFILE64_SOURCE    1
147 # undef  _BSD_SOURCE
148 # define _BSD_SOURCE    1
149 # undef  _SVID_SOURCE
150 # define _SVID_SOURCE   1
151 #endif
152
153 /* If nothing (other than _GNU_SOURCE) is defined,
154    define _BSD_SOURCE and _SVID_SOURCE.  */
155 #if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \
156      !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \
157      !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \
158      !defined _BSD_SOURCE && !defined _SVID_SOURCE)
159 # define _BSD_SOURCE    1
160 # define _SVID_SOURCE   1
161 #endif
162
163 /* This is to enable the ISO C99 extension.  Also recognize the old macro
164    which was used prior to the standard acceptance.  This macro will
165    eventually go away and the features enabled by default once the ISO C99
166    standard is widely adopted.  */
167 #if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \
168      || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
169 # define __USE_ISOC99   1
170 #endif
171
172 /* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
173    (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined).  */
174 #if (!defined __STRICT_ANSI__ && !defined _POSIX_SOURCE && \
175      !defined _POSIX_C_SOURCE)
176 # define _POSIX_SOURCE  1
177 # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
178 #  define _POSIX_C_SOURCE       2
179 # else
180 #  define _POSIX_C_SOURCE       199506L
181 # endif
182 #endif
183
184 #if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
185 # define __USE_POSIX    1
186 #endif
187
188 #if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
189 # define __USE_POSIX2   1
190 #endif
191
192 #if (_POSIX_C_SOURCE - 0) >= 199309L
193 # define __USE_POSIX199309      1
194 #endif
195
196 #if (_POSIX_C_SOURCE - 0) >= 199506L
197 # define __USE_POSIX199506      1
198 #endif
199
200 #ifdef  _XOPEN_SOURCE
201 # define __USE_XOPEN    1
202 # if (_XOPEN_SOURCE - 0) >= 500
203 #  define __USE_XOPEN_EXTENDED  1
204 #  define __USE_UNIX98  1
205 #  undef _LARGEFILE_SOURCE
206 #  define _LARGEFILE_SOURCE     1
207 #  if (_XOPEN_SOURCE - 0) >= 600
208 #   define __USE_XOPEN2K        1
209 #   undef __USE_ISOC99
210 #   define __USE_ISOC99         1
211 #  endif
212 # else
213 #  ifdef _XOPEN_SOURCE_EXTENDED
214 #   define __USE_XOPEN_EXTENDED 1
215 #  endif
216 # endif
217 #endif
218
219 #ifdef _LARGEFILE_SOURCE
220 # define __USE_LARGEFILE        1
221 #endif
222
223 #ifdef _LARGEFILE64_SOURCE
224 # define __USE_LARGEFILE64      1
225 #endif
226
227 #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
228 # define __USE_FILE_OFFSET64    1
229 #endif
230
231 #if defined _BSD_SOURCE || defined _SVID_SOURCE
232 # define __USE_MISC     1
233 #endif
234
235 #ifdef  _BSD_SOURCE
236 # define __USE_BSD      1
237 #endif
238
239 #ifdef  _SVID_SOURCE
240 # define __USE_SVID     1
241 #endif
242
243 #ifdef  _GNU_SOURCE
244 # define __USE_GNU      1
245 #endif
246
247 #if defined _REENTRANT || defined _THREAD_SAFE
248 # define __USE_REENTRANT        1
249 #endif
250
251 /* We do support the IEC 559 math functionality, real and complex.  */
252 #define __STDC_IEC_559__                1
253 #define __STDC_IEC_559_COMPLEX__        1
254
255 /* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.0.  */
256 #define __STDC_ISO_10646__              200009L
257
258 /* Major and minor version number of the uClibc library package.  Use
259    these macros to test for features in specific releases.  */
260 #define __UCLIBC__              0
261 #define __UCLIBC_MAJOR__        9
262 #define __UCLIBC_MINOR__        5
263
264 /*  There is an unwholesomely huge amount of code out there that depends on the
265  *  presence of GNU libc header files.  We have GNU libc header files.  So here
266  *  we commit a horrible sin.  At this point, we _lie_ and claim to be GNU libc
267  *  to make things like /usr/include/linux/socket.h and lots of apps work as
268  *  their developers intended.  This is IMHO, pardonable, since these defines
269  *  are not really intended to check for the presence of a particular library,
270  *  but rather are used to define an _interface_.  */
271 #if !defined __FORCE_NOGLIBC && (!defined _LIBC || defined __FORCE_GLIBC)
272 #   define __GNU_LIBRARY__ 6
273 #   define __GLIBC__       2
274 #   define __GLIBC_MINOR__ 2
275 #endif  
276
277 /* Convenience macros to test the versions of glibc and gcc.
278    Use them like this:
279    #if __GNUC_PREREQ (2,8)
280    ... code requiring gcc 2.8 or later ...
281    #endif
282    Note - they won't work for gcc1 or glibc1, since the _MINOR macros
283    were not defined then.  */
284 #if defined __GNUC__ && defined __GNUC_MINOR__
285 # define __GNUC_PREREQ(maj, min) \
286         ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
287 #else
288 # define __GNUC_PREREQ(maj, min) 0
289 #endif
290
291 #define __GLIBC_PREREQ(maj, min) \
292         ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
293
294 /* This is here only because every header file already includes this one.  */
295 #ifndef __ASSEMBLER__
296 #ifndef _SYS_CDEFS_H
297 # include <sys/cdefs.h>
298 #endif
299
300 /* If we don't have __REDIRECT, prototypes will be missing if
301    __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
302 # if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
303 #  define __USE_LARGEFILE       1
304 #  define __USE_LARGEFILE64     1
305 # endif
306
307 #endif  /* !ASSEMBLER */
308
309 /* Decide whether we can define 'extern inline' functions in headers.  */
310 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
311     && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
312 # define __USE_EXTERN_INLINES   1
313 #endif
314
315 /* This is here only because every header file already includes this one.  */
316 #if 0
317 /*#ifndef _LIBC*/
318 /* Get the definitions of all the appropriate `__stub_FUNCTION' symbols.
319    <gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub
320    which will always return failure (and set errno to ENOSYS).
321
322    We avoid including <gnu/stubs.h> when compiling the C library itself to
323    avoid a dependency loop.  stubs.h depends on every object file.  If
324    this #include were done for the library source code, then every object
325    file would depend on stubs.h.  */
326
327 # include <gnu/stubs.h>
328 #endif
329
330 /* No C++ */
331 #define __BEGIN_DECLS
332 #define __END_DECLS
333
334 /* Load up the current set of uClibc supported features */
335 #define __need_uClibc_config_h
336 #include <bits/uClibc_config.h>
337 #undef __need_uClibc_config_h
338
339 /* Make sure users large file options agree with uClibc's configuration. */
340 #ifndef __UCLIBC_HAVE_LFS__
341 /* If uClibc was built without large file support, output an error if
342  * large file functions are requested. */
343 #ifdef __USER_REQUESTED_LFS_OPTION
344 #error uClibc was configured without large file support...
345 /* Since _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE can be turned by
346  *  other options, disable them with a warning if they were enabled. */
347 #elif defined(_LARGEFILE_SOURCE) || defined(_LARGEFILE64_SOURCE)
348 #warning uClibc was configured without large file support...
349 #endif
350 #undef  _LARGEFILE_SOURCE
351 #undef  _LARGEFILE64_SOURCE
352 #undef  _FILE_OFFSET_BITS
353 #undef  __USE_LARGEFILE
354 #undef  __USE_LARGEFILE64
355 #undef  __USE_FILE_OFFSET64
356 /* If we're actually building uClibc with large file support,
357  * define __USE_LARGEFILE64 only. */
358 #elif defined(_LIBC)
359 #undef  _LARGEFILE_SOURCE
360 #undef  _LARGEFILE64_SOURCE
361 #undef  _FILE_OFFSET_BITS
362 #undef  __USE_LARGEFILE
363 #undef  __USE_LARGEFILE64
364 #undef  __USE_FILE_OFFSET64
365 #define __USE_LARGEFILE64       1
366 #endif
367
368 /* Some nice features only work properly with ELF */
369 #if defined _LIBC && defined HAVE_ELF   
370 /* Define ALIASNAME as a weak alias for NAME. */
371 #  define weak_alias(name, aliasname) _weak_alias (name, aliasname)
372 #  define _weak_alias(name, aliasname) \
373       extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
374 /* Define ALIASNAME as a strong alias for NAME.  */
375 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
376 # define _strong_alias(name, aliasname) \
377   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
378 /* This comes between the return type and function name in
379  *    a function definition to make that definition weak.  */
380 # define weak_function __attribute__ ((weak))
381 # define weak_const_function __attribute__ ((weak, __const__))
382 /* Tacking on "\n\t#" to the section name makes gcc put it's bogus
383  * section attributes on what looks like a comment to the assembler. */
384 #  define link_warning(symbol, msg)                                           \
385         asm (".section "  ".gnu.warning." #symbol  "\n\t.previous");          \
386             static const char __evoke_link_warning_##symbol[]                 \
387             __attribute__ ((section (".gnu.warning." #symbol "\n\t#"))) = msg;
388 #else
389 #  define strong_alias(name, aliasname) _strong_alias (name, aliasname)
390 #  define weak_alias(name, aliasname) _strong_alias (name, aliasname)
391 #  define _strong_alias(name, aliasname) \
392         __asm__(".global _" #aliasname "\n.set _" #aliasname ",_" #name);
393 #  define link_warning(symbol, msg) \
394         asm (".stabs \"" msg "\",30,0,0,0\n\t" \
395               ".stabs \"" #symbol "\",1,0,0,0\n");
396 #endif
397
398 /* --- this is added to integrate linuxthreads */
399
400 #define __USE_UNIX98            1
401
402
403 #ifndef weak_function
404 /* If we do not have the __attribute__ ((weak)) syntax, there is no way we
405    can define functions as weak symbols.  The compiler will emit a `.globl'
406    directive for the function symbol, and a `.weak' directive in addition
407    will produce an error from the assembler.  */ 
408 # define weak_function          /* empty */
409 # define weak_const_function    /* empty */
410 #endif
411
412 /* On some platforms we can make internal function calls (i.e., calls of
413    functions not exported) a bit faster by using a different calling
414    convention.  */
415 #ifndef internal_function
416 # define internal_function      /* empty */
417 #endif
418
419 /* Prepare for the case that `__builtin_expect' is not available.  */
420 #ifndef HAVE_BUILTIN_EXPECT
421 # define __builtin_expect(expr, val) (expr)
422 #endif
423
424
425 #endif  /* features.h  */