authorgravatar for greg@gpanders.comGregory Anders <greg@gpanders.com> 2021-11-08 07:48:07-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-11-09 13:36:36-05:00
log3534f8a3eda03c412e71970fa1f1ce9de49404b7
treec2dfc97ce8c30776815e8ee2672d7f7759de86bf
parent082072bd4f4613e798068370681c269860785cbf

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.

1 files changed, 2 insertions(+), 1 deletions(-)

lib/std/os.zig+2-1
...@@ -5823,7 +5823,8 @@ pub fn ppoll(fds: []pollfd, timeout: ?*const timespec, mask: ?*const sigset_t) P...@@ -5823,7 +5823,8 @@ pub fn ppoll(fds: []pollfd, timeout: ?*const timespec, mask: ?*const sigset_t) P
5823 ts_ptr = &ts;5823 ts_ptr = &ts;
5824 ts = timeout_ns.*;5824 ts = timeout_ns.*;
5825 }5825 }
5826 const rc = system.ppoll(fds.ptr, fds.len, ts_ptr, mask);5826 const fds_count = math.cast(nfds_t, fds.len) catch return error.SystemResources;
5827 const rc = system.ppoll(fds.ptr, fds_count, ts_ptr, mask);
5827 switch (errno(rc)) {5828 switch (errno(rc)) {
5828 .SUCCESS => return @intCast(usize, rc),5829 .SUCCESS => return @intCast(usize, rc),
5829 .FAULT => unreachable,5830 .FAULT => unreachable,