brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.9 KiB · 99b275a Raw
140 lines · c
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-exception6 *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. This13 * can be useful for POSIX headers that need to not expose all of stddef.h, but14 * need to use some of its interfaces. Otherwise this header provides all of15 * the expected interfaces.16 *17 * When clang modules are enabled, this header is a textual header to support18 * the multiple include behavior. As such, it doesn't directly declare anything19 * 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_t24#undef __need_size_t25#undef __need_rsize_t26#undef __need_wchar_t27#undef __need_NULL28#undef __need_nullptr_t29#undef __need_unreachable30#undef __need_max_align_t31#undef __need_offsetof32#undef __need_wint_t33#include <__stddef_header_macro.h>34#include_next <stddef.h>35 36#else37 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_t44#define __need_size_t45/* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is46 * enabled. */47#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 148#define __need_rsize_t49#endif50#define __need_wchar_t51#if !defined(__STDDEF_H) || __has_feature(modules)52/*53 * __stddef_null.h is special when building without modules: if __need_NULL is54 * set, then it will unconditionally redefine NULL. To avoid stepping on client55 * definitions of NULL, __need_NULL should only be set the first time this56 * header is included, that is when __STDDEF_H is not defined. However, when57 * building with modules, this header is a textual header and needs to58 * unconditionally include __stdef_null.h to support multiple submodules59 * exporting _Builtin_stddef.null. Take module SM with submodules A and B, whose60 * 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 without62 * local submodule visibility. stddef.h wouldn't include __stddef_null.h, and63 * SM.B wouldn't import _Builtin_stddef.null, and SM.B's `export *` wouldn't64 * export NULL as expected. When building with modules, always include65 * __stddef_null.h so that everything works as expected.66 */67#define __need_NULL68#endif69#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) ||              \70    defined(__cplusplus)71#define __need_nullptr_t72#endif73#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L74#define __need_unreachable75#endif76#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) ||              \77    (defined(__cplusplus) && __cplusplus >= 201103L)78#define __need_max_align_t79#endif80#define __need_offsetof81/* wint_t is provided by <wchar.h> and not <stddef.h>. It's here82 * for compatibility, but must be explicitly requested. Therefore83 * __need_wint_t is intentionally not defined here. */84#include <__stddef_header_macro.h>85#endif86 87#if defined(__need_ptrdiff_t)88#include <__stddef_ptrdiff_t.h>89#undef __need_ptrdiff_t90#endif /* defined(__need_ptrdiff_t) */91 92#if defined(__need_size_t)93#include <__stddef_size_t.h>94#undef __need_size_t95#endif /*defined(__need_size_t) */96 97#if defined(__need_rsize_t)98#include <__stddef_rsize_t.h>99#undef __need_rsize_t100#endif /* defined(__need_rsize_t) */101 102#if defined(__need_wchar_t)103#include <__stddef_wchar_t.h>104#undef __need_wchar_t105#endif /* defined(__need_wchar_t) */106 107#if defined(__need_NULL)108#include <__stddef_null.h>109#undef __need_NULL110#endif /* defined(__need_NULL) */111 112#if defined(__need_nullptr_t)113#include <__stddef_nullptr_t.h>114#undef __need_nullptr_t115#endif /* defined(__need_nullptr_t) */116 117#if defined(__need_unreachable)118#include <__stddef_unreachable.h>119#undef __need_unreachable120#endif /* defined(__need_unreachable) */121 122#if defined(__need_max_align_t)123#include <__stddef_max_align_t.h>124#undef __need_max_align_t125#endif /* defined(__need_max_align_t) */126 127#if defined(__need_offsetof)128#include <__stddef_offsetof.h>129#undef __need_offsetof130#endif /* defined(__need_offsetof) */131 132/* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use133__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_t137#endif /* __need_wint_t */138 139#endif /* __MVS__ */140