1 /* Copyright (C) 1991-1993,1995-2006,2007,2009 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, see 16 <http://www.gnu.org/licenses/>. */ 17 18 #ifndef _FEATURES_H 19 #define _FEATURES_H 1 20 21 /* These are defined by the user (or the compiler) 22 to specify the desired environment: 23 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. 49 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. 56 57 These are defined by this file and are used by the 58 header files to decide what to declare or define: 59 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. 82 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. 87 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. */ 93 94 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 119 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 125 126 /* Always use ISO C things. */ 127 #define __USE_ANSI 1 128 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 142 143 /* Convenience macro to test the version of clang. 144 Use like this: 145 #if __CLANG_PREREQ(3,2) 146 ... code requiring clang 3.2 or later ... 147 #endif */ 148 #if defined __clang__ 149 # define __CLANG_PREREQ(maj, min) \ 150 ((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min)) 151 #else 152 # define __CLANG_PREREQ(maj, min) 0 153 #endif 154 155 /* Whether to use feature set F. */ 156 #define __GLIBC_USE(F) __GLIBC_USE_ ## F 157 158 /* _DEFAULT_SOURCE is equivalent to defining _BSD_SOURCE, _SVID_SOURCE 159 * and _POSIX_C_SOURCE=200809L and vice versa. */ 160 #if defined _DEFAULT_SOURCE || defined _BSD_SOURCE || defined _SVID_SOURCE 161 # undef _DEFAULT_SOURCE 162 # define _DEFAULT_SOURCE 1 163 # undef _BSD_SOURCE 164 # define _BSD_SOURCE 1 165 # undef _SVID_SOURCE 166 # define _SVID_SOURCE 1 167 # if _POSIX_C_SOURCE < 200809L 168 # undef _POSIX_C_SOURCE 169 # define _POSIX_C_SOURCE 200809L 170 # endif 171 #endif 172 173 /* If _GNU_SOURCE was defined by the user, turn on all the other features. */ 174 #ifdef _GNU_SOURCE 175 # undef _ISOC99_SOURCE 176 # define _ISOC99_SOURCE 1 177 # undef _ISOC11_SOURCE 178 # define _ISOC11_SOURCE 1 179 # undef _POSIX_SOURCE 180 # define _POSIX_SOURCE 1 181 # undef _POSIX_C_SOURCE 182 # define _POSIX_C_SOURCE 200809L 183 # undef _XOPEN_SOURCE 184 # define _XOPEN_SOURCE 700 185 # undef _XOPEN_SOURCE_EXTENDED 186 # define _XOPEN_SOURCE_EXTENDED 1 187 # undef _LARGEFILE64_SOURCE 188 # define _LARGEFILE64_SOURCE 1 189 # undef _BSD_SOURCE 190 # define _BSD_SOURCE 1 191 # undef _SVID_SOURCE 192 # define _SVID_SOURCE 1 193 # undef _ATFILE_SOURCE 194 # define _ATFILE_SOURCE 1 195 #endif 196 197 /* This macro indicates that the installed library is uClibc. Use 198 * __UCLIBC_MAJOR__ and __UCLIBC_MINOR__ to test for the features in 199 * specific releases. */ 200 #define __UCLIBC__ 1 201 202 #ifdef __UCLIBC__ 203 /* Load up the current set of uClibc supported features along 204 * with the current uClibc major and minor version numbers. 205 * For uClibc release 0.9.26, these numbers would be: 206 * #define __UCLIBC_MAJOR__ 0 207 * #define __UCLIBC_MINOR__ 9 208 * #define __UCLIBC_SUBLEVEL__ 26 209 */ 210 # define __need_uClibc_config_h 211 # include <bits/uClibc_config.h> 212 # undef __need_uClibc_config_h 213 214 /* For uClibc, always optimize for size -- this should disable 215 * a lot of expensive inlining... 216 * TODO: this is wrong! __OPTIMIZE_SIZE__ is an indicator of 217 * gcc -Os compile. We should not mess with compiler inlines. 218 * We should instead disable __USE_EXTERN_INLINES unconditionally, 219 * or maybe actually audit and test uclibc to work correctly 220 * with __USE_EXTERN_INLINES on. 221 */ 222 # define __OPTIMIZE_SIZE__ 1 223 224 /* disable unsupported features */ 225 # undef __LDBL_COMPAT 226 227 /* no support for FORTIFY */ 228 # undef _FORTIFY_SOURCE 229 230 # ifndef __UCLIBC_HAS_THREADS__ 231 # if defined _REENTRANT || defined _THREAD_SAFE 232 # warning requested reentrant code, but thread support was disabled 233 # undef _REENTRANT 234 # undef _THREAD_SAFE 235 # endif 236 # endif 237 238 #endif /* __UCLIBC__ */ 239 240 /* If nothing (other than _GNU_SOURCE) is defined, 241 define _BSD_SOURCE and _SVID_SOURCE. */ 242 #if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \ 243 !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \ 244 !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \ 245 !defined _BSD_SOURCE && !defined _SVID_SOURCE) 246 # define _BSD_SOURCE 1 247 # define _SVID_SOURCE 1 248 #endif 249 250 /* This is to enable the ISO C11 extension. */ 251 #if (defined _ISOC11_SOURCE \ 252 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)) 253 # define __USE_ISOC11 1 254 #endif 255 256 /* This is to enable the ISO C99 extension. */ 257 #if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \ 258 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) 259 # define __USE_ISOC99 1 260 #endif 261 262 /* This is to enable the ISO C90 Amendment 1:1995 extension. */ 263 #if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \ 264 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L)) 265 # define __USE_ISOC95 1 266 #endif 267 268 /* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2 269 (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */ 270 #if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \ 271 !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE) 272 # define _POSIX_SOURCE 1 273 # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500 274 # define _POSIX_C_SOURCE 2 275 # elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 600 276 # define _POSIX_C_SOURCE 199506L 277 # elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 700 278 # define _POSIX_C_SOURCE 200112L 279 # else 280 # define _POSIX_C_SOURCE 200809L 281 # endif 282 # define __USE_POSIX_IMPLICITLY 1 283 #endif 284 285 #if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE 286 # define __USE_POSIX 1 287 #endif 288 289 #if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE 290 # define __USE_POSIX2 1 291 #endif 292 293 #if (_POSIX_C_SOURCE - 0) >= 199309L 294 # define __USE_POSIX199309 1 295 #endif 296 297 #if (_POSIX_C_SOURCE - 0) >= 199506L 298 # define __USE_POSIX199506 1 299 #endif 300 301 #if (_POSIX_C_SOURCE - 0) >= 200112L 302 # define __USE_XOPEN2K 1 303 # undef __USE_ISOC99 304 # define __USE_ISOC99 1 305 #endif 306 307 #if (_POSIX_C_SOURCE - 0) >= 200809L 308 # define __USE_XOPEN2K8 1 309 # undef _ATFILE_SOURCE 310 # define _ATFILE_SOURCE 1 311 #endif 312 313 #ifdef _XOPEN_SOURCE 314 # define __USE_XOPEN 1 315 # if (_XOPEN_SOURCE - 0) >= 500 316 # define __USE_XOPEN_EXTENDED 1 317 # define __USE_UNIX98 1 318 # undef _LARGEFILE_SOURCE 319 # define _LARGEFILE_SOURCE 1 320 # if (_XOPEN_SOURCE - 0) >= 600 321 # if (_XOPEN_SOURCE - 0) >= 700 322 # define __USE_XOPEN2K8 1 323 # endif 324 # define __USE_XOPEN2K 1 325 # undef __USE_ISOC99 326 # define __USE_ISOC99 1 327 # endif 328 # else 329 # ifdef _XOPEN_SOURCE_EXTENDED 330 # define __USE_XOPEN_EXTENDED 1 331 # endif 332 # endif 333 #endif 334 335 #ifdef _LARGEFILE_SOURCE 336 # define __USE_LARGEFILE 1 337 #endif 338 339 #ifdef _LARGEFILE64_SOURCE 340 # define __USE_LARGEFILE64 1 341 #endif 342 343 #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 344 # define __USE_FILE_OFFSET64 1 345 #endif 346 347 #if defined _BSD_SOURCE || defined _SVID_SOURCE 348 # define __USE_MISC 1 349 #endif 350 351 #ifdef _BSD_SOURCE 352 # define __USE_BSD 1 353 #endif 354 355 #ifdef _SVID_SOURCE 356 # define __USE_SVID 1 357 #endif 358 359 #ifdef _ATFILE_SOURCE 360 # define __USE_ATFILE 1 361 #endif 362 363 #ifdef _GNU_SOURCE 364 # define __USE_GNU 1 365 #endif 366 367 #if defined _REENTRANT || defined _THREAD_SAFE 368 # define __USE_REENTRANT 1 369 #endif 370 371 /* We do support the IEC 559 math functionality, real and complex. */ 372 #ifdef __UCLIBC_HAS_FLOATS__ 373 #define __STDC_IEC_559__ 1 374 #define __STDC_IEC_559_COMPLEX__ 1 375 #endif 376 377 #ifdef __UCLIBC_HAS_WCHAR__ 378 /* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.1. */ 379 #define __STDC_ISO_10646__ 200009L 380 #endif 381 382 /* There is an unwholesomely huge amount of code out there that depends on the 383 * presence of GNU libc header files. We have GNU libc header files. So here 384 * we commit a horrible sin. At this point, we _lie_ and claim to be GNU libc 385 * to make things like /usr/include/linux/socket.h and lots of apps work as 386 * their developers intended. This is IMHO, pardonable, since these defines 387 * are not really intended to check for the presence of a particular library, 388 * but rather are used to define an _interface_. */ 389 #if !defined __FORCE_NOGLIBC && (!defined _LIBC || defined __FORCE_GLIBC) 390 /* This macro indicates that the installed library is the GNU C Library. 391 For historic reasons the value now is 6 and this will stay from now 392 on. The use of this variable is deprecated. */ 393 /* uClibc WARNING: leave these aligned to the left, don't put a space after '#', else 394 * broken apps could fail the check. */ 395 #undef __GNU_LIBRARY__ 396 #define __GNU_LIBRARY__ 6 397 398 /* Major and minor version number of the GNU C library package. Use 399 these macros to test for features in specific releases. */ 400 /* Don't do it, if you want to keep uClibc happy. */ 401 #define __GLIBC__ 2 402 #define __GLIBC_MINOR__ 2 403 #endif 404 405 #define __GLIBC_PREREQ(maj, min) \ 406 ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min)) 407 408 #ifndef __UCLIBC__ 409 /* Decide whether a compiler supports the long long datatypes. */ 410 #if defined __GNUC__ \ 411 || (defined __PGI && defined __i386__ ) \ 412 || (defined __INTEL_COMPILER && (defined __i386__ || defined __ia64__)) \ 413 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) 414 # define __GLIBC_HAVE_LONG_LONG 1 415 #endif 416 #endif 417 418 /* This is here only because every header file already includes this one. */ 419 #ifndef __ASSEMBLER__ 420 # ifndef _SYS_CDEFS_H 421 # include <sys/cdefs.h> 422 # endif 423 424 /* If we don't have __REDIRECT, prototypes will be missing if 425 __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */ 426 # if defined __USE_FILE_OFFSET64 && !defined __REDIRECT 427 # define __USE_LARGEFILE 1 428 # define __USE_LARGEFILE64 1 429 # endif 430 431 #endif /* !ASSEMBLER */ 432 433 /* Decide whether we can, and are willing to define extern inline 434 * functions in headers, even if this results in a slightly bigger 435 * code for user programs built against uclibc. 436 * Enabled only in -O2 compiles, not -Os. 437 * uclibc itself is usually built without __USE_EXTERN_INLINES, 438 * remove "&& !defined __OPTIMIZE_SIZE__" part to do otherwise. 439 */ 440 #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \ 441 && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \ 442 && (defined __extern_inline || defined __GNUC_GNU_INLINE__ || defined __GNUC_STDC_INLINE__) 443 # define __USE_EXTERN_INLINES 1 444 #endif 445 446 #ifdef _LIBC 447 # undef _FILE_OFFSET_BITS 448 # undef __USE_FILE_OFFSET64 449 # include <libc-internal.h> 450 #endif 451 452 #if defined(__UCLIBC_USE_TIME64__) || __TARGET_ARCH_BITS__ == 64 453 #define __USE_TIME_BITS64 1 454 #endif 455 456 #endif /* features.h */ 457