From ad438a95c528c4a2013e3e7fb99ea9a260143eb3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 24 Oct 2019 19:43:56 -0400 Subject: avoid passing -march=native when not supported Clang does not support -march=native for all targets. Arguably it should always work, but in reality it gives: error: the clang compiler does not support '-march=native' If we move CPU detection logic into Zig itelf, we will not need this, instead we will always pass target features and CPU configuration explicitly. For now, we simply avoid passing the flag when it is known to not be supported. --- src/target.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/target.cpp') diff --git a/src/target.cpp b/src/target.cpp index 1cab9253a0..9af42b7d9d 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -1583,9 +1583,19 @@ bool target_os_requires_libc(Os os) { } bool target_supports_fpic(const ZigTarget *target) { - // This is not whether the target supports Position Independent Code, but whether the -fPIC - // C compiler argument is valid. - return target->os != OsWindows; + // This is not whether the target supports Position Independent Code, but whether the -fPIC + // C compiler argument is valid. + return target->os != OsWindows; +} + +bool target_supports_clang_march_native(const ZigTarget *target) { + // Whether clang supports -march=native on this target. + // Arguably it should always work, but in reality it gives: + // error: the clang compiler does not support '-march=native' + // If we move CPU detection logic into Zig itelf, we will not need this, + // instead we will always pass target features and CPU configuration explicitly. + return target->arch != ZigLLVM_aarch64 && + target->arch != ZigLLVM_aarch64_be; } bool target_supports_stack_probing(const ZigTarget *target) { -- cgit v1.2.3 From 33cc2044811e41a74e3112fc0abcc5dc6fd34836 Mon Sep 17 00:00:00 2001 From: Tse <1@tse.gratis> Date: Wed, 23 Oct 2019 01:06:35 +0300 Subject: DragonFlyBSD support --- lib/std/atomic/queue.zig | 1 + lib/std/atomic/stack.zig | 1 + lib/std/c.zig | 1 + lib/std/c/dragonfly.zig | 14 + lib/std/debug.zig | 2 +- lib/std/event/channel.zig | 1 + lib/std/event/fs.zig | 24 +- lib/std/event/group.zig | 1 + lib/std/event/lock.zig | 1 + lib/std/event/loop.zig | 21 +- lib/std/fs.zig | 12 +- lib/std/fs/get_app_data_dir.zig | 2 +- lib/std/mutex.zig | 1 + lib/std/os.zig | 4 +- lib/std/os/bits.zig | 1 + lib/std/os/bits/darwin.zig | 4 + lib/std/os/bits/dragonfly.zig | 702 +++++++++++++++++++++++++++++++ lib/std/os/bits/freebsd.zig | 4 + lib/std/os/bits/linux.zig | 4 + lib/std/os/bits/netbsd.zig | 4 + lib/std/os/dragonfly.zig | 3 + lib/std/os/test.zig | 4 + lib/std/statically_initialized_mutex.zig | 1 + src/libc_installation.cpp | 8 +- src/link.cpp | 16 - src/os.cpp | 12 +- src/os.hpp | 2 + src/target.cpp | 9 +- test/stage1/behavior/byteswap.zig | 2 + test/stage1/behavior/vector.zig | 2 + 30 files changed, 807 insertions(+), 57 deletions(-) create mode 100644 lib/std/c/dragonfly.zig create mode 100644 lib/std/os/bits/dragonfly.zig create mode 100644 lib/std/os/dragonfly.zig (limited to 'src/target.cpp') diff --git a/lib/std/atomic/queue.zig b/lib/std/atomic/queue.zig index dbc011bed3..a9d7649829 100644 --- a/lib/std/atomic/queue.zig +++ b/lib/std/atomic/queue.zig @@ -152,6 +152,7 @@ const puts_per_thread = 500; const put_thread_count = 3; test "std.atomic.Queue" { + if (builtin.os == .dragonfly) return error.SkipZigTest; var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024); defer std.heap.direct_allocator.free(plenty_of_memory); diff --git a/lib/std/atomic/stack.zig b/lib/std/atomic/stack.zig index dd288adbf1..ee6238542f 100644 --- a/lib/std/atomic/stack.zig +++ b/lib/std/atomic/stack.zig @@ -86,6 +86,7 @@ const puts_per_thread = 500; const put_thread_count = 3; test "std.atomic.stack" { + if (builtin.os == .dragonfly) return error.SkipZigTest; var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024); defer std.heap.direct_allocator.free(plenty_of_memory); diff --git a/lib/std/c.zig b/lib/std/c.zig index f591481d04..2c4a224408 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -10,6 +10,7 @@ pub usingnamespace switch (builtin.os) { .macosx, .ios, .tvos, .watchos => @import("c/darwin.zig"), .freebsd => @import("c/freebsd.zig"), .netbsd => @import("c/netbsd.zig"), + .dragonfly => @import("c/dragonfly.zig"), else => struct {}, }; diff --git a/lib/std/c/dragonfly.zig b/lib/std/c/dragonfly.zig new file mode 100644 index 0000000000..bd44a25514 --- /dev/null +++ b/lib/std/c/dragonfly.zig @@ -0,0 +1,14 @@ +const std = @import("../std.zig"); +usingnamespace std.c; + +extern "c" threadlocal var errno: c_int; +pub fn _errno() *c_int { + return &errno; +} + +pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; +pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; +pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; + +pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info, size: usize, data: ?*c_void) c_int; +pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int; diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 95670dc4ea..5e5a886d4e 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -1272,7 +1272,7 @@ pub const DebugInfo = switch (builtin.os) { sect_contribs: []pdb.SectionContribEntry, modules: []Module, }, - .linux, .freebsd, .netbsd => DwarfInfo, + .linux, .freebsd, .netbsd, .dragonfly => DwarfInfo, else => @compileError("Unsupported OS"), }; diff --git a/lib/std/event/channel.zig b/lib/std/event/channel.zig index 1092f2204a..b46cca1261 100644 --- a/lib/std/event/channel.zig +++ b/lib/std/event/channel.zig @@ -304,6 +304,7 @@ pub fn Channel(comptime T: type) type { } test "std.event.Channel" { + if (builtin.os == .dragonfly) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/1908 if (builtin.single_threaded) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/3251 diff --git a/lib/std/event/fs.zig b/lib/std/event/fs.zig index 2f64d453af..d86bcbaed5 100644 --- a/lib/std/event/fs.zig +++ b/lib/std/event/fs.zig @@ -92,6 +92,7 @@ pub fn pwritev(loop: *Loop, fd: fd_t, data: []const []const u8, offset: usize) P .linux, .freebsd, .netbsd, + .dragonfly, => { const iovecs = try loop.allocator.alloc(os.iovec_const, data.len); defer loop.allocator.free(iovecs); @@ -248,6 +249,7 @@ pub fn preadv(loop: *Loop, fd: fd_t, data: []const []u8, offset: usize) PReadVEr .linux, .freebsd, .netbsd, + .dragonfly, => { const iovecs = try loop.allocator.alloc(os.iovec, data.len); defer loop.allocator.free(iovecs); @@ -412,7 +414,7 @@ pub fn openPosix( pub fn openRead(loop: *Loop, path: []const u8) File.OpenError!fd_t { switch (builtin.os) { - .macosx, .linux, .freebsd, .netbsd => { + .macosx, .linux, .freebsd, .netbsd, .dragonfly => { const flags = os.O_LARGEFILE | os.O_RDONLY | os.O_CLOEXEC; return openPosix(loop, path, flags, File.default_mode); }, @@ -444,6 +446,7 @@ pub fn openWriteMode(loop: *Loop, path: []const u8, mode: File.Mode) File.OpenEr .linux, .freebsd, .netbsd, + .dragonfly, => { const flags = os.O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_TRUNC; return openPosix(loop, path, flags, File.default_mode); @@ -468,7 +471,7 @@ pub fn openReadWrite( mode: File.Mode, ) File.OpenError!fd_t { switch (builtin.os) { - .macosx, .linux, .freebsd, .netbsd => { + .macosx, .linux, .freebsd, .netbsd, .dragonfly => { const flags = os.O_LARGEFILE | os.O_RDWR | os.O_CREAT | os.O_CLOEXEC; return openPosix(loop, path, flags, mode); }, @@ -498,7 +501,7 @@ pub const CloseOperation = struct { os_data: OsData, const OsData = switch (builtin.os) { - .linux, .macosx, .freebsd, .netbsd => OsDataPosix, + .linux, .macosx, .freebsd, .netbsd, .dragonfly => OsDataPosix, .windows => struct { handle: ?fd_t, @@ -517,7 +520,7 @@ pub const CloseOperation = struct { self.* = CloseOperation{ .loop = loop, .os_data = switch (builtin.os) { - .linux, .macosx, .freebsd, .netbsd => initOsDataPosix(self), + .linux, .macosx, .freebsd, .netbsd, .dragonfly => initOsDataPosix(self), .windows => OsData{ .handle = null }, else => @compileError("Unsupported OS"), }, @@ -548,6 +551,7 @@ pub const CloseOperation = struct { .macosx, .freebsd, .netbsd, + .dragonfly, => { if (self.os_data.have_fd) { self.loop.posixFsRequest(&self.os_data.close_req_node); @@ -571,6 +575,7 @@ pub const CloseOperation = struct { .macosx, .freebsd, .netbsd, + .dragonfly, => { self.os_data.close_req_node.data.msg.Close.fd = handle; self.os_data.have_fd = true; @@ -589,6 +594,7 @@ pub const CloseOperation = struct { .macosx, .freebsd, .netbsd, + .dragonfly, => { self.os_data.have_fd = false; }, @@ -605,6 +611,7 @@ pub const CloseOperation = struct { .macosx, .freebsd, .netbsd, + .dragonfly, => { assert(self.os_data.have_fd); return self.os_data.close_req_node.data.msg.Close.fd; @@ -630,6 +637,7 @@ pub fn writeFileMode(loop: *Loop, path: []const u8, contents: []const u8, mode: .macosx, .freebsd, .netbsd, + .dragonfly, => return writeFileModeThread(loop, path, contents, mode), .windows => return writeFileWindows(loop, path, contents), else => @compileError("Unsupported OS"), @@ -742,7 +750,7 @@ fn hashString(s: []const u16) u32 { // os_data: OsData, // // const OsData = switch (builtin.os) { -// .macosx, .freebsd, .netbsd => struct { +// .macosx, .freebsd, .netbsd, .dragonfly => struct { // file_table: FileTable, // table_lock: event.Lock, // @@ -831,7 +839,7 @@ fn hashString(s: []const u16) u32 { // return self; // }, // -// .macosx, .freebsd, .netbsd => { +// .macosx, .freebsd, .netbsd, .dragonfly => { // const self = try loop.allocator.create(Self); // errdefer loop.allocator.destroy(self); // @@ -851,7 +859,7 @@ fn hashString(s: []const u16) u32 { // /// All addFile calls and removeFile calls must have completed. // pub fn destroy(self: *Self) void { // switch (builtin.os) { -// .macosx, .freebsd, .netbsd => { +// .macosx, .freebsd, .netbsd, .dragonfly => { // // TODO we need to cancel the frames before destroying the lock // self.os_data.table_lock.deinit(); // var it = self.os_data.file_table.iterator(); @@ -893,7 +901,7 @@ fn hashString(s: []const u16) u32 { // // pub async fn addFile(self: *Self, file_path: []const u8, value: V) !?V { // switch (builtin.os) { -// .macosx, .freebsd, .netbsd => return await (async addFileKEvent(self, file_path, value) catch unreachable), +// .macosx, .freebsd, .netbsd, .dragonfly => return await (async addFileKEvent(self, file_path, value) catch unreachable), // .linux => return await (async addFileLinux(self, file_path, value) catch unreachable), // .windows => return await (async addFileWindows(self, file_path, value) catch unreachable), // else => @compileError("Unsupported OS"), diff --git a/lib/std/event/group.zig b/lib/std/event/group.zig index f96b938f80..6991fb2fa6 100644 --- a/lib/std/event/group.zig +++ b/lib/std/event/group.zig @@ -81,6 +81,7 @@ pub fn Group(comptime ReturnType: type) type { } test "std.event.Group" { + if (builtin.os == .dragonfly) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/1908 if (builtin.single_threaded) return error.SkipZigTest; diff --git a/lib/std/event/lock.zig b/lib/std/event/lock.zig index fdcfd1e298..f86afdbf65 100644 --- a/lib/std/event/lock.zig +++ b/lib/std/event/lock.zig @@ -116,6 +116,7 @@ pub const Lock = struct { }; test "std.event.Lock" { + if (builtin.os == .dragonfly) return error.SkipZigTest; // TODO https://github.com/ziglang/zig/issues/1908 if (builtin.single_threaded) return error.SkipZigTest; // TODO https://github.com/ziglang/zig/issues/3251 diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig index d0d36abc0c..22013edba6 100644 --- a/lib/std/event/loop.zig +++ b/lib/std/event/loop.zig @@ -51,7 +51,7 @@ pub const Loop = struct { }; pub const EventFd = switch (builtin.os) { - .macosx, .freebsd, .netbsd => KEventFd, + .macosx, .freebsd, .netbsd, .dragonfly => KEventFd, .linux => struct { base: ResumeNode, epoll_op: u32, @@ -70,7 +70,7 @@ pub const Loop = struct { }; pub const Basic = switch (builtin.os) { - .macosx, .freebsd, .netbsd => KEventBasic, + .macosx, .freebsd, .netbsd, .dragonfly => KEventBasic, .linux => struct { base: ResumeNode, }, @@ -244,7 +244,7 @@ pub const Loop = struct { self.extra_threads[extra_thread_index] = try Thread.spawn(self, workerRun); } }, - .macosx, .freebsd, .netbsd => { + .macosx, .freebsd, .netbsd, .dragonfly => { self.os_data.kqfd = try os.kqueue(); errdefer os.close(self.os_data.kqfd); @@ -409,7 +409,7 @@ pub const Loop = struct { os.close(self.os_data.epollfd); self.allocator.free(self.eventfd_resume_nodes); }, - .macosx, .freebsd, .netbsd => { + .macosx, .freebsd, .netbsd, .dragonfly => { os.close(self.os_data.kqfd); os.close(self.os_data.fs_kqfd); }, @@ -523,7 +523,7 @@ pub const Loop = struct { const eventfd_node = &resume_stack_node.data; eventfd_node.base.handle = next_tick_node.data; switch (builtin.os) { - .macosx, .freebsd, .netbsd => { + .macosx, .freebsd, .netbsd, .dragonfly => { const kevent_array = (*const [1]os.Kevent)(&eventfd_node.kevent); const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; _ = os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null) catch { @@ -587,6 +587,7 @@ pub const Loop = struct { .macosx, .freebsd, .netbsd, + .dragonfly, => self.os_data.fs_thread.wait(), else => {}, } @@ -644,7 +645,7 @@ pub const Loop = struct { os.write(self.os_data.final_eventfd, wakeup_bytes) catch unreachable; return; }, - .macosx, .freebsd, .netbsd => { + .macosx, .freebsd, .netbsd, .dragonfly => { self.posixFsRequest(&self.os_data.fs_end_request); const final_kevent = (*const [1]os.Kevent)(&self.os_data.final_kevent); const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; @@ -702,7 +703,7 @@ pub const Loop = struct { } } }, - .macosx, .freebsd, .netbsd => { + .macosx, .freebsd, .netbsd, .dragonfly => { var eventlist: [1]os.Kevent = undefined; const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; const count = os.kevent(self.os_data.kqfd, empty_kevs, eventlist[0..], null) catch unreachable; @@ -765,7 +766,7 @@ pub const Loop = struct { self.beginOneEvent(); // finished in posixFsRun after processing the msg self.os_data.fs_queue.put(request_node); switch (builtin.os) { - .macosx, .freebsd, .netbsd => { + .macosx, .freebsd, .netbsd, .dragonfly => { const fs_kevs = (*const [1]os.Kevent)(&self.os_data.fs_kevent_wake); const empty_kevs = ([*]os.Kevent)(undefined)[0..0]; _ = os.kevent(self.os_data.fs_kqfd, fs_kevs, empty_kevs, null) catch unreachable; @@ -838,7 +839,7 @@ pub const Loop = struct { else => unreachable, } }, - .macosx, .freebsd, .netbsd => { + .macosx, .freebsd, .netbsd, .dragonfly => { const fs_kevs = (*const [1]os.Kevent)(&self.os_data.fs_kevent_wait); var out_kevs: [1]os.Kevent = undefined; _ = os.kevent(self.os_data.fs_kqfd, fs_kevs, out_kevs[0..], null) catch unreachable; @@ -850,7 +851,7 @@ pub const Loop = struct { const OsData = switch (builtin.os) { .linux => LinuxOsData, - .macosx, .freebsd, .netbsd => KEventData, + .macosx, .freebsd, .netbsd, .dragonfly => KEventData, .windows => struct { io_port: windows.HANDLE, extra_thread_count: usize, diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 5517f6f280..a447267cf0 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -28,7 +28,7 @@ pub const GetAppDataDirError = @import("fs/get_app_data_dir.zig").GetAppDataDirE /// All file system operations which return a path are guaranteed to /// fit into a UTF-8 encoded array of this length. pub const MAX_PATH_BYTES = switch (builtin.os) { - .linux, .macosx, .ios, .freebsd, .netbsd => os.PATH_MAX, + .linux, .macosx, .ios, .freebsd, .netbsd, .dragonfly => os.PATH_MAX, // Each UTF-16LE character may be expanded to 3 UTF-8 bytes. // If it would require 4 UTF-8 bytes, then there would be a surrogate // pair in the UTF-16LE, and we (over)account 3 bytes for it that way. @@ -380,7 +380,7 @@ pub const Dir = struct { const IteratorError = error{AccessDenied} || os.UnexpectedError; pub const Iterator = switch (builtin.os) { - .macosx, .ios, .freebsd, .netbsd => struct { + .macosx, .ios, .freebsd, .netbsd, .dragonfly => struct { dir: Dir, seek: i64, buf: [8192]u8, // TODO align(@alignOf(os.dirent)), @@ -396,7 +396,7 @@ pub const Dir = struct { pub fn next(self: *Self) Error!?Entry { switch (builtin.os) { .macosx, .ios => return self.nextDarwin(), - .freebsd, .netbsd => return self.nextBsd(), + .freebsd, .netbsd, .dragonfly => return self.nextBsd(), else => @compileError("unimplemented"), } } @@ -630,7 +630,7 @@ pub const Dir = struct { pub fn iterate(self: Dir) Iterator { switch (builtin.os) { - .macosx, .ios, .freebsd, .netbsd => return Iterator{ + .macosx, .ios, .freebsd, .netbsd, .dragonfly => return Iterator{ .dir = self, .seek = 0, .index = 0, @@ -1162,7 +1162,7 @@ pub fn openSelfExe() OpenSelfExeError!File { test "openSelfExe" { switch (builtin.os) { - .linux, .macosx, .ios, .windows, .freebsd => (try openSelfExe()).close(), + .linux, .macosx, .ios, .windows, .freebsd, .dragonfly => (try openSelfExe()).close(), else => return error.SkipZigTest, // Unsupported OS. } } @@ -1188,7 +1188,7 @@ pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) SelfExePathError![]u8 { } switch (builtin.os) { .linux => return os.readlinkC(c"/proc/self/exe", out_buffer), - .freebsd => { + .freebsd, .dragonfly => { var mib = [4]c_int{ os.CTL_KERN, os.KERN_PROC, os.KERN_PROC_PATHNAME, -1 }; var out_len: usize = out_buffer.len; try os.sysctl(&mib, out_buffer, &out_len, null, 0); diff --git a/lib/std/fs/get_app_data_dir.zig b/lib/std/fs/get_app_data_dir.zig index cdab7703f8..657971dd90 100644 --- a/lib/std/fs/get_app_data_dir.zig +++ b/lib/std/fs/get_app_data_dir.zig @@ -44,7 +44,7 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD }; return fs.path.join(allocator, [_][]const u8{ home_dir, "Library", "Application Support", appname }); }, - .linux, .freebsd, .netbsd => { + .linux, .freebsd, .netbsd, .dragonfly => { const home_dir = os.getenv("HOME") orelse { // TODO look in /etc/passwd return error.AppDataDirUnavailable; diff --git a/lib/std/mutex.zig b/lib/std/mutex.zig index 5f3b9272d9..3eea8d0c71 100644 --- a/lib/std/mutex.zig +++ b/lib/std/mutex.zig @@ -130,6 +130,7 @@ const TestContext = struct { }; test "std.Mutex" { + if (builtin.os == .dragonfly) return error.SkipZigTest; var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024); defer std.heap.direct_allocator.free(plenty_of_memory); diff --git a/lib/std/os.zig b/lib/std/os.zig index 40041c8ef7..376beb1280 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -24,9 +24,10 @@ const dl = @import("dynamic_library.zig"); const MAX_PATH_BYTES = std.fs.MAX_PATH_BYTES; pub const darwin = @import("os/darwin.zig"); +pub const dragonfly = @import("os/dragonfly.zig"); pub const freebsd = @import("os/freebsd.zig"); -pub const linux = @import("os/linux.zig"); pub const netbsd = @import("os/netbsd.zig"); +pub const linux = @import("os/linux.zig"); pub const uefi = @import("os/uefi.zig"); pub const wasi = @import("os/wasi.zig"); pub const windows = @import("os/windows.zig"); @@ -55,6 +56,7 @@ pub const system = if (builtin.link_libc) std.c else switch (builtin.os) { .freebsd => freebsd, .linux => linux, .netbsd => netbsd, + .dragonfly => dragonfly, .wasi => wasi, .windows => windows, .zen => zen, diff --git a/lib/std/os/bits.zig b/lib/std/os/bits.zig index f16da2487b..6d6163b8fa 100644 --- a/lib/std/os/bits.zig +++ b/lib/std/os/bits.zig @@ -5,6 +5,7 @@ const builtin = @import("builtin"); pub usingnamespace switch (builtin.os) { .macosx, .ios, .tvos, .watchos => @import("bits/darwin.zig"), + .dragonfly => @import("bits/dragonfly.zig"), .freebsd => @import("bits/freebsd.zig"), .linux => @import("bits/linux.zig"), .netbsd => @import("bits/netbsd.zig"), diff --git a/lib/std/os/bits/darwin.zig b/lib/std/os/bits/darwin.zig index fe3156bb90..dce3ed4410 100644 --- a/lib/std/os/bits/darwin.zig +++ b/lib/std/os/bits/darwin.zig @@ -119,6 +119,10 @@ pub const dirent = extern struct { d_namlen: u16, d_type: u8, d_name: u8, // field address is address of first byte of name + + pub fn reclen(self: dirent) usize { + return self.d_reclen; + } }; pub const pthread_attr_t = extern struct { diff --git a/lib/std/os/bits/dragonfly.zig b/lib/std/os/bits/dragonfly.zig new file mode 100644 index 0000000000..9efc7297c8 --- /dev/null +++ b/lib/std/os/bits/dragonfly.zig @@ -0,0 +1,702 @@ +const std = @import("../../std.zig"); +const maxInt = std.math.maxInt; + +pub fn S_ISCHR(m: u32) bool { + return m & S_IFMT == S_IFCHR; +} +pub const fd_t = c_int; +pub const pid_t = c_int; +pub const off_t = c_long; + +pub const ENOTSUP = EOPNOTSUPP; +pub const EWOULDBLOCK = EAGAIN; +pub const EPERM = 1; +pub const ENOENT = 2; +pub const ESRCH = 3; +pub const EINTR = 4; +pub const EIO = 5; +pub const ENXIO = 6; +pub const E2BIG = 7; +pub const ENOEXEC = 8; +pub const EBADF = 9; +pub const ECHILD = 10; +pub const EDEADLK = 11; +pub const ENOMEM = 12; +pub const EACCES = 13; +pub const EFAULT = 14; +pub const ENOTBLK = 15; +pub const EBUSY = 16; +pub const EEXIST = 17; +pub const EXDEV = 18; +pub const ENODEV = 19; +pub const ENOTDIR = 20; +pub const EISDIR = 21; +pub const EINVAL = 22; +pub const ENFILE = 23; +pub const EMFILE = 24; +pub const ENOTTY = 25; +pub const ETXTBSY = 26; +pub const EFBIG = 27; +pub const ENOSPC = 28; +pub const ESPIPE = 29; +pub const EROFS = 30; +pub const EMLINK = 31; +pub const EPIPE = 32; +pub const EDOM = 33; +pub const ERANGE = 34; +pub const EAGAIN = 35; +pub const EINPROGRESS = 36; +pub const EALREADY = 37; +pub const ENOTSOCK = 38; +pub const EDESTADDRREQ = 39; +pub const EMSGSIZE = 40; +pub const EPROTOTYPE = 41; +pub const ENOPROTOOPT = 42; +pub const EPROTONOSUPPORT = 43; +pub const ESOCKTNOSUPPORT = 44; +pub const EOPNOTSUPP = 45; +pub const EPFNOSUPPORT = 46; +pub const EAFNOSUPPORT = 47; +pub const EADDRINUSE = 48; +pub const EADDRNOTAVAIL = 49; +pub const ENETDOWN = 50; +pub const ENETUNREACH = 51; +pub const ENETRESET = 52; +pub const ECONNABORTED = 53; +pub const ECONNRESET = 54; +pub const ENOBUFS = 55; +pub const EISCONN = 56; +pub const ENOTCONN = 57; +pub const ESHUTDOWN = 58; +pub const ETOOMANYREFS = 59; +pub const ETIMEDOUT = 60; +pub const ECONNREFUSED = 61; +pub const ELOOP = 62; +pub const ENAMETOOLONG = 63; +pub const EHOSTDOWN = 64; +pub const EHOSTUNREACH = 65; +pub const ENOTEMPTY = 66; +pub const EPROCLIM = 67; +pub const EUSERS = 68; +pub const EDQUOT = 69; +pub const ESTALE = 70; +pub const EREMOTE = 71; +pub const EBADRPC = 72; +pub const ERPCMISMATCH = 73; +pub const EPROGUNAVAIL = 74; +pub const EPROGMISMATCH = 75; +pub const EPROCUNAVAIL = 76; +pub const ENOLCK = 77; +pub const ENOSYS = 78; +pub const EFTYPE = 79; +pub const EAUTH = 80; +pub const ENEEDAUTH = 81; +pub const EIDRM = 82; +pub const ENOMSG = 83; +pub const EOVERFLOW = 84; +pub const ECANCELED = 85; +pub const EILSEQ = 86; +pub const ENOATTR = 87; +pub const EDOOFUS = 88; +pub const EBADMSG = 89; +pub const EMULTIHOP = 90; +pub const ENOLINK = 91; +pub const EPROTO = 92; +pub const ENOMEDIUM = 93; +pub const ELAST = 99; +pub const EASYNC = 99; + +pub const STDIN_FILENO = 0; +pub const STDOUT_FILENO = 1; +pub const STDERR_FILENO = 2; + +pub const PROT_NONE = 0; +pub const PROT_READ = 1; +pub const PROT_WRITE = 2; +pub const PROT_EXEC = 4; + +pub const MAP_FILE = 0; +pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); +pub const MAP_ANONYMOUS = MAP_ANON; +pub const MAP_COPY = MAP_PRIVATE; +pub const MAP_SHARED = 1; +pub const MAP_PRIVATE = 2; +pub const MAP_FIXED = 16; +pub const MAP_RENAME = 32; +pub const MAP_NORESERVE = 64; +pub const MAP_INHERIT = 128; +pub const MAP_NOEXTEND = 256; +pub const MAP_HASSEMAPHORE = 512; +pub const MAP_STACK = 1024; +pub const MAP_NOSYNC = 2048; +pub const MAP_ANON = 4096; +pub const MAP_VPAGETABLE = 8192; +pub const MAP_TRYFIXED = 65536; +pub const MAP_NOCORE = 131072; +pub const MAP_SIZEALIGN = 262144; + +pub const PATH_MAX = 1024; + +pub const Stat = extern struct { + ino: c_ulong, + nlink: c_uint, + dev: c_uint, + mode: c_ushort, + padding1: u16, + uid: c_uint, + gid: c_uint, + rdev: c_uint, + atim: timespec, + mtim: timespec, + ctim: timespec, + size: c_ulong, + blocks: i64, + blksize: u32, + flags: u32, + gen: u32, + lspare: i32, + qspare1: i64, + qspare2: i64, + pub fn atime(self: Stat) timespec { + return self.atim; + } + + pub fn mtime(self: Stat) timespec { + return self.mtim; + } + + pub fn ctime(self: Stat) timespec { + return self.ctim; + } +}; + +pub const timespec = extern struct { + tv_sec: c_long, + tv_nsec: c_long, +}; + +pub const CTL_UNSPEC = 0; +pub const CTL_KERN = 1; +pub const CTL_VM = 2; +pub const CTL_VFS = 3; +pub const CTL_NET = 4; +pub const CTL_DEBUG = 5; +pub const CTL_HW = 6; +pub const CTL_MACHDEP = 7; +pub const CTL_USER = 8; +pub const CTL_LWKT = 10; +pub const CTL_MAXID = 11; +pub const CTL_MAXNAME = 12; + +pub const KERN_PROC_ALL = 0; +pub const KERN_OSTYPE = 1; +pub const KERN_PROC_PID = 1; +pub const KERN_OSRELEASE = 2; +pub const KERN_PROC_PGRP = 2; +pub const KERN_OSREV = 3; +pub const KERN_PROC_SESSION = 3; +pub const KERN_VERSION = 4; +pub const KERN_PROC_TTY = 4; +pub const KERN_MAXVNODES = 5; +pub const KERN_PROC_UID = 5; +pub const KERN_MAXPROC = 6; +pub const KERN_PROC_RUID = 6; +pub const KERN_MAXFILES = 7; +pub const KERN_PROC_ARGS = 7; +pub const KERN_ARGMAX = 8; +pub const KERN_PROC_CWD = 8; +pub const KERN_PROC_PATHNAME = 9; +pub const KERN_SECURELVL = 9; +pub const KERN_PROC_SIGTRAMP = 10; +pub const KERN_HOSTNAME = 10; +pub const KERN_HOSTID = 11; +pub const KERN_CLOCKRATE = 12; +pub const KERN_VNODE = 13; +pub const KERN_PROC = 14; +pub const KERN_FILE = 15; +pub const KERN_PROC_FLAGMASK = 16; +pub const KERN_PROF = 16; +pub const KERN_PROC_FLAG_LWP = 16; +pub const KERN_POSIX1 = 17; +pub const KERN_NGROUPS = 18; +pub const KERN_JOB_CONTROL = 19; +pub const KERN_SAVED_IDS = 20; +pub const KERN_BOOTTIME = 21; +pub const KERN_NISDOMAINNAME = 22; +pub const KERN_UPDATEINTERVAL = 23; +pub const KERN_OSRELDATE = 24; +pub const KERN_NTP_PLL = 25; +pub const KERN_BOOTFILE = 26; +pub const KERN_MAXFILESPERPROC = 27; +pub const KERN_MAXPROCPERUID = 28; +pub const KERN_DUMPDEV = 29; +pub const KERN_IPC = 30; +pub const KERN_DUMMY = 31; +pub const KERN_PS_STRINGS = 32; +pub const KERN_USRSTACK = 33; +pub const KERN_LOGSIGEXIT = 34; +pub const KERN_IOV_MAX = 35; +pub const KERN_MAXPOSIXLOCKSPERUID = 36; +pub const KERN_MAXID = 37; + +pub const HOST_NAME_MAX = 255; + +pub const O_LARGEFILE = 0; // faked support +pub const O_RDONLY = 0; +pub const O_NDELAY = O_NONBLOCK; +pub const O_WRONLY = 1; +pub const O_RDWR = 2; +pub const O_ACCMODE = 3; +pub const O_NONBLOCK = 4; +pub const O_APPEND = 8; +pub const O_SHLOCK = 16; +pub const O_EXLOCK = 32; +pub const O_ASYNC = 64; +pub const O_FSYNC = 128; +pub const O_SYNC = 128; +pub const O_NOFOLLOW = 256; +pub const O_CREAT = 512; +pub const O_TRUNC = 1024; +pub const O_EXCL = 2048; +pub const O_NOCTTY = 32768; +pub const O_DIRECT = 65536; +pub const O_CLOEXEC = 131072; +pub const O_FBLOCKING = 262144; +pub const O_FNONBLOCKING = 524288; +pub const O_FAPPEND = 1048576; +pub const O_FOFFSET = 2097152; +pub const O_FSYNCWRITE = 4194304; +pub const O_FASYNCWRITE = 8388608; +pub const O_DIRECTORY = 134217728; + +pub const SEEK_SET = 0; +pub const SEEK_CUR = 1; +pub const SEEK_END = 2; +pub const SEEK_DATA = 3; +pub const SEEK_HOLE = 4; + +pub const F_OK = 0; +pub const F_ULOCK = 0; +pub const F_LOCK = 1; +pub const F_TLOCK = 2; +pub const F_TEST = 3; + +pub const AT_FDCWD = -328243; +pub const AT_SYMLINK_NOFOLLOW = 1; +pub const AT_REMOVEDIR = 2; +pub const AT_EACCESS = 4; +pub const AT_SYMLINK_FOLLOW = 8; + +pub fn WEXITSTATUS(s: u32) u32 { + return (s & 0xff00) >> 8; +} +pub fn WTERMSIG(s: u32) u32 { + return s & 0x7f; +} +pub fn WSTOPSIG(s: u32) u32 { + return WEXITSTATUS(s); +} +pub fn WIFEXITED(s: u32) bool { + return WTERMSIG(s) == 0; +} +pub fn WIFSTOPPED(s: u32) bool { + return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; +} +pub fn WIFSIGNALED(s: u32) bool { + return (s & 0xffff) -% 1 < 0xff; +} + +pub const dirent = extern struct { + d_fileno: c_ulong, + d_namlen: u16, + d_type: u8, + d_unused1: u8, + d_unused2: u32, + d_name: [256]u8, + + pub fn reclen(self: dirent) usize { + return (@byteOffsetOf(dirent, "d_name") + self.d_namlen + 1 + 7) & ~usize(7); + } +}; + +pub const DT_UNKNOWN = 0; +pub const DT_FIFO = 1; +pub const DT_CHR = 2; +pub const DT_DIR = 4; +pub const DT_BLK = 6; +pub const DT_REG = 8; +pub const DT_LNK = 10; +pub const DT_SOCK = 12; +pub const DT_WHT = 14; +pub const DT_DBF = 15; + +pub const CLOCK_REALTIME = 0; +pub const CLOCK_VIRTUAL = 1; +pub const CLOCK_PROF = 2; +pub const CLOCK_MONOTONIC = 4; +pub const CLOCK_UPTIME = 5; +pub const CLOCK_UPTIME_PRECISE = 7; +pub const CLOCK_UPTIME_FAST = 8; +pub const CLOCK_REALTIME_PRECISE = 9; +pub const CLOCK_REALTIME_FAST = 10; +pub const CLOCK_MONOTONIC_PRECISE = 11; +pub const CLOCK_MONOTONIC_FAST = 12; +pub const CLOCK_SECOND = 13; +pub const CLOCK_THREAD_CPUTIME_ID = 14; +pub const CLOCK_PROCESS_CPUTIME_ID = 15; + +pub const sockaddr = extern struct { + sa_len: u8, + sa_family: u8, + sa_data: [14]u8, +}; + +pub const Kevent = extern struct { + ident: usize, + filter: c_short, + flags: c_ushort, + fflags: c_uint, + data: isize, + udata: usize, +}; + +pub const pthread_attr_t = extern struct { // copied from freebsd + __size: [56]u8, + __align: c_long, +}; + +pub const EVFILT_FS = -10; +pub const EVFILT_USER = -9; +pub const EVFILT_EXCEPT = -8; +pub const EVFILT_TIMER = -7; +pub const EVFILT_SIGNAL = -6; +pub const EVFILT_PROC = -5; +pub const EVFILT_VNODE = -4; +pub const EVFILT_AIO = -3; +pub const EVFILT_WRITE = -2; +pub const EVFILT_READ = -1; +pub const EVFILT_SYSCOUNT = 10; +pub const EVFILT_MARKER = 15; + +pub const EV_ADD = 1; +pub const EV_DELETE = 2; +pub const EV_ENABLE = 4; +pub const EV_DISABLE = 8; +pub const EV_ONESHOT = 16; +pub const EV_CLEAR = 32; +pub const EV_RECEIPT = 64; +pub const EV_DISPATCH = 128; +pub const EV_NODATA = 4096; +pub const EV_FLAG1 = 8192; +pub const EV_ERROR = 16384; +pub const EV_EOF = 32768; +pub const EV_SYSFLAGS = 61440; + +pub const NOTE_FFNOP = 0; +pub const NOTE_TRACK = 1; +pub const NOTE_DELETE = 1; +pub const NOTE_LOWAT = 1; +pub const NOTE_TRACKERR = 2; +pub const NOTE_OOB = 2; +pub const NOTE_WRITE = 2; +pub const NOTE_EXTEND = 4; +pub const NOTE_CHILD = 4; +pub const NOTE_ATTRIB = 8; +pub const NOTE_LINK = 16; +pub const NOTE_RENAME = 32; +pub const NOTE_REVOKE = 64; +pub const NOTE_PDATAMASK = 1048575; +pub const NOTE_FFLAGSMASK = 16777215; +pub const NOTE_TRIGGER = 16777216; +pub const NOTE_EXEC = 536870912; +pub const NOTE_FFAND = 1073741824; +pub const NOTE_FORK = 1073741824; +pub const NOTE_EXIT = 2147483648; +pub const NOTE_FFOR = 2147483648; +pub const NOTE_FFCTRLMASK = 3221225472; +pub const NOTE_FFCOPY = 3221225472; +pub const NOTE_PCTRLMASK = 4026531840; + +pub const stack_t = extern struct { + ss_sp: [*]u8, + ss_size: isize, + ss_flags: i32, +}; + +pub const S_IREAD = S_IRUSR; +pub const S_IEXEC = S_IXUSR; +pub const S_IWRITE = S_IWUSR; +pub const S_IXOTH = 1; +pub const S_IWOTH = 2; +pub const S_IROTH = 4; +pub const S_IRWXO = 7; +pub const S_IXGRP = 8; +pub const S_IWGRP = 16; +pub const S_IRGRP = 32; +pub const S_IRWXG = 56; +pub const S_IXUSR = 64; +pub const S_IWUSR = 128; +pub const S_IRUSR = 256; +pub const S_IRWXU = 448; +pub const S_ISTXT = 512; +pub const S_BLKSIZE = 512; +pub const S_ISVTX = 512; +pub const S_ISGID = 1024; +pub const S_ISUID = 2048; +pub const S_IFIFO = 4096; +pub const S_IFCHR = 8192; +pub const S_IFDIR = 16384; +pub const S_IFBLK = 24576; +pub const S_IFREG = 32768; +pub const S_IFDB = 36864; +pub const S_IFLNK = 40960; +pub const S_IFSOCK = 49152; +pub const S_IFWHT = 57344; +pub const S_IFMT = 61440; + +pub const SIG_ERR = @intToPtr(extern fn (i32) void, maxInt(usize)); +pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0); +pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1); +pub const BADSIG = SIG_ERR; +pub const SIG_BLOCK = 1; +pub const SIG_UNBLOCK = 2; +pub const SIG_SETMASK = 3; + +pub const SIGIOT = SIGABRT; +pub const SIGHUP = 1; +pub const SIGINT = 2; +pub const SIGQUIT = 3; +pub const SIGILL = 4; +pub const SIGTRAP = 5; +pub const SIGABRT = 6; +pub const SIGEMT = 7; +pub const SIGFPE = 8; +pub const SIGKILL = 9; +pub const SIGBUS = 10; +pub const SIGSEGV = 11; +pub const SIGSYS = 12; +pub const SIGPIPE = 13; +pub const SIGALRM = 14; +pub const SIGTERM = 15; +pub const SIGURG = 16; +pub const SIGSTOP = 17; +pub const SIGTSTP = 18; +pub const SIGCONT = 19; +pub const SIGCHLD = 20; +pub const SIGTTIN = 21; +pub const SIGTTOU = 22; +pub const SIGIO = 23; +pub const SIGXCPU = 24; +pub const SIGXFSZ = 25; +pub const SIGVTALRM = 26; +pub const SIGPROF = 27; +pub const SIGWINCH = 28; +pub const SIGINFO = 29; +pub const SIGUSR1 = 30; +pub const SIGUSR2 = 31; +pub const SIGTHR = 32; +pub const SIGCKPT = 33; +pub const SIGCKPTEXIT = 34; +pub const siginfo_t = extern struct { + si_signo: c_int, + si_errno: c_int, + si_code: c_int, + si_pid: c_int, + si_uid: c_uint, + si_status: c_int, + si_addr: ?*c_void, + si_value: union_sigval, + si_band: c_long, + __spare__: [7]c_int, +}; +pub const sigset_t = extern struct { + __bits: [4]c_uint, +}; +pub const sig_atomic_t = c_int; +pub const Sigaction = extern struct { + __sigaction_u: extern union { + __sa_handler: ?extern fn(c_int) void, + __sa_sigaction: ?extern fn(c_int, [*c]siginfo_t, ?*c_void) void, + }, + sa_flags: c_int, + sa_mask: sigset_t, +}; +pub const sig_t = [*c]extern fn(c_int) void; + +pub const sigvec = extern struct { + sv_handler: [*c]__sighandler_t, + sv_mask: c_int, + sv_flags: c_int, +}; + +pub const SOCK_STREAM = 1; +pub const SOCK_DGRAM = 2; +pub const SOCK_RAW = 3; +pub const SOCK_RDM = 4; +pub const SOCK_SEQPACKET = 5; +pub const SOCK_MAXADDRLEN = 255; +pub const SOCK_CLOEXEC = 268435456; +pub const SOCK_NONBLOCK = 536870912; + +pub const PF_INET6 = AF_INET6; +pub const PF_IMPLINK = AF_IMPLINK; +pub const PF_ROUTE = AF_ROUTE; +pub const PF_ISO = AF_ISO; +pub const PF_PIP = pseudo_AF_PIP; +pub const PF_CHAOS = AF_CHAOS; +pub const PF_DATAKIT = AF_DATAKIT; +pub const PF_INET = AF_INET; +pub const PF_APPLETALK = AF_APPLETALK; +pub const PF_SIP = AF_SIP; +pub const PF_OSI = AF_ISO; +pub const PF_CNT = AF_CNT; +pub const PF_LINK = AF_LINK; +pub const PF_HYLINK = AF_HYLINK; +pub const PF_MAX = AF_MAX; +pub const PF_KEY = pseudo_AF_KEY; +pub const PF_PUP = AF_PUP; +pub const PF_COIP = AF_COIP; +pub const PF_SNA = AF_SNA; +pub const PF_LOCAL = AF_LOCAL; +pub const PF_NETBIOS = AF_NETBIOS; +pub const PF_NATM = AF_NATM; +pub const PF_BLUETOOTH = AF_BLUETOOTH; +pub const PF_UNSPEC = AF_UNSPEC; +pub const PF_NETGRAPH = AF_NETGRAPH; +pub const PF_ECMA = AF_ECMA; +pub const PF_IPX = AF_IPX; +pub const PF_DLI = AF_DLI; +pub const PF_ATM = AF_ATM; +pub const PF_CCITT = AF_CCITT; +pub const PF_ISDN = AF_ISDN; +pub const PF_RTIP = pseudo_AF_RTIP; +pub const PF_LAT = AF_LAT; +pub const PF_UNIX = PF_LOCAL; +pub const PF_XTP = pseudo_AF_XTP; +pub const PF_DECnet = AF_DECnet; + +pub const AF_UNSPEC = 0; +pub const AF_OSI = AF_ISO; +pub const AF_UNIX = AF_LOCAL; +pub const AF_LOCAL = 1; +pub const AF_INET = 2; +pub const AF_IMPLINK = 3; +pub const AF_PUP = 4; +pub const AF_CHAOS = 5; +pub const AF_NETBIOS = 6; +pub const AF_ISO = 7; +pub const AF_ECMA = 8; +pub const AF_DATAKIT = 9; +pub const AF_CCITT = 10; +pub const AF_SNA = 11; +pub const AF_DLI = 13; +pub const AF_LAT = 14; +pub const AF_HYLINK = 15; +pub const AF_APPLETALK = 16; +pub const AF_ROUTE = 17; +pub const AF_LINK = 18; +pub const AF_COIP = 20; +pub const AF_CNT = 21; +pub const AF_IPX = 23; +pub const AF_SIP = 24; +pub const AF_ISDN = 26; +pub const AF_NATM = 29; +pub const AF_ATM = 30; +pub const AF_NETGRAPH = 32; +pub const AF_BLUETOOTH = 33; +pub const AF_MPLS = 34; +pub const AF_MAX = 36; + +pub const sa_family_t = u8; +pub const socklen_t = c_uint; +pub const sockaddr_storage = extern struct { + ss_len: u8, + ss_family: sa_family_t, + __ss_pad1: [6]u8, + __ss_align: i64, + __ss_pad2: [112]u8, +}; +pub const dl_phdr_info = extern struct { + dlpi_addr: usize, + dlpi_name: ?[*]const u8, + dlpi_phdr: [*]std.elf.Phdr, + dlpi_phnum: u16, +}; +pub const msghdr = extern struct { + msg_name: ?*c_void, + msg_namelen: socklen_t, + msg_iov: [*c]iovec, + msg_iovlen: c_int, + msg_control: ?*c_void, + msg_controllen: socklen_t, + msg_flags: c_int, +}; +pub const cmsghdr = extern struct { + cmsg_len: socklen_t, + cmsg_level: c_int, + cmsg_type: c_int, +}; +pub const cmsgcred = extern struct { + cmcred_pid: pid_t, + cmcred_uid: uid_t, + cmcred_euid: uid_t, + cmcred_gid: gid_t, + cmcred_ngroups: c_short, + cmcred_groups: [16]gid_t, +}; +pub const sf_hdtr = extern struct { + headers: [*c]iovec, + hdr_cnt: c_int, + trailers: [*c]iovec, + trl_cnt: c_int, +}; + +pub const MS_SYNC = 0; +pub const MS_ASYNC = 1; +pub const MS_INVALIDATE = 2; + +pub const POSIX_MADV_SEQUENTIAL = 2; +pub const POSIX_MADV_RANDOM = 1; +pub const POSIX_MADV_DONTNEED = 4; +pub const POSIX_MADV_NORMAL = 0; +pub const POSIX_MADV_WILLNEED = 3; + +pub const MADV_SEQUENTIAL = 2; +pub const MADV_CONTROL_END = MADV_SETMAP; +pub const MADV_DONTNEED = 4; +pub const MADV_RANDOM = 1; +pub const MADV_WILLNEED = 3; +pub const MADV_NORMAL = 0; +pub const MADV_CONTROL_START = MADV_INVAL; +pub const MADV_FREE = 5; +pub const MADV_NOSYNC = 6; +pub const MADV_AUTOSYNC = 7; +pub const MADV_NOCORE = 8; +pub const MADV_CORE = 9; +pub const MADV_INVAL = 10; +pub const MADV_SETMAP = 11; + +pub const F_DUPFD = 0; +pub const F_GETFD = 1; +pub const F_RDLCK = 1; +pub const F_SETFD = 2; +pub const F_UNLCK = 2; +pub const F_WRLCK = 3; +pub const F_GETFL = 3; +pub const F_SETFL = 4; +pub const F_GETOWN = 5; +pub const F_SETOWN = 6; +pub const F_GETLK = 7; +pub const F_SETLK = 8; +pub const F_SETLKW = 9; +pub const F_DUP2FD = 10; +pub const F_DUPFD_CLOEXEC = 17; +pub const F_DUP2FD_CLOEXEC = 18; + +pub const Flock = extern struct { + l_start: off_t, + l_len: off_t, + l_pid: pid_t, + l_type: c_short, + l_whence: c_short, +}; diff --git a/lib/std/os/bits/freebsd.zig b/lib/std/os/bits/freebsd.zig index 4427acb334..dbe556154f 100644 --- a/lib/std/os/bits/freebsd.zig +++ b/lib/std/os/bits/freebsd.zig @@ -132,6 +132,10 @@ pub const dirent = extern struct { d_namlen: u16, d_pad1: u16, d_name: [256]u8, + + pub fn reclen(self: dirent) usize { + return self.d_reclen; + } }; pub const in_port_t = u16; diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig index d2d521a005..a1898a5151 100644 --- a/lib/std/os/bits/linux.zig +++ b/lib/std/os/bits/linux.zig @@ -1023,6 +1023,10 @@ pub const dirent64 = extern struct { d_reclen: u16, d_type: u8, d_name: u8, // field address is the address of first byte of name https://github.com/ziglang/zig/issues/173 + + pub fn reclen(self: dirent) usize { + return self.d_reclen; + } }; pub const dl_phdr_info = extern struct { diff --git a/lib/std/os/bits/netbsd.zig b/lib/std/os/bits/netbsd.zig index 14c35faf6c..50d6883a58 100644 --- a/lib/std/os/bits/netbsd.zig +++ b/lib/std/os/bits/netbsd.zig @@ -128,6 +128,10 @@ pub const dirent = extern struct { d_type: u8, d_off: i64, d_name: [512]u8, + + pub fn reclen(self: dirent) usize { + return self.d_reclen; + } }; pub const in_port_t = u16; diff --git a/lib/std/os/dragonfly.zig b/lib/std/os/dragonfly.zig new file mode 100644 index 0000000000..5f9684b96d --- /dev/null +++ b/lib/std/os/dragonfly.zig @@ -0,0 +1,3 @@ +const std = @import("../std.zig"); +pub usingnamespace std.c; +pub usingnamespace @import("bits.zig"); diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig index 1d61548396..534ebfac9d 100644 --- a/lib/std/os/test.zig +++ b/lib/std/os/test.zig @@ -16,6 +16,7 @@ const AtomicRmwOp = builtin.AtomicRmwOp; const AtomicOrder = builtin.AtomicOrder; test "makePath, put some files in it, deleteTree" { + if (builtin.os == .dragonfly) return error.SkipZigTest; try fs.makePath(a, "os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c"); try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c" ++ fs.path.sep_str ++ "file.txt", "nonsense"); 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" { } test "access file" { + if (builtin.os == .dragonfly) return error.SkipZigTest; try fs.makePath(a, "os_test_tmp"); if (File.access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt")) |ok| { @panic("expected error"); @@ -95,6 +97,7 @@ test "cpu count" { } test "AtomicFile" { + if (builtin.os == .dragonfly) return error.SkipZigTest; var buffer: [1024]u8 = undefined; const allocator = &std.heap.FixedBufferAllocator.init(buffer[0..]).allocator; const test_out_file = "tmp_atomic_file_test_dest.txt"; @@ -115,6 +118,7 @@ test "AtomicFile" { } test "thread local storage" { + if (builtin.os == .dragonfly) return error.SkipZigTest; if (builtin.single_threaded) return error.SkipZigTest; const thread1 = try Thread.spawn({}, testTls); const thread2 = try Thread.spawn({}, testTls); diff --git a/lib/std/statically_initialized_mutex.zig b/lib/std/statically_initialized_mutex.zig index 2ad47b5d91..31ef643384 100644 --- a/lib/std/statically_initialized_mutex.zig +++ b/lib/std/statically_initialized_mutex.zig @@ -61,6 +61,7 @@ pub const StaticallyInitializedMutex = switch (builtin.os) { }; test "std.StaticallyInitializedMutex" { + if (builtin.os == .dragonfly) return error.SkipZigTest; const TestContext = struct { data: i128, diff --git a/src/libc_installation.cpp b/src/libc_installation.cpp index 135941dc40..6ae6bb9075 100644 --- a/src/libc_installation.cpp +++ b/src/libc_installation.cpp @@ -320,7 +320,7 @@ Error zig_libc_cc_print_file_name(const char *o_file, Buf *out, bool want_dirnam #undef CC_EXE -#if defined(ZIG_OS_WINDOWS) || defined(ZIG_OS_LINUX) +#if defined(ZIG_OS_WINDOWS) || defined(ZIG_OS_LINUX) || defined(ZIG_OS_DRAGONFLY) static Error zig_libc_find_native_crt_dir_posix(ZigLibCInstallation *self, bool verbose) { return zig_libc_cc_print_file_name("crt1.o", &self->crt_dir, true, verbose); } @@ -413,6 +413,7 @@ void zig_libc_render(ZigLibCInstallation *self, FILE *file) { "# The directory that contains `stdlib.h`.\n" "# On POSIX-like systems, include directories be found with: `cc -E -Wp,-v -xc /dev/null`\n" "include_dir=%s\n" + "\n" "# The system-specific include directory. May be the same as `include_dir`.\n" "# On Windows it's the directory that includes `vcruntime.h`.\n" "# On POSIX it's the directory that includes `sys/errno.h`.\n" @@ -435,8 +436,7 @@ void zig_libc_render(ZigLibCInstallation *self, FILE *file) { "# The directory that contains `kernel32.lib`.\n" "# Only needed when targeting MSVC on Windows.\n" "kernel32_lib_dir=%s\n" - "\n" - , + "\n", buf_ptr(&self->include_dir), buf_ptr(&self->sys_include_dir), buf_ptr(&self->crt_dir), @@ -489,7 +489,7 @@ Error zig_libc_find_native(ZigLibCInstallation *self, bool verbose) { return err; #if defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) buf_init_from_str(&self->crt_dir, "/usr/lib"); -#elif defined(ZIG_OS_LINUX) +#elif defined(ZIG_OS_LINUX) || defined(ZIG_OS_DRAGONFLY) if ((err = zig_libc_find_native_crt_dir_posix(self, verbose))) return err; #endif diff --git a/src/link.cpp b/src/link.cpp index 664e83e8b1..c115ffe2fd 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -1792,28 +1792,12 @@ static void construct_linker_job_elf(LinkJob *lj) { if (g->libc != nullptr) { if (!g->have_dynamic_link) { lj->args.append("--start-group"); - if (!target_is_android(g->zig_target)) { - lj->args.append("-lgcc"); - lj->args.append("-lgcc_eh"); - } lj->args.append("-lc"); lj->args.append("-lm"); lj->args.append("--end-group"); } else { - if (!target_is_android(g->zig_target)) { - lj->args.append("-lgcc"); - lj->args.append("--as-needed"); - lj->args.append("-lgcc_s"); - lj->args.append("--no-as-needed"); - } lj->args.append("-lc"); lj->args.append("-lm"); - if (!target_is_android(g->zig_target)) { - lj->args.append("-lgcc"); - lj->args.append("--as-needed"); - lj->args.append("-lgcc_s"); - lj->args.append("--no-as-needed"); - } } if (g->zig_target->os == OsFreeBSD) { diff --git a/src/os.cpp b/src/os.cpp index 6dc3777f8c..908c3b47d9 100644 --- a/src/os.cpp +++ b/src/os.cpp @@ -52,7 +52,7 @@ typedef SSIZE_T ssize_t; #endif -#if defined(ZIG_OS_LINUX) || defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) +#if defined(ZIG_OS_LINUX) || defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) || defined(ZIG_OS_DRAGONFLY) #include #endif @@ -60,7 +60,7 @@ typedef SSIZE_T ssize_t; #include #endif -#if defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) +#if defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) || defined(ZIG_OS_DRAGONFLY) #include #endif @@ -85,7 +85,7 @@ static clock_serv_t macos_monotonic_clock; #if defined(__APPLE__) && !defined(environ) #include #define environ (*_NSGetEnviron()) -#elif defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) +#elif defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) || defined(ZIG_OS_DRAGONFLY) extern char **environ; #endif @@ -1450,7 +1450,7 @@ Error os_self_exe_path(Buf *out_path) { } buf_resize(out_path, amt); return ErrorNone; -#elif defined(ZIG_OS_FREEBSD) +#elif defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_DRAGONFLY) buf_resize(out_path, PATH_MAX); int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; size_t cb = PATH_MAX; @@ -1792,7 +1792,7 @@ Error os_get_app_data_dir(Buf *out_path, const char *appname) { } -#if defined(ZIG_OS_LINUX) || defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) +#if defined(ZIG_OS_LINUX) || defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) || defined(ZIG_OS_DRAGONFLY) static int self_exe_shared_libs_callback(struct dl_phdr_info *info, size_t size, void *data) { ZigList *libs = reinterpret_cast< ZigList *>(data); if (info->dlpi_name[0] == '/') { @@ -1803,7 +1803,7 @@ static int self_exe_shared_libs_callback(struct dl_phdr_info *info, size_t size, #endif Error os_self_exe_shared_libs(ZigList &paths) { -#if defined(ZIG_OS_LINUX) || defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) +#if defined(ZIG_OS_LINUX) || defined(ZIG_OS_FREEBSD) || defined(ZIG_OS_NETBSD) || defined(ZIG_OS_DRAGONFLY) paths.resize(0); dl_iterate_phdr(self_exe_shared_libs_callback, &paths); return ErrorNone; diff --git a/src/os.hpp b/src/os.hpp index afeef10e0c..7da846a509 100644 --- a/src/os.hpp +++ b/src/os.hpp @@ -27,6 +27,8 @@ #define ZIG_OS_FREEBSD #elif defined(__NetBSD__) #define ZIG_OS_NETBSD +#elif defined(__DragonFly__) +#define ZIG_OS_DRAGONFLY #else #define ZIG_OS_UNKNOWN #endif diff --git a/src/target.cpp b/src/target.cpp index 9af42b7d9d..8fd7d7055f 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -1050,6 +1050,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { case OsZen: case OsFreeBSD: case OsNetBSD: + case OsDragonFly: case OsOpenBSD: case OsWASI: case OsEmscripten: @@ -1104,7 +1105,6 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { } case OsAnanas: case OsCloudABI: - case OsDragonFly: case OsKFreeBSD: case OsLv2: case OsSolaris: @@ -1267,6 +1267,8 @@ const char *target_dynamic_linker(const ZigTarget *target) { return "/libexec/ld-elf.so.1"; case OsNetBSD: return "/libexec/ld.elf_so"; + case OsDragonFly: + return "/libexec/ld-elf.so.2"; case OsLinux: { const ZigLLVM_EnvironmentType abi = target->abi; switch (target->arch) { @@ -1383,7 +1385,6 @@ const char *target_dynamic_linker(const ZigTarget *target) { case OsAnanas: case OsCloudABI: - case OsDragonFly: case OsFuchsia: case OsKFreeBSD: case OsLv2: @@ -1579,7 +1580,7 @@ bool target_os_requires_libc(Os os) { // On Darwin, we always link libSystem which contains libc. // Similarly on FreeBSD and NetBSD we always link system libc // since this is the stable syscall interface. - return (target_os_is_darwin(os) || os == OsFreeBSD || os == OsNetBSD); + return (target_os_is_darwin(os) || os == OsFreeBSD || os == OsNetBSD || os == OsDragonFly); } bool target_supports_fpic(const ZigTarget *target) { @@ -1636,7 +1637,6 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) { case OsFreestanding: case OsAnanas: case OsCloudABI: - case OsDragonFly: case OsLv2: case OsSolaris: case OsHaiku: @@ -1665,6 +1665,7 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) { case OsFuchsia: case OsKFreeBSD: case OsNetBSD: + case OsDragonFly: case OsHurd: return ZigLLVM_GNU; case OsUefi: diff --git a/test/stage1/behavior/byteswap.zig b/test/stage1/behavior/byteswap.zig index 449fad67ae..4ba421679d 100644 --- a/test/stage1/behavior/byteswap.zig +++ b/test/stage1/behavior/byteswap.zig @@ -1,5 +1,6 @@ const std = @import("std"); const expect = std.testing.expect; +const builtin = @import("builtin"); test "@byteSwap integers" { const ByteSwapIntTest = struct { @@ -40,6 +41,7 @@ test "@byteSwap integers" { test "@byteSwap vectors" { // Disabled because of #3317 + if (builtin.os == .dragonfly) return error.SkipZigTest; if (@import("builtin").arch == .mipsel) return error.SkipZigTest; const ByteSwapVectorTest = struct { diff --git a/test/stage1/behavior/vector.zig b/test/stage1/behavior/vector.zig index d3a771fca8..dd8e5f1f7e 100644 --- a/test/stage1/behavior/vector.zig +++ b/test/stage1/behavior/vector.zig @@ -1,6 +1,7 @@ const std = @import("std"); const mem = std.mem; const expect = std.testing.expect; +const builtin = @import("builtin"); test "implicit cast vector to array - bool" { const S = struct { @@ -111,6 +112,7 @@ test "array to vector" { } test "vector casts of sizes not divisable by 8" { + if (builtin.os == .dragonfly) return error.SkipZigTest; const S = struct { fn doTheTest() void { { -- cgit v1.2.3 From 4261fa3c49be715355c9623102bad0bf93d537a3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 25 Nov 2019 18:46:17 -0500 Subject: move logic to the appropriate layers; add new compile error --- lib/std/heap.zig | 8 +++--- lib/std/os.zig | 44 ++++++++++++++++++++++++++++- lib/std/os/wasi.zig | 50 ++------------------------------- lib/std/target.zig | 6 +++- src/analyze.cpp | 3 +- src/ir.cpp | 8 ++++++ src/target.cpp | 6 ++-- test/compile_errors.zig | 19 ++++++++++++- test/stage1/behavior/asm.zig | 3 +- test/stage1/behavior/new_stack_call.zig | 3 ++ 10 files changed, 91 insertions(+), 59 deletions(-) (limited to 'src/target.cpp') diff --git a/lib/std/heap.zig b/lib/std/heap.zig index 259c29f6e6..997f1fa06f 100644 --- a/lib/std/heap.zig +++ b/lib/std/heap.zig @@ -273,17 +273,17 @@ const WasmPageAllocator = struct { if (new_end_index > num_pages * mem.page_size) { const required_memory = new_end_index - (num_pages * mem.page_size); - var num_pages: usize = required_memory / mem.page_size; + var inner_num_pages: usize = required_memory / mem.page_size; if (required_memory % mem.page_size != 0) { - num_pages += 1; + inner_num_pages += 1; } - const prev_page = @"llvm.wasm.memory.grow.i32"(0, @intCast(u32, num_pages)); + const prev_page = @"llvm.wasm.memory.grow.i32"(0, @intCast(u32, inner_num_pages)); if (prev_page == -1) { return error.OutOfMemory; } - num_pages += num_pages; + num_pages += inner_num_pages; } const result = start_ptr[adjusted_index..new_end_index]; diff --git a/lib/std/os.zig b/lib/std/os.zig index a616fbc49f..22d52b24a6 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -1527,7 +1527,22 @@ pub fn isatty(handle: fd_t) bool { return system.isatty(handle) != 0; } if (builtin.os == .wasi) { - return system.isatty(handle); + var statbuf: fdstat_t = undefined; + const err = system.fd_fdstat_get(handle, &statbuf); + if (err != 0) { + // errno = err; + return false; + } + + // A tty is a character device that we can't seek or tell on. + if (statbuf.fs_filetype != FILETYPE_CHARACTER_DEVICE or + (statbuf.fs_rights_base & (RIGHT_FD_SEEK | RIGHT_FD_TELL)) != 0) + { + // errno = ENOTTY; + return false; + } + + return true; } if (builtin.os == .linux) { var wsz: linux.winsize = undefined; @@ -2720,6 +2735,20 @@ pub fn dl_iterate_phdr( pub const ClockGetTimeError = error{UnsupportedClock} || UnexpectedError; pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { + if (comptime std.Target.current.getOs() == .wasi) { + var ts: timestamp_t = undefined; + switch (system.clock_time_get(@bitCast(u32, clk_id), 1, &ts)) { + 0 => { + tp.* = .{ + .tv_sec = @intCast(i64, ts / std.time.ns_per_s), + .tv_nsec = @intCast(isize, ts % std.time.ns_per_s), + }; + }, + EINVAL => return error.UnsupportedClock, + else => |err| return unexpectedErrno(err), + } + return; + } switch (errno(system.clock_gettime(clk_id, tp))) { 0 => return, EFAULT => unreachable, @@ -2729,6 +2758,19 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { } pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void { + if (comptime std.Target.current.getOs() == .wasi) { + var ts: timestamp_t = undefined; + switch (system.clock_res_get(@bitCast(u32, clk_id), &ts)) { + 0 => res.* = .{ + .tv_sec = @intCast(i64, ts / std.time.ns_per_s), + .tv_nsec = @intCast(isize, ts % std.time.ns_per_s), + }, + EINVAL => return error.UnsupportedClock, + else => |err| return unexpectedErrno(err), + } + return; + } + switch (errno(system.clock_getres(clk_id, res))) { 0 => return, EFAULT => unreachable, diff --git a/lib/std/os/wasi.zig b/lib/std/os/wasi.zig index 1ffc9610f0..c417097c7b 100644 --- a/lib/std/os/wasi.zig +++ b/lib/std/os/wasi.zig @@ -78,52 +78,6 @@ pub extern "wasi_unstable" fn sock_send(sock: fd_t, si_data: *const ciovec_t, si pub extern "wasi_unstable" fn sock_shutdown(sock: fd_t, how: sdflags_t) errno_t; /// Get the errno from a syscall return value, or 0 for no error. -pub fn getErrno(r: usize) usize { - const signed_r = @bitCast(isize, r); - return if (signed_r > -4096 and signed_r < 0) @intCast(usize, -signed_r) else 0; -} - -pub fn clock_getres(clock_id: i32, res: *timespec) errno_t { - var ts: timestamp_t = undefined; - const err = clock_res_get(@bitCast(u32, clock_id), &ts); - if (err != 0) { - return err; - } - res.* = .{ - .tv_sec = @intCast(i64, ts / std.time.ns_per_s), - .tv_nsec = @intCast(isize, ts % std.time.ns_per_s), - }; - return 0; -} - -pub fn clock_gettime(clock_id: i32, tp: *timespec) errno_t { - var ts: timestamp_t = undefined; - const err = clock_time_get(@bitCast(u32, clock_id), 1, &ts); - if (err != 0) { - return err; - } - tp.* = .{ - .tv_sec = @intCast(i64, ts / std.time.ns_per_s), - .tv_nsec = @intCast(isize, ts % std.time.ns_per_s), - }; - return 0; -} - -pub fn isatty(fd: fd_t) bool { - var statbuf: fdstat_t = undefined; - const err = fd_fdstat_get(fd, &statbuf); - if (err != 0) { - // errno = err; - return false; - } - - // A tty is a character device that we can't seek or tell on. - if (statbuf.fs_filetype != FILETYPE_CHARACTER_DEVICE or - (statbuf.fs_rights_base & (RIGHT_FD_SEEK | RIGHT_FD_TELL)) != 0) - { - // errno = ENOTTY; - return false; - } - - return true; +pub fn getErrno(r: errno_t) usize { + return r; } diff --git a/lib/std/target.zig b/lib/std/target.zig index 9652d5b6e5..4d19fa6275 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -607,6 +607,10 @@ pub const Target = union(enum) { } } + pub fn supportsNewStackCall(self: Target) bool { + return !self.isWasm(); + } + pub const Executor = union(enum) { native, qemu: []const u8, @@ -650,7 +654,7 @@ pub const Target = union(enum) { } } - if (self.isWasm()) { + if (self.getOs() == .wasi) { switch (self.getArchPtrBitWidth()) { 32 => return Executor{ .wasmtime = "wasmtime" }, else => return .unavailable, diff --git a/src/analyze.cpp b/src/analyze.cpp index e47b67a495..e1b086059b 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -978,7 +978,8 @@ bool want_first_arg_sret(CodeGen *g, FnTypeId *fn_type_id) { if (g->zig_target->arch == ZigLLVM_x86 || g->zig_target->arch == ZigLLVM_x86_64 || target_is_arm(g->zig_target) || - target_is_riscv(g->zig_target)) + target_is_riscv(g->zig_target) || + target_is_wasm(g->zig_target)) { X64CABIClass abi_class = type_c_abi_x86_64_class(g, fn_type_id->return_type); return abi_class == X64CABIClass_MEMORY || abi_class == X64CABIClass_MEMORY_nobyval; diff --git a/src/ir.cpp b/src/ir.cpp index f4bcfb6330..7e867f1c93 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -17095,6 +17095,14 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstructionCall if (call_instruction->new_stack == nullptr) return nullptr; + if (!call_instruction->is_async_call_builtin && + arch_stack_pointer_register_name(ira->codegen->zig_target->arch) == nullptr) + { + ir_add_error(ira, &call_instruction->base, + buf_sprintf("target arch '%s' does not support @newStackCall", + target_arch_name(ira->codegen->zig_target->arch))); + } + IrInstruction *new_stack = call_instruction->new_stack->child; if (type_is_invalid(new_stack->value->type)) return ira->codegen->invalid_instruction; diff --git a/src/target.cpp b/src/target.cpp index 8fd7d7055f..538f836f24 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -1458,6 +1458,10 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) { case ZigLLVM_mipsel: return "sp"; + case ZigLLVM_wasm32: + case ZigLLVM_wasm64: + return nullptr; // known to be not available + case ZigLLVM_amdgcn: case ZigLLVM_amdil: case ZigLLVM_amdil64: @@ -1491,8 +1495,6 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) { case ZigLLVM_systemz: case ZigLLVM_tce: case ZigLLVM_tcele: - case ZigLLVM_wasm32: - case ZigLLVM_wasm64: case ZigLLVM_xcore: case ZigLLVM_ppc: case ZigLLVM_ppc64: diff --git a/test/compile_errors.zig b/test/compile_errors.zig index dd0f80b255..c1e2d579a4 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2,6 +2,24 @@ const tests = @import("tests.zig"); const builtin = @import("builtin"); pub fn addCases(cases: *tests.CompileErrorContext) void { + cases.addCase(x: { + var tc = cases.create("@newStackCall on unsupported target", + \\export fn entry() void { + \\ var buf: [10]u8 align(16) = undefined; + \\ @newStackCall(&buf, foo); + \\} + \\fn foo() void {} + , "tmp.zig:3:5: error: target arch 'wasm32' does not support @newStackCall"); + tc.target = tests.Target{ + .Cross = tests.CrossTarget{ + .arch = .wasm32, + .os = .wasi, + .abi = .none, + }, + }; + break :x tc; + }); + cases.add( "incompatible sentinels", \\export fn entry1(ptr: [*:255]u8) [*:0]u8 { @@ -26,7 +44,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { "tmp.zig:8:35: note: destination array requires a terminating '0' sentinel, but source array has a terminating '255' sentinel", "tmp.zig:11:31: error: expected type '[2:0]u8', found '[2]u8'", "tmp.zig:11:31: note: destination array requires a terminating '0' sentinel", - ); cases.add( diff --git a/test/stage1/behavior/asm.zig b/test/stage1/behavior/asm.zig index 9278d45d5d..d1404c6f45 100644 --- a/test/stage1/behavior/asm.zig +++ b/test/stage1/behavior/asm.zig @@ -1,5 +1,6 @@ +const std = @import("std"); const config = @import("builtin"); -const expect = @import("std").testing.expect; +const expect = std.testing.expect; comptime { if (config.arch == config.Arch.x86_64 and config.os == config.Os.linux) { diff --git a/test/stage1/behavior/new_stack_call.zig b/test/stage1/behavior/new_stack_call.zig index a2f3773afe..b057566d9c 100644 --- a/test/stage1/behavior/new_stack_call.zig +++ b/test/stage1/behavior/new_stack_call.zig @@ -12,6 +12,9 @@ test "calling a function with a new stack" { // TODO: https://github.com/ziglang/zig/issues/3338 return error.SkipZigTest; } + if (comptime !std.Target.current.supportsNewStackCall()) { + return error.SkipZigTest; + } const arg = 1234; -- cgit v1.2.3 From dcbd5ad1553c5994353de47babc0e07e02153bd8 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 2 Dec 2019 12:01:49 -0500 Subject: remove upstream support for Zen hobby OS The new plan to support hobby operating systems is #3784. And what kind of name is "Zen" anyway? There's already a [Zen programming language](http://zenlang.sourceforge.net/) and that's just confusing. --- lib/std/os.zig | 3 --- lib/std/target.zig | 2 -- src-self-hosted/c_int.zig | 1 - src-self-hosted/link.zig | 7 ------- src/link.cpp | 6 ------ src/target.cpp | 7 ------- src/target.hpp | 1 - 7 files changed, 27 deletions(-) (limited to 'src/target.cpp') diff --git a/lib/std/os.zig b/lib/std/os.zig index c06c1dedf5..66a5522ac1 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -31,7 +31,6 @@ pub const linux = @import("os/linux.zig"); pub const uefi = @import("os/uefi.zig"); pub const wasi = @import("os/wasi.zig"); pub const windows = @import("os/windows.zig"); -pub const zen = @import("os/zen.zig"); comptime { assert(@import("std") == std); // std lib tests require --override-lib-dir @@ -45,7 +44,6 @@ test "" { _ = uefi; _ = wasi; _ = windows; - _ = zen; _ = @import("os/test.zig"); } @@ -59,7 +57,6 @@ pub const system = if (builtin.link_libc) std.c else switch (builtin.os) { .dragonfly => dragonfly, .wasi => wasi, .windows => windows, - .zen => zen, else => struct {}, }; diff --git a/lib/std/target.zig b/lib/std/target.zig index 685533f67e..cdabf7448d 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -45,7 +45,6 @@ pub const Target = union(enum) { hurd, wasi, emscripten, - zen, uefi, }; @@ -432,7 +431,6 @@ pub const Target = union(enum) { .mesa3d, .contiki, .amdpal, - .zen, .hermit, => return .eabi, .openbsd, diff --git a/src-self-hosted/c_int.zig b/src-self-hosted/c_int.zig index 00c521a167..b68137bbd4 100644 --- a/src-self-hosted/c_int.zig +++ b/src-self-hosted/c_int.zig @@ -105,7 +105,6 @@ pub const CInt = struct { .macosx, .freebsd, .openbsd, - .zen, => switch (cint.id) { .Short, .UShort, diff --git a/src-self-hosted/link.zig b/src-self-hosted/link.zig index 68e16020c9..339acfd3ef 100644 --- a/src-self-hosted/link.zig +++ b/src-self-hosted/link.zig @@ -304,13 +304,6 @@ fn constructLinkerArgsElf(ctx: *Context) !void { if (ctx.comp.target != Target.Native) { try ctx.args.append("--allow-shlib-undefined"); } - - if (ctx.comp.target.getOs() == .zen) { - try ctx.args.append("-e"); - try ctx.args.append("_start"); - - try ctx.args.append("--image-base=0x10000000"); - } } fn addPathJoin(ctx: *Context, dirname: []const u8, basename: []const u8) !void { diff --git a/src/link.cpp b/src/link.cpp index c115ffe2fd..530a0c27c4 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -1831,12 +1831,6 @@ static void construct_linker_job_elf(LinkJob *lj) { if (!g->zig_target->is_native) { lj->args.append("--allow-shlib-undefined"); } - - if (g->zig_target->os == OsZen) { - lj->args.append("-e"); - lj->args.append("_start"); - lj->args.append("--image-base=0x10000000"); - } } static void construct_linker_job_wasm(LinkJob *lj) { diff --git a/src/target.cpp b/src/target.cpp index 538f836f24..8705cfd29c 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -179,7 +179,6 @@ static const Os os_list[] = { OsHurd, OsWASI, OsEmscripten, - OsZen, OsUefi, }; @@ -269,7 +268,6 @@ Os target_os_enum(size_t index) { ZigLLVM_OSType get_llvm_os_type(Os os_type) { switch (os_type) { case OsFreestanding: - case OsZen: return ZigLLVM_UnknownOS; case OsAnanas: return ZigLLVM_Ananas; @@ -425,8 +423,6 @@ const char *target_os_name(Os os_type) { switch (os_type) { case OsFreestanding: return "freestanding"; - case OsZen: - return "zen"; case OsUefi: return "uefi"; case OsAnanas: @@ -1047,7 +1043,6 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { } case OsLinux: case OsMacOSX: - case OsZen: case OsFreeBSD: case OsNetBSD: case OsDragonFly: @@ -1404,7 +1399,6 @@ const char *target_dynamic_linker(const ZigTarget *target) { case OsMesa3D: case OsContiki: case OsAMDPAL: - case OsZen: case OsHermitCore: case OsHurd: case OsWASI: @@ -1655,7 +1649,6 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) { case OsMesa3D: case OsContiki: case OsAMDPAL: - case OsZen: case OsHermitCore: return ZigLLVM_EABI; case OsOpenBSD: diff --git a/src/target.hpp b/src/target.hpp index e6b152be53..8297d528f9 100644 --- a/src/target.hpp +++ b/src/target.hpp @@ -49,7 +49,6 @@ enum Os { OsHurd, OsWASI, OsEmscripten, - OsZen, OsUefi, }; -- cgit v1.2.3 From 10e172b1d77619469653b0521d8f65604fa549c7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 4 Dec 2019 14:42:18 -0500 Subject: add `other` OS and fix regression in build-exe for freestanding --- lib/std/special/start.zig | 14 ++++++++------ lib/std/target.zig | 2 ++ src-self-hosted/c_int.zig | 2 +- src/target.cpp | 10 +++++++++- src/target.hpp | 1 + 5 files changed, 21 insertions(+), 8 deletions(-) (limited to 'src/target.cpp') diff --git a/lib/std/special/start.zig b/lib/std/special/start.zig index a93b01c290..9c24e38137 100644 --- a/lib/std/special/start.zig +++ b/lib/std/special/start.zig @@ -32,14 +32,16 @@ comptime { if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup")) { @export("WinMainCRTStartup", WinMainCRTStartup, .Strong); } - } else if (is_wasm and builtin.os == .freestanding) { - if (!@hasDecl(root, "_start")) @export("_start", wasm_freestanding_start, .Strong); } else if (builtin.os == .uefi) { if (!@hasDecl(root, "EfiMain")) @export("EfiMain", EfiMain, .Strong); - } else if (is_mips) { - if (!@hasDecl(root, "__start")) @export("__start", _start, .Strong); - } else { - if (!@hasDecl(root, "_start")) @export("_start", _start, .Strong); + } else if (builtin.os != .freestanding) { + if (is_mips) { + if (!@hasDecl(root, "__start")) @export("__start", _start, .Strong); + } else { + if (!@hasDecl(root, "_start")) @export("_start", _start, .Strong); + } + } else if (is_wasm) { + if (!@hasDecl(root, "_start")) @export("_start", wasm_freestanding_start, .Strong); } } } diff --git a/lib/std/target.zig b/lib/std/target.zig index cdabf7448d..e4beea4552 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -46,6 +46,7 @@ pub const Target = union(enum) { wasi, emscripten, uefi, + other, }; pub const Arch = union(enum) { @@ -432,6 +433,7 @@ pub const Target = union(enum) { .contiki, .amdpal, .hermit, + .other, => return .eabi, .openbsd, .macosx, diff --git a/src-self-hosted/c_int.zig b/src-self-hosted/c_int.zig index b68137bbd4..2a840372b9 100644 --- a/src-self-hosted/c_int.zig +++ b/src-self-hosted/c_int.zig @@ -71,7 +71,7 @@ pub const CInt = struct { pub fn sizeInBits(cint: CInt, self: Target) u32 { const arch = self.getArch(); switch (self.getOs()) { - .freestanding => switch (self.getArch()) { + .freestanding, .other => switch (self.getArch()) { .msp430 => switch (cint.id) { .Short, .UShort, diff --git a/src/target.cpp b/src/target.cpp index 8705cfd29c..03815a20fe 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -180,6 +180,7 @@ static const Os os_list[] = { OsWASI, OsEmscripten, OsUefi, + OsOther, }; // Coordinate with zig_llvm.h @@ -268,6 +269,7 @@ Os target_os_enum(size_t index) { ZigLLVM_OSType get_llvm_os_type(Os os_type) { switch (os_type) { case OsFreestanding: + case OsOther: return ZigLLVM_UnknownOS; case OsAnanas: return ZigLLVM_Ananas; @@ -425,6 +427,8 @@ const char *target_os_name(Os os_type) { return "freestanding"; case OsUefi: return "uefi"; + case OsOther: + return "other"; case OsAnanas: case OsCloudABI: case OsDragonFly: @@ -1005,6 +1009,7 @@ uint32_t target_arch_largest_atomic_bits(ZigLLVM_ArchType arch) { uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { switch (target->os) { case OsFreestanding: + case OsOther: switch (target->arch) { case ZigLLVM_msp430: switch (id) { @@ -1134,7 +1139,8 @@ bool target_allows_addr_zero(const ZigTarget *target) { const char *target_o_file_ext(const ZigTarget *target) { if (target->abi == ZigLLVM_MSVC || (target->os == OsWindows && !target_abi_is_gnu(target->abi)) || - target->os == OsUefi) { + target->os == OsUefi) + { return ".obj"; } else { return ".o"; @@ -1376,6 +1382,7 @@ const char *target_dynamic_linker(const ZigTarget *target) { case OsUefi: case OsWindows: case OsEmscripten: + case OsOther: return nullptr; case OsAnanas: @@ -1650,6 +1657,7 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) { case OsContiki: case OsAMDPAL: case OsHermitCore: + case OsOther: return ZigLLVM_EABI; case OsOpenBSD: case OsMacOSX: diff --git a/src/target.hpp b/src/target.hpp index 8297d528f9..f72b44a277 100644 --- a/src/target.hpp +++ b/src/target.hpp @@ -50,6 +50,7 @@ enum Os { OsWASI, OsEmscripten, OsUefi, + OsOther, }; // Synchronize with target.cpp::subarch_list_list -- cgit v1.2.3 From 839b3a61ad51b385ac28a0123b6cc63d90ef83f8 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 16 Dec 2019 13:51:21 -0500 Subject: expose the ability to disable C sanitization and disable C sanitization when building libcs. Empirically, they seem to trigger undef-sanitization. --- lib/std/build.zig | 5 +++++ src/all_types.hpp | 8 ++++++++ src/codegen.cpp | 31 +++++++++++++++++++++++++------ src/main.cpp | 9 +++++++++ src/target.cpp | 4 ++++ src/target.hpp | 1 + 6 files changed, 52 insertions(+), 6 deletions(-) (limited to 'src/target.cpp') diff --git a/lib/std/build.zig b/lib/std/build.zig index e54a23d8ab..f7e4756e90 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -1034,6 +1034,7 @@ pub const LibExeObjStep = struct { disable_gen_h: bool, bundle_compiler_rt: bool, disable_stack_probing: bool, + disable_sanitize_c: bool, c_std: Builder.CStd, override_lib_dir: ?[]const u8, main_pkg_path: ?[]const u8, @@ -1183,6 +1184,7 @@ pub const LibExeObjStep = struct { .disable_gen_h = false, .bundle_compiler_rt = false, .disable_stack_probing = false, + .disable_sanitize_c = false, .output_dir = null, .need_system_paths = false, .single_threaded = false, @@ -1822,6 +1824,9 @@ pub const LibExeObjStep = struct { if (self.disable_stack_probing) { try zig_args.append("-fno-stack-check"); } + if (self.disable_sanitize_c) { + try zig_args.append("-fno-sanitize-c"); + } switch (self.target) { .Native => {}, diff --git a/src/all_types.hpp b/src/all_types.hpp index 5f0211df74..bcef45f718 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -1928,6 +1928,12 @@ enum WantStackCheck { WantStackCheckEnabled, }; +enum WantCSanitize { + WantCSanitizeAuto, + WantCSanitizeDisabled, + WantCSanitizeEnabled, +}; + struct CFile { ZigList args; const char *source_path; @@ -2096,6 +2102,7 @@ struct CodeGen { WantPIC want_pic; WantStackCheck want_stack_check; + WantCSanitize want_sanitize_c; CacheHash cache_hash; ErrColor err_color; uint32_t next_unresolved_index; @@ -2170,6 +2177,7 @@ struct CodeGen { bool have_pic; bool have_dynamic_link; // this is whether the final thing will be dynamically linked. see also is_dynamic bool have_stack_probing; + bool have_sanitize_c; bool function_sections; bool enable_dump_analysis; bool enable_doc_generation; diff --git a/src/codegen.cpp b/src/codegen.cpp index b828410181..edc2c7f435 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -8261,6 +8261,20 @@ static bool detect_stack_probing(CodeGen *g) { zig_unreachable(); } +static bool detect_sanitize_c(CodeGen *g) { + if (!target_supports_sanitize_c(g->zig_target)) + return false; + switch (g->want_sanitize_c) { + case WantCSanitizeDisabled: + return false; + case WantCSanitizeEnabled: + return true; + case WantCSanitizeAuto: + return g->build_mode == BuildModeSafeRelease || g->build_mode == BuildModeDebug; + } + zig_unreachable(); +} + // Returns TargetSubsystemAuto to mean "no subsystem" TargetSubsystem detect_subsystem(CodeGen *g) { if (g->subsystem != TargetSubsystemAuto) @@ -8297,6 +8311,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) { g->have_dynamic_link = detect_dynamic_link(g); g->have_pic = detect_pic(g); g->have_stack_probing = detect_stack_probing(g); + g->have_sanitize_c = detect_sanitize_c(g); g->is_single_threaded = detect_single_threaded(g); g->have_err_ret_tracing = detect_err_ret_tracing(g); @@ -8582,6 +8597,7 @@ static void init(CodeGen *g) { g->have_dynamic_link = detect_dynamic_link(g); g->have_pic = detect_pic(g); g->have_stack_probing = detect_stack_probing(g); + g->have_sanitize_c = detect_sanitize_c(g); g->is_single_threaded = detect_single_threaded(g); g->have_err_ret_tracing = detect_err_ret_tracing(g); @@ -8971,11 +8987,13 @@ void add_cc_args(CodeGen *g, ZigList &args, const char *out_dep_pa args.append("-fomit-frame-pointer"); } + if (g->have_sanitize_c) { + args.append("-fsanitize=undefined"); + args.append("-fsanitize-trap=undefined"); + } + switch (g->build_mode) { case BuildModeDebug: - args.append("-fsanitize=undefined"); - args.append("-fsanitize-trap=undefined"); - // windows c runtime requires -D_DEBUG if using debug libraries args.append("-D_DEBUG"); @@ -8988,9 +9006,6 @@ void add_cc_args(CodeGen *g, ZigList &args, const char *out_dep_pa } break; case BuildModeSafeRelease: - args.append("-fsanitize=undefined"); - args.append("-fsanitize-trap=undefined"); - // See the comment in the BuildModeFastRelease case for why we pass -O2 rather // than -O3 here. args.append("-O2"); @@ -9312,6 +9327,7 @@ Error create_c_object_cache(CodeGen *g, CacheHash **out_cache_hash, bool verbose cache_bool(cache_hash, g->strip_debug_symbols); cache_int(cache_hash, g->build_mode); cache_bool(cache_hash, g->have_pic); + cache_bool(cache_hash, g->have_sanitize_c); cache_bool(cache_hash, want_valgrind_support(g)); cache_bool(cache_hash, g->function_sections); for (size_t arg_i = 0; arg_i < g->clang_argv_len; arg_i += 1) { @@ -10090,6 +10106,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { cache_bool(ch, g->have_pic); cache_bool(ch, g->have_dynamic_link); cache_bool(ch, g->have_stack_probing); + cache_bool(ch, g->have_sanitize_c); cache_bool(ch, g->is_dummy_so); cache_bool(ch, g->function_sections); cache_bool(ch, g->enable_dump_analysis); @@ -10210,6 +10227,7 @@ void codegen_build_and_link(CodeGen *g) { g->have_pic = detect_pic(g); g->is_single_threaded = detect_single_threaded(g); g->have_err_ret_tracing = detect_err_ret_tracing(g); + g->have_sanitize_c = detect_sanitize_c(g); detect_libc(g); detect_dynamic_linker(g); @@ -10398,6 +10416,7 @@ CodeGen *create_child_codegen(CodeGen *parent_gen, Buf *root_src_path, OutType o child_gen->root_out_name = buf_create_from_str(name); child_gen->disable_gen_h = true; child_gen->want_stack_check = WantStackCheckDisabled; + child_gen->want_sanitize_c = WantCSanitizeDisabled; child_gen->verbose_tokenize = parent_gen->verbose_tokenize; child_gen->verbose_ast = parent_gen->verbose_ast; child_gen->verbose_link = parent_gen->verbose_link; diff --git a/src/main.cpp b/src/main.cpp index a6b26893b9..2cda18f7a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -59,6 +59,8 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) { " --enable-valgrind include valgrind client requests release builds\n" " -fstack-check enable stack probing in unsafe builds\n" " -fno-stack-check disable stack probing in safe builds\n" + " -fsanitize-c enable C undefined behavior detection in unsafe builds\n" + " -fno-sanitize-c disable C undefined behavior detection in safe builds\n" " --emit [asm|bin|llvm-ir] emit a specific file format as compilation output\n" " -fPIC enable Position Independent Code\n" " -fno-PIC disable Position Independent Code\n" @@ -524,6 +526,7 @@ int main(int argc, char **argv) { ValgrindSupport valgrind_support = ValgrindSupportAuto; WantPIC want_pic = WantPICAuto; WantStackCheck want_stack_check = WantStackCheckAuto; + WantCSanitize want_sanitize_c = WantCSanitizeAuto; bool function_sections = false; ZigList llvm_argv = {0}; @@ -722,6 +725,10 @@ int main(int argc, char **argv) { want_stack_check = WantStackCheckEnabled; } else if (strcmp(arg, "-fno-stack-check") == 0) { want_stack_check = WantStackCheckDisabled; + } else if (strcmp(arg, "-fsanitize-c") == 0) { + want_sanitize_c = WantCSanitizeEnabled; + } else if (strcmp(arg, "-fno-sanitize-c") == 0) { + want_sanitize_c = WantCSanitizeDisabled; } else if (strcmp(arg, "--system-linker-hack") == 0) { system_linker_hack = true; } else if (strcmp(arg, "--single-threaded") == 0) { @@ -1093,6 +1100,7 @@ int main(int argc, char **argv) { g->valgrind_support = valgrind_support; g->want_pic = want_pic; g->want_stack_check = want_stack_check; + g->want_sanitize_c = want_sanitize_c; g->want_single_threaded = want_single_threaded; Buf *builtin_source = codegen_generate_builtin_source(g); if (fwrite(buf_ptr(builtin_source), 1, buf_len(builtin_source), stdout) != buf_len(builtin_source)) { @@ -1192,6 +1200,7 @@ int main(int argc, char **argv) { g->valgrind_support = valgrind_support; g->want_pic = want_pic; g->want_stack_check = want_stack_check; + g->want_sanitize_c = want_sanitize_c; g->subsystem = subsystem; g->enable_time_report = timing_info; diff --git a/src/target.cpp b/src/target.cpp index 03815a20fe..82d5467e26 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -1606,6 +1606,10 @@ bool target_supports_stack_probing(const ZigTarget *target) { return target->os != OsWindows && target->os != OsUefi && (target->arch == ZigLLVM_x86 || target->arch == ZigLLVM_x86_64); } +bool target_supports_sanitize_c(const ZigTarget *target) { + return true; +} + bool target_requires_pic(const ZigTarget *target, bool linking_libc) { // This function returns whether non-pic code is completely invalid on the given target. return target_is_android(target) || target->os == OsWindows || target->os == OsUefi || target_os_requires_libc(target->os) || diff --git a/src/target.hpp b/src/target.hpp index f72b44a277..50611bc853 100644 --- a/src/target.hpp +++ b/src/target.hpp @@ -194,6 +194,7 @@ bool target_is_riscv(const ZigTarget *target); bool target_is_android(const ZigTarget *target); bool target_is_single_threaded(const ZigTarget *target); bool target_supports_stack_probing(const ZigTarget *target); +bool target_supports_sanitize_c(const ZigTarget *target); bool target_has_debug_info(const ZigTarget *target); const char *target_arch_musl_name(ZigLLVM_ArchType arch); bool target_supports_libunwind(const ZigTarget *target); -- cgit v1.2.3