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