From 5d389535e875f3d1b4865fc10fb79317b26c5ed7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 19 Mar 2024 16:59:07 -0700 Subject: [PATCH 1/2] std: fix inconsistent errno size on linux Now it's always u16 --- lib/std/os/linux.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index ba0ffb452f..9ff272a332 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -2264,7 +2264,7 @@ pub fn map_shadow_stack(addr: u64, size: u64, flags: u32) usize { } pub const E = switch (native_arch) { - .mips, .mipsel => enum(i32) { + .mips, .mipsel => enum(u16) { /// No error occurred. SUCCESS = 0, @@ -2406,7 +2406,7 @@ pub const E = switch (native_arch) { pub const init = errnoFromSyscall; }, - .sparc, .sparcel, .sparc64 => enum(i32) { + .sparc, .sparcel, .sparc64 => enum(u16) { /// No error occurred. SUCCESS = 0, From cba155510431104fcfe2f6b61e955bc4d42927fb Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 19 Mar 2024 17:02:04 -0700 Subject: [PATCH 2/2] std: don't do BYOS at the POSIX API layer This was a mistake from day one. This is the wrong abstraction layer to do this in. My alternate plan for this is to make all I/O operations require an IO interface parameter, similar to how allocations require an Allocator interface parameter today. --- lib/std/posix.zig | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 6d70b79a4c..fb2262e267 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -39,12 +39,8 @@ const linux = std.os.linux; const windows = std.os.windows; const wasi = std.os.wasi; -/// Applications can override the `system` API layer in their root source file. -/// Otherwise, when linking libc, this is the C API. -/// When not linking libc, it is the OS-specific system interface. -pub const system = if (@hasDecl(root, "os") and @hasDecl(root.os, "system") and root.os != @This()) - root.os.system -else if (use_libc) +/// A libc-compatible API layer. +pub const system = if (use_libc) std.c else switch (native_os) { .linux => linux,