From d6540d9077cbfe18f0d6804ec2a301c04758c820 Mon Sep 17 00:00:00 2001 From: Rickard Andersson Date: Wed, 14 Jun 2023 23:26:43 +0300 Subject: [PATCH] fix(os_linux): call `ppoll` instead on `arm64` --- core/os/os_linux.odin | 4 +--- core/sys/unix/syscalls_linux.odin | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/core/os/os_linux.odin b/core/os/os_linux.odin index 70e842aa4..3e5258af3 100644 --- a/core/os/os_linux.odin +++ b/core/os/os_linux.odin @@ -440,9 +440,7 @@ pollfd :: struct { nfds_t :: distinct c.uint -sigset_t :: struct { - __val: [16]c.ulong, -} +sigset_t :: distinct u64 foreign libc { @(link_name="__errno_location") __errno_location :: proc() -> ^int --- diff --git a/core/sys/unix/syscalls_linux.odin b/core/sys/unix/syscalls_linux.odin index 54f8bcc25..2e5bad153 100644 --- a/core/sys/unix/syscalls_linux.odin +++ b/core/sys/unix/syscalls_linux.odin @@ -2079,7 +2079,22 @@ sys_select :: proc "contextless" (nfds: int, readfds, writefds, exceptfds: rawpt } sys_poll :: proc "contextless" (fds: rawptr, nfds: uint, timeout: int) -> int { - return int(intrinsics.syscall(SYS_poll, uintptr(fds), uintptr(nfds), uintptr(timeout))) + // NOTE: specialcased here because `arm64` does not have `poll` + when ODIN_ARCH != .arm64 { + // redefined because we can't depend on the `unix` module here + timespec :: struct { + tv_sec: i64, + tv_nsec: i64, + } + seconds := i64(timeout / 1_000) + nanoseconds := i64((timeout % 1000) * 1_000_000) + timeout_spec := timespec{seconds, nanoseconds} + + return int(intrinsics.syscall(SYS_ppoll, uintptr(fds), uintptr(nfds), uintptr(&timeout_spec), uintptr(0), uintptr(8))) + } else { + return int(intrinsics.syscall(SYS_poll, uintptr(fds), uintptr(nfds), uintptr(timeout))) + } + } sys_ppoll :: proc "contextless" (fds: rawptr, nfds: uint, timeout: rawptr, sigmask: rawptr, sigsetsize: uint) -> int {