authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2025-12-28 23:23:54+01:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2025-12-28 23:23:54+01:00
log6ca1c88e46352b006c26d4c99944ac0c70fe28e7
treefa136a1969b073416d59fcbdc5977355640a5652
parent6984992153f0656b04c39279f9684fd5a06e952d
parentac4c9b8fb29f30692b40d35db533e7c4e80300b4

Merge pull request 'minor bsd fixups' (#30609) from mikdusan/zig:bsd into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30609 Reviewed-by: Andrew Kelley <andrewrk@noreply.codeberg.org>

3 files changed, 15 insertions(+), 6 deletions(-)

lib/std/Io/Threaded.zig+3-3
......@@ -7209,7 +7209,7 @@ fn processExecutablePath(userdata: ?*anyopaque, out_buffer: []u8) std.process.Ex
72097209 .openbsd, .haiku => {
72107210 // The best we can do on these operating systems is check based on
72117211 // the first process argument.
7212 const argv0 = t.argv0.value orelse return error.OperationUnsupported;
7212 const argv0 = std.mem.span(t.argv0.value orelse return error.OperationUnsupported);
72137213 if (std.mem.findScalar(u8, argv0, '/') != null) {
72147214 // argv[0] is a path (relative or absolute): use realpath(3) directly
72157215 const current_thread = Thread.getCurrent(t);
......@@ -12153,7 +12153,7 @@ fn scanEnviron(t: *Threaded) void {
1215312153
1215412154 var end_i: usize = line_i;
1215512155 while (line[end_i] != 0) : (end_i += 1) {}
12156 const value = line[line_i + 1 .. end_i];
12156 const value = line[line_i + 1 .. end_i :0];
1215712157
1215812158 if (std.mem.eql(u8, key, "NO_COLOR")) {
1215912159 t.environ.exist.NO_COLOR = true;
......@@ -12171,7 +12171,7 @@ fn scanEnviron(t: *Threaded) void {
1217112171
1217212172 var end_i: usize = line_i;
1217312173 while (line[end_i] != 0) : (end_i += 1) {}
12174 const value = line[line_i + 1 .. end_i];
12174 const value = line[line_i + 1 .. end_i :0];
1217512175
1217612176 if (std.mem.eql(u8, key, "NO_COLOR")) {
1217712177 t.environ.exist.NO_COLOR = true;
lib/std/c.zig+8-1
......@@ -10651,7 +10651,12 @@ pub extern "c" fn unlink(path: [*:0]const u8) c_int;
1065110651pub extern "c" fn unlinkat(dirfd: fd_t, path: [*:0]const u8, flags: c_uint) c_int;
1065210652pub extern "c" fn getcwd(buf: [*]u8, size: usize) ?[*]u8;
1065310653pub extern "c" fn waitpid(pid: pid_t, status: ?*c_int, options: c_int) pid_t;
10654pub extern "c" fn wait4(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_t;
10654
10655pub const wait4 = switch (native_os) {
10656 .netbsd => private.__wait450,
10657 else => private.wait4,
10658};
10659
1065510660pub const fork = switch (native_os) {
1065610661 .dragonfly,
1065710662 .freebsd,
......@@ -11440,6 +11445,7 @@ const private = struct {
1144011445 extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
1144111446 extern "c" fn sysconf(sc: c_int) c_long;
1144211447 extern "c" fn shm_open(name: [*:0]const u8, flag: c_int, mode: mode_t) c_int;
11448 extern "c" fn wait4(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_t;
1144311449
1144411450 extern "c" fn pthread_setname_np(thread: pthread_t, name: [*:0]const u8) c_int;
1144511451
......@@ -11492,6 +11498,7 @@ const private = struct {
1149211498 extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int;
1149311499 extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int;
1149411500 extern "c" fn __sigaltstack14(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
11501 extern "c" fn __wait450(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_t;
1149511502
1149611503 extern "c" fn __libc_current_sigrtmin() c_int;
1149711504 extern "c" fn __libc_current_sigrtmax() c_int;
src/main.zig+4-2
......@@ -198,7 +198,7 @@ pub fn main() anyerror!void {
198198 return mainArgs(gpa, arena, args);
199199}
200200
201fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
201fn mainArgs(gpa: Allocator, arena: Allocator, args: []const [:0]const u8) !void {
202202 const tr = tracy.trace(@src());
203203 defer tr.end();
204204
......@@ -241,7 +241,9 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
241241 }
242242 }
243243
244 var threaded: Io.Threaded = .init(gpa, .{});
244 var threaded: Io.Threaded = .init(gpa, .{
245 .argv0 = if (@hasField(Io.Threaded.Argv0, "value")) .{ .value = args[0] } else .{},
246 });
245247 defer threaded.deinit();
246248 threaded_impl_ptr = &threaded;
247249 threaded.stack_size = thread_stack_size;