diff options
| author | Sébastien Marie <semarie@online.fr> | 2020-10-11 08:23:36 +0000 |
|---|---|---|
| committer | Sébastien Marie <semarie@online.fr> | 2020-10-11 08:23:36 +0000 |
| commit | f33a610c84313255477cc04d930b02ad984118ae (patch) | |
| tree | 6451483302a0c8924fd26ca48c84cfa88617c80b /lib/std/event | |
| parent | a31b70c4b8d0bed67463b2f54e74198baa93329f (diff) | |
| download | zig-f33a610c84313255477cc04d930b02ad984118ae.tar.gz zig-f33a610c84313255477cc04d930b02ad984118ae.zip | |
add minimal openbsd support
Diffstat (limited to 'lib/std/event')
| -rw-r--r-- | lib/std/event/loop.zig | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig index a064f711e2..7fa6fee398 100644 --- a/lib/std/event/loop.zig +++ b/lib/std/event/loop.zig @@ -66,7 +66,7 @@ pub const Loop = struct { }; pub const EventFd = switch (builtin.os.tag) { - .macosx, .freebsd, .netbsd, .dragonfly => KEventFd, + .macosx, .freebsd, .netbsd, .dragonfly, .openbsd => KEventFd, .linux => struct { base: ResumeNode, epoll_op: u32, @@ -85,7 +85,7 @@ pub const Loop = struct { }; pub const Basic = switch (builtin.os.tag) { - .macosx, .freebsd, .netbsd, .dragonfly => KEventBasic, + .macosx, .freebsd, .netbsd, .dragonfly, .openbsd => KEventBasic, .linux => struct { base: ResumeNode, }, @@ -259,7 +259,7 @@ pub const Loop = struct { self.extra_threads[extra_thread_index] = try Thread.spawn(self, workerRun); } }, - .macosx, .freebsd, .netbsd, .dragonfly => { + .macosx, .freebsd, .netbsd, .dragonfly, .openbsd => { self.os_data.kqfd = try os.kqueue(); errdefer os.close(self.os_data.kqfd); @@ -384,7 +384,7 @@ pub const Loop = struct { while (self.available_eventfd_resume_nodes.pop()) |node| os.close(node.data.eventfd); os.close(self.os_data.epollfd); }, - .macosx, .freebsd, .netbsd, .dragonfly => { + .macosx, .freebsd, .netbsd, .dragonfly, .openbsd => { os.close(self.os_data.kqfd); }, .windows => { @@ -478,7 +478,7 @@ pub const Loop = struct { .linux => { self.linuxWaitFd(fd, os.EPOLLET | os.EPOLLONESHOT | os.EPOLLIN); }, - .macosx, .freebsd, .netbsd, .dragonfly => { + .macosx, .freebsd, .netbsd, .dragonfly, .openbsd => { self.bsdWaitKev(@intCast(usize, fd), os.EVFILT_READ, os.EV_ONESHOT); }, else => @compileError("Unsupported OS"), @@ -490,7 +490,7 @@ pub const Loop = struct { .linux => { self.linuxWaitFd(fd, os.EPOLLET | os.EPOLLONESHOT | os.EPOLLOUT); }, - .macosx, .freebsd, .netbsd, .dragonfly => { + .macosx, .freebsd, .netbsd, .dragonfly, .openbsd => { self.bsdWaitKev(@intCast(usize, fd), os.EVFILT_WRITE, os.EV_ONESHOT); }, else => @compileError("Unsupported OS"), @@ -502,7 +502,7 @@ pub const Loop = struct { .linux => { self.linuxWaitFd(fd, os.EPOLLET | os.EPOLLONESHOT | os.EPOLLOUT | os.EPOLLIN); }, - .macosx, .freebsd, .netbsd, .dragonfly => { + .macosx, .freebsd, .netbsd, .dragonfly, .openbsd => { self.bsdWaitKev(@intCast(usize, fd), os.EVFILT_READ, os.EV_ONESHOT); self.bsdWaitKev(@intCast(usize, fd), os.EVFILT_WRITE, os.EV_ONESHOT); }, @@ -571,7 +571,7 @@ pub const Loop = struct { const eventfd_node = &resume_stack_node.data; eventfd_node.base.handle = next_tick_node.data; switch (builtin.os.tag) { - .macosx, .freebsd, .netbsd, .dragonfly => { + .macosx, .freebsd, .netbsd, .dragonfly, .openbsd => { const kevent_array = @as(*const [1]os.Kevent, &eventfd_node.kevent); const empty_kevs = &[0]os.Kevent{}; _ = os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null) catch { @@ -637,6 +637,7 @@ pub const Loop = struct { .freebsd, .netbsd, .dragonfly, + .openbsd, => self.fs_thread.wait(), else => {}, } @@ -725,7 +726,7 @@ pub const Loop = struct { } return; }, - .macosx, .freebsd, .netbsd, .dragonfly => { + .macosx, .freebsd, .netbsd, .dragonfly, .openbsd => { const final_kevent = @as(*const [1]os.Kevent, &self.os_data.final_kevent); const empty_kevs = &[0]os.Kevent{}; // cannot fail because we already added it and this just enables it @@ -1218,7 +1219,7 @@ pub const Loop = struct { } } }, - .macosx, .freebsd, .netbsd, .dragonfly => { + .macosx, .freebsd, .netbsd, .dragonfly, .openbsd => { var eventlist: [1]os.Kevent = undefined; const empty_kevs = &[0]os.Kevent{}; const count = os.kevent(self.os_data.kqfd, empty_kevs, eventlist[0..], null) catch unreachable; @@ -1344,7 +1345,7 @@ pub const Loop = struct { const OsData = switch (builtin.os.tag) { .linux => LinuxOsData, - .macosx, .freebsd, .netbsd, .dragonfly => KEventData, + .macosx, .freebsd, .netbsd, .dragonfly, .openbsd => KEventData, .windows => struct { io_port: windows.HANDLE, extra_thread_count: usize, |
