1 /* Copyright (C) 1992-2001, 2002, 2004, 2005, 2006, 2007, 2009, 2011 2 Free Software Foundation, Inc. 3 This file is part of the GNU C Library. 4 5 The GNU C Library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 The GNU C Library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with the GNU C Library; if not, write to the Free 17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 02111-1307 USA. */ 19 20 #ifndef _SYS_CDEFS_H 21 #define _SYS_CDEFS_H 1 22 23 /* We are almost always included from features.h. */ 24 #ifndef _FEATURES_H 25 # include <features.h> 26 #endif 27 28 /* The GNU libc does not support any K&R compilers or the traditional mode 29 of ISO C compilers anymore. Check for some of the combinations not 30 anymore supported. */ 31 #if defined __GNUC__ && !defined __STDC__ 32 # error "You need a ISO C conforming compiler to use the glibc headers" 33 #endif 34 35 /* Some user header file might have defined this before. */ 36 #undef __P 37 #undef __PMT 38 39 #ifdef __GNUC__ 40 41 /* All functions, except those with callbacks or those that 42 synchronize memory, are leaf functions. */ 43 # if __GNUC_PREREQ (4, 6) && !defined _LIBC 44 # define __LEAF , __leaf__ 45 # define __LEAF_ATTR __attribute__ ((__leaf__)) 46 # else 47 # define __LEAF 48 # define __LEAF_ATTR 49 # endif 50 51 /* GCC can always grok prototypes. For C++ programs we add throw() 52 to help it optimize the function calls. But this works only with 53 gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions 54 as non-throwing using a function attribute since programs can use 55 the -fexceptions options for C code as well. */ 56 # if !defined __cplusplus && __GNUC_PREREQ (3, 3) 57 # define __THROW __attribute__ ((__nothrow__ __LEAF)) 58 # define __THROWNL __attribute__ ((__nothrow__)) 59 # define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct 60 # else 61 # if defined __cplusplus && __GNUC_PREREQ (2,8) 62 # define __THROW throw () 63 # define __THROWNL throw () 64 # define __NTH(fct) __LEAF_ATTR fct throw () 65 # else 66 # define __THROW 67 # define __THROWNL 68 # define __NTH(fct) fct 69 # endif 70 # endif 71 72 #else /* Not GCC. */ 73 74 # define __inline /* No inline functions. */ 75 76 # define __THROW 77 # define __THROWNL 78 # define __NTH(fct) fct 79 80 # define __const const 81 # define __signed signed 82 # define __volatile volatile 83 84 #endif /* GCC. */ 85 86 /* These two macros are not used in glibc anymore. They are kept here 87 only because some other projects expect the macros to be defined. */ 88 #define __P(args) args 89 #define __PMT(args) args 90 91 /* For these things, GCC behaves the ANSI way normally, 92 and the non-ANSI way under -traditional. */ 93 94 #define __CONCAT(x,y) x ## y 95 #define __STRING(x) #x 96 97 /* This is not a typedef so `const __ptr_t' does the right thing. */ 98 #define __ptr_t void * 99 #define __long_double_t long double 100 101 102 /* C++ needs to know that types and declarations are C, not C++. */ 103 #ifdef __cplusplus 104 # define __BEGIN_DECLS extern "C" { 105 # define __END_DECLS } 106 #else 107 # define __BEGIN_DECLS 108 # define __END_DECLS 109 #endif 110 111 112 /* The standard library needs the functions from the ISO C90 standard 113 in the std namespace. At the same time we want to be safe for 114 future changes and we include the ISO C99 code in the non-standard 115 namespace __c99. The C++ wrapper header take case of adding the 116 definitions to the global namespace. */ 117 #if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES 118 # define __BEGIN_NAMESPACE_STD namespace std { 119 # define __END_NAMESPACE_STD } 120 # define __USING_NAMESPACE_STD(name) using std::name; 121 # define __BEGIN_NAMESPACE_C99 namespace __c99 { 122 # define __END_NAMESPACE_C99 } 123 # define __USING_NAMESPACE_C99(name) using __c99::name; 124 #else 125 /* For compatibility we do not add the declarations into any 126 namespace. They will end up in the global namespace which is what 127 old code expects. */ 128 # define __BEGIN_NAMESPACE_STD 129 # define __END_NAMESPACE_STD 130 # define __USING_NAMESPACE_STD(name) 131 # define __BEGIN_NAMESPACE_C99 132 # define __END_NAMESPACE_C99 133 # define __USING_NAMESPACE_C99(name) 134 #endif 135 136 137 /* Support for bounded pointers. */ 138 #ifndef __BOUNDED_POINTERS__ 139 # define __bounded /* nothing */ 140 # define __unbounded /* nothing */ 141 # define __ptrvalue /* nothing */ 142 #endif 143 144 145 /* Fortify support. */ 146 #define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) 147 #define __bos0(ptr) __builtin_object_size (ptr, 0) 148 149 #if __GNUC_PREREQ (4,3) 150 # define __warndecl(name, msg) \ 151 extern void name (void) __attribute__((__warning__ (msg))) 152 # define __warnattr(msg) __attribute__((__warning__ (msg))) 153 # define __errordecl(name, msg) \ 154 extern void name (void) __attribute__((__error__ (msg))) 155 #else 156 # define __warndecl(name, msg) extern void name (void) 157 # define __warnattr(msg) 158 # define __errordecl(name, msg) extern void name (void) 159 #endif 160 161 /* Support for flexible arrays. */ 162 #if __GNUC_PREREQ (2,97) 163 /* GCC 2.97 supports C99 flexible array members. */ 164 # define __flexarr [] 165 #else 166 # ifdef __GNUC__ 167 # define __flexarr [0] 168 # else 169 # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L 170 # define __flexarr [] 171 # else 172 /* Some other non-C99 compiler. Approximate with [1]. */ 173 # define __flexarr [1] 174 # endif 175 # endif 176 #endif 177 178 179 /* __asm__ ("xyz") is used throughout the headers to rename functions 180 at the assembly language level. This is wrapped by the __REDIRECT 181 macro, in order to support compilers that can do this some other 182 way. When compilers don't support asm-names at all, we have to do 183 preprocessor tricks instead (which don't have exactly the right 184 semantics, but it's the best we can do). 185 186 Example: 187 int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */ 188 189 #if defined __GNUC__ && __GNUC__ >= 2 190 191 # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias)) 192 # ifdef __cplusplus 193 # define __REDIRECT_NTH(name, proto, alias) \ 194 name proto __THROW __asm__ (__ASMNAME (#alias)) 195 # define __REDIRECT_NTHNL(name, proto, alias) \ 196 name proto __THROWNL __asm__ (__ASMNAME (#alias)) 197 # else 198 # define __REDIRECT_NTH(name, proto, alias) \ 199 name proto __asm__ (__ASMNAME (#alias)) __THROW 200 # define __REDIRECT_NTHNL(name, proto, alias) \ 201 name proto __asm__ (__ASMNAME (#alias)) __THROWNL 202 # endif 203 # define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname) 204 # define __ASMNAME2(prefix, cname) __STRING (prefix) cname 205 206 /* 207 #elif __SOME_OTHER_COMPILER__ 208 209 # define __REDIRECT(name, proto, alias) name proto; \ 210 _Pragma("let " #name " = " #alias) 211 */ 212 #endif 213 214 /* GCC has various useful declarations that can be made with the 215 `__attribute__' syntax. All of the ways we use this do fine if 216 they are omitted for compilers that don't understand it. */ 217 #if !defined __GNUC__ || __GNUC__ < 2 218 # define __attribute__(xyz) /* Ignore */ 219 #endif 220 221 /* At some point during the gcc 2.96 development the `malloc' attribute 222 for functions was introduced. We don't want to use it unconditionally 223 (although this would be possible) since it generates warnings. */ 224 #if __GNUC_PREREQ (2,96) 225 # define __attribute_malloc__ __attribute__ ((__malloc__)) 226 #else 227 # define __attribute_malloc__ /* Ignore */ 228 #endif 229 230 /* At some point during the gcc 2.96 development the `pure' attribute 231 for functions was introduced. We don't want to use it unconditionally 232 (although this would be possible) since it generates warnings. */ 233 #if __GNUC_PREREQ (2,96) 234 # define __attribute_pure__ __attribute__ ((__pure__)) 235 #else 236 # define __attribute_pure__ /* Ignore */ 237 #endif 238 239 /* This declaration tells the compiler that the value is constant. */ 240 #if __GNUC_PREREQ (2,5) 241 # define __attribute_const__ __attribute__ ((__const__)) 242 #else 243 # define __attribute_const__ /* Ignore */ 244 #endif 245 246 /* At some point during the gcc 3.1 development the `used' attribute 247 for functions was introduced. We don't want to use it unconditionally 248 (although this would be possible) since it generates warnings. */ 249 #if __GNUC_PREREQ (3,1) 250 # define __attribute_used__ __attribute__ ((__used__)) 251 # define __attribute_noinline__ __attribute__ ((__noinline__)) 252 #else 253 # define __attribute_used__ __attribute__ ((__unused__)) 254 # define __attribute_noinline__ /* Ignore */ 255 #endif 256 257 /* gcc allows marking deprecated functions. */ 258 #if __GNUC_PREREQ (3,2) 259 # define __attribute_deprecated__ __attribute__ ((__deprecated__)) 260 #else 261 # define __attribute_deprecated__ /* Ignore */ 262 #endif 263 264 /* At some point during the gcc 2.8 development the `format_arg' attribute 265 for functions was introduced. We don't want to use it unconditionally 266 (although this would be possible) since it generates warnings. 267 If several `format_arg' attributes are given for the same function, in 268 gcc-3.0 and older, all but the last one are ignored. In newer gccs, 269 all designated arguments are considered. */ 270 #if __GNUC_PREREQ (2,8) 271 # define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x))) 272 #else 273 # define __attribute_format_arg__(x) /* Ignore */ 274 #endif 275 276 /* At some point during the gcc 2.97 development the `strfmon' format 277 attribute for functions was introduced. We don't want to use it 278 unconditionally (although this would be possible) since it 279 generates warnings. */ 280 #if __GNUC_PREREQ (2,97) 281 # define __attribute_format_strfmon__(a,b) \ 282 __attribute__ ((__format__ (__strfmon__, a, b))) 283 #else 284 # define __attribute_format_strfmon__(a,b) /* Ignore */ 285 #endif 286 287 /* The nonull function attribute allows to mark pointer parameters which 288 must not be NULL. */ 289 #if __GNUC_PREREQ (3,3) 290 # define __nonnull(params) __attribute__ ((__nonnull__ params)) 291 #else 292 # define __nonnull(params) 293 #endif 294 295 /* If fortification mode, we warn about unused results of certain 296 function calls which can lead to problems. */ 297 #if __GNUC_PREREQ (3,4) 298 # define __attribute_warn_unused_result__ \ 299 __attribute__ ((__warn_unused_result__)) 300 # if __USE_FORTIFY_LEVEL > 0 301 # define __wur __attribute_warn_unused_result__ 302 # endif 303 #else 304 # define __attribute_warn_unused_result__ /* empty */ 305 #endif 306 #ifndef __wur 307 # define __wur /* Ignore */ 308 #endif 309 310 /* Forces a function to be always inlined. */ 311 #if __GNUC_PREREQ (3,2) 312 # define __always_inline __inline __attribute__ ((__always_inline__)) 313 #else 314 # define __always_inline __inline 315 #endif 316 317 /* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 318 inline semantics, unless -fgnu89-inline is used. */ 319 #if !defined __cplusplus || __GNUC_PREREQ (4,3) 320 # if defined __GNUC_STDC_INLINE__ || defined __cplusplus 321 # define __extern_inline extern __inline __attribute__ ((__gnu_inline__)) 322 # if __GNUC_PREREQ (4,3) 323 # define __extern_always_inline \ 324 extern __always_inline __attribute__ ((__gnu_inline__, __artificial__)) 325 # else 326 # define __extern_always_inline \ 327 extern __always_inline __attribute__ ((__gnu_inline__)) 328 # endif 329 # else 330 # define __extern_inline extern __inline 331 # if __GNUC_PREREQ (4,3) 332 # define __extern_always_inline \ 333 extern __always_inline __attribute__ ((__artificial__)) 334 # else 335 # define __extern_always_inline extern __always_inline 336 # endif 337 # endif 338 #endif 339 340 /* GCC 4.3 and above allow passing all anonymous arguments of an 341 __extern_always_inline function to some other vararg function. */ 342 #if __GNUC_PREREQ (4,3) 343 # define __va_arg_pack() __builtin_va_arg_pack () 344 # define __va_arg_pack_len() __builtin_va_arg_pack_len () 345 #endif 346 347 /* It is possible to compile containing GCC extensions even if GCC is 348 run in pedantic mode if the uses are carefully marked using the 349 `__extension__' keyword. But this is not generally available before 350 version 2.8. */ 351 #if !__GNUC_PREREQ (2,8) 352 # define __extension__ /* Ignore */ 353 #endif 354 355 /* __restrict is known in EGCS 1.2 and above. */ 356 #if !__GNUC_PREREQ (2,92) 357 # define __restrict /* Ignore */ 358 #endif 359 360 /* ISO C99 also allows to declare arrays as non-overlapping. The syntax is 361 array_name[restrict] 362 GCC 3.1 supports this. */ 363 #if __GNUC_PREREQ (3,1) && !defined __GNUG__ 364 # define __restrict_arr __restrict 365 #else 366 # ifdef __GNUC__ 367 # define __restrict_arr /* Not supported in old GCC. */ 368 # else 369 # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L 370 # define __restrict_arr restrict 371 # else 372 /* Some other non-C99 compiler. */ 373 # define __restrict_arr /* Not supported. */ 374 # endif 375 # endif 376 #endif 377 378 #include <bits/wordsize.h> 379 380 #if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH 381 # define __LDBL_COMPAT 1 382 # ifdef __REDIRECT 383 # define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias) 384 # define __LDBL_REDIR(name, proto) \ 385 __LDBL_REDIR1 (name, proto, __nldbl_##name) 386 # define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias) 387 # define __LDBL_REDIR_NTH(name, proto) \ 388 __LDBL_REDIR1_NTH (name, proto, __nldbl_##name) 389 # define __LDBL_REDIR1_DECL(name, alias) \ 390 extern __typeof (name) name __asm (__ASMNAME (#alias)); 391 # define __LDBL_REDIR_DECL(name) \ 392 extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name)); 393 # define __REDIRECT_LDBL(name, proto, alias) \ 394 __LDBL_REDIR1 (name, proto, __nldbl_##alias) 395 # define __REDIRECT_NTH_LDBL(name, proto, alias) \ 396 __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias) 397 # endif 398 #endif 399 #if !defined __LDBL_COMPAT || !defined __REDIRECT 400 # define __LDBL_REDIR1(name, proto, alias) name proto 401 # define __LDBL_REDIR(name, proto) name proto 402 # define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW 403 # define __LDBL_REDIR_NTH(name, proto) name proto __THROW 404 # define __LDBL_REDIR_DECL(name) 405 # ifdef __REDIRECT 406 # define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias) 407 # define __REDIRECT_NTH_LDBL(name, proto, alias) \ 408 __REDIRECT_NTH (name, proto, alias) 409 # endif 410 #endif 411 412 #endif /* sys/cdefs.h */ 413