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