diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-09-17 15:52:35 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-09-17 15:52:35 +0200 |
| commit | 0975820c48f8e876c2838a5ef94400fdb5db0f87 (patch) | |
| tree | 8eaf5cd5f4093e58081e5164734884918d9040d7 /core/sync | |
| parent | 0d33df15b4af3a7a1afa9431fbfeff99c4f705c2 (diff) | |
fix wrong ulock timeout calculation, add version check for ios
Diffstat (limited to 'core/sync')
| -rw-r--r-- | core/sync/futex_darwin.odin | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/core/sync/futex_darwin.odin b/core/sync/futex_darwin.odin index 32fdb1552..87b7b96e6 100644 --- a/core/sync/futex_darwin.odin +++ b/core/sync/futex_darwin.odin @@ -12,6 +12,7 @@ foreign System { // __ulock_wait is not available on 10.15 // See https://github.com/odin-lang/Odin/issues/1959 __ulock_wait :: proc "c" (operation: u32, addr: rawptr, value: u64, timeout_us: u32) -> c.int --- + // >= MacOS 11. __ulock_wait2 :: proc "c" (operation: u32, addr: rawptr, value: u64, timeout_ns: u64, value2: u64) -> c.int --- __ulock_wake :: proc "c" (operation: u32, addr: rawptr, wake_value: u64) -> c.int --- } @@ -57,12 +58,14 @@ _futex_wait_with_timeout :: proc "contextless" (f: ^Futex, expected: u32, durati timeout_ns := u64(duration) s := __ulock_wait2(UL_COMPARE_AND_WAIT | ULF_NO_ERRNO, f, u64(expected), timeout_ns, 0) } else { - timeout_us := u32(duration) * 1000 + timeout_us := u32(duration / time.Microsecond) s := __ulock_wait(UL_COMPARE_AND_WAIT | ULF_NO_ERRNO, f, u64(expected), timeout_us) } + if s >= 0 { return true } + switch s { case EINTR, EFAULT: return true |