32#ifndef _GLIBCXX_ATOMIC
33#define _GLIBCXX_ATOMIC 1
36#pragma GCC system_header
39#if __cplusplus < 201103L
43#define __glibcxx_want_atomic_is_always_lock_free
44#define __glibcxx_want_atomic_flag_test
45#define __glibcxx_want_atomic_float
46#define __glibcxx_want_atomic_ref
47#define __glibcxx_want_atomic_lock_free_type_aliases
48#define __glibcxx_want_atomic_value_initialization
49#define __glibcxx_want_atomic_wait
56namespace std _GLIBCXX_VISIBILITY(default)
58_GLIBCXX_BEGIN_NAMESPACE_VERSION
65 template<
typename _Tp>
73 using value_type = bool;
76 __atomic_base<bool> _M_base;
79 atomic() noexcept = default;
80 ~atomic() noexcept = default;
81 atomic(const atomic&) = delete;
82 atomic& operator=(const atomic&) = delete;
83 atomic& operator=(const atomic&) volatile = delete;
85 constexpr atomic(
bool __i) noexcept : _M_base(__i) { }
88 operator=(
bool __i)
noexcept
89 {
return _M_base.operator=(__i); }
92 operator=(
bool __i)
volatile noexcept
93 {
return _M_base.operator=(__i); }
95 operator bool() const noexcept
96 {
return _M_base.load(); }
98 operator bool() const volatile noexcept
99 {
return _M_base.load(); }
102 is_lock_free() const noexcept {
return _M_base.is_lock_free(); }
105 is_lock_free() const volatile noexcept {
return _M_base.is_lock_free(); }
107#ifdef __cpp_lib_atomic_is_always_lock_free
112 store(
bool __i,
memory_order __m = memory_order_seq_cst)
noexcept
113 { _M_base.store(__i, __m); }
116 store(
bool __i,
memory_order __m = memory_order_seq_cst)
volatile noexcept
117 { _M_base.store(__i, __m); }
120 load(
memory_order __m = memory_order_seq_cst)
const noexcept
121 {
return _M_base.load(__m); }
124 load(
memory_order __m = memory_order_seq_cst)
const volatile noexcept
125 {
return _M_base.load(__m); }
128 exchange(
bool __i,
memory_order __m = memory_order_seq_cst)
noexcept
129 {
return _M_base.exchange(__i, __m); }
133 memory_order __m = memory_order_seq_cst)
volatile noexcept
134 {
return _M_base.exchange(__i, __m); }
137 compare_exchange_weak(
bool& __i1,
bool __i2,
memory_order __m1,
139 {
return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); }
142 compare_exchange_weak(
bool& __i1,
bool __i2,
memory_order __m1,
144 {
return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); }
147 compare_exchange_weak(
bool& __i1,
bool __i2,
149 {
return _M_base.compare_exchange_weak(__i1, __i2, __m); }
152 compare_exchange_weak(
bool& __i1,
bool __i2,
153 memory_order __m = memory_order_seq_cst)
volatile noexcept
154 {
return _M_base.compare_exchange_weak(__i1, __i2, __m); }
157 compare_exchange_strong(
bool& __i1,
bool __i2,
memory_order __m1,
159 {
return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); }
162 compare_exchange_strong(
bool& __i1,
bool __i2,
memory_order __m1,
164 {
return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); }
167 compare_exchange_strong(
bool& __i1,
bool __i2,
169 {
return _M_base.compare_exchange_strong(__i1, __i2, __m); }
172 compare_exchange_strong(
bool& __i1,
bool __i2,
173 memory_order __m = memory_order_seq_cst)
volatile noexcept
174 {
return _M_base.compare_exchange_strong(__i1, __i2, __m); }
176#if __cpp_lib_atomic_wait
178 wait(
bool __old,
memory_order __m = memory_order_seq_cst)
const noexcept
179 { _M_base.wait(__old, __m); }
184 notify_one() noexcept
185 { _M_base.notify_one(); }
188 notify_all() noexcept
189 { _M_base.notify_all(); }
198 template<
typename _Tp>
201 using value_type = _Tp;
205 static constexpr int _S_min_alignment
206 = (
sizeof(_Tp) & (
sizeof(_Tp) - 1)) ||
sizeof(_Tp) > 16
209 static constexpr int _S_alignment
210 = _S_min_alignment >
alignof(_Tp) ? _S_min_alignment :
alignof(_Tp);
212 alignas(_S_alignment) _Tp _M_i;
214 static_assert(__is_trivially_copyable(_Tp),
215 "std::atomic requires a trivially copyable type");
217 static_assert(
sizeof(_Tp) > 0,
218 "Incomplete or zero-sized types are not supported");
223 "template argument for std::atomic must not be const or volatile");
225#if __cplusplus > 201703L
226 static_assert(is_copy_constructible_v<_Tp>);
227 static_assert(is_move_constructible_v<_Tp>);
228 static_assert(is_copy_assignable_v<_Tp>);
229 static_assert(is_move_assignable_v<_Tp>);
233#if __cpp_lib_atomic_value_initialization
236 constexpr atomic()
noexcept(is_nothrow_default_constructible_v<_Tp>)
237 requires is_default_constructible_v<_Tp>
244 ~atomic()
noexcept =
default;
245 atomic(
const atomic&) =
delete;
246 atomic& operator=(
const atomic&) =
delete;
247 atomic& operator=(
const atomic&)
volatile =
delete;
249 constexpr atomic(_Tp __i) noexcept : _M_i(__i)
251#if __cplusplus >= 201402L && __has_builtin(__builtin_clear_padding)
252 if _GLIBCXX17_CONSTEXPR (__atomic_impl::__maybe_has_padding<_Tp>())
257 operator _Tp()
const noexcept
260 operator _Tp()
const volatile noexcept
264 operator=(_Tp __i)
noexcept
265 { store(__i);
return __i; }
268 operator=(_Tp __i)
volatile noexcept
269 { store(__i);
return __i; }
272 is_lock_free()
const noexcept
275 return __atomic_is_lock_free(
sizeof(_M_i),
276 reinterpret_cast<void *
>(-_S_alignment));
280 is_lock_free()
const volatile noexcept
283 return __atomic_is_lock_free(
sizeof(_M_i),
284 reinterpret_cast<void *
>(-_S_alignment));
287#ifdef __cpp_lib_atomic_is_always_lock_free
288 static constexpr bool is_always_lock_free
289 = __atomic_always_lock_free(
sizeof(_M_i), 0);
293 store(_Tp __i,
memory_order __m = memory_order_seq_cst)
noexcept
296 __atomic_impl::__clear_padding(__i),
301 store(_Tp __i,
memory_order __m = memory_order_seq_cst)
volatile noexcept
304 __atomic_impl::__clear_padding(__i),
309 load(
memory_order __m = memory_order_seq_cst)
const noexcept
311 alignas(_Tp)
unsigned char __buf[
sizeof(_Tp)];
312 _Tp* __ptr =
reinterpret_cast<_Tp*
>(__buf);
318 load(
memory_order __m = memory_order_seq_cst)
const volatile noexcept
320 alignas(_Tp)
unsigned char __buf[
sizeof(_Tp)];
321 _Tp* __ptr =
reinterpret_cast<_Tp*
>(__buf);
327 exchange(_Tp __i,
memory_order __m = memory_order_seq_cst)
noexcept
329 alignas(_Tp)
unsigned char __buf[
sizeof(_Tp)];
330 _Tp* __ptr =
reinterpret_cast<_Tp*
>(__buf);
332 __atomic_impl::__clear_padding(__i),
339 memory_order __m = memory_order_seq_cst)
volatile noexcept
341 alignas(_Tp)
unsigned char __buf[
sizeof(_Tp)];
342 _Tp* __ptr =
reinterpret_cast<_Tp*
>(__buf);
344 __atomic_impl::__clear_padding(__i),
350 compare_exchange_weak(_Tp& __e, _Tp __i,
memory_order __s,
353 return __atomic_impl::__compare_exchange(_M_i, __e, __i,
true,
358 compare_exchange_weak(_Tp& __e, _Tp __i,
memory_order __s,
361 return __atomic_impl::__compare_exchange(_M_i, __e, __i,
true,
366 compare_exchange_weak(_Tp& __e, _Tp __i,
368 {
return compare_exchange_weak(__e, __i, __m,
369 __cmpexch_failure_order(__m)); }
372 compare_exchange_weak(_Tp& __e, _Tp __i,
373 memory_order __m = memory_order_seq_cst)
volatile noexcept
374 {
return compare_exchange_weak(__e, __i, __m,
375 __cmpexch_failure_order(__m)); }
378 compare_exchange_strong(_Tp& __e, _Tp __i,
memory_order __s,
381 return __atomic_impl::__compare_exchange(_M_i, __e, __i,
false,
386 compare_exchange_strong(_Tp& __e, _Tp __i,
memory_order __s,
389 return __atomic_impl::__compare_exchange(_M_i, __e, __i,
false,
394 compare_exchange_strong(_Tp& __e, _Tp __i,
396 {
return compare_exchange_strong(__e, __i, __m,
397 __cmpexch_failure_order(__m)); }
400 compare_exchange_strong(_Tp& __e, _Tp __i,
401 memory_order __m = memory_order_seq_cst)
volatile noexcept
402 {
return compare_exchange_strong(__e, __i, __m,
403 __cmpexch_failure_order(__m)); }
405#if __cpp_lib_atomic_wait
407 wait(_Tp __old,
memory_order __m = memory_order_seq_cst)
const noexcept
410 [__m,
this] {
return this->load(__m); });
416 notify_one()
noexcept
420 notify_all()
noexcept
426 template<
typename _Tp>
429 using value_type = _Tp*;
430 using difference_type = ptrdiff_t;
432 typedef _Tp* __pointer_type;
433 typedef __atomic_base<_Tp*> __base_type;
436 atomic()
noexcept =
default;
437 ~atomic()
noexcept =
default;
438 atomic(
const atomic&) =
delete;
439 atomic& operator=(
const atomic&) =
delete;
440 atomic& operator=(
const atomic&)
volatile =
delete;
442 constexpr atomic(__pointer_type __p) noexcept : _M_b(__p) { }
444 operator __pointer_type()
const noexcept
445 {
return __pointer_type(_M_b); }
447 operator __pointer_type()
const volatile noexcept
448 {
return __pointer_type(_M_b); }
451 operator=(__pointer_type __p)
noexcept
452 {
return _M_b.operator=(__p); }
455 operator=(__pointer_type __p)
volatile noexcept
456 {
return _M_b.operator=(__p); }
459 operator++(
int)
noexcept
461#if __cplusplus >= 201703L
462 static_assert( is_object_v<_Tp>,
"pointer to object type" );
468 operator++(
int)
volatile noexcept
470#if __cplusplus >= 201703L
471 static_assert( is_object_v<_Tp>,
"pointer to object type" );
477 operator--(
int)
noexcept
479#if __cplusplus >= 201703L
480 static_assert( is_object_v<_Tp>,
"pointer to object type" );
486 operator--(
int)
volatile noexcept
488#if __cplusplus >= 201703L
489 static_assert( is_object_v<_Tp>,
"pointer to object type" );
495 operator++()
noexcept
497#if __cplusplus >= 201703L
498 static_assert( is_object_v<_Tp>,
"pointer to object type" );
504 operator++()
volatile noexcept
506#if __cplusplus >= 201703L
507 static_assert( is_object_v<_Tp>,
"pointer to object type" );
513 operator--()
noexcept
515#if __cplusplus >= 201703L
516 static_assert( is_object_v<_Tp>,
"pointer to object type" );
522 operator--()
volatile noexcept
524#if __cplusplus >= 201703L
525 static_assert( is_object_v<_Tp>,
"pointer to object type" );
531 operator+=(ptrdiff_t __d)
noexcept
533#if __cplusplus >= 201703L
534 static_assert( is_object_v<_Tp>,
"pointer to object type" );
536 return _M_b.operator+=(__d);
540 operator+=(ptrdiff_t __d)
volatile noexcept
542#if __cplusplus >= 201703L
543 static_assert( is_object_v<_Tp>,
"pointer to object type" );
545 return _M_b.operator+=(__d);
549 operator-=(ptrdiff_t __d)
noexcept
551#if __cplusplus >= 201703L
552 static_assert( is_object_v<_Tp>,
"pointer to object type" );
554 return _M_b.operator-=(__d);
558 operator-=(ptrdiff_t __d)
volatile noexcept
560#if __cplusplus >= 201703L
561 static_assert( is_object_v<_Tp>,
"pointer to object type" );
563 return _M_b.operator-=(__d);
567 is_lock_free()
const noexcept
568 {
return _M_b.is_lock_free(); }
571 is_lock_free()
const volatile noexcept
572 {
return _M_b.is_lock_free(); }
574#ifdef __cpp_lib_atomic_is_always_lock_free
575 static constexpr bool is_always_lock_free
576 = ATOMIC_POINTER_LOCK_FREE == 2;
580 store(__pointer_type __p,
582 {
return _M_b.store(__p, __m); }
585 store(__pointer_type __p,
586 memory_order __m = memory_order_seq_cst)
volatile noexcept
587 {
return _M_b.store(__p, __m); }
590 load(
memory_order __m = memory_order_seq_cst)
const noexcept
591 {
return _M_b.load(__m); }
594 load(
memory_order __m = memory_order_seq_cst)
const volatile noexcept
595 {
return _M_b.load(__m); }
598 exchange(__pointer_type __p,
600 {
return _M_b.exchange(__p, __m); }
603 exchange(__pointer_type __p,
604 memory_order __m = memory_order_seq_cst)
volatile noexcept
605 {
return _M_b.exchange(__p, __m); }
608 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
610 {
return _M_b.compare_exchange_weak(__p1, __p2, __m1, __m2); }
613 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
616 {
return _M_b.compare_exchange_weak(__p1, __p2, __m1, __m2); }
619 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
622 return compare_exchange_weak(__p1, __p2, __m,
623 __cmpexch_failure_order(__m));
627 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
628 memory_order __m = memory_order_seq_cst)
volatile noexcept
630 return compare_exchange_weak(__p1, __p2, __m,
631 __cmpexch_failure_order(__m));
635 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
637 {
return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
640 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
643 {
return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
646 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
649 return _M_b.compare_exchange_strong(__p1, __p2, __m,
650 __cmpexch_failure_order(__m));
654 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
655 memory_order __m = memory_order_seq_cst)
volatile noexcept
657 return _M_b.compare_exchange_strong(__p1, __p2, __m,
658 __cmpexch_failure_order(__m));
661#if __cpp_lib_atomic_wait
663 wait(__pointer_type __old,
memory_order __m = memory_order_seq_cst)
const noexcept
664 { _M_b.wait(__old, __m); }
669 notify_one()
noexcept
670 { _M_b.notify_one(); }
673 notify_all()
noexcept
674 { _M_b.notify_all(); }
678 fetch_add(ptrdiff_t __d,
681#if __cplusplus >= 201703L
682 static_assert( is_object_v<_Tp>,
"pointer to object type" );
684 return _M_b.fetch_add(__d, __m);
688 fetch_add(ptrdiff_t __d,
689 memory_order __m = memory_order_seq_cst)
volatile noexcept
691#if __cplusplus >= 201703L
692 static_assert( is_object_v<_Tp>,
"pointer to object type" );
694 return _M_b.fetch_add(__d, __m);
698 fetch_sub(ptrdiff_t __d,
701#if __cplusplus >= 201703L
702 static_assert( is_object_v<_Tp>,
"pointer to object type" );
704 return _M_b.fetch_sub(__d, __m);
708 fetch_sub(ptrdiff_t __d,
709 memory_order __m = memory_order_seq_cst)
volatile noexcept
711#if __cplusplus >= 201703L
712 static_assert( is_object_v<_Tp>,
"pointer to object type" );
714 return _M_b.fetch_sub(__d, __m);
721 struct atomic<char> : __atomic_base<char>
723 typedef char __integral_type;
724 typedef __atomic_base<char> __base_type;
726 atomic() noexcept = default;
727 ~
atomic() noexcept = default;
732 constexpr
atomic(__integral_type __i) noexcept : __base_type(__i) { }
734 using __base_type::operator __integral_type;
735 using __base_type::operator=;
737#ifdef __cpp_lib_atomic_is_always_lock_free
738 static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
744 struct atomic<signed char> : __atomic_base<signed char>
746 typedef signed char __integral_type;
747 typedef __atomic_base<signed char> __base_type;
749 atomic() noexcept= default;
750 ~atomic() noexcept = default;
751 atomic(const atomic&) = delete;
752 atomic& operator=(const atomic&) = delete;
753 atomic& operator=(const atomic&) volatile = delete;
755 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
757 using __base_type::operator __integral_type;
758 using __base_type::operator=;
760#ifdef __cpp_lib_atomic_is_always_lock_free
761 static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
767 struct atomic<unsigned char> : __atomic_base<unsigned char>
769 typedef unsigned char __integral_type;
770 typedef __atomic_base<unsigned char> __base_type;
772 atomic() noexcept= default;
773 ~atomic() noexcept = default;
774 atomic(const atomic&) = delete;
775 atomic& operator=(const atomic&) = delete;
776 atomic& operator=(const atomic&) volatile = delete;
778 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
780 using __base_type::operator __integral_type;
781 using __base_type::operator=;
783#ifdef __cpp_lib_atomic_is_always_lock_free
784 static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
790 struct atomic<short> : __atomic_base<short>
792 typedef short __integral_type;
793 typedef __atomic_base<short> __base_type;
795 atomic() noexcept = default;
796 ~atomic() noexcept = default;
797 atomic(const atomic&) = delete;
798 atomic& operator=(const atomic&) = delete;
799 atomic& operator=(const atomic&) volatile = delete;
801 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
803 using __base_type::operator __integral_type;
804 using __base_type::operator=;
806#ifdef __cpp_lib_atomic_is_always_lock_free
807 static constexpr bool is_always_lock_free = ATOMIC_SHORT_LOCK_FREE == 2;
813 struct atomic<unsigned short> : __atomic_base<unsigned short>
815 typedef unsigned short __integral_type;
816 typedef __atomic_base<unsigned short> __base_type;
818 atomic() noexcept = default;
819 ~atomic() noexcept = default;
820 atomic(const atomic&) = delete;
821 atomic& operator=(const atomic&) = delete;
822 atomic& operator=(const atomic&) volatile = delete;
824 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
826 using __base_type::operator __integral_type;
827 using __base_type::operator=;
829#ifdef __cpp_lib_atomic_is_always_lock_free
830 static constexpr bool is_always_lock_free = ATOMIC_SHORT_LOCK_FREE == 2;
836 struct atomic<int> : __atomic_base<int>
838 typedef int __integral_type;
839 typedef __atomic_base<int> __base_type;
841 atomic() noexcept = default;
842 ~atomic() noexcept = default;
843 atomic(const atomic&) = delete;
844 atomic& operator=(const atomic&) = delete;
845 atomic& operator=(const atomic&) volatile = delete;
847 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
849 using __base_type::operator __integral_type;
850 using __base_type::operator=;
852#ifdef __cpp_lib_atomic_is_always_lock_free
853 static constexpr bool is_always_lock_free = ATOMIC_INT_LOCK_FREE == 2;
859 struct atomic<unsigned int> : __atomic_base<unsigned int>
861 typedef unsigned int __integral_type;
862 typedef __atomic_base<unsigned int> __base_type;
864 atomic() noexcept = default;
865 ~atomic() noexcept = default;
866 atomic(const atomic&) = delete;
867 atomic& operator=(const atomic&) = delete;
868 atomic& operator=(const atomic&) volatile = delete;
870 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
872 using __base_type::operator __integral_type;
873 using __base_type::operator=;
875#ifdef __cpp_lib_atomic_is_always_lock_free
876 static constexpr bool is_always_lock_free = ATOMIC_INT_LOCK_FREE == 2;
882 struct atomic<long> : __atomic_base<long>
884 typedef long __integral_type;
885 typedef __atomic_base<long> __base_type;
887 atomic() noexcept = default;
888 ~atomic() noexcept = default;
889 atomic(const atomic&) = delete;
890 atomic& operator=(const atomic&) = delete;
891 atomic& operator=(const atomic&) volatile = delete;
893 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
895 using __base_type::operator __integral_type;
896 using __base_type::operator=;
898#ifdef __cpp_lib_atomic_is_always_lock_free
899 static constexpr bool is_always_lock_free = ATOMIC_LONG_LOCK_FREE == 2;
905 struct atomic<unsigned long> : __atomic_base<unsigned long>
907 typedef unsigned long __integral_type;
908 typedef __atomic_base<unsigned long> __base_type;
910 atomic() noexcept = default;
911 ~atomic() noexcept = default;
912 atomic(const atomic&) = delete;
913 atomic& operator=(const atomic&) = delete;
914 atomic& operator=(const atomic&) volatile = delete;
916 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
918 using __base_type::operator __integral_type;
919 using __base_type::operator=;
921#ifdef __cpp_lib_atomic_is_always_lock_free
922 static constexpr bool is_always_lock_free = ATOMIC_LONG_LOCK_FREE == 2;
928 struct atomic<long long> : __atomic_base<long long>
930 typedef long long __integral_type;
931 typedef __atomic_base<long long> __base_type;
933 atomic() noexcept = default;
934 ~atomic() noexcept = default;
935 atomic(const atomic&) = delete;
936 atomic& operator=(const atomic&) = delete;
937 atomic& operator=(const atomic&) volatile = delete;
939 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
941 using __base_type::operator __integral_type;
942 using __base_type::operator=;
944#ifdef __cpp_lib_atomic_is_always_lock_free
945 static constexpr bool is_always_lock_free = ATOMIC_LLONG_LOCK_FREE == 2;
951 struct atomic<unsigned long long> : __atomic_base<unsigned long long>
953 typedef unsigned long long __integral_type;
954 typedef __atomic_base<unsigned long long> __base_type;
956 atomic() noexcept = default;
957 ~atomic() noexcept = default;
958 atomic(const atomic&) = delete;
959 atomic& operator=(const atomic&) = delete;
960 atomic& operator=(const atomic&) volatile = delete;
962 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
964 using __base_type::operator __integral_type;
965 using __base_type::operator=;
967#ifdef __cpp_lib_atomic_is_always_lock_free
968 static constexpr bool is_always_lock_free = ATOMIC_LLONG_LOCK_FREE == 2;
974 struct atomic<wchar_t> : __atomic_base<wchar_t>
976 typedef wchar_t __integral_type;
977 typedef __atomic_base<wchar_t> __base_type;
979 atomic() noexcept = default;
980 ~atomic() noexcept = default;
981 atomic(const atomic&) = delete;
982 atomic& operator=(const atomic&) = delete;
983 atomic& operator=(const atomic&) volatile = delete;
985 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
987 using __base_type::operator __integral_type;
988 using __base_type::operator=;
990#ifdef __cpp_lib_atomic_is_always_lock_free
991 static constexpr bool is_always_lock_free = ATOMIC_WCHAR_T_LOCK_FREE == 2;
995#ifdef _GLIBCXX_USE_CHAR8_T
998 struct atomic<char8_t> : __atomic_base<char8_t>
1000 typedef char8_t __integral_type;
1001 typedef __atomic_base<char8_t> __base_type;
1003 atomic() noexcept = default;
1004 ~atomic() noexcept = default;
1005 atomic(const atomic&) = delete;
1006 atomic& operator=(const atomic&) = delete;
1007 atomic& operator=(const atomic&) volatile = delete;
1009 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
1011 using __base_type::operator __integral_type;
1012 using __base_type::operator=;
1014#ifdef __cpp_lib_atomic_is_always_lock_free
1015 static constexpr bool is_always_lock_free
1016 = ATOMIC_CHAR8_T_LOCK_FREE == 2;
1023 struct atomic<char16_t> : __atomic_base<char16_t>
1025 typedef char16_t __integral_type;
1026 typedef __atomic_base<char16_t> __base_type;
1028 atomic() noexcept = default;
1029 ~atomic() noexcept = default;
1030 atomic(const atomic&) = delete;
1031 atomic& operator=(const atomic&) = delete;
1032 atomic& operator=(const atomic&) volatile = delete;
1034 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
1036 using __base_type::operator __integral_type;
1037 using __base_type::operator=;
1039#ifdef __cpp_lib_atomic_is_always_lock_free
1040 static constexpr bool is_always_lock_free
1041 = ATOMIC_CHAR16_T_LOCK_FREE == 2;
1047 struct atomic<char32_t> : __atomic_base<char32_t>
1049 typedef char32_t __integral_type;
1050 typedef __atomic_base<char32_t> __base_type;
1052 atomic() noexcept = default;
1053 ~atomic() noexcept = default;
1054 atomic(const atomic&) = delete;
1055 atomic& operator=(const atomic&) = delete;
1056 atomic& operator=(const atomic&) volatile = delete;
1058 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
1060 using __base_type::operator __integral_type;
1061 using __base_type::operator=;
1063#ifdef __cpp_lib_atomic_is_always_lock_free
1064 static constexpr bool is_always_lock_free
1065 = ATOMIC_CHAR32_T_LOCK_FREE == 2;
1109#ifdef _GLIBCXX_USE_CHAR8_T
1120#ifdef _GLIBCXX_USE_C99_STDINT
1219 atomic_flag_test_and_set_explicit(
atomic_flag* __a,
1221 {
return __a->test_and_set(__m); }
1224 atomic_flag_test_and_set_explicit(
volatile atomic_flag* __a,
1226 {
return __a->test_and_set(__m); }
1228#if __cpp_lib_atomic_flag_test
1231 {
return __a->test(); }
1234 atomic_flag_test(
const volatile atomic_flag* __a)
noexcept
1235 {
return __a->test(); }
1240 {
return __a->test(__m); }
1243 atomic_flag_test_explicit(
const volatile atomic_flag* __a,
1245 {
return __a->test(__m); }
1250 { __a->clear(__m); }
1253 atomic_flag_clear_explicit(
volatile atomic_flag* __a,
1255 { __a->clear(__m); }
1258 atomic_flag_test_and_set(
atomic_flag* __a)
noexcept
1259 {
return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
1262 atomic_flag_test_and_set(
volatile atomic_flag* __a)
noexcept
1263 {
return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
1267 { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
1270 atomic_flag_clear(
volatile atomic_flag* __a)
noexcept
1271 { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
1273#if __cpp_lib_atomic_wait
1275 atomic_flag_wait(
atomic_flag* __a,
bool __old)
noexcept
1276 { __a->wait(__old); }
1279 atomic_flag_wait_explicit(
atomic_flag* __a,
bool __old,
1281 { __a->wait(__old, __m); }
1285 { __a->notify_one(); }
1289 { __a->notify_all(); }
1295 template<
typename _Tp>
1296 using __atomic_val_t = __type_identity_t<_Tp>;
1297 template<
typename _Tp>
1303 template<
typename _ITp>
1306 {
return __a->is_lock_free(); }
1308 template<
typename _ITp>
1310 atomic_is_lock_free(
const volatile atomic<_ITp>* __a)
noexcept
1311 {
return __a->is_lock_free(); }
1313 template<
typename _ITp>
1315 atomic_init(
atomic<_ITp>* __a, __atomic_val_t<_ITp> __i)
noexcept
1316 { __a->store(__i, memory_order_relaxed); }
1318 template<
typename _ITp>
1320 atomic_init(
volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i)
noexcept
1321 { __a->store(__i, memory_order_relaxed); }
1323 template<
typename _ITp>
1325 atomic_store_explicit(
atomic<_ITp>* __a, __atomic_val_t<_ITp> __i,
1327 { __a->store(__i, __m); }
1329 template<
typename _ITp>
1331 atomic_store_explicit(
volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i,
1333 { __a->store(__i, __m); }
1335 template<
typename _ITp>
1338 {
return __a->load(__m); }
1340 template<
typename _ITp>
1344 {
return __a->load(__m); }
1346 template<
typename _ITp>
1348 atomic_exchange_explicit(
atomic<_ITp>* __a, __atomic_val_t<_ITp> __i,
1350 {
return __a->exchange(__i, __m); }
1352 template<
typename _ITp>
1355 __atomic_val_t<_ITp> __i,
1357 {
return __a->exchange(__i, __m); }
1359 template<
typename _ITp>
1361 atomic_compare_exchange_weak_explicit(
atomic<_ITp>* __a,
1362 __atomic_val_t<_ITp>* __i1,
1363 __atomic_val_t<_ITp> __i2,
1366 {
return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); }
1368 template<
typename _ITp>
1370 atomic_compare_exchange_weak_explicit(
volatile atomic<_ITp>* __a,
1371 __atomic_val_t<_ITp>* __i1,
1372 __atomic_val_t<_ITp> __i2,
1375 {
return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); }
1377 template<
typename _ITp>
1379 atomic_compare_exchange_strong_explicit(
atomic<_ITp>* __a,
1380 __atomic_val_t<_ITp>* __i1,
1381 __atomic_val_t<_ITp> __i2,
1384 {
return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); }
1386 template<
typename _ITp>
1388 atomic_compare_exchange_strong_explicit(
volatile atomic<_ITp>* __a,
1389 __atomic_val_t<_ITp>* __i1,
1390 __atomic_val_t<_ITp> __i2,
1393 {
return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); }
1396 template<
typename _ITp>
1398 atomic_store(
atomic<_ITp>* __a, __atomic_val_t<_ITp> __i)
noexcept
1399 { atomic_store_explicit(__a, __i, memory_order_seq_cst); }
1401 template<
typename _ITp>
1403 atomic_store(
volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i)
noexcept
1404 { atomic_store_explicit(__a, __i, memory_order_seq_cst); }
1406 template<
typename _ITp>
1409 {
return atomic_load_explicit(__a, memory_order_seq_cst); }
1411 template<
typename _ITp>
1414 {
return atomic_load_explicit(__a, memory_order_seq_cst); }
1416 template<
typename _ITp>
1418 atomic_exchange(
atomic<_ITp>* __a, __atomic_val_t<_ITp> __i)
noexcept
1419 {
return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); }
1421 template<
typename _ITp>
1424 __atomic_val_t<_ITp> __i)
noexcept
1425 {
return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); }
1427 template<
typename _ITp>
1430 __atomic_val_t<_ITp>* __i1,
1431 __atomic_val_t<_ITp> __i2)
noexcept
1433 return atomic_compare_exchange_weak_explicit(__a, __i1, __i2,
1434 memory_order_seq_cst,
1435 memory_order_seq_cst);
1438 template<
typename _ITp>
1440 atomic_compare_exchange_weak(
volatile atomic<_ITp>* __a,
1441 __atomic_val_t<_ITp>* __i1,
1442 __atomic_val_t<_ITp> __i2)
noexcept
1444 return atomic_compare_exchange_weak_explicit(__a, __i1, __i2,
1445 memory_order_seq_cst,
1446 memory_order_seq_cst);
1449 template<
typename _ITp>
1452 __atomic_val_t<_ITp>* __i1,
1453 __atomic_val_t<_ITp> __i2)
noexcept
1455 return atomic_compare_exchange_strong_explicit(__a, __i1, __i2,
1456 memory_order_seq_cst,
1457 memory_order_seq_cst);
1460 template<
typename _ITp>
1462 atomic_compare_exchange_strong(
volatile atomic<_ITp>* __a,
1463 __atomic_val_t<_ITp>* __i1,
1464 __atomic_val_t<_ITp> __i2)
noexcept
1466 return atomic_compare_exchange_strong_explicit(__a, __i1, __i2,
1467 memory_order_seq_cst,
1468 memory_order_seq_cst);
1472#if __cpp_lib_atomic_wait
1473 template<
typename _Tp>
1476 typename std::atomic<_Tp>::value_type __old)
noexcept
1477 { __a->wait(__old); }
1479 template<
typename _Tp>
1482 typename std::atomic<_Tp>::value_type __old,
1484 { __a->wait(__old, __m); }
1486 template<
typename _Tp>
1489 { __a->notify_one(); }
1491 template<
typename _Tp>
1494 { __a->notify_all(); }
1501 template<
typename _ITp>
1504 __atomic_diff_t<_ITp> __i,
1506 {
return __a->fetch_add(__i, __m); }
1508 template<
typename _ITp>
1511 __atomic_diff_t<_ITp> __i,
1513 {
return __a->fetch_add(__i, __m); }
1515 template<
typename _ITp>
1518 __atomic_diff_t<_ITp> __i,
1520 {
return __a->fetch_sub(__i, __m); }
1522 template<
typename _ITp>
1525 __atomic_diff_t<_ITp> __i,
1527 {
return __a->fetch_sub(__i, __m); }
1529 template<
typename _ITp>
1531 atomic_fetch_and_explicit(__atomic_base<_ITp>* __a,
1532 __atomic_val_t<_ITp> __i,
1534 {
return __a->fetch_and(__i, __m); }
1536 template<
typename _ITp>
1538 atomic_fetch_and_explicit(
volatile __atomic_base<_ITp>* __a,
1539 __atomic_val_t<_ITp> __i,
1541 {
return __a->fetch_and(__i, __m); }
1543 template<
typename _ITp>
1545 atomic_fetch_or_explicit(__atomic_base<_ITp>* __a,
1546 __atomic_val_t<_ITp> __i,
1548 {
return __a->fetch_or(__i, __m); }
1550 template<
typename _ITp>
1552 atomic_fetch_or_explicit(
volatile __atomic_base<_ITp>* __a,
1553 __atomic_val_t<_ITp> __i,
1555 {
return __a->fetch_or(__i, __m); }
1557 template<
typename _ITp>
1559 atomic_fetch_xor_explicit(__atomic_base<_ITp>* __a,
1560 __atomic_val_t<_ITp> __i,
1562 {
return __a->fetch_xor(__i, __m); }
1564 template<
typename _ITp>
1566 atomic_fetch_xor_explicit(
volatile __atomic_base<_ITp>* __a,
1567 __atomic_val_t<_ITp> __i,
1569 {
return __a->fetch_xor(__i, __m); }
1571 template<
typename _ITp>
1574 __atomic_diff_t<_ITp> __i)
noexcept
1575 {
return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); }
1577 template<
typename _ITp>
1580 __atomic_diff_t<_ITp> __i)
noexcept
1581 {
return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); }
1583 template<
typename _ITp>
1586 __atomic_diff_t<_ITp> __i)
noexcept
1587 {
return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); }
1589 template<
typename _ITp>
1592 __atomic_diff_t<_ITp> __i)
noexcept
1593 {
return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); }
1595 template<
typename _ITp>
1597 atomic_fetch_and(__atomic_base<_ITp>* __a,
1598 __atomic_val_t<_ITp> __i)
noexcept
1599 {
return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); }
1601 template<
typename _ITp>
1603 atomic_fetch_and(
volatile __atomic_base<_ITp>* __a,
1604 __atomic_val_t<_ITp> __i)
noexcept
1605 {
return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); }
1607 template<
typename _ITp>
1609 atomic_fetch_or(__atomic_base<_ITp>* __a,
1610 __atomic_val_t<_ITp> __i)
noexcept
1611 {
return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); }
1613 template<
typename _ITp>
1615 atomic_fetch_or(
volatile __atomic_base<_ITp>* __a,
1616 __atomic_val_t<_ITp> __i)
noexcept
1617 {
return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); }
1619 template<
typename _ITp>
1621 atomic_fetch_xor(__atomic_base<_ITp>* __a,
1622 __atomic_val_t<_ITp> __i)
noexcept
1623 {
return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); }
1625 template<
typename _ITp>
1627 atomic_fetch_xor(
volatile __atomic_base<_ITp>* __a,
1628 __atomic_val_t<_ITp> __i)
noexcept
1629 {
return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); }
1631#ifdef __cpp_lib_atomic_float
1633 struct atomic<float> : __atomic_float<float>
1635 atomic() noexcept = default;
1638 atomic(
float __fp) noexcept : __atomic_float<
float>(__fp)
1641 atomic& operator=(
const atomic&)
volatile =
delete;
1642 atomic& operator=(
const atomic&) =
delete;
1644 using __atomic_float<
float>::operator=;
1648 struct atomic<double> : __atomic_float<double>
1650 atomic() noexcept = default;
1653 atomic(
double __fp) noexcept : __atomic_float<
double>(__fp)
1656 atomic& operator=(
const atomic&)
volatile =
delete;
1657 atomic& operator=(
const atomic&) =
delete;
1659 using __atomic_float<
double>::operator=;
1663 struct atomic<long double> : __atomic_float<long double>
1665 atomic() noexcept = default;
1668 atomic(
long double __fp) noexcept : __atomic_float<
long double>(__fp)
1671 atomic& operator=(
const atomic&)
volatile =
delete;
1672 atomic& operator=(
const atomic&) =
delete;
1674 using __atomic_float<
long double>::operator=;
1677#ifdef __STDCPP_FLOAT16_T__
1679 struct atomic<_Float16> : __atomic_float<_Float16>
1681 atomic() noexcept = default;
1684 atomic(_Float16 __fp) noexcept : __atomic_float<_Float16>(__fp)
1687 atomic& operator=(
const atomic&)
volatile =
delete;
1688 atomic& operator=(
const atomic&) =
delete;
1690 using __atomic_float<_Float16>::operator=;
1694#ifdef __STDCPP_FLOAT32_T__
1696 struct atomic<_Float32> : __atomic_float<_Float32>
1698 atomic() noexcept = default;
1701 atomic(_Float32 __fp) noexcept : __atomic_float<_Float32>(__fp)
1704 atomic& operator=(
const atomic&)
volatile =
delete;
1705 atomic& operator=(
const atomic&) =
delete;
1707 using __atomic_float<_Float32>::operator=;
1711#ifdef __STDCPP_FLOAT64_T__
1713 struct atomic<_Float64> : __atomic_float<_Float64>
1715 atomic() noexcept = default;
1718 atomic(_Float64 __fp) noexcept : __atomic_float<_Float64>(__fp)
1721 atomic& operator=(
const atomic&)
volatile =
delete;
1722 atomic& operator=(
const atomic&) =
delete;
1724 using __atomic_float<_Float64>::operator=;
1728#ifdef __STDCPP_FLOAT128_T__
1730 struct atomic<_Float128> : __atomic_float<_Float128>
1732 atomic() noexcept = default;
1735 atomic(_Float128 __fp) noexcept : __atomic_float<_Float128>(__fp)
1738 atomic& operator=(
const atomic&)
volatile =
delete;
1739 atomic& operator=(
const atomic&) =
delete;
1741 using __atomic_float<_Float128>::operator=;
1745#ifdef __STDCPP_BFLOAT16_T__
1747 struct atomic<__gnu_cxx::__bfloat16_t> : __atomic_float<__gnu_cxx::__bfloat16_t>
1749 atomic() noexcept = default;
1752 atomic(__gnu_cxx::__bfloat16_t __fp) noexcept : __atomic_float<__gnu_cxx::__bfloat16_t>(__fp)
1755 atomic& operator=(
const atomic&)
volatile =
delete;
1756 atomic& operator=(
const atomic&) =
delete;
1758 using __atomic_float<__gnu_cxx::__bfloat16_t>::operator=;
1763#ifdef __cpp_lib_atomic_ref
1765 template<
typename _Tp>
1766 struct atomic_ref : __atomic_ref<_Tp>
1769 atomic_ref(_Tp& __t) noexcept : __atomic_ref<_Tp>(__t)
1772 atomic_ref& operator=(
const atomic_ref&) =
delete;
1774 atomic_ref(
const atomic_ref&) =
default;
1776 using __atomic_ref<_Tp>::operator=;
1780#ifdef __cpp_lib_atomic_lock_free_type_aliases
1781# ifdef _GLIBCXX_HAVE_PLATFORM_WAIT
1782 using atomic_signed_lock_free
1784 using atomic_unsigned_lock_free
1786# elif ATOMIC_INT_LOCK_FREE == 2
1789# elif ATOMIC_LONG_LOCK_FREE == 2
1792# elif ATOMIC_CHAR_LOCK_FREE == 2
1796# error "libstdc++ bug: no lock-free atomics but they were emitted in <version>"
1802_GLIBCXX_END_NAMESPACE_VERSION
constexpr _Tp * addressof(_Tp &__r) noexcept
Returns the actual address of the object or function referenced by r, even in the presence of an over...
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
atomic< unsigned long > atomic_ulong
atomic_ulong
atomic< intmax_t > atomic_intmax_t
atomic_intmax_t
atomic< uintptr_t > atomic_uintptr_t
atomic_uintptr_t
atomic< signed char > atomic_schar
atomic_schar
atomic< int_least8_t > atomic_int_least8_t
atomic_int_least8_t
atomic< unsigned long long > atomic_ullong
atomic_ullong
atomic< uint_fast8_t > atomic_uint_fast8_t
atomic_uint_fast8_t
atomic< intptr_t > atomic_intptr_t
atomic_intptr_t
atomic< int16_t > atomic_int16_t
atomic_int16_t
atomic< size_t > atomic_size_t
atomic_size_t
atomic< long > atomic_long
atomic_long
atomic< uint_least8_t > atomic_uint_least8_t
atomic_uint_least8_t
atomic< short > atomic_short
atomic_short
atomic< uint_least16_t > atomic_uint_least16_t
atomic_uint_least16_t
atomic< uint16_t > atomic_uint16_t
atomic_uint16_t
atomic< uint64_t > atomic_uint64_t
atomic_uint64_t
atomic< int_least32_t > atomic_int_least32_t
atomic_int_least32_t
atomic< uint8_t > atomic_uint8_t
atomic_uint8_t
#define ATOMIC_BOOL_LOCK_FREE
atomic< wchar_t > atomic_wchar_t
atomic_wchar_t
atomic< unsigned int > atomic_uint
atomic_uint
atomic< uint_least32_t > atomic_uint_least32_t
atomic_uint_least32_t
atomic< uint_fast64_t > atomic_uint_fast64_t
atomic_uint_fast64_t
atomic< int_fast32_t > atomic_int_fast32_t
atomic_int_fast32_t
atomic< char > atomic_char
atomic_char
atomic< int > atomic_int
atomic_int
atomic< uint_least64_t > atomic_uint_least64_t
atomic_uint_least64_t
atomic< int64_t > atomic_int64_t
atomic_int64_t
atomic< uintmax_t > atomic_uintmax_t
atomic_uintmax_t
atomic< int_fast16_t > atomic_int_fast16_t
atomic_int_fast16_t
atomic< int32_t > atomic_int32_t
atomic_int32_t
atomic< uint_fast16_t > atomic_uint_fast16_t
atomic_uint_fast16_t
atomic< int8_t > atomic_int8_t
atomic_int8_t
atomic< long long > atomic_llong
atomic_llong
atomic< char16_t > atomic_char16_t
atomic_char16_t
atomic< int_fast64_t > atomic_int_fast64_t
atomic_int_fast64_t
atomic< ptrdiff_t > atomic_ptrdiff_t
atomic_ptrdiff_t
atomic< char32_t > atomic_char32_t
atomic_char32_t
atomic< int_least16_t > atomic_int_least16_t
atomic_int_least16_t
atomic< unsigned char > atomic_uchar
atomic_uchar
atomic< int_fast8_t > atomic_int_fast8_t
atomic_int_fast8_t
memory_order
Enumeration for memory_order.
atomic< unsigned short > atomic_ushort
atomic_ushort
atomic< int_least64_t > atomic_int_least64_t
atomic_int_least64_t
atomic< bool > atomic_bool
atomic_bool
atomic< uint_fast32_t > atomic_uint_fast32_t
atomic_uint_fast32_t
atomic< uint32_t > atomic_uint32_t
atomic_uint32_t
ISO C++ entities toplevel namespace is std.
Generic atomic type, primary class template.