32 #ifndef _GLIBCXX_ATOMIC
33 #define _GLIBCXX_ATOMIC 1
35 #pragma GCC system_header
37 #if __cplusplus < 201103L
43 namespace std _GLIBCXX_VISIBILITY(default)
45 _GLIBCXX_BEGIN_NAMESPACE_VERSION
52 #if __cplusplus >= 201703L
53 # define __cpp_lib_atomic_is_always_lock_free 201603
56 template<
typename _Tp>
64 using value_type = bool;
70 atomic() noexcept =
default;
71 ~
atomic() noexcept =
default;
76 constexpr
atomic(
bool __i) noexcept : _M_base(__i) { }
79 operator=(
bool __i) noexcept
80 {
return _M_base.operator=(__i); }
83 operator=(
bool __i)
volatile noexcept
84 {
return _M_base.operator=(__i); }
86 operator bool()
const noexcept
87 {
return _M_base.load(); }
89 operator bool()
const volatile noexcept
90 {
return _M_base.load(); }
93 is_lock_free()
const noexcept {
return _M_base.is_lock_free(); }
96 is_lock_free()
const volatile noexcept {
return _M_base.is_lock_free(); }
98 #if __cplusplus >= 201703L
103 store(
bool __i,
memory_order __m = memory_order_seq_cst) noexcept
104 { _M_base.store(__i, __m); }
107 store(
bool __i,
memory_order __m = memory_order_seq_cst)
volatile noexcept
108 { _M_base.store(__i, __m); }
111 load(
memory_order __m = memory_order_seq_cst)
const noexcept
112 {
return _M_base.load(__m); }
115 load(
memory_order __m = memory_order_seq_cst)
const volatile noexcept
116 {
return _M_base.load(__m); }
119 exchange(
bool __i,
memory_order __m = memory_order_seq_cst) noexcept
120 {
return _M_base.exchange(__i, __m); }
124 memory_order __m = memory_order_seq_cst)
volatile noexcept
125 {
return _M_base.exchange(__i, __m); }
128 compare_exchange_weak(
bool& __i1,
bool __i2,
memory_order __m1,
130 {
return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); }
133 compare_exchange_weak(
bool& __i1,
bool __i2,
memory_order __m1,
135 {
return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); }
138 compare_exchange_weak(
bool& __i1,
bool __i2,
140 {
return _M_base.compare_exchange_weak(__i1, __i2, __m); }
143 compare_exchange_weak(
bool& __i1,
bool __i2,
144 memory_order __m = memory_order_seq_cst)
volatile noexcept
145 {
return _M_base.compare_exchange_weak(__i1, __i2, __m); }
148 compare_exchange_strong(
bool& __i1,
bool __i2,
memory_order __m1,
150 {
return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); }
153 compare_exchange_strong(
bool& __i1,
bool __i2,
memory_order __m1,
155 {
return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); }
158 compare_exchange_strong(
bool& __i1,
bool __i2,
160 {
return _M_base.compare_exchange_strong(__i1, __i2, __m); }
163 compare_exchange_strong(
bool& __i1,
bool __i2,
164 memory_order __m = memory_order_seq_cst)
volatile noexcept
165 {
return _M_base.compare_exchange_strong(__i1, __i2, __m); }
168 #if __cplusplus <= 201703L
169 # define _GLIBCXX20_INIT(I)
171 # define _GLIBCXX20_INIT(I) = I
179 template<
typename _Tp>
182 using value_type = _Tp;
186 static constexpr
int _S_min_alignment
187 = (
sizeof(_Tp) & (
sizeof(_Tp) - 1)) ||
sizeof(_Tp) > 16
190 static constexpr
int _S_alignment
191 = _S_min_alignment >
alignof(_Tp) ? _S_min_alignment :
alignof(_Tp);
193 alignas(_S_alignment) _Tp _M_i _GLIBCXX20_INIT(_Tp());
195 static_assert(__is_trivially_copyable(_Tp),
196 "std::atomic requires a trivially copyable type");
198 static_assert(
sizeof(_Tp) > 0,
199 "Incomplete or zero-sized types are not supported");
203 ~
atomic() noexcept = default;
208 constexpr
atomic(_Tp __i) noexcept : _M_i(__i) { }
210 operator _Tp() const noexcept
213 operator _Tp() const volatile noexcept
217 operator=(_Tp __i) noexcept
218 { store(__i);
return __i; }
221 operator=(_Tp __i)
volatile noexcept
222 { store(__i);
return __i; }
225 is_lock_free() const noexcept
228 return __atomic_is_lock_free(
sizeof(_M_i),
229 reinterpret_cast<void *>(-_S_alignment));
233 is_lock_free() const volatile noexcept
236 return __atomic_is_lock_free(
sizeof(_M_i),
237 reinterpret_cast<void *>(-_S_alignment));
240 #if __cplusplus >= 201703L
241 static constexpr
bool is_always_lock_free
242 = __atomic_always_lock_free(
sizeof(_M_i), 0);
246 store(_Tp __i,
memory_order __m = memory_order_seq_cst) noexcept
250 store(_Tp __i,
memory_order __m = memory_order_seq_cst) volatile noexcept
254 load(
memory_order __m = memory_order_seq_cst) const noexcept
256 alignas(_Tp)
unsigned char __buf[
sizeof(_Tp)];
257 _Tp* __ptr =
reinterpret_cast<_Tp*
>(__buf);
263 load(
memory_order __m = memory_order_seq_cst) const volatile noexcept
265 alignas(_Tp)
unsigned char __buf[
sizeof(_Tp)];
266 _Tp* __ptr =
reinterpret_cast<_Tp*
>(__buf);
272 exchange(_Tp __i,
memory_order __m = memory_order_seq_cst) noexcept
274 alignas(_Tp)
unsigned char __buf[
sizeof(_Tp)];
275 _Tp* __ptr =
reinterpret_cast<_Tp*
>(__buf);
283 memory_order __m = memory_order_seq_cst) volatile noexcept
285 alignas(_Tp)
unsigned char __buf[
sizeof(_Tp)];
286 _Tp* __ptr =
reinterpret_cast<_Tp*
>(__buf);
293 compare_exchange_weak(_Tp& __e, _Tp __i,
memory_order __s,
299 true,
int(__s),
int(__f));
303 compare_exchange_weak(_Tp& __e, _Tp __i,
memory_order __s,
309 true,
int(__s),
int(__f));
313 compare_exchange_weak(_Tp& __e, _Tp __i,
315 {
return compare_exchange_weak(__e, __i, __m,
316 __cmpexch_failure_order(__m)); }
319 compare_exchange_weak(_Tp& __e, _Tp __i,
320 memory_order __m = memory_order_seq_cst) volatile noexcept
321 {
return compare_exchange_weak(__e, __i, __m,
322 __cmpexch_failure_order(__m)); }
325 compare_exchange_strong(_Tp& __e, _Tp __i,
memory_order __s,
331 false,
int(__s),
int(__f));
335 compare_exchange_strong(_Tp& __e, _Tp __i,
memory_order __s,
341 false,
int(__s),
int(__f));
345 compare_exchange_strong(_Tp& __e, _Tp __i,
347 {
return compare_exchange_strong(__e, __i, __m,
348 __cmpexch_failure_order(__m)); }
351 compare_exchange_strong(_Tp& __e, _Tp __i,
352 memory_order __m = memory_order_seq_cst) volatile noexcept
353 {
return compare_exchange_strong(__e, __i, __m,
354 __cmpexch_failure_order(__m)); }
356 #undef _GLIBCXX20_INIT
359 template<
typename _Tp>
362 using value_type = _Tp*;
363 using difference_type = ptrdiff_t;
365 typedef _Tp* __pointer_type;
369 atomic() noexcept =
default;
370 ~
atomic() noexcept =
default;
375 constexpr
atomic(__pointer_type __p) noexcept : _M_b(__p) { }
377 operator __pointer_type()
const noexcept
378 {
return __pointer_type(_M_b); }
380 operator __pointer_type()
const volatile noexcept
381 {
return __pointer_type(_M_b); }
384 operator=(__pointer_type __p) noexcept
385 {
return _M_b.operator=(__p); }
388 operator=(__pointer_type __p)
volatile noexcept
389 {
return _M_b.operator=(__p); }
392 operator++(
int) noexcept
394 #if __cplusplus >= 201703L
401 operator++(
int)
volatile noexcept
403 #if __cplusplus >= 201703L
410 operator--(
int) noexcept
412 #if __cplusplus >= 201703L
419 operator--(
int)
volatile noexcept
421 #if __cplusplus >= 201703L
428 operator++() noexcept
430 #if __cplusplus >= 201703L
437 operator++()
volatile noexcept
439 #if __cplusplus >= 201703L
446 operator--() noexcept
448 #if __cplusplus >= 201703L
455 operator--()
volatile noexcept
457 #if __cplusplus >= 201703L
464 operator+=(ptrdiff_t __d) noexcept
466 #if __cplusplus >= 201703L
469 return _M_b.operator+=(__d);
473 operator+=(ptrdiff_t __d)
volatile noexcept
475 #if __cplusplus >= 201703L
478 return _M_b.operator+=(__d);
482 operator-=(ptrdiff_t __d) noexcept
484 #if __cplusplus >= 201703L
487 return _M_b.operator-=(__d);
491 operator-=(ptrdiff_t __d)
volatile noexcept
493 #if __cplusplus >= 201703L
496 return _M_b.operator-=(__d);
500 is_lock_free()
const noexcept
501 {
return _M_b.is_lock_free(); }
504 is_lock_free()
const volatile noexcept
505 {
return _M_b.is_lock_free(); }
507 #if __cplusplus >= 201703L
508 static constexpr
bool is_always_lock_free = ATOMIC_POINTER_LOCK_FREE == 2;
512 store(__pointer_type __p,
514 {
return _M_b.store(__p, __m); }
517 store(__pointer_type __p,
518 memory_order __m = memory_order_seq_cst)
volatile noexcept
519 {
return _M_b.store(__p, __m); }
522 load(
memory_order __m = memory_order_seq_cst)
const noexcept
523 {
return _M_b.load(__m); }
526 load(
memory_order __m = memory_order_seq_cst)
const volatile noexcept
527 {
return _M_b.load(__m); }
532 {
return _M_b.exchange(__p, __m); }
536 memory_order __m = memory_order_seq_cst)
volatile noexcept
537 {
return _M_b.exchange(__p, __m); }
540 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
542 {
return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
545 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
548 {
return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
551 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
554 return compare_exchange_weak(__p1, __p2, __m,
555 __cmpexch_failure_order(__m));
559 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
560 memory_order __m = memory_order_seq_cst)
volatile noexcept
562 return compare_exchange_weak(__p1, __p2, __m,
563 __cmpexch_failure_order(__m));
567 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
569 {
return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
572 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
575 {
return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
578 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
581 return _M_b.compare_exchange_strong(__p1, __p2, __m,
582 __cmpexch_failure_order(__m));
586 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
587 memory_order __m = memory_order_seq_cst)
volatile noexcept
589 return _M_b.compare_exchange_strong(__p1, __p2, __m,
590 __cmpexch_failure_order(__m));
594 fetch_add(ptrdiff_t __d,
597 #if __cplusplus >= 201703L
600 return _M_b.fetch_add(__d, __m);
604 fetch_add(ptrdiff_t __d,
605 memory_order __m = memory_order_seq_cst)
volatile noexcept
607 #if __cplusplus >= 201703L
610 return _M_b.fetch_add(__d, __m);
614 fetch_sub(ptrdiff_t __d,
617 #if __cplusplus >= 201703L
620 return _M_b.fetch_sub(__d, __m);
624 fetch_sub(ptrdiff_t __d,
625 memory_order __m = memory_order_seq_cst)
volatile noexcept
627 #if __cplusplus >= 201703L
630 return _M_b.fetch_sub(__d, __m);
639 typedef char __integral_type;
642 atomic() noexcept =
default;
643 ~
atomic() noexcept =
default;
650 using __base_type::operator __integral_type;
651 using __base_type::operator=;
653 #if __cplusplus >= 201703L
654 static constexpr
bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
662 typedef signed char __integral_type;
665 atomic() noexcept=
default;
666 ~
atomic() noexcept =
default;
673 using __base_type::operator __integral_type;
674 using __base_type::operator=;
676 #if __cplusplus >= 201703L
677 static constexpr
bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
685 typedef unsigned char __integral_type;
688 atomic() noexcept=
default;
689 ~
atomic() noexcept =
default;
696 using __base_type::operator __integral_type;
697 using __base_type::operator=;
699 #if __cplusplus >= 201703L
700 static constexpr
bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
708 typedef short __integral_type;
711 atomic() noexcept =
default;
712 ~
atomic() noexcept =
default;
719 using __base_type::operator __integral_type;
720 using __base_type::operator=;
722 #if __cplusplus >= 201703L
723 static constexpr
bool is_always_lock_free = ATOMIC_SHORT_LOCK_FREE == 2;
731 typedef unsigned short __integral_type;
734 atomic() noexcept =
default;
735 ~
atomic() noexcept =
default;
742 using __base_type::operator __integral_type;
743 using __base_type::operator=;
745 #if __cplusplus >= 201703L
746 static constexpr
bool is_always_lock_free = ATOMIC_SHORT_LOCK_FREE == 2;
754 typedef int __integral_type;
757 atomic() noexcept =
default;
758 ~
atomic() noexcept =
default;
765 using __base_type::operator __integral_type;
766 using __base_type::operator=;
768 #if __cplusplus >= 201703L
769 static constexpr
bool is_always_lock_free = ATOMIC_INT_LOCK_FREE == 2;
777 typedef unsigned int __integral_type;
780 atomic() noexcept =
default;
781 ~
atomic() noexcept =
default;
788 using __base_type::operator __integral_type;
789 using __base_type::operator=;
791 #if __cplusplus >= 201703L
792 static constexpr
bool is_always_lock_free = ATOMIC_INT_LOCK_FREE == 2;
800 typedef long __integral_type;
803 atomic() noexcept =
default;
804 ~
atomic() noexcept =
default;
811 using __base_type::operator __integral_type;
812 using __base_type::operator=;
814 #if __cplusplus >= 201703L
815 static constexpr
bool is_always_lock_free = ATOMIC_LONG_LOCK_FREE == 2;
823 typedef unsigned long __integral_type;
826 atomic() noexcept =
default;
827 ~
atomic() noexcept =
default;
834 using __base_type::operator __integral_type;
835 using __base_type::operator=;
837 #if __cplusplus >= 201703L
838 static constexpr
bool is_always_lock_free = ATOMIC_LONG_LOCK_FREE == 2;
846 typedef long long __integral_type;
849 atomic() noexcept =
default;
850 ~
atomic() noexcept =
default;
857 using __base_type::operator __integral_type;
858 using __base_type::operator=;
860 #if __cplusplus >= 201703L
861 static constexpr
bool is_always_lock_free = ATOMIC_LLONG_LOCK_FREE == 2;
869 typedef unsigned long long __integral_type;
872 atomic() noexcept =
default;
873 ~
atomic() noexcept =
default;
880 using __base_type::operator __integral_type;
881 using __base_type::operator=;
883 #if __cplusplus >= 201703L
884 static constexpr
bool is_always_lock_free = ATOMIC_LLONG_LOCK_FREE == 2;
892 typedef wchar_t __integral_type;
895 atomic() noexcept =
default;
896 ~
atomic() noexcept =
default;
903 using __base_type::operator __integral_type;
904 using __base_type::operator=;
906 #if __cplusplus >= 201703L
907 static constexpr
bool is_always_lock_free = ATOMIC_WCHAR_T_LOCK_FREE == 2;
911 #ifdef _GLIBCXX_USE_CHAR8_T
916 typedef char8_t __integral_type;
919 atomic() noexcept = default;
920 ~
atomic() noexcept = default;
925 constexpr
atomic(__integral_type __i) noexcept : __base_type(__i) { }
927 using __base_type::operator __integral_type;
928 using __base_type::operator=;
930 #if __cplusplus > 201402L
931 static constexpr
bool is_always_lock_free = ATOMIC_CHAR8_T_LOCK_FREE == 2;
940 typedef char16_t __integral_type;
943 atomic() noexcept =
default;
944 ~
atomic() noexcept =
default;
951 using __base_type::operator __integral_type;
952 using __base_type::operator=;
954 #if __cplusplus >= 201703L
955 static constexpr
bool is_always_lock_free = ATOMIC_CHAR16_T_LOCK_FREE == 2;
963 typedef char32_t __integral_type;
966 atomic() noexcept =
default;
967 ~
atomic() noexcept =
default;
974 using __base_type::operator __integral_type;
975 using __base_type::operator=;
977 #if __cplusplus >= 201703L
978 static constexpr
bool is_always_lock_free = ATOMIC_CHAR32_T_LOCK_FREE == 2;
1022 #ifdef _GLIBCXX_USE_CHAR8_T
1033 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
1125 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
1135 atomic_flag_test_and_set_explicit(
atomic_flag* __a,
1137 {
return __a->test_and_set(__m); }
1140 atomic_flag_test_and_set_explicit(
volatile atomic_flag* __a,
1142 {
return __a->test_and_set(__m); }
1145 atomic_flag_clear_explicit(atomic_flag* __a,
memory_order __m) noexcept
1146 { __a->clear(__m); }
1149 atomic_flag_clear_explicit(
volatile atomic_flag* __a,
1151 { __a->clear(__m); }
1154 atomic_flag_test_and_set(atomic_flag* __a) noexcept
1155 {
return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
1158 atomic_flag_test_and_set(
volatile atomic_flag* __a) noexcept
1159 {
return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
1162 atomic_flag_clear(atomic_flag* __a) noexcept
1163 { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
1166 atomic_flag_clear(
volatile atomic_flag* __a) noexcept
1167 { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
1170 template<
typename _Tp>
1171 using __atomic_val_t =
typename atomic<_Tp>::value_type;
1172 template<
typename _Tp>
1173 using __atomic_diff_t =
typename atomic<_Tp>::difference_type;
1177 template<
typename _ITp>
1179 atomic_is_lock_free(
const atomic<_ITp>* __a) noexcept
1180 {
return __a->is_lock_free(); }
1182 template<
typename _ITp>
1184 atomic_is_lock_free(
const volatile atomic<_ITp>* __a) noexcept
1185 {
return __a->is_lock_free(); }
1187 template<
typename _ITp>
1189 atomic_init(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept
1190 { __a->store(__i, memory_order_relaxed); }
1192 template<
typename _ITp>
1194 atomic_init(
volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept
1195 { __a->store(__i, memory_order_relaxed); }
1197 template<
typename _ITp>
1199 atomic_store_explicit(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i,
1201 { __a->store(__i, __m); }
1203 template<
typename _ITp>
1205 atomic_store_explicit(
volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i,
1207 { __a->store(__i, __m); }
1209 template<
typename _ITp>
1211 atomic_load_explicit(
const atomic<_ITp>* __a,
memory_order __m) noexcept
1212 {
return __a->load(__m); }
1214 template<
typename _ITp>
1216 atomic_load_explicit(
const volatile atomic<_ITp>* __a,
1218 {
return __a->load(__m); }
1220 template<
typename _ITp>
1222 atomic_exchange_explicit(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i,
1224 {
return __a->exchange(__i, __m); }
1226 template<
typename _ITp>
1228 atomic_exchange_explicit(
volatile atomic<_ITp>* __a,
1229 __atomic_val_t<_ITp> __i,
1231 {
return __a->exchange(__i, __m); }
1233 template<
typename _ITp>
1235 atomic_compare_exchange_weak_explicit(atomic<_ITp>* __a,
1236 __atomic_val_t<_ITp>* __i1,
1237 __atomic_val_t<_ITp> __i2,
1240 {
return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); }
1242 template<
typename _ITp>
1244 atomic_compare_exchange_weak_explicit(
volatile atomic<_ITp>* __a,
1245 __atomic_val_t<_ITp>* __i1,
1246 __atomic_val_t<_ITp> __i2,
1249 {
return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); }
1251 template<
typename _ITp>
1253 atomic_compare_exchange_strong_explicit(atomic<_ITp>* __a,
1254 __atomic_val_t<_ITp>* __i1,
1255 __atomic_val_t<_ITp> __i2,
1258 {
return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); }
1260 template<
typename _ITp>
1262 atomic_compare_exchange_strong_explicit(
volatile atomic<_ITp>* __a,
1263 __atomic_val_t<_ITp>* __i1,
1264 __atomic_val_t<_ITp> __i2,
1267 {
return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); }
1270 template<
typename _ITp>
1272 atomic_store(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept
1273 { atomic_store_explicit(__a, __i, memory_order_seq_cst); }
1275 template<
typename _ITp>
1277 atomic_store(
volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept
1278 { atomic_store_explicit(__a, __i, memory_order_seq_cst); }
1280 template<
typename _ITp>
1282 atomic_load(
const atomic<_ITp>* __a) noexcept
1283 {
return atomic_load_explicit(__a, memory_order_seq_cst); }
1285 template<
typename _ITp>
1287 atomic_load(
const volatile atomic<_ITp>* __a) noexcept
1288 {
return atomic_load_explicit(__a, memory_order_seq_cst); }
1290 template<
typename _ITp>
1292 atomic_exchange(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept
1293 {
return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); }
1295 template<
typename _ITp>
1297 atomic_exchange(
volatile atomic<_ITp>* __a,
1298 __atomic_val_t<_ITp> __i) noexcept
1299 {
return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); }
1301 template<
typename _ITp>
1303 atomic_compare_exchange_weak(atomic<_ITp>* __a,
1304 __atomic_val_t<_ITp>* __i1,
1305 __atomic_val_t<_ITp> __i2) noexcept
1307 return atomic_compare_exchange_weak_explicit(__a, __i1, __i2,
1308 memory_order_seq_cst,
1309 memory_order_seq_cst);
1312 template<
typename _ITp>
1314 atomic_compare_exchange_weak(
volatile atomic<_ITp>* __a,
1315 __atomic_val_t<_ITp>* __i1,
1316 __atomic_val_t<_ITp> __i2) noexcept
1318 return atomic_compare_exchange_weak_explicit(__a, __i1, __i2,
1319 memory_order_seq_cst,
1320 memory_order_seq_cst);
1323 template<
typename _ITp>
1325 atomic_compare_exchange_strong(atomic<_ITp>* __a,
1326 __atomic_val_t<_ITp>* __i1,
1327 __atomic_val_t<_ITp> __i2) noexcept
1329 return atomic_compare_exchange_strong_explicit(__a, __i1, __i2,
1330 memory_order_seq_cst,
1331 memory_order_seq_cst);
1334 template<
typename _ITp>
1336 atomic_compare_exchange_strong(
volatile atomic<_ITp>* __a,
1337 __atomic_val_t<_ITp>* __i1,
1338 __atomic_val_t<_ITp> __i2) noexcept
1340 return atomic_compare_exchange_strong_explicit(__a, __i1, __i2,
1341 memory_order_seq_cst,
1342 memory_order_seq_cst);
1349 template<
typename _ITp>
1351 atomic_fetch_add_explicit(atomic<_ITp>* __a,
1352 __atomic_diff_t<_ITp> __i,
1354 {
return __a->fetch_add(__i, __m); }
1356 template<
typename _ITp>
1358 atomic_fetch_add_explicit(
volatile atomic<_ITp>* __a,
1359 __atomic_diff_t<_ITp> __i,
1361 {
return __a->fetch_add(__i, __m); }
1363 template<
typename _ITp>
1365 atomic_fetch_sub_explicit(atomic<_ITp>* __a,
1366 __atomic_diff_t<_ITp> __i,
1368 {
return __a->fetch_sub(__i, __m); }
1370 template<
typename _ITp>
1372 atomic_fetch_sub_explicit(
volatile atomic<_ITp>* __a,
1373 __atomic_diff_t<_ITp> __i,
1375 {
return __a->fetch_sub(__i, __m); }
1377 template<
typename _ITp>
1379 atomic_fetch_and_explicit(__atomic_base<_ITp>* __a,
1380 __atomic_val_t<_ITp> __i,
1382 {
return __a->fetch_and(__i, __m); }
1384 template<
typename _ITp>
1386 atomic_fetch_and_explicit(
volatile __atomic_base<_ITp>* __a,
1387 __atomic_val_t<_ITp> __i,
1389 {
return __a->fetch_and(__i, __m); }
1391 template<
typename _ITp>
1393 atomic_fetch_or_explicit(__atomic_base<_ITp>* __a,
1394 __atomic_val_t<_ITp> __i,
1396 {
return __a->fetch_or(__i, __m); }
1398 template<
typename _ITp>
1400 atomic_fetch_or_explicit(
volatile __atomic_base<_ITp>* __a,
1401 __atomic_val_t<_ITp> __i,
1403 {
return __a->fetch_or(__i, __m); }
1405 template<
typename _ITp>
1407 atomic_fetch_xor_explicit(__atomic_base<_ITp>* __a,
1408 __atomic_val_t<_ITp> __i,
1410 {
return __a->fetch_xor(__i, __m); }
1412 template<
typename _ITp>
1414 atomic_fetch_xor_explicit(
volatile __atomic_base<_ITp>* __a,
1415 __atomic_val_t<_ITp> __i,
1417 {
return __a->fetch_xor(__i, __m); }
1419 template<
typename _ITp>
1421 atomic_fetch_add(atomic<_ITp>* __a,
1422 __atomic_diff_t<_ITp> __i) noexcept
1423 {
return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); }
1425 template<
typename _ITp>
1427 atomic_fetch_add(
volatile atomic<_ITp>* __a,
1428 __atomic_diff_t<_ITp> __i) noexcept
1429 {
return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); }
1431 template<
typename _ITp>
1433 atomic_fetch_sub(atomic<_ITp>* __a,
1434 __atomic_diff_t<_ITp> __i) noexcept
1435 {
return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); }
1437 template<
typename _ITp>
1439 atomic_fetch_sub(
volatile atomic<_ITp>* __a,
1440 __atomic_diff_t<_ITp> __i) noexcept
1441 {
return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); }
1443 template<
typename _ITp>
1445 atomic_fetch_and(__atomic_base<_ITp>* __a,
1446 __atomic_val_t<_ITp> __i) noexcept
1447 {
return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); }
1449 template<
typename _ITp>
1451 atomic_fetch_and(
volatile __atomic_base<_ITp>* __a,
1452 __atomic_val_t<_ITp> __i) noexcept
1453 {
return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); }
1455 template<
typename _ITp>
1457 atomic_fetch_or(__atomic_base<_ITp>* __a,
1458 __atomic_val_t<_ITp> __i) noexcept
1459 {
return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); }
1461 template<
typename _ITp>
1463 atomic_fetch_or(
volatile __atomic_base<_ITp>* __a,
1464 __atomic_val_t<_ITp> __i) noexcept
1465 {
return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); }
1467 template<
typename _ITp>
1469 atomic_fetch_xor(__atomic_base<_ITp>* __a,
1470 __atomic_val_t<_ITp> __i) noexcept
1471 {
return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); }
1473 template<
typename _ITp>
1475 atomic_fetch_xor(
volatile __atomic_base<_ITp>* __a,
1476 __atomic_val_t<_ITp> __i) noexcept
1477 {
return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); }
1479 #if __cplusplus > 201703L
1480 #define __cpp_lib_atomic_float 201711L
1482 struct atomic<float> : __atomic_float<float>
1484 atomic() noexcept = default;
1487 atomic(
float __fp) noexcept : __atomic_float<
float>(__fp)
1490 atomic& operator=(
const atomic&)
volatile =
delete;
1491 atomic& operator=(
const atomic&) =
delete;
1493 using __atomic_float<float>::operator=;
1497 struct atomic<double> : __atomic_float<double>
1499 atomic() noexcept = default;
1502 atomic(
double __fp) noexcept : __atomic_float<
double>(__fp)
1505 atomic& operator=(
const atomic&)
volatile =
delete;
1506 atomic& operator=(
const atomic&) =
delete;
1508 using __atomic_float<double>::operator=;
1512 struct atomic<long double> : __atomic_float<long double>
1514 atomic() noexcept = default;
1517 atomic(
long double __fp) noexcept : __atomic_float<
long double>(__fp)
1520 atomic& operator=(
const atomic&)
volatile =
delete;
1521 atomic& operator=(
const atomic&) =
delete;
1523 using __atomic_float<long double>::operator=;
1526 #define __cpp_lib_atomic_ref 201806L
1529 template<
typename _Tp>
1530 struct atomic_ref : __atomic_ref<_Tp>
1533 atomic_ref(_Tp& __t) noexcept : __atomic_ref<_Tp>(__t)
1536 atomic_ref& operator=(
const atomic_ref&) =
delete;
1538 atomic_ref(
const atomic_ref&) =
default;
1540 using __atomic_ref<_Tp>::operator=;
1547 _GLIBCXX_END_NAMESPACE_VERSION
1552 #endif // _GLIBCXX_ATOMIC
atomic< wchar_t > atomic_wchar_t
atomic_wchar_t
atomic< ptrdiff_t > atomic_ptrdiff_t
atomic_ptrdiff_t
atomic< int_least32_t > atomic_int_least32_t
atomic_int_least32_t
Explicit specialization for unsigned char.
atomic< intptr_t > atomic_intptr_t
atomic_intptr_t
atomic< int_least16_t > atomic_int_least16_t
atomic_int_least16_t
atomic< uint_fast16_t > atomic_uint_fast16_t
atomic_uint_fast16_t
atomic< uint_fast64_t > atomic_uint_fast64_t
atomic_uint_fast64_t
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
atomic< uint8_t > atomic_uint8_t
atomic_uint8_t
atomic< int64_t > atomic_int64_t
atomic_int64_t
Explicit specialization for long.
atomic< size_t > atomic_size_t
atomic_size_t
memory_order
Enumeration for memory_order.
atomic< unsigned long > atomic_ulong
atomic_ulong
Explicit specialization for char32_t.
Explicit specialization for signed char.
atomic< char > atomic_char
atomic_char
atomic< bool > atomic_bool
atomic_bool
atomic< signed char > atomic_schar
atomic_schar
atomic< uintptr_t > atomic_uintptr_t
atomic_uintptr_t
Explicit specialization for unsigned long.
atomic< unsigned char > atomic_uchar
atomic_uchar
atomic< uint64_t > atomic_uint64_t
atomic_uint64_t
atomic< long long > atomic_llong
atomic_llong
Explicit specialization for int.
atomic< char32_t > atomic_char32_t
atomic_char32_t
Explicit specialization for char16_t.
atomic< uint_fast32_t > atomic_uint_fast32_t
atomic_uint_fast32_t
atomic< int_fast32_t > atomic_int_fast32_t
atomic_int_fast32_t
atomic< int > atomic_int
atomic_int
atomic< int16_t > atomic_int16_t
atomic_int16_t
atomic< int_least8_t > atomic_int_least8_t
atomic_int_least8_t
#define ATOMIC_BOOL_LOCK_FREE
atomic< unsigned int > atomic_uint
atomic_uint
atomic< int_fast64_t > atomic_int_fast64_t
atomic_int_fast64_t
atomic< unsigned long long > atomic_ullong
atomic_ullong
atomic< int_fast16_t > atomic_int_fast16_t
atomic_int_fast16_t
Explicit specialization for short.
atomic< uint16_t > atomic_uint16_t
atomic_uint16_t
atomic< unsigned short > atomic_ushort
atomic_ushort
atomic< int_least64_t > atomic_int_least64_t
atomic_int_least64_t
atomic< uint_fast8_t > atomic_uint_fast8_t
atomic_uint_fast8_t
Explicit specialization for unsigned int.
Generic atomic type, primary class template.
atomic< char16_t > atomic_char16_t
atomic_char16_t
Explicit specialization for unsigned short.
atomic< uint_least8_t > atomic_uint_least8_t
atomic_uint_least8_t
atomic< intmax_t > atomic_intmax_t
atomic_intmax_t
Explicit specialization for char.
atomic< long > atomic_long
atomic_long
atomic< int32_t > atomic_int32_t
atomic_int32_t
atomic< uint_least16_t > atomic_uint_least16_t
atomic_uint_least16_t
atomic< int8_t > atomic_int8_t
atomic_int8_t
Explicit specialization for long long.
constexpr _Tp exchange(_Tp &__obj, _Up &&__new_val)
Assign __new_val to __obj and return its previous value.
atomic< uintmax_t > atomic_uintmax_t
atomic_uintmax_t
atomic< uint32_t > atomic_uint32_t
atomic_uint32_t
Explicit specialization for wchar_t.
atomic< short > atomic_short
atomic_short
atomic< int_fast8_t > atomic_int_fast8_t
atomic_int_fast8_t
Explicit specialization for unsigned long long.
atomic< uint_least64_t > atomic_uint_least64_t
atomic_uint_least64_t
atomic< uint_least32_t > atomic_uint_least32_t
atomic_uint_least32_t