diff options
author | Thomas Rodgers <trodgers@redhat.com> | 2022-08-25 12:11:40 +0200 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2022-09-08 19:29:12 +0100 |
commit | 157236dbd621644b3cec50b6cf38811959f3e78c (patch) | |
tree | af9e5ef2a4382cb1af7d6083b3945936e60d18f5 /gcc | |
parent | d3883dc77b1426984c0edea6081f57ed2305c9f2 (diff) | |
download | gcc-157236dbd621644b3cec50b6cf38811959f3e78c.zip gcc-157236dbd621644b3cec50b6cf38811959f3e78c.tar.gz gcc-157236dbd621644b3cec50b6cf38811959f3e78c.tar.bz2 |
libstdc++: Clear padding bits in atomic compare_exchange
This change implements P0528 which requires that padding bits not
participate in atomic compare exchange operations. All arguments to the
generic template are 'sanitized' by the __builtin_clear_padding intrinsic
before they are used in comparisons. This requires that any stores
also sanitize the incoming value.
Co-authored-by: Jakub Jelinek <jakub@redhat.com>
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Thomas Rodgers <trodgers@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/atomic_base.h (__atomic_impl::__maybe_has_padding):
New function.
(__atomic_impl::clear_padding): Likewise.
(__atomic_impl::__compare_exchange): Likewise.
(__atomic_impl::compare_exchange_weak): Delegate to
__compare_exchange.
(__atomic_impl::compare_exchange_strong): Likewise.
* include/std/atomic (atomic<T>::atomic(T)): Clear padding when
possible in a constexpr function.
(atomic::store): Clear padding.
(atomic::exchange): Likewise.
(atomic::compare_exchange_weak): Use __compare_exchange.
(atomic::compare_exchange_strong): Likewise.
* testsuite/29_atomics/atomic/compare_exchange_padding.cc: New
test.
* testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc:
New test.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions