]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ginclude/stddef.h
Update copyright years.
[thirdparty/gcc.git] / gcc / ginclude / stddef.h
CommitLineData
fbd26352 1/* Copyright (C) 1989-2019 Free Software Foundation, Inc.
69fb1563 2
bc53ba74 3This file is part of GCC.
69fb1563 4
bc53ba74 5GCC is free software; you can redistribute it and/or modify
69fb1563 6it under the terms of the GNU General Public License as published by
6bc9506f 7the Free Software Foundation; either version 3, or (at your option)
69fb1563 8any later version.
9
bc53ba74 10GCC is distributed in the hope that it will be useful,
69fb1563 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
6bc9506f 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.
69fb1563 18
6bc9506f 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/>. */
69fb1563 23
24/*
25 * ISO C Standard: 7.17 Common definitions <stddef.h>
26 */
9915044d 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)
69c30b10 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) \
23aff663 37 && !defined(__need_ptrdiff_t) && !defined(__need_NULL) \
38 && !defined(__need_wint_t))
00cb7f36 39#define _STDDEF_H
40#define _STDDEF_H_
c04132ff 41/* snaroff@next.com says the NeXT needs this. */
42#define _ANSI_STDDEF_H
69c30b10 43#endif
00cb7f36 44
087d2183 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
c7af124d 49#if defined(__NetBSD__)
abbd44ff 50#include <machine/ansi.h>
c319aebb 51#endif
07d455ca 52
53#if defined (__FreeBSD__)
733997eb 54#include <sys/_types.h>
55#endif
c319aebb 56
c7af124d 57#if defined(__NetBSD__)
b862e373 58#if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_)
c319aebb 59#define _SIZE_T
60#endif
b862e373 61#if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_)
c319aebb 62#define _PTRDIFF_T
63#endif
b61fbd10 64/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
65 instead of _WCHAR_T_. */
b862e373 66#if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_)
b61fbd10 67#ifndef _BSD_WCHAR_T_
c319aebb 68#define _WCHAR_T
69#endif
b61fbd10 70#endif
d4a04e5d 71/* Undef _FOO_T_ if we are supposed to define foo_t. */
47001a6d 72#if defined (__need_ptrdiff_t) || defined (_STDDEF_H_)
c319aebb 73#undef _PTRDIFF_T_
b862e373 74#undef _BSD_PTRDIFF_T_
d4a04e5d 75#endif
47001a6d 76#if defined (__need_size_t) || defined (_STDDEF_H_)
abbd44ff 77#undef _SIZE_T_
b862e373 78#undef _BSD_SIZE_T_
d4a04e5d 79#endif
47001a6d 80#if defined (__need_wchar_t) || defined (_STDDEF_H_)
f100e763 81#undef _WCHAR_T_
b862e373 82#undef _BSD_WCHAR_T_
abbd44ff 83#endif
c7af124d 84#endif /* defined(__NetBSD__) */
f100e763 85
f57a5bf5 86/* Sequent's header files use _PTRDIFF_T_ in some conflicting way.
87 Just ignore it. */
88#if defined (__sequent__) && defined (_PTRDIFF_T_)
89#undef _PTRDIFF_T_
90#endif
91
ba9b6ab6 92/* On VxWorks, <type/vxTypesBase.h> may have defined macros like
93 _TYPE_size_t which will typedef size_t. fixincludes patched the
94 vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is
95 not defined, and so that defining this macro defines _GCC_SIZE_T.
96 If we find that the macros are still defined at this point, we must
97 invoke them so that the type is defined as expected. */
36ea3d1d 98#if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_))
ba9b6ab6 99_TYPE_ptrdiff_t;
100#undef _TYPE_ptrdiff_t
101#endif
102#if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_))
103_TYPE_size_t;
104#undef _TYPE_size_t
105#endif
106#if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_))
107_TYPE_wchar_t;
108#undef _TYPE_wchar_t
109#endif
110
b29231ea 111/* In case nobody has defined these types, but we aren't running under
37c5f237 112 GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and
b29231ea 113 __WCHAR_TYPE__ have reasonable values. This can happen if the
114 parts of GCC is compiled by an older compiler, that actually
115 include gstddef.h, such as collect2. */
116
00cb7f36 117/* Signed type of difference of two pointers. */
118
0db7b740 119/* Define this type if we are doing the whole job,
120 or if we want this type in particular. */
121#if defined (_STDDEF_H) || defined (__need_ptrdiff_t)
00cb7f36 122#ifndef _PTRDIFF_T /* in case <sys/types.h> has defined it. */
f1cea477 123#ifndef _T_PTRDIFF_
00cb7f36 124#ifndef _T_PTRDIFF
125#ifndef __PTRDIFF_T
126#ifndef _PTRDIFF_T_
b862e373 127#ifndef _BSD_PTRDIFF_T_
00cb7f36 128#ifndef ___int_ptrdiff_t_h
f1cea477 129#ifndef _GCC_PTRDIFF_T
463553db 130#ifndef _PTRDIFF_T_DECLARED /* DragonFly */
00cb7f36 131#define _PTRDIFF_T
f1cea477 132#define _T_PTRDIFF_
00cb7f36 133#define _T_PTRDIFF
134#define __PTRDIFF_T
135#define _PTRDIFF_T_
b862e373 136#define _BSD_PTRDIFF_T_
00cb7f36 137#define ___int_ptrdiff_t_h
f1cea477 138#define _GCC_PTRDIFF_T
463553db 139#define _PTRDIFF_T_DECLARED
b29231ea 140#ifndef __PTRDIFF_TYPE__
141#define __PTRDIFF_TYPE__ long int
142#endif
00cb7f36 143typedef __PTRDIFF_TYPE__ ptrdiff_t;
463553db 144#endif /* _PTRDIFF_T_DECLARED */
f1cea477 145#endif /* _GCC_PTRDIFF_T */
00cb7f36 146#endif /* ___int_ptrdiff_t_h */
b862e373 147#endif /* _BSD_PTRDIFF_T_ */
00cb7f36 148#endif /* _PTRDIFF_T_ */
149#endif /* __PTRDIFF_T */
150#endif /* _T_PTRDIFF */
f1cea477 151#endif /* _T_PTRDIFF_ */
00cb7f36 152#endif /* _PTRDIFF_T */
153
69c30b10 154/* If this symbol has done its job, get rid of it. */
155#undef __need_ptrdiff_t
156
0db7b740 157#endif /* _STDDEF_H or __need_ptrdiff_t. */
158
00cb7f36 159/* Unsigned type of `sizeof' something. */
160
0db7b740 161/* Define this type if we are doing the whole job,
162 or if we want this type in particular. */
163#if defined (_STDDEF_H) || defined (__need_size_t)
79013643 164#ifndef __size_t__ /* BeOS */
9caef960 165#ifndef __SIZE_T__ /* Cray Unicos/Mk */
00cb7f36 166#ifndef _SIZE_T /* in case <sys/types.h> has defined it. */
fcc24a75 167#ifndef _SYS_SIZE_T_H
f1cea477 168#ifndef _T_SIZE_
00cb7f36 169#ifndef _T_SIZE
170#ifndef __SIZE_T
171#ifndef _SIZE_T_
b862e373 172#ifndef _BSD_SIZE_T_
c48cecd7 173#ifndef _SIZE_T_DEFINED_
3da98d1b 174#ifndef _SIZE_T_DEFINED
e1039e7b 175#ifndef _BSD_SIZE_T_DEFINED_ /* Darwin */
733997eb 176#ifndef _SIZE_T_DECLARED /* FreeBSD 5 */
00cb7f36 177#ifndef ___int_size_t_h
f1cea477 178#ifndef _GCC_SIZE_T
b2540e0b 179#ifndef _SIZET_
ed0efb93 180#ifndef __size_t
79013643 181#define __size_t__ /* BeOS */
9caef960 182#define __SIZE_T__ /* Cray Unicos/Mk */
00cb7f36 183#define _SIZE_T
fcc24a75 184#define _SYS_SIZE_T_H
f1cea477 185#define _T_SIZE_
00cb7f36 186#define _T_SIZE
187#define __SIZE_T
188#define _SIZE_T_
b862e373 189#define _BSD_SIZE_T_
c48cecd7 190#define _SIZE_T_DEFINED_
3da98d1b 191#define _SIZE_T_DEFINED
e1039e7b 192#define _BSD_SIZE_T_DEFINED_ /* Darwin */
733997eb 193#define _SIZE_T_DECLARED /* FreeBSD 5 */
00cb7f36 194#define ___int_size_t_h
f1cea477 195#define _GCC_SIZE_T
b2540e0b 196#define _SIZET_
07d455ca 197#if defined (__FreeBSD__) \
463553db 198 || defined(__DragonFly__) \
b6d2c36a 199 || defined(__FreeBSD_kernel__) \
200 || defined(__VMS__)
201/* __size_t is a typedef, must not trash it. */
733997eb 202#else
ed0efb93 203#define __size_t
733997eb 204#endif
b29231ea 205#ifndef __SIZE_TYPE__
206#define __SIZE_TYPE__ long unsigned int
207#endif
0cdb5e6f 208#if !(defined (__GNUG__) && defined (size_t))
00cb7f36 209typedef __SIZE_TYPE__ size_t;
79013643 210#ifdef __BEOS__
211typedef long ssize_t;
212#endif /* __BEOS__ */
0cdb5e6f 213#endif /* !(defined (__GNUG__) && defined (size_t)) */
ed0efb93 214#endif /* __size_t */
b2540e0b 215#endif /* _SIZET_ */
f1cea477 216#endif /* _GCC_SIZE_T */
00cb7f36 217#endif /* ___int_size_t_h */
733997eb 218#endif /* _SIZE_T_DECLARED */
e1039e7b 219#endif /* _BSD_SIZE_T_DEFINED_ */
3da98d1b 220#endif /* _SIZE_T_DEFINED */
c48cecd7 221#endif /* _SIZE_T_DEFINED_ */
b862e373 222#endif /* _BSD_SIZE_T_ */
00cb7f36 223#endif /* _SIZE_T_ */
224#endif /* __SIZE_T */
225#endif /* _T_SIZE */
f1cea477 226#endif /* _T_SIZE_ */
fcc24a75 227#endif /* _SYS_SIZE_T_H */
00cb7f36 228#endif /* _SIZE_T */
9caef960 229#endif /* __SIZE_T__ */
79013643 230#endif /* __size_t__ */
69c30b10 231#undef __need_size_t
0db7b740 232#endif /* _STDDEF_H or __need_size_t. */
00cb7f36 233
69c30b10 234
235/* Wide character type.
236 Locale-writers should change this as necessary to
237 be big enough to hold unique values not between 0 and 127,
238 and not (wchar_t) -1, for each defined multibyte character. */
00cb7f36 239
0db7b740 240/* Define this type if we are doing the whole job,
241 or if we want this type in particular. */
242#if defined (_STDDEF_H) || defined (__need_wchar_t)
79013643 243#ifndef __wchar_t__ /* BeOS */
9caef960 244#ifndef __WCHAR_T__ /* Cray Unicos/Mk */
00cb7f36 245#ifndef _WCHAR_T
246#ifndef _T_WCHAR_
105f7b10 247#ifndef _T_WCHAR
00cb7f36 248#ifndef __WCHAR_T
249#ifndef _WCHAR_T_
b862e373 250#ifndef _BSD_WCHAR_T_
80d725d7 251#ifndef _BSD_WCHAR_T_DEFINED_ /* Darwin */
e1039e7b 252#ifndef _BSD_RUNE_T_DEFINED_ /* Darwin */
733997eb 253#ifndef _WCHAR_T_DECLARED /* FreeBSD 5 */
c48cecd7 254#ifndef _WCHAR_T_DEFINED_
3da98d1b 255#ifndef _WCHAR_T_DEFINED
65e1295a 256#ifndef _WCHAR_T_H
00cb7f36 257#ifndef ___int_wchar_t_h
8211d82f 258#ifndef __INT_WCHAR_T_H
f1cea477 259#ifndef _GCC_WCHAR_T
79013643 260#define __wchar_t__ /* BeOS */
9caef960 261#define __WCHAR_T__ /* Cray Unicos/Mk */
00cb7f36 262#define _WCHAR_T
263#define _T_WCHAR_
105f7b10 264#define _T_WCHAR
00cb7f36 265#define __WCHAR_T
266#define _WCHAR_T_
b862e373 267#define _BSD_WCHAR_T_
c48cecd7 268#define _WCHAR_T_DEFINED_
3da98d1b 269#define _WCHAR_T_DEFINED
65e1295a 270#define _WCHAR_T_H
00cb7f36 271#define ___int_wchar_t_h
8211d82f 272#define __INT_WCHAR_T_H
f1cea477 273#define _GCC_WCHAR_T
733997eb 274#define _WCHAR_T_DECLARED
b61fbd10 275
276/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
277 instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other
278 symbols in the _FOO_T_ family, stays defined even after its
279 corresponding type is defined). If we define wchar_t, then we
280 must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if
281 we undef _WCHAR_T_, then we must also define rune_t, since
282 headers like runetype.h assume that if machine/ansi.h is included,
283 and _BSD_WCHAR_T_ is not defined, then rune_t is available.
284 machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of
285 the same type." */
286#ifdef _BSD_WCHAR_T_
287#undef _BSD_WCHAR_T_
288#ifdef _BSD_RUNE_T_
289#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
290typedef _BSD_RUNE_T_ rune_t;
158da7c0 291#define _BSD_WCHAR_T_DEFINED_
e1039e7b 292#define _BSD_RUNE_T_DEFINED_ /* Darwin */
733997eb 293#if defined (__FreeBSD__) && (__FreeBSD__ < 5)
ee9c3cfb 294/* Why is this file so hard to maintain properly? In contrast to
df283112 295 the comment above regarding BSD/386 1.1, on FreeBSD for as long
296 as the symbol has existed, _BSD_RUNE_T_ must not stay defined or
297 redundant typedefs will occur when stdlib.h is included after this file. */
298#undef _BSD_RUNE_T_
299#endif
b61fbd10 300#endif
301#endif
302#endif
733997eb 303/* FreeBSD 5 can't be handled well using "traditional" logic above
304 since it no longer defines _BSD_RUNE_T_ yet still desires to export
305 rune_t in some cases... */
306#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
307#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
308#if __BSD_VISIBLE
309#ifndef _RUNE_T_DECLARED
310typedef __rune_t rune_t;
311#define _RUNE_T_DECLARED
312#endif
313#endif
314#endif
315#endif
b61fbd10 316
b29231ea 317#ifndef __WCHAR_TYPE__
318#define __WCHAR_TYPE__ int
319#endif
9af515ab 320#ifndef __cplusplus
00cb7f36 321typedef __WCHAR_TYPE__ wchar_t;
322#endif
323#endif
324#endif
325#endif
326#endif
f1cea477 327#endif
f992b523 328#endif
733997eb 329#endif /* _WCHAR_T_DECLARED */
e1039e7b 330#endif /* _BSD_RUNE_T_DEFINED_ */
65e1295a 331#endif
8211d82f 332#endif
c48cecd7 333#endif
b862e373 334#endif
3da98d1b 335#endif
9af515ab 336#endif
80d725d7 337#endif
9caef960 338#endif /* __WCHAR_T__ */
79013643 339#endif /* __wchar_t__ */
55369351 340#undef __need_wchar_t
0db7b740 341#endif /* _STDDEF_H or __need_wchar_t. */
00cb7f36 342
55dbcdfe 343#if defined (__need_wint_t)
23aff663 344#ifndef _WINT_T
345#define _WINT_T
346
347#ifndef __WINT_TYPE__
348#define __WINT_TYPE__ unsigned int
349#endif
23aff663 350typedef __WINT_TYPE__ wint_t;
351#endif
38b2d359 352#undef __need_wint_t
23aff663 353#endif
23aff663 354
c7af124d 355#if defined(__NetBSD__)
b61fbd10 356/* The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_
93dd477e 357 are probably typos and should be removed before 2.8 is released. */
d4a04e5d 358#ifdef _GCC_PTRDIFF_T_
c319aebb 359#undef _PTRDIFF_T_
b862e373 360#undef _BSD_PTRDIFF_T_
d4a04e5d 361#endif
362#ifdef _GCC_SIZE_T_
c319aebb 363#undef _SIZE_T_
b862e373 364#undef _BSD_SIZE_T_
c319aebb 365#endif
d4a04e5d 366#ifdef _GCC_WCHAR_T_
367#undef _WCHAR_T_
b862e373 368#undef _BSD_WCHAR_T_
abbd44ff 369#endif
b61fbd10 370/* The following ones are the real ones. */
371#ifdef _GCC_PTRDIFF_T
372#undef _PTRDIFF_T_
93dd477e 373#undef _BSD_PTRDIFF_T_
b61fbd10 374#endif
375#ifdef _GCC_SIZE_T
376#undef _SIZE_T_
93dd477e 377#undef _BSD_SIZE_T_
b61fbd10 378#endif
379#ifdef _GCC_WCHAR_T
380#undef _WCHAR_T_
93dd477e 381#undef _BSD_WCHAR_T_
b61fbd10 382#endif
c7af124d 383#endif /* __NetBSD__ */
c319aebb 384
087d2183 385#endif /* __sys_stdtypes_h */
386
00cb7f36 387/* A null pointer constant. */
388
69c30b10 389#if defined (_STDDEF_H) || defined (__need_NULL)
00cb7f36 390#undef NULL /* in case <stdio.h> has defined it. */
cef3f5da 391#ifdef __GNUG__
392#define NULL __null
393#else /* G++ */
ba21f363 394#ifndef __cplusplus
00cb7f36 395#define NULL ((void *)0)
ba21f363 396#else /* C++ */
397#define NULL 0
398#endif /* C++ */
cef3f5da 399#endif /* G++ */
69c30b10 400#endif /* NULL not defined and <stddef.h> or need NULL. */
401#undef __need_NULL
402
403#ifdef _STDDEF_H
00cb7f36 404
64658f9a 405/* Offset of member MEMBER in a struct of type TYPE. */
43bf5d72 406#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
407
32074525 408#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) \
83e25171 409 || (defined(__cplusplus) && __cplusplus >= 201103L)
410#ifndef _GCC_MAX_ALIGN_T
411#define _GCC_MAX_ALIGN_T
412/* Type whose alignment is supported in every context and is at least
413 as great as that of any standard type not using alignment
414 specifiers. */
415typedef struct {
416 long long __max_align_ll __attribute__((__aligned__(__alignof__(long long))));
417 long double __max_align_ld __attribute__((__aligned__(__alignof__(long double))));
9b5c49ef 418 /* _Float128 is defined as a basic type, so max_align_t must be
419 sufficiently aligned for it. This code must work in C++, so we
420 use __float128 here; that is only available on some
421 architectures, but only on i386 is extra alignment needed for
422 __float128. */
423#ifdef __i386__
424 __float128 __max_align_f128 __attribute__((__aligned__(__alignof(__float128))));
425#endif
83e25171 426} max_align_t;
427#endif
32074525 428#endif /* C11 or C++11. */
83e25171 429
24b73c8c 430#if defined(__cplusplus) && __cplusplus >= 201103L
431#ifndef _GXX_NULLPTR_T
432#define _GXX_NULLPTR_T
433 typedef decltype(nullptr) nullptr_t;
434#endif
435#endif /* C++11. */
436
69c30b10 437#endif /* _STDDEF_H was defined this time */
188e3846 438
9915044d 439#endif /* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__
440 || __need_XXX was not defined before */