mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
cover openbsd too
This commit is contained in:
@@ -504,6 +504,40 @@ gb_internal void tpool_wait_on_addr(Futex *addr, Footex val) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(GB_SYSTEM_OPENBSD)
|
||||||
|
|
||||||
|
#include <sys/futex.h>
|
||||||
|
|
||||||
|
typedef std::atomic<int32_t> Futex;
|
||||||
|
typedef volatile int32_t Footex;
|
||||||
|
|
||||||
|
gb_internal void tpool_wake_addr(Futex *addr) {
|
||||||
|
int ret = futex((volatile uint32_t *)addr, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1, NULL, NULL);
|
||||||
|
if (ret == -1) {
|
||||||
|
perror("Futex wake");
|
||||||
|
GB_PANIC("futex wake fail");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gb_internal void tpool_wait_on_addr(Futex *addr, Footex val) {
|
||||||
|
for (;;) {
|
||||||
|
int ret = futex((volatile uint32_t *)addr, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, val, NULL, NULL);
|
||||||
|
if (ret != -1) {
|
||||||
|
if (*addr != val) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (errno == ETIMEDOUT || errno == EINTR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
perror("Futex wait");
|
||||||
|
GB_PANIC("Failed in futex wait!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#elif defined(GB_SYSTEM_OSX)
|
#elif defined(GB_SYSTEM_OSX)
|
||||||
|
|
||||||
typedef std::atomic<int64_t> Futex;
|
typedef std::atomic<int64_t> Futex;
|
||||||
|
|||||||
Reference in New Issue
Block a user