1 /* $FreeBSD: src/contrib/gcc/ginclude/stddef.h,v 1.3 1999/10/13 15:55:31 obrien Exp $ */
2 /* $DragonFly: src/contrib/gcc/ginclude/Attic/stddef.h,v 1.2 2003/06/17 04:24:02 dillon Exp $ */
4 #if (!defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \
5 && !defined(__STDDEF_H__)) \
6 || defined(__need_wchar_t) || defined(__need_size_t) \
7 || defined(__need_ptrdiff_t) || defined(__need_NULL) \
8 || defined(__need_wint_t)
10 /* Any one of these symbols __need_* means that GNU libc
11 wants us just to define one data type. So don't define
12 the symbols that indicate this file's entire job has been done. */
13 #if (!defined(__need_wchar_t) && !defined(__need_size_t) \
14 && !defined(__need_ptrdiff_t) && !defined(__need_NULL) \
15 && !defined(__need_wint_t))
18 /* snaroff@next.com says the NeXT needs this. */
19 #define _ANSI_STDDEF_H
20 /* Irix 5.1 needs this. */
24 #ifndef __sys_stdtypes_h
25 /* This avoids lossage on SunOS but only if stdtypes.h comes first.
26 There's no way to win with the other order! Sun lossage. */
28 /* On 4.3bsd-net2, make sure ansi.h is included, so we have
29 one less case to deal with in the following. */
30 #if defined (__BSD_NET2__) || defined (____386BSD____) || defined (__FreeBSD__) || defined(__NetBSD__)
31 #include <machine/ansi.h>
34 /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are
35 defined if the corresponding type is *not* defined.
36 FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_ */
37 #if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_)
38 #if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_)
41 #if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_)
44 /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
45 instead of _WCHAR_T_. */
46 #if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_)
51 /* Undef _FOO_T_ if we are supposed to define foo_t. */
52 #if defined (__need_ptrdiff_t) || defined (_STDDEF_H_)
54 #undef _BSD_PTRDIFF_T_
56 #if defined (__need_size_t) || defined (_STDDEF_H_)
60 #if defined (__need_wchar_t) || defined (_STDDEF_H_)
64 #endif /* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) */
66 /* Sequent's header files use _PTRDIFF_T_ in some conflicting way.
68 #if defined (__sequent__) && defined (_PTRDIFF_T_)
72 /* On VxWorks, <type/vxTypesBase.h> may have defined macros like
73 _TYPE_size_t which will typedef size_t. fixincludes patched the
74 vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is
75 not defined, and so that defining this macro defines _GCC_SIZE_T.
76 If we find that the macros are still defined at this point, we must
77 invoke them so that the type is defined as expected. */
78 #if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_))
80 #undef _TYPE_ptrdiff_t
82 #if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_))
86 #if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_))
91 /* In case nobody has defined these types, but we aren't running under
92 GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE__TYPE__, and
93 __WCHAR_TYPE__ have reasonable values. This can happen if the
94 parts of GCC is compiled by an older compiler, that actually
95 include gstddef.h, such as collect2. */
97 /* Signed type of difference of two pointers. */
99 /* Define this type if we are doing the whole job,
100 or if we want this type in particular. */
101 #if defined (_STDDEF_H) || defined (__need_ptrdiff_t)
102 #ifndef _PTRDIFF_T /* in case <sys/types.h> has defined it. */
107 #ifndef _BSD_PTRDIFF_T_
108 #ifndef ___int_ptrdiff_t_h
109 #ifndef _GCC_PTRDIFF_T
115 #define _BSD_PTRDIFF_T_
116 #define ___int_ptrdiff_t_h
117 #define _GCC_PTRDIFF_T
118 #ifndef __PTRDIFF_TYPE__
119 #define __PTRDIFF_TYPE__ long int
121 typedef __PTRDIFF_TYPE__ ptrdiff_t;
122 #endif /* _GCC_PTRDIFF_T */
123 #endif /* ___int_ptrdiff_t_h */
124 #endif /* _BSD_PTRDIFF_T_ */
125 #endif /* _PTRDIFF_T_ */
126 #endif /* __PTRDIFF_T */
127 #endif /* _T_PTRDIFF */
128 #endif /* _T_PTRDIFF_ */
129 #endif /* _PTRDIFF_T */
131 /* If this symbol has done its job, get rid of it. */
132 #undef __need_ptrdiff_t
134 #endif /* _STDDEF_H or __need_ptrdiff_t. */
136 /* Unsigned type of `sizeof' something. */
138 /* Define this type if we are doing the whole job,
139 or if we want this type in particular. */
140 #if defined (_STDDEF_H) || defined (__need_size_t)
141 #ifndef __size_t__ /* BeOS */
142 #ifndef _SIZE_T /* in case <sys/types.h> has defined it. */
143 #ifndef _SYS_SIZE_T_H
149 #ifndef _SIZE_T_DEFINED_
150 #ifndef _SIZE_T_DEFINED
151 #ifndef ___int_size_t_h
155 #define __size_t__ /* BeOS */
157 #define _SYS_SIZE_T_H
163 #define _SIZE_T_DEFINED_
164 #define _SIZE_T_DEFINED
165 #define ___int_size_t_h
169 #ifndef __SIZE_TYPE__
170 #define __SIZE_TYPE__ long unsigned int
172 #if !(defined (__GNUG__) && defined (size_t))
173 typedef __SIZE_TYPE__ size_t;
175 typedef long ssize_t;
176 #endif /* __BEOS__ */
177 #endif /* !(defined (__GNUG__) && defined (size_t)) */
178 #endif /* __size_t */
180 #endif /* _GCC_SIZE_T */
181 #endif /* ___int_size_t_h */
182 #endif /* _SIZE_T_DEFINED */
183 #endif /* _SIZE_T_DEFINED_ */
184 #endif /* _BSD_SIZE_T_ */
185 #endif /* _SIZE_T_ */
186 #endif /* __SIZE_T */
188 #endif /* _T_SIZE_ */
189 #endif /* _SYS_SIZE_T_H */
191 #endif /* __size_t__ */
193 #endif /* _STDDEF_H or __need_size_t. */
196 /* Wide character type.
197 Locale-writers should change this as necessary to
198 be big enough to hold unique values not between 0 and 127,
199 and not (wchar_t) -1, for each defined multibyte character. */
201 /* Define this type if we are doing the whole job,
202 or if we want this type in particular. */
203 #if defined (_STDDEF_H) || defined (__need_wchar_t)
204 #ifndef __wchar_t__ /* BeOS */
210 #ifndef _BSD_WCHAR_T_
211 #ifndef _WCHAR_T_DEFINED_
212 #ifndef _WCHAR_T_DEFINED
214 #ifndef ___int_wchar_t_h
215 #ifndef __INT_WCHAR_T_H
217 #define __wchar_t__ /* BeOS */
223 #define _BSD_WCHAR_T_
224 #define _WCHAR_T_DEFINED_
225 #define _WCHAR_T_DEFINED
227 #define ___int_wchar_t_h
228 #define __INT_WCHAR_T_H
231 /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
232 instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other
233 symbols in the _FOO_T_ family, stays defined even after its
234 corresponding type is defined). If we define wchar_t, then we
235 must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if
236 we undef _WCHAR_T_, then we must also define rune_t, since
237 headers like runetype.h assume that if machine/ansi.h is included,
238 and _BSD_WCHAR_T_ is not defined, then rune_t is available.
239 machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of
244 #if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
245 typedef _BSD_RUNE_T_ rune_t;
250 #ifndef __WCHAR_TYPE__
252 #define __WCHAR_TYPE__ unsigned char
254 #define __WCHAR_TYPE__ int
258 typedef __WCHAR_TYPE__ wchar_t;
272 #endif /* __wchar_t__ */
273 #undef __need_wchar_t
274 #endif /* _STDDEF_H or __need_wchar_t. */
276 #if defined (_STDDEF_H) || defined (__need_wint_t)
280 #ifndef __WINT_TYPE__
281 #define __WINT_TYPE__ unsigned int
283 typedef __WINT_TYPE__ wint_t;
288 /* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
289 are already defined. */
290 /* BSD/OS 3.1 requires the MACHINE_ANSI_H check here. FreeBSD 2.x apparently
291 does not, even though there is a check for MACHINE_ANSI_H above. */
292 #if defined(_ANSI_H_) || (defined(__bsdi__) && defined(_MACHINE_ANSI_H_))
293 /* The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_
294 are probably typos and should be removed before 2.8 is released. */
295 #ifdef _GCC_PTRDIFF_T_
297 #undef _BSD_PTRDIFF_T_
307 /* The following ones are the real ones. */
308 #ifdef _GCC_PTRDIFF_T
310 #undef _BSD_PTRDIFF_T_
320 #endif /* _ANSI_H_ || ( __bsdi__ && _MACHINE_ANSI_H_ ) */
322 #endif /* __sys_stdtypes_h */
324 /* A null pointer constant. */
326 #if defined (_STDDEF_H) || defined (__need_NULL)
327 #undef NULL /* in case <stdio.h> has defined it. */
331 #define NULL ((void *)0)
333 #endif /* NULL not defined and <stddef.h> or need NULL. */
338 /* Offset of member MEMBER in a struct of type TYPE. */
340 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
342 #endif /* _STDDEF_H was defined this time */
344 #endif /* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__
345 || __need_XXX was not defined before */