From 52475b1761bb275829c326cfda65200d63c5dd9d Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sun, 4 Sep 2022 13:11:06 +0200 Subject: [PATCH] Use __ulock_wait macOS; fix #1959 --- core/sync/futex_darwin.odin | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/sync/futex_darwin.odin b/core/sync/futex_darwin.odin index a106faa9c..1c118e75d 100644 --- a/core/sync/futex_darwin.odin +++ b/core/sync/futex_darwin.odin @@ -8,8 +8,9 @@ import "core:time" foreign import System "System.framework" 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 --- - __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 --- } @@ -28,9 +29,9 @@ _futex_wait :: proc(f: ^Futex, expected: u32) -> bool { } _futex_wait_with_timeout :: proc(f: ^Futex, expected: u32, duration: time.Duration) -> bool { - timeout_ns := u64(duration) + timeout_ns := u32(duration) * 1000 - s := __ulock_wait2(UL_COMPARE_AND_WAIT | ULF_NO_ERRNO, f, u64(expected), timeout_ns, 0) + s := __ulock_wait(UL_COMPARE_AND_WAIT | ULF_NO_ERRNO, f, u64(expected), timeout_ns) if s >= 0 { return true }