diff options
| author | Tse <1@tse.gratis> | 2019-10-23 01:06:35 +0300 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-10-30 21:21:58 -0400 |
| commit | 33cc2044811e41a74e3112fc0abcc5dc6fd34836 (patch) | |
| tree | 380b8a0e296e32fae4415035338ec268c1a1beaf /lib/std/event | |
| parent | 7c7350345147c61e3e0873c3c4f233e351a3910a (diff) | |
| download | zig-33cc2044811e41a74e3112fc0abcc5dc6fd34836.tar.gz zig-33cc2044811e41a74e3112fc0abcc5dc6fd34836.zip | |
DragonFlyBSD support
Diffstat (limited to 'lib/std/event')
| -rw-r--r-- | lib/std/event/channel.zig | 1 | ||||
| -rw-r--r-- | lib/std/event/fs.zig | 24 | ||||
| -rw-r--r-- | lib/std/event/group.zig | 1 | ||||
| -rw-r--r-- | lib/std/event/lock.zig | 1 | ||||
| -rw-r--r-- | lib/std/event/loop.zig | 21 |
5 files changed, 30 insertions, 18 deletions
diff --git a/lib/std/event/channel.zig b/lib/std/event/channel.zig index 1092f2204a..b46cca1261 100644 --- a/lib/std/event/channel.zig +++ b/lib/std/event/channel.zig @@ -304,6 +304,7 @@ pub fn Channel(comptime T: type) type { } test "std.event.Channel" { + if (builtin.os == .dragonfly) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/1908 if (builtin.single_threaded) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/3251 diff --git a/lib/std/event/fs.zig b/lib/std/event/fs.zig index 2f64d453af..d86bcbaed5 100644 --- a/lib/std/event/fs.zig +++ b/lib/std/event/fs.zig @@ -92,6 +92,7 @@ pub fn pwritev(loop: *Loop, fd: fd_t, data: []const []const u8, offset: usize) P .linux, .freebsd, .netbsd, + .dragonfly, => { const iovecs = try loop.allocator.alloc(os.iovec_const, data.len); defer loop.allocator.free(iovecs); @@ -248,6 +249,7 @@ pub fn preadv(loop: *Loop, fd: fd_t, data: []const []u8, offset: usize) PReadVEr .linux, .freebsd, .netbsd, + .dragonfly, => { const iovecs = try loop.allocator.alloc(os.iovec, data.len); defer loop.allocator.free(iovecs); @@ -412,7 +414,7 @@ pub fn openPosix( pub fn openRead(loop: *Loop, path: []const u8) File.OpenError!fd_t { switch (builtin.os) { - .macosx, .linux, .freebsd, .netbsd => { + .macosx, .linux, .freebsd, .netbsd, .dragonfly => { const flags = os.O_LARGEFILE | os.O_RDONLY | os.O_CLOEXEC; return openPosix(loop, path, flags, File.default_mode); }, @@ -444,6 +446,7 @@ pub fn openWriteMode(loop: *Loop, path: []const u8, mode: File.Mode) File.OpenEr .linux, .freebsd, .netbsd, + .dragonfly, => { const flags = os.O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_TRUNC; return openPosix(loop, path, flags, File.default_mode); @@ -468,7 +471,7 @@ pub fn openReadWrite( mode: File.Mode, ) File.OpenError!fd_t { switch (builtin.os) { - .macosx, .linux, .freebsd, .netbsd => { + .macosx, .linux, .freebsd, .netbsd, .dragonfly => { const flags = os.O_LARGEFILE | os.O_RDWR | os.O_CREAT | os.O_CLOEXEC; return openPosix(loop, path, flags, mode); }, @@ -498,7 +501,7 @@ pub const CloseOperation = struct { os_data: OsData, const OsData = switch (builtin.os) { - .linux, .macosx, .freebsd, .netbsd => OsDataPosix, + .linux, .macosx, .freebsd, .netbsd, .dragonfly => OsDataPosix, .windows => struct { handle: ?fd_t, @@ -517,7 +520,7 @@ pub const CloseOperation = struct { self.* = CloseOperation{ .loop = loop, .os_data = switch (builtin.os) { - .linux, .macosx, .freebsd, .netbsd => initOsDataPosix(self), + .linux, .macosx, .freebsd, .netbsd, .dragonfly => initOsDataPosix(self), .windows => OsData{ .handle = null }, else => @compileError("Unsupported OS"), }, @@ -548,6 +551,7 @@ pub const CloseOperation = struct { .macosx, .freebsd, .netbsd, + .dragonfly, => { if (self.os_data.have_fd) { self.loop.posixFsRequest(&self.os_data.close_req_node); @@ -571,6 +575,7 @@ pub const CloseOperation = struct { .macosx, .freebsd, .netbsd, + .dragonfly, => { self.os_data.close_req_node.data.msg.Close.fd = handle; self.os_data.have_fd = true; @@ -589,6 +594,7 @@ pub const CloseOperation = struct { .macosx, .freebsd, .netbsd, + .dragonfly, => { self.os_data.have_fd = false; }, @@ -605,6 +611,7 @@ pub const CloseOperation = struct { .macosx, .freebsd, .netbsd, + .dragonfly, => { assert(self.os_data.have_fd); return self.os_data.close_req_node.data.msg.Close.fd; @@ -630,6 +637,7 @@ pub fn writeFileMode(loop: *Loop, path: []const u8, contents: []const u8, mode: .macosx, .freebsd, .netbsd, + .dragonfly, => return writeFileModeThread(loop, path, contents, mode), .windows => return writeFileWindows(loop, path, contents), else => @compileError("Unsupported OS"), @@ -742,7 +750,7 @@ fn hashString(s: []const u16) u32 { // os_data: OsData, // // const OsData = switch (builtin.os) { -// .macosx, .freebsd, .netbsd => struct { +// .macosx, .freebsd, .netbsd, .dragonfly => struct { // file_table: FileTable, // table_lock: event.Lock, // @@ -831,7 +839,7 @@ fn hashString(s: []const u16) u32 { // return self; // }, // -// .macosx, .freebsd, .netbsd => { +// .macosx, .freebsd, .netbsd, .dragonfly => { // const self = try loop.allocator.create(Self); // errdefer loop.allocator.destroy(self); // @@ -851,7 +859,7 @@ fn hashString(s: []const u16) u32 { // /// All addFile calls and removeFile calls must have completed. // pub fn destroy(self: *Self) void { // switch (builtin.os) { -// .macosx, .freebsd, .netbsd => { +// .macosx, .freebsd, .netbsd, .dragonfly => { // // TODO we need to cancel the frames before destroying the lock // self.os_data.table_lock.deinit(); // var it = self.os_data.file_table.iterator(); @@ -893,7 +901,7 @@ fn hashString(s: []const u16) u32 { // // pub async fn addFile(self: *Self, file_path: []const u8, value: V) !?V { // switch (builtin.os) { -// .macosx, .freebsd, .netbsd => return await (async addFileKEvent(self, file_path, value) catch unreachable), +// .macosx, .freebsd, .netbsd, .dragonfly => return await (async addFileKEvent(self, file_path, value) catch unreachable), // .linux => return await (async addFileLinux(self, file_path, value) catch unreachable), // .windows => return await (async addFileWindows(self, file_path, value) catch unreachable), // else => @compileError("Unsupported OS"), diff --git a/lib/std/event/group.zig b/lib/std/event/group.zig index f96b938f80..6991fb2fa6 100644 --- a/lib/std/event/group.zig +++ b/lib/std/event/group.zig @@ -81,6 +81,7 @@ pub fn Group(comptime ReturnType: type) type { } test "std.event.Group" { + if (builtin.os == .dragonfly) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/1908 if (builtin.single_threaded) return error.SkipZigTest; diff --git a/lib/std/event/lock.zig b/lib/std/event/lock.zig index fdcfd1e298..f86afdbf65 100644 --- a/lib/std/event/lock.zig +++ b/lib/std/event/lock.zig @@ -116,6 +116,7 @@ pub const Lock = struct { }; test "std.event.Lock" { + if (builtin.os == .dragonfly) return error.SkipZigTest; // TODO https://github.com/ziglang/zig/issues/1908 if (builtin.single_threaded) return error.SkipZigTest; // TODO https://github.com/ziglang/zig/issues/3251 diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig index d0d36abc0c..22013edba6 100644 --- a/lib/std/event/loop.zig +++ b/lib/std/event/loop.zig @@ -51,7 +51,7 @@ pub const Loop = struct { }; pub const EventFd = switch (builtin.os) { - .macosx, .freebsd, .netbsd => KEventFd, + .macosx, .freebsd, .netbsd, .dragonfly => KEventFd, .linux => struct { base: ResumeNode, epoll_op: u32, @@ -70,7 +70,7 @@ pub const Loop = struct { }; pub const Basic = switch (builtin.os) { - .macosx, .freebsd, .netbsd => KEventBasic, + .macosx, .freebsd, .netbsd, .dragonfly => KEventBasic, .linux => struct { base: ResumeNode, }, @@ -244,7 +244,7 @@ pub const Loop = struct { self.extra_threads[extra_thread_index] = try Thread.spawn(self, workerRun); } }, - .macosx, .freebsd, .netbsd => { + .macosx, .freebsd, .netbsd, .dragonfly => { self.os_data.kqfd = try os.kqueue(); errdefer os.close(self.os_data.kqfd); @@ -409,7 +409,7 @@ pub const Loop = struct { os.close(self.os_data.epollfd); self.allocator.free(self.eventfd_resume_nodes); }, - .macosx, .freebsd, .netbsd => { + .macosx, .freebsd, .netbsd, .dragonfly => { os.close(self.os_data.kqfd); os.close(self.os_data.fs_kqfd); }, @@ -523,7 +523,7 @@ pub const Loop = struct { const eventfd_node = &resume_stack_node.data; eventfd_node.base.handle = next_tick_node.data; switch (builtin.os) { - .macosx, .freebsd, .netbsd => { + .macosx, .freebsd, .netbsd, .dragonfly => { const kevent_array = (*const [1]os.Kevent)(&eventfd_node.kevent); const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; _ = os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null) catch { @@ -587,6 +587,7 @@ pub const Loop = struct { .macosx, .freebsd, .netbsd, + .dragonfly, => self.os_data.fs_thread.wait(), else => {}, } @@ -644,7 +645,7 @@ pub const Loop = struct { os.write(self.os_data.final_eventfd, wakeup_bytes) catch unreachable; return; }, - .macosx, .freebsd, .netbsd => { + .macosx, .freebsd, .netbsd, .dragonfly => { self.posixFsRequest(&self.os_data.fs_end_request); const final_kevent = (*const [1]os.Kevent)(&self.os_data.final_kevent); const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; @@ -702,7 +703,7 @@ pub const Loop = struct { } } }, - .macosx, .freebsd, .netbsd => { + .macosx, .freebsd, .netbsd, .dragonfly => { var eventlist: [1]os.Kevent = undefined; const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; const count = os.kevent(self.os_data.kqfd, empty_kevs, eventlist[0..], null) catch unreachable; @@ -765,7 +766,7 @@ pub const Loop = struct { self.beginOneEvent(); // finished in posixFsRun after processing the msg self.os_data.fs_queue.put(request_node); switch (builtin.os) { - .macosx, .freebsd, .netbsd => { + .macosx, .freebsd, .netbsd, .dragonfly => { const fs_kevs = (*const [1]os.Kevent)(&self.os_data.fs_kevent_wake); const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; _ = os.kevent(self.os_data.fs_kqfd, fs_kevs, empty_kevs, null) catch unreachable; @@ -838,7 +839,7 @@ pub const Loop = struct { else => unreachable, } }, - .macosx, .freebsd, .netbsd => { + .macosx, .freebsd, .netbsd, .dragonfly => { const fs_kevs = (*const [1]os.Kevent)(&self.os_data.fs_kevent_wait); var out_kevs: [1]os.Kevent = undefined; _ = os.kevent(self.os_data.fs_kqfd, fs_kevs, out_kevs[0..], null) catch unreachable; @@ -850,7 +851,7 @@ pub const Loop = struct { const OsData = switch (builtin.os) { .linux => LinuxOsData, - .macosx, .freebsd, .netbsd => KEventData, + .macosx, .freebsd, .netbsd, .dragonfly => KEventData, .windows => struct { io_port: windows.HANDLE, extra_thread_count: usize, |
