1 /* Copyright (C) 1989, 1997, 1998, 1999, 2000, 2002, 2004, 2009, 2011 2 Free Software Foundation, Inc. 3 4 This file is part of GCC. 5 6 GCC is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 3, or (at your option) 9 any later version. 10 11 GCC is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 Under Section 7 of GPL version 3, you are granted additional 17 permissions described in the GCC Runtime Library Exception, version 18 3.1, as published by the Free Software Foundation. 19 20 You should have received a copy of the GNU General Public License and 21 a copy of the GCC Runtime Library Exception along with this program; 22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 23 <http://www.gnu.org/licenses/>. */ 24 25 /* 26 * ISO C Standard: 7.17 Common definitions <stddef.h> 27 */ 28 #if (!defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \ 29 && !defined(__STDDEF_H__)) \ 30 || defined(__need_wchar_t) || defined(__need_size_t) \ 31 || defined(__need_ptrdiff_t) || defined(__need_NULL) \ 32 || defined(__need_wint_t) 33 34 /* Any one of these symbols __need_* means that GNU libc 35 wants us just to define one data type. So don't define 36 the symbols that indicate this file's entire job has been done. */ 37 #if (!defined(__need_wchar_t) && !defined(__need_size_t) \ 38 && !defined(__need_ptrdiff_t) && !defined(__need_NULL) \ 39 && !defined(__need_wint_t)) 40 #define _STDDEF_H 41 #define _STDDEF_H_ 42 /* snaroff@next.com says the NeXT needs this. */ 43 #define _ANSI_STDDEF_H 44 /* Irix 5.1 needs this. */ 45 #define __STDDEF_H__ 46 #endif 47 48 #ifndef __sys_stdtypes_h 49 /* This avoids lossage on SunOS but only if stdtypes.h comes first. 50 There's no way to win with the other order! Sun lossage. */ 51 52 /* On 4.3bsd-net2, make sure ansi.h is included, so we have 53 one less case to deal with in the following. */ 54 #if defined (__BSD_NET2__) || defined (____386BSD____) || (defined (__FreeBSD__) && (__FreeBSD__ < 5)) || defined(__NetBSD__) 55 #include <machine/ansi.h> 56 #if !defined(_MACHINE_ANSI_H_) 57 #if defined(_I386_ANSI_H_) || defined(_X86_64_ANSI_H_) 58 #define _MACHINE_ANSI_H_ 59 #endif 60 #endif 61 #endif 62 /* On FreeBSD 5, machine/ansi.h does not exist anymore... */ 63 #if defined (__FreeBSD__) && (__FreeBSD__ >= 5) 64 #include <sys/_types.h> 65 #endif 66 67 #if defined(__DragonFly__) 68 #include <sys/types.h> 69 #endif 70 71 /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are 72 defined if the corresponding type is *not* defined. 73 FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_. 74 NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ */ 75 #if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_) 76 #if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_) 77 #define _SIZE_T 78 #endif 79 #if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_) 80 #define _PTRDIFF_T 81 #endif 82 /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ 83 instead of _WCHAR_T_. */ 84 #if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_) 85 #ifndef _BSD_WCHAR_T_ 86 #define _WCHAR_T 87 #endif 88 #endif 89 /* Undef _FOO_T_ if we are supposed to define foo_t. */ 90 #if defined (__need_ptrdiff_t) || defined (_STDDEF_H_) 91 #undef _PTRDIFF_T_ 92 #undef _BSD_PTRDIFF_T_ 93 #endif 94 #if defined (__need_size_t) || defined (_STDDEF_H_) 95 #undef _SIZE_T_ 96 #undef _BSD_SIZE_T_ 97 #endif 98 #if defined (__need_wchar_t) || defined (_STDDEF_H_) 99 #undef _WCHAR_T_ 100 #undef _BSD_WCHAR_T_ 101 #endif 102 #endif /* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_) */ 103 104 /* Sequent's header files use _PTRDIFF_T_ in some conflicting way. 105 Just ignore it. */ 106 #if defined (__sequent__) && defined (_PTRDIFF_T_) 107 #undef _PTRDIFF_T_ 108 #endif 109 110 /* On VxWorks, <type/vxTypesBase.h> may have defined macros like 111 _TYPE_size_t which will typedef size_t. fixincludes patched the 112 vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is 113 not defined, and so that defining this macro defines _GCC_SIZE_T. 114 If we find that the macros are still defined at this point, we must 115 invoke them so that the type is defined as expected. */ 116 #if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_)) 117 _TYPE_ptrdiff_t; 118 #undef _TYPE_ptrdiff_t 119 #endif 120 #if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_)) 121 _TYPE_size_t; 122 #undef _TYPE_size_t 123 #endif 124 #if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_)) 125 _TYPE_wchar_t; 126 #undef _TYPE_wchar_t 127 #endif 128 129 /* In case nobody has defined these types, but we aren't running under 130 GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and 131 __WCHAR_TYPE__ have reasonable values. This can happen if the 132 parts of GCC is compiled by an older compiler, that actually 133 include gstddef.h, such as collect2. */ 134 135 /* Signed type of difference of two pointers. */ 136 137 /* Define this type if we are doing the whole job, 138 or if we want this type in particular. */ 139 #if defined (_STDDEF_H) || defined (__need_ptrdiff_t) 140 #ifndef _PTRDIFF_T /* in case <sys/types.h> has defined it. */ 141 #ifndef _T_PTRDIFF_ 142 #ifndef _T_PTRDIFF 143 #ifndef __PTRDIFF_T 144 #ifndef _PTRDIFF_T_ 145 #ifndef _BSD_PTRDIFF_T_ 146 #ifndef ___int_ptrdiff_t_h 147 #ifndef _GCC_PTRDIFF_T 148 #ifndef _PTRDIFF_T_DECLARED /* DragonFly */ 149 #define _PTRDIFF_T 150 #define _T_PTRDIFF_ 151 #define _T_PTRDIFF 152 #define __PTRDIFF_T 153 #define _PTRDIFF_T_ 154 #define _BSD_PTRDIFF_T_ 155 #define ___int_ptrdiff_t_h 156 #define _GCC_PTRDIFF_T 157 #define _PTRDIFF_T_DECLARED 158 #ifndef __PTRDIFF_TYPE__ 159 #define __PTRDIFF_TYPE__ long int 160 #endif 161 typedef __PTRDIFF_TYPE__ ptrdiff_t; 162 #endif /* _PTRDIFF_T_DECLARED */ 163 #endif /* _GCC_PTRDIFF_T */ 164 #endif /* ___int_ptrdiff_t_h */ 165 #endif /* _BSD_PTRDIFF_T_ */ 166 #endif /* _PTRDIFF_T_ */ 167 #endif /* __PTRDIFF_T */ 168 #endif /* _T_PTRDIFF */ 169 #endif /* _T_PTRDIFF_ */ 170 #endif /* _PTRDIFF_T */ 171 172 /* If this symbol has done its job, get rid of it. */ 173 #undef __need_ptrdiff_t 174 175 #endif /* _STDDEF_H or __need_ptrdiff_t. */ 176 177 /* Unsigned type of `sizeof' something. */ 178 179 /* Define this type if we are doing the whole job, 180 or if we want this type in particular. */ 181 #if defined (_STDDEF_H) || defined (__need_size_t) 182 #ifndef __size_t__ /* BeOS */ 183 #ifndef __SIZE_T__ /* Cray Unicos/Mk */ 184 #ifndef _SIZE_T /* in case <sys/types.h> has defined it. */ 185 #ifndef _SYS_SIZE_T_H 186 #ifndef _T_SIZE_ 187 #ifndef _T_SIZE 188 #ifndef __SIZE_T 189 #ifndef _SIZE_T_ 190 #ifndef _BSD_SIZE_T_ 191 #ifndef _SIZE_T_DEFINED_ 192 #ifndef _SIZE_T_DEFINED 193 #ifndef _BSD_SIZE_T_DEFINED_ /* Darwin */ 194 #ifndef _SIZE_T_DECLARED /* FreeBSD 5 */ 195 #ifndef ___int_size_t_h 196 #ifndef _GCC_SIZE_T 197 #ifndef _SIZET_ 198 #ifndef __size_t 199 #define __size_t__ /* BeOS */ 200 #define __SIZE_T__ /* Cray Unicos/Mk */ 201 #define _SIZE_T 202 #define _SYS_SIZE_T_H 203 #define _T_SIZE_ 204 #define _T_SIZE 205 #define __SIZE_T 206 #define _SIZE_T_ 207 #define _BSD_SIZE_T_ 208 #define _SIZE_T_DEFINED_ 209 #define _SIZE_T_DEFINED 210 #define _BSD_SIZE_T_DEFINED_ /* Darwin */ 211 #define _SIZE_T_DECLARED /* FreeBSD 5 */ 212 #define ___int_size_t_h 213 #define _GCC_SIZE_T 214 #define _SIZET_ 215 #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \ 216 || defined(__DragonFly__) \ 217 || defined(__FreeBSD_kernel__) 218 /* __size_t is a typedef on FreeBSD 5, must not trash it. */ 219 #else 220 #define __size_t 221 #endif 222 #ifndef __SIZE_TYPE__ 223 #define __SIZE_TYPE__ long unsigned int 224 #endif 225 #if !(defined (__GNUG__) && defined (size_t)) 226 typedef __SIZE_TYPE__ size_t; 227 #ifdef __BEOS__ 228 typedef long ssize_t; 229 #endif /* __BEOS__ */ 230 #endif /* !(defined (__GNUG__) && defined (size_t)) */ 231 #endif /* __size_t */ 232 #endif /* _SIZET_ */ 233 #endif /* _GCC_SIZE_T */ 234 #endif /* ___int_size_t_h */ 235 #endif /* _SIZE_T_DECLARED */ 236 #endif /* _BSD_SIZE_T_DEFINED_ */ 237 #endif /* _SIZE_T_DEFINED */ 238 #endif /* _SIZE_T_DEFINED_ */ 239 #endif /* _BSD_SIZE_T_ */ 240 #endif /* _SIZE_T_ */ 241 #endif /* __SIZE_T */ 242 #endif /* _T_SIZE */ 243 #endif /* _T_SIZE_ */ 244 #endif /* _SYS_SIZE_T_H */ 245 #endif /* _SIZE_T */ 246 #endif /* __SIZE_T__ */ 247 #endif /* __size_t__ */ 248 #undef __need_size_t 249 #endif /* _STDDEF_H or __need_size_t. */ 250 251 252 /* Wide character type. 253 Locale-writers should change this as necessary to 254 be big enough to hold unique values not between 0 and 127, 255 and not (wchar_t) -1, for each defined multibyte character. */ 256 257 /* Define this type if we are doing the whole job, 258 or if we want this type in particular. */ 259 #if defined (_STDDEF_H) || defined (__need_wchar_t) 260 #ifndef __wchar_t__ /* BeOS */ 261 #ifndef __WCHAR_T__ /* Cray Unicos/Mk */ 262 #ifndef _WCHAR_T 263 #ifndef _T_WCHAR_ 264 #ifndef _T_WCHAR 265 #ifndef __WCHAR_T 266 #ifndef _WCHAR_T_ 267 #ifndef _BSD_WCHAR_T_ 268 #ifndef _BSD_WCHAR_T_DEFINED_ /* Darwin */ 269 #ifndef _BSD_RUNE_T_DEFINED_ /* Darwin */ 270 #ifndef _WCHAR_T_DECLARED /* FreeBSD 5 */ 271 #ifndef _WCHAR_T_DEFINED_ 272 #ifndef _WCHAR_T_DEFINED 273 #ifndef _WCHAR_T_H 274 #ifndef ___int_wchar_t_h 275 #ifndef __INT_WCHAR_T_H 276 #ifndef _GCC_WCHAR_T 277 #define __wchar_t__ /* BeOS */ 278 #define __WCHAR_T__ /* Cray Unicos/Mk */ 279 #define _WCHAR_T 280 #define _T_WCHAR_ 281 #define _T_WCHAR 282 #define __WCHAR_T 283 #define _WCHAR_T_ 284 #define _BSD_WCHAR_T_ 285 #define _WCHAR_T_DEFINED_ 286 #define _WCHAR_T_DEFINED 287 #define _WCHAR_T_H 288 #define ___int_wchar_t_h 289 #define __INT_WCHAR_T_H 290 #define _GCC_WCHAR_T 291 #define _WCHAR_T_DECLARED 292 293 /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ 294 instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other 295 symbols in the _FOO_T_ family, stays defined even after its 296 corresponding type is defined). If we define wchar_t, then we 297 must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if 298 we undef _WCHAR_T_, then we must also define rune_t, since 299 headers like runetype.h assume that if machine/ansi.h is included, 300 and _BSD_WCHAR_T_ is not defined, then rune_t is available. 301 machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of 302 the same type." */ 303 #ifdef _BSD_WCHAR_T_ 304 #undef _BSD_WCHAR_T_ 305 #ifdef _BSD_RUNE_T_ 306 #if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE) 307 typedef _BSD_RUNE_T_ rune_t; 308 #define _BSD_WCHAR_T_DEFINED_ 309 #define _BSD_RUNE_T_DEFINED_ /* Darwin */ 310 #if defined (__FreeBSD__) && (__FreeBSD__ < 5) 311 /* Why is this file so hard to maintain properly? In contrast to 312 the comment above regarding BSD/386 1.1, on FreeBSD for as long 313 as the symbol has existed, _BSD_RUNE_T_ must not stay defined or 314 redundant typedefs will occur when stdlib.h is included after this file. */ 315 #undef _BSD_RUNE_T_ 316 #endif 317 #endif 318 #endif 319 #endif 320 /* FreeBSD 5 can't be handled well using "traditional" logic above 321 since it no longer defines _BSD_RUNE_T_ yet still desires to export 322 rune_t in some cases... */ 323 #if defined (__DragonFly__) || (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) 324 #if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE) 325 #if __BSD_VISIBLE 326 #ifndef _RUNE_T_DECLARED 327 typedef __rune_t rune_t; 328 #define _RUNE_T_DECLARED 329 #endif 330 #endif 331 #endif 332 #endif 333 334 #ifndef __WCHAR_TYPE__ 335 #define __WCHAR_TYPE__ int 336 #endif 337 #ifndef __cplusplus 338 typedef __WCHAR_TYPE__ wchar_t; 339 #endif 340 #endif 341 #endif 342 #endif 343 #endif 344 #endif 345 #endif 346 #endif /* _WCHAR_T_DECLARED */ 347 #endif /* _BSD_RUNE_T_DEFINED_ */ 348 #endif 349 #endif 350 #endif 351 #endif 352 #endif 353 #endif 354 #endif 355 #endif /* __WCHAR_T__ */ 356 #endif /* __wchar_t__ */ 357 #undef __need_wchar_t 358 #endif /* _STDDEF_H or __need_wchar_t. */ 359 360 #if defined (__need_wint_t) 361 #ifndef _WINT_T 362 #define _WINT_T 363 364 #ifndef __WINT_TYPE__ 365 #define __WINT_TYPE__ unsigned int 366 #endif 367 typedef __WINT_TYPE__ wint_t; 368 #endif 369 #undef __need_wint_t 370 #endif 371 372 /* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. 373 are already defined. */ 374 /* BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. */ 375 /* NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. */ 376 #if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_) 377 /* The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_ 378 are probably typos and should be removed before 2.8 is released. */ 379 #ifdef _GCC_PTRDIFF_T_ 380 #undef _PTRDIFF_T_ 381 #undef _BSD_PTRDIFF_T_ 382 #endif 383 #ifdef _GCC_SIZE_T_ 384 #undef _SIZE_T_ 385 #undef _BSD_SIZE_T_ 386 #endif 387 #ifdef _GCC_WCHAR_T_ 388 #undef _WCHAR_T_ 389 #undef _BSD_WCHAR_T_ 390 #endif 391 /* The following ones are the real ones. */ 392 #ifdef _GCC_PTRDIFF_T 393 #undef _PTRDIFF_T_ 394 #undef _BSD_PTRDIFF_T_ 395 #endif 396 #ifdef _GCC_SIZE_T 397 #undef _SIZE_T_ 398 #undef _BSD_SIZE_T_ 399 #endif 400 #ifdef _GCC_WCHAR_T 401 #undef _WCHAR_T_ 402 #undef _BSD_WCHAR_T_ 403 #endif 404 #endif /* _ANSI_H_ || _MACHINE_ANSI_H_ || _X86_64_ANSI_H_ || _I386_ANSI_H_ */ 405 406 #endif /* __sys_stdtypes_h */ 407 408 /* A null pointer constant. */ 409 410 #if defined (_STDDEF_H) || defined (__need_NULL) 411 #undef NULL /* in case <stdio.h> has defined it. */ 412 #ifdef __GNUG__ 413 #define NULL __null 414 #else /* G++ */ 415 #ifndef __cplusplus 416 #define NULL ((void *)0) 417 #else /* C++ */ 418 #define NULL 0 419 #endif /* C++ */ 420 #endif /* G++ */ 421 #endif /* NULL not defined and <stddef.h> or need NULL. */ 422 #undef __need_NULL 423 424 #ifdef _STDDEF_H 425 426 /* Offset of member MEMBER in a struct of type TYPE. */ 427 #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) 428 429 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) \ 430 || (defined(__cplusplus) && __cplusplus >= 201103L) 431 #ifndef _GCC_MAX_ALIGN_T 432 #define _GCC_MAX_ALIGN_T 433 /* Type whose alignment is supported in every context and is at least 434 as great as that of any standard type not using alignment 435 specifiers. */ 436 typedef struct { 437 long long __max_align_ll __attribute__((__aligned__(__alignof__(long long)))); 438 long double __max_align_ld __attribute__((__aligned__(__alignof__(long double)))); 439 } max_align_t; 440 #endif 441 #endif /* C11 or C++11. */ 442 443 #endif /* _STDDEF_H was defined this time */ 444 445 #endif /* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__ 446 || __need_XXX was not defined before */ 447