2009-06-02 17:58:47 +00:00
|
|
|
/*===---- stddef.h - Basic type definitions --------------------------------===
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008 Eli Friedman
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*===-----------------------------------------------------------------------===
|
|
|
|
*/
|
|
|
|
|
2014-11-24 09:15:30 +00:00
|
|
|
#if !defined(__STDDEF_H) || defined(__need_ptrdiff_t) || \
|
|
|
|
defined(__need_size_t) || defined(__need_wchar_t) || \
|
|
|
|
defined(__need_NULL) || defined(__need_wint_t)
|
|
|
|
|
|
|
|
#if !defined(__need_ptrdiff_t) && !defined(__need_size_t) && \
|
|
|
|
!defined(__need_wchar_t) && !defined(__need_NULL) && \
|
|
|
|
!defined(__need_wint_t)
|
2015-01-18 16:23:48 +00:00
|
|
|
/* Always define miscellaneous pieces when modules are available. */
|
|
|
|
#if !__has_feature(modules)
|
2009-06-02 17:58:47 +00:00
|
|
|
#define __STDDEF_H
|
2015-01-18 16:23:48 +00:00
|
|
|
#endif
|
2014-11-24 09:15:30 +00:00
|
|
|
#define __need_ptrdiff_t
|
|
|
|
#define __need_size_t
|
|
|
|
#define __need_wchar_t
|
|
|
|
#define __need_NULL
|
2015-01-18 16:23:48 +00:00
|
|
|
#define __need_STDDEF_H_misc
|
2014-11-24 09:15:30 +00:00
|
|
|
/* __need_wint_t is intentionally not defined here. */
|
|
|
|
#endif
|
2009-06-02 17:58:47 +00:00
|
|
|
|
2014-11-24 09:15:30 +00:00
|
|
|
#if defined(__need_ptrdiff_t)
|
2013-04-08 18:45:10 +00:00
|
|
|
#if !defined(_PTRDIFF_T) || __has_feature(modules)
|
|
|
|
/* Always define ptrdiff_t when modules are available. */
|
|
|
|
#if !__has_feature(modules)
|
2011-05-02 19:39:53 +00:00
|
|
|
#define _PTRDIFF_T
|
|
|
|
#endif
|
2013-04-08 18:45:10 +00:00
|
|
|
typedef __PTRDIFF_TYPE__ ptrdiff_t;
|
|
|
|
#endif
|
2014-11-24 09:15:30 +00:00
|
|
|
#undef __need_ptrdiff_t
|
|
|
|
#endif /* defined(__need_ptrdiff_t) */
|
2013-04-08 18:45:10 +00:00
|
|
|
|
2014-11-24 09:15:30 +00:00
|
|
|
#if defined(__need_size_t)
|
2013-04-08 18:45:10 +00:00
|
|
|
#if !defined(_SIZE_T) || __has_feature(modules)
|
|
|
|
/* Always define size_t when modules are available. */
|
|
|
|
#if !__has_feature(modules)
|
2010-03-10 17:45:58 +00:00
|
|
|
#define _SIZE_T
|
|
|
|
#endif
|
2013-04-08 18:45:10 +00:00
|
|
|
typedef __SIZE_TYPE__ size_t;
|
|
|
|
#endif
|
2014-11-24 09:15:30 +00:00
|
|
|
#undef __need_size_t
|
|
|
|
#endif /*defined(__need_size_t) */
|
2013-04-08 18:45:10 +00:00
|
|
|
|
2015-01-18 16:23:48 +00:00
|
|
|
#if defined(__need_STDDEF_H_misc)
|
2013-06-10 20:45:12 +00:00
|
|
|
/* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is
|
|
|
|
* enabled. */
|
|
|
|
#if (defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 && \
|
|
|
|
!defined(_RSIZE_T)) || __has_feature(modules)
|
|
|
|
/* Always define rsize_t when modules are available. */
|
|
|
|
#if !__has_feature(modules)
|
|
|
|
#define _RSIZE_T
|
|
|
|
#endif
|
|
|
|
typedef __SIZE_TYPE__ rsize_t;
|
|
|
|
#endif
|
2015-01-18 16:23:48 +00:00
|
|
|
#endif /* defined(__need_STDDEF_H_misc) */
|
2013-06-10 20:45:12 +00:00
|
|
|
|
2014-11-24 09:15:30 +00:00
|
|
|
#if defined(__need_wchar_t)
|
2009-06-02 17:58:47 +00:00
|
|
|
#ifndef __cplusplus
|
2013-04-08 18:45:10 +00:00
|
|
|
/* Always define wchar_t when modules are available. */
|
|
|
|
#if !defined(_WCHAR_T) || __has_feature(modules)
|
|
|
|
#if !__has_feature(modules)
|
2010-03-10 17:45:58 +00:00
|
|
|
#define _WCHAR_T
|
2013-06-10 20:45:12 +00:00
|
|
|
#if defined(_MSC_EXTENSIONS)
|
|
|
|
#define _WCHAR_T_DEFINED
|
|
|
|
#endif
|
2013-04-08 18:45:10 +00:00
|
|
|
#endif
|
2010-09-17 15:54:40 +00:00
|
|
|
typedef __WCHAR_TYPE__ wchar_t;
|
2009-06-02 17:58:47 +00:00
|
|
|
#endif
|
2010-03-10 17:45:58 +00:00
|
|
|
#endif
|
2014-11-24 09:15:30 +00:00
|
|
|
#undef __need_wchar_t
|
|
|
|
#endif /* defined(__need_wchar_t) */
|
2009-06-02 17:58:47 +00:00
|
|
|
|
2014-11-24 09:15:30 +00:00
|
|
|
#if defined(__need_NULL)
|
2010-03-10 17:45:58 +00:00
|
|
|
#undef NULL
|
2009-06-02 17:58:47 +00:00
|
|
|
#ifdef __cplusplus
|
2012-08-15 20:02:54 +00:00
|
|
|
# if !defined(__MINGW32__) && !defined(_MSC_VER)
|
|
|
|
# define NULL __null
|
|
|
|
# else
|
|
|
|
# define NULL 0
|
|
|
|
# endif
|
2009-06-02 17:58:47 +00:00
|
|
|
#else
|
2012-08-15 20:02:54 +00:00
|
|
|
# define NULL ((void*)0)
|
|
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#if defined(_MSC_EXTENSIONS) && defined(_NATIVE_NULLPTR_SUPPORTED)
|
|
|
|
namespace std { typedef decltype(nullptr) nullptr_t; }
|
|
|
|
using ::std::nullptr_t;
|
|
|
|
#endif
|
2009-06-02 17:58:47 +00:00
|
|
|
#endif
|
2014-11-24 09:15:30 +00:00
|
|
|
#undef __need_NULL
|
|
|
|
#endif /* defined(__need_NULL) */
|
2009-06-02 17:58:47 +00:00
|
|
|
|
2015-01-18 16:23:48 +00:00
|
|
|
#if defined(__need_STDDEF_H_misc)
|
2014-11-24 09:15:30 +00:00
|
|
|
#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L
|
2015-01-18 16:23:48 +00:00
|
|
|
#include "__stddef_max_align_t.h"
|
2014-11-24 09:15:30 +00:00
|
|
|
#endif
|
|
|
|
#define offsetof(t, d) __builtin_offsetof(t, d)
|
2015-01-18 16:23:48 +00:00
|
|
|
#undef __need_STDDEF_H_misc
|
|
|
|
#endif /* defined(__need_STDDEF_H_misc) */
|
2011-02-20 13:06:31 +00:00
|
|
|
|
|
|
|
/* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use
|
2011-05-02 19:39:53 +00:00
|
|
|
__WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */
|
2011-02-20 13:06:31 +00:00
|
|
|
#if defined(__need_wint_t)
|
2013-04-08 18:45:10 +00:00
|
|
|
/* Always define wint_t when modules are available. */
|
|
|
|
#if !defined(_WINT_T) || __has_feature(modules)
|
|
|
|
#if !__has_feature(modules)
|
2011-02-20 13:06:31 +00:00
|
|
|
#define _WINT_T
|
2013-04-08 18:45:10 +00:00
|
|
|
#endif
|
2011-02-20 13:06:31 +00:00
|
|
|
typedef __WINT_TYPE__ wint_t;
|
2013-04-08 18:45:10 +00:00
|
|
|
#endif
|
2011-02-20 13:06:31 +00:00
|
|
|
#undef __need_wint_t
|
|
|
|
#endif /* __need_wint_t */
|
2014-11-24 09:15:30 +00:00
|
|
|
|
|
|
|
#endif
|