| 1 |
/*===---- stddef.h - Basic type definitions --------------------------------=== |
| 2 |
* |
| 3 |
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
* See https://llvm.org/LICENSE.txt for license information. |
| 5 |
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
* |
| 7 |
*===-----------------------------------------------------------------------=== |
| 8 |
*/ |
| 9 |
|
| 10 |
/* |
| 11 |
* This header is designed to be included multiple times. If any of the __need_ |
| 12 |
* macros are defined, then only that subset of interfaces are provided. This |
| 13 |
* can be useful for POSIX headers that need to not expose all of stddef.h, but |
| 14 |
* need to use some of its interfaces. Otherwise this header provides all of |
| 15 |
* the expected interfaces. |
| 16 |
* |
| 17 |
* When clang modules are enabled, this header is a textual header to support |
| 18 |
* the multiple include behavior. As such, it doesn't directly declare anything |
| 19 |
* so that it doesn't add duplicate declarations to all of its includers' |
| 20 |
* modules. |
| 21 |
*/ |
| 22 |
#if defined(__MVS__) && __has_include_next(<stddef.h>) |
| 23 |
#undef __need_ptrdiff_t |
| 24 |
#undef __need_size_t |
| 25 |
#undef __need_rsize_t |
| 26 |
#undef __need_wchar_t |
| 27 |
#undef __need_NULL |
| 28 |
#undef __need_nullptr_t |
| 29 |
#undef __need_unreachable |
| 30 |
#undef __need_max_align_t |
| 31 |
#undef __need_offsetof |
| 32 |
#undef __need_wint_t |
| 33 |
#include <__stddef_header_macro.h> |
| 34 |
#include_next <stddef.h> |
| 35 |
|
| 36 |
#else |
| 37 |
|
| 38 |
#if !defined(__need_ptrdiff_t) && !defined(__need_size_t) && \ |
| 39 |
!defined(__need_rsize_t) && !defined(__need_wchar_t) && \ |
| 40 |
!defined(__need_NULL) && !defined(__need_nullptr_t) && \ |
| 41 |
!defined(__need_unreachable) && !defined(__need_max_align_t) && \ |
| 42 |
!defined(__need_offsetof) && !defined(__need_wint_t) |
| 43 |
#define __need_ptrdiff_t |
| 44 |
#define __need_size_t |
| 45 |
/* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is |
| 46 |
* enabled. */ |
| 47 |
#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 |
| 48 |
#define __need_rsize_t |
| 49 |
#endif |
| 50 |
#define __need_wchar_t |
| 51 |
#if !defined(__STDDEF_H) || __has_feature(modules) |
| 52 |
/* |
| 53 |
* __stddef_null.h is special when building without modules: if __need_NULL is |
| 54 |
* set, then it will unconditionally redefine NULL. To avoid stepping on client |
| 55 |
* definitions of NULL, __need_NULL should only be set the first time this |
| 56 |
* header is included, that is when __STDDEF_H is not defined. However, when |
| 57 |
* building with modules, this header is a textual header and needs to |
| 58 |
* unconditionally include __stdef_null.h to support multiple submodules |
| 59 |
* exporting _Builtin_stddef.null. Take module SM with submodules A and B, whose |
| 60 |
* headers both include stddef.h When SM.A builds, __STDDEF_H will be defined. |
| 61 |
* When SM.B builds, the definition from SM.A will leak when building without |
| 62 |
* local submodule visibility. stddef.h wouldn't include __stddef_null.h, and |
| 63 |
* SM.B wouldn't import _Builtin_stddef.null, and SM.B's `export *` wouldn't |
| 64 |
* export NULL as expected. When building with modules, always include |
| 65 |
* __stddef_null.h so that everything works as expected. |
| 66 |
*/ |
| 67 |
#define __need_NULL |
| 68 |
#endif |
| 69 |
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ |
| 70 |
defined(__cplusplus) |
| 71 |
#define __need_nullptr_t |
| 72 |
#endif |
| 73 |
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L |
| 74 |
#define __need_unreachable |
| 75 |
#endif |
| 76 |
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ |
| 77 |
(defined(__cplusplus) && __cplusplus >= 201103L) |
| 78 |
#define __need_max_align_t |
| 79 |
#endif |
| 80 |
#define __need_offsetof |
| 81 |
/* wint_t is provided by <wchar.h> and not <stddef.h>. It's here |
| 82 |
* for compatibility, but must be explicitly requested. Therefore |
| 83 |
* __need_wint_t is intentionally not defined here. */ |
| 84 |
#include <__stddef_header_macro.h> |
| 85 |
#endif |
| 86 |
|
| 87 |
#if defined(__need_ptrdiff_t) |
| 88 |
#include <__stddef_ptrdiff_t.h> |
| 89 |
#undef __need_ptrdiff_t |
| 90 |
#endif /* defined(__need_ptrdiff_t) */ |
| 91 |
|
| 92 |
#if defined(__need_size_t) |
| 93 |
#include <__stddef_size_t.h> |
| 94 |
#undef __need_size_t |
| 95 |
#endif /*defined(__need_size_t) */ |
| 96 |
|
| 97 |
#if defined(__need_rsize_t) |
| 98 |
#include <__stddef_rsize_t.h> |
| 99 |
#undef __need_rsize_t |
| 100 |
#endif /* defined(__need_rsize_t) */ |
| 101 |
|
| 102 |
#if defined(__need_wchar_t) |
| 103 |
#include <__stddef_wchar_t.h> |
| 104 |
#undef __need_wchar_t |
| 105 |
#endif /* defined(__need_wchar_t) */ |
| 106 |
|
| 107 |
#if defined(__need_NULL) |
| 108 |
#include <__stddef_null.h> |
| 109 |
#undef __need_NULL |
| 110 |
#endif /* defined(__need_NULL) */ |
| 111 |
|
| 112 |
#if defined(__need_nullptr_t) |
| 113 |
#include <__stddef_nullptr_t.h> |
| 114 |
#undef __need_nullptr_t |
| 115 |
#endif /* defined(__need_nullptr_t) */ |
| 116 |
|
| 117 |
#if defined(__need_unreachable) |
| 118 |
#include <__stddef_unreachable.h> |
| 119 |
#undef __need_unreachable |
| 120 |
#endif /* defined(__need_unreachable) */ |
| 121 |
|
| 122 |
#if defined(__need_max_align_t) |
| 123 |
#include <__stddef_max_align_t.h> |
| 124 |
#undef __need_max_align_t |
| 125 |
#endif /* defined(__need_max_align_t) */ |
| 126 |
|
| 127 |
#if defined(__need_offsetof) |
| 128 |
#include <__stddef_offsetof.h> |
| 129 |
#undef __need_offsetof |
| 130 |
#endif /* defined(__need_offsetof) */ |
| 131 |
|
| 132 |
/* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use |
| 133 |
__WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */ |
| 134 |
#if defined(__need_wint_t) |
| 135 |
#include <__stddef_wint_t.h> |
| 136 |
#undef __need_wint_t |
| 137 |
#endif /* __need_wint_t */ |
| 138 |
|
| 139 |
#endif /* __MVS__ */ |