From 8cd56e70886e9ccc1f6a1c7978b32ba7e79516e0 Mon Sep 17 00:00:00 2001 From: Elaine Gibson Date: Sat, 31 May 2025 01:40:43 +0100 Subject: [PATCH 1/7] haiku: restore functions mistakenly removed in e8c4e79 --- lib/std/c/haiku.zig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/std/c/haiku.zig b/lib/std/c/haiku.zig index a9877d07e3..bfac0cfa55 100644 --- a/lib/std/c/haiku.zig +++ b/lib/std/c/haiku.zig @@ -23,6 +23,11 @@ pub extern "root" fn get_system_info(system_info: *system_info) usize; pub extern "root" fn _get_team_info(team: i32, team_info: *team_info, size: usize) i32; pub extern "root" fn _get_next_area_info(team: i32, cookie: *i64, area_info: *area_info, size: usize) i32; pub extern "root" fn _get_next_image_info(team: i32, cookie: *i32, image_info: *image_info, size: usize) i32; +pub extern "root" fn _kern_get_current_team() team_id; +pub extern "root" fn _kern_open_dir(fd: fd_t, path: [*:0]const u8) fd_t; +pub extern "root" fn _kern_read_dir(fd: fd_t, buffer: [*]u8, bufferSize: usize, maxCount: u32) isize; +pub extern "root" fn _kern_rewind_dir(fd: fd_t) status_t; +pub extern "root" fn _kern_read_stat(fd: fd_t, path: [*:0]const u8, traverseLink: bool, stat: *std.c.Stat, statSize: usize) status_t; pub const area_info = extern struct { area: u32, From 8910ac2ba877ebf745fb35b8ec9b21fdc70d092a Mon Sep 17 00:00:00 2001 From: Elaine Gibson Date: Sat, 31 May 2025 01:55:55 +0100 Subject: [PATCH 2/7] std.c.SOCK: define NONBLOCK and CLOEXEC for haiku --- lib/std/c.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/std/c.zig b/lib/std/c.zig index 25d45ae8a6..6d49e8de8a 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -5703,6 +5703,9 @@ pub const SOCK = switch (native_os) { pub const RAW = 3; pub const SEQPACKET = 5; pub const MISC = 255; + + pub const NONBLOCK = 0x40000; + pub const CLOEXEC = 0x80000; }, .openbsd => struct { pub const STREAM = 1; From 2139eb75f9e1e6fa766797b60566b254efce2f8f Mon Sep 17 00:00:00 2001 From: Elaine Gibson Date: Sat, 31 May 2025 03:04:58 +0100 Subject: [PATCH 3/7] std.c: getcontext is not supported on haiku --- lib/std/c.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/c.zig b/lib/std/c.zig index 6d49e8de8a..390d5f89c3 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -10827,8 +10827,8 @@ pub const LC = enum(c_int) { pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) ?[*:0]const u8; -pub const getcontext = if (builtin.target.abi.isAndroid() or builtin.target.os.tag == .openbsd) -{} // android bionic and openbsd libc does not implement getcontext +pub const getcontext = if (builtin.target.abi.isAndroid() or builtin.target.os.tag == .openbsd or builtin.target.os.tag == .haiku) +{} // libc does not implement getcontext else if (native_os == .linux and builtin.target.abi.isMusl()) linux.getcontext else From 2cfa0f567d42a8dace0fb186c710548f18ae0639 Mon Sep 17 00:00:00 2001 From: Elaine Gibson Date: Sat, 31 May 2025 03:14:01 +0100 Subject: [PATCH 4/7] std.Build.Watch: not supported on haiku --- lib/compiler/build_runner.zig | 2 +- lib/std/Build/Watch.zig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/compiler/build_runner.zig b/lib/compiler/build_runner.zig index 1a019c80d9..31985f3e3d 100644 --- a/lib/compiler/build_runner.zig +++ b/lib/compiler/build_runner.zig @@ -415,7 +415,7 @@ pub fn main() !void { else => return err, }; - var w = if (watch) try Watch.init() else undefined; + var w: Watch = if (watch and Watch.have_impl) try Watch.init() else undefined; try run.thread_pool.init(thread_pool_options); defer run.thread_pool.deinit(); diff --git a/lib/std/Build/Watch.zig b/lib/std/Build/Watch.zig index 13540a2b36..bae3af1f63 100644 --- a/lib/std/Build/Watch.zig +++ b/lib/std/Build/Watch.zig @@ -600,7 +600,7 @@ const Os = switch (builtin.os.tag) { }; } }, - .dragonfly, .freebsd, .netbsd, .openbsd, .ios, .macos, .tvos, .visionos, .watchos, .haiku => struct { + .dragonfly, .freebsd, .netbsd, .openbsd, .ios, .macos, .tvos, .visionos, .watchos => struct { const posix = std.posix; kq_fd: i32, From 2e5b3b5c7c7f5e46f1b4481bd81652db869da6d9 Mon Sep 17 00:00:00 2001 From: Elaine Gibson Date: Sat, 31 May 2025 03:20:55 +0100 Subject: [PATCH 5/7] build runner: disable fuzz in single-threaded builds --- lib/compiler/build_runner.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/compiler/build_runner.zig b/lib/compiler/build_runner.zig index 31985f3e3d..d73fb6d29d 100644 --- a/lib/compiler/build_runner.zig +++ b/lib/compiler/build_runner.zig @@ -435,6 +435,9 @@ pub fn main() !void { else => return err, }; if (fuzz) { + if (builtin.single_threaded) { + fatal("--fuzz not yet implemented for single-threaded builds", .{}); + } switch (builtin.os.tag) { // Current implementation depends on two things that need to be ported to Windows: // * Memory-mapping to share data between the fuzzer and build runner. From ed48e2eb7599d93b6d3248391da7a7c7f1f92acf Mon Sep 17 00:00:00 2001 From: Elaine Gibson Date: Sat, 31 May 2025 03:53:20 +0100 Subject: [PATCH 6/7] std.crypto.Certificate.Bundle: haiku support --- lib/std/crypto/Certificate/Bundle.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/std/crypto/Certificate/Bundle.zig b/lib/std/crypto/Certificate/Bundle.zig index a74eb44a91..437f7a224c 100644 --- a/lib/std/crypto/Certificate/Bundle.zig +++ b/lib/std/crypto/Certificate/Bundle.zig @@ -64,6 +64,7 @@ pub fn rescan(cb: *Bundle, gpa: Allocator) RescanError!void { .netbsd => return rescanWithPath(cb, gpa, "/etc/openssl/certs/ca-certificates.crt"), .dragonfly => return rescanWithPath(cb, gpa, "/usr/local/etc/ssl/cert.pem"), .solaris, .illumos => return rescanWithPath(cb, gpa, "/etc/ssl/cacert.pem"), + .haiku => return rescanWithPath(cb, gpa, "/boot/system/data/ssl/CARootCertificates.pem"), // https://github.com/SerenityOS/serenity/blob/222acc9d389bc6b490d4c39539761b043a4bfcb0/Ports/ca-certificates/package.sh#L19 .serenity => return rescanWithPath(cb, gpa, "/etc/ssl/certs/ca-certificates.crt"), .windows => return rescanWindows(cb, gpa), From 7f7318700427875d5b0ec2f8601c12e5bc21cebe Mon Sep 17 00:00:00 2001 From: Elaine Gibson Date: Wed, 4 Jun 2025 23:15:35 +0100 Subject: [PATCH 7/7] std.fs.Dir: haiku fixes --- lib/std/fs/Dir.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/std/fs/Dir.zig b/lib/std/fs/Dir.zig index 6075c8ca0f..90c46740ca 100644 --- a/lib/std/fs/Dir.zig +++ b/lib/std/fs/Dir.zig @@ -13,6 +13,7 @@ pub const Entry = struct { const IteratorError = error{ AccessDenied, + PermissionDenied, SystemResources, /// WASI-only. The path of an entry could not be encoded as valid UTF-8. /// WASI is unable to handle paths that cannot be encoded as well-formed UTF-8. @@ -287,7 +288,7 @@ pub const Iterator = switch (native_os) { name, false, &stat_info, - 0, + @sizeOf(posix.Stat), )))) { .SUCCESS => {}, .INVAL => unreachable,