aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include/__atomic
diff options
context:
space:
mode:
authorHui <hui.xie1990@gmail.com>2026-02-12 19:14:18 +0000
committerGitHub <noreply@github.com>2026-02-12 19:14:18 +0000
commit155beb97492e14e29ab7af3a805bbfb97bee1e6b (patch)
tree30b6ac0acc073cb3e0816bf8debf6298cec54707 /libcxx/include/__atomic
parenta1c4c1de051974a6fea4e9eda0f5df1c4fab462e (diff)
downloadllvm-main.zip
llvm-main.tar.gz
llvm-main.tar.bz2
[libc++] Fix native wait alignment (#180928)HEADmain
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.h9
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