Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- cstddef ----------------------------------===// |
| 3 | // |
Howard Hinnant | c566dc3 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // |
Howard Hinnant | ee11c31 | 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 | c51e102 | 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 | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 21 | |
Howard Hinnant | c51e102 | 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 | cade1f7 | 2017-03-24 05:45:39 +0000 | [diff] [blame] | 31 | byte // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 32 | |
| 33 | } // std |
| 34 | |
| 35 | */ |
| 36 | |
| 37 | #include <__config> |
Marshall Clow | 0a1e750 | 2018-09-12 19:41:40 +0000 | [diff] [blame^] | 38 | #include <version> |
Howard Hinnant | 59ef87b | 2010-06-02 18:53:22 +0000 | [diff] [blame] | 39 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 40 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 41 | #pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 42 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 43 | |
Richard Smith | 523b172 | 2015-10-09 00:26:50 +0000 | [diff] [blame] | 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 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 48 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 49 | |
| 50 | using ::ptrdiff_t; |
| 51 | using ::size_t; |
| 52 | |
David L. Jones | 8465cf1 | 2017-02-10 01:27:42 +0000 | [diff] [blame] | 53 | #if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \ |
Kamil Rytarowski | 5678f1e | 2018-08-20 22:29:20 +0000 | [diff] [blame] | 54 | defined(__DEFINED_max_align_t) || defined(__NetBSD__) |
Chandler Carruth | 4dcf199 | 2014-02-21 08:37:30 +0000 | [diff] [blame] | 55 | // Re-use the compiler's <stddef.h> max_align_t where possible. |
| 56 | using ::max_align_t; |
| 57 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 58 | typedef long double max_align_t; |
Chandler Carruth | 4dcf199 | 2014-02-21 08:37:30 +0000 | [diff] [blame] | 59 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 60 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 61 | _LIBCPP_END_NAMESPACE_STD |
| 62 | |
Marshall Clow | cade1f7 | 2017-03-24 05:45:39 +0000 | [diff] [blame] | 63 | #if _LIBCPP_STD_VER > 14 |
| 64 | namespace std // purposefully not versioned |
| 65 | { |
| 66 | enum class byte : unsigned char {}; |
| 67 | |
Marshall Clow | cade1f7 | 2017-03-24 05:45:39 +0000 | [diff] [blame] | 68 | constexpr byte operator| (byte __lhs, byte __rhs) noexcept |
Marshall Clow | 31c8f46 | 2017-11-14 01:14:53 +0000 | [diff] [blame] | 69 | { |
Louis Dionne | 44bcff9 | 2018-08-03 22:36:53 +0000 | [diff] [blame] | 70 | return static_cast<byte>( |
| 71 | static_cast<unsigned char>( |
| 72 | static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs) |
| 73 | )); |
Marshall Clow | 31c8f46 | 2017-11-14 01:14:53 +0000 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept |
| 77 | { return __lhs = __lhs | __rhs; } |
| 78 | |
| 79 | constexpr byte operator& (byte __lhs, byte __rhs) noexcept |
| 80 | { |
Louis Dionne | 44bcff9 | 2018-08-03 22:36:53 +0000 | [diff] [blame] | 81 | return static_cast<byte>( |
| 82 | static_cast<unsigned char>( |
| 83 | static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs) |
| 84 | )); |
Marshall Clow | 31c8f46 | 2017-11-14 01:14:53 +0000 | [diff] [blame] | 85 | } |
Marshall Clow | cade1f7 | 2017-03-24 05:45:39 +0000 | [diff] [blame] | 86 | |
| 87 | constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept |
Marshall Clow | 31c8f46 | 2017-11-14 01:14:53 +0000 | [diff] [blame] | 88 | { return __lhs = __lhs & __rhs; } |
| 89 | |
| 90 | constexpr byte operator^ (byte __lhs, byte __rhs) noexcept |
| 91 | { |
Louis Dionne | 44bcff9 | 2018-08-03 22:36:53 +0000 | [diff] [blame] | 92 | return static_cast<byte>( |
| 93 | static_cast<unsigned char>( |
| 94 | static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs) |
| 95 | )); |
Marshall Clow | 31c8f46 | 2017-11-14 01:14:53 +0000 | [diff] [blame] | 96 | } |
Marshall Clow | cade1f7 | 2017-03-24 05:45:39 +0000 | [diff] [blame] | 97 | |
Louis Dionne | 44bcff9 | 2018-08-03 22:36:53 +0000 | [diff] [blame] | 98 | constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept |
Marshall Clow | 31c8f46 | 2017-11-14 01:14:53 +0000 | [diff] [blame] | 99 | { return __lhs = __lhs ^ __rhs; } |
Marshall Clow | cade1f7 | 2017-03-24 05:45:39 +0000 | [diff] [blame] | 100 | |
| 101 | constexpr byte operator~ (byte __b) noexcept |
Marshall Clow | 31c8f46 | 2017-11-14 01:14:53 +0000 | [diff] [blame] | 102 | { |
| 103 | return static_cast<byte>( |
| 104 | static_cast<unsigned char>( |
| 105 | ~static_cast<unsigned int>(__b) |
| 106 | )); |
| 107 | } |
Marshall Clow | cade1f7 | 2017-03-24 05:45:39 +0000 | [diff] [blame] | 108 | |
| 109 | } |
| 110 | |
| 111 | #include <type_traits> // rest of byte |
| 112 | #endif |
| 113 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 114 | #endif // _LIBCPP_CSTDDEF |