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