Make sync calls contextless where possible

This commit is contained in:
gingerBill
2022-12-08 15:55:53 +00:00
parent 9cb9964c2d
commit 20943a81c1
11 changed files with 171 additions and 155 deletions
+7 -7
View File
@@ -24,11 +24,11 @@ EINTR :: -4
EFAULT :: -14
ETIMEDOUT :: -60
_futex_wait :: proc(f: ^Futex, expected: u32) -> bool {
_futex_wait :: proc "contextless" (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) -> bool {
_futex_wait_with_timeout :: proc "contextless" (f: ^Futex, expected: u32, duration: time.Duration) -> bool {
timeout_ns := u32(duration) * 1000
s := __ulock_wait(UL_COMPARE_AND_WAIT | ULF_NO_ERRNO, f, u64(expected), timeout_ns)
@@ -41,13 +41,13 @@ _futex_wait_with_timeout :: proc(f: ^Futex, expected: u32, duration: time.Durati
case ETIMEDOUT:
return false
case:
panic("futex_wait failure")
_panic("futex_wait failure")
}
return true
}
_futex_signal :: proc(f: ^Futex) {
_futex_signal :: proc "contextless" (f: ^Futex) {
loop: for {
s := __ulock_wake(UL_COMPARE_AND_WAIT | ULF_NO_ERRNO, f, 0)
if s >= 0 {
@@ -59,12 +59,12 @@ _futex_signal :: proc(f: ^Futex) {
case ENOENT:
return
case:
panic("futex_wake_single failure")
_panic("futex_wake_single failure")
}
}
}
_futex_broadcast :: proc(f: ^Futex) {
_futex_broadcast :: proc "contextless" (f: ^Futex) {
loop: for {
s := __ulock_wake(UL_COMPARE_AND_WAIT | ULF_NO_ERRNO | ULF_WAKE_ALL, f, 0)
if s >= 0 {
@@ -76,7 +76,7 @@ _futex_broadcast :: proc(f: ^Futex) {
case ENOENT:
return
case:
panic("futex_wake_all failure")
_panic("futex_wake_all failure")
}
}
}