From 63cc2ba4faf0a66babffc66644e01692772007c3 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 23 Apr 2022 10:31:02 -0700 Subject: [PATCH] libuv: implement kqueue --- src/libuv/Embed.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libuv/Embed.zig b/src/libuv/Embed.zig index 00c4a8d94..fb2bec1fc 100644 --- a/src/libuv/Embed.zig +++ b/src/libuv/Embed.zig @@ -101,6 +101,18 @@ fn threadMain(self: *Embed) void { while (std.os.epoll_wait(fd, &ev, timeout) == -1) {} }, + // kqueue + .macos, .dragonfly, .freebsd, .openbsd, .netbsd => { + // TODO: untested, probably some compile errors here + // or other issues, but this is roughly what we're trying + // to do. + var ts: std.os.timespec = .{ + .tv_sec = timeout / 1000, + .tv_nsec = (timeout % 1000) * 1000, + }; + while ((try std.os.kevent(fd, null, null, &ts)) == -1) {} + }, + else => @compileError("unsupported libuv Embed platform"), }