| 1 | // -*- C++ -*- | 
| 2 | //===--------------------------- cstddef ----------------------------------===// | 
| 3 | // | 
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | 
| 5 | // See https://llvm.org/LICENSE.txt for license information. | 
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | 
| 7 | // | 
| 8 | //===----------------------------------------------------------------------===// | 
| 9 |  | 
| 10 | #ifndef _LIBCPP_CSTDDEF | 
| 11 | #define _LIBCPP_CSTDDEF | 
| 12 |  | 
| 13 | /* | 
| 14 |     cstddef synopsis | 
| 15 |  | 
| 16 | Macros: | 
| 17 |  | 
| 18 |     offsetof(type,member-designator) | 
| 19 |     NULL | 
| 20 |  | 
| 21 | namespace std | 
| 22 | { | 
| 23 |  | 
| 24 | Types: | 
| 25 |  | 
| 26 |     ptrdiff_t | 
| 27 |     size_t | 
| 28 |     max_align_t | 
| 29 |     nullptr_t | 
| 30 |     byte // C++17 | 
| 31 |  | 
| 32 | }  // std | 
| 33 |  | 
| 34 | */ | 
| 35 |  | 
| 36 | #include <__config> | 
| 37 | #include <version> | 
| 38 |  | 
| 39 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 
| 40 | #pragma GCC system_header | 
| 41 | #endif | 
| 42 |  | 
| 43 | // Don't include our own <stddef.h>; we don't want to declare ::nullptr_t. | 
| 44 | #include_next <stddef.h> | 
| 45 | #include <__nullptr> | 
| 46 |  | 
| 47 | _LIBCPP_BEGIN_NAMESPACE_STD | 
| 48 |  | 
| 49 | using ::ptrdiff_t; | 
| 50 | using ::size_t; | 
| 51 |  | 
| 52 | #if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \ | 
| 53 |     defined(__DEFINED_max_align_t) || defined(__NetBSD__) | 
| 54 | // Re-use the compiler's <stddef.h> max_align_t where possible. | 
| 55 | using ::max_align_t; | 
| 56 | #else | 
| 57 | typedef long double max_align_t; | 
| 58 | #endif | 
| 59 |  | 
| 60 | _LIBCPP_END_NAMESPACE_STD | 
| 61 |  | 
| 62 | #if _LIBCPP_STD_VER > 14 | 
| 63 | namespace std  // purposefully not versioned | 
| 64 | { | 
| 65 | enum class byte : unsigned char {}; | 
| 66 |  | 
| 67 | constexpr byte  operator| (byte  __lhs, byte __rhs) noexcept | 
| 68 | { | 
| 69 |     return static_cast<byte>( | 
| 70 |       static_cast<unsigned char>( | 
| 71 |          static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs) | 
| 72 |     )); | 
| 73 | } | 
| 74 |  | 
| 75 | constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept | 
| 76 | { return __lhs = __lhs | __rhs; } | 
| 77 |  | 
| 78 | constexpr byte  operator& (byte  __lhs, byte __rhs) noexcept | 
| 79 | { | 
| 80 |     return static_cast<byte>( | 
| 81 |       static_cast<unsigned char>( | 
| 82 |          static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs) | 
| 83 |     )); | 
| 84 | } | 
| 85 |  | 
| 86 | constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept | 
| 87 | { return __lhs = __lhs & __rhs; } | 
| 88 |  | 
| 89 | constexpr byte  operator^ (byte  __lhs, byte __rhs) noexcept | 
| 90 | { | 
| 91 |     return static_cast<byte>( | 
| 92 |       static_cast<unsigned char>( | 
| 93 |          static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs) | 
| 94 |     )); | 
| 95 | } | 
| 96 |  | 
| 97 | constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept | 
| 98 | { return __lhs = __lhs ^ __rhs; } | 
| 99 |  | 
| 100 | constexpr byte  operator~ (byte __b) noexcept | 
| 101 | { | 
| 102 |     return static_cast<byte>( | 
| 103 |       static_cast<unsigned char>( | 
| 104 |         ~static_cast<unsigned int>(__b) | 
| 105 |     )); | 
| 106 | } | 
| 107 |  | 
| 108 | } | 
| 109 |  | 
| 110 | #include <type_traits>  // rest of byte | 
| 111 | #endif | 
| 112 |  | 
| 113 | #endif  // _LIBCPP_CSTDDEF | 
| 114 |  |