[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / lib / Headers / stddef.h
blob8e86a21e8dbed58177ac3ec76e86abb721ca5a16
1 /*===---- stddef.h - Basic type definitions --------------------------------===
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
7 *===-----------------------------------------------------------------------===
8 */
10 #if !defined(__STDDEF_H) || defined(__need_ptrdiff_t) || \
11 defined(__need_size_t) || defined(__need_wchar_t) || \
12 defined(__need_NULL) || defined(__need_wint_t)
14 #if !defined(__need_ptrdiff_t) && !defined(__need_size_t) && \
15 !defined(__need_wchar_t) && !defined(__need_NULL) && \
16 !defined(__need_wint_t)
17 /* Always define miscellaneous pieces when modules are available. */
18 #if !__has_feature(modules)
19 #define __STDDEF_H
20 #endif
21 #define __need_ptrdiff_t
22 #define __need_size_t
23 #define __need_wchar_t
24 #define __need_NULL
25 #define __need_STDDEF_H_misc
26 /* __need_wint_t is intentionally not defined here. */
27 #endif
29 #if defined(__need_ptrdiff_t)
30 #if !defined(_PTRDIFF_T) || __has_feature(modules)
31 /* Always define ptrdiff_t when modules are available. */
32 #if !__has_feature(modules)
33 #define _PTRDIFF_T
34 #endif
35 typedef __PTRDIFF_TYPE__ ptrdiff_t;
36 #endif
37 #undef __need_ptrdiff_t
38 #endif /* defined(__need_ptrdiff_t) */
40 #if defined(__need_size_t)
41 #if !defined(_SIZE_T) || __has_feature(modules)
42 /* Always define size_t when modules are available. */
43 #if !__has_feature(modules)
44 #define _SIZE_T
45 #endif
46 typedef __SIZE_TYPE__ size_t;
47 #endif
48 #undef __need_size_t
49 #endif /*defined(__need_size_t) */
51 #if defined(__need_STDDEF_H_misc)
52 /* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is
53 * enabled. */
54 #if (defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 && \
55 !defined(_RSIZE_T)) || __has_feature(modules)
56 /* Always define rsize_t when modules are available. */
57 #if !__has_feature(modules)
58 #define _RSIZE_T
59 #endif
60 typedef __SIZE_TYPE__ rsize_t;
61 #endif
62 #endif /* defined(__need_STDDEF_H_misc) */
64 #if defined(__need_wchar_t)
65 #if !defined(__cplusplus) || (defined(_MSC_VER) && !_NATIVE_WCHAR_T_DEFINED)
66 /* Always define wchar_t when modules are available. */
67 #if !defined(_WCHAR_T) || __has_feature(modules)
68 #if !__has_feature(modules)
69 #define _WCHAR_T
70 #if defined(_MSC_EXTENSIONS)
71 #define _WCHAR_T_DEFINED
72 #endif
73 #endif
74 typedef __WCHAR_TYPE__ wchar_t;
75 #endif
76 #endif
77 #undef __need_wchar_t
78 #endif /* defined(__need_wchar_t) */
80 #if defined(__need_NULL)
81 #undef NULL
82 #ifdef __cplusplus
83 # if !defined(__MINGW32__) && !defined(_MSC_VER)
84 # define NULL __null
85 # else
86 # define NULL 0
87 # endif
88 #else
89 # define NULL ((void*)0)
90 #endif
91 #ifdef __cplusplus
92 #if defined(_MSC_EXTENSIONS) && defined(_NATIVE_NULLPTR_SUPPORTED)
93 namespace std { typedef decltype(nullptr) nullptr_t; }
94 using ::std::nullptr_t;
95 #endif
96 #endif
97 #undef __need_NULL
98 #endif /* defined(__need_NULL) */
100 #if defined(__need_STDDEF_H_misc)
101 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
102 (defined(__cplusplus) && __cplusplus >= 201103L)
103 #include "__stddef_max_align_t.h"
104 #endif
105 #define offsetof(t, d) __builtin_offsetof(t, d)
106 #undef __need_STDDEF_H_misc
107 #endif /* defined(__need_STDDEF_H_misc) */
109 /* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use
110 __WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */
111 #if defined(__need_wint_t)
112 /* Always define wint_t when modules are available. */
113 #if !defined(_WINT_T) || __has_feature(modules)
114 #if !__has_feature(modules)
115 #define _WINT_T
116 #endif
117 typedef __WINT_TYPE__ wint_t;
118 #endif
119 #undef __need_wint_t
120 #endif /* __need_wint_t */
122 #endif