From 2c16a9668632be83c5e1bb0baeb00d221bb0eca1 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 21 Oct 2020 16:29:15 +0200 Subject: [PATCH] std: Fix poll definitions for FreeBSD/Darwin --- lib/std/os/bits/darwin.zig | 2 +- lib/std/os/bits/freebsd.zig | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/std/os/bits/darwin.zig b/lib/std/os/bits/darwin.zig index b9fe23eeb1..5016134e76 100644 --- a/lib/std/os/bits/darwin.zig +++ b/lib/std/os/bits/darwin.zig @@ -1461,7 +1461,7 @@ pub const LOCK_EX = 2; pub const LOCK_UN = 8; pub const LOCK_NB = 4; -pub const nfds_t = usize; +pub const nfds_t = u32; pub const pollfd = extern struct { fd: fd_t, events: i16, diff --git a/lib/std/os/bits/freebsd.zig b/lib/std/os/bits/freebsd.zig index 08713bb2e4..351e86caa1 100644 --- a/lib/std/os/bits/freebsd.zig +++ b/lib/std/os/bits/freebsd.zig @@ -1480,3 +1480,28 @@ pub const rlimit = extern struct { pub const SHUT_RD = 0; pub const SHUT_WR = 1; pub const SHUT_RDWR = 2; + +pub const nfds_t = u32; + +pub const pollfd = extern struct { + fd: fd_t, + events: i16, + revents: i16, +}; + +/// any readable data available. +pub const POLLIN = 0x0001; +/// OOB/Urgent readable data. +pub const POLLPRI = 0x0002; +/// file descriptor is writeable. +pub const POLLOUT = 0x0004; +/// non-OOB/URG data available. +pub const POLLRDNORM = 0x0040; +/// no write type differentiation. +pub const POLLWRNORM = POLLOUT; +/// OOB/Urgent readable data. +pub const POLLRDBAND = 0x0080; +/// OOB/Urgent data can be written. +pub const POLLWRBAND = 0x0100; +/// like POLLIN, except ignore EOF. +pub const POLLINIGNEOF = 0x2000;