Home | History | Annotate | Download | only in include
      1 /* Copyright (C) 1989, 1997, 1998, 1999, 2000, 2002, 2004, 2009
      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 (at) 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 #endif
     57 /* On FreeBSD 5, machine/ansi.h does not exist anymore... */
     58 #if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
     59 #include <sys/_types.h>
     60 #endif
     61 
     62 /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are
     63    defined if the corresponding type is *not* defined.
     64    FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_.
     65    NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ */
     66 #if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_)  || defined(_I386_ANSI_H_)
     67 #if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_)
     68 #define _SIZE_T
     69 #endif
     70 #if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_)
     71 #define _PTRDIFF_T
     72 #endif
     73 /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
     74    instead of _WCHAR_T_. */
     75 #if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_)
     76 #ifndef _BSD_WCHAR_T_
     77 #define _WCHAR_T
     78 #endif
     79 #endif
     80 /* Undef _FOO_T_ if we are supposed to define foo_t.  */
     81 #if defined (__need_ptrdiff_t) || defined (_STDDEF_H_)
     82 #undef _PTRDIFF_T_
     83 #undef _BSD_PTRDIFF_T_
     84 #endif
     85 #if defined (__need_size_t) || defined (_STDDEF_H_)
     86 #undef _SIZE_T_
     87 #undef _BSD_SIZE_T_
     88 #endif
     89 #if defined (__need_wchar_t) || defined (_STDDEF_H_)
     90 #undef _WCHAR_T_
     91 #undef _BSD_WCHAR_T_
     92 #endif
     93 #endif /* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_) */
     94 
     95 /* Sequent's header files use _PTRDIFF_T_ in some conflicting way.
     96    Just ignore it.  */
     97 #if defined (__sequent__) && defined (_PTRDIFF_T_)
     98 #undef _PTRDIFF_T_
     99 #endif
    100 
    101 /* On VxWorks, <type/vxTypesBase.h> may have defined macros like
    102    _TYPE_size_t which will typedef size_t.  fixincludes patched the
    103    vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is
    104    not defined, and so that defining this macro defines _GCC_SIZE_T.
    105    If we find that the macros are still defined at this point, we must
    106    invoke them so that the type is defined as expected.  */
    107 #if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_))
    108 _TYPE_ptrdiff_t;
    109 #undef _TYPE_ptrdiff_t
    110 #endif
    111 #if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_))
    112 _TYPE_size_t;
    113 #undef _TYPE_size_t
    114 #endif
    115 #if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_))
    116 _TYPE_wchar_t;
    117 #undef _TYPE_wchar_t
    118 #endif
    119 
    120 /* In case nobody has defined these types, but we aren't running under
    121    GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and
    122    __WCHAR_TYPE__ have reasonable values.  This can happen if the
    123    parts of GCC is compiled by an older compiler, that actually
    124    include gstddef.h, such as collect2.  */
    125 
    126 /* Signed type of difference of two pointers.  */
    127 
    128 /* Define this type if we are doing the whole job,
    129    or if we want this type in particular.  */
    130 #if defined (_STDDEF_H) || defined (__need_ptrdiff_t)
    131 #ifndef _PTRDIFF_T	/* in case <sys/types.h> has defined it. */
    132 #ifndef _T_PTRDIFF_
    133 #ifndef _T_PTRDIFF
    134 #ifndef __PTRDIFF_T
    135 #ifndef _PTRDIFF_T_
    136 #ifndef _BSD_PTRDIFF_T_
    137 #ifndef ___int_ptrdiff_t_h
    138 #ifndef _GCC_PTRDIFF_T
    139 #define _PTRDIFF_T
    140 #define _T_PTRDIFF_
    141 #define _T_PTRDIFF
    142 #define __PTRDIFF_T
    143 #define _PTRDIFF_T_
    144 #define _BSD_PTRDIFF_T_
    145 #define ___int_ptrdiff_t_h
    146 #define _GCC_PTRDIFF_T
    147 #ifndef __PTRDIFF_TYPE__
    148 #define __PTRDIFF_TYPE__ long int
    149 #endif
    150 typedef __PTRDIFF_TYPE__ ptrdiff_t;
    151 #endif /* _GCC_PTRDIFF_T */
    152 #endif /* ___int_ptrdiff_t_h */
    153 #endif /* _BSD_PTRDIFF_T_ */
    154 #endif /* _PTRDIFF_T_ */
    155 #endif /* __PTRDIFF_T */
    156 #endif /* _T_PTRDIFF */
    157 #endif /* _T_PTRDIFF_ */
    158 #endif /* _PTRDIFF_T */
    159 
    160 /* If this symbol has done its job, get rid of it.  */
    161 #undef	__need_ptrdiff_t
    162 
    163 #endif /* _STDDEF_H or __need_ptrdiff_t.  */
    164 
    165 /* Unsigned type of `sizeof' something.  */
    166 
    167 /* Define this type if we are doing the whole job,
    168    or if we want this type in particular.  */
    169 #if defined (_STDDEF_H) || defined (__need_size_t)
    170 #ifndef __size_t__	/* BeOS */
    171 #ifndef __SIZE_T__	/* Cray Unicos/Mk */
    172 #ifndef _SIZE_T	/* in case <sys/types.h> has defined it. */
    173 #ifndef _SYS_SIZE_T_H
    174 #ifndef _T_SIZE_
    175 #ifndef _T_SIZE
    176 #ifndef __SIZE_T
    177 #ifndef _SIZE_T_
    178 #ifndef _BSD_SIZE_T_
    179 #ifndef _SIZE_T_DEFINED_
    180 #ifndef _SIZE_T_DEFINED
    181 #ifndef _BSD_SIZE_T_DEFINED_	/* Darwin */
    182 #ifndef _SIZE_T_DECLARED	/* FreeBSD 5 */
    183 #ifndef ___int_size_t_h
    184 #ifndef _GCC_SIZE_T
    185 #ifndef _SIZET_
    186 #ifndef __size_t
    187 #define __size_t__	/* BeOS */
    188 #define __SIZE_T__	/* Cray Unicos/Mk */
    189 #define _SIZE_T
    190 #define _SYS_SIZE_T_H
    191 #define _T_SIZE_
    192 #define _T_SIZE
    193 #define __SIZE_T
    194 #define _SIZE_T_
    195 #define _BSD_SIZE_T_
    196 #define _SIZE_T_DEFINED_
    197 #define _SIZE_T_DEFINED
    198 #define _BSD_SIZE_T_DEFINED_	/* Darwin */
    199 #define _SIZE_T_DECLARED	/* FreeBSD 5 */
    200 #define ___int_size_t_h
    201 #define _GCC_SIZE_T
    202 #define _SIZET_
    203 #if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
    204 /* __size_t is a typedef on FreeBSD 5!, must not trash it. */
    205 #else
    206 #define __size_t
    207 #endif
    208 #ifndef __SIZE_TYPE__
    209 #define __SIZE_TYPE__ long unsigned int
    210 #endif
    211 #if !(defined (__GNUG__) && defined (size_t))
    212 typedef __SIZE_TYPE__ size_t;
    213 #ifdef __BEOS__
    214 typedef long ssize_t;
    215 #endif /* __BEOS__ */
    216 #endif /* !(defined (__GNUG__) && defined (size_t)) */
    217 #endif /* __size_t */
    218 #endif /* _SIZET_ */
    219 #endif /* _GCC_SIZE_T */
    220 #endif /* ___int_size_t_h */
    221 #endif /* _SIZE_T_DECLARED */
    222 #endif /* _BSD_SIZE_T_DEFINED_ */
    223 #endif /* _SIZE_T_DEFINED */
    224 #endif /* _SIZE_T_DEFINED_ */
    225 #endif /* _BSD_SIZE_T_ */
    226 #endif /* _SIZE_T_ */
    227 #endif /* __SIZE_T */
    228 #endif /* _T_SIZE */
    229 #endif /* _T_SIZE_ */
    230 #endif /* _SYS_SIZE_T_H */
    231 #endif /* _SIZE_T */
    232 #endif /* __SIZE_T__ */
    233 #endif /* __size_t__ */
    234 #undef	__need_size_t
    235 #endif /* _STDDEF_H or __need_size_t.  */
    236 
    237 
    238 /* Wide character type.
    239    Locale-writers should change this as necessary to
    240    be big enough to hold unique values not between 0 and 127,
    241    and not (wchar_t) -1, for each defined multibyte character.  */
    242 
    243 /* Define this type if we are doing the whole job,
    244    or if we want this type in particular.  */
    245 #if defined (_STDDEF_H) || defined (__need_wchar_t)
    246 #ifndef __wchar_t__	/* BeOS */
    247 #ifndef __WCHAR_T__	/* Cray Unicos/Mk */
    248 #ifndef _WCHAR_T
    249 #ifndef _T_WCHAR_
    250 #ifndef _T_WCHAR
    251 #ifndef __WCHAR_T
    252 #ifndef _WCHAR_T_
    253 #ifndef _BSD_WCHAR_T_
    254 #ifndef _BSD_WCHAR_T_DEFINED_    /* Darwin */
    255 #ifndef _BSD_RUNE_T_DEFINED_	/* Darwin */
    256 #ifndef _WCHAR_T_DECLARED /* FreeBSD 5 */
    257 #ifndef _WCHAR_T_DEFINED_
    258 #ifndef _WCHAR_T_DEFINED
    259 #ifndef _WCHAR_T_H
    260 #ifndef ___int_wchar_t_h
    261 #ifndef __INT_WCHAR_T_H
    262 #ifndef _GCC_WCHAR_T
    263 #define __wchar_t__	/* BeOS */
    264 #define __WCHAR_T__	/* Cray Unicos/Mk */
    265 #define _WCHAR_T
    266 #define _T_WCHAR_
    267 #define _T_WCHAR
    268 #define __WCHAR_T
    269 #define _WCHAR_T_
    270 #define _BSD_WCHAR_T_
    271 #define _WCHAR_T_DEFINED_
    272 #define _WCHAR_T_DEFINED
    273 #define _WCHAR_T_H
    274 #define ___int_wchar_t_h
    275 #define __INT_WCHAR_T_H
    276 #define _GCC_WCHAR_T
    277 #define _WCHAR_T_DECLARED
    278 
    279 /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
    280    instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other
    281    symbols in the _FOO_T_ family, stays defined even after its
    282    corresponding type is defined).  If we define wchar_t, then we
    283    must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if
    284    we undef _WCHAR_T_, then we must also define rune_t, since
    285    headers like runetype.h assume that if machine/ansi.h is included,
    286    and _BSD_WCHAR_T_ is not defined, then rune_t is available.
    287    machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of
    288    the same type." */
    289 #ifdef _BSD_WCHAR_T_
    290 #undef _BSD_WCHAR_T_
    291 #ifdef _BSD_RUNE_T_
    292 #if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
    293 typedef _BSD_RUNE_T_ rune_t;
    294 #define _BSD_WCHAR_T_DEFINED_
    295 #define _BSD_RUNE_T_DEFINED_	/* Darwin */
    296 #if defined (__FreeBSD__) && (__FreeBSD__ < 5)
    297 /* Why is this file so hard to maintain properly?  In contrast to
    298    the comment above regarding BSD/386 1.1, on FreeBSD for as long
    299    as the symbol has existed, _BSD_RUNE_T_ must not stay defined or
    300    redundant typedefs will occur when stdlib.h is included after this file. */
    301 #undef _BSD_RUNE_T_
    302 #endif
    303 #endif
    304 #endif
    305 #endif
    306 /* FreeBSD 5 can't be handled well using "traditional" logic above
    307    since it no longer defines _BSD_RUNE_T_ yet still desires to export
    308    rune_t in some cases... */
    309 #if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
    310 #if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
    311 #if __BSD_VISIBLE
    312 #ifndef _RUNE_T_DECLARED
    313 typedef __rune_t        rune_t;
    314 #define _RUNE_T_DECLARED
    315 #endif
    316 #endif
    317 #endif
    318 #endif
    319 
    320 #ifndef __WCHAR_TYPE__
    321 #define __WCHAR_TYPE__ int
    322 #endif
    323 #ifndef __cplusplus
    324 typedef __WCHAR_TYPE__ wchar_t;
    325 #endif
    326 #endif
    327 #endif
    328 #endif
    329 #endif
    330 #endif
    331 #endif
    332 #endif /* _WCHAR_T_DECLARED */
    333 #endif /* _BSD_RUNE_T_DEFINED_ */
    334 #endif
    335 #endif
    336 #endif
    337 #endif
    338 #endif
    339 #endif
    340 #endif
    341 #endif /* __WCHAR_T__ */
    342 #endif /* __wchar_t__ */
    343 #undef	__need_wchar_t
    344 #endif /* _STDDEF_H or __need_wchar_t.  */
    345 
    346 #if defined (__need_wint_t)
    347 #ifndef _WINT_T
    348 #define _WINT_T
    349 
    350 #ifndef __WINT_TYPE__
    351 #define __WINT_TYPE__ unsigned int
    352 #endif
    353 typedef __WINT_TYPE__ wint_t;
    354 #endif
    355 #undef __need_wint_t
    356 #endif
    357 
    358 /*  In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
    359     are already defined.  */
    360 /*  BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here.  */
    361 /*  NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here.  */
    362 #if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_)
    363 /*  The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_
    364     are probably typos and should be removed before 2.8 is released.  */
    365 #ifdef _GCC_PTRDIFF_T_
    366 #undef _PTRDIFF_T_
    367 #undef _BSD_PTRDIFF_T_
    368 #endif
    369 #ifdef _GCC_SIZE_T_
    370 #undef _SIZE_T_
    371 #undef _BSD_SIZE_T_
    372 #endif
    373 #ifdef _GCC_WCHAR_T_
    374 #undef _WCHAR_T_
    375 #undef _BSD_WCHAR_T_
    376 #endif
    377 /*  The following ones are the real ones.  */
    378 #ifdef _GCC_PTRDIFF_T
    379 #undef _PTRDIFF_T_
    380 #undef _BSD_PTRDIFF_T_
    381 #endif
    382 #ifdef _GCC_SIZE_T
    383 #undef _SIZE_T_
    384 #undef _BSD_SIZE_T_
    385 #endif
    386 #ifdef _GCC_WCHAR_T
    387 #undef _WCHAR_T_
    388 #undef _BSD_WCHAR_T_
    389 #endif
    390 #endif /* _ANSI_H_ || _MACHINE_ANSI_H_ || _X86_64_ANSI_H_ || _I386_ANSI_H_ */
    391 
    392 #endif /* __sys_stdtypes_h */
    393 
    394 /* A null pointer constant.  */
    395 
    396 #if defined (_STDDEF_H) || defined (__need_NULL)
    397 #undef NULL		/* in case <stdio.h> has defined it. */
    398 #ifdef __GNUG__
    399 #define NULL __null
    400 #else   /* G++ */
    401 #ifndef __cplusplus
    402 #define NULL ((void *)0)
    403 #else   /* C++ */
    404 #define NULL 0
    405 #endif  /* C++ */
    406 #endif  /* G++ */
    407 #endif	/* NULL not defined and <stddef.h> or need NULL.  */
    408 #undef	__need_NULL
    409 
    410 #ifdef _STDDEF_H
    411 
    412 /* Offset of member MEMBER in a struct of type TYPE. */
    413 #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
    414 
    415 #endif /* _STDDEF_H was defined this time */
    416 
    417 #endif /* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__
    418 	  || __need_XXX was not defined before */
    419