Change futex_wait_with_timeout to return a boolean rather than an enum

This commit is contained in:
gingerBill
2021-10-11 13:23:11 +01:00
parent a1e8769cff
commit 240b6aab13
5 changed files with 22 additions and 26 deletions
+6 -6
View File
@@ -23,26 +23,26 @@ EINTR :: -4
EFAULT :: -14
ETIMEDOUT :: -60
_futex_wait :: proc(f: ^Futex, expected: u32) -> Futex_Error {
_futex_wait :: proc(f: ^Futex, expected: u32) -> bool {
return _futex_wait_with_timeout(f, expected, 0)
}
_futex_wait_with_timeout :: proc(f: ^Futex, expected: u32, duration: time.Duration) -> Futex_Error {
_futex_wait_with_timeout :: proc(f: ^Futex, expected: u32, duration: time.Duration) -> bool {
timeout_ns := u64(duration)
s := __ulock_wait2(UL_COMPARE_AND_WAIT | ULF_NO_ERRNO, f, u64(expected), timeout_ns, 0)
if s >= 0 {
return nil
return true
}
switch s {
case EINTR, EFAULT:
return nil
return true
case ETIMEDOUT:
return .Timed_Out
return false
case:
panic("futex_wait failure")
}
return nil
return true
}