You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

182 lines
6.1KB

  1. // -*- C++ -*- forwarding header.
  2. // Copyright (C) 1997-2020 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /** @file cstddef
  21. * This is a Standard C++ Library file. You should @c \#include this file
  22. * in your programs, rather than any of the @a *.h implementation files.
  23. *
  24. * This is the C++ version of the Standard C Library header @c stddef.h,
  25. * and its contents are (mostly) the same as that header, but are all
  26. * contained in the namespace @c std (except for names which are defined
  27. * as macros in C).
  28. */
  29. //
  30. // ISO C++ 14882: 18.1 Types
  31. //
  32. #ifndef _GLIBCXX_CSTDDEF
  33. #define _GLIBCXX_CSTDDEF 1
  34. #pragma GCC system_header
  35. #undef __need_wchar_t
  36. #undef __need_ptrdiff_t
  37. #undef __need_size_t
  38. #undef __need_NULL
  39. #undef __need_wint_t
  40. #include <bits/c++config.h>
  41. #include <stddef.h>
  42. extern "C++"
  43. {
  44. #if __cplusplus >= 201103L
  45. namespace std
  46. {
  47. // We handle size_t, ptrdiff_t, and nullptr_t in c++config.h.
  48. using ::max_align_t;
  49. }
  50. #endif // C++11
  51. #if __cplusplus >= 201703L
  52. namespace std
  53. {
  54. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  55. #define __cpp_lib_byte 201603
  56. /// std::byte
  57. enum class byte : unsigned char {};
  58. template<typename _IntegerType> struct __byte_operand { };
  59. template<> struct __byte_operand<bool> { using __type = byte; };
  60. template<> struct __byte_operand<char> { using __type = byte; };
  61. template<> struct __byte_operand<signed char> { using __type = byte; };
  62. template<> struct __byte_operand<unsigned char> { using __type = byte; };
  63. #ifdef _GLIBCXX_USE_WCHAR_T
  64. template<> struct __byte_operand<wchar_t> { using __type = byte; };
  65. #endif
  66. #ifdef _GLIBCXX_USE_CHAR8_T
  67. template<> struct __byte_operand<char8_t> { using __type = byte; };
  68. #endif
  69. template<> struct __byte_operand<char16_t> { using __type = byte; };
  70. template<> struct __byte_operand<char32_t> { using __type = byte; };
  71. template<> struct __byte_operand<short> { using __type = byte; };
  72. template<> struct __byte_operand<unsigned short> { using __type = byte; };
  73. template<> struct __byte_operand<int> { using __type = byte; };
  74. template<> struct __byte_operand<unsigned int> { using __type = byte; };
  75. template<> struct __byte_operand<long> { using __type = byte; };
  76. template<> struct __byte_operand<unsigned long> { using __type = byte; };
  77. template<> struct __byte_operand<long long> { using __type = byte; };
  78. template<> struct __byte_operand<unsigned long long> { using __type = byte; };
  79. #if defined(__GLIBCXX_TYPE_INT_N_0)
  80. template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_0>
  81. { using __type = byte; };
  82. template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_0>
  83. { using __type = byte; };
  84. #endif
  85. #if defined(__GLIBCXX_TYPE_INT_N_1)
  86. template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_1>
  87. { using __type = byte; };
  88. template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_1>
  89. { using __type = byte; };
  90. #endif
  91. #if defined(__GLIBCXX_TYPE_INT_N_2)
  92. template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_2>
  93. { using __type = byte; };
  94. template<> struct __byte_operand<unsigned __GLIBCXX_TYPE_INT_N_2>
  95. { using __type = byte; };
  96. #endif
  97. template<typename _IntegerType>
  98. struct __byte_operand<const _IntegerType>
  99. : __byte_operand<_IntegerType> { };
  100. template<typename _IntegerType>
  101. struct __byte_operand<volatile _IntegerType>
  102. : __byte_operand<_IntegerType> { };
  103. template<typename _IntegerType>
  104. struct __byte_operand<const volatile _IntegerType>
  105. : __byte_operand<_IntegerType> { };
  106. template<typename _IntegerType>
  107. using __byte_op_t = typename __byte_operand<_IntegerType>::__type;
  108. template<typename _IntegerType>
  109. constexpr __byte_op_t<_IntegerType>
  110. operator<<(byte __b, _IntegerType __shift) noexcept
  111. { return (byte)(unsigned char)((unsigned)__b << __shift); }
  112. template<typename _IntegerType>
  113. constexpr __byte_op_t<_IntegerType>
  114. operator>>(byte __b, _IntegerType __shift) noexcept
  115. { return (byte)(unsigned char)((unsigned)__b >> __shift); }
  116. constexpr byte
  117. operator|(byte __l, byte __r) noexcept
  118. { return (byte)(unsigned char)((unsigned)__l | (unsigned)__r); }
  119. constexpr byte
  120. operator&(byte __l, byte __r) noexcept
  121. { return (byte)(unsigned char)((unsigned)__l & (unsigned)__r); }
  122. constexpr byte
  123. operator^(byte __l, byte __r) noexcept
  124. { return (byte)(unsigned char)((unsigned)__l ^ (unsigned)__r); }
  125. constexpr byte
  126. operator~(byte __b) noexcept
  127. { return (byte)(unsigned char)~(unsigned)__b; }
  128. template<typename _IntegerType>
  129. constexpr __byte_op_t<_IntegerType>&
  130. operator<<=(byte& __b, _IntegerType __shift) noexcept
  131. { return __b = __b << __shift; }
  132. template<typename _IntegerType>
  133. constexpr __byte_op_t<_IntegerType>&
  134. operator>>=(byte& __b, _IntegerType __shift) noexcept
  135. { return __b = __b >> __shift; }
  136. constexpr byte&
  137. operator|=(byte& __l, byte __r) noexcept
  138. { return __l = __l | __r; }
  139. constexpr byte&
  140. operator&=(byte& __l, byte __r) noexcept
  141. { return __l = __l & __r; }
  142. constexpr byte&
  143. operator^=(byte& __l, byte __r) noexcept
  144. { return __l = __l ^ __r; }
  145. template<typename _IntegerType>
  146. constexpr _IntegerType
  147. to_integer(__byte_op_t<_IntegerType> __b) noexcept
  148. { return _IntegerType(__b); }
  149. _GLIBCXX_END_NAMESPACE_VERSION
  150. } // namespace std
  151. #endif // C++17
  152. } // extern "C++"
  153. #endif // _GLIBCXX_CSTDDEF