[libcxx-commits] [libcxx] [libc++] Allows any types of size 4 and 8 to use native platform ulock_wait (PR #161086)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Oct 31 10:59:48 PDT 2025
================
@@ -53,13 +54,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#ifdef __linux__
-static void
-__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {
+template <std::size_t _Size>
+static void __libcpp_platform_wait_on_address(void const volatile* __ptr, void const* __val) {
+ static_assert(_Size == 4, "Can only wait on 4 bytes value");
+ char buffer[_Size];
+ std::memcpy(&buffer, const_cast<const void*>(__val), _Size);
static constexpr timespec __timeout = {2, 0};
- _LIBCPP_FUTEX(__ptr, FUTEX_WAIT_PRIVATE, __val, &__timeout, 0, 0);
+ _LIBCPP_FUTEX(__ptr, FUTEX_WAIT_PRIVATE, *reinterpret_cast<__cxx_contention_t const*>(&buffer), &__timeout, 0, 0);
}
-static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) {
+template <std::size_t _Size>
+static void __libcpp_platform_wake_by_address(void const volatile* __ptr, bool __notify_one) {
----------------
ldionne wrote:
You can (and probably should) get rid of the `__libcpp` prefixes in these local functions.
https://github.com/llvm/llvm-project/pull/161086
More information about the libcxx-commits
mailing list