aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/linux.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-10-29 02:19:22 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-10-29 02:19:22 -0400
commit67058b9b7089446e16eee3c03ab3f8f9a5d13529 (patch)
tree6c70752e5ad29ce53088f30fa431833c58f36b04 /lib/std/os/linux.zig
parentd5865f5319305b6d06502b64772f8207bae2d6a5 (diff)
downloadzig-67058b9b7089446e16eee3c03ab3f8f9a5d13529.tar.gz
zig-67058b9b7089446e16eee3c03ab3f8f9a5d13529.zip
basic DNS address resolution for linux without libc
Diffstat (limited to 'lib/std/os/linux.zig')
-rw-r--r--lib/std/os/linux.zig22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig
index 2c8500574d..cf7a5dffb0 100644
--- a/lib/std/os/linux.zig
+++ b/lib/std/os/linux.zig
@@ -226,6 +226,28 @@ pub fn munmap(address: [*]const u8, length: usize) usize {
return syscall2(SYS_munmap, @ptrToInt(address), length);
}
+pub fn poll(fds: [*]pollfd, n: nfds_t, timeout: i32) usize {
+ if (@hasDecl(@This(), "SYS_poll")) {
+ return syscall3(SYS_poll, @ptrToInt(fds), n, @bitCast(u32, timeout));
+ } else {
+ return syscall6(
+ SYS_ppoll,
+ @ptrToInt(fds),
+ n,
+ @ptrToInt(if (timeout >= 0)
+ &timespec{
+ .tv_sec = timeout / 1000,
+ .tv_nsec = (timeout % 1000) * 1000000,
+ }
+ else
+ null),
+ 0,
+ 0,
+ NSIG / 8,
+ );
+ }
+}
+
pub fn read(fd: i32, buf: [*]u8, count: usize) usize {
return syscall3(SYS_read, @bitCast(usize, isize(fd)), @ptrToInt(buf), count);
}