mirror of
https://github.com/decompals/wibo.git
synced 2025-12-13 07:06:18 +00:00
Fix Linux build
This commit is contained in:
@@ -197,14 +197,14 @@ inline void platformNotifyAddress(void *address, size_t, bool wakeOne) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(__linux__)
|
#else
|
||||||
|
|
||||||
template <typename T> void platformWaitIndefinite(T volatile *address, T expected) {
|
template <typename T> void platformWaitIndefinite(T volatile *address, T expected) {
|
||||||
std::atomic_ref<T> ref(*address);
|
std::atomic_ref<T> ref(*const_cast<T *>(address));
|
||||||
ref.wait(expected, std::memory_order_relaxed);
|
ref.wait(expected, std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> void linuxNotify(void *address, bool wakeOne) {
|
template <typename T> void atomicNotify(void *address, bool wakeOne) {
|
||||||
auto *typed = reinterpret_cast<T *>(address);
|
auto *typed = reinterpret_cast<T *>(address);
|
||||||
std::atomic_ref<T> ref(*typed);
|
std::atomic_ref<T> ref(*typed);
|
||||||
if (wakeOne) {
|
if (wakeOne) {
|
||||||
@@ -217,32 +217,22 @@ template <typename T> void linuxNotify(void *address, bool wakeOne) {
|
|||||||
inline void platformNotifyAddress(void *address, size_t size, bool wakeOne) {
|
inline void platformNotifyAddress(void *address, size_t size, bool wakeOne) {
|
||||||
switch (size) {
|
switch (size) {
|
||||||
case 1:
|
case 1:
|
||||||
linuxNotify<uint8_t>(address, wakeOne);
|
atomicNotify<uint8_t>(address, wakeOne);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
linuxNotify<uint16_t>(address, wakeOne);
|
atomicNotify<uint16_t>(address, wakeOne);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
linuxNotify<uint32_t>(address, wakeOne);
|
atomicNotify<uint32_t>(address, wakeOne);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
linuxNotify<uint64_t>(address, wakeOne);
|
atomicNotify<uint64_t>(address, wakeOne);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
template <typename T> 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
|
#endif
|
||||||
|
|
||||||
void notifyAtomicWaiters(void *address, const std::array<size_t, kSupportedAddressSizes> &sizeCounts, bool wakeOne) {
|
void notifyAtomicWaiters(void *address, const std::array<size_t, kSupportedAddressSizes> &sizeCounts, bool wakeOne) {
|
||||||
|
|||||||
Reference in New Issue
Block a user