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 byte // C++17 32 33} // std 34 35*/ 36 37#include <__config> 38#include <version> 39 40#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 41#pragma GCC system_header 42#endif 43 44// Don't include our own <stddef.h>; we don't want to declare ::nullptr_t. 45#include_next <stddef.h> 46#include <__nullptr> 47 48_LIBCPP_BEGIN_NAMESPACE_STD 49 50using ::ptrdiff_t; 51using ::size_t; 52 53#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \ 54 defined(__DEFINED_max_align_t) || defined(__NetBSD__) 55// Re-use the compiler's <stddef.h> max_align_t where possible. 56using ::max_align_t; 57#else 58typedef long double max_align_t; 59#endif 60 61_LIBCPP_END_NAMESPACE_STD 62 63#if _LIBCPP_STD_VER > 14 64namespace std // purposefully not versioned 65{ 66enum class byte : unsigned char {}; 67 68constexpr byte operator| (byte __lhs, byte __rhs) noexcept 69{ 70 return static_cast<byte>( 71 static_cast<unsigned char>( 72 static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs) 73 )); 74} 75 76constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept 77{ return __lhs = __lhs | __rhs; } 78 79constexpr byte operator& (byte __lhs, byte __rhs) noexcept 80{ 81 return static_cast<byte>( 82 static_cast<unsigned char>( 83 static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs) 84 )); 85} 86 87constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept 88{ return __lhs = __lhs & __rhs; } 89 90constexpr byte operator^ (byte __lhs, byte __rhs) noexcept 91{ 92 return static_cast<byte>( 93 static_cast<unsigned char>( 94 static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs) 95 )); 96} 97 98constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept 99{ return __lhs = __lhs ^ __rhs; } 100 101constexpr byte operator~ (byte __b) noexcept 102{ 103 return static_cast<byte>( 104 static_cast<unsigned char>( 105 ~static_cast<unsigned int>(__b) 106 )); 107} 108 109} 110 111#include <type_traits> // rest of byte 112#endif 113 114#endif // _LIBCPP_CSTDDEF 115