std: Fix compilation on FreeBSD/Darwin

This commit is contained in:
LemonBoy 2020-10-21 18:24:24 +02:00 committed by Andrew Kelley
parent 1667c937a0
commit b297c2eae9
2 changed files with 12 additions and 1 deletions

View File

@ -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()) {

View File

@ -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;