2008-05-20 21:34:26 +08:00
|
|
|
/*===---- stddef.h - Basic type definitions --------------------------------===
|
|
|
|
*
|
2019-04-09 04:51:30 +08:00
|
|
|
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
* See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2008-05-20 21:34:26 +08:00
|
|
|
*
|
|
|
|
*===-----------------------------------------------------------------------===
|
|
|
|
*/
|
|
|
|
|
2014-04-30 12:35:09 +08: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)
|
2014-10-03 08:31:35 +08:00
|
|
|
/* Always define miscellaneous pieces when modules are available. */
|
|
|
|
#if !__has_feature(modules)
|
2008-05-20 21:34:26 +08:00
|
|
|
#define __STDDEF_H
|
2014-10-03 08:31:35 +08:00
|
|
|
#endif
|
2014-04-30 12:35:09 +08:00
|
|
|
#define __need_ptrdiff_t
|
|
|
|
#define __need_size_t
|
|
|
|
#define __need_wchar_t
|
|
|
|
#define __need_NULL
|
2014-10-03 08:31:35 +08:00
|
|
|
#define __need_STDDEF_H_misc
|
2014-04-30 12:35:09 +08:00
|
|
|
/* __need_wint_t is intentionally not defined here. */
|
|
|
|
#endif
|
2008-05-20 21:34:26 +08:00
|
|
|
|
2014-04-30 12:35:09 +08:00
|
|
|
#if defined(__need_ptrdiff_t)
|
2013-03-22 08:10:49 +08:00
|
|
|
#if !defined(_PTRDIFF_T) || __has_feature(modules)
|
|
|
|
/* Always define ptrdiff_t when modules are available. */
|
|
|
|
#if !__has_feature(modules)
|
2011-03-31 05:43:52 +08:00
|
|
|
#define _PTRDIFF_T
|
2013-03-22 08:10:49 +08:00
|
|
|
#endif
|
2013-02-06 08:38:13 +08:00
|
|
|
typedef __PTRDIFF_TYPE__ ptrdiff_t;
|
2011-03-31 05:43:52 +08:00
|
|
|
#endif
|
2014-04-30 12:35:09 +08:00
|
|
|
#undef __need_ptrdiff_t
|
|
|
|
#endif /* defined(__need_ptrdiff_t) */
|
2013-03-22 08:10:49 +08:00
|
|
|
|
2014-04-30 12:35:09 +08:00
|
|
|
#if defined(__need_size_t)
|
2013-03-22 08:10:49 +08:00
|
|
|
#if !defined(_SIZE_T) || __has_feature(modules)
|
|
|
|
/* Always define size_t when modules are available. */
|
|
|
|
#if !__has_feature(modules)
|
2010-03-09 07:23:45 +08:00
|
|
|
#define _SIZE_T
|
2013-03-22 08:10:49 +08:00
|
|
|
#endif
|
2013-02-06 08:38:13 +08:00
|
|
|
typedef __SIZE_TYPE__ size_t;
|
2010-03-09 07:23:45 +08:00
|
|
|
#endif
|
2014-04-30 12:35:09 +08:00
|
|
|
#undef __need_size_t
|
|
|
|
#endif /*defined(__need_size_t) */
|
2013-03-22 08:10:49 +08:00
|
|
|
|
2014-10-03 08:31:35 +08:00
|
|
|
#if defined(__need_STDDEF_H_misc)
|
2013-05-02 18:36:31 +08:00
|
|
|
/* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is
|
2013-04-13 07:24:56 +08:00
|
|
|
* 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
|
2014-10-03 08:31:35 +08:00
|
|
|
#endif /* defined(__need_STDDEF_H_misc) */
|
2013-04-13 07:24:56 +08:00
|
|
|
|
2014-04-30 12:35:09 +08:00
|
|
|
#if defined(__need_wchar_t)
|
2008-05-20 21:34:26 +08:00
|
|
|
#ifndef __cplusplus
|
2013-03-22 08:10:49 +08:00
|
|
|
/* Always define wchar_t when modules are available. */
|
|
|
|
#if !defined(_WCHAR_T) || __has_feature(modules)
|
|
|
|
#if !__has_feature(modules)
|
2010-03-09 07:23:45 +08:00
|
|
|
#define _WCHAR_T
|
2013-05-02 21:12:32 +08:00
|
|
|
#if defined(_MSC_EXTENSIONS)
|
|
|
|
#define _WCHAR_T_DEFINED
|
|
|
|
#endif
|
2013-03-22 08:10:49 +08:00
|
|
|
#endif
|
2010-09-06 07:29:49 +08:00
|
|
|
typedef __WCHAR_TYPE__ wchar_t;
|
2008-05-20 21:34:26 +08:00
|
|
|
#endif
|
2010-03-09 07:23:45 +08:00
|
|
|
#endif
|
2014-04-30 12:35:09 +08:00
|
|
|
#undef __need_wchar_t
|
|
|
|
#endif /* defined(__need_wchar_t) */
|
2008-05-20 21:34:26 +08:00
|
|
|
|
2014-04-30 12:35:09 +08:00
|
|
|
#if defined(__need_NULL)
|
2010-03-09 07:23:45 +08:00
|
|
|
#undef NULL
|
2013-03-28 05:22:45 +08:00
|
|
|
#ifdef __cplusplus
|
2012-04-25 05:27:01 +08:00
|
|
|
# if !defined(__MINGW32__) && !defined(_MSC_VER)
|
|
|
|
# define NULL __null
|
|
|
|
# else
|
|
|
|
# define NULL 0
|
|
|
|
# endif
|
2008-11-04 14:53:14 +08:00
|
|
|
#else
|
2012-04-25 05:27:01 +08:00
|
|
|
# define NULL ((void*)0)
|
2008-11-04 14:53:14 +08:00
|
|
|
#endif
|
2012-06-30 02:28:41 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
#if defined(_MSC_EXTENSIONS) && defined(_NATIVE_NULLPTR_SUPPORTED)
|
|
|
|
namespace std { typedef decltype(nullptr) nullptr_t; }
|
|
|
|
using ::std::nullptr_t;
|
|
|
|
#endif
|
|
|
|
#endif
|
2014-04-30 12:35:09 +08:00
|
|
|
#undef __need_NULL
|
|
|
|
#endif /* defined(__need_NULL) */
|
|
|
|
|
2014-10-03 08:31:35 +08:00
|
|
|
#if defined(__need_STDDEF_H_misc)
|
2014-02-20 06:35:01 +08:00
|
|
|
#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L
|
2014-10-03 08:31:35 +08:00
|
|
|
#include "__stddef_max_align_t.h"
|
2014-03-05 07:43:48 +08:00
|
|
|
#endif
|
2008-05-20 21:34:26 +08:00
|
|
|
#define offsetof(t, d) __builtin_offsetof(t, d)
|
2014-10-03 08:31:35 +08:00
|
|
|
#undef __need_STDDEF_H_misc
|
|
|
|
#endif /* defined(__need_STDDEF_H_misc) */
|
2010-10-19 11:42:41 +08:00
|
|
|
|
|
|
|
/* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use
|
2011-04-15 13:22:18 +08:00
|
|
|
__WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */
|
2010-10-19 11:42:41 +08:00
|
|
|
#if defined(__need_wint_t)
|
2013-03-22 08:10:49 +08:00
|
|
|
/* Always define wint_t when modules are available. */
|
|
|
|
#if !defined(_WINT_T) || __has_feature(modules)
|
|
|
|
#if !__has_feature(modules)
|
2010-10-19 11:42:41 +08:00
|
|
|
#define _WINT_T
|
2013-03-22 08:10:49 +08:00
|
|
|
#endif
|
2010-10-19 11:42:41 +08:00
|
|
|
typedef __WINT_TYPE__ wint_t;
|
2013-03-22 08:10:49 +08:00
|
|
|
#endif
|
2010-10-19 11:42:41 +08:00
|
|
|
#undef __need_wint_t
|
|
|
|
#endif /* __need_wint_t */
|
2014-04-30 12:35:09 +08:00
|
|
|
|
|
|
|
#endif
|