Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- cstddef ----------------------------------===// |
| 3 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_CSTDDEF |
| 12 | #define _LIBCPP_CSTDDEF |
| 13 | |
| 14 | /* |
| 15 | cstddef synopsis |
| 16 | |
| 17 | Macros: |
| 18 | |
| 19 | offsetof(type,member-designator) |
| 20 | NULL |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 21 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 22 | namespace std |
| 23 | { |
| 24 | |
| 25 | Types: |
| 26 | |
| 27 | ptrdiff_t |
| 28 | size_t |
| 29 | max_align_t |
| 30 | nullptr_t |
| 31 | |
| 32 | } // std |
| 33 | |
| 34 | */ |
| 35 | |
| 36 | #include <__config> |
Howard Hinnant | ed30e07 | 2010-06-02 18:53:22 +0000 | [diff] [blame] | 37 | |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 38 | #include <stddef.h> |
| 39 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 40 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 41 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 42 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 43 | |
| 44 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 45 | |
| 46 | using ::ptrdiff_t; |
| 47 | using ::size_t; |
| 48 | |
Chandler Carruth | f84f611 | 2014-02-21 08:37:30 +0000 | [diff] [blame] | 49 | #if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) |
| 50 | // Re-use the compiler's <stddef.h> max_align_t where possible. |
| 51 | using ::max_align_t; |
| 52 | #else |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 53 | typedef long double max_align_t; |
Chandler Carruth | f84f611 | 2014-02-21 08:37:30 +0000 | [diff] [blame] | 54 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 55 | |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 56 | #ifdef _LIBCPP_HAS_NO_NULLPTR |
| 57 | |
| 58 | struct _LIBCPP_TYPE_VIS_ONLY nullptr_t |
| 59 | { |
| 60 | void* __lx; |
| 61 | |
| 62 | struct __nat {int __for_bool_;}; |
| 63 | |
| 64 | _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {} |
| 65 | _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {} |
| 66 | |
| 67 | _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;} |
| 68 | |
| 69 | template <class _Tp> |
| 70 | _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR |
| 71 | operator _Tp* () const {return 0;} |
| 72 | |
| 73 | template <class _Tp, class _Up> |
| 74 | _LIBCPP_ALWAYS_INLINE |
| 75 | operator _Tp _Up::* () const {return 0;} |
| 76 | |
| 77 | friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} |
| 78 | friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} |
| 79 | friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, nullptr_t) {return false;} |
| 80 | friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, nullptr_t) {return true;} |
| 81 | friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, nullptr_t) {return false;} |
| 82 | friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, nullptr_t) {return true;} |
| 83 | }; |
| 84 | |
| 85 | inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} |
| 86 | |
| 87 | #define nullptr _VSTD::__get_nullptr_t() |
| 88 | |
| 89 | #endif // _LIBCPP_HAS_NO_NULLPTR |
| 90 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 91 | _LIBCPP_END_NAMESPACE_STD |
| 92 | |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 93 | #ifndef _LIBCPP_HAS_NO_NULLPTR |
| 94 | |
| 95 | namespace std |
| 96 | { |
| 97 | typedef decltype(nullptr) nullptr_t; |
| 98 | } |
| 99 | |
| 100 | #endif // _LIBCPP_HAS_NO_NULLPTR |
| 101 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 102 | #endif // _LIBCPP_CSTDDEF |