@@ -155,27 +155,30 @@ static void* win32_get_synch_api_function(const char* function_name) {
155155 return reinterpret_cast <void *>(GetProcAddress (module_handle, function_name));
156156}
157157
158- static void
159- __libcpp_platform_wait_on_address (__cxx_atomic_contention_t const volatile * __ptr, __cxx_contention_t __val) {
158+ template <std::size_t _Size>
159+ static void __platform_wait_on_address (void const volatile * __ptr, void const * __val) {
160+ static_assert (_Size == 8 , " Can only wait on 8 bytes value" );
160161 // WaitOnAddress was added in Windows 8 (build 9200)
161162 static auto wait_on_address = reinterpret_cast <BOOL (WINAPI*)(volatile void *, PVOID, SIZE_T, DWORD)>(
162163 win32_get_synch_api_function (" WaitOnAddress" ));
163164 if (wait_on_address != nullptr ) {
164- wait_on_address (const_cast <__cxx_atomic_contention_t *>(__ptr), &__val, sizeof (__val) , INFINITE);
165+ wait_on_address (const_cast <void *>(__ptr), &__val, _Size , INFINITE);
165166 } else {
166167 __libcpp_thread_poll_with_backoff (
167- [=]() -> bool { return ! __cxx_nonatomic_compare_equal ( __cxx_atomic_load (__ptr, memory_order_relaxed ), __val) ; },
168+ [=]() -> bool { return std::memcmp ( const_cast < const void *> (__ptr), __val, _Size) != 0 ; },
168169 __libcpp_timed_backoff_policy ());
169170 }
170171}
171172
172- static void __libcpp_platform_wake_by_address (__cxx_atomic_contention_t const volatile * __ptr, bool __notify_one) {
173+ template <std::size_t _Size>
174+ static void __platform_wake_by_address (void const volatile * __ptr, bool __notify_one) {
175+ static_assert (_Size == 8 , " Can only wake up on 8 bytes value" );
173176 if (__notify_one) {
174177 // WakeByAddressSingle was added in Windows 8 (build 9200)
175178 static auto wake_by_address_single =
176179 reinterpret_cast <void (WINAPI*)(PVOID)>(win32_get_synch_api_function (" WakeByAddressSingle" ));
177180 if (wake_by_address_single != nullptr ) {
178- wake_by_address_single (const_cast <__cxx_atomic_contention_t *>(__ptr));
181+ wake_by_address_single (const_cast <void *>(__ptr));
179182 } else {
180183 // The fallback implementation of waking does nothing, as the fallback wait implementation just does polling, so
181184 // there's nothing to do here.
@@ -185,7 +188,7 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
185188 static auto wake_by_address_all =
186189 reinterpret_cast <void (WINAPI*)(PVOID)>(win32_get_synch_api_function (" WakeByAddressAll" ));
187190 if (wake_by_address_all != nullptr ) {
188- wake_by_address_all (const_cast <__cxx_atomic_contention_t *>(__ptr));
191+ wake_by_address_all (const_cast <void *>(__ptr));
189192 } else {
190193 // The fallback implementation of waking does nothing, as the fallback wait implementation just does polling, so
191194 // there's nothing to do here.
0 commit comments