diff --git a/dll/kernel32/synchapi.cpp b/dll/kernel32/synchapi.cpp index 88e08d3..a93add7 100644 --- a/dll/kernel32/synchapi.cpp +++ b/dll/kernel32/synchapi.cpp @@ -197,14 +197,14 @@ inline void platformNotifyAddress(void *address, size_t, bool wakeOne) { } } -#elif defined(__linux__) +#else template void platformWaitIndefinite(T volatile *address, T expected) { - std::atomic_ref ref(*address); + std::atomic_ref ref(*const_cast(address)); ref.wait(expected, std::memory_order_relaxed); } -template void linuxNotify(void *address, bool wakeOne) { +template void atomicNotify(void *address, bool wakeOne) { auto *typed = reinterpret_cast(address); std::atomic_ref ref(*typed); if (wakeOne) { @@ -217,32 +217,22 @@ template void linuxNotify(void *address, bool wakeOne) { inline void platformNotifyAddress(void *address, size_t size, bool wakeOne) { switch (size) { case 1: - linuxNotify(address, wakeOne); + atomicNotify(address, wakeOne); break; case 2: - linuxNotify(address, wakeOne); + atomicNotify(address, wakeOne); break; case 4: - linuxNotify(address, wakeOne); + atomicNotify(address, wakeOne); break; case 8: - linuxNotify(address, wakeOne); + atomicNotify(address, wakeOne); break; default: break; } } -#else - -template void platformWaitIndefinite(T volatile *address, T expected) { - while (__atomic_load_n(address, __ATOMIC_ACQUIRE) == expected) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } -} - -inline void platformNotifyAddress(void *, size_t, bool) {} - #endif void notifyAtomicWaiters(void *address, const std::array &sizeCounts, bool wakeOne) {