1 // -*- C++ -*- 2 //===--------------------------- cstddef ----------------------------------===// 3 // 4 // The LLVM Compiler Infrastructure 5 // 6 // This file is dual licensed under the MIT and the University of Illinois Open 7 // Source Licenses. See LICENSE.TXT for details. 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 21 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> 37 38 #ifdef __GLIBC__ 39 #define __need_NULL 40 #define __need_ptrdiff_t 41 #define __need_size_t 42 #endif // __GLIBC__ 43 44 #include <stddef.h> 45 46 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 47 #pragma GCC system_header 48 #endif 49 50 _LIBCPP_BEGIN_NAMESPACE_STD 51 52 using ::ptrdiff_t; 53 using ::size_t; 54 55 #if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) 56 // Re-use the compiler's <stddef.h> max_align_t where possible. 57 using ::max_align_t; 58 #else 59 typedef long double max_align_t; 60 #endif 61 62 #ifdef _LIBCPP_HAS_NO_NULLPTR 63 64 struct _LIBCPP_TYPE_VIS_ONLY nullptr_t 65 { 66 void* __lx; 67 68 struct __nat {int __for_bool_;}; 69 70 _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {} 71 _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {} 72 73 _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;} 74 75 template <class _Tp> 76 _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR 77 operator _Tp* () const {return 0;} 78 79 template <class _Tp, class _Up> 80 _LIBCPP_ALWAYS_INLINE 81 operator _Tp _Up::* () const {return 0;} 82 83 friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} 84 friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} 85 friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, nullptr_t) {return false;} 86 friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, nullptr_t) {return true;} 87 friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, nullptr_t) {return false;} 88 friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, nullptr_t) {return true;} 89 }; 90 91 inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} 92 93 #define nullptr _VSTD::__get_nullptr_t() 94 95 #endif // _LIBCPP_HAS_NO_NULLPTR 96 97 _LIBCPP_END_NAMESPACE_STD 98 99 #ifndef _LIBCPP_HAS_NO_NULLPTR 100 101 namespace std 102 { 103 typedef decltype(nullptr) nullptr_t; 104 } 105 106 #endif // _LIBCPP_HAS_NO_NULLPTR 107 108 #endif // _LIBCPP_CSTDDEF 109