]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ginclude/stddef.h
Update copyright years.
[thirdparty/gcc.git] / gcc / ginclude / stddef.h
CommitLineData
818ab71a 1/* Copyright (C) 1989-2016 Free Software Foundation, Inc.
fe1dbf6c 2
e531258e 3This file is part of GCC.
fe1dbf6c 4
e531258e 5GCC is free software; you can redistribute it and/or modify
fe1dbf6c 6it under the terms of the GNU General Public License as published by
748086b7 7the Free Software Foundation; either version 3, or (at your option)
fe1dbf6c
ZW
8any later version.
9
e531258e 10GCC is distributed in the hope that it will be useful,
fe1dbf6c
ZW
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
748086b7
JJ
15Under Section 7 of GPL version 3, you are granted additional
16permissions described in the GCC Runtime Library Exception, version
173.1, as published by the Free Software Foundation.
fe1dbf6c 18
748086b7
JJ
19You should have received a copy of the GNU General Public License and
20a copy of the GCC Runtime Library Exception along with this program;
21see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22<http://www.gnu.org/licenses/>. */
fe1dbf6c
ZW
23
24/*
25 * ISO C Standard: 7.17 Common definitions <stddef.h>
26 */
57bc5ea0
RK
27#if (!defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \
28 && !defined(__STDDEF_H__)) \
29 || defined(__need_wchar_t) || defined(__need_size_t) \
30 || defined(__need_ptrdiff_t) || defined(__need_NULL) \
31 || defined(__need_wint_t)
77395be6
RS
32
33/* Any one of these symbols __need_* means that GNU libc
34 wants us just to define one data type. So don't define
35 the symbols that indicate this file's entire job has been done. */
36#if (!defined(__need_wchar_t) && !defined(__need_size_t) \
3464bdc4
RK
37 && !defined(__need_ptrdiff_t) && !defined(__need_NULL) \
38 && !defined(__need_wint_t))
301264e6
MM
39#define _STDDEF_H
40#define _STDDEF_H_
cac47212
RS
41/* snaroff@next.com says the NeXT needs this. */
42#define _ANSI_STDDEF_H
77395be6 43#endif
301264e6 44
da38c875
DE
45#ifndef __sys_stdtypes_h
46/* This avoids lossage on SunOS but only if stdtypes.h comes first.
47 There's no way to win with the other order! Sun lossage. */
48
6be564d0
RS
49/* On 4.3bsd-net2, make sure ansi.h is included, so we have
50 one less case to deal with in the following. */
081d6fb9 51#if defined (__BSD_NET2__) || defined (____386BSD____) || (defined (__FreeBSD__) && (__FreeBSD__ < 5)) || defined(__NetBSD__)
ca2ece1b 52#include <machine/ansi.h>
6be564d0 53#endif
081d6fb9
LR
54/* On FreeBSD 5, machine/ansi.h does not exist anymore... */
55#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
56#include <sys/_types.h>
57#endif
6be564d0
RS
58
59/* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are
b095754a 60 defined if the corresponding type is *not* defined.
4406d0e9
JW
61 FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_.
62 NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ */
63#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_)
ec2c907a 64#if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_)
6be564d0
RS
65#define _SIZE_T
66#endif
ec2c907a 67#if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_)
6be564d0
RS
68#define _PTRDIFF_T
69#endif
73c8c157
RK
70/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
71 instead of _WCHAR_T_. */
ec2c907a 72#if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_)
73c8c157 73#ifndef _BSD_WCHAR_T_
6be564d0
RS
74#define _WCHAR_T
75#endif
73c8c157 76#endif
26afdb8e 77/* Undef _FOO_T_ if we are supposed to define foo_t. */
6de47384 78#if defined (__need_ptrdiff_t) || defined (_STDDEF_H_)
6be564d0 79#undef _PTRDIFF_T_
ec2c907a 80#undef _BSD_PTRDIFF_T_
26afdb8e 81#endif
6de47384 82#if defined (__need_size_t) || defined (_STDDEF_H_)
ca2ece1b 83#undef _SIZE_T_
ec2c907a 84#undef _BSD_SIZE_T_
26afdb8e 85#endif
6de47384 86#if defined (__need_wchar_t) || defined (_STDDEF_H_)
09dafdad 87#undef _WCHAR_T_
ec2c907a 88#undef _BSD_WCHAR_T_
ca2ece1b 89#endif
4406d0e9 90#endif /* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_) */
09dafdad 91
6d68f08e
RS
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
97
3d356a8c
ILT
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. */
25e0447f 104#if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_))
3d356a8c
ILT
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
116
616f7d00 117/* In case nobody has defined these types, but we aren't running under
b7a0c86f 118 GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and
616f7d00
RS
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. */
122
301264e6
MM
123/* Signed type of difference of two pointers. */
124
c8b9d354
CH
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)
301264e6 128#ifndef _PTRDIFF_T /* in case <sys/types.h> has defined it. */
3308e40a 129#ifndef _T_PTRDIFF_
301264e6
MM
130#ifndef _T_PTRDIFF
131#ifndef __PTRDIFF_T
132#ifndef _PTRDIFF_T_
ec2c907a 133#ifndef _BSD_PTRDIFF_T_
301264e6 134#ifndef ___int_ptrdiff_t_h
3308e40a 135#ifndef _GCC_PTRDIFF_T
dbed5a9b 136#ifndef _PTRDIFF_T_DECLARED /* DragonFly */
301264e6 137#define _PTRDIFF_T
3308e40a 138#define _T_PTRDIFF_
301264e6
MM
139#define _T_PTRDIFF
140#define __PTRDIFF_T
141#define _PTRDIFF_T_
ec2c907a 142#define _BSD_PTRDIFF_T_
301264e6 143#define ___int_ptrdiff_t_h
3308e40a 144#define _GCC_PTRDIFF_T
dbed5a9b 145#define _PTRDIFF_T_DECLARED
616f7d00
RS
146#ifndef __PTRDIFF_TYPE__
147#define __PTRDIFF_TYPE__ long int
148#endif
301264e6 149typedef __PTRDIFF_TYPE__ ptrdiff_t;
dbed5a9b 150#endif /* _PTRDIFF_T_DECLARED */
3308e40a 151#endif /* _GCC_PTRDIFF_T */
301264e6 152#endif /* ___int_ptrdiff_t_h */
ec2c907a 153#endif /* _BSD_PTRDIFF_T_ */
301264e6
MM
154#endif /* _PTRDIFF_T_ */
155#endif /* __PTRDIFF_T */
156#endif /* _T_PTRDIFF */
3308e40a 157#endif /* _T_PTRDIFF_ */
301264e6
MM
158#endif /* _PTRDIFF_T */
159
77395be6
RS
160/* If this symbol has done its job, get rid of it. */
161#undef __need_ptrdiff_t
162
c8b9d354
CH
163#endif /* _STDDEF_H or __need_ptrdiff_t. */
164
301264e6
MM
165/* Unsigned type of `sizeof' something. */
166
c8b9d354
CH
167/* Define this type if we are doing the whole job,
168 or if we want this type in particular. */
169#if defined (_STDDEF_H) || defined (__need_size_t)
c55dcc7d 170#ifndef __size_t__ /* BeOS */
30102605 171#ifndef __SIZE_T__ /* Cray Unicos/Mk */
301264e6 172#ifndef _SIZE_T /* in case <sys/types.h> has defined it. */
b6126bf1 173#ifndef _SYS_SIZE_T_H
3308e40a 174#ifndef _T_SIZE_
301264e6
MM
175#ifndef _T_SIZE
176#ifndef __SIZE_T
177#ifndef _SIZE_T_
ec2c907a 178#ifndef _BSD_SIZE_T_
a1630124 179#ifndef _SIZE_T_DEFINED_
a2a8c03c 180#ifndef _SIZE_T_DEFINED
825abef4 181#ifndef _BSD_SIZE_T_DEFINED_ /* Darwin */
081d6fb9 182#ifndef _SIZE_T_DECLARED /* FreeBSD 5 */
301264e6 183#ifndef ___int_size_t_h
3308e40a 184#ifndef _GCC_SIZE_T
e2f08830 185#ifndef _SIZET_
de9f6f43 186#ifndef __size_t
c55dcc7d 187#define __size_t__ /* BeOS */
30102605 188#define __SIZE_T__ /* Cray Unicos/Mk */
301264e6 189#define _SIZE_T
b6126bf1 190#define _SYS_SIZE_T_H
3308e40a 191#define _T_SIZE_
301264e6
MM
192#define _T_SIZE
193#define __SIZE_T
194#define _SIZE_T_
ec2c907a 195#define _BSD_SIZE_T_
a1630124 196#define _SIZE_T_DEFINED_
a2a8c03c 197#define _SIZE_T_DEFINED
825abef4 198#define _BSD_SIZE_T_DEFINED_ /* Darwin */
081d6fb9 199#define _SIZE_T_DECLARED /* FreeBSD 5 */
301264e6 200#define ___int_size_t_h
3308e40a 201#define _GCC_SIZE_T
e2f08830 202#define _SIZET_
56c534c5 203#if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
dbed5a9b 204 || defined(__DragonFly__) \
56c534c5
RM
205 || defined(__FreeBSD_kernel__)
206/* __size_t is a typedef on FreeBSD 5, must not trash it. */
914e2f45 207#elif defined (__VMS__)
c8be95e6 208/* __size_t is also a typedef on VMS. */
081d6fb9 209#else
de9f6f43 210#define __size_t
081d6fb9 211#endif
616f7d00
RS
212#ifndef __SIZE_TYPE__
213#define __SIZE_TYPE__ long unsigned int
214#endif
e38ba83a 215#if !(defined (__GNUG__) && defined (size_t))
301264e6 216typedef __SIZE_TYPE__ size_t;
c55dcc7d
FF
217#ifdef __BEOS__
218typedef long ssize_t;
219#endif /* __BEOS__ */
e38ba83a 220#endif /* !(defined (__GNUG__) && defined (size_t)) */
de9f6f43 221#endif /* __size_t */
e2f08830 222#endif /* _SIZET_ */
3308e40a 223#endif /* _GCC_SIZE_T */
301264e6 224#endif /* ___int_size_t_h */
081d6fb9 225#endif /* _SIZE_T_DECLARED */
825abef4 226#endif /* _BSD_SIZE_T_DEFINED_ */
a2a8c03c 227#endif /* _SIZE_T_DEFINED */
a1630124 228#endif /* _SIZE_T_DEFINED_ */
ec2c907a 229#endif /* _BSD_SIZE_T_ */
301264e6
MM
230#endif /* _SIZE_T_ */
231#endif /* __SIZE_T */
232#endif /* _T_SIZE */
3308e40a 233#endif /* _T_SIZE_ */
b6126bf1 234#endif /* _SYS_SIZE_T_H */
301264e6 235#endif /* _SIZE_T */
30102605 236#endif /* __SIZE_T__ */
c55dcc7d 237#endif /* __size_t__ */
77395be6 238#undef __need_size_t
c8b9d354 239#endif /* _STDDEF_H or __need_size_t. */
301264e6 240
77395be6
RS
241
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. */
301264e6 246
c8b9d354
CH
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)
c55dcc7d 250#ifndef __wchar_t__ /* BeOS */
30102605 251#ifndef __WCHAR_T__ /* Cray Unicos/Mk */
301264e6
MM
252#ifndef _WCHAR_T
253#ifndef _T_WCHAR_
b125a5a8 254#ifndef _T_WCHAR
301264e6
MM
255#ifndef __WCHAR_T
256#ifndef _WCHAR_T_
ec2c907a 257#ifndef _BSD_WCHAR_T_
ee890fe2 258#ifndef _BSD_WCHAR_T_DEFINED_ /* Darwin */
825abef4 259#ifndef _BSD_RUNE_T_DEFINED_ /* Darwin */
081d6fb9 260#ifndef _WCHAR_T_DECLARED /* FreeBSD 5 */
a1630124 261#ifndef _WCHAR_T_DEFINED_
a2a8c03c 262#ifndef _WCHAR_T_DEFINED
7a0b14b8 263#ifndef _WCHAR_T_H
301264e6 264#ifndef ___int_wchar_t_h
fda59a9a 265#ifndef __INT_WCHAR_T_H
3308e40a 266#ifndef _GCC_WCHAR_T
c55dcc7d 267#define __wchar_t__ /* BeOS */
30102605 268#define __WCHAR_T__ /* Cray Unicos/Mk */
301264e6
MM
269#define _WCHAR_T
270#define _T_WCHAR_
b125a5a8 271#define _T_WCHAR
301264e6
MM
272#define __WCHAR_T
273#define _WCHAR_T_
ec2c907a 274#define _BSD_WCHAR_T_
a1630124 275#define _WCHAR_T_DEFINED_
a2a8c03c 276#define _WCHAR_T_DEFINED
7a0b14b8 277#define _WCHAR_T_H
301264e6 278#define ___int_wchar_t_h
fda59a9a 279#define __INT_WCHAR_T_H
3308e40a 280#define _GCC_WCHAR_T
081d6fb9 281#define _WCHAR_T_DECLARED
73c8c157
RK
282
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)
297typedef _BSD_RUNE_T_ rune_t;
5cb265ec 298#define _BSD_WCHAR_T_DEFINED_
825abef4 299#define _BSD_RUNE_T_DEFINED_ /* Darwin */
081d6fb9 300#if defined (__FreeBSD__) && (__FreeBSD__ < 5)
d3471d77 301/* Why is this file so hard to maintain properly? In contrast to
17eb7951
LR
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
73c8c157
RK
307#endif
308#endif
309#endif
081d6fb9
LR
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
317typedef __rune_t rune_t;
318#define _RUNE_T_DECLARED
319#endif
320#endif
321#endif
322#endif
73c8c157 323
616f7d00
RS
324#ifndef __WCHAR_TYPE__
325#define __WCHAR_TYPE__ int
326#endif
cfeda197 327#ifndef __cplusplus
301264e6
MM
328typedef __WCHAR_TYPE__ wchar_t;
329#endif
330#endif
331#endif
332#endif
333#endif
3308e40a 334#endif
84b18070 335#endif
081d6fb9 336#endif /* _WCHAR_T_DECLARED */
825abef4 337#endif /* _BSD_RUNE_T_DEFINED_ */
7a0b14b8 338#endif
fda59a9a 339#endif
a1630124 340#endif
ec2c907a 341#endif
a2a8c03c 342#endif
cfeda197 343#endif
ee890fe2 344#endif
30102605 345#endif /* __WCHAR_T__ */
c55dcc7d 346#endif /* __wchar_t__ */
590f7e64 347#undef __need_wchar_t
c8b9d354 348#endif /* _STDDEF_H or __need_wchar_t. */
301264e6 349
c5ab7f91 350#if defined (__need_wint_t)
3464bdc4
RK
351#ifndef _WINT_T
352#define _WINT_T
353
354#ifndef __WINT_TYPE__
355#define __WINT_TYPE__ unsigned int
356#endif
3464bdc4
RK
357typedef __WINT_TYPE__ wint_t;
358#endif
3e2b54f5 359#undef __need_wint_t
3464bdc4 360#endif
3464bdc4 361
6be564d0 362/* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
26afdb8e 363 are already defined. */
370c81d6 364/* BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. */
4406d0e9
JW
365/* NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. */
366#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_)
73c8c157 367/* The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_
a0ab0422 368 are probably typos and should be removed before 2.8 is released. */
26afdb8e 369#ifdef _GCC_PTRDIFF_T_
6be564d0 370#undef _PTRDIFF_T_
ec2c907a 371#undef _BSD_PTRDIFF_T_
26afdb8e
RS
372#endif
373#ifdef _GCC_SIZE_T_
6be564d0 374#undef _SIZE_T_
ec2c907a 375#undef _BSD_SIZE_T_
6be564d0 376#endif
26afdb8e
RS
377#ifdef _GCC_WCHAR_T_
378#undef _WCHAR_T_
ec2c907a 379#undef _BSD_WCHAR_T_
ca2ece1b 380#endif
73c8c157
RK
381/* The following ones are the real ones. */
382#ifdef _GCC_PTRDIFF_T
383#undef _PTRDIFF_T_
a0ab0422 384#undef _BSD_PTRDIFF_T_
73c8c157
RK
385#endif
386#ifdef _GCC_SIZE_T
387#undef _SIZE_T_
a0ab0422 388#undef _BSD_SIZE_T_
73c8c157
RK
389#endif
390#ifdef _GCC_WCHAR_T
391#undef _WCHAR_T_
a0ab0422 392#undef _BSD_WCHAR_T_
73c8c157 393#endif
4406d0e9 394#endif /* _ANSI_H_ || _MACHINE_ANSI_H_ || _X86_64_ANSI_H_ || _I386_ANSI_H_ */
6be564d0 395
da38c875
DE
396#endif /* __sys_stdtypes_h */
397
301264e6
MM
398/* A null pointer constant. */
399
77395be6 400#if defined (_STDDEF_H) || defined (__need_NULL)
301264e6 401#undef NULL /* in case <stdio.h> has defined it. */
7a389b48
JM
402#ifdef __GNUG__
403#define NULL __null
404#else /* G++ */
be78ffb2 405#ifndef __cplusplus
301264e6 406#define NULL ((void *)0)
be78ffb2
JM
407#else /* C++ */
408#define NULL 0
409#endif /* C++ */
7a389b48 410#endif /* G++ */
77395be6
RS
411#endif /* NULL not defined and <stddef.h> or need NULL. */
412#undef __need_NULL
413
414#ifdef _STDDEF_H
301264e6 415
300e89a2 416/* Offset of member MEMBER in a struct of type TYPE. */
7a3ea201
RH
417#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
418
48b0b196 419#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) \
d19fa6b5
JM
420 || (defined(__cplusplus) && __cplusplus >= 201103L)
421#ifndef _GCC_MAX_ALIGN_T
422#define _GCC_MAX_ALIGN_T
423/* Type whose alignment is supported in every context and is at least
424 as great as that of any standard type not using alignment
425 specifiers. */
426typedef struct {
427 long long __max_align_ll __attribute__((__aligned__(__alignof__(long long))));
428 long double __max_align_ld __attribute__((__aligned__(__alignof__(long double))));
429} max_align_t;
430#endif
48b0b196 431#endif /* C11 or C++11. */
d19fa6b5 432
21c278c9
PC
433#if defined(__cplusplus) && __cplusplus >= 201103L
434#ifndef _GXX_NULLPTR_T
435#define _GXX_NULLPTR_T
436 typedef decltype(nullptr) nullptr_t;
437#endif
438#endif /* C++11. */
439
77395be6 440#endif /* _STDDEF_H was defined this time */
8328559d 441
57bc5ea0
RK
442#endif /* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__
443 || __need_XXX was not defined before */