xref: /aosp_15_r20/prebuilts/sdk/renderscript/clang-include/stddef.h (revision 344a7f5ef16c479e7a7f54ee6567a9d112f9e72b)
1*344a7f5eSAndroid Build Coastguard Worker /*===---- stddef.h - Basic type definitions --------------------------------===
2*344a7f5eSAndroid Build Coastguard Worker  *
3*344a7f5eSAndroid Build Coastguard Worker  * Copyright (c) 2008 Eli Friedman
4*344a7f5eSAndroid Build Coastguard Worker  *
5*344a7f5eSAndroid Build Coastguard Worker  * Permission is hereby granted, free of charge, to any person obtaining a copy
6*344a7f5eSAndroid Build Coastguard Worker  * of this software and associated documentation files (the "Software"), to deal
7*344a7f5eSAndroid Build Coastguard Worker  * in the Software without restriction, including without limitation the rights
8*344a7f5eSAndroid Build Coastguard Worker  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9*344a7f5eSAndroid Build Coastguard Worker  * copies of the Software, and to permit persons to whom the Software is
10*344a7f5eSAndroid Build Coastguard Worker  * furnished to do so, subject to the following conditions:
11*344a7f5eSAndroid Build Coastguard Worker  *
12*344a7f5eSAndroid Build Coastguard Worker  * The above copyright notice and this permission notice shall be included in
13*344a7f5eSAndroid Build Coastguard Worker  * all copies or substantial portions of the Software.
14*344a7f5eSAndroid Build Coastguard Worker  *
15*344a7f5eSAndroid Build Coastguard Worker  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*344a7f5eSAndroid Build Coastguard Worker  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*344a7f5eSAndroid Build Coastguard Worker  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18*344a7f5eSAndroid Build Coastguard Worker  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*344a7f5eSAndroid Build Coastguard Worker  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20*344a7f5eSAndroid Build Coastguard Worker  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21*344a7f5eSAndroid Build Coastguard Worker  * THE SOFTWARE.
22*344a7f5eSAndroid Build Coastguard Worker  *
23*344a7f5eSAndroid Build Coastguard Worker  *===-----------------------------------------------------------------------===
24*344a7f5eSAndroid Build Coastguard Worker  */
25*344a7f5eSAndroid Build Coastguard Worker 
26*344a7f5eSAndroid Build Coastguard Worker #if !defined(__STDDEF_H) || defined(__need_ptrdiff_t) ||                       \
27*344a7f5eSAndroid Build Coastguard Worker     defined(__need_size_t) || defined(__need_wchar_t) ||                       \
28*344a7f5eSAndroid Build Coastguard Worker     defined(__need_NULL) || defined(__need_wint_t)
29*344a7f5eSAndroid Build Coastguard Worker 
30*344a7f5eSAndroid Build Coastguard Worker #if !defined(__need_ptrdiff_t) && !defined(__need_size_t) &&                   \
31*344a7f5eSAndroid Build Coastguard Worker     !defined(__need_wchar_t) && !defined(__need_NULL) &&                       \
32*344a7f5eSAndroid Build Coastguard Worker     !defined(__need_wint_t)
33*344a7f5eSAndroid Build Coastguard Worker /* Always define miscellaneous pieces when modules are available. */
34*344a7f5eSAndroid Build Coastguard Worker #if !__has_feature(modules)
35*344a7f5eSAndroid Build Coastguard Worker #define __STDDEF_H
36*344a7f5eSAndroid Build Coastguard Worker #endif
37*344a7f5eSAndroid Build Coastguard Worker #define __need_ptrdiff_t
38*344a7f5eSAndroid Build Coastguard Worker #define __need_size_t
39*344a7f5eSAndroid Build Coastguard Worker #define __need_wchar_t
40*344a7f5eSAndroid Build Coastguard Worker #define __need_NULL
41*344a7f5eSAndroid Build Coastguard Worker #define __need_STDDEF_H_misc
42*344a7f5eSAndroid Build Coastguard Worker /* __need_wint_t is intentionally not defined here. */
43*344a7f5eSAndroid Build Coastguard Worker #endif
44*344a7f5eSAndroid Build Coastguard Worker 
45*344a7f5eSAndroid Build Coastguard Worker #if defined(__need_ptrdiff_t)
46*344a7f5eSAndroid Build Coastguard Worker #if !defined(_PTRDIFF_T) || __has_feature(modules)
47*344a7f5eSAndroid Build Coastguard Worker /* Always define ptrdiff_t when modules are available. */
48*344a7f5eSAndroid Build Coastguard Worker #if !__has_feature(modules)
49*344a7f5eSAndroid Build Coastguard Worker #define _PTRDIFF_T
50*344a7f5eSAndroid Build Coastguard Worker #endif
51*344a7f5eSAndroid Build Coastguard Worker typedef __PTRDIFF_TYPE__ ptrdiff_t;
52*344a7f5eSAndroid Build Coastguard Worker #endif
53*344a7f5eSAndroid Build Coastguard Worker #undef __need_ptrdiff_t
54*344a7f5eSAndroid Build Coastguard Worker #endif /* defined(__need_ptrdiff_t) */
55*344a7f5eSAndroid Build Coastguard Worker 
56*344a7f5eSAndroid Build Coastguard Worker #if defined(__need_size_t)
57*344a7f5eSAndroid Build Coastguard Worker #if !defined(_SIZE_T) || __has_feature(modules)
58*344a7f5eSAndroid Build Coastguard Worker /* Always define size_t when modules are available. */
59*344a7f5eSAndroid Build Coastguard Worker #if !__has_feature(modules)
60*344a7f5eSAndroid Build Coastguard Worker #define _SIZE_T
61*344a7f5eSAndroid Build Coastguard Worker #endif
62*344a7f5eSAndroid Build Coastguard Worker typedef __SIZE_TYPE__ size_t;
63*344a7f5eSAndroid Build Coastguard Worker #endif
64*344a7f5eSAndroid Build Coastguard Worker #undef __need_size_t
65*344a7f5eSAndroid Build Coastguard Worker #endif /*defined(__need_size_t) */
66*344a7f5eSAndroid Build Coastguard Worker 
67*344a7f5eSAndroid Build Coastguard Worker #if defined(__need_STDDEF_H_misc)
68*344a7f5eSAndroid Build Coastguard Worker /* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is
69*344a7f5eSAndroid Build Coastguard Worker  * enabled. */
70*344a7f5eSAndroid Build Coastguard Worker #if (defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 && \
71*344a7f5eSAndroid Build Coastguard Worker      !defined(_RSIZE_T)) || __has_feature(modules)
72*344a7f5eSAndroid Build Coastguard Worker /* Always define rsize_t when modules are available. */
73*344a7f5eSAndroid Build Coastguard Worker #if !__has_feature(modules)
74*344a7f5eSAndroid Build Coastguard Worker #define _RSIZE_T
75*344a7f5eSAndroid Build Coastguard Worker #endif
76*344a7f5eSAndroid Build Coastguard Worker typedef __SIZE_TYPE__ rsize_t;
77*344a7f5eSAndroid Build Coastguard Worker #endif
78*344a7f5eSAndroid Build Coastguard Worker #endif /* defined(__need_STDDEF_H_misc) */
79*344a7f5eSAndroid Build Coastguard Worker 
80*344a7f5eSAndroid Build Coastguard Worker #if defined(__need_wchar_t)
81*344a7f5eSAndroid Build Coastguard Worker #ifndef __cplusplus
82*344a7f5eSAndroid Build Coastguard Worker /* Always define wchar_t when modules are available. */
83*344a7f5eSAndroid Build Coastguard Worker #if !defined(_WCHAR_T) || __has_feature(modules)
84*344a7f5eSAndroid Build Coastguard Worker #if !__has_feature(modules)
85*344a7f5eSAndroid Build Coastguard Worker #define _WCHAR_T
86*344a7f5eSAndroid Build Coastguard Worker #if defined(_MSC_EXTENSIONS)
87*344a7f5eSAndroid Build Coastguard Worker #define _WCHAR_T_DEFINED
88*344a7f5eSAndroid Build Coastguard Worker #endif
89*344a7f5eSAndroid Build Coastguard Worker #endif
90*344a7f5eSAndroid Build Coastguard Worker typedef __WCHAR_TYPE__ wchar_t;
91*344a7f5eSAndroid Build Coastguard Worker #endif
92*344a7f5eSAndroid Build Coastguard Worker #endif
93*344a7f5eSAndroid Build Coastguard Worker #undef __need_wchar_t
94*344a7f5eSAndroid Build Coastguard Worker #endif /* defined(__need_wchar_t) */
95*344a7f5eSAndroid Build Coastguard Worker 
96*344a7f5eSAndroid Build Coastguard Worker #if defined(__need_NULL)
97*344a7f5eSAndroid Build Coastguard Worker #undef NULL
98*344a7f5eSAndroid Build Coastguard Worker #ifdef __cplusplus
99*344a7f5eSAndroid Build Coastguard Worker #  if !defined(__MINGW32__) && !defined(_MSC_VER)
100*344a7f5eSAndroid Build Coastguard Worker #    define NULL __null
101*344a7f5eSAndroid Build Coastguard Worker #  else
102*344a7f5eSAndroid Build Coastguard Worker #    define NULL 0
103*344a7f5eSAndroid Build Coastguard Worker #  endif
104*344a7f5eSAndroid Build Coastguard Worker #else
105*344a7f5eSAndroid Build Coastguard Worker #  define NULL ((void*)0)
106*344a7f5eSAndroid Build Coastguard Worker #endif
107*344a7f5eSAndroid Build Coastguard Worker #ifdef __cplusplus
108*344a7f5eSAndroid Build Coastguard Worker #if defined(_MSC_EXTENSIONS) && defined(_NATIVE_NULLPTR_SUPPORTED)
109*344a7f5eSAndroid Build Coastguard Worker namespace std { typedef decltype(nullptr) nullptr_t; }
110*344a7f5eSAndroid Build Coastguard Worker using ::std::nullptr_t;
111*344a7f5eSAndroid Build Coastguard Worker #endif
112*344a7f5eSAndroid Build Coastguard Worker #endif
113*344a7f5eSAndroid Build Coastguard Worker #undef __need_NULL
114*344a7f5eSAndroid Build Coastguard Worker #endif /* defined(__need_NULL) */
115*344a7f5eSAndroid Build Coastguard Worker 
116*344a7f5eSAndroid Build Coastguard Worker #if defined(__need_STDDEF_H_misc)
117*344a7f5eSAndroid Build Coastguard Worker #if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L
118*344a7f5eSAndroid Build Coastguard Worker #include "__stddef_max_align_t.h"
119*344a7f5eSAndroid Build Coastguard Worker #endif
120*344a7f5eSAndroid Build Coastguard Worker #define offsetof(t, d) __builtin_offsetof(t, d)
121*344a7f5eSAndroid Build Coastguard Worker #undef __need_STDDEF_H_misc
122*344a7f5eSAndroid Build Coastguard Worker #endif  /* defined(__need_STDDEF_H_misc) */
123*344a7f5eSAndroid Build Coastguard Worker 
124*344a7f5eSAndroid Build Coastguard Worker /* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use
125*344a7f5eSAndroid Build Coastguard Worker __WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */
126*344a7f5eSAndroid Build Coastguard Worker #if defined(__need_wint_t)
127*344a7f5eSAndroid Build Coastguard Worker /* Always define wint_t when modules are available. */
128*344a7f5eSAndroid Build Coastguard Worker #if !defined(_WINT_T) || __has_feature(modules)
129*344a7f5eSAndroid Build Coastguard Worker #if !__has_feature(modules)
130*344a7f5eSAndroid Build Coastguard Worker #define _WINT_T
131*344a7f5eSAndroid Build Coastguard Worker #endif
132*344a7f5eSAndroid Build Coastguard Worker typedef __WINT_TYPE__ wint_t;
133*344a7f5eSAndroid Build Coastguard Worker #endif
134*344a7f5eSAndroid Build Coastguard Worker #undef __need_wint_t
135*344a7f5eSAndroid Build Coastguard Worker #endif /* __need_wint_t */
136*344a7f5eSAndroid Build Coastguard Worker 
137*344a7f5eSAndroid Build Coastguard Worker #endif
138