|
@@ -12,6 +12,7 @@ foreign System {
|
|
// __ulock_wait is not available on 10.15
|
|
// __ulock_wait is not available on 10.15
|
|
// See https://github.com/odin-lang/Odin/issues/1959
|
|
// 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_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_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 ---
|
|
__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)
|
|
timeout_ns := u64(duration)
|
|
s := __ulock_wait2(UL_COMPARE_AND_WAIT | ULF_NO_ERRNO, f, u64(expected), timeout_ns, 0)
|
|
s := __ulock_wait2(UL_COMPARE_AND_WAIT | ULF_NO_ERRNO, f, u64(expected), timeout_ns, 0)
|
|
} else {
|
|
} 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)
|
|
s := __ulock_wait(UL_COMPARE_AND_WAIT | ULF_NO_ERRNO, f, u64(expected), timeout_us)
|
|
}
|
|
}
|
|
|
|
+
|
|
if s >= 0 {
|
|
if s >= 0 {
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
|
|
+
|
|
switch s {
|
|
switch s {
|
|
case EINTR, EFAULT:
|
|
case EINTR, EFAULT:
|
|
return true
|
|
return true
|