From: Jonathan Wakely Date: Thu, 5 Jan 2023 20:23:26 +0000 (+0000) Subject: libstdc++: Use lock-free type for __platform_wait_t X-Git-Tag: basepoints/gcc-14~2088 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dc22cf461278ace754042d9388a62afb002dfa0e;p=thirdparty%2Fgcc.git libstdc++: Use lock-free type for __platform_wait_t For non-futex targets the __platform_wait_t type is currently uint64_t, but that requires a lock in libatomic for some 32-bit targets. We don't really need a 64-bit type, so use unsigned long if that is lock-free, and int otherwise. This should mean it's lock-free on a wider set of targets. libstdc++-v3/ChangeLog: * include/bits/atomic_wait.h (__detail::__platform_wait_t): Define as unsigned long if always lock-free, and unsigned int otherwise. --- diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h index bd1ed56d1576..1d7a034a1658 100644 --- a/libstdc++-v3/include/bits/atomic_wait.h +++ b/libstdc++-v3/include/bits/atomic_wait.h @@ -64,7 +64,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // and __platform_notify() if there is a more efficient primitive supported // by the platform (e.g. __ulock_wait()/__ulock_wake()) which is better than // a mutex/condvar based wait. - using __platform_wait_t = uint64_t; +# if ATOMIC_LONG_LOCK_FREE == 2 + using __platform_wait_t = unsigned long; +# else + using __platform_wait_t = unsigned int; +# endif inline constexpr size_t __platform_wait_alignment = __alignof__(__platform_wait_t); #endif