libstdc++
stdatomic.h
Go to the documentation of this file.
1 // C compatibility header <stdatomic.h> -*- C++ -*-
2 
3 // Copyright The GNU Toolchain Authors.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19 
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24 
25 /** @file include/stdatomic.h
26  * This is a Standard C++ Library header.
27  */
28 
29 #ifndef _GLIBCXX_STDATOMIC_H
30 #define _GLIBCXX_STDATOMIC_H
31 
32 #if __cplusplus > 202002L
33 #include <atomic>
34 
35 #define __cpp_lib_stdatomic_h 202011L
36 
37 #define _Atomic(_Tp) std::atomic<_Tp>
38 
39 using std::memory_order;
40 using std::memory_order_relaxed;
41 using std::memory_order_consume;
42 using std::memory_order_acquire;
43 using std::memory_order_release;
44 using std::memory_order_acq_rel;
45 using std::memory_order_seq_cst;
46 using std::atomic_flag;
47 using std::atomic_bool;
48 using std::atomic_char;
49 using std::atomic_schar;
50 using std::atomic_uchar;
51 using std::atomic_short;
52 using std::atomic_ushort;
53 using std::atomic_int;
54 using std::atomic_uint;
55 using std::atomic_long;
56 using std::atomic_ulong;
57 using std::atomic_llong;
58 using std::atomic_ullong;
59 #ifdef _GLIBCXX_USE_CHAR8_T
60 using std::atomic_char8_t;
61 #endif
65 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
66 using std::atomic_int8_t;
90 #endif
93 using std::atomic_size_t;
95 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
98 #endif
100 using std::atomic_load;
102 using std::atomic_store;
110 using std::atomic_fetch_add;
111 using std::atomic_fetch_add_explicit;
112 using std::atomic_fetch_sub;
113 using std::atomic_fetch_sub_explicit;
114 using std::atomic_fetch_or;
115 using std::atomic_fetch_or_explicit;
116 using std::atomic_fetch_xor;
117 using std::atomic_fetch_xor_explicit;
118 using std::atomic_fetch_and;
119 using std::atomic_fetch_and_explicit;
120 using std::atomic_flag_test_and_set;
121 using std::atomic_flag_test_and_set_explicit;
122 using std::atomic_flag_clear;
123 using std::atomic_flag_clear_explicit;
124 using std::atomic_thread_fence;
125 using std::atomic_signal_fence;
126 
127 #elif defined __clang__
128 # include_next <stdatomic.h>
129 #endif // C++23
130 #endif // _GLIBCXX_STDATOMIC_H
atomic< unsigned long > atomic_ulong
atomic_ulong
Definition: atomic:1084
__shared_ptr< _Tp, _Lp > atomic_load_explicit(const __shared_ptr< _Tp, _Lp > *__p, memory_order)
Atomic load for shared_ptr objects.
atomic< int_least8_t > atomic_int_least8_t
atomic_int_least8_t
Definition: atomic:1136
memory_order
Enumeration for memory_order.
Definition: atomic_base.h:62
atomic< int_fast32_t > atomic_int_fast32_t
atomic_int_fast32_t
Definition: atomic:1173
atomic< int8_t > atomic_int8_t
atomic_int8_t
Definition: atomic:1111
atomic< ptrdiff_t > atomic_ptrdiff_t
atomic_ptrdiff_t
Definition: atomic:1196
atomic< uint32_t > atomic_uint32_t
atomic_uint32_t
Definition: atomic:1126
bool atomic_compare_exchange_weak_explicit(__shared_ptr< _Tp, _Lp > *__p, __shared_ptr< _Tp, _Lp > *__v, __shared_ptr< _Tp, _Lp > __w, memory_order __success, memory_order __failure)
Atomic compare-and-swap for shared_ptr objects.
atomic< size_t > atomic_size_t
atomic_size_t
Definition: atomic:1193
atomic< char > atomic_char
atomic_char
Definition: atomic:1060
atomic< int32_t > atomic_int32_t
atomic_int32_t
Definition: atomic:1123
atomic< unsigned short > atomic_ushort
atomic_ushort
Definition: atomic:1072
atomic< uintptr_t > atomic_uintptr_t
atomic_uintptr_t
Definition: atomic:1190
atomic< uint_least8_t > atomic_uint_least8_t
atomic_uint_least8_t
Definition: atomic:1139
atomic< uint64_t > atomic_uint64_t
atomic_uint64_t
Definition: atomic:1132
bool atomic_compare_exchange_strong_explicit(__shared_ptr< _Tp, _Lp > *__p, __shared_ptr< _Tp, _Lp > *__v, __shared_ptr< _Tp, _Lp > __w, memory_order, memory_order)
Atomic compare-and-swap for shared_ptr objects.
atomic< uint_least16_t > atomic_uint_least16_t
atomic_uint_least16_t
Definition: atomic:1145
void atomic_store_explicit(__shared_ptr< _Tp, _Lp > *__p, __shared_ptr< _Tp, _Lp > __r, memory_order)
Atomic store for shared_ptr objects.
atomic< intmax_t > atomic_intmax_t
atomic_intmax_t
Definition: atomic:1200
atomic< uintmax_t > atomic_uintmax_t
atomic_uintmax_t
Definition: atomic:1203
__shared_ptr< _Tp, _Lp > atomic_exchange(__shared_ptr< _Tp, _Lp > *__p, __shared_ptr< _Tp, _Lp > __r)
Atomic exchange for shared_ptr objects.
atomic< uint16_t > atomic_uint16_t
atomic_uint16_t
Definition: atomic:1120
atomic< uint8_t > atomic_uint8_t
atomic_uint8_t
Definition: atomic:1114
atomic< short > atomic_short
atomic_short
Definition: atomic:1069
atomic< wchar_t > atomic_wchar_t
atomic_wchar_t
Definition: atomic:1093
atomic_flag
Definition: atomic_base.h:212
bool atomic_is_lock_free(const shared_ptr< _Tp > *__p)
Report whether shared_ptr atomic operations are lock-free.
atomic< signed char > atomic_schar
atomic_schar
Definition: atomic:1063
atomic< char16_t > atomic_char16_t
atomic_char16_t
Definition: atomic:1101
atomic< uint_fast8_t > atomic_uint_fast8_t
atomic_uint_fast8_t
Definition: atomic:1164
atomic< uint_least64_t > atomic_uint_least64_t
atomic_uint_least64_t
Definition: atomic:1157
atomic< long > atomic_long
atomic_long
Definition: atomic:1081
void atomic_store(__shared_ptr< _Tp, _Lp > *__p, __shared_ptr< _Tp, _Lp > __r)
Atomic store for shared_ptr objects.
__shared_ptr< _Tp, _Lp > atomic_exchange_explicit(__shared_ptr< _Tp, _Lp > *__p, __shared_ptr< _Tp, _Lp > __r, memory_order)
Atomic exchange for shared_ptr objects.
bool atomic_compare_exchange_weak(__shared_ptr< _Tp, _Lp > *__p, __shared_ptr< _Tp, _Lp > *__v, __shared_ptr< _Tp, _Lp > __w)
Atomic compare-and-swap for shared_ptr objects.
atomic< int_least32_t > atomic_int_least32_t
atomic_int_least32_t
Definition: atomic:1148
atomic< int_least16_t > atomic_int_least16_t
atomic_int_least16_t
Definition: atomic:1142
atomic< uint_fast16_t > atomic_uint_fast16_t
atomic_uint_fast16_t
Definition: atomic:1170
__shared_ptr< _Tp, _Lp > atomic_load(const __shared_ptr< _Tp, _Lp > *__p)
Atomic load for shared_ptr objects.
atomic< int_least64_t > atomic_int_least64_t
atomic_int_least64_t
Definition: atomic:1154
bool atomic_compare_exchange_strong(__shared_ptr< _Tp, _Lp > *__p, __shared_ptr< _Tp, _Lp > *__v, __shared_ptr< _Tp, _Lp > __w)
Atomic compare-and-swap for shared_ptr objects.
atomic< intptr_t > atomic_intptr_t
atomic_intptr_t
Definition: atomic:1187
atomic< unsigned char > atomic_uchar
atomic_uchar
Definition: atomic:1066
atomic< int64_t > atomic_int64_t
atomic_int64_t
Definition: atomic:1129
atomic< int_fast8_t > atomic_int_fast8_t
atomic_int_fast8_t
Definition: atomic:1161
atomic< long long > atomic_llong
atomic_llong
Definition: atomic:1087
atomic< int > atomic_int
atomic_int
Definition: atomic:1075
atomic< uint_least32_t > atomic_uint_least32_t
atomic_uint_least32_t
Definition: atomic:1151
atomic< unsigned int > atomic_uint
atomic_uint
Definition: atomic:1078
atomic< int_fast16_t > atomic_int_fast16_t
atomic_int_fast16_t
Definition: atomic:1167
atomic< int16_t > atomic_int16_t
atomic_int16_t
Definition: atomic:1117
atomic< unsigned long long > atomic_ullong
atomic_ullong
Definition: atomic:1090
atomic< char32_t > atomic_char32_t
atomic_char32_t
Definition: atomic:1104
atomic< int_fast64_t > atomic_int_fast64_t
atomic_int_fast64_t
Definition: atomic:1179
atomic< bool > atomic_bool
atomic_bool
Definition: atomic:1057
atomic< uint_fast32_t > atomic_uint_fast32_t
atomic_uint_fast32_t
Definition: atomic:1176
atomic< uint_fast64_t > atomic_uint_fast64_t
atomic_uint_fast64_t
Definition: atomic:1182