mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Clean up _futex_wait_with_timeout on Linux
This commit is contained in:
@@ -55,21 +55,19 @@ _futex_wait :: proc(f: ^Futex, expected: u32) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_futex_wait_with_timeout :: proc(f: ^Futex, expected: u32, duration: time.Duration) -> bool {
|
_futex_wait_with_timeout :: proc(f: ^Futex, expected: u32, duration: time.Duration) -> bool {
|
||||||
|
if duration <= 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
timespec_t :: struct {
|
timespec_t :: struct {
|
||||||
tv_sec: c.long,
|
tv_sec: c.long,
|
||||||
tv_nsec: c.long,
|
tv_nsec: c.long,
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout: timespec_t
|
err := internal_futex(f, FUTEX_WAIT_PRIVATE | FUTEX_WAIT, expected, ×pec_t{
|
||||||
timeout_ptr: ^timespec_t = nil
|
tv_sec = (c.long)(duration/1e9),
|
||||||
|
tv_nsec = (c.long)(duration%1e9),
|
||||||
if duration > 0 {
|
})
|
||||||
timeout.tv_sec = (c.long)(duration/1e9)
|
|
||||||
timeout.tv_nsec = (c.long)(duration%1e9)
|
|
||||||
timeout_ptr = &timeout
|
|
||||||
}
|
|
||||||
|
|
||||||
err := internal_futex(f, FUTEX_WAIT_PRIVATE | FUTEX_WAIT, expected, &timeout)
|
|
||||||
switch err {
|
switch err {
|
||||||
case ESUCCESS, EINTR, EAGAIN, EINVAL:
|
case ESUCCESS, EINTR, EAGAIN, EINVAL:
|
||||||
// okay
|
// okay
|
||||||
|
|||||||
Reference in New Issue
Block a user