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