Commit b297c2eae9

LemonBoy <thatlemon@gmail.com>
2020-10-21 18:24:24
std: Fix compilation on FreeBSD/Darwin
1 parent 1667c93
Changed files (2)
lib
std
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;
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()) {