diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-12-14 16:46:08 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-12-23 22:15:09 -0800 |
| commit | 4458e423bf2d2cf485031d1f527e407bfc9113df (patch) | |
| tree | 346c1463c8bbf76bf690a056e2851754e8661dae /lib | |
| parent | 2a40c1b556d7ed7811d3d2432dce8ba5d7c2e753 (diff) | |
| download | zig-4458e423bf2d2cf485031d1f527e407bfc9113df.tar.gz zig-4458e423bf2d2cf485031d1f527e407bfc9113df.zip | |
link.MappedFile: update statx usage
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/Io/Threaded.zig | 18 | ||||
| -rw-r--r-- | lib/std/testing.zig | 7 | ||||
| -rw-r--r-- | lib/std/zig/ErrorBundle.zig | 5 | ||||
| -rw-r--r-- | lib/std/zig/parser_test.zig | 4 |
4 files changed, 24 insertions, 10 deletions
diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index f4f42cc39f..d9ef36cfda 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -1822,6 +1822,11 @@ fn dirStatFileLinux( const t: *Threaded = @ptrCast(@alignCast(userdata)); const current_thread = Thread.getCurrent(t); const linux = std.os.linux; + const use_c = std.c.versionCheck(if (builtin.abi.isAndroid()) + .{ .major = 30, .minor = 0, .patch = 0 } + else + .{ .major = 2, .minor = 28, .patch = 0 }); + const sys = if (use_c) std.c else std.os.linux; var path_buffer: [posix.PATH_MAX]u8 = undefined; const sub_path_posix = try pathToPosix(sub_path, &path_buffer); @@ -1832,14 +1837,14 @@ fn dirStatFileLinux( try current_thread.beginSyscall(); while (true) { var statx = std.mem.zeroes(linux.Statx); - const rc = linux.statx( + const rc = sys.statx( dir.handle, sub_path_posix, flags, .{ .TYPE = true, .MODE = true, .ATIME = true, .MTIME = true, .CTIME = true, .INO = true, .SIZE = true }, &statx, ); - switch (linux.errno(rc)) { + switch (sys.errno(rc)) { .SUCCESS => { current_thread.endSyscall(); assert(statx.mask.TYPE); @@ -2076,18 +2081,23 @@ fn fileStatLinux(userdata: ?*anyopaque, file: File) File.StatError!File.Stat { const t: *Threaded = @ptrCast(@alignCast(userdata)); const current_thread = Thread.getCurrent(t); const linux = std.os.linux; + const use_c = std.c.versionCheck(if (builtin.abi.isAndroid()) + .{ .major = 30, .minor = 0, .patch = 0 } + else + .{ .major = 2, .minor = 28, .patch = 0 }); + const sys = if (use_c) std.c else std.os.linux; try current_thread.beginSyscall(); while (true) { var statx = std.mem.zeroes(linux.Statx); - const rc = linux.statx( + const rc = sys.statx( file.handle, "", linux.AT.EMPTY_PATH, .{ .TYPE = true, .MODE = true, .ATIME = true, .MTIME = true, .CTIME = true, .INO = true, .SIZE = true }, &statx, ); - switch (linux.errno(rc)) { + switch (sys.errno(rc)) { .SUCCESS => { current_thread.endSyscall(); assert(statx.mask.TYPE); diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 64ea3d1a4d..be6f316804 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -1148,9 +1148,10 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime break :x failing_allocator_inst.alloc_index; }; - var fail_index: usize = 0; - while (fail_index < needed_alloc_count) : (fail_index += 1) { - var failing_allocator_inst = std.testing.FailingAllocator.init(backing_allocator, .{ .fail_index = fail_index }); + for (0..needed_alloc_count) |fail_index| { + var failing_allocator_inst = std.testing.FailingAllocator.init(backing_allocator, .{ + .fail_index = fail_index, + }); args.@"0" = failing_allocator_inst.allocator(); if (@call(.auto, test_fn, args)) |_| { diff --git a/lib/std/zig/ErrorBundle.zig b/lib/std/zig/ErrorBundle.zig index 0342874cf9..907256c2e4 100644 --- a/lib/std/zig/ErrorBundle.zig +++ b/lib/std/zig/ErrorBundle.zig @@ -168,7 +168,10 @@ pub fn renderToStderr(eb: ErrorBundle, io: Io, options: RenderOptions, color: st var buffer: [256]u8 = undefined; const stderr = try io.lockStderrWriter(&buffer); defer io.unlockStderrWriter(); - try renderToWriter(eb, options, &stderr.interface, color.getTtyConf(stderr.mode)); + renderToWriter(eb, options, &stderr.interface, color.getTtyConf(stderr.mode)) catch |err| switch (err) { + error.WriteFailed => return stderr.interface.err.?, + else => |e| return e, + }; } pub fn renderToWriter( diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index 5318eab2df..6c11c3021b 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -6362,9 +6362,9 @@ fn testParse(io: Io, source: [:0]const u8, allocator: Allocator, anything_change return formatted; } fn testTransformImpl( - io: Io, allocator: Allocator, fba: *std.heap.FixedBufferAllocator, + io: Io, source: [:0]const u8, expected_source: []const u8, ) !void { @@ -6386,7 +6386,7 @@ fn testTransform(source: [:0]const u8, expected_source: []const u8) !void { const io = std.testing.io; var fixed_allocator = std.heap.FixedBufferAllocator.init(fixed_buffer_mem[0..]); return std.testing.checkAllAllocationFailures(fixed_allocator.allocator(), testTransformImpl, .{ - io, &fixed_allocator, source, expected_source, + &fixed_allocator, io, source, expected_source, }); } fn testCanonical(source: [:0]const u8) !void { |
