Back to index

glibc  2.9
features.h
Go to the documentation of this file.
00001 /* Copyright (C) 1991,1992,1993,1995-2006,2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifndef       _FEATURES_H
00020 #define       _FEATURES_H   1
00021 
00022 /* These are defined by the user (or the compiler)
00023    to specify the desired environment:
00024 
00025    __STRICT_ANSI__   ISO Standard C.
00026    _ISOC99_SOURCE    Extensions to ISO C89 from ISO C99.
00027    _POSIX_SOURCE     IEEE Std 1003.1.
00028    _POSIX_C_SOURCE   If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;
00029                      if >=199309L, add IEEE Std 1003.1b-1993;
00030                      if >=199506L, add IEEE Std 1003.1c-1995;
00031                      if >=200112L, all of IEEE 1003.1-2004
00032    _XOPEN_SOURCE     Includes POSIX and XPG things.  Set to 500 if
00033                      Single Unix conformance is wanted, to 600 for the
00034                      upcoming sixth revision.
00035    _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
00036    _LARGEFILE_SOURCE Some more functions for correct standard I/O.
00037    _LARGEFILE64_SOURCE      Additional functionality from LFS for large files.
00038    _FILE_OFFSET_BITS=N      Select default filesystem interface.
00039    _BSD_SOURCE              ISO C, POSIX, and 4.3BSD things.
00040    _SVID_SOURCE             ISO C, POSIX, and SVID things.
00041    _ATFILE_SOURCE    Additional *at interfaces.
00042    _GNU_SOURCE              All of the above, plus GNU extensions.
00043    _REENTRANT        Select additionally reentrant object.
00044    _THREAD_SAFE             Same as _REENTRANT, often used by other systems.
00045    _FORTIFY_SOURCE   If set to numeric value > 0 additional security
00046                      measures are defined, according to level.
00047 
00048    The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__.
00049    If none of these are defined, the default is to have _SVID_SOURCE,
00050    _BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
00051    200112L.  If more than one of these are defined, they accumulate.
00052    For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE
00053    together give you ISO C, 1003.1, and 1003.2, but nothing else.
00054 
00055    These are defined by this file and are used by the
00056    header files to decide what to declare or define:
00057 
00058    __USE_ISOC99             Define ISO C99 things.
00059    __USE_ISOC95             Define ISO C90 AMD1 (C95) things.
00060    __USE_POSIX              Define IEEE Std 1003.1 things.
00061    __USE_POSIX2             Define IEEE Std 1003.2 things.
00062    __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things.
00063    __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things.
00064    __USE_XOPEN              Define XPG things.
00065    __USE_XOPEN_EXTENDED     Define X/Open Unix things.
00066    __USE_UNIX98             Define Single Unix V2 things.
00067    __USE_XOPEN2K        Define XPG6 things.
00068    __USE_LARGEFILE   Define correct standard I/O things.
00069    __USE_LARGEFILE64 Define LFS things with separate names.
00070    __USE_FILE_OFFSET64      Define 64bit interface as default.
00071    __USE_BSD         Define 4.3BSD things.
00072    __USE_SVID        Define SVID things.
00073    __USE_MISC        Define things common to BSD and System V Unix.
00074    __USE_ATFILE             Define *at interfaces and AT_* constants for them.
00075    __USE_GNU         Define GNU extensions.
00076    __USE_REENTRANT   Define reentrant/thread-safe *_r functions.
00077    __USE_FORTIFY_LEVEL      Additional security measures used, according to level.
00078    __FAVOR_BSD              Favor 4.3BSD things in cases of conflict.
00079 
00080    The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are
00081    defined by this file unconditionally.  `__GNU_LIBRARY__' is provided
00082    only for compatibility.  All new code should use the other symbols
00083    to test for features.
00084 
00085    All macros listed above as possibly being defined by this file are
00086    explicitly undefined if they are not explicitly defined.
00087    Feature-test macros that are not defined by the user or compiler
00088    but are implied by the other feature-test macros defined (or by the
00089    lack of any definitions) are defined by the file.  */
00090 
00091 
00092 /* Undefine everything, so we get a clean slate.  */
00093 #undef __USE_ISOC99
00094 #undef __USE_ISOC95
00095 #undef __USE_POSIX
00096 #undef __USE_POSIX2
00097 #undef __USE_POSIX199309
00098 #undef __USE_POSIX199506
00099 #undef __USE_XOPEN
00100 #undef __USE_XOPEN_EXTENDED
00101 #undef __USE_UNIX98
00102 #undef __USE_XOPEN2K
00103 #undef __USE_LARGEFILE
00104 #undef __USE_LARGEFILE64
00105 #undef __USE_FILE_OFFSET64
00106 #undef __USE_BSD
00107 #undef __USE_SVID
00108 #undef __USE_MISC
00109 #undef __USE_ATFILE
00110 #undef __USE_GNU
00111 #undef __USE_REENTRANT
00112 #undef __USE_FORTIFY_LEVEL
00113 #undef __FAVOR_BSD
00114 #undef __KERNEL_STRICT_NAMES
00115 
00116 /* Suppress kernel-name space pollution unless user expressedly asks
00117    for it.  */
00118 #ifndef _LOOSE_KERNEL_NAMES
00119 # define __KERNEL_STRICT_NAMES
00120 #endif
00121 
00122 /* Always use ISO C things.  */
00123 #define       __USE_ANSI    1
00124 
00125 /* Convenience macros to test the versions of glibc and gcc.
00126    Use them like this:
00127    #if __GNUC_PREREQ (2,8)
00128    ... code requiring gcc 2.8 or later ...
00129    #endif
00130    Note - they won't work for gcc1 or glibc1, since the _MINOR macros
00131    were not defined then.  */
00132 #if defined __GNUC__ && defined __GNUC_MINOR__
00133 # define __GNUC_PREREQ(maj, min) \
00134        ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
00135 #else
00136 # define __GNUC_PREREQ(maj, min) 0
00137 #endif
00138 
00139 
00140 /* If _BSD_SOURCE was defined by the user, favor BSD over POSIX.  */
00141 #if defined _BSD_SOURCE && \
00142     !(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \
00143       defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \
00144       defined _GNU_SOURCE || defined _SVID_SOURCE)
00145 # define __FAVOR_BSD 1
00146 #endif
00147 
00148 /* If _GNU_SOURCE was defined by the user, turn on all the other features.  */
00149 #ifdef _GNU_SOURCE
00150 # undef  _ISOC99_SOURCE
00151 # define _ISOC99_SOURCE     1
00152 # undef  _POSIX_SOURCE
00153 # define _POSIX_SOURCE      1
00154 # undef  _POSIX_C_SOURCE
00155 # define _POSIX_C_SOURCE    200112L
00156 # undef  _XOPEN_SOURCE
00157 # define _XOPEN_SOURCE      600
00158 # undef  _XOPEN_SOURCE_EXTENDED
00159 # define _XOPEN_SOURCE_EXTENDED    1
00160 # undef        _LARGEFILE64_SOURCE
00161 # define _LARGEFILE64_SOURCE       1
00162 # undef  _BSD_SOURCE
00163 # define _BSD_SOURCE 1
00164 # undef  _SVID_SOURCE
00165 # define _SVID_SOURCE       1
00166 # undef  _ATFILE_SOURCE
00167 # define _ATFILE_SOURCE     1
00168 #endif
00169 
00170 /* If nothing (other than _GNU_SOURCE) is defined,
00171    define _BSD_SOURCE and _SVID_SOURCE.  */
00172 #if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \
00173      !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \
00174      !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \
00175      !defined _BSD_SOURCE && !defined _SVID_SOURCE)
00176 # define _BSD_SOURCE 1
00177 # define _SVID_SOURCE       1
00178 #endif
00179 
00180 /* This is to enable the ISO C99 extension.  Also recognize the old macro
00181    which was used prior to the standard acceptance.  This macro will
00182    eventually go away and the features enabled by default once the ISO C99
00183    standard is widely adopted.  */
00184 #if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \
00185      || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
00186 # define __USE_ISOC99       1
00187 #endif
00188 
00189 /* This is to enable the ISO C90 Amendment 1:1995 extension.  */
00190 #if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \
00191      || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L))
00192 # define __USE_ISOC95       1
00193 #endif
00194 
00195 /* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
00196    (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined).  */
00197 #if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \
00198      !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
00199 # define _POSIX_SOURCE      1
00200 # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
00201 #  define _POSIX_C_SOURCE   2
00202 # elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 600
00203 #  define _POSIX_C_SOURCE   199506L
00204 # else
00205 #  define _POSIX_C_SOURCE   200112L
00206 # endif
00207 #endif
00208 
00209 #if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
00210 # define __USE_POSIX 1
00211 #endif
00212 
00213 #if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
00214 # define __USE_POSIX2       1
00215 #endif
00216 
00217 #if (_POSIX_C_SOURCE - 0) >= 199309L
00218 # define __USE_POSIX199309  1
00219 #endif
00220 
00221 #if (_POSIX_C_SOURCE - 0) >= 199506L
00222 # define __USE_POSIX199506  1
00223 #endif
00224 
00225 #if (_POSIX_C_SOURCE - 0) >= 200112L
00226 # define __USE_XOPEN2K             1
00227 #endif
00228 
00229 #ifdef _XOPEN_SOURCE
00230 # define __USE_XOPEN 1
00231 # if (_XOPEN_SOURCE - 0) >= 500
00232 #  define __USE_XOPEN_EXTENDED     1
00233 #  define __USE_UNIX98      1
00234 #  undef _LARGEFILE_SOURCE
00235 #  define _LARGEFILE_SOURCE 1
00236 #  if (_XOPEN_SOURCE - 0) >= 600
00237 #   define __USE_XOPEN2K    1
00238 #   undef __USE_ISOC99
00239 #   define __USE_ISOC99            1
00240 #  endif
00241 # else
00242 #  ifdef _XOPEN_SOURCE_EXTENDED
00243 #   define __USE_XOPEN_EXTENDED    1
00244 #  endif
00245 # endif
00246 #endif
00247 
00248 #ifdef _LARGEFILE_SOURCE
00249 # define __USE_LARGEFILE    1
00250 #endif
00251 
00252 #ifdef _LARGEFILE64_SOURCE
00253 # define __USE_LARGEFILE64  1
00254 #endif
00255 
00256 #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
00257 # define __USE_FILE_OFFSET64       1
00258 #endif
00259 
00260 #if defined _BSD_SOURCE || defined _SVID_SOURCE
00261 # define __USE_MISC  1
00262 #endif
00263 
00264 #ifdef _BSD_SOURCE
00265 # define __USE_BSD   1
00266 #endif
00267 
00268 #ifdef _SVID_SOURCE
00269 # define __USE_SVID  1
00270 #endif
00271 
00272 #ifdef _ATFILE_SOURCE
00273 # define __USE_ATFILE       1
00274 #endif
00275 
00276 #ifdef _GNU_SOURCE
00277 # define __USE_GNU   1
00278 #endif
00279 
00280 #if defined _REENTRANT || defined _THREAD_SAFE
00281 # define __USE_REENTRANT    1
00282 #endif
00283 
00284 #if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \
00285     && __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
00286 # if _FORTIFY_SOURCE > 1
00287 #  define __USE_FORTIFY_LEVEL 2
00288 # else
00289 #  define __USE_FORTIFY_LEVEL 1
00290 # endif
00291 #else
00292 # define __USE_FORTIFY_LEVEL 0
00293 #endif
00294 
00295 /* We do support the IEC 559 math functionality, real and complex.  */
00296 #define __STDC_IEC_559__           1
00297 #define __STDC_IEC_559_COMPLEX__   1
00298 
00299 /* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.1.  */
00300 #define __STDC_ISO_10646__         200009L
00301 
00302 /* This macro indicates that the installed library is the GNU C Library.
00303    For historic reasons the value now is 6 and this will stay from now
00304    on.  The use of this variable is deprecated.  Use __GLIBC__ and
00305    __GLIBC_MINOR__ now (see below) when you want to test for a specific
00306    GNU C library version and use the values in <gnu/lib-names.h> to get
00307    the sonames of the shared libraries.  */
00308 #undef  __GNU_LIBRARY__
00309 #define __GNU_LIBRARY__ 6
00310 
00311 /* Major and minor version number of the GNU C library package.  Use
00312    these macros to test for features in specific releases.  */
00313 #define       __GLIBC__     2
00314 #define       __GLIBC_MINOR__      9
00315 
00316 #define __GLIBC_PREREQ(maj, min) \
00317        ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
00318 
00319 /* Decide whether a compiler supports the long long datatypes.  */
00320 #if defined __GNUC__ \
00321     || (defined __PGI && defined __i386__ ) \
00322     || (defined __INTEL_COMPILER && (defined __i386__ || defined __ia64__)) \
00323     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
00324 # define __GLIBC_HAVE_LONG_LONG    1
00325 #endif
00326 
00327 /* This is here only because every header file already includes this one.  */
00328 #ifndef __ASSEMBLER__
00329 # ifndef _SYS_CDEFS_H
00330 #  include <sys/cdefs.h>
00331 # endif
00332 
00333 /* If we don't have __REDIRECT, prototypes will be missing if
00334    __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
00335 # if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
00336 #  define __USE_LARGEFILE   1
00337 #  define __USE_LARGEFILE64 1
00338 # endif
00339 
00340 #endif /* !ASSEMBLER */
00341 
00342 /* Decide whether we can define 'extern inline' functions in headers.  */
00343 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
00344     && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \
00345     && defined __extern_inline
00346 # define __USE_EXTERN_INLINES      1
00347 #endif
00348 
00349 
00350 /* This is here only because every header file already includes this one.
00351    Get the definitions of all the appropriate `__stub_FUNCTION' symbols.
00352    <gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub
00353    that will always return failure (and set errno to ENOSYS).  */
00354 #include <gnu/stubs.h>
00355 
00356 
00357 #endif /* features.h  */