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