From: Jonathan Wakely Date: Tue, 18 Jan 2022 21:15:05 +0000 (+0000) Subject: libstdc++: Fix std::atomic> for AIX [PR104101] X-Git-Tag: basepoints/gcc-13~1605 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c3861f79859d96777f86a24261fe639538fd2e1c;p=thirdparty%2Fgcc.git libstdc++: Fix std::atomic> for AIX [PR104101] This fixes an on AIX. The lock function currently just spins, which should be changed to use back-off, and maybe then _M_val.wait(__current) when supported. libstdc++-v3/ChangeLog: PR libstdc++/104101 * include/bits/shared_ptr_atomic.h (_Sp_atomic::_Atomic_count::lock): Only use __thread_relax if __cpp_lib_atomic_wait is defined. --- diff --git a/libstdc++-v3/include/bits/shared_ptr_atomic.h b/libstdc++-v3/include/bits/shared_ptr_atomic.h index 50aa46370cab..35f781dc9a09 100644 --- a/libstdc++-v3/include/bits/shared_ptr_atomic.h +++ b/libstdc++-v3/include/bits/shared_ptr_atomic.h @@ -392,7 +392,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION auto __current = _M_val.load(memory_order_relaxed); while (__current & _S_lock_bit) { +#if __cpp_lib_atomic_wait __detail::__thread_relax(); +#endif __current = _M_val.load(memory_order_relaxed); } @@ -401,7 +403,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __o, memory_order_relaxed)) { +#if __cpp_lib_atomic_wait __detail::__thread_relax(); +#endif __current = __current & ~_S_lock_bit; } return reinterpret_cast(__current);