| author | |
| committer | |
| log | 33cc2044811e41a74e3112fc0abcc5dc6fd34836 |
| tree | 380b8a0e296e32fae4415035338ec268c1a1beaf |
| parent | 7c7350345147c61e3e0873c3c4f233e351a3910a |
30 files changed, 807 insertions(+), 57 deletions(-)
lib/std/atomic/queue.zig+1| ... | @@ -152,6 +152,7 @@ const puts_per_thread = 500; | ... | @@ -152,6 +152,7 @@ const puts_per_thread = 500; |
| 152 | const put_thread_count = 3; | 152 | const put_thread_count = 3; |
| 153 | 153 | ||
| 154 | test "std.atomic.Queue" { | 154 | test "std.atomic.Queue" { |
| 155 | if (builtin.os == .dragonfly) return error.SkipZigTest; | ||
| 155 | var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024); | 156 | var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024); |
| 156 | defer std.heap.direct_allocator.free(plenty_of_memory); | 157 | defer std.heap.direct_allocator.free(plenty_of_memory); |
| 157 | 158 |
lib/std/atomic/stack.zig+1| ... | @@ -86,6 +86,7 @@ const puts_per_thread = 500; | ... | @@ -86,6 +86,7 @@ const puts_per_thread = 500; |
| 86 | const put_thread_count = 3; | 86 | const put_thread_count = 3; |
| 87 | 87 | ||
| 88 | test "std.atomic.stack" { | 88 | test "std.atomic.stack" { |
| 89 | if (builtin.os == .dragonfly) return error.SkipZigTest; | ||
| 89 | var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024); | 90 | var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024); |
| 90 | defer std.heap.direct_allocator.free(plenty_of_memory); | 91 | defer std.heap.direct_allocator.free(plenty_of_memory); |
| 91 | 92 |
lib/std/c.zig+1| ... | @@ -10,6 +10,7 @@ pub usingnamespace switch (builtin.os) { | ... | @@ -10,6 +10,7 @@ pub usingnamespace switch (builtin.os) { |
| 10 | .macosx, .ios, .tvos, .watchos => @import("c/darwin.zig"), | 10 | .macosx, .ios, .tvos, .watchos => @import("c/darwin.zig"), |
| 11 | .freebsd => @import("c/freebsd.zig"), | 11 | .freebsd => @import("c/freebsd.zig"), |
| 12 | .netbsd => @import("c/netbsd.zig"), | 12 | .netbsd => @import("c/netbsd.zig"), |
| 13 | .dragonfly => @import("c/dragonfly.zig"), | ||
| 13 | else => struct {}, | 14 | else => struct {}, |
| 14 | }; | 15 | }; |
| 15 | 16 |
lib/std/c/dragonfly.zig created+14| ... | @@ -0,0 +1,14 @@ | ||
| 1 | const std = @import("../std.zig"); | ||
| 2 | usingnamespace std.c; | ||
| 3 | |||
| 4 | extern "c" threadlocal var errno: c_int; | ||
| 5 | pub fn _errno() *c_int { | ||
| 6 | return &errno; | ||
| 7 | } | ||
| 8 | |||
| 9 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; | ||
| 10 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; | ||
| 11 | pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; | ||
| 12 | |||
| 13 | pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int; | ||
| 14 | pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int; | ||
lib/std/debug.zig+1-1| ... | @@ -1272,7 +1272,7 @@ pub const DebugInfo = switch (builtin.os) { | ... | @@ -1272,7 +1272,7 @@ pub const DebugInfo = switch (builtin.os) { |
| 1272 | sect_contribs: []pdb.SectionContribEntry, | 1272 | sect_contribs: []pdb.SectionContribEntry, |
| 1273 | modules: []Module, | 1273 | modules: []Module, |
| 1274 | }, | 1274 | }, |
| 1275 | .linux, .freebsd, .netbsd => DwarfInfo, | 1275 | .linux, .freebsd, .netbsd, .dragonfly => DwarfInfo, |
| 1276 | else => @compileError("Unsupported OS"), | 1276 | else => @compileError("Unsupported OS"), |
| 1277 | }; | 1277 | }; |
| 1278 | 1278 |
lib/std/event/channel.zig+1| ... | @@ -304,6 +304,7 @@ pub fn Channel(comptime T: type) type { | ... | @@ -304,6 +304,7 @@ pub fn Channel(comptime T: type) type { |
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | test "std.event.Channel" { | 306 | test "std.event.Channel" { |
| 307 | if (builtin.os == .dragonfly) return error.SkipZigTest; | ||
| 307 | // https://github.com/ziglang/zig/issues/1908 | 308 | // https://github.com/ziglang/zig/issues/1908 |
| 308 | if (builtin.single_threaded) return error.SkipZigTest; | 309 | if (builtin.single_threaded) return error.SkipZigTest; |
| 309 | // https://github.com/ziglang/zig/issues/3251 | 310 | // https://github.com/ziglang/zig/issues/3251 |
lib/std/event/fs.zig+16-8| ... | @@ -92,6 +92,7 @@ pub fn pwritev(loop: *Loop, fd: fd_t, data: []const []const u8, offset: usize) P | ... | @@ -92,6 +92,7 @@ pub fn pwritev(loop: *Loop, fd: fd_t, data: []const []const u8, offset: usize) P |
| 92 | .linux, | 92 | .linux, |
| 93 | .freebsd, | 93 | .freebsd, |
| 94 | .netbsd, | 94 | .netbsd, |
| 95 | .dragonfly, | ||
| 95 | => { | 96 | => { |
| 96 | const iovecs = try loop.allocator.alloc(os.iovec_const, data.len); | 97 | const iovecs = try loop.allocator.alloc(os.iovec_const, data.len); |
| 97 | defer loop.allocator.free(iovecs); | 98 | defer loop.allocator.free(iovecs); |
| ... | @@ -248,6 +249,7 @@ pub fn preadv(loop: *Loop, fd: fd_t, data: []const []u8, offset: usize) PReadVEr | ... | @@ -248,6 +249,7 @@ pub fn preadv(loop: *Loop, fd: fd_t, data: []const []u8, offset: usize) PReadVEr |
| 248 | .linux, | 249 | .linux, |
| 249 | .freebsd, | 250 | .freebsd, |
| 250 | .netbsd, | 251 | .netbsd, |
| 252 | .dragonfly, | ||
| 251 | => { | 253 | => { |
| 252 | const iovecs = try loop.allocator.alloc(os.iovec, data.len); | 254 | const iovecs = try loop.allocator.alloc(os.iovec, data.len); |
| 253 | defer loop.allocator.free(iovecs); | 255 | defer loop.allocator.free(iovecs); |
| ... | @@ -412,7 +414,7 @@ pub fn openPosix( | ... | @@ -412,7 +414,7 @@ pub fn openPosix( |
| 412 | 414 | ||
| 413 | pub fn openRead(loop: *Loop, path: []const u8) File.OpenError!fd_t { | 415 | pub fn openRead(loop: *Loop, path: []const u8) File.OpenError!fd_t { |
| 414 | switch (builtin.os) { | 416 | switch (builtin.os) { |
| 415 | .macosx, .linux, .freebsd, .netbsd => { | 417 | .macosx, .linux, .freebsd, .netbsd, .dragonfly => { |
| 416 | const flags = os.O_LARGEFILE | os.O_RDONLY | os.O_CLOEXEC; | 418 | const flags = os.O_LARGEFILE | os.O_RDONLY | os.O_CLOEXEC; |
| 417 | return openPosix(loop, path, flags, File.default_mode); | 419 | return openPosix(loop, path, flags, File.default_mode); |
| 418 | }, | 420 | }, |
| ... | @@ -444,6 +446,7 @@ pub fn openWriteMode(loop: *Loop, path: []const u8, mode: File.Mode) File.OpenEr | ... | @@ -444,6 +446,7 @@ pub fn openWriteMode(loop: *Loop, path: []const u8, mode: File.Mode) File.OpenEr |
| 444 | .linux, | 446 | .linux, |
| 445 | .freebsd, | 447 | .freebsd, |
| 446 | .netbsd, | 448 | .netbsd, |
| 449 | .dragonfly, | ||
| 447 | => { | 450 | => { |
| 448 | const flags = os.O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_TRUNC; | 451 | const flags = os.O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_TRUNC; |
| 449 | return openPosix(loop, path, flags, File.default_mode); | 452 | return openPosix(loop, path, flags, File.default_mode); |
| ... | @@ -468,7 +471,7 @@ pub fn openReadWrite( | ... | @@ -468,7 +471,7 @@ pub fn openReadWrite( |
| 468 | mode: File.Mode, | 471 | mode: File.Mode, |
| 469 | ) File.OpenError!fd_t { | 472 | ) File.OpenError!fd_t { |
| 470 | switch (builtin.os) { | 473 | switch (builtin.os) { |
| 471 | .macosx, .linux, .freebsd, .netbsd => { | 474 | .macosx, .linux, .freebsd, .netbsd, .dragonfly => { |
| 472 | const flags = os.O_LARGEFILE | os.O_RDWR | os.O_CREAT | os.O_CLOEXEC; | 475 | const flags = os.O_LARGEFILE | os.O_RDWR | os.O_CREAT | os.O_CLOEXEC; |
| 473 | return openPosix(loop, path, flags, mode); | 476 | return openPosix(loop, path, flags, mode); |
| 474 | }, | 477 | }, |
| ... | @@ -498,7 +501,7 @@ pub const CloseOperation = struct { | ... | @@ -498,7 +501,7 @@ pub const CloseOperation = struct { |
| 498 | os_data: OsData, | 501 | os_data: OsData, |
| 499 | 502 | ||
| 500 | const OsData = switch (builtin.os) { | 503 | const OsData = switch (builtin.os) { |
| 501 | .linux, .macosx, .freebsd, .netbsd => OsDataPosix, | 504 | .linux, .macosx, .freebsd, .netbsd, .dragonfly => OsDataPosix, |
| 502 | 505 | ||
| 503 | .windows => struct { | 506 | .windows => struct { |
| 504 | handle: ?fd_t, | 507 | handle: ?fd_t, |
| ... | @@ -517,7 +520,7 @@ pub const CloseOperation = struct { | ... | @@ -517,7 +520,7 @@ pub const CloseOperation = struct { |
| 517 | self.* = CloseOperation{ | 520 | self.* = CloseOperation{ |
| 518 | .loop = loop, | 521 | .loop = loop, |
| 519 | .os_data = switch (builtin.os) { | 522 | .os_data = switch (builtin.os) { |
| 520 | .linux, .macosx, .freebsd, .netbsd => initOsDataPosix(self), | 523 | .linux, .macosx, .freebsd, .netbsd, .dragonfly => initOsDataPosix(self), |
| 521 | .windows => OsData{ .handle = null }, | 524 | .windows => OsData{ .handle = null }, |
| 522 | else => @compileError("Unsupported OS"), | 525 | else => @compileError("Unsupported OS"), |
| 523 | }, | 526 | }, |
| ... | @@ -548,6 +551,7 @@ pub const CloseOperation = struct { | ... | @@ -548,6 +551,7 @@ pub const CloseOperation = struct { |
| 548 | .macosx, | 551 | .macosx, |
| 549 | .freebsd, | 552 | .freebsd, |
| 550 | .netbsd, | 553 | .netbsd, |
| 554 | .dragonfly, | ||
| 551 | => { | 555 | => { |
| 552 | if (self.os_data.have_fd) { | 556 | if (self.os_data.have_fd) { |
| 553 | self.loop.posixFsRequest(&self.os_data.close_req_node); | 557 | self.loop.posixFsRequest(&self.os_data.close_req_node); |
| ... | @@ -571,6 +575,7 @@ pub const CloseOperation = struct { | ... | @@ -571,6 +575,7 @@ pub const CloseOperation = struct { |
| 571 | .macosx, | 575 | .macosx, |
| 572 | .freebsd, | 576 | .freebsd, |
| 573 | .netbsd, | 577 | .netbsd, |
| 578 | .dragonfly, | ||
| 574 | => { | 579 | => { |
| 575 | self.os_data.close_req_node.data.msg.Close.fd = handle; | 580 | self.os_data.close_req_node.data.msg.Close.fd = handle; |
| 576 | self.os_data.have_fd = true; | 581 | self.os_data.have_fd = true; |
| ... | @@ -589,6 +594,7 @@ pub const CloseOperation = struct { | ... | @@ -589,6 +594,7 @@ pub const CloseOperation = struct { |
| 589 | .macosx, | 594 | .macosx, |
| 590 | .freebsd, | 595 | .freebsd, |
| 591 | .netbsd, | 596 | .netbsd, |
| 597 | .dragonfly, | ||
| 592 | => { | 598 | => { |
| 593 | self.os_data.have_fd = false; | 599 | self.os_data.have_fd = false; |
| 594 | }, | 600 | }, |
| ... | @@ -605,6 +611,7 @@ pub const CloseOperation = struct { | ... | @@ -605,6 +611,7 @@ pub const CloseOperation = struct { |
| 605 | .macosx, | 611 | .macosx, |
| 606 | .freebsd, | 612 | .freebsd, |
| 607 | .netbsd, | 613 | .netbsd, |
| 614 | .dragonfly, | ||
| 608 | => { | 615 | => { |
| 609 | assert(self.os_data.have_fd); | 616 | assert(self.os_data.have_fd); |
| 610 | return self.os_data.close_req_node.data.msg.Close.fd; | 617 | 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: | ... | @@ -630,6 +637,7 @@ pub fn writeFileMode(loop: *Loop, path: []const u8, contents: []const u8, mode: |
| 630 | .macosx, | 637 | .macosx, |
| 631 | .freebsd, | 638 | .freebsd, |
| 632 | .netbsd, | 639 | .netbsd, |
| 640 | .dragonfly, | ||
| 633 | => return writeFileModeThread(loop, path, contents, mode), | 641 | => return writeFileModeThread(loop, path, contents, mode), |
| 634 | .windows => return writeFileWindows(loop, path, contents), | 642 | .windows => return writeFileWindows(loop, path, contents), |
| 635 | else => @compileError("Unsupported OS"), | 643 | else => @compileError("Unsupported OS"), |
| ... | @@ -742,7 +750,7 @@ fn hashString(s: []const u16) u32 { | ... | @@ -742,7 +750,7 @@ fn hashString(s: []const u16) u32 { |
| 742 | // os_data: OsData, | 750 | // os_data: OsData, |
| 743 | // | 751 | // |
| 744 | // const OsData = switch (builtin.os) { | 752 | // const OsData = switch (builtin.os) { |
| 745 | // .macosx, .freebsd, .netbsd => struct { | 753 | // .macosx, .freebsd, .netbsd, .dragonfly => struct { |
| 746 | // file_table: FileTable, | 754 | // file_table: FileTable, |
| 747 | // table_lock: event.Lock, | 755 | // table_lock: event.Lock, |
| 748 | // | 756 | // |
| ... | @@ -831,7 +839,7 @@ fn hashString(s: []const u16) u32 { | ... | @@ -831,7 +839,7 @@ fn hashString(s: []const u16) u32 { |
| 831 | // return self; | 839 | // return self; |
| 832 | // }, | 840 | // }, |
| 833 | // | 841 | // |
| 834 | // .macosx, .freebsd, .netbsd => { | 842 | // .macosx, .freebsd, .netbsd, .dragonfly => { |
| 835 | // const self = try loop.allocator.create(Self); | 843 | // const self = try loop.allocator.create(Self); |
| 836 | // errdefer loop.allocator.destroy(self); | 844 | // errdefer loop.allocator.destroy(self); |
| 837 | // | 845 | // |
| ... | @@ -851,7 +859,7 @@ fn hashString(s: []const u16) u32 { | ... | @@ -851,7 +859,7 @@ fn hashString(s: []const u16) u32 { |
| 851 | // /// All addFile calls and removeFile calls must have completed. | 859 | // /// All addFile calls and removeFile calls must have completed. |
| 852 | // pub fn destroy(self: *Self) void { | 860 | // pub fn destroy(self: *Self) void { |
| 853 | // switch (builtin.os) { | 861 | // switch (builtin.os) { |
| 854 | // .macosx, .freebsd, .netbsd => { | 862 | // .macosx, .freebsd, .netbsd, .dragonfly => { |
| 855 | // // TODO we need to cancel the frames before destroying the lock | 863 | // // TODO we need to cancel the frames before destroying the lock |
| 856 | // self.os_data.table_lock.deinit(); | 864 | // self.os_data.table_lock.deinit(); |
| 857 | // var it = self.os_data.file_table.iterator(); | 865 | // var it = self.os_data.file_table.iterator(); |
| ... | @@ -893,7 +901,7 @@ fn hashString(s: []const u16) u32 { | ... | @@ -893,7 +901,7 @@ fn hashString(s: []const u16) u32 { |
| 893 | // | 901 | // |
| 894 | // pub async fn addFile(self: *Self, file_path: []const u8, value: V) !?V { | 902 | // pub async fn addFile(self: *Self, file_path: []const u8, value: V) !?V { |
| 895 | // switch (builtin.os) { | 903 | // switch (builtin.os) { |
| 896 | // .macosx, .freebsd, .netbsd => return await (async addFileKEvent(self, file_path, value) catch unreachable), | 904 | // .macosx, .freebsd, .netbsd, .dragonfly => return await (async addFileKEvent(self, file_path, value) catch unreachable), |
| 897 | // .linux => return await (async addFileLinux(self, file_path, value) catch unreachable), | 905 | // .linux => return await (async addFileLinux(self, file_path, value) catch unreachable), |
| 898 | // .windows => return await (async addFileWindows(self, file_path, value) catch unreachable), | 906 | // .windows => return await (async addFileWindows(self, file_path, value) catch unreachable), |
| 899 | // else => @compileError("Unsupported OS"), | 907 | // else => @compileError("Unsupported OS"), |
lib/std/event/group.zig+1| ... | @@ -81,6 +81,7 @@ pub fn Group(comptime ReturnType: type) type { | ... | @@ -81,6 +81,7 @@ pub fn Group(comptime ReturnType: type) type { |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | test "std.event.Group" { | 83 | test "std.event.Group" { |
| 84 | if (builtin.os == .dragonfly) return error.SkipZigTest; | ||
| 84 | // https://github.com/ziglang/zig/issues/1908 | 85 | // https://github.com/ziglang/zig/issues/1908 |
| 85 | if (builtin.single_threaded) return error.SkipZigTest; | 86 | if (builtin.single_threaded) return error.SkipZigTest; |
| 86 | 87 |
lib/std/event/lock.zig+1| ... | @@ -116,6 +116,7 @@ pub const Lock = struct { | ... | @@ -116,6 +116,7 @@ pub const Lock = struct { |
| 116 | }; | 116 | }; |
| 117 | 117 | ||
| 118 | test "std.event.Lock" { | 118 | test "std.event.Lock" { |
| 119 | if (builtin.os == .dragonfly) return error.SkipZigTest; | ||
| 119 | // TODO https://github.com/ziglang/zig/issues/1908 | 120 | // TODO https://github.com/ziglang/zig/issues/1908 |
| 120 | if (builtin.single_threaded) return error.SkipZigTest; | 121 | if (builtin.single_threaded) return error.SkipZigTest; |
| 121 | // TODO https://github.com/ziglang/zig/issues/3251 | 122 | // TODO https://github.com/ziglang/zig/issues/3251 |
lib/std/event/loop.zig+11-10| ... | @@ -51,7 +51,7 @@ pub const Loop = struct { | ... | @@ -51,7 +51,7 @@ pub const Loop = struct { |
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| 53 | pub const EventFd = switch (builtin.os) { | 53 | pub const EventFd = switch (builtin.os) { |
| 54 | .macosx, .freebsd, .netbsd => KEventFd, | 54 | .macosx, .freebsd, .netbsd, .dragonfly => KEventFd, |
| 55 | .linux => struct { | 55 | .linux => struct { |
| 56 | base: ResumeNode, | 56 | base: ResumeNode, |
| 57 | epoll_op: u32, | 57 | epoll_op: u32, |
| ... | @@ -70,7 +70,7 @@ pub const Loop = struct { | ... | @@ -70,7 +70,7 @@ pub const Loop = struct { |
| 70 | }; | 70 | }; |
| 71 | 71 | ||
| 72 | pub const Basic = switch (builtin.os) { | 72 | pub const Basic = switch (builtin.os) { |
| 73 | .macosx, .freebsd, .netbsd => KEventBasic, | 73 | .macosx, .freebsd, .netbsd, .dragonfly => KEventBasic, |
| 74 | .linux => struct { | 74 | .linux => struct { |
| 75 | base: ResumeNode, | 75 | base: ResumeNode, |
| 76 | }, | 76 | }, |
| ... | @@ -244,7 +244,7 @@ pub const Loop = struct { | ... | @@ -244,7 +244,7 @@ pub const Loop = struct { |
| 244 | self.extra_threads[extra_thread_index] = try Thread.spawn(self, workerRun); | 244 | self.extra_threads[extra_thread_index] = try Thread.spawn(self, workerRun); |
| 245 | } | 245 | } |
| 246 | }, | 246 | }, |
| 247 | .macosx, .freebsd, .netbsd => { | 247 | .macosx, .freebsd, .netbsd, .dragonfly => { |
| 248 | self.os_data.kqfd = try os.kqueue(); | 248 | self.os_data.kqfd = try os.kqueue(); |
| 249 | errdefer os.close(self.os_data.kqfd); | 249 | errdefer os.close(self.os_data.kqfd); |
| 250 | 250 | ||
| ... | @@ -409,7 +409,7 @@ pub const Loop = struct { | ... | @@ -409,7 +409,7 @@ pub const Loop = struct { |
| 409 | os.close(self.os_data.epollfd); | 409 | os.close(self.os_data.epollfd); |
| 410 | self.allocator.free(self.eventfd_resume_nodes); | 410 | self.allocator.free(self.eventfd_resume_nodes); |
| 411 | }, | 411 | }, |
| 412 | .macosx, .freebsd, .netbsd => { | 412 | .macosx, .freebsd, .netbsd, .dragonfly => { |
| 413 | os.close(self.os_data.kqfd); | 413 | os.close(self.os_data.kqfd); |
| 414 | os.close(self.os_data.fs_kqfd); | 414 | os.close(self.os_data.fs_kqfd); |
| 415 | }, | 415 | }, |
| ... | @@ -523,7 +523,7 @@ pub const Loop = struct { | ... | @@ -523,7 +523,7 @@ pub const Loop = struct { |
| 523 | const eventfd_node = &resume_stack_node.data; | 523 | const eventfd_node = &resume_stack_node.data; |
| 524 | eventfd_node.base.handle = next_tick_node.data; | 524 | eventfd_node.base.handle = next_tick_node.data; |
| 525 | switch (builtin.os) { | 525 | switch (builtin.os) { |
| 526 | .macosx, .freebsd, .netbsd => { | 526 | .macosx, .freebsd, .netbsd, .dragonfly => { |
| 527 | const kevent_array = (*const [1]os.Kevent)(&eventfd_node.kevent); | 527 | const kevent_array = (*const [1]os.Kevent)(&eventfd_node.kevent); |
| 528 | const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; | 528 | const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; |
| 529 | _ = os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null) catch { | 529 | _ = os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null) catch { |
| ... | @@ -587,6 +587,7 @@ pub const Loop = struct { | ... | @@ -587,6 +587,7 @@ pub const Loop = struct { |
| 587 | .macosx, | 587 | .macosx, |
| 588 | .freebsd, | 588 | .freebsd, |
| 589 | .netbsd, | 589 | .netbsd, |
| 590 | .dragonfly, | ||
| 590 | => self.os_data.fs_thread.wait(), | 591 | => self.os_data.fs_thread.wait(), |
| 591 | else => {}, | 592 | else => {}, |
| 592 | } | 593 | } |
| ... | @@ -644,7 +645,7 @@ pub const Loop = struct { | ... | @@ -644,7 +645,7 @@ pub const Loop = struct { |
| 644 | os.write(self.os_data.final_eventfd, wakeup_bytes) catch unreachable; | 645 | os.write(self.os_data.final_eventfd, wakeup_bytes) catch unreachable; |
| 645 | return; | 646 | return; |
| 646 | }, | 647 | }, |
| 647 | .macosx, .freebsd, .netbsd => { | 648 | .macosx, .freebsd, .netbsd, .dragonfly => { |
| 648 | self.posixFsRequest(&self.os_data.fs_end_request); | 649 | self.posixFsRequest(&self.os_data.fs_end_request); |
| 649 | const final_kevent = (*const [1]os.Kevent)(&self.os_data.final_kevent); | 650 | const final_kevent = (*const [1]os.Kevent)(&self.os_data.final_kevent); |
| 650 | const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; | 651 | const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; |
| ... | @@ -702,7 +703,7 @@ pub const Loop = struct { | ... | @@ -702,7 +703,7 @@ pub const Loop = struct { |
| 702 | } | 703 | } |
| 703 | } | 704 | } |
| 704 | }, | 705 | }, |
| 705 | .macosx, .freebsd, .netbsd => { | 706 | .macosx, .freebsd, .netbsd, .dragonfly => { |
| 706 | var eventlist: [1]os.Kevent = undefined; | 707 | var eventlist: [1]os.Kevent = undefined; |
| 707 | const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; | 708 | const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; |
| 708 | const count = os.kevent(self.os_data.kqfd, empty_kevs, eventlist[0..], null) catch unreachable; | 709 | const count = os.kevent(self.os_data.kqfd, empty_kevs, eventlist[0..], null) catch unreachable; |
| ... | @@ -765,7 +766,7 @@ pub const Loop = struct { | ... | @@ -765,7 +766,7 @@ pub const Loop = struct { |
| 765 | self.beginOneEvent(); // finished in posixFsRun after processing the msg | 766 | self.beginOneEvent(); // finished in posixFsRun after processing the msg |
| 766 | self.os_data.fs_queue.put(request_node); | 767 | self.os_data.fs_queue.put(request_node); |
| 767 | switch (builtin.os) { | 768 | switch (builtin.os) { |
| 768 | .macosx, .freebsd, .netbsd => { | 769 | .macosx, .freebsd, .netbsd, .dragonfly => { |
| 769 | const fs_kevs = (*const [1]os.Kevent)(&self.os_data.fs_kevent_wake); | 770 | const fs_kevs = (*const [1]os.Kevent)(&self.os_data.fs_kevent_wake); |
| 770 | const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; | 771 | const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; |
| 771 | _ = os.kevent(self.os_data.fs_kqfd, fs_kevs, empty_kevs, null) catch unreachable; | 772 | _ = os.kevent(self.os_data.fs_kqfd, fs_kevs, empty_kevs, null) catch unreachable; |
| ... | @@ -838,7 +839,7 @@ pub const Loop = struct { | ... | @@ -838,7 +839,7 @@ pub const Loop = struct { |
| 838 | else => unreachable, | 839 | else => unreachable, |
| 839 | } | 840 | } |
| 840 | }, | 841 | }, |
| 841 | .macosx, .freebsd, .netbsd => { | 842 | .macosx, .freebsd, .netbsd, .dragonfly => { |
| 842 | const fs_kevs = (*const [1]os.Kevent)(&self.os_data.fs_kevent_wait); | 843 | const fs_kevs = (*const [1]os.Kevent)(&self.os_data.fs_kevent_wait); |
| 843 | var out_kevs: [1]os.Kevent = undefined; | 844 | var out_kevs: [1]os.Kevent = undefined; |
| 844 | _ = os.kevent(self.os_data.fs_kqfd, fs_kevs, out_kevs[0..], null) catch unreachable; | 845 | _ = os.kevent(self.os_data.fs_kqfd, fs_kevs, out_kevs[0..], null) catch unreachable; |
| ... | @@ -850,7 +851,7 @@ pub const Loop = struct { | ... | @@ -850,7 +851,7 @@ pub const Loop = struct { |
| 850 | 851 | ||
| 851 | const OsData = switch (builtin.os) { | 852 | const OsData = switch (builtin.os) { |
| 852 | .linux => LinuxOsData, | 853 | .linux => LinuxOsData, |
| 853 | .macosx, .freebsd, .netbsd => KEventData, | 854 | .macosx, .freebsd, .netbsd, .dragonfly => KEventData, |
| 854 | .windows => struct { | 855 | .windows => struct { |
| 855 | io_port: windows.HANDLE, | 856 | io_port: windows.HANDLE, |
| 856 | extra_thread_count: usize, | 857 | extra_thread_count: usize, |
lib/std/fs.zig+6-6| ... | @@ -28,7 +28,7 @@ pub const GetAppDataDirError = @import("fs/get_app_data_dir.zig").GetAppDataDirE | ... | @@ -28,7 +28,7 @@ pub const GetAppDataDirError = @import("fs/get_app_data_dir.zig").GetAppDataDirE |
| 28 | /// All file system operations which return a path are guaranteed to | 28 | /// All file system operations which return a path are guaranteed to |
| 29 | /// fit into a UTF-8 encoded array of this length. | 29 | /// fit into a UTF-8 encoded array of this length. |
| 30 | pub const MAX_PATH_BYTES = switch (builtin.os) { | 30 | pub const MAX_PATH_BYTES = switch (builtin.os) { |
| 31 | .linux, .macosx, .ios, .freebsd, .netbsd => os.PATH_MAX, | 31 | .linux, .macosx, .ios, .freebsd, .netbsd, .dragonfly => os.PATH_MAX, |
| 32 | // Each UTF-16LE character may be expanded to 3 UTF-8 bytes. | 32 | // Each UTF-16LE character may be expanded to 3 UTF-8 bytes. |
| 33 | // If it would require 4 UTF-8 bytes, then there would be a surrogate | 33 | // If it would require 4 UTF-8 bytes, then there would be a surrogate |
| 34 | // pair in the UTF-16LE, and we (over)account 3 bytes for it that way. | 34 | // pair in the UTF-16LE, and we (over)account 3 bytes for it that way. |
| ... | @@ -380,7 +380,7 @@ pub const Dir = struct { | ... | @@ -380,7 +380,7 @@ pub const Dir = struct { |
| 380 | const IteratorError = error{AccessDenied} || os.UnexpectedError; | 380 | const IteratorError = error{AccessDenied} || os.UnexpectedError; |
| 381 | 381 | ||
| 382 | pub const Iterator = switch (builtin.os) { | 382 | pub const Iterator = switch (builtin.os) { |
| 383 | .macosx, .ios, .freebsd, .netbsd => struct { | 383 | .macosx, .ios, .freebsd, .netbsd, .dragonfly => struct { |
| 384 | dir: Dir, | 384 | dir: Dir, |
| 385 | seek: i64, | 385 | seek: i64, |
| 386 | buf: [8192]u8, // TODO align(@alignOf(os.dirent)), | 386 | buf: [8192]u8, // TODO align(@alignOf(os.dirent)), |
| ... | @@ -396,7 +396,7 @@ pub const Dir = struct { | ... | @@ -396,7 +396,7 @@ pub const Dir = struct { |
| 396 | pub fn next(self: *Self) Error!?Entry { | 396 | pub fn next(self: *Self) Error!?Entry { |
| 397 | switch (builtin.os) { | 397 | switch (builtin.os) { |
| 398 | .macosx, .ios => return self.nextDarwin(), | 398 | .macosx, .ios => return self.nextDarwin(), |
| 399 | .freebsd, .netbsd => return self.nextBsd(), | 399 | .freebsd, .netbsd, .dragonfly => return self.nextBsd(), |
| 400 | else => @compileError("unimplemented"), | 400 | else => @compileError("unimplemented"), |
| 401 | } | 401 | } |
| 402 | } | 402 | } |
| ... | @@ -630,7 +630,7 @@ pub const Dir = struct { | ... | @@ -630,7 +630,7 @@ pub const Dir = struct { |
| 630 | 630 | ||
| 631 | pub fn iterate(self: Dir) Iterator { | 631 | pub fn iterate(self: Dir) Iterator { |
| 632 | switch (builtin.os) { | 632 | switch (builtin.os) { |
| 633 | .macosx, .ios, .freebsd, .netbsd => return Iterator{ | 633 | .macosx, .ios, .freebsd, .netbsd, .dragonfly => return Iterator{ |
| 634 | .dir = self, | 634 | .dir = self, |
| 635 | .seek = 0, | 635 | .seek = 0, |
| 636 | .index = 0, | 636 | .index = 0, |
| ... | @@ -1162,7 +1162,7 @@ pub fn openSelfExe() OpenSelfExeError!File { | ... | @@ -1162,7 +1162,7 @@ pub fn openSelfExe() OpenSelfExeError!File { |
| 1162 | 1162 | ||
| 1163 | test "openSelfExe" { | 1163 | test "openSelfExe" { |
| 1164 | switch (builtin.os) { | 1164 | switch (builtin.os) { |
| 1165 | .linux, .macosx, .ios, .windows, .freebsd => (try openSelfExe()).close(), | 1165 | .linux, .macosx, .ios, .windows, .freebsd, .dragonfly => (try openSelfExe()).close(), |
| 1166 | else => return error.SkipZigTest, // Unsupported OS. | 1166 | else => return error.SkipZigTest, // Unsupported OS. |
| 1167 | } | 1167 | } |
| 1168 | } | 1168 | } |
| ... | @@ -1188,7 +1188,7 @@ pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) SelfExePathError![]u8 { | ... | @@ -1188,7 +1188,7 @@ pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) SelfExePathError![]u8 { |
| 1188 | } | 1188 | } |
| 1189 | switch (builtin.os) { | 1189 | switch (builtin.os) { |
| 1190 | .linux => return os.readlinkC(c"/proc/self/exe", out_buffer), | 1190 | .linux => return os.readlinkC(c"/proc/self/exe", out_buffer), |
| 1191 | .freebsd => { | 1191 | .freebsd, .dragonfly => { |
| 1192 | var mib = [4]c_int{ os.CTL_KERN, os.KERN_PROC, os.KERN_PROC_PATHNAME, -1 }; | 1192 | var mib = [4]c_int{ os.CTL_KERN, os.KERN_PROC, os.KERN_PROC_PATHNAME, -1 }; |
| 1193 | var out_len: usize = out_buffer.len; | 1193 | var out_len: usize = out_buffer.len; |
| 1194 | try os.sysctl(&mib, out_buffer, &out_len, null, 0); | 1194 | try os.sysctl(&mib, out_buffer, &out_len, null, 0); |
lib/std/fs/get_app_data_dir.zig+1-1| ... | @@ -44,7 +44,7 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD | ... | @@ -44,7 +44,7 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD |
| 44 | }; | 44 | }; |
| 45 | return fs.path.join(allocator, [_][]const u8{ home_dir, "Library", "Application Support", appname }); | 45 | return fs.path.join(allocator, [_][]const u8{ home_dir, "Library", "Application Support", appname }); |
| 46 | }, | 46 | }, |
| 47 | .linux, .freebsd, .netbsd => { | 47 | .linux, .freebsd, .netbsd, .dragonfly => { |
| 48 | const home_dir = os.getenv("HOME") orelse { | 48 | const home_dir = os.getenv("HOME") orelse { |
| 49 | // TODO look in /etc/passwd | 49 | // TODO look in /etc/passwd |
| 50 | return error.AppDataDirUnavailable; | 50 | return error.AppDataDirUnavailable; |
lib/std/mutex.zig+1| ... | @@ -130,6 +130,7 @@ const TestContext = struct { | ... | @@ -130,6 +130,7 @@ const TestContext = struct { |
| 130 | }; | 130 | }; |
| 131 | 131 | ||
| 132 | test "std.Mutex" { | 132 | test "std.Mutex" { |
| 133 | if (builtin.os == .dragonfly) return error.SkipZigTest; | ||
| 133 | var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024); | 134 | var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024); |
| 134 | defer std.heap.direct_allocator.free(plenty_of_memory); | 135 | defer std.heap.direct_allocator.free(plenty_of_memory); |
| 135 | 136 |
lib/std/os.zig+3-1| ... | @@ -24,9 +24,10 @@ const dl = @import("dynamic_library.zig"); | ... | @@ -24,9 +24,10 @@ const dl = @import("dynamic_library.zig"); |
| 24 | const MAX_PATH_BYTES = std.fs.MAX_PATH_BYTES; | 24 | const MAX_PATH_BYTES = std.fs.MAX_PATH_BYTES; |
| 25 | 25 | ||
| 26 | pub const darwin = @import("os/darwin.zig"); | 26 | pub const darwin = @import("os/darwin.zig"); |
| 27 | pub const dragonfly = @import("os/dragonfly.zig"); | ||
| 27 | pub const freebsd = @import("os/freebsd.zig"); | 28 | pub const freebsd = @import("os/freebsd.zig"); |
| 28 | pub const linux = @import("os/linux.zig"); | ||
| 29 | pub const netbsd = @import("os/netbsd.zig"); | 29 | pub const netbsd = @import("os/netbsd.zig"); |
| 30 | pub const linux = @import("os/linux.zig"); | ||
| 30 | pub const uefi = @import("os/uefi.zig"); | 31 | pub const uefi = @import("os/uefi.zig"); |
| 31 | pub const wasi = @import("os/wasi.zig"); | 32 | pub const wasi = @import("os/wasi.zig"); |
| 32 | pub const windows = @import("os/windows.zig"); | 33 | pub const windows = @import("os/windows.zig"); |
| ... | @@ -55,6 +56,7 @@ pub const system = if (builtin.link_libc) std.c else switch (builtin.os) { | ... | @@ -55,6 +56,7 @@ pub const system = if (builtin.link_libc) std.c else switch (builtin.os) { |
| 55 | .freebsd => freebsd, | 56 | .freebsd => freebsd, |
| 56 | .linux => linux, | 57 | .linux => linux, |
| 57 | .netbsd => netbsd, | 58 | .netbsd => netbsd, |
| 59 | .dragonfly => dragonfly, | ||
| 58 | .wasi => wasi, | 60 | .wasi => wasi, |
| 59 | .windows => windows, | 61 | .windows => windows, |
| 60 | .zen => zen, | 62 | .zen => zen, |
lib/std/os/bits.zig+1| ... | @@ -5,6 +5,7 @@ const builtin = @import("builtin"); | ... | @@ -5,6 +5,7 @@ const builtin = @import("builtin"); |
| 5 | 5 | ||
| 6 | pub usingnamespace switch (builtin.os) { | 6 | pub usingnamespace switch (builtin.os) { |
| 7 | .macosx, .ios, .tvos, .watchos => @import("bits/darwin.zig"), | 7 | .macosx, .ios, .tvos, .watchos => @import("bits/darwin.zig"), |
| 8 | .dragonfly => @import("bits/dragonfly.zig"), | ||
| 8 | .freebsd => @import("bits/freebsd.zig"), | 9 | .freebsd => @import("bits/freebsd.zig"), |
| 9 | .linux => @import("bits/linux.zig"), | 10 | .linux => @import("bits/linux.zig"), |
| 10 | .netbsd => @import("bits/netbsd.zig"), | 11 | .netbsd => @import("bits/netbsd.zig"), |
lib/std/os/bits/darwin.zig+4| ... | @@ -119,6 +119,10 @@ pub const dirent = extern struct { | ... | @@ -119,6 +119,10 @@ pub const dirent = extern struct { |
| 119 | d_namlen: u16, | 119 | d_namlen: u16, |
| 120 | d_type: u8, | 120 | d_type: u8, |
| 121 | d_name: u8, // field address is address of first byte of name | 121 | d_name: u8, // field address is address of first byte of name |
| 122 | |||
| 123 | pub fn reclen(self: dirent) usize { | ||
| 124 | return self.d_reclen; | ||
| 125 | } | ||
| 122 | }; | 126 | }; |
| 123 | 127 | ||
| 124 | pub const pthread_attr_t = extern struct { | 128 | pub const pthread_attr_t = extern struct { |
lib/std/os/bits/dragonfly.zig created+702| ... | @@ -0,0 +1,702 @@ | ||
| 1 | const std = @import("../../std.zig"); | ||
| 2 | const maxInt = std.math.maxInt; | ||
| 3 | |||
| 4 | pub fn S_ISCHR(m: u32) bool { | ||
| 5 | return m & S_IFMT == S_IFCHR; | ||
| 6 | } | ||
| 7 | pub const fd_t = c_int; | ||
| 8 | pub const pid_t = c_int; | ||
| 9 | pub const off_t = c_long; | ||
| 10 | |||
| 11 | pub const ENOTSUP = EOPNOTSUPP; | ||
| 12 | pub const EWOULDBLOCK = EAGAIN; | ||
| 13 | pub const EPERM = 1; | ||
| 14 | pub const ENOENT = 2; | ||
| 15 | pub const ESRCH = 3; | ||
| 16 | pub const EINTR = 4; | ||
| 17 | pub const EIO = 5; | ||
| 18 | pub const ENXIO = 6; | ||
| 19 | pub const E2BIG = 7; | ||
| 20 | pub const ENOEXEC = 8; | ||
| 21 | pub const EBADF = 9; | ||
| 22 | pub const ECHILD = 10; | ||
| 23 | pub const EDEADLK = 11; | ||
| 24 | pub const ENOMEM = 12; | ||
| 25 | pub const EACCES = 13; | ||
| 26 | pub const EFAULT = 14; | ||
| 27 | pub const ENOTBLK = 15; | ||
| 28 | pub const EBUSY = 16; | ||
| 29 | pub const EEXIST = 17; | ||
| 30 | pub const EXDEV = 18; | ||
| 31 | pub const ENODEV = 19; | ||
| 32 | pub const ENOTDIR = 20; | ||
| 33 | pub const EISDIR = 21; | ||
| 34 | pub const EINVAL = 22; | ||
| 35 | pub const ENFILE = 23; | ||
| 36 | pub const EMFILE = 24; | ||
| 37 | pub const ENOTTY = 25; | ||
| 38 | pub const ETXTBSY = 26; | ||
| 39 | pub const EFBIG = 27; | ||
| 40 | pub const ENOSPC = 28; | ||
| 41 | pub const ESPIPE = 29; | ||
| 42 | pub const EROFS = 30; | ||
| 43 | pub const EMLINK = 31; | ||
| 44 | pub const EPIPE = 32; | ||
| 45 | pub const EDOM = 33; | ||
| 46 | pub const ERANGE = 34; | ||
| 47 | pub const EAGAIN = 35; | ||
| 48 | pub const EINPROGRESS = 36; | ||
| 49 | pub const EALREADY = 37; | ||
| 50 | pub const ENOTSOCK = 38; | ||
| 51 | pub const EDESTADDRREQ = 39; | ||
| 52 | pub const EMSGSIZE = 40; | ||
| 53 | pub const EPROTOTYPE = 41; | ||
| 54 | pub const ENOPROTOOPT = 42; | ||
| 55 | pub const EPROTONOSUPPORT = 43; | ||
| 56 | pub const ESOCKTNOSUPPORT = 44; | ||
| 57 | pub const EOPNOTSUPP = 45; | ||
| 58 | pub const EPFNOSUPPORT = 46; | ||
| 59 | pub const EAFNOSUPPORT = 47; | ||
| 60 | pub const EADDRINUSE = 48; | ||
| 61 | pub const EADDRNOTAVAIL = 49; | ||
| 62 | pub const ENETDOWN = 50; | ||
| 63 | pub const ENETUNREACH = 51; | ||
| 64 | pub const ENETRESET = 52; | ||
| 65 | pub const ECONNABORTED = 53; | ||
| 66 | pub const ECONNRESET = 54; | ||
| 67 | pub const ENOBUFS = 55; | ||
| 68 | pub const EISCONN = 56; | ||
| 69 | pub const ENOTCONN = 57; | ||
| 70 | pub const ESHUTDOWN = 58; | ||
| 71 | pub const ETOOMANYREFS = 59; | ||
| 72 | pub const ETIMEDOUT = 60; | ||
| 73 | pub const ECONNREFUSED = 61; | ||
| 74 | pub const ELOOP = 62; | ||
| 75 | pub const ENAMETOOLONG = 63; | ||
| 76 | pub const EHOSTDOWN = 64; | ||
| 77 | pub const EHOSTUNREACH = 65; | ||
| 78 | pub const ENOTEMPTY = 66; | ||
| 79 | pub const EPROCLIM = 67; | ||
| 80 | pub const EUSERS = 68; | ||
| 81 | pub const EDQUOT = 69; | ||
| 82 | pub const ESTALE = 70; | ||
| 83 | pub const EREMOTE = 71; | ||
| 84 | pub const EBADRPC = 72; | ||
| 85 | pub const ERPCMISMATCH = 73; | ||
| 86 | pub const EPROGUNAVAIL = 74; | ||
| 87 | pub const EPROGMISMATCH = 75; | ||
| 88 | pub const EPROCUNAVAIL = 76; | ||
| 89 | pub const ENOLCK = 77; | ||
| 90 | pub const ENOSYS = 78; | ||
| 91 | pub const EFTYPE = 79; | ||
| 92 | pub const EAUTH = 80; | ||
| 93 | pub const ENEEDAUTH = 81; | ||
| 94 | pub const EIDRM = 82; | ||
| 95 | pub const ENOMSG = 83; | ||
| 96 | pub const EOVERFLOW = 84; | ||
| 97 | pub const ECANCELED = 85; | ||
| 98 | pub const EILSEQ = 86; | ||
| 99 | pub const ENOATTR = 87; | ||
| 100 | pub const EDOOFUS = 88; | ||
| 101 | pub const EBADMSG = 89; | ||
| 102 | pub const EMULTIHOP = 90; | ||
| 103 | pub const ENOLINK = 91; | ||
| 104 | pub const EPROTO = 92; | ||
| 105 | pub const ENOMEDIUM = 93; | ||
| 106 | pub const ELAST = 99; | ||
| 107 | pub const EASYNC = 99; | ||
| 108 | |||
| 109 | pub const STDIN_FILENO = 0; | ||
| 110 | pub const STDOUT_FILENO = 1; | ||
| 111 | pub const STDERR_FILENO = 2; | ||
| 112 | |||
| 113 | pub const PROT_NONE = 0; | ||
| 114 | pub const PROT_READ = 1; | ||
| 115 | pub const PROT_WRITE = 2; | ||
| 116 | pub const PROT_EXEC = 4; | ||
| 117 | |||
| 118 | pub const MAP_FILE = 0; | ||
| 119 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); | ||
| 120 | pub const MAP_ANONYMOUS = MAP_ANON; | ||
| 121 | pub const MAP_COPY = MAP_PRIVATE; | ||
| 122 | pub const MAP_SHARED = 1; | ||
| 123 | pub const MAP_PRIVATE = 2; | ||
| 124 | pub const MAP_FIXED = 16; | ||
| 125 | pub const MAP_RENAME = 32; | ||
| 126 | pub const MAP_NORESERVE = 64; | ||
| 127 | pub const MAP_INHERIT = 128; | ||
| 128 | pub const MAP_NOEXTEND = 256; | ||
| 129 | pub const MAP_HASSEMAPHORE = 512; | ||
| 130 | pub const MAP_STACK = 1024; | ||
| 131 | pub const MAP_NOSYNC = 2048; | ||
| 132 | pub const MAP_ANON = 4096; | ||
| 133 | pub const MAP_VPAGETABLE = 8192; | ||
| 134 | pub const MAP_TRYFIXED = 65536; | ||
| 135 | pub const MAP_NOCORE = 131072; | ||
| 136 | pub const MAP_SIZEALIGN = 262144; | ||
| 137 | |||
| 138 | pub const PATH_MAX = 1024; | ||
| 139 | |||
| 140 | pub const Stat = extern struct { | ||
| 141 | ino: c_ulong, | ||
| 142 | nlink: c_uint, | ||
| 143 | dev: c_uint, | ||
| 144 | mode: c_ushort, | ||
| 145 | padding1: u16, | ||
| 146 | uid: c_uint, | ||
| 147 | gid: c_uint, | ||
| 148 | rdev: c_uint, | ||
| 149 | atim: timespec, | ||
| 150 | mtim: timespec, | ||
| 151 | ctim: timespec, | ||
| 152 | size: c_ulong, | ||
| 153 | blocks: i64, | ||
| 154 | blksize: u32, | ||
| 155 | flags: u32, | ||
| 156 | gen: u32, | ||
| 157 | lspare: i32, | ||
| 158 | qspare1: i64, | ||
| 159 | qspare2: i64, | ||
| 160 | pub fn atime(self: Stat) timespec { | ||
| 161 | return self.atim; | ||
| 162 | } | ||
| 163 | |||
| 164 | pub fn mtime(self: Stat) timespec { | ||
| 165 | return self.mtim; | ||
| 166 | } | ||
| 167 | |||
| 168 | pub fn ctime(self: Stat) timespec { | ||
| 169 | return self.ctim; | ||
| 170 | } | ||
| 171 | }; | ||
| 172 | |||
| 173 | pub const timespec = extern struct { | ||
| 174 | tv_sec: c_long, | ||
| 175 | tv_nsec: c_long, | ||
| 176 | }; | ||
| 177 | |||
| 178 | pub const CTL_UNSPEC = 0; | ||
| 179 | pub const CTL_KERN = 1; | ||
| 180 | pub const CTL_VM = 2; | ||
| 181 | pub const CTL_VFS = 3; | ||
| 182 | pub const CTL_NET = 4; | ||
| 183 | pub const CTL_DEBUG = 5; | ||
| 184 | pub const CTL_HW = 6; | ||
| 185 | pub const CTL_MACHDEP = 7; | ||
| 186 | pub const CTL_USER = 8; | ||
| 187 | pub const CTL_LWKT = 10; | ||
| 188 | pub const CTL_MAXID = 11; | ||
| 189 | pub const CTL_MAXNAME = 12; | ||
| 190 | |||
| 191 | pub const KERN_PROC_ALL = 0; | ||
| 192 | pub const KERN_OSTYPE = 1; | ||
| 193 | pub const KERN_PROC_PID = 1; | ||
| 194 | pub const KERN_OSRELEASE = 2; | ||
| 195 | pub const KERN_PROC_PGRP = 2; | ||
| 196 | pub const KERN_OSREV = 3; | ||
| 197 | pub const KERN_PROC_SESSION = 3; | ||
| 198 | pub const KERN_VERSION = 4; | ||
| 199 | pub const KERN_PROC_TTY = 4; | ||
| 200 | pub const KERN_MAXVNODES = 5; | ||
| 201 | pub const KERN_PROC_UID = 5; | ||
| 202 | pub const KERN_MAXPROC = 6; | ||
| 203 | pub const KERN_PROC_RUID = 6; | ||
| 204 | pub const KERN_MAXFILES = 7; | ||
| 205 | pub const KERN_PROC_ARGS = 7; | ||
| 206 | pub const KERN_ARGMAX = 8; | ||
| 207 | pub const KERN_PROC_CWD = 8; | ||
| 208 | pub const KERN_PROC_PATHNAME = 9; | ||
| 209 | pub const KERN_SECURELVL = 9; | ||
| 210 | pub const KERN_PROC_SIGTRAMP = 10; | ||
| 211 | pub const KERN_HOSTNAME = 10; | ||
| 212 | pub const KERN_HOSTID = 11; | ||
| 213 | pub const KERN_CLOCKRATE = 12; | ||
| 214 | pub const KERN_VNODE = 13; | ||
| 215 | pub const KERN_PROC = 14; | ||
| 216 | pub const KERN_FILE = 15; | ||
| 217 | pub const KERN_PROC_FLAGMASK = 16; | ||
| 218 | pub const KERN_PROF = 16; | ||
| 219 | pub const KERN_PROC_FLAG_LWP = 16; | ||
| 220 | pub const KERN_POSIX1 = 17; | ||
| 221 | pub const KERN_NGROUPS = 18; | ||
| 222 | pub const KERN_JOB_CONTROL = 19; | ||
| 223 | pub const KERN_SAVED_IDS = 20; | ||
| 224 | pub const KERN_BOOTTIME = 21; | ||
| 225 | pub const KERN_NISDOMAINNAME = 22; | ||
| 226 | pub const KERN_UPDATEINTERVAL = 23; | ||
| 227 | pub const KERN_OSRELDATE = 24; | ||
| 228 | pub const KERN_NTP_PLL = 25; | ||
| 229 | pub const KERN_BOOTFILE = 26; | ||
| 230 | pub const KERN_MAXFILESPERPROC = 27; | ||
| 231 | pub const KERN_MAXPROCPERUID = 28; | ||
| 232 | pub const KERN_DUMPDEV = 29; | ||
| 233 | pub const KERN_IPC = 30; | ||
| 234 | pub const KERN_DUMMY = 31; | ||
| 235 | pub const KERN_PS_STRINGS = 32; | ||
| 236 | pub const KERN_USRSTACK = 33; | ||
| 237 | pub const KERN_LOGSIGEXIT = 34; | ||
| 238 | pub const KERN_IOV_MAX = 35; | ||
| 239 | pub const KERN_MAXPOSIXLOCKSPERUID = 36; | ||
| 240 | pub const KERN_MAXID = 37; | ||
| 241 | |||
| 242 | pub const HOST_NAME_MAX = 255; | ||
| 243 | |||
| 244 | pub const O_LARGEFILE = 0; // faked support | ||
| 245 | pub const O_RDONLY = 0; | ||
| 246 | pub const O_NDELAY = O_NONBLOCK; | ||
| 247 | pub const O_WRONLY = 1; | ||
| 248 | pub const O_RDWR = 2; | ||
| 249 | pub const O_ACCMODE = 3; | ||
| 250 | pub const O_NONBLOCK = 4; | ||
| 251 | pub const O_APPEND = 8; | ||
| 252 | pub const O_SHLOCK = 16; | ||
| 253 | pub const O_EXLOCK = 32; | ||
| 254 | pub const O_ASYNC = 64; | ||
| 255 | pub const O_FSYNC = 128; | ||
| 256 | pub const O_SYNC = 128; | ||
| 257 | pub const O_NOFOLLOW = 256; | ||
| 258 | pub const O_CREAT = 512; | ||
| 259 | pub const O_TRUNC = 1024; | ||
| 260 | pub const O_EXCL = 2048; | ||
| 261 | pub const O_NOCTTY = 32768; | ||
| 262 | pub const O_DIRECT = 65536; | ||
| 263 | pub const O_CLOEXEC = 131072; | ||
| 264 | pub const O_FBLOCKING = 262144; | ||
| 265 | pub const O_FNONBLOCKING = 524288; | ||
| 266 | pub const O_FAPPEND = 1048576; | ||
| 267 | pub const O_FOFFSET = 2097152; | ||
| 268 | pub const O_FSYNCWRITE = 4194304; | ||
| 269 | pub const O_FASYNCWRITE = 8388608; | ||
| 270 | pub const O_DIRECTORY = 134217728; | ||
| 271 | |||
| 272 | pub const SEEK_SET = 0; | ||
| 273 | pub const SEEK_CUR = 1; | ||
| 274 | pub const SEEK_END = 2; | ||
| 275 | pub const SEEK_DATA = 3; | ||
| 276 | pub const SEEK_HOLE = 4; | ||
| 277 | |||
| 278 | pub const F_OK = 0; | ||
| 279 | pub const F_ULOCK = 0; | ||
| 280 | pub const F_LOCK = 1; | ||
| 281 | pub const F_TLOCK = 2; | ||
| 282 | pub const F_TEST = 3; | ||
| 283 | |||
| 284 | pub const AT_FDCWD = -328243; | ||
| 285 | pub const AT_SYMLINK_NOFOLLOW = 1; | ||
| 286 | pub const AT_REMOVEDIR = 2; | ||
| 287 | pub const AT_EACCESS = 4; | ||
| 288 | pub const AT_SYMLINK_FOLLOW = 8; | ||
| 289 | |||
| 290 | pub fn WEXITSTATUS(s: u32) u32 { | ||
| 291 | return (s & 0xff00) >> 8; | ||
| 292 | } | ||
| 293 | pub fn WTERMSIG(s: u32) u32 { | ||
| 294 | return s & 0x7f; | ||
| 295 | } | ||
| 296 | pub fn WSTOPSIG(s: u32) u32 { | ||
| 297 | return WEXITSTATUS(s); | ||
| 298 | } | ||
| 299 | pub fn WIFEXITED(s: u32) bool { | ||
| 300 | return WTERMSIG(s) == 0; | ||
| 301 | } | ||
| 302 | pub fn WIFSTOPPED(s: u32) bool { | ||
| 303 | return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; | ||
| 304 | } | ||
| 305 | pub fn WIFSIGNALED(s: u32) bool { | ||
| 306 | return (s & 0xffff) -% 1 < 0xff; | ||
| 307 | } | ||
| 308 | |||
| 309 | pub const dirent = extern struct { | ||
| 310 | d_fileno: c_ulong, | ||
| 311 | d_namlen: u16, | ||
| 312 | d_type: u8, | ||
| 313 | d_unused1: u8, | ||
| 314 | d_unused2: u32, | ||
| 315 | d_name: [256]u8, | ||
| 316 | |||
| 317 | pub fn reclen(self: dirent) usize { | ||
| 318 | return (@byteOffsetOf(dirent, "d_name") + self.d_namlen + 1 + 7) & ~usize(7); | ||
| 319 | } | ||
| 320 | }; | ||
| 321 | |||
| 322 | pub const DT_UNKNOWN = 0; | ||
| 323 | pub const DT_FIFO = 1; | ||
| 324 | pub const DT_CHR = 2; | ||
| 325 | pub const DT_DIR = 4; | ||
| 326 | pub const DT_BLK = 6; | ||
| 327 | pub const DT_REG = 8; | ||
| 328 | pub const DT_LNK = 10; | ||
| 329 | pub const DT_SOCK = 12; | ||
| 330 | pub const DT_WHT = 14; | ||
| 331 | pub const DT_DBF = 15; | ||
| 332 | |||
| 333 | pub const CLOCK_REALTIME = 0; | ||
| 334 | pub const CLOCK_VIRTUAL = 1; | ||
| 335 | pub const CLOCK_PROF = 2; | ||
| 336 | pub const CLOCK_MONOTONIC = 4; | ||
| 337 | pub const CLOCK_UPTIME = 5; | ||
| 338 | pub const CLOCK_UPTIME_PRECISE = 7; | ||
| 339 | pub const CLOCK_UPTIME_FAST = 8; | ||
| 340 | pub const CLOCK_REALTIME_PRECISE = 9; | ||
| 341 | pub const CLOCK_REALTIME_FAST = 10; | ||
| 342 | pub const CLOCK_MONOTONIC_PRECISE = 11; | ||
| 343 | pub const CLOCK_MONOTONIC_FAST = 12; | ||
| 344 | pub const CLOCK_SECOND = 13; | ||
| 345 | pub const CLOCK_THREAD_CPUTIME_ID = 14; | ||
| 346 | pub const CLOCK_PROCESS_CPUTIME_ID = 15; | ||
| 347 | |||
| 348 | pub const sockaddr = extern struct { | ||
| 349 | sa_len: u8, | ||
| 350 | sa_family: u8, | ||
| 351 | sa_data: [14]u8, | ||
| 352 | }; | ||
| 353 | |||
| 354 | pub const Kevent = extern struct { | ||
| 355 | ident: usize, | ||
| 356 | filter: c_short, | ||
| 357 | flags: c_ushort, | ||
| 358 | fflags: c_uint, | ||
| 359 | data: isize, | ||
| 360 | udata: usize, | ||
| 361 | }; | ||
| 362 | |||
| 363 | pub const pthread_attr_t = extern struct { // copied from freebsd | ||
| 364 | __size: [56]u8, | ||
| 365 | __align: c_long, | ||
| 366 | }; | ||
| 367 | |||
| 368 | pub const EVFILT_FS = -10; | ||
| 369 | pub const EVFILT_USER = -9; | ||
| 370 | pub const EVFILT_EXCEPT = -8; | ||
| 371 | pub const EVFILT_TIMER = -7; | ||
| 372 | pub const EVFILT_SIGNAL = -6; | ||
| 373 | pub const EVFILT_PROC = -5; | ||
| 374 | pub const EVFILT_VNODE = -4; | ||
| 375 | pub const EVFILT_AIO = -3; | ||
| 376 | pub const EVFILT_WRITE = -2; | ||
| 377 | pub const EVFILT_READ = -1; | ||
| 378 | pub const EVFILT_SYSCOUNT = 10; | ||
| 379 | pub const EVFILT_MARKER = 15; | ||
| 380 | |||
| 381 | pub const EV_ADD = 1; | ||
| 382 | pub const EV_DELETE = 2; | ||
| 383 | pub const EV_ENABLE = 4; | ||
| 384 | pub const EV_DISABLE = 8; | ||
| 385 | pub const EV_ONESHOT = 16; | ||
| 386 | pub const EV_CLEAR = 32; | ||
| 387 | pub const EV_RECEIPT = 64; | ||
| 388 | pub const EV_DISPATCH = 128; | ||
| 389 | pub const EV_NODATA = 4096; | ||
| 390 | pub const EV_FLAG1 = 8192; | ||
| 391 | pub const EV_ERROR = 16384; | ||
| 392 | pub const EV_EOF = 32768; | ||
| 393 | pub const EV_SYSFLAGS = 61440; | ||
| 394 | |||
| 395 | pub const NOTE_FFNOP = 0; | ||
| 396 | pub const NOTE_TRACK = 1; | ||
| 397 | pub const NOTE_DELETE = 1; | ||
| 398 | pub const NOTE_LOWAT = 1; | ||
| 399 | pub const NOTE_TRACKERR = 2; | ||
| 400 | pub const NOTE_OOB = 2; | ||
| 401 | pub const NOTE_WRITE = 2; | ||
| 402 | pub const NOTE_EXTEND = 4; | ||
| 403 | pub const NOTE_CHILD = 4; | ||
| 404 | pub const NOTE_ATTRIB = 8; | ||
| 405 | pub const NOTE_LINK = 16; | ||
| 406 | pub const NOTE_RENAME = 32; | ||
| 407 | pub const NOTE_REVOKE = 64; | ||
| 408 | pub const NOTE_PDATAMASK = 1048575; | ||
| 409 | pub const NOTE_FFLAGSMASK = 16777215; | ||
| 410 | pub const NOTE_TRIGGER = 16777216; | ||
| 411 | pub const NOTE_EXEC = 536870912; | ||
| 412 | pub const NOTE_FFAND = 1073741824; | ||
| 413 | pub const NOTE_FORK = 1073741824; | ||
| 414 | pub const NOTE_EXIT = 2147483648; | ||
| 415 | pub const NOTE_FFOR = 2147483648; | ||
| 416 | pub const NOTE_FFCTRLMASK = 3221225472; | ||
| 417 | pub const NOTE_FFCOPY = 3221225472; | ||
| 418 | pub const NOTE_PCTRLMASK = 4026531840; | ||
| 419 | |||
| 420 | pub const stack_t = extern struct { | ||
| 421 | ss_sp: [*]u8, | ||
| 422 | ss_size: isize, | ||
| 423 | ss_flags: i32, | ||
| 424 | }; | ||
| 425 | |||
| 426 | pub const S_IREAD = S_IRUSR; | ||
| 427 | pub const S_IEXEC = S_IXUSR; | ||
| 428 | pub const S_IWRITE = S_IWUSR; | ||
| 429 | pub const S_IXOTH = 1; | ||
| 430 | pub const S_IWOTH = 2; | ||
| 431 | pub const S_IROTH = 4; | ||
| 432 | pub const S_IRWXO = 7; | ||
| 433 | pub const S_IXGRP = 8; | ||
| 434 | pub const S_IWGRP = 16; | ||
| 435 | pub const S_IRGRP = 32; | ||
| 436 | pub const S_IRWXG = 56; | ||
| 437 | pub const S_IXUSR = 64; | ||
| 438 | pub const S_IWUSR = 128; | ||
| 439 | pub const S_IRUSR = 256; | ||
| 440 | pub const S_IRWXU = 448; | ||
| 441 | pub const S_ISTXT = 512; | ||
| 442 | pub const S_BLKSIZE = 512; | ||
| 443 | pub const S_ISVTX = 512; | ||
| 444 | pub const S_ISGID = 1024; | ||
| 445 | pub const S_ISUID = 2048; | ||
| 446 | pub const S_IFIFO = 4096; | ||
| 447 | pub const S_IFCHR = 8192; | ||
| 448 | pub const S_IFDIR = 16384; | ||
| 449 | pub const S_IFBLK = 24576; | ||
| 450 | pub const S_IFREG = 32768; | ||
| 451 | pub const S_IFDB = 36864; | ||
| 452 | pub const S_IFLNK = 40960; | ||
| 453 | pub const S_IFSOCK = 49152; | ||
| 454 | pub const S_IFWHT = 57344; | ||
| 455 | pub const S_IFMT = 61440; | ||
| 456 | |||
| 457 | pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize)); | ||
| 458 | pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0); | ||
| 459 | pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1); | ||
| 460 | pub const BADSIG = SIG_ERR; | ||
| 461 | pub const SIG_BLOCK = 1; | ||
| 462 | pub const SIG_UNBLOCK = 2; | ||
| 463 | pub const SIG_SETMASK = 3; | ||
| 464 | |||
| 465 | pub const SIGIOT = SIGABRT; | ||
| 466 | pub const SIGHUP = 1; | ||
| 467 | pub const SIGINT = 2; | ||
| 468 | pub const SIGQUIT = 3; | ||
| 469 | pub const SIGILL = 4; | ||
| 470 | pub const SIGTRAP = 5; | ||
| 471 | pub const SIGABRT = 6; | ||
| 472 | pub const SIGEMT = 7; | ||
| 473 | pub const SIGFPE = 8; | ||
| 474 | pub const SIGKILL = 9; | ||
| 475 | pub const SIGBUS = 10; | ||
| 476 | pub const SIGSEGV = 11; | ||
| 477 | pub const SIGSYS = 12; | ||
| 478 | pub const SIGPIPE = 13; | ||
| 479 | pub const SIGALRM = 14; | ||
| 480 | pub const SIGTERM = 15; | ||
| 481 | pub const SIGURG = 16; | ||
| 482 | pub const SIGSTOP = 17; | ||
| 483 | pub const SIGTSTP = 18; | ||
| 484 | pub const SIGCONT = 19; | ||
| 485 | pub const SIGCHLD = 20; | ||
| 486 | pub const SIGTTIN = 21; | ||
| 487 | pub const SIGTTOU = 22; | ||
| 488 | pub const SIGIO = 23; | ||
| 489 | pub const SIGXCPU = 24; | ||
| 490 | pub const SIGXFSZ = 25; | ||
| 491 | pub const SIGVTALRM = 26; | ||
| 492 | pub const SIGPROF = 27; | ||
| 493 | pub const SIGWINCH = 28; | ||
| 494 | pub const SIGINFO = 29; | ||
| 495 | pub const SIGUSR1 = 30; | ||
| 496 | pub const SIGUSR2 = 31; | ||
| 497 | pub const SIGTHR = 32; | ||
| 498 | pub const SIGCKPT = 33; | ||
| 499 | pub const SIGCKPTEXIT = 34; | ||
| 500 | pub const siginfo_t = extern struct { | ||
| 501 | si_signo: c_int, | ||
| 502 | si_errno: c_int, | ||
| 503 | si_code: c_int, | ||
| 504 | si_pid: c_int, | ||
| 505 | si_uid: c_uint, | ||
| 506 | si_status: c_int, | ||
| 507 | si_addr: ?*c_void, | ||
| 508 | si_value: union_sigval, | ||
| 509 | si_band: c_long, | ||
| 510 | __spare__: [7]c_int, | ||
| 511 | }; | ||
| 512 | pub const sigset_t = extern struct { | ||
| 513 | __bits: [4]c_uint, | ||
| 514 | }; | ||
| 515 | pub const sig_atomic_t = c_int; | ||
| 516 | pub const Sigaction = extern struct { | ||
| 517 | __sigaction_u: extern union { | ||
| 518 | __sa_handler: ?extern fn(c_int) void, | ||
| 519 | __sa_sigaction: ?extern fn(c_int, [*c]siginfo_t, ?*c_void) void, | ||
| 520 | }, | ||
| 521 | sa_flags: c_int, | ||
| 522 | sa_mask: sigset_t, | ||
| 523 | }; | ||
| 524 | pub const sig_t = [*c]extern fn(c_int) void; | ||
| 525 | |||
| 526 | pub const sigvec = extern struct { | ||
| 527 | sv_handler: [*c]__sighandler_t, | ||
| 528 | sv_mask: c_int, | ||
| 529 | sv_flags: c_int, | ||
| 530 | }; | ||
| 531 | |||
| 532 | pub const SOCK_STREAM = 1; | ||
| 533 | pub const SOCK_DGRAM = 2; | ||
| 534 | pub const SOCK_RAW = 3; | ||
| 535 | pub const SOCK_RDM = 4; | ||
| 536 | pub const SOCK_SEQPACKET = 5; | ||
| 537 | pub const SOCK_MAXADDRLEN = 255; | ||
| 538 | pub const SOCK_CLOEXEC = 268435456; | ||
| 539 | pub const SOCK_NONBLOCK = 536870912; | ||
| 540 | |||
| 541 | pub const PF_INET6 = AF_INET6; | ||
| 542 | pub const PF_IMPLINK = AF_IMPLINK; | ||
| 543 | pub const PF_ROUTE = AF_ROUTE; | ||
| 544 | pub const PF_ISO = AF_ISO; | ||
| 545 | pub const PF_PIP = pseudo_AF_PIP; | ||
| 546 | pub const PF_CHAOS = AF_CHAOS; | ||
| 547 | pub const PF_DATAKIT = AF_DATAKIT; | ||
| 548 | pub const PF_INET = AF_INET; | ||
| 549 | pub const PF_APPLETALK = AF_APPLETALK; | ||
| 550 | pub const PF_SIP = AF_SIP; | ||
| 551 | pub const PF_OSI = AF_ISO; | ||
| 552 | pub const PF_CNT = AF_CNT; | ||
| 553 | pub const PF_LINK = AF_LINK; | ||
| 554 | pub const PF_HYLINK = AF_HYLINK; | ||
| 555 | pub const PF_MAX = AF_MAX; | ||
| 556 | pub const PF_KEY = pseudo_AF_KEY; | ||
| 557 | pub const PF_PUP = AF_PUP; | ||
| 558 | pub const PF_COIP = AF_COIP; | ||
| 559 | pub const PF_SNA = AF_SNA; | ||
| 560 | pub const PF_LOCAL = AF_LOCAL; | ||
| 561 | pub const PF_NETBIOS = AF_NETBIOS; | ||
| 562 | pub const PF_NATM = AF_NATM; | ||
| 563 | pub const PF_BLUETOOTH = AF_BLUETOOTH; | ||
| 564 | pub const PF_UNSPEC = AF_UNSPEC; | ||
| 565 | pub const PF_NETGRAPH = AF_NETGRAPH; | ||
| 566 | pub const PF_ECMA = AF_ECMA; | ||
| 567 | pub const PF_IPX = AF_IPX; | ||
| 568 | pub const PF_DLI = AF_DLI; | ||
| 569 | pub const PF_ATM = AF_ATM; | ||
| 570 | pub const PF_CCITT = AF_CCITT; | ||
| 571 | pub const PF_ISDN = AF_ISDN; | ||
| 572 | pub const PF_RTIP = pseudo_AF_RTIP; | ||
| 573 | pub const PF_LAT = AF_LAT; | ||
| 574 | pub const PF_UNIX = PF_LOCAL; | ||
| 575 | pub const PF_XTP = pseudo_AF_XTP; | ||
| 576 | pub const PF_DECnet = AF_DECnet; | ||
| 577 | |||
| 578 | pub const AF_UNSPEC = 0; | ||
| 579 | pub const AF_OSI = AF_ISO; | ||
| 580 | pub const AF_UNIX = AF_LOCAL; | ||
| 581 | pub const AF_LOCAL = 1; | ||
| 582 | pub const AF_INET = 2; | ||
| 583 | pub const AF_IMPLINK = 3; | ||
| 584 | pub const AF_PUP = 4; | ||
| 585 | pub const AF_CHAOS = 5; | ||
| 586 | pub const AF_NETBIOS = 6; | ||
| 587 | pub const AF_ISO = 7; | ||
| 588 | pub const AF_ECMA = 8; | ||
| 589 | pub const AF_DATAKIT = 9; | ||
| 590 | pub const AF_CCITT = 10; | ||
| 591 | pub const AF_SNA = 11; | ||
| 592 | pub const AF_DLI = 13; | ||
| 593 | pub const AF_LAT = 14; | ||
| 594 | pub const AF_HYLINK = 15; | ||
| 595 | pub const AF_APPLETALK = 16; | ||
| 596 | pub const AF_ROUTE = 17; | ||
| 597 | pub const AF_LINK = 18; | ||
| 598 | pub const AF_COIP = 20; | ||
| 599 | pub const AF_CNT = 21; | ||
| 600 | pub const AF_IPX = 23; | ||
| 601 | pub const AF_SIP = 24; | ||
| 602 | pub const AF_ISDN = 26; | ||
| 603 | pub const AF_NATM = 29; | ||
| 604 | pub const AF_ATM = 30; | ||
| 605 | pub const AF_NETGRAPH = 32; | ||
| 606 | pub const AF_BLUETOOTH = 33; | ||
| 607 | pub const AF_MPLS = 34; | ||
| 608 | pub const AF_MAX = 36; | ||
| 609 | |||
| 610 | pub const sa_family_t = u8; | ||
| 611 | pub const socklen_t = c_uint; | ||
| 612 | pub const sockaddr_storage = extern struct { | ||
| 613 | ss_len: u8, | ||
| 614 | ss_family: sa_family_t, | ||
| 615 | __ss_pad1: [6]u8, | ||
| 616 | __ss_align: i64, | ||
| 617 | __ss_pad2: [112]u8, | ||
| 618 | }; | ||
| 619 | pub const dl_phdr_info = extern struct { | ||
| 620 | dlpi_addr: usize, | ||
| 621 | dlpi_name: ?[*]const u8, | ||
| 622 | dlpi_phdr: [*]std.elf.Phdr, | ||
| 623 | dlpi_phnum: u16, | ||
| 624 | }; | ||
| 625 | pub const msghdr = extern struct { | ||
| 626 | msg_name: ?*c_void, | ||
| 627 | msg_namelen: socklen_t, | ||
| 628 | msg_iov: [*c]iovec, | ||
| 629 | msg_iovlen: c_int, | ||
| 630 | msg_control: ?*c_void, | ||
| 631 | msg_controllen: socklen_t, | ||
| 632 | msg_flags: c_int, | ||
| 633 | }; | ||
| 634 | pub const cmsghdr = extern struct { | ||
| 635 | cmsg_len: socklen_t, | ||
| 636 | cmsg_level: c_int, | ||
| 637 | cmsg_type: c_int, | ||
| 638 | }; | ||
| 639 | pub const cmsgcred = extern struct { | ||
| 640 | cmcred_pid: pid_t, | ||
| 641 | cmcred_uid: uid_t, | ||
| 642 | cmcred_euid: uid_t, | ||
| 643 | cmcred_gid: gid_t, | ||
| 644 | cmcred_ngroups: c_short, | ||
| 645 | cmcred_groups: [16]gid_t, | ||
| 646 | }; | ||
| 647 | pub const sf_hdtr = extern struct { | ||
| 648 | headers: [*c]iovec, | ||
| 649 | hdr_cnt: c_int, | ||
| 650 | trailers: [*c]iovec, | ||
| 651 | trl_cnt: c_int, | ||
| 652 | }; | ||
| 653 | |||
| 654 | pub const MS_SYNC = 0; | ||
| 655 | pub const MS_ASYNC = 1; | ||
| 656 | pub const MS_INVALIDATE = 2; | ||
| 657 | |||
| 658 | pub const POSIX_MADV_SEQUENTIAL = 2; | ||
| 659 | pub const POSIX_MADV_RANDOM = 1; | ||
| 660 | pub const POSIX_MADV_DONTNEED = 4; | ||
| 661 | pub const POSIX_MADV_NORMAL = 0; | ||
| 662 | pub const POSIX_MADV_WILLNEED = 3; | ||
| 663 | |||
| 664 | pub const MADV_SEQUENTIAL = 2; | ||
| 665 | pub const MADV_CONTROL_END = MADV_SETMAP; | ||
| 666 | pub const MADV_DONTNEED = 4; | ||
| 667 | pub const MADV_RANDOM = 1; | ||
| 668 | pub const MADV_WILLNEED = 3; | ||
| 669 | pub const MADV_NORMAL = 0; | ||
| 670 | pub const MADV_CONTROL_START = MADV_INVAL; | ||
| 671 | pub const MADV_FREE = 5; | ||
| 672 | pub const MADV_NOSYNC = 6; | ||
| 673 | pub const MADV_AUTOSYNC = 7; | ||
| 674 | pub const MADV_NOCORE = 8; | ||
| 675 | pub const MADV_CORE = 9; | ||
| 676 | pub const MADV_INVAL = 10; | ||
| 677 | pub const MADV_SETMAP = 11; | ||
| 678 | |||
| 679 | pub const F_DUPFD = 0; | ||
| 680 | pub const F_GETFD = 1; | ||
| 681 | pub const F_RDLCK = 1; | ||
| 682 | pub const F_SETFD = 2; | ||
| 683 | pub const F_UNLCK = 2; | ||
| 684 | pub const F_WRLCK = 3; | ||
| 685 | pub const F_GETFL = 3; | ||
| 686 | pub const F_SETFL = 4; | ||
| 687 | pub const F_GETOWN = 5; | ||
| 688 | pub const F_SETOWN = 6; | ||
| 689 | pub const F_GETLK = 7; | ||
| 690 | pub const F_SETLK = 8; | ||
| 691 | pub const F_SETLKW = 9; | ||
| 692 | pub const F_DUP2FD = 10; | ||
| 693 | pub const F_DUPFD_CLOEXEC = 17; | ||
| 694 | pub const F_DUP2FD_CLOEXEC = 18; | ||
| 695 | |||
| 696 | pub const Flock = extern struct { | ||
| 697 | l_start: off_t, | ||
| 698 | l_len: off_t, | ||
| 699 | l_pid: pid_t, | ||
| 700 | l_type: c_short, | ||
| 701 | l_whence: c_short, | ||
| 702 | }; | ||
lib/std/os/bits/freebsd.zig+4| ... | @@ -132,6 +132,10 @@ pub const dirent = extern struct { | ... | @@ -132,6 +132,10 @@ pub const dirent = extern struct { |
| 132 | d_namlen: u16, | 132 | d_namlen: u16, |
| 133 | d_pad1: u16, | 133 | d_pad1: u16, |
| 134 | d_name: [256]u8, | 134 | d_name: [256]u8, |
| 135 | |||
| 136 | pub fn reclen(self: dirent) usize { | ||
| 137 | return self.d_reclen; | ||
| 138 | } | ||
| 135 | }; | 139 | }; |
| 136 | 140 | ||
| 137 | pub const in_port_t = u16; | 141 | pub const in_port_t = u16; |
lib/std/os/bits/linux.zig+4| ... | @@ -1023,6 +1023,10 @@ pub const dirent64 = extern struct { | ... | @@ -1023,6 +1023,10 @@ pub const dirent64 = extern struct { |
| 1023 | d_reclen: u16, | 1023 | d_reclen: u16, |
| 1024 | d_type: u8, | 1024 | d_type: u8, |
| 1025 | d_name: u8, // field address is the address of first byte of name https://github.com/ziglang/zig/issues/173 | 1025 | d_name: u8, // field address is the address of first byte of name https://github.com/ziglang/zig/issues/173 |
| 1026 | |||
| 1027 | pub fn reclen(self: dirent) usize { | ||
| 1028 | return self.d_reclen; | ||
| 1029 | } | ||
| 1026 | }; | 1030 | }; |
| 1027 | 1031 | ||
| 1028 | pub const dl_phdr_info = extern struct { | 1032 | pub const dl_phdr_info = extern struct { |
lib/std/os/bits/netbsd.zig+4| ... | @@ -128,6 +128,10 @@ pub const dirent = extern struct { | ... | @@ -128,6 +128,10 @@ pub const dirent = extern struct { |
| 128 | d_type: u8, | 128 | d_type: u8, |
| 129 | d_off: i64, | 129 | d_off: i64, |
| 130 | d_name: [512]u8, | 130 | d_name: [512]u8, |
| 131 | |||
| 132 | pub fn reclen(self: dirent) usize { | ||
| 133 | return self.d_reclen; | ||
| 134 | } | ||
| 131 | }; | 135 | }; |
| 132 | 136 | ||
| 133 | pub const in_port_t = u16; | 137 | pub const in_port_t = u16; |
lib/std/os/dragonfly.zig created+3| ... | @@ -0,0 +1,3 @@ | ||
| 1 | const std = @import("../std.zig"); | ||
| 2 | pub usingnamespace std.c; | ||
| 3 | pub usingnamespace @import("bits.zig"); | ||
lib/std/os/test.zig+4| ... | @@ -16,6 +16,7 @@ const AtomicRmwOp = builtin.AtomicRmwOp; | ... | @@ -16,6 +16,7 @@ const AtomicRmwOp = builtin.AtomicRmwOp; |
| 16 | const AtomicOrder = builtin.AtomicOrder; | 16 | const AtomicOrder = builtin.AtomicOrder; |
| 17 | 17 | ||
| 18 | test "makePath, put some files in it, deleteTree" { | 18 | test "makePath, put some files in it, deleteTree" { |
| 19 | if (builtin.os == .dragonfly) return error.SkipZigTest; | ||
| 19 | try fs.makePath(a, "os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c"); | 20 | try fs.makePath(a, "os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c"); |
| 20 | try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c" ++ fs.path.sep_str ++ "file.txt", "nonsense"); | 21 | try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c" ++ fs.path.sep_str ++ "file.txt", "nonsense"); |
| 21 | try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah"); | 22 | try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah"); |
| ... | @@ -28,6 +29,7 @@ test "makePath, put some files in it, deleteTree" { | ... | @@ -28,6 +29,7 @@ test "makePath, put some files in it, deleteTree" { |
| 28 | } | 29 | } |
| 29 | 30 | ||
| 30 | test "access file" { | 31 | test "access file" { |
| 32 | if (builtin.os == .dragonfly) return error.SkipZigTest; | ||
| 31 | try fs.makePath(a, "os_test_tmp"); | 33 | try fs.makePath(a, "os_test_tmp"); |
| 32 | if (File.access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt")) |ok| { | 34 | if (File.access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt")) |ok| { |
| 33 | @panic("expected error"); | 35 | @panic("expected error"); |
| ... | @@ -95,6 +97,7 @@ test "cpu count" { | ... | @@ -95,6 +97,7 @@ test "cpu count" { |
| 95 | } | 97 | } |
| 96 | 98 | ||
| 97 | test "AtomicFile" { | 99 | test "AtomicFile" { |
| 100 | if (builtin.os == .dragonfly) return error.SkipZigTest; | ||
| 98 | var buffer: [1024]u8 = undefined; | 101 | var buffer: [1024]u8 = undefined; |
| 99 | const allocator = &std.heap.FixedBufferAllocator.init(buffer[0..]).allocator; | 102 | const allocator = &std.heap.FixedBufferAllocator.init(buffer[0..]).allocator; |
| 100 | const test_out_file = "tmp_atomic_file_test_dest.txt"; | 103 | const test_out_file = "tmp_atomic_file_test_dest.txt"; |
| ... | @@ -115,6 +118,7 @@ test "AtomicFile" { | ... | @@ -115,6 +118,7 @@ test "AtomicFile" { |
| 115 | } | 118 | } |
| 116 | 119 | ||
| 117 | test "thread local storage" { | 120 | test "thread local storage" { |
| 121 | if (builtin.os == .dragonfly) return error.SkipZigTest; | ||
| 118 | if (builtin.single_threaded) return error.SkipZigTest; | 122 | if (builtin.single_threaded) return error.SkipZigTest; |
| 119 | const thread1 = try Thread.spawn({}, testTls); | 123 | const thread1 = try Thread.spawn({}, testTls); |
| 120 | const thread2 = try Thread.spawn({}, testTls); | 124 | const thread2 = try Thread.spawn({}, testTls); |
lib/std/statically_initialized_mutex.zig+1| ... | @@ -61,6 +61,7 @@ pub const StaticallyInitializedMutex = switch (builtin.os) { | ... | @@ -61,6 +61,7 @@ pub const StaticallyInitializedMutex = switch (builtin.os) { |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | test "std.StaticallyInitializedMutex" { | 63 | test "std.StaticallyInitializedMutex" { |
| 64 | if (builtin.os == .dragonfly) return error.SkipZigTest; | ||
| 64 | const TestContext = struct { | 65 | const TestContext = struct { |
| 65 | data: i128, | 66 | data: i128, |
| 66 | 67 |
src/libc_installation.cpp+4-4| ... | @@ -320,7 +320,7 @@ Error zig_libc_cc_print_file_name(const char *o_file, Buf *out, bool want_dirnam | ... | @@ -320,7 +320,7 @@ Error zig_libc_cc_print_file_name(const char *o_file, Buf *out, bool want_dirnam |
| 320 | 320 | ||
| 321 | #undef CC_EXE | 321 | #undef CC_EXE |
| 322 | 322 | ||
| 323 | #if defined(ZIG_OS_WINDOWS) || defined(ZIG_OS_LINUX) | 323 | #if defined(ZIG_OS_WINDOWS) || defined(ZIG_OS_LINUX) || defined(ZIG_OS_DRAGONFLY) |
| 324 | static Error zig_libc_find_native_crt_dir_posix(ZigLibCInstallation *self, bool verbose) { | 324 | static Error zig_libc_find_native_crt_dir_posix(ZigLibCInstallation *self, bool verbose) { |
| 325 | return zig_libc_cc_print_file_name("crt1.o", &self->crt_dir, true, verbose); | 325 | return zig_libc_cc_print_file_name("crt1.o", &self->crt_dir, true, verbose); |
| 326 | } | 326 | } |
| ... | @@ -413,6 +413,7 @@ void zig_libc_render(ZigLibCInstallation *self, FILE *file) { | ... | @@ -413,6 +413,7 @@ void zig_libc_render(ZigLibCInstallation *self, FILE *file) { |
| 413 | "# The directory that contains `stdlib.h`.\n" | 413 | "# The directory that contains `stdlib.h`.\n" |
| 414 | "# On POSIX-like systems, include directories be found with: `cc -E -Wp,-v -xc /dev/null`\n" | 414 | "# On POSIX-like systems, include directories be found with: `cc -E -Wp,-v -xc /dev/null`\n" |
| 415 | "include_dir=%s\n" | 415 | "include_dir=%s\n" |
| 416 | "\n" | ||
| 416 | "# The system-specific include directory. May be the same as `include_dir`.\n" | 417 | "# The system-specific include directory. May be the same as `include_dir`.\n" |
| 417 | "# On Windows it's the directory that includes `vcruntime.h`.\n" | 418 | "# On Windows it's the directory that includes `vcruntime.h`.\n" |
| 418 | "# On POSIX it's the directory that includes `sys/errno.h`.\n" | 419 | "# On POSIX it's the directory that includes `sys/errno.h`.\n" |
| ... | @@ -435,8 +436,7 @@ void zig_libc_render(ZigLibCInstallation *self, FILE *file) { | ... | @@ -435,8 +436,7 @@ void zig_libc_render(ZigLibCInstallation *self, FILE *file) { |
| 435 | "# The directory that contains `kernel32.lib`.\n" | 436 | "# The directory that contains `kernel32.lib`.\n" |
| 436 | "# Only needed when targeting MSVC on Windows.\n" | 437 | "# Only needed when targeting MSVC on Windows.\n" |
| 437 | "kernel32_lib_dir=%s\n" | 438 | "kernel32_lib_dir=%s\n" |
| 438 | "\n" | 439 | "\n", |
| 439 | , | ||
| 440 | buf_ptr(&self->include_dir), | 440 | buf_ptr(&self->include_dir), |
| 441 | buf_ptr(&self->sys_include_dir), | 441 | buf_ptr(&self->sys_include_dir), |
| 442 | buf_ptr(&self->crt_dir), | 442 | buf_ptr(&self->crt_dir), |
| ... | @@ -489,7 +489,7 @@ Error zig_libc_find_native(ZigLibCInstallation *self, bool verbose) { | ... | @@ -489,7 +489,7 @@ Error zig_libc_find_native(ZigLibCInstallation *self, bool verbose) { |
| 489 | return err; | 489 | return err; |
| 490 | #if defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) | 490 | #if defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) |
| 491 | buf_init_from_str(&self->crt_dir, "/usr/lib"); | 491 | buf_init_from_str(&self->crt_dir, "/usr/lib"); |
| 492 | #elif defined(ZIG_OS_LINUX) | 492 | #elif defined(ZIG_OS_LINUX) || defined(ZIG_OS_DRAGONFLY) |
| 493 | if ((err = zig_libc_find_native_crt_dir_posix(self, verbose))) | 493 | if ((err = zig_libc_find_native_crt_dir_posix(self, verbose))) |
| 494 | return err; | 494 | return err; |
| 495 | #endif | 495 | #endif |
src/link.cpp-16| ... | @@ -1792,28 +1792,12 @@ static void construct_linker_job_elf(LinkJob *lj) { | ... | @@ -1792,28 +1792,12 @@ static void construct_linker_job_elf(LinkJob *lj) { |
| 1792 | if (g->libc != nullptr) { | 1792 | if (g->libc != nullptr) { |
| 1793 | if (!g->have_dynamic_link) { | 1793 | if (!g->have_dynamic_link) { |
| 1794 | lj->args.append("--start-group"); | 1794 | lj->args.append("--start-group"); |
| 1795 | if (!target_is_android(g->zig_target)) { | ||
| 1796 | lj->args.append("-lgcc"); | ||
| 1797 | lj->args.append("-lgcc_eh"); | ||
| 1798 | } | ||
| 1799 | lj->args.append("-lc"); | 1795 | lj->args.append("-lc"); |
| 1800 | lj->args.append("-lm"); | 1796 | lj->args.append("-lm"); |
| 1801 | lj->args.append("--end-group"); | 1797 | lj->args.append("--end-group"); |
| 1802 | } else { | 1798 | } else { |
| 1803 | if (!target_is_android(g->zig_target)) { | ||
| 1804 | lj->args.append("-lgcc"); | ||
| 1805 | lj->args.append("--as-needed"); | ||
| 1806 | lj->args.append("-lgcc_s"); | ||
| 1807 | lj->args.append("--no-as-needed"); | ||
| 1808 | } | ||
| 1809 | lj->args.append("-lc"); | 1799 | lj->args.append("-lc"); |
| 1810 | lj->args.append("-lm"); | 1800 | lj->args.append("-lm"); |
| 1811 | if (!target_is_android(g->zig_target)) { | ||
| 1812 | lj->args.append("-lgcc"); | ||
| 1813 | lj->args.append("--as-needed"); | ||
| 1814 | lj->args.append("-lgcc_s"); | ||
| 1815 | lj->args.append("--no-as-needed"); | ||
| 1816 | } | ||
| 1817 | } | 1801 | } |
| 1818 | 1802 | ||
| 1819 | if (g->zig_target->os == OsFreeBSD) { | 1803 | if (g->zig_target->os == OsFreeBSD) { |
src/os.cpp+6-6| ... | @@ -52,7 +52,7 @@ typedef SSIZE_T ssize_t; | ... | @@ -52,7 +52,7 @@ typedef SSIZE_T ssize_t; |
| 52 | 52 | ||
| 53 | #endif | 53 | #endif |
| 54 | 54 | ||
| 55 | #if defined(ZIG_OS_LINUX) || defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) | 55 | #if defined(ZIG_OS_LINUX) || defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) || defined(ZIG_OS_DRAGONFLY) |
| 56 | #include <link.h> | 56 | #include <link.h> |
| 57 | #endif | 57 | #endif |
| 58 | 58 | ||
| ... | @@ -60,7 +60,7 @@ typedef SSIZE_T ssize_t; | ... | @@ -60,7 +60,7 @@ typedef SSIZE_T ssize_t; |
| 60 | #include <sys/auxv.h> | 60 | #include <sys/auxv.h> |
| 61 | #endif | 61 | #endif |
| 62 | 62 | ||
| 63 | #if defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) | 63 | #if defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) || defined(ZIG_OS_DRAGONFLY) |
| 64 | #include <sys/sysctl.h> | 64 | #include <sys/sysctl.h> |
| 65 | #endif | 65 | #endif |
| 66 | 66 | ||
| ... | @@ -85,7 +85,7 @@ static clock_serv_t macos_monotonic_clock; | ... | @@ -85,7 +85,7 @@ static clock_serv_t macos_monotonic_clock; |
| 85 | #if defined(__APPLE__) && !defined(environ) | 85 | #if defined(__APPLE__) && !defined(environ) |
| 86 | #include <crt_externs.h> | 86 | #include <crt_externs.h> |
| 87 | #define environ (*_NSGetEnviron()) | 87 | #define environ (*_NSGetEnviron()) |
| 88 | #elif defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) | 88 | #elif defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) || defined(ZIG_OS_DRAGONFLY) |
| 89 | extern char **environ; | 89 | extern char **environ; |
| 90 | #endif | 90 | #endif |
| 91 | 91 | ||
| ... | @@ -1450,7 +1450,7 @@ Error os_self_exe_path(Buf *out_path) { | ... | @@ -1450,7 +1450,7 @@ Error os_self_exe_path(Buf *out_path) { |
| 1450 | } | 1450 | } |
| 1451 | buf_resize(out_path, amt); | 1451 | buf_resize(out_path, amt); |
| 1452 | return ErrorNone; | 1452 | return ErrorNone; |
| 1453 | #elif defined(ZIG_OS_FREEBSD) | 1453 | #elif defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_DRAGONFLY) |
| 1454 | buf_resize(out_path, PATH_MAX); | 1454 | buf_resize(out_path, PATH_MAX); |
| 1455 | int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; | 1455 | int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; |
| 1456 | size_t cb = PATH_MAX; | 1456 | size_t cb = PATH_MAX; |
| ... | @@ -1792,7 +1792,7 @@ Error os_get_app_data_dir(Buf *out_path, const char *appname) { | ... | @@ -1792,7 +1792,7 @@ Error os_get_app_data_dir(Buf *out_path, const char *appname) { |
| 1792 | } | 1792 | } |
| 1793 | 1793 | ||
| 1794 | 1794 | ||
| 1795 | #if defined(ZIG_OS_LINUX) || defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) | 1795 | #if defined(ZIG_OS_LINUX) || defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) || defined(ZIG_OS_DRAGONFLY) |
| 1796 | static int self_exe_shared_libs_callback(struct dl_phdr_info *info, size_t size, void *data) { | 1796 | static int self_exe_shared_libs_callback(struct dl_phdr_info *info, size_t size, void *data) { |
| 1797 | ZigList<Buf *> *libs = reinterpret_cast< ZigList<Buf *> *>(data); | 1797 | ZigList<Buf *> *libs = reinterpret_cast< ZigList<Buf *> *>(data); |
| 1798 | if (info->dlpi_name[0] == '/') { | 1798 | if (info->dlpi_name[0] == '/') { |
| ... | @@ -1803,7 +1803,7 @@ static int self_exe_shared_libs_callback(struct dl_phdr_info *info, size_t size, | ... | @@ -1803,7 +1803,7 @@ static int self_exe_shared_libs_callback(struct dl_phdr_info *info, size_t size, |
| 1803 | #endif | 1803 | #endif |
| 1804 | 1804 | ||
| 1805 | Error os_self_exe_shared_libs(ZigList<Buf *> &paths) { | 1805 | Error os_self_exe_shared_libs(ZigList<Buf *> &paths) { |
| 1806 | #if defined(ZIG_OS_LINUX) || defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) | 1806 | #if defined(ZIG_OS_LINUX) || defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) || defined(ZIG_OS_DRAGONFLY) |
| 1807 | paths.resize(0); | 1807 | paths.resize(0); |
| 1808 | dl_iterate_phdr(self_exe_shared_libs_callback, &paths); | 1808 | dl_iterate_phdr(self_exe_shared_libs_callback, &paths); |
| 1809 | return ErrorNone; | 1809 | return ErrorNone; |
src/os.hpp+2| ... | @@ -27,6 +27,8 @@ | ... | @@ -27,6 +27,8 @@ |
| 27 | #define ZIG_OS_FREEBSD | 27 | #define ZIG_OS_FREEBSD |
| 28 | #elif defined(__NetBSD__) | 28 | #elif defined(__NetBSD__) |
| 29 | #define ZIG_OS_NETBSD | 29 | #define ZIG_OS_NETBSD |
| 30 | #elif defined(__DragonFly__) | ||
| 31 | #define ZIG_OS_DRAGONFLY | ||
| 30 | #else | 32 | #else |
| 31 | #define ZIG_OS_UNKNOWN | 33 | #define ZIG_OS_UNKNOWN |
| 32 | #endif | 34 | #endif |
src/target.cpp+5-4| ... | @@ -1050,6 +1050,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { | ... | @@ -1050,6 +1050,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { |
| 1050 | case OsZen: | 1050 | case OsZen: |
| 1051 | case OsFreeBSD: | 1051 | case OsFreeBSD: |
| 1052 | case OsNetBSD: | 1052 | case OsNetBSD: |
| 1053 | case OsDragonFly: | ||
| 1053 | case OsOpenBSD: | 1054 | case OsOpenBSD: |
| 1054 | case OsWASI: | 1055 | case OsWASI: |
| 1055 | case OsEmscripten: | 1056 | case OsEmscripten: |
| ... | @@ -1104,7 +1105,6 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { | ... | @@ -1104,7 +1105,6 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { |
| 1104 | } | 1105 | } |
| 1105 | case OsAnanas: | 1106 | case OsAnanas: |
| 1106 | case OsCloudABI: | 1107 | case OsCloudABI: |
| 1107 | case OsDragonFly: | ||
| 1108 | case OsKFreeBSD: | 1108 | case OsKFreeBSD: |
| 1109 | case OsLv2: | 1109 | case OsLv2: |
| 1110 | case OsSolaris: | 1110 | case OsSolaris: |
| ... | @@ -1267,6 +1267,8 @@ const char *target_dynamic_linker(const ZigTarget *target) { | ... | @@ -1267,6 +1267,8 @@ const char *target_dynamic_linker(const ZigTarget *target) { |
| 1267 | return "/libexec/ld-elf.so.1"; | 1267 | return "/libexec/ld-elf.so.1"; |
| 1268 | case OsNetBSD: | 1268 | case OsNetBSD: |
| 1269 | return "/libexec/ld.elf_so"; | 1269 | return "/libexec/ld.elf_so"; |
| 1270 | case OsDragonFly: | ||
| 1271 | return "/libexec/ld-elf.so.2"; | ||
| 1270 | case OsLinux: { | 1272 | case OsLinux: { |
| 1271 | const ZigLLVM_EnvironmentType abi = target->abi; | 1273 | const ZigLLVM_EnvironmentType abi = target->abi; |
| 1272 | switch (target->arch) { | 1274 | switch (target->arch) { |
| ... | @@ -1383,7 +1385,6 @@ const char *target_dynamic_linker(const ZigTarget *target) { | ... | @@ -1383,7 +1385,6 @@ const char *target_dynamic_linker(const ZigTarget *target) { |
| 1383 | 1385 | ||
| 1384 | case OsAnanas: | 1386 | case OsAnanas: |
| 1385 | case OsCloudABI: | 1387 | case OsCloudABI: |
| 1386 | case OsDragonFly: | ||
| 1387 | case OsFuchsia: | 1388 | case OsFuchsia: |
| 1388 | case OsKFreeBSD: | 1389 | case OsKFreeBSD: |
| 1389 | case OsLv2: | 1390 | case OsLv2: |
| ... | @@ -1579,7 +1580,7 @@ bool target_os_requires_libc(Os os) { | ... | @@ -1579,7 +1580,7 @@ bool target_os_requires_libc(Os os) { |
| 1579 | // On Darwin, we always link libSystem which contains libc. | 1580 | // On Darwin, we always link libSystem which contains libc. |
| 1580 | // Similarly on FreeBSD and NetBSD we always link system libc | 1581 | // Similarly on FreeBSD and NetBSD we always link system libc |
| 1581 | // since this is the stable syscall interface. | 1582 | // since this is the stable syscall interface. |
| 1582 | return (target_os_is_darwin(os) || os == OsFreeBSD || os == OsNetBSD); | 1583 | return (target_os_is_darwin(os) || os == OsFreeBSD || os == OsNetBSD || os == OsDragonFly); |
| 1583 | } | 1584 | } |
| 1584 | 1585 | ||
| 1585 | bool target_supports_fpic(const ZigTarget *target) { | 1586 | bool target_supports_fpic(const ZigTarget *target) { |
| ... | @@ -1636,7 +1637,6 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) { | ... | @@ -1636,7 +1637,6 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) { |
| 1636 | case OsFreestanding: | 1637 | case OsFreestanding: |
| 1637 | case OsAnanas: | 1638 | case OsAnanas: |
| 1638 | case OsCloudABI: | 1639 | case OsCloudABI: |
| 1639 | case OsDragonFly: | ||
| 1640 | case OsLv2: | 1640 | case OsLv2: |
| 1641 | case OsSolaris: | 1641 | case OsSolaris: |
| 1642 | case OsHaiku: | 1642 | case OsHaiku: |
| ... | @@ -1665,6 +1665,7 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) { | ... | @@ -1665,6 +1665,7 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) { |
| 1665 | case OsFuchsia: | 1665 | case OsFuchsia: |
| 1666 | case OsKFreeBSD: | 1666 | case OsKFreeBSD: |
| 1667 | case OsNetBSD: | 1667 | case OsNetBSD: |
| 1668 | case OsDragonFly: | ||
| 1668 | case OsHurd: | 1669 | case OsHurd: |
| 1669 | return ZigLLVM_GNU; | 1670 | return ZigLLVM_GNU; |
| 1670 | case OsUefi: | 1671 | case OsUefi: |
test/stage1/behavior/byteswap.zig+2| ... | @@ -1,5 +1,6 @@ | ... | @@ -1,5 +1,6 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const expect = std.testing.expect; | 2 | const expect = std.testing.expect; |
| 3 | const builtin = @import("builtin"); | ||
| 3 | 4 | ||
| 4 | test "@byteSwap integers" { | 5 | test "@byteSwap integers" { |
| 5 | const ByteSwapIntTest = struct { | 6 | const ByteSwapIntTest = struct { |
| ... | @@ -40,6 +41,7 @@ test "@byteSwap integers" { | ... | @@ -40,6 +41,7 @@ test "@byteSwap integers" { |
| 40 | 41 | ||
| 41 | test "@byteSwap vectors" { | 42 | test "@byteSwap vectors" { |
| 42 | // Disabled because of #3317 | 43 | // Disabled because of #3317 |
| 44 | if (builtin.os == .dragonfly) return error.SkipZigTest; | ||
| 43 | if (@import("builtin").arch == .mipsel) return error.SkipZigTest; | 45 | if (@import("builtin").arch == .mipsel) return error.SkipZigTest; |
| 44 | 46 | ||
| 45 | const ByteSwapVectorTest = struct { | 47 | const ByteSwapVectorTest = struct { |
test/stage1/behavior/vector.zig+2| ... | @@ -1,6 +1,7 @@ | ... | @@ -1,6 +1,7 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const mem = std.mem; | 2 | const mem = std.mem; |
| 3 | const expect = std.testing.expect; | 3 | const expect = std.testing.expect; |
| 4 | const builtin = @import("builtin"); | ||
| 4 | 5 | ||
| 5 | test "implicit cast vector to array - bool" { | 6 | test "implicit cast vector to array - bool" { |
| 6 | const S = struct { | 7 | const S = struct { |
| ... | @@ -111,6 +112,7 @@ test "array to vector" { | ... | @@ -111,6 +112,7 @@ test "array to vector" { |
| 111 | } | 112 | } |
| 112 | 113 | ||
| 113 | test "vector casts of sizes not divisable by 8" { | 114 | test "vector casts of sizes not divisable by 8" { |
| 115 | if (builtin.os == .dragonfly) return error.SkipZigTest; | ||
| 114 | const S = struct { | 116 | const S = struct { |
| 115 | fn doTheTest() void { | 117 | fn doTheTest() void { |
| 116 | { | 118 | { |