authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-09-19 10:43:34+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-09-20 00:11:26+02:00
log1175a3e992fc30361febf3517827a5d0ada49b5b
treeef1a1594382d9b70fbfb73dce621b1fdad960321
parent177e62218e67cef8c437460de50724a41774c3f3

std.os.linux: make errno() generic so that it can handle u32 and u64 correctly

closes https://codeberg.org/ziglang/zig/issues/36883

1 files changed, 3 insertions(+), 4 deletions(-)

lib/std/os/linux.zig+3-4
...@@ -1039,10 +1039,9 @@ fn splitValue64(val: i64) [2]u32 {...@@ -1039,10 +1039,9 @@ fn splitValue64(val: i64) [2]u32 {
1039}1039}
10401040
1041/// Get the errno from a syscall return value. SUCCESS means no error.1041/// Get the errno from a syscall return value. SUCCESS means no error.
1042pub fn errno(r: u64) E {1042pub fn errno(r: anytype) E {
1043 const signed_r: i32 = @bitCast(@as(u32, @truncate(r)));1043 const signed_r: @Int(.signed, @typeInfo(@TypeOf(r)).int.bits) = @bitCast(r);
1044 const int = if (signed_r > -4096 and signed_r < 0) -signed_r else 0;1044 return @fromBackingInt(@intCast(if (signed_r > -4096 and signed_r < 0) -signed_r else 0));
1045 return @fromBackingInt(@intCast(int));
1046}1045}
10471046
1048pub fn brk(addr: usize) usize {1047pub fn brk(addr: usize) usize {