From: Thomas Rodgers Date: Thu, 10 Feb 2022 18:12:36 +0000 (-0800) Subject: libstdc++: Strengthen memory order for atomic::wait/notify X-Git-Tag: basepoints/gcc-13~1127 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b25a7c05f120e46a60430dcefe529c72303b7022;p=thirdparty%2Fgcc.git libstdc++: Strengthen memory order for atomic::wait/notify This changes the memory order used in the spin wait code to match that of libc++. libstdc++-v3/ChangeLog: * include/bits/atomic_wait.h (__waiter_base::_S_do_spin, __waiter_base::_S_do_spin_v): Change memory order from relaxed to acquire. --- diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h index 6ce7f9343cf5..125b1cad8868 100644 --- a/libstdc++-v3/include/bits/atomic_wait.h +++ b/libstdc++-v3/include/bits/atomic_wait.h @@ -332,7 +332,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else { - __atomic_load(__addr, &__val, __ATOMIC_RELAXED); + __atomic_load(__addr, &__val, __ATOMIC_ACQUIRE); } return __atomic_spin(__pred, __spin); } @@ -353,7 +353,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __platform_wait_t& __val, _Spin __spin = _Spin{ }) { - __atomic_load(__addr, &__val, __ATOMIC_RELAXED); + __atomic_load(__addr, &__val, __ATOMIC_ACQUIRE); return __atomic_spin(__pred, __spin); }