| ... | @@ -2167,6 +2167,10 @@ pub const libc = struct { | ... | @@ -2167,6 +2167,10 @@ pub const libc = struct { |
| 2167 | /// https://pubs.opengroup.org/onlinepubs/9799919799/functions/pipe.html | 2167 | /// https://pubs.opengroup.org/onlinepubs/9799919799/functions/pipe.html |
| 2168 | pub extern fn pipe2(pipefd: *[2]c_int, flag: c_int) c_int; | 2168 | pub extern fn pipe2(pipefd: *[2]c_int, flag: c_int) c_int; |
| 2169 | | 2169 | |
| | 2170 | /// int poll(struct pollfd fds[], nfds_t nfds, int timeout); |
| | 2171 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/poll.html |
| | 2172 | pub extern fn poll(fds: [*]struct_pollfd, nfds: nfds_t, timeout: c_int) c_int; |
| | 2173 | |
| 2170 | /// double pow(double x, double y); | 2174 | /// double pow(double x, double y); |
| 2171 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pow.html | 2175 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/pow.html |
| 2172 | pub extern fn pow(x: f64, y: f64) f64; | 2176 | pub extern fn pow(x: f64, y: f64) f64; |
| ... | @@ -2856,6 +2860,8 @@ pub const struct_sockaddr_un = extern struct { family: AF = .UNIX, path: [108]u8 | ... | @@ -2856,6 +2860,8 @@ pub const struct_sockaddr_un = extern struct { family: AF = .UNIX, path: [108]u8 |
| 2856 | pub const struct_addrinfo = extern struct { flags: c_int, family: c_int, socktype: c_int, protocol: c_int, addrlen: socklen_t, addr: ?*struct_sockaddr, canonname: ?[*:0]u8, next: ?*struct_addrinfo }; | 2860 | pub const struct_addrinfo = extern struct { flags: c_int, family: c_int, socktype: c_int, protocol: c_int, addrlen: socklen_t, addr: ?*struct_sockaddr, canonname: ?[*:0]u8, next: ?*struct_addrinfo }; |
| 2857 | pub const struct_dirent = extern struct { ino: ino_t, off: off_t, reclen: c_ushort, type: DT, name: [NAME_MAX + 1]u8 }; | 2861 | pub const struct_dirent = extern struct { ino: ino_t, off: off_t, reclen: c_ushort, type: DT, name: [NAME_MAX + 1]u8 }; |
| 2858 | pub const cpu_set_t = [1024 / 8 / @sizeOf(c_ulong)]c_ulong; | 2862 | pub const cpu_set_t = [1024 / 8 / @sizeOf(c_ulong)]c_ulong; |
| | 2863 | pub const nfds_t = c_ulong; |
| | 2864 | pub const struct_pollfd = extern struct { fd: c_int, events: c_short, revents: c_short }; |
| 2859 | | 2865 | |
| 2860 | const impdef = @cImport({ | 2866 | const impdef = @cImport({ |
| 2861 | @cInclude("pthread.h"); | 2867 | @cInclude("pthread.h"); |
| ... | @@ -3250,6 +3256,21 @@ pub const SIG = struct { | ... | @@ -3250,6 +3256,21 @@ pub const SIG = struct { |
| 3250 | pub const UNUSED = SYS; | 3256 | pub const UNUSED = SYS; |
| 3251 | }; | 3257 | }; |
| 3252 | | 3258 | |
| | 3259 | pub const POLL = struct { |
| | 3260 | pub const IN = 0x001; |
| | 3261 | pub const PRI = 0x002; |
| | 3262 | pub const OUT = 0x004; |
| | 3263 | pub const ERR = 0x008; |
| | 3264 | pub const HUP = 0x010; |
| | 3265 | pub const NVAL = 0x020; |
| | 3266 | pub const RDNORM = 0x040; |
| | 3267 | pub const RDBAND = 0x080; |
| | 3268 | pub const WRNORM = if (arch.isMIPS()) OUT else 0x100; |
| | 3269 | pub const WRBAND = if (arch.isMIPS()) 0x100 else 0x200; |
| | 3270 | pub const MSG = 0x400; |
| | 3271 | pub const RDHUP = 0x2000; |
| | 3272 | }; |
| | 3273 | |
| 3253 | pub fn getpid() pid_t { | 3274 | pub fn getpid() pid_t { |
| 3254 | return libc.getpid(); | 3275 | return libc.getpid(); |
| 3255 | } | 3276 | } |
| ... | @@ -3619,3 +3640,9 @@ pub fn dup2(fildes: c_int, fildes2: c_int) !void { | ... | @@ -3619,3 +3640,9 @@ pub fn dup2(fildes: c_int, fildes2: c_int) !void { |
| 3619 | if (rc == -1) return errno.fromInt(errno.fromLibC()); | 3640 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 3620 | std.debug.assert(rc >= 0); | 3641 | std.debug.assert(rc >= 0); |
| 3621 | } | 3642 | } |
| | 3643 | pub fn poll(fds: []struct_pollfd, timeout_ms: c_int) !c_int { |
| | 3644 | const rc = libc.poll(fds.ptr, fds.len, timeout_ms); |
| | 3645 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| | 3646 | std.debug.assert(rc >= 0); |
| | 3647 | return rc; |
| | 3648 | } |