authorgravatar for bill@axzez.comBill Nagel <bill@axzez.com> 2022-09-17 06:57:58-04:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-10-13 13:33:45+02:00
logea23217751c474140c7b46cbffa796a2f93f3ffb
tree9ff18713c1b49568f677010426c6e909a0deaadf
parentfb366f3cd4a8a28a2a66753acc53d06a0d88c838

enable event loop for ios, tvos, and watchos


1 files changed, 14 insertions(+), 11 deletions(-)

lib/std/event/loop.zig+14-11
...@@ -69,7 +69,7 @@ pub const Loop = struct {...@@ -69,7 +69,7 @@ pub const Loop = struct {
69 };69 };
7070
71 pub const EventFd = switch (builtin.os.tag) {71 pub const EventFd = switch (builtin.os.tag) {
72 .macos, .freebsd, .netbsd, .dragonfly, .openbsd => KEventFd,72 .macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => KEventFd,
73 .linux => struct {73 .linux => struct {
74 base: ResumeNode,74 base: ResumeNode,
75 epoll_op: u32,75 epoll_op: u32,
...@@ -88,7 +88,7 @@ pub const Loop = struct {...@@ -88,7 +88,7 @@ pub const Loop = struct {
88 };88 };
8989
90 pub const Basic = switch (builtin.os.tag) {90 pub const Basic = switch (builtin.os.tag) {
91 .macos, .freebsd, .netbsd, .dragonfly, .openbsd => KEventBasic,91 .macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => KEventBasic,
92 .linux => struct {92 .linux => struct {
93 base: ResumeNode,93 base: ResumeNode,
94 },94 },
...@@ -269,7 +269,7 @@ pub const Loop = struct {...@@ -269,7 +269,7 @@ pub const Loop = struct {
269 self.extra_threads[extra_thread_index] = try Thread.spawn(.{}, workerRun, .{self});269 self.extra_threads[extra_thread_index] = try Thread.spawn(.{}, workerRun, .{self});
270 }270 }
271 },271 },
272 .macos, .freebsd, .netbsd, .dragonfly => {272 .macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly => {
273 self.os_data.kqfd = try os.kqueue();273 self.os_data.kqfd = try os.kqueue();
274 errdefer os.close(self.os_data.kqfd);274 errdefer os.close(self.os_data.kqfd);
275275
...@@ -457,7 +457,7 @@ pub const Loop = struct {...@@ -457,7 +457,7 @@ pub const Loop = struct {
457 while (self.available_eventfd_resume_nodes.pop()) |node| os.close(node.data.eventfd);457 while (self.available_eventfd_resume_nodes.pop()) |node| os.close(node.data.eventfd);
458 os.close(self.os_data.epollfd);458 os.close(self.os_data.epollfd);
459 },459 },
460 .macos, .freebsd, .netbsd, .dragonfly, .openbsd => {460 .macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => {
461 os.close(self.os_data.kqfd);461 os.close(self.os_data.kqfd);
462 },462 },
463 .windows => {463 .windows => {
...@@ -552,7 +552,7 @@ pub const Loop = struct {...@@ -552,7 +552,7 @@ pub const Loop = struct {
552 .linux => {552 .linux => {
553 self.linuxWaitFd(fd, os.linux.EPOLL.ET | os.linux.EPOLL.ONESHOT | os.linux.EPOLL.IN);553 self.linuxWaitFd(fd, os.linux.EPOLL.ET | os.linux.EPOLL.ONESHOT | os.linux.EPOLL.IN);
554 },554 },
555 .macos, .freebsd, .netbsd, .dragonfly, .openbsd => {555 .macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => {
556 self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_READ, os.system.EV_ONESHOT);556 self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_READ, os.system.EV_ONESHOT);
557 },557 },
558 else => @compileError("Unsupported OS"),558 else => @compileError("Unsupported OS"),
...@@ -564,7 +564,7 @@ pub const Loop = struct {...@@ -564,7 +564,7 @@ pub const Loop = struct {
564 .linux => {564 .linux => {
565 self.linuxWaitFd(fd, os.linux.EPOLL.ET | os.linux.EPOLL.ONESHOT | os.linux.EPOLL.OUT);565 self.linuxWaitFd(fd, os.linux.EPOLL.ET | os.linux.EPOLL.ONESHOT | os.linux.EPOLL.OUT);
566 },566 },
567 .macos, .freebsd, .netbsd, .dragonfly, .openbsd => {567 .macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => {
568 self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_WRITE, os.system.EV_ONESHOT);568 self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_WRITE, os.system.EV_ONESHOT);
569 },569 },
570 else => @compileError("Unsupported OS"),570 else => @compileError("Unsupported OS"),
...@@ -576,7 +576,7 @@ pub const Loop = struct {...@@ -576,7 +576,7 @@ pub const Loop = struct {
576 .linux => {576 .linux => {
577 self.linuxWaitFd(fd, os.linux.EPOLL.ET | os.linux.EPOLL.ONESHOT | os.linux.EPOLL.OUT | os.linux.EPOLL.IN);577 self.linuxWaitFd(fd, os.linux.EPOLL.ET | os.linux.EPOLL.ONESHOT | os.linux.EPOLL.OUT | os.linux.EPOLL.IN);
578 },578 },
579 .macos, .freebsd, .netbsd, .dragonfly, .openbsd => {579 .macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => {
580 self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_READ, os.system.EV_ONESHOT);580 self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_READ, os.system.EV_ONESHOT);
581 self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_WRITE, os.system.EV_ONESHOT);581 self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_WRITE, os.system.EV_ONESHOT);
582 },582 },
...@@ -645,7 +645,7 @@ pub const Loop = struct {...@@ -645,7 +645,7 @@ pub const Loop = struct {
645 const eventfd_node = &resume_stack_node.data;645 const eventfd_node = &resume_stack_node.data;
646 eventfd_node.base.handle = next_tick_node.data;646 eventfd_node.base.handle = next_tick_node.data;
647 switch (builtin.os.tag) {647 switch (builtin.os.tag) {
648 .macos, .freebsd, .netbsd, .dragonfly, .openbsd => {648 .macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => {
649 const kevent_array = @as(*const [1]os.Kevent, &eventfd_node.kevent);649 const kevent_array = @as(*const [1]os.Kevent, &eventfd_node.kevent);
650 const empty_kevs = &[0]os.Kevent{};650 const empty_kevs = &[0]os.Kevent{};
651 _ = os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null) catch {651 _ = os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null) catch {
...@@ -708,6 +708,9 @@ pub const Loop = struct {...@@ -708,6 +708,9 @@ pub const Loop = struct {
708 switch (builtin.os.tag) {708 switch (builtin.os.tag) {
709 .linux,709 .linux,
710 .macos,710 .macos,
711 .ios,
712 .tvos,
713 .watchos,
711 .freebsd,714 .freebsd,
712 .netbsd,715 .netbsd,
713 .dragonfly,716 .dragonfly,
...@@ -802,7 +805,7 @@ pub const Loop = struct {...@@ -802,7 +805,7 @@ pub const Loop = struct {
802 }805 }
803 return;806 return;
804 },807 },
805 .macos, .freebsd, .netbsd, .dragonfly, .openbsd => {808 .macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => {
806 const final_kevent = @as(*const [1]os.Kevent, &self.os_data.final_kevent);809 const final_kevent = @as(*const [1]os.Kevent, &self.os_data.final_kevent);
807 const empty_kevs = &[0]os.Kevent{};810 const empty_kevs = &[0]os.Kevent{};
808 // cannot fail because we already added it and this just enables it811 // cannot fail because we already added it and this just enables it
...@@ -1428,7 +1431,7 @@ pub const Loop = struct {...@@ -1428,7 +1431,7 @@ pub const Loop = struct {
1428 }1431 }
1429 }1432 }
1430 },1433 },
1431 .macos, .freebsd, .netbsd, .dragonfly, .openbsd => {1434 .macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => {
1432 var eventlist: [1]os.Kevent = undefined;1435 var eventlist: [1]os.Kevent = undefined;
1433 const empty_kevs = &[0]os.Kevent{};1436 const empty_kevs = &[0]os.Kevent{};
1434 const count = os.kevent(self.os_data.kqfd, empty_kevs, eventlist[0..], null) catch unreachable;1437 const count = os.kevent(self.os_data.kqfd, empty_kevs, eventlist[0..], null) catch unreachable;
...@@ -1554,7 +1557,7 @@ pub const Loop = struct {...@@ -1554,7 +1557,7 @@ pub const Loop = struct {
15541557
1555 const OsData = switch (builtin.os.tag) {1558 const OsData = switch (builtin.os.tag) {
1556 .linux => LinuxOsData,1559 .linux => LinuxOsData,
1557 .macos, .freebsd, .netbsd, .dragonfly, .openbsd => KEventData,1560 .macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => KEventData,
1558 .windows => struct {1561 .windows => struct {
1559 io_port: windows.HANDLE,1562 io_port: windows.HANDLE,
1560 extra_thread_count: usize,1563 extra_thread_count: usize,