xref: /xnu-8792.41.9/EXTERNAL_HEADERS/stddef.h (revision 5c2921b07a2480ab43ec66f5b9e41cb872bc554f)
1*5c2921b0SApple OSS Distributions /*===---- stddef.h - Basic type definitions --------------------------------===
2*5c2921b0SApple OSS Distributions  *
3*5c2921b0SApple OSS Distributions  * Copyright (c) 2008 Eli Friedman
4*5c2921b0SApple OSS Distributions  *
5*5c2921b0SApple OSS Distributions  * Permission is hereby granted, free of charge, to any person obtaining a copy
6*5c2921b0SApple OSS Distributions  * of this software and associated documentation files (the "Software"), to deal
7*5c2921b0SApple OSS Distributions  * in the Software without restriction, including without limitation the rights
8*5c2921b0SApple OSS Distributions  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9*5c2921b0SApple OSS Distributions  * copies of the Software, and to permit persons to whom the Software is
10*5c2921b0SApple OSS Distributions  * furnished to do so, subject to the following conditions:
11*5c2921b0SApple OSS Distributions  *
12*5c2921b0SApple OSS Distributions  * The above copyright notice and this permission notice shall be included in
13*5c2921b0SApple OSS Distributions  * all copies or substantial portions of the Software.
14*5c2921b0SApple OSS Distributions  *
15*5c2921b0SApple OSS Distributions  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*5c2921b0SApple OSS Distributions  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*5c2921b0SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18*5c2921b0SApple OSS Distributions  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*5c2921b0SApple OSS Distributions  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20*5c2921b0SApple OSS Distributions  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21*5c2921b0SApple OSS Distributions  * THE SOFTWARE.
22*5c2921b0SApple OSS Distributions  *
23*5c2921b0SApple OSS Distributions  *===-----------------------------------------------------------------------===
24*5c2921b0SApple OSS Distributions  */
25*5c2921b0SApple OSS Distributions 
26*5c2921b0SApple OSS Distributions #ifndef __STDDEF_H
27*5c2921b0SApple OSS Distributions #define __STDDEF_H
28*5c2921b0SApple OSS Distributions 
29*5c2921b0SApple OSS Distributions #undef NULL
30*5c2921b0SApple OSS Distributions #ifdef __cplusplus
31*5c2921b0SApple OSS Distributions #if __cplusplus >= 201103L
32*5c2921b0SApple OSS Distributions #define NULL nullptr
33*5c2921b0SApple OSS Distributions #else
34*5c2921b0SApple OSS Distributions #undef __null  // VC++ hack.
35*5c2921b0SApple OSS Distributions #define NULL __null
36*5c2921b0SApple OSS Distributions #endif
37*5c2921b0SApple OSS Distributions #else
38*5c2921b0SApple OSS Distributions #define NULL ((void*)0)
39*5c2921b0SApple OSS Distributions #endif
40*5c2921b0SApple OSS Distributions 
41*5c2921b0SApple OSS Distributions #ifndef _PTRDIFF_T
42*5c2921b0SApple OSS Distributions #define _PTRDIFF_T
43*5c2921b0SApple OSS Distributions typedef __typeof__(((int*)NULL)-((int*)NULL)) ptrdiff_t;
44*5c2921b0SApple OSS Distributions #endif
45*5c2921b0SApple OSS Distributions #ifndef _SIZE_T
46*5c2921b0SApple OSS Distributions #define _SIZE_T
47*5c2921b0SApple OSS Distributions typedef __typeof__(sizeof(int)) size_t;
48*5c2921b0SApple OSS Distributions #endif
49*5c2921b0SApple OSS Distributions #ifndef __cplusplus
50*5c2921b0SApple OSS Distributions #ifndef _WCHAR_T
51*5c2921b0SApple OSS Distributions #define _WCHAR_T
52*5c2921b0SApple OSS Distributions typedef __WCHAR_TYPE__ wchar_t;
53*5c2921b0SApple OSS Distributions #endif
54*5c2921b0SApple OSS Distributions #endif
55*5c2921b0SApple OSS Distributions 
56*5c2921b0SApple OSS Distributions #ifndef offsetof
57*5c2921b0SApple OSS Distributions #define offsetof(t, d) __builtin_offsetof(t, d)
58*5c2921b0SApple OSS Distributions #endif
59*5c2921b0SApple OSS Distributions 
60*5c2921b0SApple OSS Distributions #endif /* __STDDEF_H */
61*5c2921b0SApple OSS Distributions 
62*5c2921b0SApple OSS Distributions /* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use
63*5c2921b0SApple OSS Distributions __WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */
64*5c2921b0SApple OSS Distributions #if defined(__need_wint_t)
65*5c2921b0SApple OSS Distributions #if !defined(_WINT_T)
66*5c2921b0SApple OSS Distributions #define _WINT_T
67*5c2921b0SApple OSS Distributions typedef __WINT_TYPE__ wint_t;
68*5c2921b0SApple OSS Distributions #endif /* _WINT_T */
69*5c2921b0SApple OSS Distributions #undef __need_wint_t
70*5c2921b0SApple OSS Distributions #endif /* __need_wint_t */
71