annotate libcxx/include/cstddef @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1f2b6ac9f198
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // -*- C++ -*-
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
2 //===----------------------------------------------------------------------===//
150
anatofuz
parents:
diff changeset
3 //
anatofuz
parents:
diff changeset
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
5 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
7 //
anatofuz
parents:
diff changeset
8 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 #ifndef _LIBCPP_CSTDDEF
anatofuz
parents:
diff changeset
11 #define _LIBCPP_CSTDDEF
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 /*
anatofuz
parents:
diff changeset
14 cstddef synopsis
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 Macros:
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 offsetof(type,member-designator)
anatofuz
parents:
diff changeset
19 NULL
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 namespace std
anatofuz
parents:
diff changeset
22 {
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 Types:
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 ptrdiff_t
anatofuz
parents:
diff changeset
27 size_t
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
28 max_align_t // C++11
150
anatofuz
parents:
diff changeset
29 nullptr_t
anatofuz
parents:
diff changeset
30 byte // C++17
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 } // std
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 */
anatofuz
parents:
diff changeset
35
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
36 #include <__assert> // all public C++ headers provide the assertion handler
150
anatofuz
parents:
diff changeset
37 #include <__config>
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
38 #include <__type_traits/enable_if.h>
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
39 #include <__type_traits/integral_constant.h>
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
40 #include <__type_traits/is_integral.h>
150
anatofuz
parents:
diff changeset
41 #include <version>
anatofuz
parents:
diff changeset
42
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
43 #include <stddef.h>
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
44
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
45 #ifndef _LIBCPP_STDDEF_H
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
46 # error <cstddef> tried including <stddef.h> but didn't find libc++'s <stddef.h> header. \
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
47 This usually means that your header search paths are not configured properly. \
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
48 The header search paths should contain the C++ Standard Library headers before \
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
49 any C Standard Library, and you are probably using compiler flags that make that \
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
50 not be the case.
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
51 #endif
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
52
150
anatofuz
parents:
diff changeset
53 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
54 # pragma GCC system_header
150
anatofuz
parents:
diff changeset
55 #endif
anatofuz
parents:
diff changeset
56
anatofuz
parents:
diff changeset
57 _LIBCPP_BEGIN_NAMESPACE_STD
anatofuz
parents:
diff changeset
58
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
59 using ::nullptr_t;
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
60 using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
61 using ::size_t _LIBCPP_USING_IF_EXISTS;
150
anatofuz
parents:
diff changeset
62
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
63 #if !defined(_LIBCPP_CXX03_LANG)
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
64 using ::max_align_t _LIBCPP_USING_IF_EXISTS;
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
65 #endif
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
66
150
anatofuz
parents:
diff changeset
67 _LIBCPP_END_NAMESPACE_STD
anatofuz
parents:
diff changeset
68
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
69 #if _LIBCPP_STD_VER >= 17
150
anatofuz
parents:
diff changeset
70 namespace std // purposefully not versioned
anatofuz
parents:
diff changeset
71 {
anatofuz
parents:
diff changeset
72 enum class byte : unsigned char {};
anatofuz
parents:
diff changeset
73
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
74 _LIBCPP_HIDE_FROM_ABI constexpr byte operator| (byte __lhs, byte __rhs) noexcept
150
anatofuz
parents:
diff changeset
75 {
anatofuz
parents:
diff changeset
76 return static_cast<byte>(
anatofuz
parents:
diff changeset
77 static_cast<unsigned char>(
anatofuz
parents:
diff changeset
78 static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs)
anatofuz
parents:
diff changeset
79 ));
anatofuz
parents:
diff changeset
80 }
anatofuz
parents:
diff changeset
81
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
82 _LIBCPP_HIDE_FROM_ABI constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
150
anatofuz
parents:
diff changeset
83 { return __lhs = __lhs | __rhs; }
anatofuz
parents:
diff changeset
84
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
85 _LIBCPP_HIDE_FROM_ABI constexpr byte operator& (byte __lhs, byte __rhs) noexcept
150
anatofuz
parents:
diff changeset
86 {
anatofuz
parents:
diff changeset
87 return static_cast<byte>(
anatofuz
parents:
diff changeset
88 static_cast<unsigned char>(
anatofuz
parents:
diff changeset
89 static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs)
anatofuz
parents:
diff changeset
90 ));
anatofuz
parents:
diff changeset
91 }
anatofuz
parents:
diff changeset
92
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
93 _LIBCPP_HIDE_FROM_ABI constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
150
anatofuz
parents:
diff changeset
94 { return __lhs = __lhs & __rhs; }
anatofuz
parents:
diff changeset
95
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
96 _LIBCPP_HIDE_FROM_ABI constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
150
anatofuz
parents:
diff changeset
97 {
anatofuz
parents:
diff changeset
98 return static_cast<byte>(
anatofuz
parents:
diff changeset
99 static_cast<unsigned char>(
anatofuz
parents:
diff changeset
100 static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs)
anatofuz
parents:
diff changeset
101 ));
anatofuz
parents:
diff changeset
102 }
anatofuz
parents:
diff changeset
103
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
104 _LIBCPP_HIDE_FROM_ABI constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
150
anatofuz
parents:
diff changeset
105 { return __lhs = __lhs ^ __rhs; }
anatofuz
parents:
diff changeset
106
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
107 _LIBCPP_HIDE_FROM_ABI constexpr byte operator~ (byte __b) noexcept
150
anatofuz
parents:
diff changeset
108 {
anatofuz
parents:
diff changeset
109 return static_cast<byte>(
anatofuz
parents:
diff changeset
110 static_cast<unsigned char>(
anatofuz
parents:
diff changeset
111 ~static_cast<unsigned int>(__b)
anatofuz
parents:
diff changeset
112 ));
anatofuz
parents:
diff changeset
113 }
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
114
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
115 template <class _Tp>
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
116 using _EnableByteOverload = __enable_if_t<is_integral<_Tp>::value, byte>;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
117
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
118 template <class _Integer>
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
119 _LIBCPP_HIDE_FROM_ABI constexpr _EnableByteOverload<_Integer> &
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
120 operator<<=(byte& __lhs, _Integer __shift) noexcept
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
121 { return __lhs = __lhs << __shift; }
150
anatofuz
parents:
diff changeset
122
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
123 template <class _Integer>
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
124 _LIBCPP_HIDE_FROM_ABI constexpr _EnableByteOverload<_Integer>
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
125 operator<< (byte __lhs, _Integer __shift) noexcept
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
126 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
127
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
128 template <class _Integer>
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
129 _LIBCPP_HIDE_FROM_ABI constexpr _EnableByteOverload<_Integer> &
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
130 operator>>=(byte& __lhs, _Integer __shift) noexcept
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
131 { return __lhs = __lhs >> __shift; }
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
132
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
133 template <class _Integer>
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
134 _LIBCPP_HIDE_FROM_ABI constexpr _EnableByteOverload<_Integer>
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
135 operator>> (byte __lhs, _Integer __shift) noexcept
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
136 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
137
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
138 template <class _Integer, class = _EnableByteOverload<_Integer> >
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
139 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Integer
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
140 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
141
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
142 } // namespace std
150
anatofuz
parents:
diff changeset
143
anatofuz
parents:
diff changeset
144 #endif
anatofuz
parents:
diff changeset
145
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
146 #endif // _LIBCPP_CSTDDEF