From 0ae629ee226d2a07922772b6eae409926e62d110 Mon Sep 17 00:00:00 2001 From: Michael Dusan Date: Sat, 27 Dec 2025 16:48:07 -0500 Subject: [PATCH 1/3] netbsd: use correct symbol for wait4 --- lib/std/c.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/std/c.zig b/lib/std/c.zig index 2a7579f2606b06e0a8cf16ea324a73d2ee7743f7..5f0d2dedf879bcabaa3117414d737c78a4b3aabc 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -10651,7 +10651,12 @@ pub extern "c" fn unlink(path: [*:0]const u8) c_int; pub extern "c" fn unlinkat(dirfd: fd_t, path: [*:0]const u8, flags: c_uint) c_int; pub extern "c" fn getcwd(buf: [*]u8, size: usize) ?[*]u8; pub extern "c" fn waitpid(pid: pid_t, status: ?*c_int, options: c_int) pid_t; -pub extern "c" fn wait4(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_t; + +pub const wait4 = switch (native_os) { + .netbsd => private.__wait450, + else => private.wait4, +}; + pub const fork = switch (native_os) { .dragonfly, .freebsd, @@ -11440,6 +11445,7 @@ const private = struct { extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; extern "c" fn sysconf(sc: c_int) c_long; extern "c" fn shm_open(name: [*:0]const u8, flag: c_int, mode: mode_t) c_int; + extern "c" fn wait4(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_t; extern "c" fn pthread_setname_np(thread: pthread_t, name: [*:0]const u8) c_int; @@ -11492,6 +11498,7 @@ const private = struct { extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int; extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int; extern "c" fn __sigaltstack14(ss: ?*stack_t, old_ss: ?*stack_t) c_int; + extern "c" fn __wait450(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_t; extern "c" fn __libc_current_sigrtmin() c_int; extern "c" fn __libc_current_sigrtmax() c_int; -- 2.54.0 From b335e52ed6c09f6fd1c8c3a666fd0fa50659b081 Mon Sep 17 00:00:00 2001 From: Michael Dusan Date: Sat, 27 Dec 2025 16:48:07 -0500 Subject: [PATCH 2/3] openbsd: fixup nullz handling in Io.Threaded --- lib/std/Io/Threaded.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index fdd4e6c34a0550cf2ea7f421c0699bd6a81a106f..9e758be9fd4b34721ac6de70e9cd601bea306fd8 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -7209,7 +7209,7 @@ fn processExecutablePath(userdata: ?*anyopaque, out_buffer: []u8) std.process.Ex .openbsd, .haiku => { // The best we can do on these operating systems is check based on // the first process argument. - const argv0 = t.argv0.value orelse return error.OperationUnsupported; + const argv0 = std.mem.span(t.argv0.value orelse return error.OperationUnsupported); if (std.mem.findScalar(u8, argv0, '/') != null) { // argv[0] is a path (relative or absolute): use realpath(3) directly const current_thread = Thread.getCurrent(t); @@ -12153,7 +12153,7 @@ fn scanEnviron(t: *Threaded) void { var end_i: usize = line_i; while (line[end_i] != 0) : (end_i += 1) {} - const value = line[line_i + 1 .. end_i]; + const value = line[line_i + 1 .. end_i :0]; if (std.mem.eql(u8, key, "NO_COLOR")) { t.environ.exist.NO_COLOR = true; @@ -12171,7 +12171,7 @@ fn scanEnviron(t: *Threaded) void { var end_i: usize = line_i; while (line[end_i] != 0) : (end_i += 1) {} - const value = line[line_i + 1 .. end_i]; + const value = line[line_i + 1 .. end_i :0]; if (std.mem.eql(u8, key, "NO_COLOR")) { t.environ.exist.NO_COLOR = true; -- 2.54.0 From ac4c9b8fb29f30692b40d35db533e7c4e80300b4 Mon Sep 17 00:00:00 2001 From: Michael Dusan Date: Sat, 27 Dec 2025 16:48:08 -0500 Subject: [PATCH 3/3] openbsd: initialize Io.Threaded.argv0 --- src/main.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.zig b/src/main.zig index 628d91017a6c02d274665f056258f920bec3820c..d07580636cbb82b91f681eb8c42ccb11d3fbc350 100644 --- a/src/main.zig +++ b/src/main.zig @@ -198,7 +198,7 @@ pub fn main() anyerror!void { return mainArgs(gpa, arena, args); } -fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { +fn mainArgs(gpa: Allocator, arena: Allocator, args: []const [:0]const u8) !void { const tr = tracy.trace(@src()); defer tr.end(); @@ -241,7 +241,9 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { } } - var threaded: Io.Threaded = .init(gpa, .{}); + var threaded: Io.Threaded = .init(gpa, .{ + .argv0 = if (@hasField(Io.Threaded.Argv0, "value")) .{ .value = args[0] } else .{}, + }); defer threaded.deinit(); threaded_impl_ptr = &threaded; threaded.stack_size = thread_stack_size; -- 2.54.0