diff --git a/lib/std/os.zig b/lib/std/os.zig index 28d4f6bb1a..88f6292629 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -5269,7 +5269,9 @@ pub const PollError = error{ pub fn poll(fds: []pollfd, timeout: i32) PollError!usize { while (true) { - const rc = system.poll(fds.ptr, fds.len, timeout); + const fds_count = math.cast(nfds_t, fds.len) catch + return error.SystemResources; + const rc = system.poll(fds.ptr, fds_count, timeout); if (builtin.os.tag == .windows) { if (rc == windows.ws2_32.SOCKET_ERROR) { switch (windows.ws2_32.WSAGetLastError()) { diff --git a/lib/std/os/bits/freebsd.zig b/lib/std/os/bits/freebsd.zig index 351e86caa1..13e14df33c 100644 --- a/lib/std/os/bits/freebsd.zig +++ b/lib/std/os/bits/freebsd.zig @@ -1505,3 +1505,12 @@ pub const POLLRDBAND = 0x0080; pub const POLLWRBAND = 0x0100; /// like POLLIN, except ignore EOF. pub const POLLINIGNEOF = 0x2000; +/// some poll error occurred. +pub const POLLERR = 0x0008; +/// file descriptor was "hung up". +pub const POLLHUP = 0x0010; +/// requested events "invalid". +pub const POLLNVAL = 0x0020; + +pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND | + POLLWRBAND | POLLERR | POLLHUP | POLLNVAL;