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 |
Marshall Clow | 21ae16e | 2017-03-24 05:45:39 +0000 | [diff] [blame] | 31 | byte // C++17 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 32 | |
| 33 | } // std |
| 34 | |
| 35 | */ |
| 36 | |
| 37 | #include <__config> |
Howard Hinnant | ed30e07 | 2010-06-02 18:53:22 +0000 | [diff] [blame] | 38 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 39 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 40 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 41 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 42 | |
Richard Smith | 45bae0b | 2015-10-09 00:26:50 +0000 | [diff] [blame] | 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 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 47 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 48 | |
| 49 | using ::ptrdiff_t; |
| 50 | using ::size_t; |
| 51 | |
David L. Jones | 917331c | 2017-02-10 01:27:42 +0000 | [diff] [blame] | 52 | #if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \ |
| 53 | defined(__DEFINED_max_align_t) |
Chandler Carruth | f84f611 | 2014-02-21 08:37:30 +0000 | [diff] [blame] | 54 | // Re-use the compiler's <stddef.h> max_align_t where possible. |
| 55 | using ::max_align_t; |
| 56 | #else |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 57 | typedef long double max_align_t; |
Chandler Carruth | f84f611 | 2014-02-21 08:37:30 +0000 | [diff] [blame] | 58 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 59 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 60 | _LIBCPP_END_NAMESPACE_STD |
| 61 | |
Marshall Clow | 21ae16e | 2017-03-24 05:45:39 +0000 | [diff] [blame] | 62 | #if _LIBCPP_STD_VER > 14 |
| 63 | namespace std // purposefully not versioned |
| 64 | { |
| 65 | enum class byte : unsigned char {}; |
| 66 | |
Marshall Clow | 21ae16e | 2017-03-24 05:45:39 +0000 | [diff] [blame] | 67 | constexpr byte operator| (byte __lhs, byte __rhs) noexcept |
Marshall Clow | 5272877 | 2017-11-14 01:14:53 +0000 | [diff] [blame] | 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 | } |
Marshall Clow | 21ae16e | 2017-03-24 05:45:39 +0000 | [diff] [blame] | 85 | |
| 86 | constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept |
Marshall Clow | 5272877 | 2017-11-14 01:14:53 +0000 | [diff] [blame] | 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 | } |
Marshall Clow | 21ae16e | 2017-03-24 05:45:39 +0000 | [diff] [blame] | 96 | |
| 97 | constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept |
Marshall Clow | 5272877 | 2017-11-14 01:14:53 +0000 | [diff] [blame] | 98 | { return __lhs = __lhs ^ __rhs; } |
Marshall Clow | 21ae16e | 2017-03-24 05:45:39 +0000 | [diff] [blame] | 99 | |
| 100 | constexpr byte operator~ (byte __b) noexcept |
Marshall Clow | 5272877 | 2017-11-14 01:14:53 +0000 | [diff] [blame] | 101 | { |
| 102 | return static_cast<byte>( |
| 103 | static_cast<unsigned char>( |
| 104 | ~static_cast<unsigned int>(__b) |
| 105 | )); |
| 106 | } |
Marshall Clow | 21ae16e | 2017-03-24 05:45:39 +0000 | [diff] [blame] | 107 | |
| 108 | } |
| 109 | |
| 110 | #include <type_traits> // rest of byte |
| 111 | #endif |
| 112 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 113 | #endif // _LIBCPP_CSTDDEF |