stddef.h revision 8da6bca896546cd98ad6aefaa3e9eba77736ea7b
18ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman/*===---- stddef.h - Basic type definitions --------------------------------===
28ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman *
38ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * Copyright (c) 2008 Eli Friedman
48ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman *
58ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * Permission is hereby granted, free of charge, to any person obtaining a copy
68ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * of this software and associated documentation files (the "Software"), to deal
78ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * in the Software without restriction, including without limitation the rights
88ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
98ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * copies of the Software, and to permit persons to whom the Software is
108ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * furnished to do so, subject to the following conditions:
118ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman *
128ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * The above copyright notice and this permission notice shall be included in
138ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * all copies or substantial portions of the Software.
148ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman *
158ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
168ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
178ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
188ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
198ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
208ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
218ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman * THE SOFTWARE.
228ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman *
238ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman *===-----------------------------------------------------------------------===
248ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman */
258ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman
268ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman#ifndef __STDDEF_H
278ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman#define __STDDEF_H
288ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman
298da6bca896546cd98ad6aefaa3e9eba77736ea7bTed Kremenek#ifndef _PTRDIFF_T
308da6bca896546cd98ad6aefaa3e9eba77736ea7bTed Kremenek#define _PTRDIFF_T
318ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedmantypedef __typeof__(((int*)0)-((int*)0)) ptrdiff_t;
328da6bca896546cd98ad6aefaa3e9eba77736ea7bTed Kremenek#endif
3321259bafdc0e113c8bdce51d7911cc9880da1892Ted Kremenek#ifndef _SIZE_T
3421259bafdc0e113c8bdce51d7911cc9880da1892Ted Kremenek#define _SIZE_T
358ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedmantypedef __typeof__(sizeof(int)) size_t;
3621259bafdc0e113c8bdce51d7911cc9880da1892Ted Kremenek#endif
378ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman#ifndef __cplusplus
3821259bafdc0e113c8bdce51d7911cc9880da1892Ted Kremenek#ifndef _WCHAR_T
3921259bafdc0e113c8bdce51d7911cc9880da1892Ted Kremenek#define _WCHAR_T
406d6370ee10ddcd8cacc44c2d6796800c1325c732Chris Lattnertypedef __WCHAR_TYPE__ wchar_t;
418ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman#endif
4221259bafdc0e113c8bdce51d7911cc9880da1892Ted Kremenek#endif
438ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman
4421259bafdc0e113c8bdce51d7911cc9880da1892Ted Kremenek#undef NULL
45f8e61b371d085516b8b9b906099db3e0b915a7c0Anders Carlsson#ifdef __cplusplus
46863e7189dc437ef0f35ff94d74f62c775759d2ceChris Lattner#undef __null  // VC++ hack.
4728d6cba4c472fca54c77cba34c15802a634984afDouglas Gregor#define NULL __null
48f8e61b371d085516b8b9b906099db3e0b915a7c0Anders Carlsson#else
498ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman#define NULL ((void*)0)
50f8e61b371d085516b8b9b906099db3e0b915a7c0Anders Carlsson#endif
51f8e61b371d085516b8b9b906099db3e0b915a7c0Anders Carlsson
528ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman#define offsetof(t, d) __builtin_offsetof(t, d)
538ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman
548ba179d4a39c79ae486472a5f413f763ffcc0739Eli Friedman#endif /* __STDDEF_H */
5551f56fc36e6d441b6dd722cc09c4ac9f081c0974NAKAMURA Takumi
5651f56fc36e6d441b6dd722cc09c4ac9f081c0974NAKAMURA Takumi/* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use
5751f56fc36e6d441b6dd722cc09c4ac9f081c0974NAKAMURA Takumi__WINT_TYPE__ directly; accomodate both by requiring __need_wint_t */
5851f56fc36e6d441b6dd722cc09c4ac9f081c0974NAKAMURA Takumi#if defined(__need_wint_t)
5951f56fc36e6d441b6dd722cc09c4ac9f081c0974NAKAMURA Takumi#if !defined(_WINT_T)
6051f56fc36e6d441b6dd722cc09c4ac9f081c0974NAKAMURA Takumi#define _WINT_T
6151f56fc36e6d441b6dd722cc09c4ac9f081c0974NAKAMURA Takumitypedef __WINT_TYPE__ wint_t;
6251f56fc36e6d441b6dd722cc09c4ac9f081c0974NAKAMURA Takumi#endif /* _WINT_T */
6351f56fc36e6d441b6dd722cc09c4ac9f081c0974NAKAMURA Takumi#undef __need_wint_t
6451f56fc36e6d441b6dd722cc09c4ac9f081c0974NAKAMURA Takumi#endif /* __need_wint_t */
65