authorgravatar for 1@tse.gratisTse <1@tse.gratis> 2019-10-23 01:06:35+03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-30 21:21:58-04:00
log33cc2044811e41a74e3112fc0abcc5dc6fd34836
tree380b8a0e296e32fae4415035338ec268c1a1beaf
parent7c7350345147c61e3e0873c3c4f233e351a3910a

DragonFlyBSD support


30 files changed, 807 insertions(+), 57 deletions(-)

lib/std/atomic/queue.zig+1
......@@ -152,6 +152,7 @@ const puts_per_thread = 500;
152152const put_thread_count = 3;
153153
154154test "std.atomic.Queue" {
155 if (builtin.os == .dragonfly) return error.SkipZigTest;
155156 var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024);
156157 defer std.heap.direct_allocator.free(plenty_of_memory);
157158
lib/std/atomic/stack.zig+1
......@@ -86,6 +86,7 @@ const puts_per_thread = 500;
8686const put_thread_count = 3;
8787
8888test "std.atomic.stack" {
89 if (builtin.os == .dragonfly) return error.SkipZigTest;
8990 var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024);
9091 defer std.heap.direct_allocator.free(plenty_of_memory);
9192
lib/std/c.zig+1
......@@ -10,6 +10,7 @@ pub usingnamespace switch (builtin.os) {
1010 .macosx, .ios, .tvos, .watchos => @import("c/darwin.zig"),
1111 .freebsd => @import("c/freebsd.zig"),
1212 .netbsd => @import("c/netbsd.zig"),
13 .dragonfly => @import("c/dragonfly.zig"),
1314 else => struct {},
1415};
1516
lib/std/c/dragonfly.zig created+14
......@@ -0,0 +1,14 @@
1const std = @import("../std.zig");
2usingnamespace std.c;
3
4extern "c" threadlocal var errno: c_int;
5pub fn _errno() *c_int {
6 return &errno;
7}
8
9pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize;
10pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
11pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize;
12
13pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int;
14pub 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) {
12721272 sect_contribs: []pdb.SectionContribEntry,
12731273 modules: []Module,
12741274 },
1275 .linux, .freebsd, .netbsd => DwarfInfo,
1275 .linux, .freebsd, .netbsd, .dragonfly => DwarfInfo,
12761276 else => @compileError("Unsupported OS"),
12771277};
12781278
lib/std/event/channel.zig+1
......@@ -304,6 +304,7 @@ pub fn Channel(comptime T: type) type {
304304}
305305
306306test "std.event.Channel" {
307 if (builtin.os == .dragonfly) return error.SkipZigTest;
307308 // https://github.com/ziglang/zig/issues/1908
308309 if (builtin.single_threaded) return error.SkipZigTest;
309310 // 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
9292 .linux,
9393 .freebsd,
9494 .netbsd,
95 .dragonfly,
9596 => {
9697 const iovecs = try loop.allocator.alloc(os.iovec_const, data.len);
9798 defer loop.allocator.free(iovecs);
......@@ -248,6 +249,7 @@ pub fn preadv(loop: *Loop, fd: fd_t, data: []const []u8, offset: usize) PReadVEr
248249 .linux,
249250 .freebsd,
250251 .netbsd,
252 .dragonfly,
251253 => {
252254 const iovecs = try loop.allocator.alloc(os.iovec, data.len);
253255 defer loop.allocator.free(iovecs);
......@@ -412,7 +414,7 @@ pub fn openPosix(
412414
413415pub fn openRead(loop: *Loop, path: []const u8) File.OpenError!fd_t {
414416 switch (builtin.os) {
415 .macosx, .linux, .freebsd, .netbsd => {
417 .macosx, .linux, .freebsd, .netbsd, .dragonfly => {
416418 const flags = os.O_LARGEFILE | os.O_RDONLY | os.O_CLOEXEC;
417419 return openPosix(loop, path, flags, File.default_mode);
418420 },
......@@ -444,6 +446,7 @@ pub fn openWriteMode(loop: *Loop, path: []const u8, mode: File.Mode) File.OpenEr
444446 .linux,
445447 .freebsd,
446448 .netbsd,
449 .dragonfly,
447450 => {
448451 const flags = os.O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_TRUNC;
449452 return openPosix(loop, path, flags, File.default_mode);
......@@ -468,7 +471,7 @@ pub fn openReadWrite(
468471 mode: File.Mode,
469472) File.OpenError!fd_t {
470473 switch (builtin.os) {
471 .macosx, .linux, .freebsd, .netbsd => {
474 .macosx, .linux, .freebsd, .netbsd, .dragonfly => {
472475 const flags = os.O_LARGEFILE | os.O_RDWR | os.O_CREAT | os.O_CLOEXEC;
473476 return openPosix(loop, path, flags, mode);
474477 },
......@@ -498,7 +501,7 @@ pub const CloseOperation = struct {
498501 os_data: OsData,
499502
500503 const OsData = switch (builtin.os) {
501 .linux, .macosx, .freebsd, .netbsd => OsDataPosix,
504 .linux, .macosx, .freebsd, .netbsd, .dragonfly => OsDataPosix,
502505
503506 .windows => struct {
504507 handle: ?fd_t,
......@@ -517,7 +520,7 @@ pub const CloseOperation = struct {
517520 self.* = CloseOperation{
518521 .loop = loop,
519522 .os_data = switch (builtin.os) {
520 .linux, .macosx, .freebsd, .netbsd => initOsDataPosix(self),
523 .linux, .macosx, .freebsd, .netbsd, .dragonfly => initOsDataPosix(self),
521524 .windows => OsData{ .handle = null },
522525 else => @compileError("Unsupported OS"),
523526 },
......@@ -548,6 +551,7 @@ pub const CloseOperation = struct {
548551 .macosx,
549552 .freebsd,
550553 .netbsd,
554 .dragonfly,
551555 => {
552556 if (self.os_data.have_fd) {
553557 self.loop.posixFsRequest(&self.os_data.close_req_node);
......@@ -571,6 +575,7 @@ pub const CloseOperation = struct {
571575 .macosx,
572576 .freebsd,
573577 .netbsd,
578 .dragonfly,
574579 => {
575580 self.os_data.close_req_node.data.msg.Close.fd = handle;
576581 self.os_data.have_fd = true;
......@@ -589,6 +594,7 @@ pub const CloseOperation = struct {
589594 .macosx,
590595 .freebsd,
591596 .netbsd,
597 .dragonfly,
592598 => {
593599 self.os_data.have_fd = false;
594600 },
......@@ -605,6 +611,7 @@ pub const CloseOperation = struct {
605611 .macosx,
606612 .freebsd,
607613 .netbsd,
614 .dragonfly,
608615 => {
609616 assert(self.os_data.have_fd);
610617 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:
630637 .macosx,
631638 .freebsd,
632639 .netbsd,
640 .dragonfly,
633641 => return writeFileModeThread(loop, path, contents, mode),
634642 .windows => return writeFileWindows(loop, path, contents),
635643 else => @compileError("Unsupported OS"),
......@@ -742,7 +750,7 @@ fn hashString(s: []const u16) u32 {
742750// os_data: OsData,
743751//
744752// const OsData = switch (builtin.os) {
745// .macosx, .freebsd, .netbsd => struct {
753// .macosx, .freebsd, .netbsd, .dragonfly => struct {
746754// file_table: FileTable,
747755// table_lock: event.Lock,
748756//
......@@ -831,7 +839,7 @@ fn hashString(s: []const u16) u32 {
831839// return self;
832840// },
833841//
834// .macosx, .freebsd, .netbsd => {
842// .macosx, .freebsd, .netbsd, .dragonfly => {
835843// const self = try loop.allocator.create(Self);
836844// errdefer loop.allocator.destroy(self);
837845//
......@@ -851,7 +859,7 @@ fn hashString(s: []const u16) u32 {
851859// /// All addFile calls and removeFile calls must have completed.
852860// pub fn destroy(self: *Self) void {
853861// switch (builtin.os) {
854// .macosx, .freebsd, .netbsd => {
862// .macosx, .freebsd, .netbsd, .dragonfly => {
855863// // TODO we need to cancel the frames before destroying the lock
856864// self.os_data.table_lock.deinit();
857865// var it = self.os_data.file_table.iterator();
......@@ -893,7 +901,7 @@ fn hashString(s: []const u16) u32 {
893901//
894902// pub async fn addFile(self: *Self, file_path: []const u8, value: V) !?V {
895903// 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),
897905// .linux => return await (async addFileLinux(self, file_path, value) catch unreachable),
898906// .windows => return await (async addFileWindows(self, file_path, value) catch unreachable),
899907// else => @compileError("Unsupported OS"),
lib/std/event/group.zig+1
......@@ -81,6 +81,7 @@ pub fn Group(comptime ReturnType: type) type {
8181}
8282
8383test "std.event.Group" {
84 if (builtin.os == .dragonfly) return error.SkipZigTest;
8485 // https://github.com/ziglang/zig/issues/1908
8586 if (builtin.single_threaded) return error.SkipZigTest;
8687
lib/std/event/lock.zig+1
......@@ -116,6 +116,7 @@ pub const Lock = struct {
116116};
117117
118118test "std.event.Lock" {
119 if (builtin.os == .dragonfly) return error.SkipZigTest;
119120 // TODO https://github.com/ziglang/zig/issues/1908
120121 if (builtin.single_threaded) return error.SkipZigTest;
121122 // TODO https://github.com/ziglang/zig/issues/3251
lib/std/event/loop.zig+11-10
......@@ -51,7 +51,7 @@ pub const Loop = struct {
5151 };
5252
5353 pub const EventFd = switch (builtin.os) {
54 .macosx, .freebsd, .netbsd => KEventFd,
54 .macosx, .freebsd, .netbsd, .dragonfly => KEventFd,
5555 .linux => struct {
5656 base: ResumeNode,
5757 epoll_op: u32,
......@@ -70,7 +70,7 @@ pub const Loop = struct {
7070 };
7171
7272 pub const Basic = switch (builtin.os) {
73 .macosx, .freebsd, .netbsd => KEventBasic,
73 .macosx, .freebsd, .netbsd, .dragonfly => KEventBasic,
7474 .linux => struct {
7575 base: ResumeNode,
7676 },
......@@ -244,7 +244,7 @@ pub const Loop = struct {
244244 self.extra_threads[extra_thread_index] = try Thread.spawn(self, workerRun);
245245 }
246246 },
247 .macosx, .freebsd, .netbsd => {
247 .macosx, .freebsd, .netbsd, .dragonfly => {
248248 self.os_data.kqfd = try os.kqueue();
249249 errdefer os.close(self.os_data.kqfd);
250250
......@@ -409,7 +409,7 @@ pub const Loop = struct {
409409 os.close(self.os_data.epollfd);
410410 self.allocator.free(self.eventfd_resume_nodes);
411411 },
412 .macosx, .freebsd, .netbsd => {
412 .macosx, .freebsd, .netbsd, .dragonfly => {
413413 os.close(self.os_data.kqfd);
414414 os.close(self.os_data.fs_kqfd);
415415 },
......@@ -523,7 +523,7 @@ pub const Loop = struct {
523523 const eventfd_node = &resume_stack_node.data;
524524 eventfd_node.base.handle = next_tick_node.data;
525525 switch (builtin.os) {
526 .macosx, .freebsd, .netbsd => {
526 .macosx, .freebsd, .netbsd, .dragonfly => {
527527 const kevent_array = (*const [1]os.Kevent)(&eventfd_node.kevent);
528528 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];
529529 _ = os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null) catch {
......@@ -587,6 +587,7 @@ pub const Loop = struct {
587587 .macosx,
588588 .freebsd,
589589 .netbsd,
590 .dragonfly,
590591 => self.os_data.fs_thread.wait(),
591592 else => {},
592593 }
......@@ -644,7 +645,7 @@ pub const Loop = struct {
644645 os.write(self.os_data.final_eventfd, wakeup_bytes) catch unreachable;
645646 return;
646647 },
647 .macosx, .freebsd, .netbsd => {
648 .macosx, .freebsd, .netbsd, .dragonfly => {
648649 self.posixFsRequest(&self.os_data.fs_end_request);
649650 const final_kevent = (*const [1]os.Kevent)(&self.os_data.final_kevent);
650651 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];
......@@ -702,7 +703,7 @@ pub const Loop = struct {
702703 }
703704 }
704705 },
705 .macosx, .freebsd, .netbsd => {
706 .macosx, .freebsd, .netbsd, .dragonfly => {
706707 var eventlist: [1]os.Kevent = undefined;
707708 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];
708709 const count = os.kevent(self.os_data.kqfd, empty_kevs, eventlist[0..], null) catch unreachable;
......@@ -765,7 +766,7 @@ pub const Loop = struct {
765766 self.beginOneEvent(); // finished in posixFsRun after processing the msg
766767 self.os_data.fs_queue.put(request_node);
767768 switch (builtin.os) {
768 .macosx, .freebsd, .netbsd => {
769 .macosx, .freebsd, .netbsd, .dragonfly => {
769770 const fs_kevs = (*const [1]os.Kevent)(&self.os_data.fs_kevent_wake);
770771 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];
771772 _ = os.kevent(self.os_data.fs_kqfd, fs_kevs, empty_kevs, null) catch unreachable;
......@@ -838,7 +839,7 @@ pub const Loop = struct {
838839 else => unreachable,
839840 }
840841 },
841 .macosx, .freebsd, .netbsd => {
842 .macosx, .freebsd, .netbsd, .dragonfly => {
842843 const fs_kevs = (*const [1]os.Kevent)(&self.os_data.fs_kevent_wait);
843844 var out_kevs: [1]os.Kevent = undefined;
844845 _ = os.kevent(self.os_data.fs_kqfd, fs_kevs, out_kevs[0..], null) catch unreachable;
......@@ -850,7 +851,7 @@ pub const Loop = struct {
850851
851852 const OsData = switch (builtin.os) {
852853 .linux => LinuxOsData,
853 .macosx, .freebsd, .netbsd => KEventData,
854 .macosx, .freebsd, .netbsd, .dragonfly => KEventData,
854855 .windows => struct {
855856 io_port: windows.HANDLE,
856857 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
2828/// All file system operations which return a path are guaranteed to
2929/// fit into a UTF-8 encoded array of this length.
3030pub 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,
3232 // Each UTF-16LE character may be expanded to 3 UTF-8 bytes.
3333 // If it would require 4 UTF-8 bytes, then there would be a surrogate
3434 // pair in the UTF-16LE, and we (over)account 3 bytes for it that way.
......@@ -380,7 +380,7 @@ pub const Dir = struct {
380380 const IteratorError = error{AccessDenied} || os.UnexpectedError;
381381
382382 pub const Iterator = switch (builtin.os) {
383 .macosx, .ios, .freebsd, .netbsd => struct {
383 .macosx, .ios, .freebsd, .netbsd, .dragonfly => struct {
384384 dir: Dir,
385385 seek: i64,
386386 buf: [8192]u8, // TODO align(@alignOf(os.dirent)),
......@@ -396,7 +396,7 @@ pub const Dir = struct {
396396 pub fn next(self: *Self) Error!?Entry {
397397 switch (builtin.os) {
398398 .macosx, .ios => return self.nextDarwin(),
399 .freebsd, .netbsd => return self.nextBsd(),
399 .freebsd, .netbsd, .dragonfly => return self.nextBsd(),
400400 else => @compileError("unimplemented"),
401401 }
402402 }
......@@ -630,7 +630,7 @@ pub const Dir = struct {
630630
631631 pub fn iterate(self: Dir) Iterator {
632632 switch (builtin.os) {
633 .macosx, .ios, .freebsd, .netbsd => return Iterator{
633 .macosx, .ios, .freebsd, .netbsd, .dragonfly => return Iterator{
634634 .dir = self,
635635 .seek = 0,
636636 .index = 0,
......@@ -1162,7 +1162,7 @@ pub fn openSelfExe() OpenSelfExeError!File {
11621162
11631163test "openSelfExe" {
11641164 switch (builtin.os) {
1165 .linux, .macosx, .ios, .windows, .freebsd => (try openSelfExe()).close(),
1165 .linux, .macosx, .ios, .windows, .freebsd, .dragonfly => (try openSelfExe()).close(),
11661166 else => return error.SkipZigTest, // Unsupported OS.
11671167 }
11681168}
......@@ -1188,7 +1188,7 @@ pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) SelfExePathError![]u8 {
11881188 }
11891189 switch (builtin.os) {
11901190 .linux => return os.readlinkC(c"/proc/self/exe", out_buffer),
1191 .freebsd => {
1191 .freebsd, .dragonfly => {
11921192 var mib = [4]c_int{ os.CTL_KERN, os.KERN_PROC, os.KERN_PROC_PATHNAME, -1 };
11931193 var out_len: usize = out_buffer.len;
11941194 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
4444 };
4545 return fs.path.join(allocator, [_][]const u8{ home_dir, "Library", "Application Support", appname });
4646 },
47 .linux, .freebsd, .netbsd => {
47 .linux, .freebsd, .netbsd, .dragonfly => {
4848 const home_dir = os.getenv("HOME") orelse {
4949 // TODO look in /etc/passwd
5050 return error.AppDataDirUnavailable;
lib/std/mutex.zig+1
......@@ -130,6 +130,7 @@ const TestContext = struct {
130130};
131131
132132test "std.Mutex" {
133 if (builtin.os == .dragonfly) return error.SkipZigTest;
133134 var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024);
134135 defer std.heap.direct_allocator.free(plenty_of_memory);
135136
lib/std/os.zig+3-1
......@@ -24,9 +24,10 @@ const dl = @import("dynamic_library.zig");
2424const MAX_PATH_BYTES = std.fs.MAX_PATH_BYTES;
2525
2626pub const darwin = @import("os/darwin.zig");
27pub const dragonfly = @import("os/dragonfly.zig");
2728pub const freebsd = @import("os/freebsd.zig");
28pub const linux = @import("os/linux.zig");
2929pub const netbsd = @import("os/netbsd.zig");
30pub const linux = @import("os/linux.zig");
3031pub const uefi = @import("os/uefi.zig");
3132pub const wasi = @import("os/wasi.zig");
3233pub const windows = @import("os/windows.zig");
......@@ -55,6 +56,7 @@ pub const system = if (builtin.link_libc) std.c else switch (builtin.os) {
5556 .freebsd => freebsd,
5657 .linux => linux,
5758 .netbsd => netbsd,
59 .dragonfly => dragonfly,
5860 .wasi => wasi,
5961 .windows => windows,
6062 .zen => zen,
lib/std/os/bits.zig+1
......@@ -5,6 +5,7 @@ const builtin = @import("builtin");
55
66pub usingnamespace switch (builtin.os) {
77 .macosx, .ios, .tvos, .watchos => @import("bits/darwin.zig"),
8 .dragonfly => @import("bits/dragonfly.zig"),
89 .freebsd => @import("bits/freebsd.zig"),
910 .linux => @import("bits/linux.zig"),
1011 .netbsd => @import("bits/netbsd.zig"),
lib/std/os/bits/darwin.zig+4
......@@ -119,6 +119,10 @@ pub const dirent = extern struct {
119119 d_namlen: u16,
120120 d_type: u8,
121121 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 }
122126};
123127
124128pub const pthread_attr_t = extern struct {
lib/std/os/bits/dragonfly.zig created+702
......@@ -0,0 +1,702 @@
1const std = @import("../../std.zig");
2const maxInt = std.math.maxInt;
3
4pub fn S_ISCHR(m: u32) bool {
5 return m & S_IFMT == S_IFCHR;
6}
7pub const fd_t = c_int;
8pub const pid_t = c_int;
9pub const off_t = c_long;
10
11pub const ENOTSUP = EOPNOTSUPP;
12pub const EWOULDBLOCK = EAGAIN;
13pub const EPERM = 1;
14pub const ENOENT = 2;
15pub const ESRCH = 3;
16pub const EINTR = 4;
17pub const EIO = 5;
18pub const ENXIO = 6;
19pub const E2BIG = 7;
20pub const ENOEXEC = 8;
21pub const EBADF = 9;
22pub const ECHILD = 10;
23pub const EDEADLK = 11;
24pub const ENOMEM = 12;
25pub const EACCES = 13;
26pub const EFAULT = 14;
27pub const ENOTBLK = 15;
28pub const EBUSY = 16;
29pub const EEXIST = 17;
30pub const EXDEV = 18;
31pub const ENODEV = 19;
32pub const ENOTDIR = 20;
33pub const EISDIR = 21;
34pub const EINVAL = 22;
35pub const ENFILE = 23;
36pub const EMFILE = 24;
37pub const ENOTTY = 25;
38pub const ETXTBSY = 26;
39pub const EFBIG = 27;
40pub const ENOSPC = 28;
41pub const ESPIPE = 29;
42pub const EROFS = 30;
43pub const EMLINK = 31;
44pub const EPIPE = 32;
45pub const EDOM = 33;
46pub const ERANGE = 34;
47pub const EAGAIN = 35;
48pub const EINPROGRESS = 36;
49pub const EALREADY = 37;
50pub const ENOTSOCK = 38;
51pub const EDESTADDRREQ = 39;
52pub const EMSGSIZE = 40;
53pub const EPROTOTYPE = 41;
54pub const ENOPROTOOPT = 42;
55pub const EPROTONOSUPPORT = 43;
56pub const ESOCKTNOSUPPORT = 44;
57pub const EOPNOTSUPP = 45;
58pub const EPFNOSUPPORT = 46;
59pub const EAFNOSUPPORT = 47;
60pub const EADDRINUSE = 48;
61pub const EADDRNOTAVAIL = 49;
62pub const ENETDOWN = 50;
63pub const ENETUNREACH = 51;
64pub const ENETRESET = 52;
65pub const ECONNABORTED = 53;
66pub const ECONNRESET = 54;
67pub const ENOBUFS = 55;
68pub const EISCONN = 56;
69pub const ENOTCONN = 57;
70pub const ESHUTDOWN = 58;
71pub const ETOOMANYREFS = 59;
72pub const ETIMEDOUT = 60;
73pub const ECONNREFUSED = 61;
74pub const ELOOP = 62;
75pub const ENAMETOOLONG = 63;
76pub const EHOSTDOWN = 64;
77pub const EHOSTUNREACH = 65;
78pub const ENOTEMPTY = 66;
79pub const EPROCLIM = 67;
80pub const EUSERS = 68;
81pub const EDQUOT = 69;
82pub const ESTALE = 70;
83pub const EREMOTE = 71;
84pub const EBADRPC = 72;
85pub const ERPCMISMATCH = 73;
86pub const EPROGUNAVAIL = 74;
87pub const EPROGMISMATCH = 75;
88pub const EPROCUNAVAIL = 76;
89pub const ENOLCK = 77;
90pub const ENOSYS = 78;
91pub const EFTYPE = 79;
92pub const EAUTH = 80;
93pub const ENEEDAUTH = 81;
94pub const EIDRM = 82;
95pub const ENOMSG = 83;
96pub const EOVERFLOW = 84;
97pub const ECANCELED = 85;
98pub const EILSEQ = 86;
99pub const ENOATTR = 87;
100pub const EDOOFUS = 88;
101pub const EBADMSG = 89;
102pub const EMULTIHOP = 90;
103pub const ENOLINK = 91;
104pub const EPROTO = 92;
105pub const ENOMEDIUM = 93;
106pub const ELAST = 99;
107pub const EASYNC = 99;
108
109pub const STDIN_FILENO = 0;
110pub const STDOUT_FILENO = 1;
111pub const STDERR_FILENO = 2;
112
113pub const PROT_NONE = 0;
114pub const PROT_READ = 1;
115pub const PROT_WRITE = 2;
116pub const PROT_EXEC = 4;
117
118pub const MAP_FILE = 0;
119pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize));
120pub const MAP_ANONYMOUS = MAP_ANON;
121pub const MAP_COPY = MAP_PRIVATE;
122pub const MAP_SHARED = 1;
123pub const MAP_PRIVATE = 2;
124pub const MAP_FIXED = 16;
125pub const MAP_RENAME = 32;
126pub const MAP_NORESERVE = 64;
127pub const MAP_INHERIT = 128;
128pub const MAP_NOEXTEND = 256;
129pub const MAP_HASSEMAPHORE = 512;
130pub const MAP_STACK = 1024;
131pub const MAP_NOSYNC = 2048;
132pub const MAP_ANON = 4096;
133pub const MAP_VPAGETABLE = 8192;
134pub const MAP_TRYFIXED = 65536;
135pub const MAP_NOCORE = 131072;
136pub const MAP_SIZEALIGN = 262144;
137
138pub const PATH_MAX = 1024;
139
140pub 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
173pub const timespec = extern struct {
174 tv_sec: c_long,
175 tv_nsec: c_long,
176};
177
178pub const CTL_UNSPEC = 0;
179pub const CTL_KERN = 1;
180pub const CTL_VM = 2;
181pub const CTL_VFS = 3;
182pub const CTL_NET = 4;
183pub const CTL_DEBUG = 5;
184pub const CTL_HW = 6;
185pub const CTL_MACHDEP = 7;
186pub const CTL_USER = 8;
187pub const CTL_LWKT = 10;
188pub const CTL_MAXID = 11;
189pub const CTL_MAXNAME = 12;
190
191pub const KERN_PROC_ALL = 0;
192pub const KERN_OSTYPE = 1;
193pub const KERN_PROC_PID = 1;
194pub const KERN_OSRELEASE = 2;
195pub const KERN_PROC_PGRP = 2;
196pub const KERN_OSREV = 3;
197pub const KERN_PROC_SESSION = 3;
198pub const KERN_VERSION = 4;
199pub const KERN_PROC_TTY = 4;
200pub const KERN_MAXVNODES = 5;
201pub const KERN_PROC_UID = 5;
202pub const KERN_MAXPROC = 6;
203pub const KERN_PROC_RUID = 6;
204pub const KERN_MAXFILES = 7;
205pub const KERN_PROC_ARGS = 7;
206pub const KERN_ARGMAX = 8;
207pub const KERN_PROC_CWD = 8;
208pub const KERN_PROC_PATHNAME = 9;
209pub const KERN_SECURELVL = 9;
210pub const KERN_PROC_SIGTRAMP = 10;
211pub const KERN_HOSTNAME = 10;
212pub const KERN_HOSTID = 11;
213pub const KERN_CLOCKRATE = 12;
214pub const KERN_VNODE = 13;
215pub const KERN_PROC = 14;
216pub const KERN_FILE = 15;
217pub const KERN_PROC_FLAGMASK = 16;
218pub const KERN_PROF = 16;
219pub const KERN_PROC_FLAG_LWP = 16;
220pub const KERN_POSIX1 = 17;
221pub const KERN_NGROUPS = 18;
222pub const KERN_JOB_CONTROL = 19;
223pub const KERN_SAVED_IDS = 20;
224pub const KERN_BOOTTIME = 21;
225pub const KERN_NISDOMAINNAME = 22;
226pub const KERN_UPDATEINTERVAL = 23;
227pub const KERN_OSRELDATE = 24;
228pub const KERN_NTP_PLL = 25;
229pub const KERN_BOOTFILE = 26;
230pub const KERN_MAXFILESPERPROC = 27;
231pub const KERN_MAXPROCPERUID = 28;
232pub const KERN_DUMPDEV = 29;
233pub const KERN_IPC = 30;
234pub const KERN_DUMMY = 31;
235pub const KERN_PS_STRINGS = 32;
236pub const KERN_USRSTACK = 33;
237pub const KERN_LOGSIGEXIT = 34;
238pub const KERN_IOV_MAX = 35;
239pub const KERN_MAXPOSIXLOCKSPERUID = 36;
240pub const KERN_MAXID = 37;
241
242pub const HOST_NAME_MAX = 255;
243
244pub const O_LARGEFILE = 0; // faked support
245pub const O_RDONLY = 0;
246pub const O_NDELAY = O_NONBLOCK;
247pub const O_WRONLY = 1;
248pub const O_RDWR = 2;
249pub const O_ACCMODE = 3;
250pub const O_NONBLOCK = 4;
251pub const O_APPEND = 8;
252pub const O_SHLOCK = 16;
253pub const O_EXLOCK = 32;
254pub const O_ASYNC = 64;
255pub const O_FSYNC = 128;
256pub const O_SYNC = 128;
257pub const O_NOFOLLOW = 256;
258pub const O_CREAT = 512;
259pub const O_TRUNC = 1024;
260pub const O_EXCL = 2048;
261pub const O_NOCTTY = 32768;
262pub const O_DIRECT = 65536;
263pub const O_CLOEXEC = 131072;
264pub const O_FBLOCKING = 262144;
265pub const O_FNONBLOCKING = 524288;
266pub const O_FAPPEND = 1048576;
267pub const O_FOFFSET = 2097152;
268pub const O_FSYNCWRITE = 4194304;
269pub const O_FASYNCWRITE = 8388608;
270pub const O_DIRECTORY = 134217728;
271
272pub const SEEK_SET = 0;
273pub const SEEK_CUR = 1;
274pub const SEEK_END = 2;
275pub const SEEK_DATA = 3;
276pub const SEEK_HOLE = 4;
277
278pub const F_OK = 0;
279pub const F_ULOCK = 0;
280pub const F_LOCK = 1;
281pub const F_TLOCK = 2;
282pub const F_TEST = 3;
283
284pub const AT_FDCWD = -328243;
285pub const AT_SYMLINK_NOFOLLOW = 1;
286pub const AT_REMOVEDIR = 2;
287pub const AT_EACCESS = 4;
288pub const AT_SYMLINK_FOLLOW = 8;
289
290pub fn WEXITSTATUS(s: u32) u32 {
291 return (s & 0xff00) >> 8;
292}
293pub fn WTERMSIG(s: u32) u32 {
294 return s & 0x7f;
295}
296pub fn WSTOPSIG(s: u32) u32 {
297 return WEXITSTATUS(s);
298}
299pub fn WIFEXITED(s: u32) bool {
300 return WTERMSIG(s) == 0;
301}
302pub fn WIFSTOPPED(s: u32) bool {
303 return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
304}
305pub fn WIFSIGNALED(s: u32) bool {
306 return (s & 0xffff) -% 1 < 0xff;
307}
308
309pub 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
322pub const DT_UNKNOWN = 0;
323pub const DT_FIFO = 1;
324pub const DT_CHR = 2;
325pub const DT_DIR = 4;
326pub const DT_BLK = 6;
327pub const DT_REG = 8;
328pub const DT_LNK = 10;
329pub const DT_SOCK = 12;
330pub const DT_WHT = 14;
331pub const DT_DBF = 15;
332
333pub const CLOCK_REALTIME = 0;
334pub const CLOCK_VIRTUAL = 1;
335pub const CLOCK_PROF = 2;
336pub const CLOCK_MONOTONIC = 4;
337pub const CLOCK_UPTIME = 5;
338pub const CLOCK_UPTIME_PRECISE = 7;
339pub const CLOCK_UPTIME_FAST = 8;
340pub const CLOCK_REALTIME_PRECISE = 9;
341pub const CLOCK_REALTIME_FAST = 10;
342pub const CLOCK_MONOTONIC_PRECISE = 11;
343pub const CLOCK_MONOTONIC_FAST = 12;
344pub const CLOCK_SECOND = 13;
345pub const CLOCK_THREAD_CPUTIME_ID = 14;
346pub const CLOCK_PROCESS_CPUTIME_ID = 15;
347
348pub const sockaddr = extern struct {
349 sa_len: u8,
350 sa_family: u8,
351 sa_data: [14]u8,
352};
353
354pub 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
363pub const pthread_attr_t = extern struct { // copied from freebsd
364 __size: [56]u8,
365 __align: c_long,
366};
367
368pub const EVFILT_FS = -10;
369pub const EVFILT_USER = -9;
370pub const EVFILT_EXCEPT = -8;
371pub const EVFILT_TIMER = -7;
372pub const EVFILT_SIGNAL = -6;
373pub const EVFILT_PROC = -5;
374pub const EVFILT_VNODE = -4;
375pub const EVFILT_AIO = -3;
376pub const EVFILT_WRITE = -2;
377pub const EVFILT_READ = -1;
378pub const EVFILT_SYSCOUNT = 10;
379pub const EVFILT_MARKER = 15;
380
381pub const EV_ADD = 1;
382pub const EV_DELETE = 2;
383pub const EV_ENABLE = 4;
384pub const EV_DISABLE = 8;
385pub const EV_ONESHOT = 16;
386pub const EV_CLEAR = 32;
387pub const EV_RECEIPT = 64;
388pub const EV_DISPATCH = 128;
389pub const EV_NODATA = 4096;
390pub const EV_FLAG1 = 8192;
391pub const EV_ERROR = 16384;
392pub const EV_EOF = 32768;
393pub const EV_SYSFLAGS = 61440;
394
395pub const NOTE_FFNOP = 0;
396pub const NOTE_TRACK = 1;
397pub const NOTE_DELETE = 1;
398pub const NOTE_LOWAT = 1;
399pub const NOTE_TRACKERR = 2;
400pub const NOTE_OOB = 2;
401pub const NOTE_WRITE = 2;
402pub const NOTE_EXTEND = 4;
403pub const NOTE_CHILD = 4;
404pub const NOTE_ATTRIB = 8;
405pub const NOTE_LINK = 16;
406pub const NOTE_RENAME = 32;
407pub const NOTE_REVOKE = 64;
408pub const NOTE_PDATAMASK = 1048575;
409pub const NOTE_FFLAGSMASK = 16777215;
410pub const NOTE_TRIGGER = 16777216;
411pub const NOTE_EXEC = 536870912;
412pub const NOTE_FFAND = 1073741824;
413pub const NOTE_FORK = 1073741824;
414pub const NOTE_EXIT = 2147483648;
415pub const NOTE_FFOR = 2147483648;
416pub const NOTE_FFCTRLMASK = 3221225472;
417pub const NOTE_FFCOPY = 3221225472;
418pub const NOTE_PCTRLMASK = 4026531840;
419
420pub const stack_t = extern struct {
421 ss_sp: [*]u8,
422 ss_size: isize,
423 ss_flags: i32,
424};
425
426pub const S_IREAD = S_IRUSR;
427pub const S_IEXEC = S_IXUSR;
428pub const S_IWRITE = S_IWUSR;
429pub const S_IXOTH = 1;
430pub const S_IWOTH = 2;
431pub const S_IROTH = 4;
432pub const S_IRWXO = 7;
433pub const S_IXGRP = 8;
434pub const S_IWGRP = 16;
435pub const S_IRGRP = 32;
436pub const S_IRWXG = 56;
437pub const S_IXUSR = 64;
438pub const S_IWUSR = 128;
439pub const S_IRUSR = 256;
440pub const S_IRWXU = 448;
441pub const S_ISTXT = 512;
442pub const S_BLKSIZE = 512;
443pub const S_ISVTX = 512;
444pub const S_ISGID = 1024;
445pub const S_ISUID = 2048;
446pub const S_IFIFO = 4096;
447pub const S_IFCHR = 8192;
448pub const S_IFDIR = 16384;
449pub const S_IFBLK = 24576;
450pub const S_IFREG = 32768;
451pub const S_IFDB = 36864;
452pub const S_IFLNK = 40960;
453pub const S_IFSOCK = 49152;
454pub const S_IFWHT = 57344;
455pub const S_IFMT = 61440;
456
457pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize));
458pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
459pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);
460pub const BADSIG = SIG_ERR;
461pub const SIG_BLOCK = 1;
462pub const SIG_UNBLOCK = 2;
463pub const SIG_SETMASK = 3;
464
465pub const SIGIOT = SIGABRT;
466pub const SIGHUP = 1;
467pub const SIGINT = 2;
468pub const SIGQUIT = 3;
469pub const SIGILL = 4;
470pub const SIGTRAP = 5;
471pub const SIGABRT = 6;
472pub const SIGEMT = 7;
473pub const SIGFPE = 8;
474pub const SIGKILL = 9;
475pub const SIGBUS = 10;
476pub const SIGSEGV = 11;
477pub const SIGSYS = 12;
478pub const SIGPIPE = 13;
479pub const SIGALRM = 14;
480pub const SIGTERM = 15;
481pub const SIGURG = 16;
482pub const SIGSTOP = 17;
483pub const SIGTSTP = 18;
484pub const SIGCONT = 19;
485pub const SIGCHLD = 20;
486pub const SIGTTIN = 21;
487pub const SIGTTOU = 22;
488pub const SIGIO = 23;
489pub const SIGXCPU = 24;
490pub const SIGXFSZ = 25;
491pub const SIGVTALRM = 26;
492pub const SIGPROF = 27;
493pub const SIGWINCH = 28;
494pub const SIGINFO = 29;
495pub const SIGUSR1 = 30;
496pub const SIGUSR2 = 31;
497pub const SIGTHR = 32;
498pub const SIGCKPT = 33;
499pub const SIGCKPTEXIT = 34;
500pub 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};
512pub const sigset_t = extern struct {
513 __bits: [4]c_uint,
514};
515pub const sig_atomic_t = c_int;
516pub 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};
524pub const sig_t = [*c]extern fn(c_int) void;
525
526pub const sigvec = extern struct {
527 sv_handler: [*c]__sighandler_t,
528 sv_mask: c_int,
529 sv_flags: c_int,
530};
531
532pub const SOCK_STREAM = 1;
533pub const SOCK_DGRAM = 2;
534pub const SOCK_RAW = 3;
535pub const SOCK_RDM = 4;
536pub const SOCK_SEQPACKET = 5;
537pub const SOCK_MAXADDRLEN = 255;
538pub const SOCK_CLOEXEC = 268435456;
539pub const SOCK_NONBLOCK = 536870912;
540
541pub const PF_INET6 = AF_INET6;
542pub const PF_IMPLINK = AF_IMPLINK;
543pub const PF_ROUTE = AF_ROUTE;
544pub const PF_ISO = AF_ISO;
545pub const PF_PIP = pseudo_AF_PIP;
546pub const PF_CHAOS = AF_CHAOS;
547pub const PF_DATAKIT = AF_DATAKIT;
548pub const PF_INET = AF_INET;
549pub const PF_APPLETALK = AF_APPLETALK;
550pub const PF_SIP = AF_SIP;
551pub const PF_OSI = AF_ISO;
552pub const PF_CNT = AF_CNT;
553pub const PF_LINK = AF_LINK;
554pub const PF_HYLINK = AF_HYLINK;
555pub const PF_MAX = AF_MAX;
556pub const PF_KEY = pseudo_AF_KEY;
557pub const PF_PUP = AF_PUP;
558pub const PF_COIP = AF_COIP;
559pub const PF_SNA = AF_SNA;
560pub const PF_LOCAL = AF_LOCAL;
561pub const PF_NETBIOS = AF_NETBIOS;
562pub const PF_NATM = AF_NATM;
563pub const PF_BLUETOOTH = AF_BLUETOOTH;
564pub const PF_UNSPEC = AF_UNSPEC;
565pub const PF_NETGRAPH = AF_NETGRAPH;
566pub const PF_ECMA = AF_ECMA;
567pub const PF_IPX = AF_IPX;
568pub const PF_DLI = AF_DLI;
569pub const PF_ATM = AF_ATM;
570pub const PF_CCITT = AF_CCITT;
571pub const PF_ISDN = AF_ISDN;
572pub const PF_RTIP = pseudo_AF_RTIP;
573pub const PF_LAT = AF_LAT;
574pub const PF_UNIX = PF_LOCAL;
575pub const PF_XTP = pseudo_AF_XTP;
576pub const PF_DECnet = AF_DECnet;
577
578pub const AF_UNSPEC = 0;
579pub const AF_OSI = AF_ISO;
580pub const AF_UNIX = AF_LOCAL;
581pub const AF_LOCAL = 1;
582pub const AF_INET = 2;
583pub const AF_IMPLINK = 3;
584pub const AF_PUP = 4;
585pub const AF_CHAOS = 5;
586pub const AF_NETBIOS = 6;
587pub const AF_ISO = 7;
588pub const AF_ECMA = 8;
589pub const AF_DATAKIT = 9;
590pub const AF_CCITT = 10;
591pub const AF_SNA = 11;
592pub const AF_DLI = 13;
593pub const AF_LAT = 14;
594pub const AF_HYLINK = 15;
595pub const AF_APPLETALK = 16;
596pub const AF_ROUTE = 17;
597pub const AF_LINK = 18;
598pub const AF_COIP = 20;
599pub const AF_CNT = 21;
600pub const AF_IPX = 23;
601pub const AF_SIP = 24;
602pub const AF_ISDN = 26;
603pub const AF_NATM = 29;
604pub const AF_ATM = 30;
605pub const AF_NETGRAPH = 32;
606pub const AF_BLUETOOTH = 33;
607pub const AF_MPLS = 34;
608pub const AF_MAX = 36;
609
610pub const sa_family_t = u8;
611pub const socklen_t = c_uint;
612pub 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};
619pub 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};
625pub 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};
634pub const cmsghdr = extern struct {
635 cmsg_len: socklen_t,
636 cmsg_level: c_int,
637 cmsg_type: c_int,
638};
639pub 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};
647pub 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
654pub const MS_SYNC = 0;
655pub const MS_ASYNC = 1;
656pub const MS_INVALIDATE = 2;
657
658pub const POSIX_MADV_SEQUENTIAL = 2;
659pub const POSIX_MADV_RANDOM = 1;
660pub const POSIX_MADV_DONTNEED = 4;
661pub const POSIX_MADV_NORMAL = 0;
662pub const POSIX_MADV_WILLNEED = 3;
663
664pub const MADV_SEQUENTIAL = 2;
665pub const MADV_CONTROL_END = MADV_SETMAP;
666pub const MADV_DONTNEED = 4;
667pub const MADV_RANDOM = 1;
668pub const MADV_WILLNEED = 3;
669pub const MADV_NORMAL = 0;
670pub const MADV_CONTROL_START = MADV_INVAL;
671pub const MADV_FREE = 5;
672pub const MADV_NOSYNC = 6;
673pub const MADV_AUTOSYNC = 7;
674pub const MADV_NOCORE = 8;
675pub const MADV_CORE = 9;
676pub const MADV_INVAL = 10;
677pub const MADV_SETMAP = 11;
678
679pub const F_DUPFD = 0;
680pub const F_GETFD = 1;
681pub const F_RDLCK = 1;
682pub const F_SETFD = 2;
683pub const F_UNLCK = 2;
684pub const F_WRLCK = 3;
685pub const F_GETFL = 3;
686pub const F_SETFL = 4;
687pub const F_GETOWN = 5;
688pub const F_SETOWN = 6;
689pub const F_GETLK = 7;
690pub const F_SETLK = 8;
691pub const F_SETLKW = 9;
692pub const F_DUP2FD = 10;
693pub const F_DUPFD_CLOEXEC = 17;
694pub const F_DUP2FD_CLOEXEC = 18;
695
696pub 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 {
132132 d_namlen: u16,
133133 d_pad1: u16,
134134 d_name: [256]u8,
135
136 pub fn reclen(self: dirent) usize {
137 return self.d_reclen;
138 }
135139};
136140
137141pub const in_port_t = u16;
lib/std/os/bits/linux.zig+4
......@@ -1023,6 +1023,10 @@ pub const dirent64 = extern struct {
10231023 d_reclen: u16,
10241024 d_type: u8,
10251025 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 }
10261030};
10271031
10281032pub const dl_phdr_info = extern struct {
lib/std/os/bits/netbsd.zig+4
......@@ -128,6 +128,10 @@ pub const dirent = extern struct {
128128 d_type: u8,
129129 d_off: i64,
130130 d_name: [512]u8,
131
132 pub fn reclen(self: dirent) usize {
133 return self.d_reclen;
134 }
131135};
132136
133137pub const in_port_t = u16;
lib/std/os/dragonfly.zig created+3
......@@ -0,0 +1,3 @@
1const std = @import("../std.zig");
2pub usingnamespace std.c;
3pub usingnamespace @import("bits.zig");
lib/std/os/test.zig+4
......@@ -16,6 +16,7 @@ const AtomicRmwOp = builtin.AtomicRmwOp;
1616const AtomicOrder = builtin.AtomicOrder;
1717
1818test "makePath, put some files in it, deleteTree" {
19 if (builtin.os == .dragonfly) return error.SkipZigTest;
1920 try fs.makePath(a, "os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c");
2021 try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c" ++ fs.path.sep_str ++ "file.txt", "nonsense");
2122 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" {
2829}
2930
3031test "access file" {
32 if (builtin.os == .dragonfly) return error.SkipZigTest;
3133 try fs.makePath(a, "os_test_tmp");
3234 if (File.access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt")) |ok| {
3335 @panic("expected error");
......@@ -95,6 +97,7 @@ test "cpu count" {
9597}
9698
9799test "AtomicFile" {
100 if (builtin.os == .dragonfly) return error.SkipZigTest;
98101 var buffer: [1024]u8 = undefined;
99102 const allocator = &std.heap.FixedBufferAllocator.init(buffer[0..]).allocator;
100103 const test_out_file = "tmp_atomic_file_test_dest.txt";
......@@ -115,6 +118,7 @@ test "AtomicFile" {
115118}
116119
117120test "thread local storage" {
121 if (builtin.os == .dragonfly) return error.SkipZigTest;
118122 if (builtin.single_threaded) return error.SkipZigTest;
119123 const thread1 = try Thread.spawn({}, testTls);
120124 const thread2 = try Thread.spawn({}, testTls);
lib/std/statically_initialized_mutex.zig+1
......@@ -61,6 +61,7 @@ pub const StaticallyInitializedMutex = switch (builtin.os) {
6161};
6262
6363test "std.StaticallyInitializedMutex" {
64 if (builtin.os == .dragonfly) return error.SkipZigTest;
6465 const TestContext = struct {
6566 data: i128,
6667
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
320320
321321#undef CC_EXE
322322
323#if defined(ZIG_OS_WINDOWS) || defined(ZIG_OS_LINUX)
323#if defined(ZIG_OS_WINDOWS) || defined(ZIG_OS_LINUX) || defined(ZIG_OS_DRAGONFLY)
324324static Error zig_libc_find_native_crt_dir_posix(ZigLibCInstallation *self, bool verbose) {
325325 return zig_libc_cc_print_file_name("crt1.o", &self->crt_dir, true, verbose);
326326}
......@@ -413,6 +413,7 @@ void zig_libc_render(ZigLibCInstallation *self, FILE *file) {
413413 "# The directory that contains `stdlib.h`.\n"
414414 "# On POSIX-like systems, include directories be found with: `cc -E -Wp,-v -xc /dev/null`\n"
415415 "include_dir=%s\n"
416 "\n"
416417 "# The system-specific include directory. May be the same as `include_dir`.\n"
417418 "# On Windows it's the directory that includes `vcruntime.h`.\n"
418419 "# On POSIX it's the directory that includes `sys/errno.h`.\n"
......@@ -435,8 +436,7 @@ void zig_libc_render(ZigLibCInstallation *self, FILE *file) {
435436 "# The directory that contains `kernel32.lib`.\n"
436437 "# Only needed when targeting MSVC on Windows.\n"
437438 "kernel32_lib_dir=%s\n"
438 "\n"
439 ,
439 "\n",
440440 buf_ptr(&self->include_dir),
441441 buf_ptr(&self->sys_include_dir),
442442 buf_ptr(&self->crt_dir),
......@@ -489,7 +489,7 @@ Error zig_libc_find_native(ZigLibCInstallation *self, bool verbose) {
489489 return err;
490490#if defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD)
491491 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)
493493 if ((err = zig_libc_find_native_crt_dir_posix(self, verbose)))
494494 return err;
495495#endif
src/link.cpp-16
......@@ -1792,28 +1792,12 @@ static void construct_linker_job_elf(LinkJob *lj) {
17921792 if (g->libc != nullptr) {
17931793 if (!g->have_dynamic_link) {
17941794 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 }
17991795 lj->args.append("-lc");
18001796 lj->args.append("-lm");
18011797 lj->args.append("--end-group");
18021798 } 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 }
18091799 lj->args.append("-lc");
18101800 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 }
18171801 }
18181802
18191803 if (g->zig_target->os == OsFreeBSD) {
src/os.cpp+6-6
......@@ -52,7 +52,7 @@ typedef SSIZE_T ssize_t;
5252
5353#endif
5454
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)
5656#include <link.h>
5757#endif
5858
......@@ -60,7 +60,7 @@ typedef SSIZE_T ssize_t;
6060#include <sys/auxv.h>
6161#endif
6262
63#if defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD)
63#if defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) || defined(ZIG_OS_DRAGONFLY)
6464#include <sys/sysctl.h>
6565#endif
6666
......@@ -85,7 +85,7 @@ static clock_serv_t macos_monotonic_clock;
8585#if defined(__APPLE__) && !defined(environ)
8686#include <crt_externs.h>
8787#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)
8989extern char **environ;
9090#endif
9191
......@@ -1450,7 +1450,7 @@ Error os_self_exe_path(Buf *out_path) {
14501450 }
14511451 buf_resize(out_path, amt);
14521452 return ErrorNone;
1453#elif defined(ZIG_OS_FREEBSD)
1453#elif defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_DRAGONFLY)
14541454 buf_resize(out_path, PATH_MAX);
14551455 int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
14561456 size_t cb = PATH_MAX;
......@@ -1792,7 +1792,7 @@ Error os_get_app_data_dir(Buf *out_path, const char *appname) {
17921792}
17931793
17941794
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)
17961796static int self_exe_shared_libs_callback(struct dl_phdr_info *info, size_t size, void *data) {
17971797 ZigList<Buf *> *libs = reinterpret_cast< ZigList<Buf *> *>(data);
17981798 if (info->dlpi_name[0] == '/') {
......@@ -1803,7 +1803,7 @@ static int self_exe_shared_libs_callback(struct dl_phdr_info *info, size_t size,
18031803#endif
18041804
18051805Error 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)
18071807 paths.resize(0);
18081808 dl_iterate_phdr(self_exe_shared_libs_callback, &paths);
18091809 return ErrorNone;
src/os.hpp+2
......@@ -27,6 +27,8 @@
2727#define ZIG_OS_FREEBSD
2828#elif defined(__NetBSD__)
2929#define ZIG_OS_NETBSD
30#elif defined(__DragonFly__)
31#define ZIG_OS_DRAGONFLY
3032#else
3133#define ZIG_OS_UNKNOWN
3234#endif
src/target.cpp+5-4
......@@ -1050,6 +1050,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) {
10501050 case OsZen:
10511051 case OsFreeBSD:
10521052 case OsNetBSD:
1053 case OsDragonFly:
10531054 case OsOpenBSD:
10541055 case OsWASI:
10551056 case OsEmscripten:
......@@ -1104,7 +1105,6 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) {
11041105 }
11051106 case OsAnanas:
11061107 case OsCloudABI:
1107 case OsDragonFly:
11081108 case OsKFreeBSD:
11091109 case OsLv2:
11101110 case OsSolaris:
......@@ -1267,6 +1267,8 @@ const char *target_dynamic_linker(const ZigTarget *target) {
12671267 return "/libexec/ld-elf.so.1";
12681268 case OsNetBSD:
12691269 return "/libexec/ld.elf_so";
1270 case OsDragonFly:
1271 return "/libexec/ld-elf.so.2";
12701272 case OsLinux: {
12711273 const ZigLLVM_EnvironmentType abi = target->abi;
12721274 switch (target->arch) {
......@@ -1383,7 +1385,6 @@ const char *target_dynamic_linker(const ZigTarget *target) {
13831385
13841386 case OsAnanas:
13851387 case OsCloudABI:
1386 case OsDragonFly:
13871388 case OsFuchsia:
13881389 case OsKFreeBSD:
13891390 case OsLv2:
......@@ -1579,7 +1580,7 @@ bool target_os_requires_libc(Os os) {
15791580 // On Darwin, we always link libSystem which contains libc.
15801581 // Similarly on FreeBSD and NetBSD we always link system libc
15811582 // 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);
15831584}
15841585
15851586bool target_supports_fpic(const ZigTarget *target) {
......@@ -1636,7 +1637,6 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) {
16361637 case OsFreestanding:
16371638 case OsAnanas:
16381639 case OsCloudABI:
1639 case OsDragonFly:
16401640 case OsLv2:
16411641 case OsSolaris:
16421642 case OsHaiku:
......@@ -1665,6 +1665,7 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) {
16651665 case OsFuchsia:
16661666 case OsKFreeBSD:
16671667 case OsNetBSD:
1668 case OsDragonFly:
16681669 case OsHurd:
16691670 return ZigLLVM_GNU;
16701671 case OsUefi:
test/stage1/behavior/byteswap.zig+2
......@@ -1,5 +1,6 @@
11const std = @import("std");
22const expect = std.testing.expect;
3const builtin = @import("builtin");
34
45test "@byteSwap integers" {
56 const ByteSwapIntTest = struct {
......@@ -40,6 +41,7 @@ test "@byteSwap integers" {
4041
4142test "@byteSwap vectors" {
4243 // Disabled because of #3317
44 if (builtin.os == .dragonfly) return error.SkipZigTest;
4345 if (@import("builtin").arch == .mipsel) return error.SkipZigTest;
4446
4547 const ByteSwapVectorTest = struct {
test/stage1/behavior/vector.zig+2
......@@ -1,6 +1,7 @@
11const std = @import("std");
22const mem = std.mem;
33const expect = std.testing.expect;
4const builtin = @import("builtin");
45
56test "implicit cast vector to array - bool" {
67 const S = struct {
......@@ -111,6 +112,7 @@ test "array to vector" {
111112}
112113
113114test "vector casts of sizes not divisable by 8" {
115 if (builtin.os == .dragonfly) return error.SkipZigTest;
114116 const S = struct {
115117 fn doTheTest() void {
116118 {