diff options
| author | Hui <hui.xie1990@gmail.com> | 2026-02-12 19:14:18 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-12 19:14:18 +0000 |
| commit | 155beb97492e14e29ab7af3a805bbfb97bee1e6b (patch) | |
| tree | 30b6ac0acc073cb3e0816bf8debf6298cec54707 /libcxx/include/__atomic | |
| parent | a1c4c1de051974a6fea4e9eda0f5df1c4fab462e (diff) | |
| download | llvm-main.zip llvm-main.tar.gz llvm-main.tar.bz2 | |
This PR fixes two issues regarding the alignment of native wait:
- In the internal platform call, the local variable is copied from a
potentially non-aligned buffer
- Under the unstable ABI, the predicate to test eligibility of a type
being able to do native wait is purely on size. We should test also the
alignment of such type is qualified for platform call
---------
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
Diffstat (limited to 'libcxx/include/__atomic')
| -rw-r--r-- | libcxx/include/__atomic/atomic_waitable_traits.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libcxx/include/__atomic/atomic_waitable_traits.h b/libcxx/include/__atomic/atomic_waitable_traits.h index 72ae4b7..369cd2c 100644 --- a/libcxx/include/__atomic/atomic_waitable_traits.h +++ b/libcxx/include/__atomic/atomic_waitable_traits.h @@ -67,8 +67,11 @@ concept __atomic_waitable = requires(const _Tp __t, memory_order __order) { # if defined(_LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE) -_LIBCPP_HIDE_FROM_ABI constexpr bool __has_native_atomic_wait_impl(size_t __size) { - switch (__size) { +template <class _Tp> +_LIBCPP_HIDE_FROM_ABI constexpr bool __has_native_atomic_wait_impl() { + if (alignof(_Tp) % sizeof(_Tp) != 0) + return false; + switch (sizeof(_Tp)) { # define _LIBCPP_MAKE_CASE(n) \ case n: \ return true; @@ -82,7 +85,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __has_native_atomic_wait_impl(size_t __size template <class _Tp> concept __has_native_atomic_wait = has_unique_object_representations_v<_Tp> && is_trivially_copyable_v<_Tp> && - __has_native_atomic_wait_impl(sizeof(_Tp)); + std::__has_native_atomic_wait_impl<_Tp>(); # else // _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE |
