authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-22 23:24:18-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-23 22:15:12-08:00
log669dae140c63b1bf4dbae6634145529333cd8371
tree9ea258107e97dbe378daa8e79c2e0e9b0723fc1b
parent0870f17501aa7d2eaaf2d774ccbc5d72291664ca

test-standalone: fix most compilation errors


28 files changed, 181 insertions(+), 169 deletions(-)

lib/fuzzer.zig+39-45
......@@ -1,18 +1,22 @@
11const builtin = @import("builtin");
2const native_endian = builtin.cpu.arch.endian();
3
24const std = @import("std");
5const Io = std.Io;
36const fatal = std.process.fatal;
47const mem = std.mem;
58const math = std.math;
6const Allocator = mem.Allocator;
9const Allocator = std.mem.Allocator;
710const assert = std.debug.assert;
811const panic = std.debug.panic;
912const abi = std.Build.abi.fuzz;
10const native_endian = builtin.cpu.arch.endian();
1113
1214pub const std_options = std.Options{
1315 .logFn = logOverride,
1416};
1517
18const io = std.Io.Threaded.global_single_threaded.ioBasic();
19
1620fn logOverride(
1721 comptime level: std.log.Level,
1822 comptime scope: @EnumLiteral(),
......@@ -21,12 +25,12 @@ fn logOverride(
2125) void {
2226 const f = log_f orelse
2327 panic("attempt to use log before initialization, message:\n" ++ format, args);
24 f.lock(.exclusive) catch |e| panic("failed to lock logging file: {t}", .{e});
25 defer f.unlock();
28 f.lock(io, .exclusive) catch |e| panic("failed to lock logging file: {t}", .{e});
29 defer f.unlock(io);
2630
2731 var buf: [256]u8 = undefined;
28 var fw = f.writer(&buf);
29 const end = f.getEndPos() catch |e| panic("failed to get fuzzer log file end: {t}", .{e});
32 var fw = f.writer(io, &buf);
33 const end = f.length(io) catch |e| panic("failed to get fuzzer log file end: {t}", .{e});
3034 fw.seekTo(end) catch |e| panic("failed to seek to fuzzer log file end: {t}", .{e});
3135
3236 const prefix1 = comptime level.asText();
......@@ -45,7 +49,7 @@ const gpa = switch (builtin.mode) {
4549};
4650
4751/// Part of `exec`, however seperate to allow it to be set before `exec` is.
48var log_f: ?std.fs.File = null;
52var log_f: ?Io.File = null;
4953var exec: Executable = .preinit;
5054var inst: Instrumentation = .preinit;
5155var fuzzer: Fuzzer = undefined;
......@@ -59,7 +63,7 @@ const Executable = struct {
5963 /// Tracks the hit count for each pc as updated by the process's instrumentation.
6064 pc_counters: []u8,
6165
62 cache_f: std.fs.Dir,
66 cache_f: Io.Dir,
6367 /// Shared copy of all pcs that have been hit stored in a memory-mapped file that can viewed
6468 /// while the fuzzer is running.
6569 shared_seen_pcs: MemoryMappedList,
......@@ -76,16 +80,16 @@ const Executable = struct {
7680 .pc_digest = undefined,
7781 };
7882
79 fn getCoverageFile(cache_dir: std.fs.Dir, pcs: []const usize, pc_digest: u64) MemoryMappedList {
83 fn getCoverageFile(cache_dir: Io.Dir, pcs: []const usize, pc_digest: u64) MemoryMappedList {
8084 const pc_bitset_usizes = bitsetUsizes(pcs.len);
8185 const coverage_file_name = std.fmt.hex(pc_digest);
8286 comptime assert(abi.SeenPcsHeader.trailing[0] == .pc_bits_usize);
8387 comptime assert(abi.SeenPcsHeader.trailing[1] == .pc_addr);
8488
85 var v = cache_dir.makeOpenPath("v", .{}) catch |e|
89 var v = cache_dir.createDirPathOpen(io, "v", .{}) catch |e|
8690 panic("failed to create directory 'v': {t}", .{e});
87 defer v.close();
88 const coverage_file, const populate = if (v.createFile(&coverage_file_name, .{
91 defer v.close(io);
92 const coverage_file, const populate = if (v.createFile(io, &coverage_file_name, .{
8993 .read = true,
9094 // If we create the file, we want to block other processes while we populate it
9195 .lock = .exclusive,
......@@ -93,7 +97,7 @@ const Executable = struct {
9397 })) |f|
9498 .{ f, true }
9599 else |e| switch (e) {
96 error.PathAlreadyExists => .{ v.openFile(&coverage_file_name, .{
100 error.PathAlreadyExists => .{ v.openFile(io, &coverage_file_name, .{
97101 .mode = .read_write,
98102 .lock = .shared,
99103 }) catch |e2| panic(
......@@ -108,7 +112,7 @@ const Executable = struct {
108112 pcs.len * @sizeOf(usize);
109113
110114 if (populate) {
111 defer coverage_file.lock(.shared) catch |e| panic(
115 defer coverage_file.lock(io, .shared) catch |e| panic(
112116 "failed to demote lock for coverage file '{s}': {t}",
113117 .{ &coverage_file_name, e },
114118 );
......@@ -130,10 +134,8 @@ const Executable = struct {
130134 }
131135 return map;
132136 } else {
133 const size = coverage_file.getEndPos() catch |e| panic(
134 "failed to stat coverage file '{s}': {t}",
135 .{ &coverage_file_name, e },
136 );
137 const size = coverage_file.length(io) catch |e|
138 panic("failed to stat coverage file '{s}': {t}", .{ &coverage_file_name, e });
137139 if (size != coverage_file_len) panic(
138140 "incompatible existing coverage file '{s}' (differing lengths: {} != {})",
139141 .{ &coverage_file_name, size, coverage_file_len },
......@@ -165,13 +167,11 @@ const Executable = struct {
165167 pub fn init(cache_dir_path: []const u8) Executable {
166168 var self: Executable = undefined;
167169
168 const cache_dir = std.fs.cwd().makeOpenPath(cache_dir_path, .{}) catch |e| panic(
169 "failed to open directory '{s}': {t}",
170 .{ cache_dir_path, e },
171 );
172 log_f = cache_dir.createFile("tmp/libfuzzer.log", .{ .truncate = false }) catch |e|
170 const cache_dir = Io.Dir.cwd().createDirPathOpen(io, cache_dir_path, .{}) catch |e|
171 panic("failed to open directory '{s}': {t}", .{ cache_dir_path, e });
172 log_f = cache_dir.createFile(io, "tmp/libfuzzer.log", .{ .truncate = false }) catch |e|
173173 panic("failed to create file 'tmp/libfuzzer.log': {t}", .{e});
174 self.cache_f = cache_dir.makeOpenPath("f", .{}) catch |e|
174 self.cache_f = cache_dir.createDirPathOpen(io, "f", .{}) catch |e|
175175 panic("failed to open directory 'f': {t}", .{e});
176176
177177 // Linkers are expected to automatically add symbols prefixed with these for the start and
......@@ -391,7 +391,7 @@ const Fuzzer = struct {
391391 mutations: std.ArrayList(Mutation) = .empty,
392392
393393 /// Filesystem directory containing found inputs for future runs
394 corpus_dir: std.fs.Dir,
394 corpus_dir: Io.Dir,
395395 corpus_dir_idx: usize = 0,
396396
397397 pub fn init(test_one: abi.TestOne, unit_test_name: []const u8) Fuzzer {
......@@ -405,10 +405,10 @@ const Fuzzer = struct {
405405 };
406406 const arena = self.arena_ctx.allocator();
407407
408 self.corpus_dir = exec.cache_f.makeOpenPath(unit_test_name, .{}) catch |e|
408 self.corpus_dir = exec.cache_f.createDirPathOpen(io, unit_test_name, .{}) catch |e|
409409 panic("failed to open directory '{s}': {t}", .{ unit_test_name, e });
410410 self.input = in: {
411 const f = self.corpus_dir.createFile("in", .{
411 const f = self.corpus_dir.createFile(io, "in", .{
412412 .read = true,
413413 .truncate = false,
414414 // In case any other fuzz tests are running under the same test name,
......@@ -419,7 +419,7 @@ const Fuzzer = struct {
419419 error.WouldBlock => @panic("input file 'in' is in use by another fuzzing process"),
420420 else => panic("failed to create input file 'in': {t}", .{e}),
421421 };
422 const size = f.getEndPos() catch |e| panic("failed to stat input file 'in': {t}", .{e});
422 const size = f.length(io) catch |e| panic("failed to stat input file 'in': {t}", .{e});
423423 const map = (if (size < std.heap.page_size_max)
424424 MemoryMappedList.create(f, 8, std.heap.page_size_max)
425425 else
......@@ -445,6 +445,7 @@ const Fuzzer = struct {
445445 while (true) {
446446 var name_buf: [@sizeOf(usize) * 2]u8 = undefined;
447447 const bytes = self.corpus_dir.readFileAlloc(
448 io,
448449 std.fmt.bufPrint(&name_buf, "{x}", .{self.corpus_dir_idx}) catch unreachable,
449450 arena,
450451 .unlimited,
......@@ -466,7 +467,7 @@ const Fuzzer = struct {
466467 self.input.deinit();
467468 self.corpus.deinit(gpa);
468469 self.mutations.deinit(gpa);
469 self.corpus_dir.close();
470 self.corpus_dir.close(io);
470471 self.arena_ctx.deinit();
471472 self.* = undefined;
472473 }
......@@ -573,17 +574,10 @@ const Fuzzer = struct {
573574
574575 // Write new corpus to cache
575576 var name_buf: [@sizeOf(usize) * 2]u8 = undefined;
576 self.corpus_dir.writeFile(.{
577 .sub_path = std.fmt.bufPrint(
578 &name_buf,
579 "{x}",
580 .{self.corpus_dir_idx},
581 ) catch unreachable,
577 self.corpus_dir.writeFile(io, .{
578 .sub_path = std.fmt.bufPrint(&name_buf, "{x}", .{self.corpus_dir_idx}) catch unreachable,
582579 .data = bytes,
583 }) catch |e| panic(
584 "failed to write corpus file '{x}': {t}",
585 .{ self.corpus_dir_idx, e },
586 );
580 }) catch |e| panic("failed to write corpus file '{x}': {t}", .{ self.corpus_dir_idx, e });
587581 self.corpus_dir_idx += 1;
588582 }
589583 }
......@@ -1320,9 +1314,9 @@ pub const MemoryMappedList = struct {
13201314 /// How many bytes this list can hold without allocating additional memory.
13211315 capacity: usize,
13221316 /// The file is kept open so that it can be resized.
1323 file: std.fs.File,
1317 file: Io.File,
13241318
1325 pub fn init(file: std.fs.File, length: usize, capacity: usize) !MemoryMappedList {
1319 pub fn init(file: Io.File, length: usize, capacity: usize) !MemoryMappedList {
13261320 const ptr = try std.posix.mmap(
13271321 null,
13281322 capacity,
......@@ -1338,13 +1332,13 @@ pub const MemoryMappedList = struct {
13381332 };
13391333 }
13401334
1341 pub fn create(file: std.fs.File, length: usize, capacity: usize) !MemoryMappedList {
1342 try file.setEndPos(capacity);
1335 pub fn create(file: Io.File, length: usize, capacity: usize) !MemoryMappedList {
1336 try file.setLength(io, capacity);
13431337 return init(file, length, capacity);
13441338 }
13451339
13461340 pub fn deinit(l: *MemoryMappedList) void {
1347 l.file.close();
1341 l.file.close(io);
13481342 std.posix.munmap(@volatileCast(l.items.ptr[0..l.capacity]));
13491343 l.* = undefined;
13501344 }
......@@ -1369,7 +1363,7 @@ pub const MemoryMappedList = struct {
13691363 if (l.capacity >= new_capacity) return;
13701364
13711365 std.posix.munmap(@volatileCast(l.items.ptr[0..l.capacity]));
1372 try l.file.setEndPos(new_capacity);
1366 try l.file.setLength(io, new_capacity);
13731367 l.* = try init(l.file, l.items.len, new_capacity);
13741368 }
13751369
test/standalone/child_process/child.zig+6-6
......@@ -26,14 +26,14 @@ fn run(allocator: std.mem.Allocator, io: Io) !void {
2626 const hello_arg = "hello arg";
2727 const a1 = args.next() orelse unreachable;
2828 if (!std.mem.eql(u8, a1, hello_arg)) {
29 testError("first arg: '{s}'; want '{s}'", .{ a1, hello_arg });
29 testError(io, "first arg: '{s}'; want '{s}'", .{ a1, hello_arg });
3030 }
3131 if (args.next()) |a2| {
32 testError("expected only one arg; got more: {s}", .{a2});
32 testError(io, "expected only one arg; got more: {s}", .{a2});
3333 }
3434
3535 // test stdout pipe; parent verifies
36 try std.Io.File.stdout().writeAll("hello from stdout");
36 try std.Io.File.stdout().writeStreamingAll(io, "hello from stdout");
3737
3838 // test stdin pipe from parent
3939 const hello_stdin = "hello from stdin";
......@@ -42,12 +42,12 @@ fn run(allocator: std.mem.Allocator, io: Io) !void {
4242 var reader = stdin.reader(io, &.{});
4343 const n = try reader.interface.readSliceShort(&buf);
4444 if (!std.mem.eql(u8, buf[0..n], hello_stdin)) {
45 testError("stdin: '{s}'; want '{s}'", .{ buf[0..n], hello_stdin });
45 testError(io, "stdin: '{s}'; want '{s}'", .{ buf[0..n], hello_stdin });
4646 }
4747}
4848
49fn testError(comptime fmt: []const u8, args: anytype) void {
50 var stderr_writer = std.Io.File.stderr().writer(&.{});
49fn testError(io: Io, comptime fmt: []const u8, args: anytype) void {
50 var stderr_writer = std.Io.File.stderr().writer(io, &.{});
5151 const stderr = &stderr_writer.interface;
5252 stderr.print("CHILD TEST ERROR: ", .{}) catch {};
5353 stderr.print(fmt, args) catch {};
test/standalone/child_process/main.zig+2-2
......@@ -31,7 +31,7 @@ pub fn main() !void {
3131 child.stderr_behavior = .Inherit;
3232 try child.spawn(io);
3333 const child_stdin = child.stdin.?;
34 try child_stdin.writeAll("hello from stdin"); // verified in child
34 try child_stdin.writeStreamingAll(io, "hello from stdin"); // verified in child
3535 child_stdin.close(io);
3636 child.stdin = null;
3737
......@@ -43,7 +43,7 @@ pub fn main() !void {
4343 testError(io, "child stdout: '{s}'; want '{s}'", .{ buf[0..n], hello_stdout });
4444 }
4545
46 switch (try child.wait()) {
46 switch (try child.wait(io)) {
4747 .Exited => |code| {
4848 const child_ok_code = 42; // set by child if no test errors
4949 if (code != child_ok_code) {
test/standalone/dirname/exists_in.zig+1-1
......@@ -39,5 +39,5 @@ fn run(allocator: std.mem.Allocator) !void {
3939 var dir = try std.Io.Dir.cwd().openDir(io, dir_path, .{});
4040 defer dir.close(io);
4141
42 _ = try dir.statFile(io, relpath);
42 _ = try dir.statFile(io, relpath, .{});
4343}
test/standalone/dirname/touch.zig+1-1
......@@ -34,7 +34,7 @@ fn run(allocator: std.mem.Allocator) !void {
3434 var dir = try std.Io.Dir.cwd().openDir(io, dir_path, .{});
3535 defer dir.close(io);
3636
37 _ = dir.statFile(io, basename) catch {
37 _ = dir.statFile(io, basename, .{}) catch {
3838 var file = try dir.createFile(io, basename, .{});
3939 file.close(io);
4040 };
test/standalone/install_headers/check_exists.zig+3-3
......@@ -14,7 +14,7 @@ pub fn main() !void {
1414 const io = std.Io.Threaded.global_single_threaded.ioBasic();
1515
1616 const cwd = std.Io.Dir.cwd();
17 const cwd_realpath = try cwd.realPathAlloc(io, arena, ".");
17 const cwd_realpath = try cwd.realPathFileAlloc(io, ".", arena);
1818
1919 while (arg_it.next()) |file_path| {
2020 if (file_path.len > 0 and file_path[0] == '!') {
......@@ -22,7 +22,7 @@ pub fn main() !void {
2222 "exclusive file check '{s}{c}{s}' failed",
2323 .{ cwd_realpath, std.fs.path.sep, file_path[1..] },
2424 );
25 if (cwd.statFile(io, file_path[1..])) |_| {
25 if (cwd.statFile(io, file_path[1..], .{})) |_| {
2626 return error.FileFound;
2727 } else |err| switch (err) {
2828 error.FileNotFound => {},
......@@ -33,7 +33,7 @@ pub fn main() !void {
3333 "inclusive file check '{s}{c}{s}' failed",
3434 .{ cwd_realpath, std.fs.path.sep, file_path },
3535 );
36 _ = try cwd.statFile(io, file_path);
36 _ = try cwd.statFile(io, file_path, .{});
3737 }
3838 }
3939}
test/standalone/run_output_caching/main.zig+1-1
......@@ -7,5 +7,5 @@ pub fn main() !void {
77 const filename = args.next().?;
88 const file = try std.Io.Dir.cwd().createFile(io, filename, .{});
99 defer file.close(io);
10 try file.writeAll(io, filename);
10 try file.writeStreamingAll(io, filename);
1111}
test/standalone/run_output_paths/create_file.zig+2-2
......@@ -10,8 +10,8 @@ pub fn main() !void {
1010 else
1111 dir_name, .{});
1212 const file_name = args.next().?;
13 const file = try dir.createFile(file_name, .{});
14 var file_writer = file.writer(&.{});
13 const file = try dir.createFile(io, file_name, .{});
14 var file_writer = file.writer(io, &.{});
1515 try file_writer.interface.print(
1616 \\{s}
1717 \\{s}
test/standalone/self_exe_symlink/main.zig+3-2
......@@ -12,10 +12,11 @@ pub fn main() !void {
1212 const self_path = try std.process.executablePathAlloc(io, gpa);
1313 defer gpa.free(self_path);
1414
15 var self_exe = try std.fs.openSelfExe(.{});
15 var self_exe = try std.process.openExecutable(io, .{});
1616 defer self_exe.close(io);
17
1718 var buf: [std.fs.max_path_bytes]u8 = undefined;
18 const self_exe_path = try std.os.getFdPath(self_exe.handle, &buf);
19 const self_exe_path = buf[0..try self_exe.realPath(io, &buf)];
1920
2021 try std.testing.expectEqualStrings(self_exe_path, self_path);
2122}
tools/dump-cov.zig+5-3
......@@ -2,6 +2,7 @@
22//! including file:line:column information for each PC.
33
44const std = @import("std");
5const Io = std.Io;
56const fatal = std.process.fatal;
67const Path = std.Build.Cache.Path;
78const assert = std.debug.assert;
......@@ -16,7 +17,7 @@ pub fn main() !void {
1617 defer arena_instance.deinit();
1718 const arena = arena_instance.allocator();
1819
19 var threaded: std.Io.Threaded = .init(gpa, .{});
20 var threaded: Io.Threaded = .init(gpa, .{});
2021 defer threaded.deinit();
2122 const io = threaded.io();
2223
......@@ -57,6 +58,7 @@ pub fn main() !void {
5758 defer debug_info.deinit(gpa);
5859
5960 const cov_bytes = cov_path.root_dir.handle.readFileAllocOptions(
61 io,
6062 cov_path.sub_path,
6163 arena,
6264 .limited(1 << 30),
......@@ -67,7 +69,7 @@ pub fn main() !void {
6769 };
6870
6971 var stdout_buffer: [4000]u8 = undefined;
70 var stdout_writer = std.fs.File.stdout().writerStreaming(&stdout_buffer);
72 var stdout_writer = Io.File.stdout().writerStreaming(io, &stdout_buffer);
7173 const stdout = &stdout_writer.interface;
7274
7375 const header: *SeenPcsHeader = @ptrCast(cov_bytes);
......@@ -83,7 +85,7 @@ pub fn main() !void {
8385 std.mem.sortUnstable(usize, sorted_pcs, {}, std.sort.asc(usize));
8486
8587 const source_locations = try arena.alloc(std.debug.Coverage.SourceLocation, sorted_pcs.len);
86 try debug_info.resolveAddresses(gpa, sorted_pcs, source_locations);
88 try debug_info.resolveAddresses(gpa, io, sorted_pcs, source_locations);
8789
8890 const seen_pcs = header.seenBits();
8991
tools/fetch_them_macos_headers.zig+6-9
......@@ -92,7 +92,7 @@ pub fn main() anyerror!void {
9292
9393 const sysroot_path = sysroot orelse blk: {
9494 const target = try std.zig.system.resolveTargetQuery(io, .{});
95 break :blk std.zig.system.darwin.getSdk(allocator, &target) orelse
95 break :blk std.zig.system.darwin.getSdk(allocator, io, &target) orelse
9696 fatal("no SDK found; you can provide one explicitly with '--sysroot' flag", .{});
9797 };
9898
......@@ -166,10 +166,7 @@ fn fetchTarget(
166166 });
167167 try cc_argv.appendSlice(args);
168168
169 const res = try std.process.Child.run(.{
170 .allocator = arena,
171 .argv = cc_argv.items,
172 });
169 const res = try std.process.Child.run(arena, io, .{ .argv = cc_argv.items });
173170
174171 if (res.stderr.len != 0) {
175172 std.log.err("{s}", .{res.stderr});
......@@ -179,7 +176,7 @@ fn fetchTarget(
179176 const headers_list_file = try tmp.dir.openFile(io, headers_list_filename, .{});
180177 defer headers_list_file.close(io);
181178
182 var headers_dir = Dir.cwd().openDir(headers_source_prefix, .{}) catch |err| switch (err) {
179 var headers_dir = Dir.cwd().openDir(io, headers_source_prefix, .{}) catch |err| switch (err) {
183180 error.FileNotFound,
184181 error.NotDir,
185182 => fatal("path '{s}' not found or not a directory. Did you accidentally delete it?", .{
......@@ -215,15 +212,15 @@ fn fetchTarget(
215212
216213 const line_stripped = mem.trim(u8, line, " \\");
217214 const abs_dirname = Dir.path.dirname(line_stripped).?;
218 var orig_subdir = try Dir.cwd().openDir(abs_dirname, .{});
215 var orig_subdir = try Dir.cwd().openDir(io, abs_dirname, .{});
219216 defer orig_subdir.close(io);
220217
221 try orig_subdir.copyFile(basename, maybe_dir.value_ptr.*, basename, .{});
218 try orig_subdir.copyFile(basename, maybe_dir.value_ptr.*, basename, io, .{});
222219 }
223220 }
224221
225222 var dir_it = dirs.iterator();
226 while (dir_it.next(io)) |entry| {
223 while (dir_it.next()) |entry| {
227224 entry.value_ptr.close(io);
228225 }
229226}
tools/gen_macos_headers_c.zig+6-6
......@@ -38,7 +38,7 @@ pub fn main() anyerror!void {
3838
3939 if (positionals.items.len != 1) fatal("expected one positional argument: [dir]", .{});
4040
41 var dir = try std.fs.cwd().openDir(io, positionals.items[0], .{ .follow_symlinks = false });
41 var dir = try Io.Dir.cwd().openDir(io, positionals.items[0], .{ .follow_symlinks = false });
4242 defer dir.close(io);
4343 var paths = std.array_list.Managed([]const u8).init(arena);
4444 try findHeaders(arena, io, dir, "", &paths);
......@@ -53,7 +53,7 @@ pub fn main() anyerror!void {
5353 std.mem.sort([]const u8, paths.items, {}, SortFn.lessThan);
5454
5555 var buffer: [2000]u8 = undefined;
56 var stdout_writer = std.fs.File.stdout().writerStreaming(&buffer);
56 var stdout_writer = Io.File.stdout().writerStreaming(io, &buffer);
5757 const w = &stdout_writer.interface;
5858 try w.writeAll("#define _XOPEN_SOURCE\n");
5959 for (paths.items) |path| {
......@@ -75,18 +75,18 @@ fn findHeaders(
7575 paths: *std.array_list.Managed([]const u8),
7676) anyerror!void {
7777 var it = dir.iterate();
78 while (try it.next()) |entry| {
78 while (try it.next(io)) |entry| {
7979 switch (entry.kind) {
8080 .directory => {
81 const path = try std.fs.path.join(arena, &.{ prefix, entry.name });
81 const path = try Io.Dir.path.join(arena, &.{ prefix, entry.name });
8282 var subdir = try dir.openDir(io, entry.name, .{ .follow_symlinks = false });
8383 defer subdir.close(io);
8484 try findHeaders(arena, io, subdir, path, paths);
8585 },
8686 .file, .sym_link => {
87 const ext = std.fs.path.extension(entry.name);
87 const ext = Io.Dir.path.extension(entry.name);
8888 if (!std.mem.eql(u8, ext, ".h")) continue;
89 const path = try std.fs.path.join(arena, &.{ prefix, entry.name });
89 const path = try Io.Dir.path.join(arena, &.{ prefix, entry.name });
9090 try paths.append(path);
9191 },
9292 else => {},
tools/gen_outline_atomics.zig+6-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const Io = std.Io;
23const Allocator = std.mem.Allocator;
34
45const AtomicOp = enum {
......@@ -15,10 +16,14 @@ pub fn main() !void {
1516 defer arena_instance.deinit();
1617 const arena = arena_instance.allocator();
1718
19 var threaded: std.Io.Threaded = .init(arena, .{});
20 defer threaded.deinit();
21 const io = threaded.io();
22
1823 //const args = try std.process.argsAlloc(arena);
1924
2025 var stdout_buffer: [2000]u8 = undefined;
21 var stdout_writer = std.fs.File.stdout().writerStreaming(&stdout_buffer);
26 var stdout_writer = Io.File.stdout().writerStreaming(io, &stdout_buffer);
2227 const w = &stdout_writer.interface;
2328
2429 try w.writeAll(
tools/gen_spirv_spec.zig+20-14
......@@ -1,5 +1,7 @@
11const std = @import("std");
2const Io = std.Io;
23const Allocator = std.mem.Allocator;
4
35const g = @import("spirv/grammar.zig");
46const CoreRegistry = g.CoreRegistry;
57const ExtensionRegistry = g.ExtensionRegistry;
......@@ -63,24 +65,28 @@ pub fn main() !void {
6365 usageAndExit(args[0], 1);
6466 }
6567
66 const json_path = try std.fs.path.join(allocator, &.{ args[1], "include/spirv/unified1/" });
67 const dir = try std.fs.cwd().openDir(json_path, .{ .iterate = true });
68 var threaded: std.Io.Threaded = .init(allocator, .{});
69 defer threaded.deinit();
70 const io = threaded.io();
71
72 const json_path = try Io.Dir.path.join(allocator, &.{ args[1], "include/spirv/unified1/" });
73 const dir = try Io.Dir.cwd().openDir(io, json_path, .{ .iterate = true });
6874
69 const core_spec = try readRegistry(CoreRegistry, dir, "spirv.core.grammar.json");
75 const core_spec = try readRegistry(io, CoreRegistry, dir, "spirv.core.grammar.json");
7076 std.mem.sortUnstable(Instruction, core_spec.instructions, CmpInst{}, CmpInst.lt);
7177
7278 var exts = std.array_list.Managed(Extension).init(allocator);
7379
7480 var it = dir.iterate();
75 while (try it.next()) |entry| {
81 while (try it.next(io)) |entry| {
7682 if (entry.kind != .file) {
7783 continue;
7884 }
7985
80 try readExtRegistry(&exts, dir, entry.name);
86 try readExtRegistry(io, &exts, dir, entry.name);
8187 }
8288
83 try readExtRegistry(&exts, std.fs.cwd(), args[2]);
89 try readExtRegistry(io, &exts, Io.Dir.cwd(), args[2]);
8490
8591 var allocating: std.Io.Writer.Allocating = .init(allocator);
8692 defer allocating.deinit();
......@@ -91,7 +97,7 @@ pub fn main() !void {
9197 var tree = try std.zig.Ast.parse(allocator, output, .zig);
9298
9399 if (tree.errors.len != 0) {
94 try std.zig.printAstErrorsToStderr(allocator, tree, "", .auto);
100 try std.zig.printAstErrorsToStderr(allocator, io, tree, "", .auto);
95101 return;
96102 }
97103
......@@ -103,22 +109,22 @@ pub fn main() !void {
103109 try wip_errors.addZirErrorMessages(zir, tree, output, "");
104110 var error_bundle = try wip_errors.toOwnedBundle("");
105111 defer error_bundle.deinit(allocator);
106 error_bundle.renderToStdErr(.{}, .auto);
112 try error_bundle.renderToStderr(io, .{}, .auto);
107113 }
108114
109115 const formatted_output = try tree.renderAlloc(allocator);
110 _ = try std.fs.File.stdout().write(formatted_output);
116 try Io.File.stdout().writeStreamingAll(io, formatted_output);
111117}
112118
113fn readExtRegistry(exts: *std.array_list.Managed(Extension), dir: std.fs.Dir, sub_path: []const u8) !void {
114 const filename = std.fs.path.basename(sub_path);
119fn readExtRegistry(io: Io, exts: *std.array_list.Managed(Extension), dir: Io.Dir, sub_path: []const u8) !void {
120 const filename = Io.Dir.path.basename(sub_path);
115121 if (!std.mem.startsWith(u8, filename, "extinst.")) {
116122 return;
117123 }
118124
119125 std.debug.assert(std.mem.endsWith(u8, filename, ".grammar.json"));
120126 const name = filename["extinst.".len .. filename.len - ".grammar.json".len];
121 const spec = try readRegistry(ExtensionRegistry, dir, sub_path);
127 const spec = try readRegistry(io, ExtensionRegistry, dir, sub_path);
122128
123129 const set_name = set_names.get(name) orelse {
124130 std.log.info("ignored instruction set '{s}'", .{name});
......@@ -134,8 +140,8 @@ fn readExtRegistry(exts: *std.array_list.Managed(Extension), dir: std.fs.Dir, su
134140 });
135141}
136142
137fn readRegistry(comptime RegistryType: type, dir: std.fs.Dir, path: []const u8) !RegistryType {
138 const spec = try dir.readFileAlloc(path, allocator, .unlimited);
143fn readRegistry(io: Io, comptime RegistryType: type, dir: Io.Dir, path: []const u8) !RegistryType {
144 const spec = try dir.readFileAlloc(io, path, allocator, .unlimited);
139145 // Required for json parsing.
140146 // TODO: ALI
141147 @setEvalBranchQuota(10000);
tools/gen_stubs.zig+12-5
......@@ -55,12 +55,14 @@
5555// - e.g. find a common previous symbol and put it after that one
5656// - they definitely need to go into the correct section
5757
58const builtin = @import("builtin");
59const native_endian = builtin.cpu.arch.endian();
60
5861const std = @import("std");
59const builtin = std.builtin;
62const Io = std.Io;
6063const mem = std.mem;
6164const log = std.log;
6265const elf = std.elf;
63const native_endian = @import("builtin").cpu.arch.endian();
6466
6567const Arch = enum {
6668 aarch64,
......@@ -284,10 +286,14 @@ pub fn main() !void {
284286 defer arena_instance.deinit();
285287 const arena = arena_instance.allocator();
286288
289 var threaded: std.Io.Threaded = .init(arena, .{});
290 defer threaded.deinit();
291 const io = threaded.io();
292
287293 const args = try std.process.argsAlloc(arena);
288294 const build_all_path = args[1];
289295
290 var build_all_dir = try std.fs.cwd().openDir(build_all_path, .{});
296 var build_all_dir = try Io.Dir.cwd().openDir(io, build_all_path, .{});
291297
292298 var sym_table = std.StringArrayHashMap(MultiSym).init(arena);
293299 var sections = std.StringArrayHashMap(void).init(arena);
......@@ -299,6 +305,7 @@ pub fn main() !void {
299305
300306 // Read the ELF header.
301307 const elf_bytes = build_all_dir.readFileAllocOptions(
308 io,
302309 libc_so_path,
303310 arena,
304311 .limited(100 * 1024 * 1024),
......@@ -334,7 +341,7 @@ pub fn main() !void {
334341 }
335342
336343 var stdout_buffer: [2000]u8 = undefined;
337 var stdout_writer = std.fs.File.stdout().writerStreaming(&stdout_buffer);
344 var stdout_writer = Io.File.stdout().writerStreaming(io, &stdout_buffer);
338345 const stdout = &stdout_writer.interface;
339346 try stdout.writeAll(
340347 \\#ifdef PTR64
......@@ -539,7 +546,7 @@ pub fn main() !void {
539546 try stdout.flush();
540547}
541548
542fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: builtin.Endian) !void {
549fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: std.builtin.Endian) !void {
543550 const arena = parse.arena;
544551 const elf_bytes = parse.elf_bytes;
545552 const header = parse.header;
tools/generate_JSONTestSuite.zig+9-4
......@@ -1,13 +1,18 @@
11// zig run this file inside the test_parsing/ directory of this repo: https://github.com/nst/JSONTestSuite
22
33const std = @import("std");
4const Io = std.Io;
45
56pub fn main() !void {
67 var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init;
78 var allocator = gpa.allocator();
89
10 var threaded: std.Io.Threaded = .init(allocator, .{});
11 defer threaded.deinit();
12 const io = threaded.io();
13
914 var stdout_buffer: [2000]u8 = undefined;
10 var stdout_writer = std.fs.File.stdout().writerStreaming(&stdout_buffer);
15 var stdout_writer = Io.File.stdout().writerStreaming(io, &stdout_buffer);
1116 const output = &stdout_writer.interface;
1217 try output.writeAll(
1318 \\// This file was generated by _generate_JSONTestSuite.zig
......@@ -20,9 +25,9 @@ pub fn main() !void {
2025 );
2126
2227 var names = std.array_list.Managed([]const u8).init(allocator);
23 var cwd = try std.fs.cwd().openDir(".", .{ .iterate = true });
28 var cwd = try Io.Dir.cwd().openDir(io, ".", .{ .iterate = true });
2429 var it = cwd.iterate();
25 while (try it.next()) |entry| {
30 while (try it.next(io)) |entry| {
2631 try names.append(try allocator.dupe(u8, entry.name));
2732 }
2833 std.mem.sort([]const u8, names.items, {}, (struct {
......@@ -32,7 +37,7 @@ pub fn main() !void {
3237 }).lessThan);
3338
3439 for (names.items) |name| {
35 const contents = try std.fs.cwd().readFileAlloc(name, allocator, .limited(250001));
40 const contents = try Io.Dir.cwd().readFileAlloc(io, name, allocator, .limited(250001));
3641 try output.writeAll("test ");
3742 try writeString(output, name);
3843 try output.writeAll(" {\n try ");
tools/generate_c_size_and_align_checks.zig+2-1
......@@ -7,6 +7,7 @@
77//! target.
88
99const std = @import("std");
10const Io = std.Io;
1011
1112fn cName(ty: std.Target.CType) []const u8 {
1213 return switch (ty) {
......@@ -47,7 +48,7 @@ pub fn main() !void {
4748 const target = try std.zig.system.resolveTargetQuery(io, query);
4849
4950 var buffer: [2000]u8 = undefined;
50 var stdout_writer = std.fs.File.stdout().writerStreaming(&buffer);
51 var stdout_writer = Io.File.stdout().writerStreaming(io, &buffer);
5152 const w = &stdout_writer.interface;
5253 inline for (@typeInfo(std.Target.CType).@"enum".fields) |field| {
5354 const c_type: std.Target.CType = @enumFromInt(field.value);
tools/generate_linux_syscalls.zig+3-3
......@@ -189,10 +189,10 @@ pub fn main() !void {
189189 const linux_path = args[1];
190190
191191 var stdout_buffer: [2048]u8 = undefined;
192 var stdout_writer = std.fs.File.stdout().writerStreaming(&stdout_buffer);
192 var stdout_writer = Io.File.stdout().writerStreaming(io, &stdout_buffer);
193193 const stdout = &stdout_writer.interface;
194194
195 var linux_dir = try std.fs.cwd().openDir(io, linux_path, .{});
195 var linux_dir = try Io.Dir.cwd().openDir(io, linux_path, .{});
196196 defer linux_dir.close(io);
197197
198198 // As of 6.11, the largest table is 24195 bytes.
......@@ -225,7 +225,7 @@ pub fn main() !void {
225225 , .{version});
226226
227227 for (architectures, 0..) |arch, i| {
228 const table = try linux_dir.readFile(switch (arch.table) {
228 const table = try linux_dir.readFile(io, switch (arch.table) {
229229 .generic => "scripts/syscall.tbl",
230230 .specific => |f| f,
231231 }, buf);
tools/migrate_langref.zig+7-7
......@@ -26,15 +26,15 @@ pub fn main() !void {
2626 defer threaded.deinit();
2727 const io = threaded.io();
2828
29 var in_file = try Dir.cwd().openFile(input_file, .{ .mode = .read_only });
29 var in_file = try Dir.cwd().openFile(io, input_file, .{ .mode = .read_only });
3030 defer in_file.close(io);
3131
32 var out_file = try Dir.cwd().createFile(output_file, .{});
32 var out_file = try Dir.cwd().createFile(io, output_file, .{});
3333 defer out_file.close(io);
3434 var out_file_buffer: [4096]u8 = undefined;
35 var out_file_writer = out_file.writer(&out_file_buffer);
35 var out_file_writer = out_file.writer(io, &out_file_buffer);
3636
37 var out_dir = try Dir.cwd().openDir(Dir.path.dirname(output_file).?, .{});
37 var out_dir = try Dir.cwd().openDir(io, Dir.path.dirname(output_file).?, .{});
3838 defer out_dir.close(io);
3939
4040 var in_file_reader = in_file.reader(io, &.{});
......@@ -42,7 +42,7 @@ pub fn main() !void {
4242
4343 var tokenizer = Tokenizer.init(input_file, input_file_bytes);
4444
45 try walk(arena, &tokenizer, out_dir, &out_file_writer.interface);
45 try walk(arena, io, &tokenizer, out_dir, &out_file_writer.interface);
4646
4747 try out_file_writer.end();
4848}
......@@ -387,12 +387,12 @@ fn walk(arena: Allocator, io: Io, tokenizer: *Tokenizer, out_dir: Dir, w: anytyp
387387
388388 const basename = try std.fmt.allocPrint(arena, "{s}.zig", .{name});
389389
390 var file = out_dir.createFile(basename, .{ .exclusive = true }) catch |err| {
390 var file = out_dir.createFile(io, basename, .{ .exclusive = true }) catch |err| {
391391 fatal("unable to create file '{s}': {s}", .{ name, @errorName(err) });
392392 };
393393 defer file.close(io);
394394 var file_buffer: [1024]u8 = undefined;
395 var file_writer = file.writer(&file_buffer);
395 var file_writer = file.writer(io, &file_buffer);
396396 const code = &file_writer.interface;
397397
398398 const source = tokenizer.buffer[source_token.start..source_token.end];
tools/process_headers.zig+4-6
......@@ -131,7 +131,7 @@ pub fn main() !void {
131131 var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
132132 const allocator = arena.allocator();
133133
134 var threaded: Io.Threaded = .init(allocator);
134 var threaded: Io.Threaded = .init(allocator, .{});
135135 defer threaded.deinit();
136136 const io = threaded.io();
137137
......@@ -253,14 +253,14 @@ pub fn main() !void {
253253
254254 var dir_it = dir.iterate();
255255
256 while (try dir_it.next()) |entry| {
256 while (try dir_it.next(io)) |entry| {
257257 const full_path = try Dir.path.join(allocator, &[_][]const u8{ full_dir_name, entry.name });
258258 switch (entry.kind) {
259259 .directory => try dir_stack.append(full_path),
260260 .file, .sym_link => {
261261 const rel_path = try Dir.path.relative(allocator, target_include_dir, full_path);
262262 const max_size = 2 * 1024 * 1024 * 1024;
263 const raw_bytes = try Dir.cwd().readFileAlloc(full_path, allocator, .limited(max_size));
263 const raw_bytes = try Dir.cwd().readFileAlloc(io, full_path, allocator, .limited(max_size));
264264 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");
265265 total_bytes += raw_bytes.len;
266266 const hash = try allocator.alloc(u8, 32);
......@@ -273,9 +273,7 @@ pub fn main() !void {
273273 max_bytes_saved += raw_bytes.len;
274274 gop.value_ptr.hit_count += 1;
275275 std.debug.print("duplicate: {s} {s} ({B})\n", .{
276 libc_dir,
277 rel_path,
278 raw_bytes.len,
276 libc_dir, rel_path, raw_bytes.len,
279277 });
280278 } else {
281279 gop.value_ptr.* = Contents{
tools/update-linux-headers.zig+1-1
......@@ -206,7 +206,7 @@ pub fn main() !void {
206206
207207 var dir_it = dir.iterate();
208208
209 while (try dir_it.next()) |entry| {
209 while (try dir_it.next(io)) |entry| {
210210 const full_path = try Dir.path.join(arena, &[_][]const u8{ full_dir_name, entry.name });
211211 switch (entry.kind) {
212212 .directory => try dir_stack.append(full_path),
tools/update_clang_options.zig+7-4
......@@ -10,7 +10,7 @@
1010//! would mean that the next parameter specifies the target.
1111
1212const std = @import("std");
13const fs = std.fs;
13const Io = std.Io;
1414const assert = std.debug.assert;
1515const json = std.json;
1616
......@@ -634,8 +634,12 @@ pub fn main() anyerror!void {
634634 const allocator = arena.allocator();
635635 const args = try std.process.argsAlloc(allocator);
636636
637 var threaded: std.Io.Threaded = .init(allocator, .{});
638 defer threaded.deinit();
639 const io = threaded.io();
640
637641 var stdout_buffer: [4000]u8 = undefined;
638 var stdout_writer = fs.File.stdout().writerStreaming(&stdout_buffer);
642 var stdout_writer = Io.File.stdout().writerStreaming(io, &stdout_buffer);
639643 const stdout = &stdout_writer.interface;
640644
641645 if (args.len <= 1) printUsageAndExit(args[0]);
......@@ -676,8 +680,7 @@ pub fn main() anyerror!void {
676680 try std.fmt.allocPrint(allocator, "-I={s}/clang/include/clang/Driver", .{llvm_src_root}),
677681 };
678682
679 const child_result = try std.process.Child.run(.{
680 .allocator = allocator,
683 const child_result = try std.process.Child.run(allocator, io, .{
681684 .argv = &child_args,
682685 .max_output_bytes = 100 * 1024 * 1024,
683686 });
tools/update_cpu_features.zig+2-3
......@@ -1994,8 +1994,7 @@ fn processOneTarget(io: Io, job: Job) void {
19941994 }),
19951995 };
19961996
1997 const child_result = try std.process.Child.run(.{
1998 .allocator = arena,
1997 const child_result = try std.process.Child.run(arena, io, .{
19991998 .argv = &child_args,
20001999 .max_output_bytes = 500 * 1024 * 1024,
20012000 });
......@@ -2250,7 +2249,7 @@ fn processOneTarget(io: Io, job: Job) void {
22502249 defer zig_code_file.close(io);
22512250
22522251 var zig_code_file_buffer: [4096]u8 = undefined;
2253 var zig_code_file_writer = zig_code_file.writer(&zig_code_file_buffer);
2252 var zig_code_file_writer = zig_code_file.writer(io, &zig_code_file_buffer);
22542253 const w = &zig_code_file_writer.interface;
22552254
22562255 try w.writeAll(
tools/update_crc_catalog.zig+2-2
......@@ -35,7 +35,7 @@ pub fn main() anyerror!void {
3535 var zig_code_file = try hash_target_dir.createFile(io, "crc.zig", .{});
3636 defer zig_code_file.close(io);
3737 var zig_code_file_buffer: [4096]u8 = undefined;
38 var zig_code_file_writer = zig_code_file.writer(&zig_code_file_buffer);
38 var zig_code_file_writer = zig_code_file.writer(io, &zig_code_file_buffer);
3939 const code_writer = &zig_code_file_writer.interface;
4040
4141 try code_writer.writeAll(
......@@ -59,7 +59,7 @@ pub fn main() anyerror!void {
5959 var zig_test_file = try crc_target_dir.createFile(io, "test.zig", .{});
6060 defer zig_test_file.close(io);
6161 var zig_test_file_buffer: [4096]u8 = undefined;
62 var zig_test_file_writer = zig_test_file.writer(&zig_test_file_buffer);
62 var zig_test_file_writer = zig_test_file.writer(io, &zig_test_file_buffer);
6363 const test_writer = &zig_test_file_writer.interface;
6464
6565 try test_writer.writeAll(
tools/update_freebsd_libc.zig+7-10
......@@ -27,13 +27,13 @@ pub fn main() !void {
2727
2828 const dest_dir_path = try std.fmt.allocPrint(arena, "{s}/lib/libc/freebsd", .{zig_src_path});
2929
30 var dest_dir = std.fs.cwd().openDir(io, dest_dir_path, .{ .iterate = true }) catch |err| {
30 var dest_dir = Io.Dir.cwd().openDir(io, dest_dir_path, .{ .iterate = true }) catch |err| {
3131 std.log.err("unable to open destination directory '{s}': {t}", .{ dest_dir_path, err });
3232 std.process.exit(1);
3333 };
3434 defer dest_dir.close(io);
3535
36 var freebsd_src_dir = try std.fs.cwd().openDir(freebsd_src_path, .{});
36 var freebsd_src_dir = try Io.Dir.cwd().openDir(io, freebsd_src_path, .{});
3737 defer freebsd_src_dir.close(io);
3838
3939 // Copy updated files from upstream.
......@@ -41,7 +41,7 @@ pub fn main() !void {
4141 var walker = try dest_dir.walk(arena);
4242 defer walker.deinit();
4343
44 walk: while (try walker.next()) |entry| {
44 walk: while (try walker.next(io)) |entry| {
4545 if (entry.kind != .file) continue;
4646 if (std.mem.startsWith(u8, entry.basename, ".")) continue;
4747 for (exempt_files) |p| {
......@@ -49,15 +49,12 @@ pub fn main() !void {
4949 }
5050
5151 std.log.info("updating '{s}/{s}' from '{s}/{s}'", .{
52 dest_dir_path, entry.path,
53 freebsd_src_path, entry.path,
52 dest_dir_path, entry.path, freebsd_src_path, entry.path,
5453 });
5554
56 freebsd_src_dir.copyFile(entry.path, dest_dir, entry.path, .{}) catch |err| {
57 std.log.warn("unable to copy '{s}/{s}' to '{s}/{s}': {s}", .{
58 freebsd_src_path, entry.path,
59 dest_dir_path, entry.path,
60 @errorName(err),
55 freebsd_src_dir.copyFile(entry.path, dest_dir, entry.path, io, .{}) catch |err| {
56 std.log.warn("unable to copy '{s}/{s}' to '{s}/{s}': {t}", .{
57 freebsd_src_path, entry.path, dest_dir_path, entry.path, err,
6158 });
6259 if (err == error.FileNotFound) {
6360 try dest_dir.deleteFile(io, entry.path);
tools/update_glibc.zig+8-11
......@@ -66,7 +66,7 @@ pub fn main() !void {
6666 var walker = try dest_dir.walk(arena);
6767 defer walker.deinit();
6868
69 walk: while (try walker.next()) |entry| {
69 walk: while (try walker.next(io)) |entry| {
7070 if (entry.kind != .file) continue;
7171 if (mem.startsWith(u8, entry.basename, ".")) continue;
7272 for (exempt_files) |p| {
......@@ -76,7 +76,7 @@ pub fn main() !void {
7676 if (mem.endsWith(u8, entry.path, ext)) continue :walk;
7777 }
7878
79 glibc_src_dir.copyFile(entry.path, dest_dir, entry.path, .{}) catch |err| {
79 glibc_src_dir.copyFile(entry.path, dest_dir, entry.path, io, .{}) catch |err| {
8080 log.warn("unable to copy '{s}/{s}' to '{s}/{s}': {t}", .{
8181 glibc_src_path, entry.path, dest_dir_path, entry.path, err,
8282 });
......@@ -106,7 +106,7 @@ pub fn main() !void {
106106 var walker = try include_dir.walk(arena);
107107 defer walker.deinit();
108108
109 walk: while (try walker.next()) |entry| {
109 walk: while (try walker.next(io)) |entry| {
110110 if (entry.kind != .file) continue;
111111 if (mem.startsWith(u8, entry.basename, ".")) continue;
112112 for (exempt_files) |p| {
......@@ -116,23 +116,21 @@ pub fn main() !void {
116116 const max_file_size = 10 * 1024 * 1024;
117117
118118 const generic_glibc_contents = generic_glibc_dir.readFileAlloc(
119 io,
119120 entry.path,
120121 arena,
121122 .limited(max_file_size),
122123 ) catch |err| switch (err) {
123124 error.FileNotFound => continue,
124 else => |e| fatal("unable to load '{s}/include/{s}': {s}", .{
125 generic_glibc_path, entry.path, @errorName(e),
126 }),
125 else => |e| fatal("unable to load '{s}/include/{s}': {t}", .{ generic_glibc_path, entry.path, e }),
127126 };
128127 const glibc_include_contents = include_dir.readFileAlloc(
128 io,
129129 entry.path,
130130 arena,
131131 .limited(max_file_size),
132132 ) catch |err| {
133 fatal("unable to load '{s}/include/{s}': {s}", .{
134 dest_dir_path, entry.path, @errorName(err),
135 });
133 fatal("unable to load '{s}/include/{s}': {t}", .{ dest_dir_path, entry.path, err });
136134 };
137135
138136 const whitespace = " \r\n\t";
......@@ -140,8 +138,7 @@ pub fn main() !void {
140138 const glibc_include_trimmed = mem.trim(u8, glibc_include_contents, whitespace);
141139 if (mem.eql(u8, generic_glibc_trimmed, glibc_include_trimmed)) {
142140 log.warn("same contents: '{s}/include/{s}' and '{s}/include/{s}'", .{
143 generic_glibc_path, entry.path,
144 dest_dir_path, entry.path,
141 generic_glibc_path, entry.path, dest_dir_path, entry.path,
145142 });
146143 }
147144 }
tools/update_mingw.zig+12-12
......@@ -26,13 +26,13 @@ pub fn main() !void {
2626 // in zig's installation.
2727
2828 var dest_crt_dir = Dir.cwd().openDir(io, dest_mingw_crt_path, .{ .iterate = true }) catch |err| {
29 std.log.err("unable to open directory '{s}': {s}", .{ dest_mingw_crt_path, @errorName(err) });
29 std.log.err("unable to open directory '{s}': {t}", .{ dest_mingw_crt_path, err });
3030 std.process.exit(1);
3131 };
3232 defer dest_crt_dir.close(io);
3333
3434 var src_crt_dir = Dir.cwd().openDir(io, src_mingw_crt_path, .{ .iterate = true }) catch |err| {
35 std.log.err("unable to open directory '{s}': {s}", .{ src_mingw_crt_path, @errorName(err) });
35 std.log.err("unable to open directory '{s}': {t}", .{ src_mingw_crt_path, err });
3636 std.process.exit(1);
3737 };
3838 defer src_crt_dir.close(io);
......@@ -43,10 +43,10 @@ pub fn main() !void {
4343
4444 var fail = false;
4545
46 while (try walker.next()) |entry| {
46 while (try walker.next(io)) |entry| {
4747 if (entry.kind != .file) continue;
4848
49 src_crt_dir.copyFile(entry.path, dest_crt_dir, entry.path, .{}) catch |err| switch (err) {
49 src_crt_dir.copyFile(entry.path, dest_crt_dir, entry.path, io, .{}) catch |err| switch (err) {
5050 error.FileNotFound => {
5151 const keep = for (kept_crt_files) |item| {
5252 if (std.mem.eql(u8, entry.path, item)) break true;
......@@ -94,10 +94,10 @@ pub fn main() !void {
9494
9595 var fail = false;
9696
97 while (try walker.next()) |entry| {
97 while (try walker.next(io)) |entry| {
9898 if (entry.kind != .file) continue;
9999
100 src_winpthreads_dir.copyFile(entry.path, dest_winpthreads_dir, entry.path, .{}) catch |err| switch (err) {
100 src_winpthreads_dir.copyFile(entry.path, dest_winpthreads_dir, entry.path, io, .{}) catch |err| switch (err) {
101101 error.FileNotFound => {
102102 std.log.warn("deleting {s}", .{entry.path});
103103 try dest_winpthreads_dir.deleteFile(io, entry.path);
......@@ -120,17 +120,17 @@ pub fn main() !void {
120120
121121 var fail = false;
122122
123 while (try walker.next()) |entry| {
123 while (try walker.next(io)) |entry| {
124124 switch (entry.kind) {
125125 .directory => {
126126 switch (entry.depth()) {
127127 1 => if (def_dirs.has(entry.basename)) {
128 try walker.enter(entry);
128 try walker.enter(io, entry);
129129 continue;
130130 },
131131 else => {
132132 // The top-level directory was already validated
133 try walker.enter(entry);
133 try walker.enter(io, entry);
134134 continue;
135135 },
136136 }
......@@ -157,15 +157,15 @@ pub fn main() !void {
157157 if (std.mem.endsWith(u8, entry.basename, "_onecore.def"))
158158 continue;
159159
160 src_crt_dir.copyFile(entry.path, dest_crt_dir, entry.path, .{}) catch |err| {
161 std.log.err("unable to copy {s}: {s}", .{ entry.path, @errorName(err) });
160 src_crt_dir.copyFile(entry.path, dest_crt_dir, entry.path, io, .{}) catch |err| {
161 std.log.err("unable to copy {s}: {t}", .{ entry.path, err });
162162 fail = true;
163163 };
164164 }
165165 if (fail) std.process.exit(1);
166166 }
167167
168 return std.process.cleanExit();
168 return std.process.cleanExit(io);
169169}
170170
171171const kept_crt_files = [_][]const u8{
tools/update_netbsd_libc.zig+4-4
......@@ -27,13 +27,13 @@ pub fn main() !void {
2727
2828 const dest_dir_path = try std.fmt.allocPrint(arena, "{s}/lib/libc/netbsd", .{zig_src_path});
2929
30 var dest_dir = std.fs.cwd().openDir(io, dest_dir_path, .{ .iterate = true }) catch |err| {
30 var dest_dir = Io.Dir.cwd().openDir(io, dest_dir_path, .{ .iterate = true }) catch |err| {
3131 std.log.err("unable to open destination directory '{s}': {t}", .{ dest_dir_path, err });
3232 std.process.exit(1);
3333 };
3434 defer dest_dir.close(io);
3535
36 var netbsd_src_dir = try std.fs.cwd().openDir(io, netbsd_src_path, .{});
36 var netbsd_src_dir = try Io.Dir.cwd().openDir(io, netbsd_src_path, .{});
3737 defer netbsd_src_dir.close(io);
3838
3939 // Copy updated files from upstream.
......@@ -41,7 +41,7 @@ pub fn main() !void {
4141 var walker = try dest_dir.walk(arena);
4242 defer walker.deinit();
4343
44 walk: while (try walker.next()) |entry| {
44 walk: while (try walker.next(io)) |entry| {
4545 if (entry.kind != .file) continue;
4646 if (std.mem.startsWith(u8, entry.basename, ".")) continue;
4747 for (exempt_files) |p| {
......@@ -53,7 +53,7 @@ pub fn main() !void {
5353 netbsd_src_path, entry.path,
5454 });
5555
56 netbsd_src_dir.copyFile(entry.path, dest_dir, entry.path, .{}) catch |err| {
56 netbsd_src_dir.copyFile(entry.path, dest_dir, entry.path, io, .{}) catch |err| {
5757 std.log.warn("unable to copy '{s}/{s}' to '{s}/{s}': {t}", .{
5858 netbsd_src_path, entry.path, dest_dir_path, entry.path, err,
5959 });