| author | |
| committer | |
| log | 669dae140c63b1bf4dbae6634145529333cd8371 |
| tree | 9ea258107e97dbe378daa8e79c2e0e9b0723fc1b |
| parent | 0870f17501aa7d2eaaf2d774ccbc5d72291664ca |
28 files changed, 181 insertions(+), 169 deletions(-)
lib/fuzzer.zig+39-45| ... | @@ -1,18 +1,22 @@ | ... | @@ -1,18 +1,22 @@ |
| 1 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 2 | const native_endian = builtin.cpu.arch.endian(); | ||
| 3 | |||
| 2 | const std = @import("std"); | 4 | const std = @import("std"); |
| 5 | const Io = std.Io; | ||
| 3 | const fatal = std.process.fatal; | 6 | const fatal = std.process.fatal; |
| 4 | const mem = std.mem; | 7 | const mem = std.mem; |
| 5 | const math = std.math; | 8 | const math = std.math; |
| 6 | const Allocator = mem.Allocator; | 9 | const Allocator = std.mem.Allocator; |
| 7 | const assert = std.debug.assert; | 10 | const assert = std.debug.assert; |
| 8 | const panic = std.debug.panic; | 11 | const panic = std.debug.panic; |
| 9 | const abi = std.Build.abi.fuzz; | 12 | const abi = std.Build.abi.fuzz; |
| 10 | const native_endian = builtin.cpu.arch.endian(); | ||
| 11 | 13 | ||
| 12 | pub const std_options = std.Options{ | 14 | pub const std_options = std.Options{ |
| 13 | .logFn = logOverride, | 15 | .logFn = logOverride, |
| 14 | }; | 16 | }; |
| 15 | 17 | ||
| 18 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | ||
| 19 | |||
| 16 | fn logOverride( | 20 | fn logOverride( |
| 17 | comptime level: std.log.Level, | 21 | comptime level: std.log.Level, |
| 18 | comptime scope: @EnumLiteral(), | 22 | comptime scope: @EnumLiteral(), |
| ... | @@ -21,12 +25,12 @@ fn logOverride( | ... | @@ -21,12 +25,12 @@ fn logOverride( |
| 21 | ) void { | 25 | ) void { |
| 22 | const f = log_f orelse | 26 | const f = log_f orelse |
| 23 | panic("attempt to use log before initialization, message:\n" ++ format, args); | 27 | 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}); | 28 | f.lock(io, .exclusive) catch |e| panic("failed to lock logging file: {t}", .{e}); |
| 25 | defer f.unlock(); | 29 | defer f.unlock(io); |
| 26 | 30 | ||
| 27 | var buf: [256]u8 = undefined; | 31 | var buf: [256]u8 = undefined; |
| 28 | var fw = f.writer(&buf); | 32 | var fw = f.writer(io, &buf); |
| 29 | const end = f.getEndPos() catch |e| panic("failed to get fuzzer log file end: {t}", .{e}); | 33 | const end = f.length(io) catch |e| panic("failed to get fuzzer log file end: {t}", .{e}); |
| 30 | fw.seekTo(end) catch |e| panic("failed to seek to fuzzer log file end: {t}", .{e}); | 34 | fw.seekTo(end) catch |e| panic("failed to seek to fuzzer log file end: {t}", .{e}); |
| 31 | 35 | ||
| 32 | const prefix1 = comptime level.asText(); | 36 | const prefix1 = comptime level.asText(); |
| ... | @@ -45,7 +49,7 @@ const gpa = switch (builtin.mode) { | ... | @@ -45,7 +49,7 @@ const gpa = switch (builtin.mode) { |
| 45 | }; | 49 | }; |
| 46 | 50 | ||
| 47 | /// Part of `exec`, however seperate to allow it to be set before `exec` is. | 51 | /// Part of `exec`, however seperate to allow it to be set before `exec` is. |
| 48 | var log_f: ?std.fs.File = null; | 52 | var log_f: ?Io.File = null; |
| 49 | var exec: Executable = .preinit; | 53 | var exec: Executable = .preinit; |
| 50 | var inst: Instrumentation = .preinit; | 54 | var inst: Instrumentation = .preinit; |
| 51 | var fuzzer: Fuzzer = undefined; | 55 | var fuzzer: Fuzzer = undefined; |
| ... | @@ -59,7 +63,7 @@ const Executable = struct { | ... | @@ -59,7 +63,7 @@ const Executable = struct { |
| 59 | /// Tracks the hit count for each pc as updated by the process's instrumentation. | 63 | /// Tracks the hit count for each pc as updated by the process's instrumentation. |
| 60 | pc_counters: []u8, | 64 | pc_counters: []u8, |
| 61 | 65 | ||
| 62 | cache_f: std.fs.Dir, | 66 | cache_f: Io.Dir, |
| 63 | /// Shared copy of all pcs that have been hit stored in a memory-mapped file that can viewed | 67 | /// Shared copy of all pcs that have been hit stored in a memory-mapped file that can viewed |
| 64 | /// while the fuzzer is running. | 68 | /// while the fuzzer is running. |
| 65 | shared_seen_pcs: MemoryMappedList, | 69 | shared_seen_pcs: MemoryMappedList, |
| ... | @@ -76,16 +80,16 @@ const Executable = struct { | ... | @@ -76,16 +80,16 @@ const Executable = struct { |
| 76 | .pc_digest = undefined, | 80 | .pc_digest = undefined, |
| 77 | }; | 81 | }; |
| 78 | 82 | ||
| 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 { |
| 80 | const pc_bitset_usizes = bitsetUsizes(pcs.len); | 84 | const pc_bitset_usizes = bitsetUsizes(pcs.len); |
| 81 | const coverage_file_name = std.fmt.hex(pc_digest); | 85 | const coverage_file_name = std.fmt.hex(pc_digest); |
| 82 | comptime assert(abi.SeenPcsHeader.trailing[0] == .pc_bits_usize); | 86 | comptime assert(abi.SeenPcsHeader.trailing[0] == .pc_bits_usize); |
| 83 | comptime assert(abi.SeenPcsHeader.trailing[1] == .pc_addr); | 87 | comptime assert(abi.SeenPcsHeader.trailing[1] == .pc_addr); |
| 84 | 88 | ||
| 85 | var v = cache_dir.makeOpenPath("v", .{}) catch |e| | 89 | var v = cache_dir.createDirPathOpen(io, "v", .{}) catch |e| |
| 86 | panic("failed to create directory 'v': {t}", .{e}); | 90 | panic("failed to create directory 'v': {t}", .{e}); |
| 87 | defer v.close(); | 91 | defer v.close(io); |
| 88 | const coverage_file, const populate = if (v.createFile(&coverage_file_name, .{ | 92 | const coverage_file, const populate = if (v.createFile(io, &coverage_file_name, .{ |
| 89 | .read = true, | 93 | .read = true, |
| 90 | // If we create the file, we want to block other processes while we populate it | 94 | // If we create the file, we want to block other processes while we populate it |
| 91 | .lock = .exclusive, | 95 | .lock = .exclusive, |
| ... | @@ -93,7 +97,7 @@ const Executable = struct { | ... | @@ -93,7 +97,7 @@ const Executable = struct { |
| 93 | })) |f| | 97 | })) |f| |
| 94 | .{ f, true } | 98 | .{ f, true } |
| 95 | else |e| switch (e) { | 99 | else |e| switch (e) { |
| 96 | error.PathAlreadyExists => .{ v.openFile(&coverage_file_name, .{ | 100 | error.PathAlreadyExists => .{ v.openFile(io, &coverage_file_name, .{ |
| 97 | .mode = .read_write, | 101 | .mode = .read_write, |
| 98 | .lock = .shared, | 102 | .lock = .shared, |
| 99 | }) catch |e2| panic( | 103 | }) catch |e2| panic( |
| ... | @@ -108,7 +112,7 @@ const Executable = struct { | ... | @@ -108,7 +112,7 @@ const Executable = struct { |
| 108 | pcs.len * @sizeOf(usize); | 112 | pcs.len * @sizeOf(usize); |
| 109 | 113 | ||
| 110 | if (populate) { | 114 | if (populate) { |
| 111 | defer coverage_file.lock(.shared) catch |e| panic( | 115 | defer coverage_file.lock(io, .shared) catch |e| panic( |
| 112 | "failed to demote lock for coverage file '{s}': {t}", | 116 | "failed to demote lock for coverage file '{s}': {t}", |
| 113 | .{ &coverage_file_name, e }, | 117 | .{ &coverage_file_name, e }, |
| 114 | ); | 118 | ); |
| ... | @@ -130,10 +134,8 @@ const Executable = struct { | ... | @@ -130,10 +134,8 @@ const Executable = struct { |
| 130 | } | 134 | } |
| 131 | return map; | 135 | return map; |
| 132 | } else { | 136 | } else { |
| 133 | const size = coverage_file.getEndPos() catch |e| panic( | 137 | const size = coverage_file.length(io) catch |e| |
| 134 | "failed to stat coverage file '{s}': {t}", | 138 | panic("failed to stat coverage file '{s}': {t}", .{ &coverage_file_name, e }); |
| 135 | .{ &coverage_file_name, e }, | ||
| 136 | ); | ||
| 137 | if (size != coverage_file_len) panic( | 139 | if (size != coverage_file_len) panic( |
| 138 | "incompatible existing coverage file '{s}' (differing lengths: {} != {})", | 140 | "incompatible existing coverage file '{s}' (differing lengths: {} != {})", |
| 139 | .{ &coverage_file_name, size, coverage_file_len }, | 141 | .{ &coverage_file_name, size, coverage_file_len }, |
| ... | @@ -165,13 +167,11 @@ const Executable = struct { | ... | @@ -165,13 +167,11 @@ const Executable = struct { |
| 165 | pub fn init(cache_dir_path: []const u8) Executable { | 167 | pub fn init(cache_dir_path: []const u8) Executable { |
| 166 | var self: Executable = undefined; | 168 | var self: Executable = undefined; |
| 167 | 169 | ||
| 168 | const cache_dir = std.fs.cwd().makeOpenPath(cache_dir_path, .{}) catch |e| panic( | 170 | const cache_dir = Io.Dir.cwd().createDirPathOpen(io, cache_dir_path, .{}) catch |e| |
| 169 | "failed to open directory '{s}': {t}", | 171 | panic("failed to open directory '{s}': {t}", .{ cache_dir_path, e }); |
| 170 | .{ cache_dir_path, e }, | 172 | log_f = cache_dir.createFile(io, "tmp/libfuzzer.log", .{ .truncate = false }) catch |e| |
| 171 | ); | ||
| 172 | log_f = cache_dir.createFile("tmp/libfuzzer.log", .{ .truncate = false }) catch |e| | ||
| 173 | panic("failed to create file 'tmp/libfuzzer.log': {t}", .{e}); | 173 | 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| |
| 175 | panic("failed to open directory 'f': {t}", .{e}); | 175 | panic("failed to open directory 'f': {t}", .{e}); |
| 176 | 176 | ||
| 177 | // Linkers are expected to automatically add symbols prefixed with these for the start and | 177 | // Linkers are expected to automatically add symbols prefixed with these for the start and |
| ... | @@ -391,7 +391,7 @@ const Fuzzer = struct { | ... | @@ -391,7 +391,7 @@ const Fuzzer = struct { |
| 391 | mutations: std.ArrayList(Mutation) = .empty, | 391 | mutations: std.ArrayList(Mutation) = .empty, |
| 392 | 392 | ||
| 393 | /// Filesystem directory containing found inputs for future runs | 393 | /// Filesystem directory containing found inputs for future runs |
| 394 | corpus_dir: std.fs.Dir, | 394 | corpus_dir: Io.Dir, |
| 395 | corpus_dir_idx: usize = 0, | 395 | corpus_dir_idx: usize = 0, |
| 396 | 396 | ||
| 397 | pub fn init(test_one: abi.TestOne, unit_test_name: []const u8) Fuzzer { | 397 | pub fn init(test_one: abi.TestOne, unit_test_name: []const u8) Fuzzer { |
| ... | @@ -405,10 +405,10 @@ const Fuzzer = struct { | ... | @@ -405,10 +405,10 @@ const Fuzzer = struct { |
| 405 | }; | 405 | }; |
| 406 | const arena = self.arena_ctx.allocator(); | 406 | const arena = self.arena_ctx.allocator(); |
| 407 | 407 | ||
| 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| |
| 409 | panic("failed to open directory '{s}': {t}", .{ unit_test_name, e }); | 409 | panic("failed to open directory '{s}': {t}", .{ unit_test_name, e }); |
| 410 | self.input = in: { | 410 | self.input = in: { |
| 411 | const f = self.corpus_dir.createFile("in", .{ | 411 | const f = self.corpus_dir.createFile(io, "in", .{ |
| 412 | .read = true, | 412 | .read = true, |
| 413 | .truncate = false, | 413 | .truncate = false, |
| 414 | // In case any other fuzz tests are running under the same test name, | 414 | // In case any other fuzz tests are running under the same test name, |
| ... | @@ -419,7 +419,7 @@ const Fuzzer = struct { | ... | @@ -419,7 +419,7 @@ const Fuzzer = struct { |
| 419 | error.WouldBlock => @panic("input file 'in' is in use by another fuzzing process"), | 419 | error.WouldBlock => @panic("input file 'in' is in use by another fuzzing process"), |
| 420 | else => panic("failed to create input file 'in': {t}", .{e}), | 420 | else => panic("failed to create input file 'in': {t}", .{e}), |
| 421 | }; | 421 | }; |
| 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}); |
| 423 | const map = (if (size < std.heap.page_size_max) | 423 | const map = (if (size < std.heap.page_size_max) |
| 424 | MemoryMappedList.create(f, 8, std.heap.page_size_max) | 424 | MemoryMappedList.create(f, 8, std.heap.page_size_max) |
| 425 | else | 425 | else |
| ... | @@ -445,6 +445,7 @@ const Fuzzer = struct { | ... | @@ -445,6 +445,7 @@ const Fuzzer = struct { |
| 445 | while (true) { | 445 | while (true) { |
| 446 | var name_buf: [@sizeOf(usize) * 2]u8 = undefined; | 446 | var name_buf: [@sizeOf(usize) * 2]u8 = undefined; |
| 447 | const bytes = self.corpus_dir.readFileAlloc( | 447 | const bytes = self.corpus_dir.readFileAlloc( |
| 448 | io, | ||
| 448 | std.fmt.bufPrint(&name_buf, "{x}", .{self.corpus_dir_idx}) catch unreachable, | 449 | std.fmt.bufPrint(&name_buf, "{x}", .{self.corpus_dir_idx}) catch unreachable, |
| 449 | arena, | 450 | arena, |
| 450 | .unlimited, | 451 | .unlimited, |
| ... | @@ -466,7 +467,7 @@ const Fuzzer = struct { | ... | @@ -466,7 +467,7 @@ const Fuzzer = struct { |
| 466 | self.input.deinit(); | 467 | self.input.deinit(); |
| 467 | self.corpus.deinit(gpa); | 468 | self.corpus.deinit(gpa); |
| 468 | self.mutations.deinit(gpa); | 469 | self.mutations.deinit(gpa); |
| 469 | self.corpus_dir.close(); | 470 | self.corpus_dir.close(io); |
| 470 | self.arena_ctx.deinit(); | 471 | self.arena_ctx.deinit(); |
| 471 | self.* = undefined; | 472 | self.* = undefined; |
| 472 | } | 473 | } |
| ... | @@ -573,17 +574,10 @@ const Fuzzer = struct { | ... | @@ -573,17 +574,10 @@ const Fuzzer = struct { |
| 573 | 574 | ||
| 574 | // Write new corpus to cache | 575 | // Write new corpus to cache |
| 575 | var name_buf: [@sizeOf(usize) * 2]u8 = undefined; | 576 | var name_buf: [@sizeOf(usize) * 2]u8 = undefined; |
| 576 | self.corpus_dir.writeFile(.{ | 577 | self.corpus_dir.writeFile(io, .{ |
| 577 | .sub_path = std.fmt.bufPrint( | 578 | .sub_path = std.fmt.bufPrint(&name_buf, "{x}", .{self.corpus_dir_idx}) catch unreachable, |
| 578 | &name_buf, | ||
| 579 | "{x}", | ||
| 580 | .{self.corpus_dir_idx}, | ||
| 581 | ) catch unreachable, | ||
| 582 | .data = bytes, | 579 | .data = bytes, |
| 583 | }) catch |e| panic( | 580 | }) catch |e| panic("failed to write corpus file '{x}': {t}", .{ self.corpus_dir_idx, e }); |
| 584 | "failed to write corpus file '{x}': {t}", | ||
| 585 | .{ self.corpus_dir_idx, e }, | ||
| 586 | ); | ||
| 587 | self.corpus_dir_idx += 1; | 581 | self.corpus_dir_idx += 1; |
| 588 | } | 582 | } |
| 589 | } | 583 | } |
| ... | @@ -1320,9 +1314,9 @@ pub const MemoryMappedList = struct { | ... | @@ -1320,9 +1314,9 @@ pub const MemoryMappedList = struct { |
| 1320 | /// How many bytes this list can hold without allocating additional memory. | 1314 | /// How many bytes this list can hold without allocating additional memory. |
| 1321 | capacity: usize, | 1315 | capacity: usize, |
| 1322 | /// The file is kept open so that it can be resized. | 1316 | /// The file is kept open so that it can be resized. |
| 1323 | file: std.fs.File, | 1317 | file: Io.File, |
| 1324 | 1318 | ||
| 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 { |
| 1326 | const ptr = try std.posix.mmap( | 1320 | const ptr = try std.posix.mmap( |
| 1327 | null, | 1321 | null, |
| 1328 | capacity, | 1322 | capacity, |
| ... | @@ -1338,13 +1332,13 @@ pub const MemoryMappedList = struct { | ... | @@ -1338,13 +1332,13 @@ pub const MemoryMappedList = struct { |
| 1338 | }; | 1332 | }; |
| 1339 | } | 1333 | } |
| 1340 | 1334 | ||
| 1341 | pub fn create(file: std.fs.File, length: usize, capacity: usize) !MemoryMappedList { | 1335 | pub fn create(file: Io.File, length: usize, capacity: usize) !MemoryMappedList { |
| 1342 | try file.setEndPos(capacity); | 1336 | try file.setLength(io, capacity); |
| 1343 | return init(file, length, capacity); | 1337 | return init(file, length, capacity); |
| 1344 | } | 1338 | } |
| 1345 | 1339 | ||
| 1346 | pub fn deinit(l: *MemoryMappedList) void { | 1340 | pub fn deinit(l: *MemoryMappedList) void { |
| 1347 | l.file.close(); | 1341 | l.file.close(io); |
| 1348 | std.posix.munmap(@volatileCast(l.items.ptr[0..l.capacity])); | 1342 | std.posix.munmap(@volatileCast(l.items.ptr[0..l.capacity])); |
| 1349 | l.* = undefined; | 1343 | l.* = undefined; |
| 1350 | } | 1344 | } |
| ... | @@ -1369,7 +1363,7 @@ pub const MemoryMappedList = struct { | ... | @@ -1369,7 +1363,7 @@ pub const MemoryMappedList = struct { |
| 1369 | if (l.capacity >= new_capacity) return; | 1363 | if (l.capacity >= new_capacity) return; |
| 1370 | 1364 | ||
| 1371 | std.posix.munmap(@volatileCast(l.items.ptr[0..l.capacity])); | 1365 | 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); |
| 1373 | l.* = try init(l.file, l.items.len, new_capacity); | 1367 | l.* = try init(l.file, l.items.len, new_capacity); |
| 1374 | } | 1368 | } |
| 1375 | 1369 |
test/standalone/child_process/child.zig+6-6| ... | @@ -26,14 +26,14 @@ fn run(allocator: std.mem.Allocator, io: Io) !void { | ... | @@ -26,14 +26,14 @@ fn run(allocator: std.mem.Allocator, io: Io) !void { |
| 26 | const hello_arg = "hello arg"; | 26 | const hello_arg = "hello arg"; |
| 27 | const a1 = args.next() orelse unreachable; | 27 | const a1 = args.next() orelse unreachable; |
| 28 | if (!std.mem.eql(u8, a1, hello_arg)) { | 28 | 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 }); |
| 30 | } | 30 | } |
| 31 | if (args.next()) |a2| { | 31 | 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}); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | // test stdout pipe; parent verifies | 35 | // 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"); |
| 37 | 37 | ||
| 38 | // test stdin pipe from parent | 38 | // test stdin pipe from parent |
| 39 | const hello_stdin = "hello from stdin"; | 39 | const hello_stdin = "hello from stdin"; |
| ... | @@ -42,12 +42,12 @@ fn run(allocator: std.mem.Allocator, io: Io) !void { | ... | @@ -42,12 +42,12 @@ fn run(allocator: std.mem.Allocator, io: Io) !void { |
| 42 | var reader = stdin.reader(io, &.{}); | 42 | var reader = stdin.reader(io, &.{}); |
| 43 | const n = try reader.interface.readSliceShort(&buf); | 43 | const n = try reader.interface.readSliceShort(&buf); |
| 44 | if (!std.mem.eql(u8, buf[0..n], hello_stdin)) { | 44 | 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 }); |
| 46 | } | 46 | } |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | fn testError(comptime fmt: []const u8, args: anytype) void { | 49 | fn testError(io: Io, comptime fmt: []const u8, args: anytype) void { |
| 50 | var stderr_writer = std.Io.File.stderr().writer(&.{}); | 50 | var stderr_writer = std.Io.File.stderr().writer(io, &.{}); |
| 51 | const stderr = &stderr_writer.interface; | 51 | const stderr = &stderr_writer.interface; |
| 52 | stderr.print("CHILD TEST ERROR: ", .{}) catch {}; | 52 | stderr.print("CHILD TEST ERROR: ", .{}) catch {}; |
| 53 | stderr.print(fmt, args) catch {}; | 53 | stderr.print(fmt, args) catch {}; |
test/standalone/child_process/main.zig+2-2| ... | @@ -31,7 +31,7 @@ pub fn main() !void { | ... | @@ -31,7 +31,7 @@ pub fn main() !void { |
| 31 | child.stderr_behavior = .Inherit; | 31 | child.stderr_behavior = .Inherit; |
| 32 | try child.spawn(io); | 32 | try child.spawn(io); |
| 33 | const child_stdin = child.stdin.?; | 33 | 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 |
| 35 | child_stdin.close(io); | 35 | child_stdin.close(io); |
| 36 | child.stdin = null; | 36 | child.stdin = null; |
| 37 | 37 | ||
| ... | @@ -43,7 +43,7 @@ pub fn main() !void { | ... | @@ -43,7 +43,7 @@ pub fn main() !void { |
| 43 | testError(io, "child stdout: '{s}'; want '{s}'", .{ buf[0..n], hello_stdout }); | 43 | testError(io, "child stdout: '{s}'; want '{s}'", .{ buf[0..n], hello_stdout }); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | switch (try child.wait()) { | 46 | switch (try child.wait(io)) { |
| 47 | .Exited => |code| { | 47 | .Exited => |code| { |
| 48 | const child_ok_code = 42; // set by child if no test errors | 48 | const child_ok_code = 42; // set by child if no test errors |
| 49 | if (code != child_ok_code) { | 49 | if (code != child_ok_code) { |
test/standalone/dirname/exists_in.zig+1-1| ... | @@ -39,5 +39,5 @@ fn run(allocator: std.mem.Allocator) !void { | ... | @@ -39,5 +39,5 @@ fn run(allocator: std.mem.Allocator) !void { |
| 39 | var dir = try std.Io.Dir.cwd().openDir(io, dir_path, .{}); | 39 | var dir = try std.Io.Dir.cwd().openDir(io, dir_path, .{}); |
| 40 | defer dir.close(io); | 40 | defer dir.close(io); |
| 41 | 41 | ||
| 42 | _ = try dir.statFile(io, relpath); | 42 | _ = try dir.statFile(io, relpath, .{}); |
| 43 | } | 43 | } |
test/standalone/dirname/touch.zig+1-1| ... | @@ -34,7 +34,7 @@ fn run(allocator: std.mem.Allocator) !void { | ... | @@ -34,7 +34,7 @@ fn run(allocator: std.mem.Allocator) !void { |
| 34 | var dir = try std.Io.Dir.cwd().openDir(io, dir_path, .{}); | 34 | var dir = try std.Io.Dir.cwd().openDir(io, dir_path, .{}); |
| 35 | defer dir.close(io); | 35 | defer dir.close(io); |
| 36 | 36 | ||
| 37 | _ = dir.statFile(io, basename) catch { | 37 | _ = dir.statFile(io, basename, .{}) catch { |
| 38 | var file = try dir.createFile(io, basename, .{}); | 38 | var file = try dir.createFile(io, basename, .{}); |
| 39 | file.close(io); | 39 | file.close(io); |
| 40 | }; | 40 | }; |
test/standalone/install_headers/check_exists.zig+3-3| ... | @@ -14,7 +14,7 @@ pub fn main() !void { | ... | @@ -14,7 +14,7 @@ pub fn main() !void { |
| 14 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | 14 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); |
| 15 | 15 | ||
| 16 | const cwd = std.Io.Dir.cwd(); | 16 | const cwd = std.Io.Dir.cwd(); |
| 17 | const cwd_realpath = try cwd.realPathAlloc(io, arena, "."); | 17 | const cwd_realpath = try cwd.realPathFileAlloc(io, ".", arena); |
| 18 | 18 | ||
| 19 | while (arg_it.next()) |file_path| { | 19 | while (arg_it.next()) |file_path| { |
| 20 | if (file_path.len > 0 and file_path[0] == '!') { | 20 | if (file_path.len > 0 and file_path[0] == '!') { |
| ... | @@ -22,7 +22,7 @@ pub fn main() !void { | ... | @@ -22,7 +22,7 @@ pub fn main() !void { |
| 22 | "exclusive file check '{s}{c}{s}' failed", | 22 | "exclusive file check '{s}{c}{s}' failed", |
| 23 | .{ cwd_realpath, std.fs.path.sep, file_path[1..] }, | 23 | .{ cwd_realpath, std.fs.path.sep, file_path[1..] }, |
| 24 | ); | 24 | ); |
| 25 | if (cwd.statFile(io, file_path[1..])) |_| { | 25 | if (cwd.statFile(io, file_path[1..], .{})) |_| { |
| 26 | return error.FileFound; | 26 | return error.FileFound; |
| 27 | } else |err| switch (err) { | 27 | } else |err| switch (err) { |
| 28 | error.FileNotFound => {}, | 28 | error.FileNotFound => {}, |
| ... | @@ -33,7 +33,7 @@ pub fn main() !void { | ... | @@ -33,7 +33,7 @@ pub fn main() !void { |
| 33 | "inclusive file check '{s}{c}{s}' failed", | 33 | "inclusive file check '{s}{c}{s}' failed", |
| 34 | .{ cwd_realpath, std.fs.path.sep, file_path }, | 34 | .{ cwd_realpath, std.fs.path.sep, file_path }, |
| 35 | ); | 35 | ); |
| 36 | _ = try cwd.statFile(io, file_path); | 36 | _ = try cwd.statFile(io, file_path, .{}); |
| 37 | } | 37 | } |
| 38 | } | 38 | } |
| 39 | } | 39 | } |
test/standalone/run_output_caching/main.zig+1-1| ... | @@ -7,5 +7,5 @@ pub fn main() !void { | ... | @@ -7,5 +7,5 @@ pub fn main() !void { |
| 7 | const filename = args.next().?; | 7 | const filename = args.next().?; |
| 8 | const file = try std.Io.Dir.cwd().createFile(io, filename, .{}); | 8 | const file = try std.Io.Dir.cwd().createFile(io, filename, .{}); |
| 9 | defer file.close(io); | 9 | defer file.close(io); |
| 10 | try file.writeAll(io, filename); | 10 | try file.writeStreamingAll(io, filename); |
| 11 | } | 11 | } |
test/standalone/run_output_paths/create_file.zig+2-2| ... | @@ -10,8 +10,8 @@ pub fn main() !void { | ... | @@ -10,8 +10,8 @@ pub fn main() !void { |
| 10 | else | 10 | else |
| 11 | dir_name, .{}); | 11 | dir_name, .{}); |
| 12 | const file_name = args.next().?; | 12 | const file_name = args.next().?; |
| 13 | const file = try dir.createFile(file_name, .{}); | 13 | const file = try dir.createFile(io, file_name, .{}); |
| 14 | var file_writer = file.writer(&.{}); | 14 | var file_writer = file.writer(io, &.{}); |
| 15 | try file_writer.interface.print( | 15 | try file_writer.interface.print( |
| 16 | \\{s} | 16 | \\{s} |
| 17 | \\{s} | 17 | \\{s} |
test/standalone/self_exe_symlink/main.zig+3-2| ... | @@ -12,10 +12,11 @@ pub fn main() !void { | ... | @@ -12,10 +12,11 @@ pub fn main() !void { |
| 12 | const self_path = try std.process.executablePathAlloc(io, gpa); | 12 | const self_path = try std.process.executablePathAlloc(io, gpa); |
| 13 | defer gpa.free(self_path); | 13 | defer gpa.free(self_path); |
| 14 | 14 | ||
| 15 | var self_exe = try std.fs.openSelfExe(.{}); | 15 | var self_exe = try std.process.openExecutable(io, .{}); |
| 16 | defer self_exe.close(io); | 16 | defer self_exe.close(io); |
| 17 | |||
| 17 | var buf: [std.fs.max_path_bytes]u8 = undefined; | 18 | 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)]; |
| 19 | 20 | ||
| 20 | try std.testing.expectEqualStrings(self_exe_path, self_path); | 21 | try std.testing.expectEqualStrings(self_exe_path, self_path); |
| 21 | } | 22 | } |
tools/dump-cov.zig+5-3| ... | @@ -2,6 +2,7 @@ | ... | @@ -2,6 +2,7 @@ |
| 2 | //! including file:line:column information for each PC. | 2 | //! including file:line:column information for each PC. |
| 3 | 3 | ||
| 4 | const std = @import("std"); | 4 | const std = @import("std"); |
| 5 | const Io = std.Io; | ||
| 5 | const fatal = std.process.fatal; | 6 | const fatal = std.process.fatal; |
| 6 | const Path = std.Build.Cache.Path; | 7 | const Path = std.Build.Cache.Path; |
| 7 | const assert = std.debug.assert; | 8 | const assert = std.debug.assert; |
| ... | @@ -16,7 +17,7 @@ pub fn main() !void { | ... | @@ -16,7 +17,7 @@ pub fn main() !void { |
| 16 | defer arena_instance.deinit(); | 17 | defer arena_instance.deinit(); |
| 17 | const arena = arena_instance.allocator(); | 18 | const arena = arena_instance.allocator(); |
| 18 | 19 | ||
| 19 | var threaded: std.Io.Threaded = .init(gpa, .{}); | 20 | var threaded: Io.Threaded = .init(gpa, .{}); |
| 20 | defer threaded.deinit(); | 21 | defer threaded.deinit(); |
| 21 | const io = threaded.io(); | 22 | const io = threaded.io(); |
| 22 | 23 | ||
| ... | @@ -57,6 +58,7 @@ pub fn main() !void { | ... | @@ -57,6 +58,7 @@ pub fn main() !void { |
| 57 | defer debug_info.deinit(gpa); | 58 | defer debug_info.deinit(gpa); |
| 58 | 59 | ||
| 59 | const cov_bytes = cov_path.root_dir.handle.readFileAllocOptions( | 60 | const cov_bytes = cov_path.root_dir.handle.readFileAllocOptions( |
| 61 | io, | ||
| 60 | cov_path.sub_path, | 62 | cov_path.sub_path, |
| 61 | arena, | 63 | arena, |
| 62 | .limited(1 << 30), | 64 | .limited(1 << 30), |
| ... | @@ -67,7 +69,7 @@ pub fn main() !void { | ... | @@ -67,7 +69,7 @@ pub fn main() !void { |
| 67 | }; | 69 | }; |
| 68 | 70 | ||
| 69 | var stdout_buffer: [4000]u8 = undefined; | 71 | 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); |
| 71 | const stdout = &stdout_writer.interface; | 73 | const stdout = &stdout_writer.interface; |
| 72 | 74 | ||
| 73 | const header: *SeenPcsHeader = @ptrCast(cov_bytes); | 75 | const header: *SeenPcsHeader = @ptrCast(cov_bytes); |
| ... | @@ -83,7 +85,7 @@ pub fn main() !void { | ... | @@ -83,7 +85,7 @@ pub fn main() !void { |
| 83 | std.mem.sortUnstable(usize, sorted_pcs, {}, std.sort.asc(usize)); | 85 | std.mem.sortUnstable(usize, sorted_pcs, {}, std.sort.asc(usize)); |
| 84 | 86 | ||
| 85 | const source_locations = try arena.alloc(std.debug.Coverage.SourceLocation, sorted_pcs.len); | 87 | 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); |
| 87 | 89 | ||
| 88 | const seen_pcs = header.seenBits(); | 90 | const seen_pcs = header.seenBits(); |
| 89 | 91 |
tools/fetch_them_macos_headers.zig+6-9| ... | @@ -92,7 +92,7 @@ pub fn main() anyerror!void { | ... | @@ -92,7 +92,7 @@ pub fn main() anyerror!void { |
| 92 | 92 | ||
| 93 | const sysroot_path = sysroot orelse blk: { | 93 | const sysroot_path = sysroot orelse blk: { |
| 94 | const target = try std.zig.system.resolveTargetQuery(io, .{}); | 94 | 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 |
| 96 | fatal("no SDK found; you can provide one explicitly with '--sysroot' flag", .{}); | 96 | fatal("no SDK found; you can provide one explicitly with '--sysroot' flag", .{}); |
| 97 | }; | 97 | }; |
| 98 | 98 | ||
| ... | @@ -166,10 +166,7 @@ fn fetchTarget( | ... | @@ -166,10 +166,7 @@ fn fetchTarget( |
| 166 | }); | 166 | }); |
| 167 | try cc_argv.appendSlice(args); | 167 | try cc_argv.appendSlice(args); |
| 168 | 168 | ||
| 169 | const res = try std.process.Child.run(.{ | 169 | const res = try std.process.Child.run(arena, io, .{ .argv = cc_argv.items }); |
| 170 | .allocator = arena, | ||
| 171 | .argv = cc_argv.items, | ||
| 172 | }); | ||
| 173 | 170 | ||
| 174 | if (res.stderr.len != 0) { | 171 | if (res.stderr.len != 0) { |
| 175 | std.log.err("{s}", .{res.stderr}); | 172 | std.log.err("{s}", .{res.stderr}); |
| ... | @@ -179,7 +176,7 @@ fn fetchTarget( | ... | @@ -179,7 +176,7 @@ fn fetchTarget( |
| 179 | const headers_list_file = try tmp.dir.openFile(io, headers_list_filename, .{}); | 176 | const headers_list_file = try tmp.dir.openFile(io, headers_list_filename, .{}); |
| 180 | defer headers_list_file.close(io); | 177 | defer headers_list_file.close(io); |
| 181 | 178 | ||
| 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) { |
| 183 | error.FileNotFound, | 180 | error.FileNotFound, |
| 184 | error.NotDir, | 181 | error.NotDir, |
| 185 | => fatal("path '{s}' not found or not a directory. Did you accidentally delete it?", .{ | 182 | => fatal("path '{s}' not found or not a directory. Did you accidentally delete it?", .{ |
| ... | @@ -215,15 +212,15 @@ fn fetchTarget( | ... | @@ -215,15 +212,15 @@ fn fetchTarget( |
| 215 | 212 | ||
| 216 | const line_stripped = mem.trim(u8, line, " \\"); | 213 | const line_stripped = mem.trim(u8, line, " \\"); |
| 217 | const abs_dirname = Dir.path.dirname(line_stripped).?; | 214 | 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, .{}); |
| 219 | defer orig_subdir.close(io); | 216 | defer orig_subdir.close(io); |
| 220 | 217 | ||
| 221 | try orig_subdir.copyFile(basename, maybe_dir.value_ptr.*, basename, .{}); | 218 | try orig_subdir.copyFile(basename, maybe_dir.value_ptr.*, basename, io, .{}); |
| 222 | } | 219 | } |
| 223 | } | 220 | } |
| 224 | 221 | ||
| 225 | var dir_it = dirs.iterator(); | 222 | var dir_it = dirs.iterator(); |
| 226 | while (dir_it.next(io)) |entry| { | 223 | while (dir_it.next()) |entry| { |
| 227 | entry.value_ptr.close(io); | 224 | entry.value_ptr.close(io); |
| 228 | } | 225 | } |
| 229 | } | 226 | } |
tools/gen_macos_headers_c.zig+6-6| ... | @@ -38,7 +38,7 @@ pub fn main() anyerror!void { | ... | @@ -38,7 +38,7 @@ pub fn main() anyerror!void { |
| 38 | 38 | ||
| 39 | if (positionals.items.len != 1) fatal("expected one positional argument: [dir]", .{}); | 39 | if (positionals.items.len != 1) fatal("expected one positional argument: [dir]", .{}); |
| 40 | 40 | ||
| 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 }); |
| 42 | defer dir.close(io); | 42 | defer dir.close(io); |
| 43 | var paths = std.array_list.Managed([]const u8).init(arena); | 43 | var paths = std.array_list.Managed([]const u8).init(arena); |
| 44 | try findHeaders(arena, io, dir, "", &paths); | 44 | try findHeaders(arena, io, dir, "", &paths); |
| ... | @@ -53,7 +53,7 @@ pub fn main() anyerror!void { | ... | @@ -53,7 +53,7 @@ pub fn main() anyerror!void { |
| 53 | std.mem.sort([]const u8, paths.items, {}, SortFn.lessThan); | 53 | std.mem.sort([]const u8, paths.items, {}, SortFn.lessThan); |
| 54 | 54 | ||
| 55 | var buffer: [2000]u8 = undefined; | 55 | 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); |
| 57 | const w = &stdout_writer.interface; | 57 | const w = &stdout_writer.interface; |
| 58 | try w.writeAll("#define _XOPEN_SOURCE\n"); | 58 | try w.writeAll("#define _XOPEN_SOURCE\n"); |
| 59 | for (paths.items) |path| { | 59 | for (paths.items) |path| { |
| ... | @@ -75,18 +75,18 @@ fn findHeaders( | ... | @@ -75,18 +75,18 @@ fn findHeaders( |
| 75 | paths: *std.array_list.Managed([]const u8), | 75 | paths: *std.array_list.Managed([]const u8), |
| 76 | ) anyerror!void { | 76 | ) anyerror!void { |
| 77 | var it = dir.iterate(); | 77 | var it = dir.iterate(); |
| 78 | while (try it.next()) |entry| { | 78 | while (try it.next(io)) |entry| { |
| 79 | switch (entry.kind) { | 79 | switch (entry.kind) { |
| 80 | .directory => { | 80 | .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 }); |
| 82 | var subdir = try dir.openDir(io, entry.name, .{ .follow_symlinks = false }); | 82 | var subdir = try dir.openDir(io, entry.name, .{ .follow_symlinks = false }); |
| 83 | defer subdir.close(io); | 83 | defer subdir.close(io); |
| 84 | try findHeaders(arena, io, subdir, path, paths); | 84 | try findHeaders(arena, io, subdir, path, paths); |
| 85 | }, | 85 | }, |
| 86 | .file, .sym_link => { | 86 | .file, .sym_link => { |
| 87 | const ext = std.fs.path.extension(entry.name); | 87 | const ext = Io.Dir.path.extension(entry.name); |
| 88 | if (!std.mem.eql(u8, ext, ".h")) continue; | 88 | 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 }); |
| 90 | try paths.append(path); | 90 | try paths.append(path); |
| 91 | }, | 91 | }, |
| 92 | else => {}, | 92 | else => {}, |
tools/gen_outline_atomics.zig+6-1| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | ||
| 2 | const Allocator = std.mem.Allocator; | 3 | const Allocator = std.mem.Allocator; |
| 3 | 4 | ||
| 4 | const AtomicOp = enum { | 5 | const AtomicOp = enum { |
| ... | @@ -15,10 +16,14 @@ pub fn main() !void { | ... | @@ -15,10 +16,14 @@ pub fn main() !void { |
| 15 | defer arena_instance.deinit(); | 16 | defer arena_instance.deinit(); |
| 16 | const arena = arena_instance.allocator(); | 17 | const arena = arena_instance.allocator(); |
| 17 | 18 | ||
| 19 | var threaded: std.Io.Threaded = .init(arena, .{}); | ||
| 20 | defer threaded.deinit(); | ||
| 21 | const io = threaded.io(); | ||
| 22 | |||
| 18 | //const args = try std.process.argsAlloc(arena); | 23 | //const args = try std.process.argsAlloc(arena); |
| 19 | 24 | ||
| 20 | var stdout_buffer: [2000]u8 = undefined; | 25 | 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); |
| 22 | const w = &stdout_writer.interface; | 27 | const w = &stdout_writer.interface; |
| 23 | 28 | ||
| 24 | try w.writeAll( | 29 | try w.writeAll( |
tools/gen_spirv_spec.zig+20-14| ... | @@ -1,5 +1,7 @@ | ... | @@ -1,5 +1,7 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | ||
| 2 | const Allocator = std.mem.Allocator; | 3 | const Allocator = std.mem.Allocator; |
| 4 | |||
| 3 | const g = @import("spirv/grammar.zig"); | 5 | const g = @import("spirv/grammar.zig"); |
| 4 | const CoreRegistry = g.CoreRegistry; | 6 | const CoreRegistry = g.CoreRegistry; |
| 5 | const ExtensionRegistry = g.ExtensionRegistry; | 7 | const ExtensionRegistry = g.ExtensionRegistry; |
| ... | @@ -63,24 +65,28 @@ pub fn main() !void { | ... | @@ -63,24 +65,28 @@ pub fn main() !void { |
| 63 | usageAndExit(args[0], 1); | 65 | usageAndExit(args[0], 1); |
| 64 | } | 66 | } |
| 65 | 67 | ||
| 66 | const json_path = try std.fs.path.join(allocator, &.{ args[1], "include/spirv/unified1/" }); | 68 | var threaded: std.Io.Threaded = .init(allocator, .{}); |
| 67 | const dir = try std.fs.cwd().openDir(json_path, .{ .iterate = true }); | 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 }); | ||
| 68 | 74 | ||
| 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"); |
| 70 | std.mem.sortUnstable(Instruction, core_spec.instructions, CmpInst{}, CmpInst.lt); | 76 | std.mem.sortUnstable(Instruction, core_spec.instructions, CmpInst{}, CmpInst.lt); |
| 71 | 77 | ||
| 72 | var exts = std.array_list.Managed(Extension).init(allocator); | 78 | var exts = std.array_list.Managed(Extension).init(allocator); |
| 73 | 79 | ||
| 74 | var it = dir.iterate(); | 80 | var it = dir.iterate(); |
| 75 | while (try it.next()) |entry| { | 81 | while (try it.next(io)) |entry| { |
| 76 | if (entry.kind != .file) { | 82 | if (entry.kind != .file) { |
| 77 | continue; | 83 | continue; |
| 78 | } | 84 | } |
| 79 | 85 | ||
| 80 | try readExtRegistry(&exts, dir, entry.name); | 86 | try readExtRegistry(io, &exts, dir, entry.name); |
| 81 | } | 87 | } |
| 82 | 88 | ||
| 83 | try readExtRegistry(&exts, std.fs.cwd(), args[2]); | 89 | try readExtRegistry(io, &exts, Io.Dir.cwd(), args[2]); |
| 84 | 90 | ||
| 85 | var allocating: std.Io.Writer.Allocating = .init(allocator); | 91 | var allocating: std.Io.Writer.Allocating = .init(allocator); |
| 86 | defer allocating.deinit(); | 92 | defer allocating.deinit(); |
| ... | @@ -91,7 +97,7 @@ pub fn main() !void { | ... | @@ -91,7 +97,7 @@ pub fn main() !void { |
| 91 | var tree = try std.zig.Ast.parse(allocator, output, .zig); | 97 | var tree = try std.zig.Ast.parse(allocator, output, .zig); |
| 92 | 98 | ||
| 93 | if (tree.errors.len != 0) { | 99 | if (tree.errors.len != 0) { |
| 94 | try std.zig.printAstErrorsToStderr(allocator, tree, "", .auto); | 100 | try std.zig.printAstErrorsToStderr(allocator, io, tree, "", .auto); |
| 95 | return; | 101 | return; |
| 96 | } | 102 | } |
| 97 | 103 | ||
| ... | @@ -103,22 +109,22 @@ pub fn main() !void { | ... | @@ -103,22 +109,22 @@ pub fn main() !void { |
| 103 | try wip_errors.addZirErrorMessages(zir, tree, output, ""); | 109 | try wip_errors.addZirErrorMessages(zir, tree, output, ""); |
| 104 | var error_bundle = try wip_errors.toOwnedBundle(""); | 110 | var error_bundle = try wip_errors.toOwnedBundle(""); |
| 105 | defer error_bundle.deinit(allocator); | 111 | defer error_bundle.deinit(allocator); |
| 106 | error_bundle.renderToStdErr(.{}, .auto); | 112 | try error_bundle.renderToStderr(io, .{}, .auto); |
| 107 | } | 113 | } |
| 108 | 114 | ||
| 109 | const formatted_output = try tree.renderAlloc(allocator); | 115 | 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); |
| 111 | } | 117 | } |
| 112 | 118 | ||
| 113 | fn readExtRegistry(exts: *std.array_list.Managed(Extension), dir: std.fs.Dir, sub_path: []const u8) !void { | 119 | fn readExtRegistry(io: Io, exts: *std.array_list.Managed(Extension), dir: Io.Dir, sub_path: []const u8) !void { |
| 114 | const filename = std.fs.path.basename(sub_path); | 120 | const filename = Io.Dir.path.basename(sub_path); |
| 115 | if (!std.mem.startsWith(u8, filename, "extinst.")) { | 121 | if (!std.mem.startsWith(u8, filename, "extinst.")) { |
| 116 | return; | 122 | return; |
| 117 | } | 123 | } |
| 118 | 124 | ||
| 119 | std.debug.assert(std.mem.endsWith(u8, filename, ".grammar.json")); | 125 | std.debug.assert(std.mem.endsWith(u8, filename, ".grammar.json")); |
| 120 | const name = filename["extinst.".len .. filename.len - ".grammar.json".len]; | 126 | 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); |
| 122 | 128 | ||
| 123 | const set_name = set_names.get(name) orelse { | 129 | const set_name = set_names.get(name) orelse { |
| 124 | std.log.info("ignored instruction set '{s}'", .{name}); | 130 | 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 | ... | @@ -134,8 +140,8 @@ fn readExtRegistry(exts: *std.array_list.Managed(Extension), dir: std.fs.Dir, su |
| 134 | }); | 140 | }); |
| 135 | } | 141 | } |
| 136 | 142 | ||
| 137 | fn readRegistry(comptime RegistryType: type, dir: std.fs.Dir, path: []const u8) !RegistryType { | 143 | fn readRegistry(io: Io, comptime RegistryType: type, dir: Io.Dir, path: []const u8) !RegistryType { |
| 138 | const spec = try dir.readFileAlloc(path, allocator, .unlimited); | 144 | const spec = try dir.readFileAlloc(io, path, allocator, .unlimited); |
| 139 | // Required for json parsing. | 145 | // Required for json parsing. |
| 140 | // TODO: ALI | 146 | // TODO: ALI |
| 141 | @setEvalBranchQuota(10000); | 147 | @setEvalBranchQuota(10000); |
tools/gen_stubs.zig+12-5| ... | @@ -55,12 +55,14 @@ | ... | @@ -55,12 +55,14 @@ |
| 55 | // - e.g. find a common previous symbol and put it after that one | 55 | // - e.g. find a common previous symbol and put it after that one |
| 56 | // - they definitely need to go into the correct section | 56 | // - they definitely need to go into the correct section |
| 57 | 57 | ||
| 58 | const builtin = @import("builtin"); | ||
| 59 | const native_endian = builtin.cpu.arch.endian(); | ||
| 60 | |||
| 58 | const std = @import("std"); | 61 | const std = @import("std"); |
| 59 | const builtin = std.builtin; | 62 | const Io = std.Io; |
| 60 | const mem = std.mem; | 63 | const mem = std.mem; |
| 61 | const log = std.log; | 64 | const log = std.log; |
| 62 | const elf = std.elf; | 65 | const elf = std.elf; |
| 63 | const native_endian = @import("builtin").cpu.arch.endian(); | ||
| 64 | 66 | ||
| 65 | const Arch = enum { | 67 | const Arch = enum { |
| 66 | aarch64, | 68 | aarch64, |
| ... | @@ -284,10 +286,14 @@ pub fn main() !void { | ... | @@ -284,10 +286,14 @@ pub fn main() !void { |
| 284 | defer arena_instance.deinit(); | 286 | defer arena_instance.deinit(); |
| 285 | const arena = arena_instance.allocator(); | 287 | const arena = arena_instance.allocator(); |
| 286 | 288 | ||
| 289 | var threaded: std.Io.Threaded = .init(arena, .{}); | ||
| 290 | defer threaded.deinit(); | ||
| 291 | const io = threaded.io(); | ||
| 292 | |||
| 287 | const args = try std.process.argsAlloc(arena); | 293 | const args = try std.process.argsAlloc(arena); |
| 288 | const build_all_path = args[1]; | 294 | const build_all_path = args[1]; |
| 289 | 295 | ||
| 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, .{}); |
| 291 | 297 | ||
| 292 | var sym_table = std.StringArrayHashMap(MultiSym).init(arena); | 298 | var sym_table = std.StringArrayHashMap(MultiSym).init(arena); |
| 293 | var sections = std.StringArrayHashMap(void).init(arena); | 299 | var sections = std.StringArrayHashMap(void).init(arena); |
| ... | @@ -299,6 +305,7 @@ pub fn main() !void { | ... | @@ -299,6 +305,7 @@ pub fn main() !void { |
| 299 | 305 | ||
| 300 | // Read the ELF header. | 306 | // Read the ELF header. |
| 301 | const elf_bytes = build_all_dir.readFileAllocOptions( | 307 | const elf_bytes = build_all_dir.readFileAllocOptions( |
| 308 | io, | ||
| 302 | libc_so_path, | 309 | libc_so_path, |
| 303 | arena, | 310 | arena, |
| 304 | .limited(100 * 1024 * 1024), | 311 | .limited(100 * 1024 * 1024), |
| ... | @@ -334,7 +341,7 @@ pub fn main() !void { | ... | @@ -334,7 +341,7 @@ pub fn main() !void { |
| 334 | } | 341 | } |
| 335 | 342 | ||
| 336 | var stdout_buffer: [2000]u8 = undefined; | 343 | 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); |
| 338 | const stdout = &stdout_writer.interface; | 345 | const stdout = &stdout_writer.interface; |
| 339 | try stdout.writeAll( | 346 | try stdout.writeAll( |
| 340 | \\#ifdef PTR64 | 347 | \\#ifdef PTR64 |
| ... | @@ -539,7 +546,7 @@ pub fn main() !void { | ... | @@ -539,7 +546,7 @@ pub fn main() !void { |
| 539 | try stdout.flush(); | 546 | try stdout.flush(); |
| 540 | } | 547 | } |
| 541 | 548 | ||
| 542 | fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: builtin.Endian) !void { | 549 | fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: std.builtin.Endian) !void { |
| 543 | const arena = parse.arena; | 550 | const arena = parse.arena; |
| 544 | const elf_bytes = parse.elf_bytes; | 551 | const elf_bytes = parse.elf_bytes; |
| 545 | const header = parse.header; | 552 | const header = parse.header; |
tools/generate_JSONTestSuite.zig+9-4| ... | @@ -1,13 +1,18 @@ | ... | @@ -1,13 +1,18 @@ |
| 1 | // zig run this file inside the test_parsing/ directory of this repo: https://github.com/nst/JSONTestSuite | 1 | // zig run this file inside the test_parsing/ directory of this repo: https://github.com/nst/JSONTestSuite |
| 2 | 2 | ||
| 3 | const std = @import("std"); | 3 | const std = @import("std"); |
| 4 | const Io = std.Io; | ||
| 4 | 5 | ||
| 5 | pub fn main() !void { | 6 | pub fn main() !void { |
| 6 | var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init; | 7 | var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init; |
| 7 | var allocator = gpa.allocator(); | 8 | var allocator = gpa.allocator(); |
| 8 | 9 | ||
| 10 | var threaded: std.Io.Threaded = .init(allocator, .{}); | ||
| 11 | defer threaded.deinit(); | ||
| 12 | const io = threaded.io(); | ||
| 13 | |||
| 9 | var stdout_buffer: [2000]u8 = undefined; | 14 | 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); |
| 11 | const output = &stdout_writer.interface; | 16 | const output = &stdout_writer.interface; |
| 12 | try output.writeAll( | 17 | try output.writeAll( |
| 13 | \\// This file was generated by _generate_JSONTestSuite.zig | 18 | \\// This file was generated by _generate_JSONTestSuite.zig |
| ... | @@ -20,9 +25,9 @@ pub fn main() !void { | ... | @@ -20,9 +25,9 @@ pub fn main() !void { |
| 20 | ); | 25 | ); |
| 21 | 26 | ||
| 22 | var names = std.array_list.Managed([]const u8).init(allocator); | 27 | 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 }); |
| 24 | var it = cwd.iterate(); | 29 | var it = cwd.iterate(); |
| 25 | while (try it.next()) |entry| { | 30 | while (try it.next(io)) |entry| { |
| 26 | try names.append(try allocator.dupe(u8, entry.name)); | 31 | try names.append(try allocator.dupe(u8, entry.name)); |
| 27 | } | 32 | } |
| 28 | std.mem.sort([]const u8, names.items, {}, (struct { | 33 | std.mem.sort([]const u8, names.items, {}, (struct { |
| ... | @@ -32,7 +37,7 @@ pub fn main() !void { | ... | @@ -32,7 +37,7 @@ pub fn main() !void { |
| 32 | }).lessThan); | 37 | }).lessThan); |
| 33 | 38 | ||
| 34 | for (names.items) |name| { | 39 | 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)); |
| 36 | try output.writeAll("test "); | 41 | try output.writeAll("test "); |
| 37 | try writeString(output, name); | 42 | try writeString(output, name); |
| 38 | try output.writeAll(" {\n try "); | 43 | try output.writeAll(" {\n try "); |
tools/generate_c_size_and_align_checks.zig+2-1| ... | @@ -7,6 +7,7 @@ | ... | @@ -7,6 +7,7 @@ |
| 7 | //! target. | 7 | //! target. |
| 8 | 8 | ||
| 9 | const std = @import("std"); | 9 | const std = @import("std"); |
| 10 | const Io = std.Io; | ||
| 10 | 11 | ||
| 11 | fn cName(ty: std.Target.CType) []const u8 { | 12 | fn cName(ty: std.Target.CType) []const u8 { |
| 12 | return switch (ty) { | 13 | return switch (ty) { |
| ... | @@ -47,7 +48,7 @@ pub fn main() !void { | ... | @@ -47,7 +48,7 @@ pub fn main() !void { |
| 47 | const target = try std.zig.system.resolveTargetQuery(io, query); | 48 | const target = try std.zig.system.resolveTargetQuery(io, query); |
| 48 | 49 | ||
| 49 | var buffer: [2000]u8 = undefined; | 50 | 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); |
| 51 | const w = &stdout_writer.interface; | 52 | const w = &stdout_writer.interface; |
| 52 | inline for (@typeInfo(std.Target.CType).@"enum".fields) |field| { | 53 | inline for (@typeInfo(std.Target.CType).@"enum".fields) |field| { |
| 53 | const c_type: std.Target.CType = @enumFromInt(field.value); | 54 | const c_type: std.Target.CType = @enumFromInt(field.value); |
tools/generate_linux_syscalls.zig+3-3| ... | @@ -189,10 +189,10 @@ pub fn main() !void { | ... | @@ -189,10 +189,10 @@ pub fn main() !void { |
| 189 | const linux_path = args[1]; | 189 | const linux_path = args[1]; |
| 190 | 190 | ||
| 191 | var stdout_buffer: [2048]u8 = undefined; | 191 | 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); |
| 193 | const stdout = &stdout_writer.interface; | 193 | const stdout = &stdout_writer.interface; |
| 194 | 194 | ||
| 195 | var linux_dir = try std.fs.cwd().openDir(io, linux_path, .{}); | 195 | var linux_dir = try Io.Dir.cwd().openDir(io, linux_path, .{}); |
| 196 | defer linux_dir.close(io); | 196 | defer linux_dir.close(io); |
| 197 | 197 | ||
| 198 | // As of 6.11, the largest table is 24195 bytes. | 198 | // As of 6.11, the largest table is 24195 bytes. |
| ... | @@ -225,7 +225,7 @@ pub fn main() !void { | ... | @@ -225,7 +225,7 @@ pub fn main() !void { |
| 225 | , .{version}); | 225 | , .{version}); |
| 226 | 226 | ||
| 227 | for (architectures, 0..) |arch, i| { | 227 | 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) { |
| 229 | .generic => "scripts/syscall.tbl", | 229 | .generic => "scripts/syscall.tbl", |
| 230 | .specific => |f| f, | 230 | .specific => |f| f, |
| 231 | }, buf); | 231 | }, buf); |
tools/migrate_langref.zig+7-7| ... | @@ -26,15 +26,15 @@ pub fn main() !void { | ... | @@ -26,15 +26,15 @@ pub fn main() !void { |
| 26 | defer threaded.deinit(); | 26 | defer threaded.deinit(); |
| 27 | const io = threaded.io(); | 27 | const io = threaded.io(); |
| 28 | 28 | ||
| 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 }); |
| 30 | defer in_file.close(io); | 30 | defer in_file.close(io); |
| 31 | 31 | ||
| 32 | var out_file = try Dir.cwd().createFile(output_file, .{}); | 32 | var out_file = try Dir.cwd().createFile(io, output_file, .{}); |
| 33 | defer out_file.close(io); | 33 | defer out_file.close(io); |
| 34 | var out_file_buffer: [4096]u8 = undefined; | 34 | 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); |
| 36 | 36 | ||
| 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).?, .{}); |
| 38 | defer out_dir.close(io); | 38 | defer out_dir.close(io); |
| 39 | 39 | ||
| 40 | var in_file_reader = in_file.reader(io, &.{}); | 40 | var in_file_reader = in_file.reader(io, &.{}); |
| ... | @@ -42,7 +42,7 @@ pub fn main() !void { | ... | @@ -42,7 +42,7 @@ pub fn main() !void { |
| 42 | 42 | ||
| 43 | var tokenizer = Tokenizer.init(input_file, input_file_bytes); | 43 | var tokenizer = Tokenizer.init(input_file, input_file_bytes); |
| 44 | 44 | ||
| 45 | try walk(arena, &tokenizer, out_dir, &out_file_writer.interface); | 45 | try walk(arena, io, &tokenizer, out_dir, &out_file_writer.interface); |
| 46 | 46 | ||
| 47 | try out_file_writer.end(); | 47 | try out_file_writer.end(); |
| 48 | } | 48 | } |
| ... | @@ -387,12 +387,12 @@ fn walk(arena: Allocator, io: Io, tokenizer: *Tokenizer, out_dir: Dir, w: anytyp | ... | @@ -387,12 +387,12 @@ fn walk(arena: Allocator, io: Io, tokenizer: *Tokenizer, out_dir: Dir, w: anytyp |
| 387 | 387 | ||
| 388 | const basename = try std.fmt.allocPrint(arena, "{s}.zig", .{name}); | 388 | const basename = try std.fmt.allocPrint(arena, "{s}.zig", .{name}); |
| 389 | 389 | ||
| 390 | var file = out_dir.createFile(basename, .{ .exclusive = true }) catch |err| { | 390 | var file = out_dir.createFile(io, basename, .{ .exclusive = true }) catch |err| { |
| 391 | fatal("unable to create file '{s}': {s}", .{ name, @errorName(err) }); | 391 | fatal("unable to create file '{s}': {s}", .{ name, @errorName(err) }); |
| 392 | }; | 392 | }; |
| 393 | defer file.close(io); | 393 | defer file.close(io); |
| 394 | var file_buffer: [1024]u8 = undefined; | 394 | var file_buffer: [1024]u8 = undefined; |
| 395 | var file_writer = file.writer(&file_buffer); | 395 | var file_writer = file.writer(io, &file_buffer); |
| 396 | const code = &file_writer.interface; | 396 | const code = &file_writer.interface; |
| 397 | 397 | ||
| 398 | const source = tokenizer.buffer[source_token.start..source_token.end]; | 398 | const source = tokenizer.buffer[source_token.start..source_token.end]; |
tools/process_headers.zig+4-6| ... | @@ -131,7 +131,7 @@ pub fn main() !void { | ... | @@ -131,7 +131,7 @@ pub fn main() !void { |
| 131 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | 131 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 132 | const allocator = arena.allocator(); | 132 | const allocator = arena.allocator(); |
| 133 | 133 | ||
| 134 | var threaded: Io.Threaded = .init(allocator); | 134 | var threaded: Io.Threaded = .init(allocator, .{}); |
| 135 | defer threaded.deinit(); | 135 | defer threaded.deinit(); |
| 136 | const io = threaded.io(); | 136 | const io = threaded.io(); |
| 137 | 137 | ||
| ... | @@ -253,14 +253,14 @@ pub fn main() !void { | ... | @@ -253,14 +253,14 @@ pub fn main() !void { |
| 253 | 253 | ||
| 254 | var dir_it = dir.iterate(); | 254 | var dir_it = dir.iterate(); |
| 255 | 255 | ||
| 256 | while (try dir_it.next()) |entry| { | 256 | while (try dir_it.next(io)) |entry| { |
| 257 | const full_path = try Dir.path.join(allocator, &[_][]const u8{ full_dir_name, entry.name }); | 257 | const full_path = try Dir.path.join(allocator, &[_][]const u8{ full_dir_name, entry.name }); |
| 258 | switch (entry.kind) { | 258 | switch (entry.kind) { |
| 259 | .directory => try dir_stack.append(full_path), | 259 | .directory => try dir_stack.append(full_path), |
| 260 | .file, .sym_link => { | 260 | .file, .sym_link => { |
| 261 | const rel_path = try Dir.path.relative(allocator, target_include_dir, full_path); | 261 | const rel_path = try Dir.path.relative(allocator, target_include_dir, full_path); |
| 262 | const max_size = 2 * 1024 * 1024 * 1024; | 262 | 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)); |
| 264 | const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t"); | 264 | const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t"); |
| 265 | total_bytes += raw_bytes.len; | 265 | total_bytes += raw_bytes.len; |
| 266 | const hash = try allocator.alloc(u8, 32); | 266 | const hash = try allocator.alloc(u8, 32); |
| ... | @@ -273,9 +273,7 @@ pub fn main() !void { | ... | @@ -273,9 +273,7 @@ pub fn main() !void { |
| 273 | max_bytes_saved += raw_bytes.len; | 273 | max_bytes_saved += raw_bytes.len; |
| 274 | gop.value_ptr.hit_count += 1; | 274 | gop.value_ptr.hit_count += 1; |
| 275 | std.debug.print("duplicate: {s} {s} ({B})\n", .{ | 275 | std.debug.print("duplicate: {s} {s} ({B})\n", .{ |
| 276 | libc_dir, | 276 | libc_dir, rel_path, raw_bytes.len, |
| 277 | rel_path, | ||
| 278 | raw_bytes.len, | ||
| 279 | }); | 277 | }); |
| 280 | } else { | 278 | } else { |
| 281 | gop.value_ptr.* = Contents{ | 279 | gop.value_ptr.* = Contents{ |
tools/update-linux-headers.zig+1-1| ... | @@ -206,7 +206,7 @@ pub fn main() !void { | ... | @@ -206,7 +206,7 @@ pub fn main() !void { |
| 206 | 206 | ||
| 207 | var dir_it = dir.iterate(); | 207 | var dir_it = dir.iterate(); |
| 208 | 208 | ||
| 209 | while (try dir_it.next()) |entry| { | 209 | while (try dir_it.next(io)) |entry| { |
| 210 | const full_path = try Dir.path.join(arena, &[_][]const u8{ full_dir_name, entry.name }); | 210 | const full_path = try Dir.path.join(arena, &[_][]const u8{ full_dir_name, entry.name }); |
| 211 | switch (entry.kind) { | 211 | switch (entry.kind) { |
| 212 | .directory => try dir_stack.append(full_path), | 212 | .directory => try dir_stack.append(full_path), |
tools/update_clang_options.zig+7-4| ... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
| 10 | //! would mean that the next parameter specifies the target. | 10 | //! would mean that the next parameter specifies the target. |
| 11 | 11 | ||
| 12 | const std = @import("std"); | 12 | const std = @import("std"); |
| 13 | const fs = std.fs; | 13 | const Io = std.Io; |
| 14 | const assert = std.debug.assert; | 14 | const assert = std.debug.assert; |
| 15 | const json = std.json; | 15 | const json = std.json; |
| 16 | 16 | ||
| ... | @@ -634,8 +634,12 @@ pub fn main() anyerror!void { | ... | @@ -634,8 +634,12 @@ pub fn main() anyerror!void { |
| 634 | const allocator = arena.allocator(); | 634 | const allocator = arena.allocator(); |
| 635 | const args = try std.process.argsAlloc(allocator); | 635 | const args = try std.process.argsAlloc(allocator); |
| 636 | 636 | ||
| 637 | var threaded: std.Io.Threaded = .init(allocator, .{}); | ||
| 638 | defer threaded.deinit(); | ||
| 639 | const io = threaded.io(); | ||
| 640 | |||
| 637 | var stdout_buffer: [4000]u8 = undefined; | 641 | 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); |
| 639 | const stdout = &stdout_writer.interface; | 643 | const stdout = &stdout_writer.interface; |
| 640 | 644 | ||
| 641 | if (args.len <= 1) printUsageAndExit(args[0]); | 645 | if (args.len <= 1) printUsageAndExit(args[0]); |
| ... | @@ -676,8 +680,7 @@ pub fn main() anyerror!void { | ... | @@ -676,8 +680,7 @@ pub fn main() anyerror!void { |
| 676 | try std.fmt.allocPrint(allocator, "-I={s}/clang/include/clang/Driver", .{llvm_src_root}), | 680 | try std.fmt.allocPrint(allocator, "-I={s}/clang/include/clang/Driver", .{llvm_src_root}), |
| 677 | }; | 681 | }; |
| 678 | 682 | ||
| 679 | const child_result = try std.process.Child.run(.{ | 683 | const child_result = try std.process.Child.run(allocator, io, .{ |
| 680 | .allocator = allocator, | ||
| 681 | .argv = &child_args, | 684 | .argv = &child_args, |
| 682 | .max_output_bytes = 100 * 1024 * 1024, | 685 | .max_output_bytes = 100 * 1024 * 1024, |
| 683 | }); | 686 | }); |
tools/update_cpu_features.zig+2-3| ... | @@ -1994,8 +1994,7 @@ fn processOneTarget(io: Io, job: Job) void { | ... | @@ -1994,8 +1994,7 @@ fn processOneTarget(io: Io, job: Job) void { |
| 1994 | }), | 1994 | }), |
| 1995 | }; | 1995 | }; |
| 1996 | 1996 | ||
| 1997 | const child_result = try std.process.Child.run(.{ | 1997 | const child_result = try std.process.Child.run(arena, io, .{ |
| 1998 | .allocator = arena, | ||
| 1999 | .argv = &child_args, | 1998 | .argv = &child_args, |
| 2000 | .max_output_bytes = 500 * 1024 * 1024, | 1999 | .max_output_bytes = 500 * 1024 * 1024, |
| 2001 | }); | 2000 | }); |
| ... | @@ -2250,7 +2249,7 @@ fn processOneTarget(io: Io, job: Job) void { | ... | @@ -2250,7 +2249,7 @@ fn processOneTarget(io: Io, job: Job) void { |
| 2250 | defer zig_code_file.close(io); | 2249 | defer zig_code_file.close(io); |
| 2251 | 2250 | ||
| 2252 | var zig_code_file_buffer: [4096]u8 = undefined; | 2251 | 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); |
| 2254 | const w = &zig_code_file_writer.interface; | 2253 | const w = &zig_code_file_writer.interface; |
| 2255 | 2254 | ||
| 2256 | try w.writeAll( | 2255 | try w.writeAll( |
tools/update_crc_catalog.zig+2-2| ... | @@ -35,7 +35,7 @@ pub fn main() anyerror!void { | ... | @@ -35,7 +35,7 @@ pub fn main() anyerror!void { |
| 35 | var zig_code_file = try hash_target_dir.createFile(io, "crc.zig", .{}); | 35 | var zig_code_file = try hash_target_dir.createFile(io, "crc.zig", .{}); |
| 36 | defer zig_code_file.close(io); | 36 | defer zig_code_file.close(io); |
| 37 | var zig_code_file_buffer: [4096]u8 = undefined; | 37 | 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); |
| 39 | const code_writer = &zig_code_file_writer.interface; | 39 | const code_writer = &zig_code_file_writer.interface; |
| 40 | 40 | ||
| 41 | try code_writer.writeAll( | 41 | try code_writer.writeAll( |
| ... | @@ -59,7 +59,7 @@ pub fn main() anyerror!void { | ... | @@ -59,7 +59,7 @@ pub fn main() anyerror!void { |
| 59 | var zig_test_file = try crc_target_dir.createFile(io, "test.zig", .{}); | 59 | var zig_test_file = try crc_target_dir.createFile(io, "test.zig", .{}); |
| 60 | defer zig_test_file.close(io); | 60 | defer zig_test_file.close(io); |
| 61 | var zig_test_file_buffer: [4096]u8 = undefined; | 61 | 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); |
| 63 | const test_writer = &zig_test_file_writer.interface; | 63 | const test_writer = &zig_test_file_writer.interface; |
| 64 | 64 | ||
| 65 | try test_writer.writeAll( | 65 | try test_writer.writeAll( |
tools/update_freebsd_libc.zig+7-10| ... | @@ -27,13 +27,13 @@ pub fn main() !void { | ... | @@ -27,13 +27,13 @@ pub fn main() !void { |
| 27 | 27 | ||
| 28 | const dest_dir_path = try std.fmt.allocPrint(arena, "{s}/lib/libc/freebsd", .{zig_src_path}); | 28 | const dest_dir_path = try std.fmt.allocPrint(arena, "{s}/lib/libc/freebsd", .{zig_src_path}); |
| 29 | 29 | ||
| 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| { |
| 31 | std.log.err("unable to open destination directory '{s}': {t}", .{ dest_dir_path, err }); | 31 | std.log.err("unable to open destination directory '{s}': {t}", .{ dest_dir_path, err }); |
| 32 | std.process.exit(1); | 32 | std.process.exit(1); |
| 33 | }; | 33 | }; |
| 34 | defer dest_dir.close(io); | 34 | defer dest_dir.close(io); |
| 35 | 35 | ||
| 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, .{}); |
| 37 | defer freebsd_src_dir.close(io); | 37 | defer freebsd_src_dir.close(io); |
| 38 | 38 | ||
| 39 | // Copy updated files from upstream. | 39 | // Copy updated files from upstream. |
| ... | @@ -41,7 +41,7 @@ pub fn main() !void { | ... | @@ -41,7 +41,7 @@ pub fn main() !void { |
| 41 | var walker = try dest_dir.walk(arena); | 41 | var walker = try dest_dir.walk(arena); |
| 42 | defer walker.deinit(); | 42 | defer walker.deinit(); |
| 43 | 43 | ||
| 44 | walk: while (try walker.next()) |entry| { | 44 | walk: while (try walker.next(io)) |entry| { |
| 45 | if (entry.kind != .file) continue; | 45 | if (entry.kind != .file) continue; |
| 46 | if (std.mem.startsWith(u8, entry.basename, ".")) continue; | 46 | if (std.mem.startsWith(u8, entry.basename, ".")) continue; |
| 47 | for (exempt_files) |p| { | 47 | for (exempt_files) |p| { |
| ... | @@ -49,15 +49,12 @@ pub fn main() !void { | ... | @@ -49,15 +49,12 @@ pub fn main() !void { |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | std.log.info("updating '{s}/{s}' from '{s}/{s}'", .{ | 51 | std.log.info("updating '{s}/{s}' from '{s}/{s}'", .{ |
| 52 | dest_dir_path, entry.path, | 52 | dest_dir_path, entry.path, freebsd_src_path, entry.path, |
| 53 | freebsd_src_path, entry.path, | ||
| 54 | }); | 53 | }); |
| 55 | 54 | ||
| 56 | freebsd_src_dir.copyFile(entry.path, dest_dir, entry.path, .{}) catch |err| { | 55 | freebsd_src_dir.copyFile(entry.path, dest_dir, entry.path, io, .{}) catch |err| { |
| 57 | std.log.warn("unable to copy '{s}/{s}' to '{s}/{s}': {s}", .{ | 56 | std.log.warn("unable to copy '{s}/{s}' to '{s}/{s}': {t}", .{ |
| 58 | freebsd_src_path, entry.path, | 57 | freebsd_src_path, entry.path, dest_dir_path, entry.path, err, |
| 59 | dest_dir_path, entry.path, | ||
| 60 | @errorName(err), | ||
| 61 | }); | 58 | }); |
| 62 | if (err == error.FileNotFound) { | 59 | if (err == error.FileNotFound) { |
| 63 | try dest_dir.deleteFile(io, entry.path); | 60 | try dest_dir.deleteFile(io, entry.path); |
tools/update_glibc.zig+8-11| ... | @@ -66,7 +66,7 @@ pub fn main() !void { | ... | @@ -66,7 +66,7 @@ pub fn main() !void { |
| 66 | var walker = try dest_dir.walk(arena); | 66 | var walker = try dest_dir.walk(arena); |
| 67 | defer walker.deinit(); | 67 | defer walker.deinit(); |
| 68 | 68 | ||
| 69 | walk: while (try walker.next()) |entry| { | 69 | walk: while (try walker.next(io)) |entry| { |
| 70 | if (entry.kind != .file) continue; | 70 | if (entry.kind != .file) continue; |
| 71 | if (mem.startsWith(u8, entry.basename, ".")) continue; | 71 | if (mem.startsWith(u8, entry.basename, ".")) continue; |
| 72 | for (exempt_files) |p| { | 72 | for (exempt_files) |p| { |
| ... | @@ -76,7 +76,7 @@ pub fn main() !void { | ... | @@ -76,7 +76,7 @@ pub fn main() !void { |
| 76 | if (mem.endsWith(u8, entry.path, ext)) continue :walk; | 76 | if (mem.endsWith(u8, entry.path, ext)) continue :walk; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 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| { |
| 80 | log.warn("unable to copy '{s}/{s}' to '{s}/{s}': {t}", .{ | 80 | log.warn("unable to copy '{s}/{s}' to '{s}/{s}': {t}", .{ |
| 81 | glibc_src_path, entry.path, dest_dir_path, entry.path, err, | 81 | glibc_src_path, entry.path, dest_dir_path, entry.path, err, |
| 82 | }); | 82 | }); |
| ... | @@ -106,7 +106,7 @@ pub fn main() !void { | ... | @@ -106,7 +106,7 @@ pub fn main() !void { |
| 106 | var walker = try include_dir.walk(arena); | 106 | var walker = try include_dir.walk(arena); |
| 107 | defer walker.deinit(); | 107 | defer walker.deinit(); |
| 108 | 108 | ||
| 109 | walk: while (try walker.next()) |entry| { | 109 | walk: while (try walker.next(io)) |entry| { |
| 110 | if (entry.kind != .file) continue; | 110 | if (entry.kind != .file) continue; |
| 111 | if (mem.startsWith(u8, entry.basename, ".")) continue; | 111 | if (mem.startsWith(u8, entry.basename, ".")) continue; |
| 112 | for (exempt_files) |p| { | 112 | for (exempt_files) |p| { |
| ... | @@ -116,23 +116,21 @@ pub fn main() !void { | ... | @@ -116,23 +116,21 @@ pub fn main() !void { |
| 116 | const max_file_size = 10 * 1024 * 1024; | 116 | const max_file_size = 10 * 1024 * 1024; |
| 117 | 117 | ||
| 118 | const generic_glibc_contents = generic_glibc_dir.readFileAlloc( | 118 | const generic_glibc_contents = generic_glibc_dir.readFileAlloc( |
| 119 | io, | ||
| 119 | entry.path, | 120 | entry.path, |
| 120 | arena, | 121 | arena, |
| 121 | .limited(max_file_size), | 122 | .limited(max_file_size), |
| 122 | ) catch |err| switch (err) { | 123 | ) catch |err| switch (err) { |
| 123 | error.FileNotFound => continue, | 124 | error.FileNotFound => continue, |
| 124 | else => |e| fatal("unable to load '{s}/include/{s}': {s}", .{ | 125 | else => |e| fatal("unable to load '{s}/include/{s}': {t}", .{ generic_glibc_path, entry.path, e }), |
| 125 | generic_glibc_path, entry.path, @errorName(e), | ||
| 126 | }), | ||
| 127 | }; | 126 | }; |
| 128 | const glibc_include_contents = include_dir.readFileAlloc( | 127 | const glibc_include_contents = include_dir.readFileAlloc( |
| 128 | io, | ||
| 129 | entry.path, | 129 | entry.path, |
| 130 | arena, | 130 | arena, |
| 131 | .limited(max_file_size), | 131 | .limited(max_file_size), |
| 132 | ) catch |err| { | 132 | ) catch |err| { |
| 133 | fatal("unable to load '{s}/include/{s}': {s}", .{ | 133 | fatal("unable to load '{s}/include/{s}': {t}", .{ dest_dir_path, entry.path, err }); |
| 134 | dest_dir_path, entry.path, @errorName(err), | ||
| 135 | }); | ||
| 136 | }; | 134 | }; |
| 137 | 135 | ||
| 138 | const whitespace = " \r\n\t"; | 136 | const whitespace = " \r\n\t"; |
| ... | @@ -140,8 +138,7 @@ pub fn main() !void { | ... | @@ -140,8 +138,7 @@ pub fn main() !void { |
| 140 | const glibc_include_trimmed = mem.trim(u8, glibc_include_contents, whitespace); | 138 | const glibc_include_trimmed = mem.trim(u8, glibc_include_contents, whitespace); |
| 141 | if (mem.eql(u8, generic_glibc_trimmed, glibc_include_trimmed)) { | 139 | if (mem.eql(u8, generic_glibc_trimmed, glibc_include_trimmed)) { |
| 142 | log.warn("same contents: '{s}/include/{s}' and '{s}/include/{s}'", .{ | 140 | log.warn("same contents: '{s}/include/{s}' and '{s}/include/{s}'", .{ |
| 143 | generic_glibc_path, entry.path, | 141 | generic_glibc_path, entry.path, dest_dir_path, entry.path, |
| 144 | dest_dir_path, entry.path, | ||
| 145 | }); | 142 | }); |
| 146 | } | 143 | } |
| 147 | } | 144 | } |
tools/update_mingw.zig+12-12| ... | @@ -26,13 +26,13 @@ pub fn main() !void { | ... | @@ -26,13 +26,13 @@ pub fn main() !void { |
| 26 | // in zig's installation. | 26 | // in zig's installation. |
| 27 | 27 | ||
| 28 | var dest_crt_dir = Dir.cwd().openDir(io, dest_mingw_crt_path, .{ .iterate = true }) catch |err| { | 28 | 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 }); |
| 30 | std.process.exit(1); | 30 | std.process.exit(1); |
| 31 | }; | 31 | }; |
| 32 | defer dest_crt_dir.close(io); | 32 | defer dest_crt_dir.close(io); |
| 33 | 33 | ||
| 34 | var src_crt_dir = Dir.cwd().openDir(io, src_mingw_crt_path, .{ .iterate = true }) catch |err| { | 34 | 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 }); |
| 36 | std.process.exit(1); | 36 | std.process.exit(1); |
| 37 | }; | 37 | }; |
| 38 | defer src_crt_dir.close(io); | 38 | defer src_crt_dir.close(io); |
| ... | @@ -43,10 +43,10 @@ pub fn main() !void { | ... | @@ -43,10 +43,10 @@ pub fn main() !void { |
| 43 | 43 | ||
| 44 | var fail = false; | 44 | var fail = false; |
| 45 | 45 | ||
| 46 | while (try walker.next()) |entry| { | 46 | while (try walker.next(io)) |entry| { |
| 47 | if (entry.kind != .file) continue; | 47 | if (entry.kind != .file) continue; |
| 48 | 48 | ||
| 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) { |
| 50 | error.FileNotFound => { | 50 | error.FileNotFound => { |
| 51 | const keep = for (kept_crt_files) |item| { | 51 | const keep = for (kept_crt_files) |item| { |
| 52 | if (std.mem.eql(u8, entry.path, item)) break true; | 52 | if (std.mem.eql(u8, entry.path, item)) break true; |
| ... | @@ -94,10 +94,10 @@ pub fn main() !void { | ... | @@ -94,10 +94,10 @@ pub fn main() !void { |
| 94 | 94 | ||
| 95 | var fail = false; | 95 | var fail = false; |
| 96 | 96 | ||
| 97 | while (try walker.next()) |entry| { | 97 | while (try walker.next(io)) |entry| { |
| 98 | if (entry.kind != .file) continue; | 98 | if (entry.kind != .file) continue; |
| 99 | 99 | ||
| 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) { |
| 101 | error.FileNotFound => { | 101 | error.FileNotFound => { |
| 102 | std.log.warn("deleting {s}", .{entry.path}); | 102 | std.log.warn("deleting {s}", .{entry.path}); |
| 103 | try dest_winpthreads_dir.deleteFile(io, entry.path); | 103 | try dest_winpthreads_dir.deleteFile(io, entry.path); |
| ... | @@ -120,17 +120,17 @@ pub fn main() !void { | ... | @@ -120,17 +120,17 @@ pub fn main() !void { |
| 120 | 120 | ||
| 121 | var fail = false; | 121 | var fail = false; |
| 122 | 122 | ||
| 123 | while (try walker.next()) |entry| { | 123 | while (try walker.next(io)) |entry| { |
| 124 | switch (entry.kind) { | 124 | switch (entry.kind) { |
| 125 | .directory => { | 125 | .directory => { |
| 126 | switch (entry.depth()) { | 126 | switch (entry.depth()) { |
| 127 | 1 => if (def_dirs.has(entry.basename)) { | 127 | 1 => if (def_dirs.has(entry.basename)) { |
| 128 | try walker.enter(entry); | 128 | try walker.enter(io, entry); |
| 129 | continue; | 129 | continue; |
| 130 | }, | 130 | }, |
| 131 | else => { | 131 | else => { |
| 132 | // The top-level directory was already validated | 132 | // The top-level directory was already validated |
| 133 | try walker.enter(entry); | 133 | try walker.enter(io, entry); |
| 134 | continue; | 134 | continue; |
| 135 | }, | 135 | }, |
| 136 | } | 136 | } |
| ... | @@ -157,15 +157,15 @@ pub fn main() !void { | ... | @@ -157,15 +157,15 @@ pub fn main() !void { |
| 157 | if (std.mem.endsWith(u8, entry.basename, "_onecore.def")) | 157 | if (std.mem.endsWith(u8, entry.basename, "_onecore.def")) |
| 158 | continue; | 158 | continue; |
| 159 | 159 | ||
| 160 | src_crt_dir.copyFile(entry.path, dest_crt_dir, entry.path, .{}) catch |err| { | 160 | src_crt_dir.copyFile(entry.path, dest_crt_dir, entry.path, io, .{}) catch |err| { |
| 161 | std.log.err("unable to copy {s}: {s}", .{ entry.path, @errorName(err) }); | 161 | std.log.err("unable to copy {s}: {t}", .{ entry.path, err }); |
| 162 | fail = true; | 162 | fail = true; |
| 163 | }; | 163 | }; |
| 164 | } | 164 | } |
| 165 | if (fail) std.process.exit(1); | 165 | if (fail) std.process.exit(1); |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | return std.process.cleanExit(); | 168 | return std.process.cleanExit(io); |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | const kept_crt_files = [_][]const u8{ | 171 | const kept_crt_files = [_][]const u8{ |
tools/update_netbsd_libc.zig+4-4| ... | @@ -27,13 +27,13 @@ pub fn main() !void { | ... | @@ -27,13 +27,13 @@ pub fn main() !void { |
| 27 | 27 | ||
| 28 | const dest_dir_path = try std.fmt.allocPrint(arena, "{s}/lib/libc/netbsd", .{zig_src_path}); | 28 | const dest_dir_path = try std.fmt.allocPrint(arena, "{s}/lib/libc/netbsd", .{zig_src_path}); |
| 29 | 29 | ||
| 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| { |
| 31 | std.log.err("unable to open destination directory '{s}': {t}", .{ dest_dir_path, err }); | 31 | std.log.err("unable to open destination directory '{s}': {t}", .{ dest_dir_path, err }); |
| 32 | std.process.exit(1); | 32 | std.process.exit(1); |
| 33 | }; | 33 | }; |
| 34 | defer dest_dir.close(io); | 34 | defer dest_dir.close(io); |
| 35 | 35 | ||
| 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, .{}); |
| 37 | defer netbsd_src_dir.close(io); | 37 | defer netbsd_src_dir.close(io); |
| 38 | 38 | ||
| 39 | // Copy updated files from upstream. | 39 | // Copy updated files from upstream. |
| ... | @@ -41,7 +41,7 @@ pub fn main() !void { | ... | @@ -41,7 +41,7 @@ pub fn main() !void { |
| 41 | var walker = try dest_dir.walk(arena); | 41 | var walker = try dest_dir.walk(arena); |
| 42 | defer walker.deinit(); | 42 | defer walker.deinit(); |
| 43 | 43 | ||
| 44 | walk: while (try walker.next()) |entry| { | 44 | walk: while (try walker.next(io)) |entry| { |
| 45 | if (entry.kind != .file) continue; | 45 | if (entry.kind != .file) continue; |
| 46 | if (std.mem.startsWith(u8, entry.basename, ".")) continue; | 46 | if (std.mem.startsWith(u8, entry.basename, ".")) continue; |
| 47 | for (exempt_files) |p| { | 47 | for (exempt_files) |p| { |
| ... | @@ -53,7 +53,7 @@ pub fn main() !void { | ... | @@ -53,7 +53,7 @@ pub fn main() !void { |
| 53 | netbsd_src_path, entry.path, | 53 | netbsd_src_path, entry.path, |
| 54 | }); | 54 | }); |
| 55 | 55 | ||
| 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| { |
| 57 | std.log.warn("unable to copy '{s}/{s}' to '{s}/{s}': {t}", .{ | 57 | std.log.warn("unable to copy '{s}/{s}' to '{s}/{s}': {t}", .{ |
| 58 | netbsd_src_path, entry.path, dest_dir_path, entry.path, err, | 58 | netbsd_src_path, entry.path, dest_dir_path, entry.path, err, |
| 59 | }); | 59 | }); |