diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 98c3f6131ee97a17ac425e376894106979dca7e5..8e6ec0dec4bb2f60a8340835dc367ffae5f74eed 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -1256,21 +1256,23 @@ pub fn munlockall() usize { } pub fn poll(fds: [*]pollfd, n: nfds_t, timeout: i32) usize { - return if (@hasField(SYS, "poll")) - return syscall3(.poll, @intFromPtr(fds), n, @as(u32, @bitCast(timeout))) - else - ppoll( + if (@hasField(SYS, "poll")) { + return syscall3(.poll, @intFromPtr(fds), n, @as(u32, @bitCast(timeout))); + } else { + var ts: timespec = if (timeout >= 0) + .{ + .sec = @divTrunc(timeout, 1000), + .nsec = @rem(timeout, 1000) * 1000000, + } + else + undefined; + return ppoll( fds, n, - if (timeout >= 0) - @constCast(×pec{ - .sec = @divTrunc(timeout, 1000), - .nsec = @rem(timeout, 1000) * 1000000, - }) - else - null, + if (timeout >= 0) &ts else null, null, ); + } } pub fn ppoll(fds: [*]pollfd, n: nfds_t, timeout: ?*timespec, sigmask: ?*const sigset_t) usize {