[PATCH] libstdc++: Clear padding bits in atomic compare_exchange
Thomas Rodgers
trodgers@redhat.com
Thu Sep 23 20:15:09 GMT 2021
Agreed, I'll revise the patch to do so.
On Thu, Sep 23, 2021 at 12:07 PM Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Sep 23, 2021 at 11:08:37AM -0700, Thomas Rodgers wrote:
> > From: Thomas Rodgers <rodgert@twrodgers.com>
> >
> > This change implements P0528 which requires that padding bits not
> > participate in atomic compare exchange operations. All arguments to the
>
> Thanks for working on this.
>
> > generic template are 'sanitized' by the __builtin_clear_padding intrinsic
> > before they are used in atomic compare_exchange. This alrequires that any
> > stores also sanitize the incoming value.
>
> Not a review, just random nit.
> Shouldn't the __builtin_clear_padding calls be guarded with
> #if __has_builtin(__builtin_clear_padding)
> or #ifdef _GLIBCXX_HAVE_BUILTIN_CLEAR_PADDING defined based on that?
> I think clang doesn't support it (yet?), and it doesn't support the MSVC
> __builtin_zero_non_value_bits (with very similar, but slightly different,
> behavior).
>
> > Signed-off-by: Thomas Rodgers <trodgers@redhat.com>
> >
> > libstdc++=v3/ChangeLog:
> >
> > * include/std/atomic (atomic<T>::atomic(_Tp) clear padding for
> > __cplusplus > 201703L.
> > (atomic<T>::store()) Clear padding.
> > (atomic<T>::exchange()) Likewise.
> > (atomic<T>::compare_exchange_weak()) Likewise.
> > (atomic<T>::compare_exchange_strong()) Likewise.
> > * testsuite/29_atomics/atomic/compare_exchange_padding.cc: New
> > test.
>
> Jakub
>
>
More information about the Libstdc++
mailing list