mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-20 09:35:05 +08:00
libstdc++: Implement std::atomic<T*>::compare_exchange_weak
For some reason r170217 didn't add compare_exchange_weak to the __atomic_base<T*> partial specialization, and so weak compare exchange operations on pointers use compare_exchange_strong instead. This adds __atomic_base<T*>::compare_exchange_weak and then uses it in std::atomic<T*>::compare_exchange_weak. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/bits/atomic_base.h (__atomic_base<P*>::compare_exchange_weak): Add new functions. * include/std/atomic (atomic<T*>::compare_exchange_weak): Use it.
This commit is contained in:
parent
892400f1f2
commit
89cf858571
@ -846,6 +846,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
return __atomic_exchange_n(&_M_p, __p, int(__m));
|
||||
}
|
||||
|
||||
_GLIBCXX_ALWAYS_INLINE bool
|
||||
compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
|
||||
memory_order __m1,
|
||||
memory_order __m2) noexcept
|
||||
{
|
||||
__glibcxx_assert(__is_valid_cmpexch_failure_order(__m2));
|
||||
|
||||
return __atomic_compare_exchange_n(&_M_p, &__p1, __p2, 1,
|
||||
int(__m1), int(__m2));
|
||||
}
|
||||
|
||||
_GLIBCXX_ALWAYS_INLINE bool
|
||||
compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
|
||||
memory_order __m1,
|
||||
memory_order __m2) volatile noexcept
|
||||
{
|
||||
__glibcxx_assert(__is_valid_cmpexch_failure_order(__m2));
|
||||
|
||||
return __atomic_compare_exchange_n(&_M_p, &__p1, __p2, 1,
|
||||
int(__m1), int(__m2));
|
||||
}
|
||||
|
||||
_GLIBCXX_ALWAYS_INLINE bool
|
||||
compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
|
||||
memory_order __m1,
|
||||
|
@ -595,13 +595,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
bool
|
||||
compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
|
||||
memory_order __m1, memory_order __m2) noexcept
|
||||
{ return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
|
||||
{ return _M_b.compare_exchange_weak(__p1, __p2, __m1, __m2); }
|
||||
|
||||
bool
|
||||
compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
|
||||
memory_order __m1,
|
||||
memory_order __m2) volatile noexcept
|
||||
{ return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
|
||||
{ return _M_b.compare_exchange_weak(__p1, __p2, __m1, __m2); }
|
||||
|
||||
bool
|
||||
compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
|
||||
|
Loading…
Reference in New Issue
Block a user