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