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 17Macros: 18 19 offsetof(type,member-designator) 20 NULL 21 22namespace std 23{ 24 25Types: 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#include <stddef.h> 39 40#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 41#pragma GCC system_header 42#endif 43 44_LIBCPP_BEGIN_NAMESPACE_STD 45 46using ::ptrdiff_t; 47using ::size_t; 48 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. 51using ::max_align_t; 52#elif defined(__ANDROID__) && !__LP64__ 53// If compiler doesn't have max_align_t (ie. clang), and it's on 32-bit Android, typedef max_align_t to 54// "long long" instead of "long double" because 32-bit Android treats "long double" the same as "double" 55// which is smaller than "long long" 56typedef long long max_align_t; 57#else 58typedef long double max_align_t; 59#endif 60 61#ifdef _LIBCPP_HAS_NO_NULLPTR 62 63struct _LIBCPP_TYPE_VIS_ONLY nullptr_t 64{ 65 void* __lx; 66 67 struct __nat {int __for_bool_;}; 68 69 _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {} 70 _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {} 71 72 _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;} 73 74 template <class _Tp> 75 _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR 76 operator _Tp* () const {return 0;} 77 78 template <class _Tp, class _Up> 79 _LIBCPP_ALWAYS_INLINE 80 operator _Tp _Up::* () const {return 0;} 81 82 friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} 83 friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} 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 true;} 86 friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, nullptr_t) {return false;} 87 friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, nullptr_t) {return true;} 88}; 89 90inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} 91 92#define nullptr _VSTD::__get_nullptr_t() 93 94#endif // _LIBCPP_HAS_NO_NULLPTR 95 96_LIBCPP_END_NAMESPACE_STD 97 98#ifndef _LIBCPP_HAS_NO_NULLPTR 99 100namespace std 101{ 102 typedef decltype(nullptr) nullptr_t; 103} 104 105#endif // _LIBCPP_HAS_NO_NULLPTR 106 107#endif // _LIBCPP_CSTDDEF 108