From 3534f8a3eda03c412e71970fa1f1ce9de49404b7 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Mon, 8 Nov 2021 07:48:07 -0700 Subject: [PATCH] std: ppoll: cast number of fds to nfds_t On some systems, the type of the length of a slice is different from the nfds_t type, so cast the slice length to nfds_t. This is already done in poll, so just copy that implementation for ppoll. --- lib/std/os.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/std/os.zig b/lib/std/os.zig index f167e47e2a..66dbe19502 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -5823,7 +5823,8 @@ pub fn ppoll(fds: []pollfd, timeout: ?*const timespec, mask: ?*const sigset_t) P ts_ptr = &ts; ts = timeout_ns.*; } - const rc = system.ppoll(fds.ptr, fds.len, ts_ptr, mask); + const fds_count = math.cast(nfds_t, fds.len) catch return error.SystemResources; + const rc = system.ppoll(fds.ptr, fds_count, ts_ptr, mask); switch (errno(rc)) { .SUCCESS => return @intCast(usize, rc), .FAULT => unreachable,