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