mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Use RtlWaitOnAddress to allow for a i64 sized duration rather than u32
This commit is contained in:
@@ -5,28 +5,28 @@ package sync
|
|||||||
import "core:time"
|
import "core:time"
|
||||||
|
|
||||||
foreign import Synchronization "system:Synchronization.lib"
|
foreign import Synchronization "system:Synchronization.lib"
|
||||||
|
|
||||||
@(default_calling_convention="stdcall")
|
@(default_calling_convention="stdcall")
|
||||||
foreign Synchronization {
|
foreign Synchronization {
|
||||||
WaitOnAddress :: proc(Address: rawptr, CompareAddress: rawptr, AddressSize: uint, Timeout: u32) -> b32 ---
|
|
||||||
WakeByAddressSingle :: proc(Address: rawptr) ---
|
WakeByAddressSingle :: proc(Address: rawptr) ---
|
||||||
WakeByAddressAll :: proc(Address: rawptr) ---
|
WakeByAddressAll :: proc(Address: rawptr) ---
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreign import Ntdll "system:Ntdll.lib"
|
||||||
|
@(default_calling_convention="stdcall")
|
||||||
|
foreign Ntdll {
|
||||||
|
RtlWaitOnAddress :: proc(Address: rawptr, CompareAddress: rawptr, AddressSize: uint, Timeout: ^i64) -> i32 ---
|
||||||
|
}
|
||||||
|
|
||||||
_futex_wait :: proc(f: ^Futex, expect: u32) -> bool {
|
_futex_wait :: proc(f: ^Futex, expect: u32) -> bool {
|
||||||
expect := expect
|
expect := expect
|
||||||
return bool(WaitOnAddress(f, &expect, size_of(expect), ~u32(0)))
|
return 0 == RtlWaitOnAddress(f, &expect, size_of(expect), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
_futex_wait_with_timeout :: proc(f: ^Futex, expect: u32, duration: time.Duration) -> bool {
|
_futex_wait_with_timeout :: proc(f: ^Futex, expect: u32, duration: time.Duration) -> bool {
|
||||||
expect := expect
|
expect := expect
|
||||||
timeout := u32(0)
|
// NOTE(bill): for some bizarre reason, this has be a negative number
|
||||||
if duration > 0 {
|
timeout := -i64(duration / 100)
|
||||||
timeout = u32(duration/1e6)
|
return 0 == RtlWaitOnAddress(f, &expect, size_of(expect), &timeout)
|
||||||
}
|
|
||||||
return bool(WaitOnAddress(f, &expect, size_of(expect), timeout))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_futex_signal :: proc(f: ^Futex) {
|
_futex_signal :: proc(f: ^Futex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user