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
@@ -39,22 +39,22 @@ internal_futex :: proc(f: ^Futex, op: c.int, val: u32, timeout: rawptr) -> int {
}
_futex_wait :: proc(f: ^Futex, expected: u32) -> Futex_Error {
_futex_wait :: proc(f: ^Futex, expected: u32) -> bool {
err := internal_futex(f, FUTEX_WAIT_PRIVATE | FUTEX_WAIT, expected, nil)
switch err {
case ESUCCESS, EINTR, EAGAIN, EINVAL:
// okay
case ETIMEDOUT:
return .Timed_Out
return false
case EFAULT:
fallthrough
case:
panic("futex_wait failure")
}
return nil
return true
}
_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 {
timespec_t :: struct {
tv_sec: c.long,
tv_nsec: c.long,
@@ -74,13 +74,13 @@ _futex_wait_with_timeout :: proc(f: ^Futex, expected: u32, duration: time.Durati
case ESUCCESS, EINTR, EAGAIN, EINVAL:
// okay
case ETIMEDOUT:
return .Timed_Out
return false
case EFAULT:
fallthrough
case:
panic("futex_wait_with_timeout failure")
}
return nil
return true
}