authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-29 20:49:18-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-30 00:48:50-07:00
log9adcc31ca3dafa4799984ceb3409a85501417288
tree7ba7345c6a1d92d7e1eef2197c8759afac2c8e87
parentfadd268a609aefa155bbe5c7fe9d7c07956e9cda

update tools and other miscellaneous things to new APIs


20 files changed, 55 insertions(+), 53 deletions(-)

lib/compiler/resinator/main.zig+7-3
...@@ -164,13 +164,14 @@ pub fn main() !void {...@@ -164,13 +164,14 @@ pub fn main() !void {
164 } else {164 } else {
165 switch (options.input_source) {165 switch (options.input_source) {
166 .stdio => |file| {166 .stdio => |file| {
167 break :full_input file.readToEndAlloc(allocator, std.math.maxInt(usize)) catch |err| {167 var file_reader = file.reader(&.{});
168 break :full_input file_reader.interface.allocRemaining(allocator, .unlimited) catch |err| {
168 try error_handler.emitMessage(allocator, .err, "unable to read input from stdin: {s}", .{@errorName(err)});169 try error_handler.emitMessage(allocator, .err, "unable to read input from stdin: {s}", .{@errorName(err)});
169 std.process.exit(1);170 std.process.exit(1);
170 };171 };
171 },172 },
172 .filename => |input_filename| {173 .filename => |input_filename| {
173 break :full_input std.fs.cwd().readFileAlloc(allocator, input_filename, std.math.maxInt(usize)) catch |err| {174 break :full_input std.fs.cwd().readFileAlloc(input_filename, allocator, .unlimited) catch |err| {
174 try error_handler.emitMessage(allocator, .err, "unable to read input file path '{s}': {s}", .{ input_filename, @errorName(err) });175 try error_handler.emitMessage(allocator, .err, "unable to read input file path '{s}': {s}", .{ input_filename, @errorName(err) });
175 std.process.exit(1);176 std.process.exit(1);
176 };177 };
...@@ -462,7 +463,10 @@ const IoStream = struct {...@@ -462,7 +463,10 @@ const IoStream = struct {
462 pub fn readAll(self: Source, allocator: std.mem.Allocator) !Data {463 pub fn readAll(self: Source, allocator: std.mem.Allocator) !Data {
463 return switch (self) {464 return switch (self) {
464 inline .file, .stdio => |file| .{465 inline .file, .stdio => |file| .{
465 .bytes = try file.readToEndAlloc(allocator, std.math.maxInt(usize)),466 .bytes = b: {
467 var file_reader = file.reader(&.{});
468 break :b try file_reader.interface.allocRemaining(allocator, .unlimited);
469 },
466 .needs_free = true,470 .needs_free = true,
467 },471 },
468 .memory => |list| .{ .bytes = list.items, .needs_free = false },472 .memory => |list| .{ .bytes = list.items, .needs_free = false },
test/src/check-stack-trace.zig+1-1
...@@ -13,7 +13,7 @@ pub fn main() !void {...@@ -13,7 +13,7 @@ pub fn main() !void {
13 const input_path = args[1];13 const input_path = args[1];
14 const optimize_mode_text = args[2];14 const optimize_mode_text = args[2];
1515
16 const input_bytes = try std.fs.cwd().readFileAlloc(arena, input_path, 5 * 1024 * 1024);16 const input_bytes = try std.fs.cwd().readFileAlloc(input_path, arena, .limited(5 * 1024 * 1024));
17 const optimize_mode = std.meta.stringToEnum(std.builtin.OptimizeMode, optimize_mode_text).?;17 const optimize_mode = std.meta.stringToEnum(std.builtin.OptimizeMode, optimize_mode_text).?;
1818
19 var stderr = input_bytes;19 var stderr = input_bytes;
test/standalone/child_process/main.zig+2-1
...@@ -32,7 +32,8 @@ pub fn main() !void {...@@ -32,7 +32,8 @@ pub fn main() !void {
3232
33 const hello_stdout = "hello from stdout";33 const hello_stdout = "hello from stdout";
34 var buf: [hello_stdout.len]u8 = undefined;34 var buf: [hello_stdout.len]u8 = undefined;
35 const n = try child.stdout.?.deprecatedReader().readAll(&buf);35 var stdout_reader = child.stdout.?.reader(&.{});
36 const n = try stdout_reader.interface.readSliceShort(&buf);
36 if (!std.mem.eql(u8, buf[0..n], hello_stdout)) {37 if (!std.mem.eql(u8, buf[0..n], hello_stdout)) {
37 testError("child stdout: '{s}'; want '{s}'", .{ buf[0..n], hello_stdout });38 testError("child stdout: '{s}'; want '{s}'", .{ buf[0..n], hello_stdout });
38 }39 }
test/standalone/cmakedefine/check.zig+2-2
...@@ -9,8 +9,8 @@ pub fn main() !void {...@@ -9,8 +9,8 @@ pub fn main() !void {
9 const actual_path = args[1];9 const actual_path = args[1];
10 const expected_path = args[2];10 const expected_path = args[2];
1111
12 const actual = try std.fs.cwd().readFileAlloc(arena, actual_path, 1024 * 1024);12 const actual = try std.fs.cwd().readFileAlloc(actual_path, arena, .limited(1024 * 1024));
13 const expected = try std.fs.cwd().readFileAlloc(arena, expected_path, 1024 * 1024);13 const expected = try std.fs.cwd().readFileAlloc(expected_path, arena, .limited(1024 * 1024));
1414
15 // The actual output starts with a comment which we should strip out before comparing.15 // The actual output starts with a comment which we should strip out before comparing.
16 const comment_str = "/* This file was generated by ConfigHeader using the Zig Build System. */\n";16 const comment_str = "/* This file was generated by ConfigHeader using the Zig Build System. */\n";
test/standalone/entry_point/check_differ.zig+2-2
...@@ -6,8 +6,8 @@ pub fn main() !void {...@@ -6,8 +6,8 @@ pub fn main() !void {
6 const args = try std.process.argsAlloc(arena);6 const args = try std.process.argsAlloc(arena);
7 if (args.len != 3) return error.BadUsage; // usage: 'check_differ <path a> <path b>'7 if (args.len != 3) return error.BadUsage; // usage: 'check_differ <path a> <path b>'
88
9 const contents_1 = try std.fs.cwd().readFileAlloc(arena, args[1], 1024 * 1024 * 64); // 64 MiB ought to be plenty9 const contents_1 = try std.fs.cwd().readFileAlloc(args[1], arena, .limited(1024 * 1024 * 64)); // 64 MiB ought to be plenty
10 const contents_2 = try std.fs.cwd().readFileAlloc(arena, args[2], 1024 * 1024 * 64); // 64 MiB ought to be plenty10 const contents_2 = try std.fs.cwd().readFileAlloc(args[2], arena, .limited(1024 * 1024 * 64)); // 64 MiB ought to be plenty
1111
12 if (std.mem.eql(u8, contents_1, contents_2)) {12 if (std.mem.eql(u8, contents_1, contents_2)) {
13 return error.FilesMatch;13 return error.FilesMatch;
tools/docgen.zig+4-5
...@@ -77,7 +77,8 @@ pub fn main() !void {...@@ -77,7 +77,8 @@ pub fn main() !void {
77 var code_dir = try fs.cwd().openDir(code_dir_path, .{});77 var code_dir = try fs.cwd().openDir(code_dir_path, .{});
78 defer code_dir.close();78 defer code_dir.close();
7979
80 const input_file_bytes = try in_file.deprecatedReader().readAllAlloc(arena, max_doc_file_size);80 var in_file_reader = in_file.reader(&.{});
81 const input_file_bytes = try in_file_reader.interface.allocRemaining(arena, .limited(max_doc_file_size));
8182
82 var tokenizer = Tokenizer.init(input_path, input_file_bytes);83 var tokenizer = Tokenizer.init(input_path, input_file_bytes);
83 var toc = try genToc(arena, &tokenizer);84 var toc = try genToc(arena, &tokenizer);
...@@ -1039,10 +1040,8 @@ fn genHtml(...@@ -1039,10 +1040,8 @@ fn genHtml(
1039 });1040 });
1040 defer allocator.free(out_basename);1041 defer allocator.free(out_basename);
10411042
1042 const contents = code_dir.readFileAlloc(allocator, out_basename, std.math.maxInt(u32)) catch |err| {1043 const contents = code_dir.readFileAlloc(out_basename, allocator, .limited(std.math.maxInt(u32))) catch |err| {
1043 return parseError(tokenizer, code.token, "unable to open '{s}': {s}", .{1044 return parseError(tokenizer, code.token, "unable to open '{s}': {t}", .{ out_basename, err });
1044 out_basename, @errorName(err),
1045 });
1046 };1045 };
1047 defer allocator.free(contents);1046 defer allocator.free(contents);
10481047
tools/doctest.zig+1-1
...@@ -70,7 +70,7 @@ pub fn main() !void {...@@ -70,7 +70,7 @@ pub fn main() !void {
70 const zig_path = opt_zig orelse fatal("missing zig compiler path (--zig)", .{});70 const zig_path = opt_zig orelse fatal("missing zig compiler path (--zig)", .{});
71 const cache_root = opt_cache_root orelse fatal("missing cache root path (--cache-root)", .{});71 const cache_root = opt_cache_root orelse fatal("missing cache root path (--cache-root)", .{});
7272
73 const source_bytes = try fs.cwd().readFileAlloc(arena, input_path, std.math.maxInt(u32));73 const source_bytes = try fs.cwd().readFileAlloc(input_path, arena, .limited(std.math.maxInt(u32)));
74 const code = try parseManifest(arena, source_bytes);74 const code = try parseManifest(arena, source_bytes);
75 const source = stripManifest(source_bytes);75 const source = stripManifest(source_bytes);
7676
tools/dump-cov.zig+2-3
...@@ -38,10 +38,9 @@ pub fn main() !void {...@@ -38,10 +38,9 @@ pub fn main() !void {
38 defer debug_info.deinit(gpa);38 defer debug_info.deinit(gpa);
3939
40 const cov_bytes = cov_path.root_dir.handle.readFileAllocOptions(40 const cov_bytes = cov_path.root_dir.handle.readFileAllocOptions(
41 arena,
42 cov_path.sub_path,41 cov_path.sub_path,
43 1 << 30,42 arena,
44 null,43 .limited(1 << 30),
45 .of(SeenPcsHeader),44 .of(SeenPcsHeader),
46 null,45 null,
47 ) catch |err| {46 ) catch |err| {
tools/fetch_them_macos_headers.zig+3-3
...@@ -1,6 +1,5 @@...@@ -1,6 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const fs = std.fs;2const fs = std.fs;
3const io = std.io;
4const mem = std.mem;3const mem = std.mem;
5const process = std.process;4const process = std.process;
6const assert = std.debug.assert;5const assert = std.debug.assert;
...@@ -93,7 +92,7 @@ pub fn main() anyerror!void {...@@ -93,7 +92,7 @@ pub fn main() anyerror!void {
9392
94 var sdk_dir = try std.fs.cwd().openDir(sysroot_path, .{});93 var sdk_dir = try std.fs.cwd().openDir(sysroot_path, .{});
95 defer sdk_dir.close();94 defer sdk_dir.close();
96 const sdk_info = try sdk_dir.readFileAlloc(allocator, "SDKSettings.json", std.math.maxInt(u32));95 const sdk_info = try sdk_dir.readFileAlloc("SDKSettings.json", allocator, .limited(std.math.maxInt(u32)));
9796
98 const parsed_json = try std.json.parseFromSlice(struct {97 const parsed_json = try std.json.parseFromSlice(struct {
99 DefaultProperties: struct { MACOSX_DEPLOYMENT_TARGET: []const u8 },98 DefaultProperties: struct { MACOSX_DEPLOYMENT_TARGET: []const u8 },
...@@ -198,7 +197,8 @@ fn fetchTarget(...@@ -198,7 +197,8 @@ fn fetchTarget(
198 var dirs = std.StringHashMap(fs.Dir).init(arena);197 var dirs = std.StringHashMap(fs.Dir).init(arena);
199 try dirs.putNoClobber(".", dest_dir);198 try dirs.putNoClobber(".", dest_dir);
200199
201 const headers_list_str = try headers_list_file.deprecatedReader().readAllAlloc(arena, std.math.maxInt(usize));200 var headers_list_file_reader = headers_list_file.reader(&.{});
201 const headers_list_str = try headers_list_file_reader.interface.allocRemaining(arena, .unlimited);
202 const prefix = "/usr/include";202 const prefix = "/usr/include";
203203
204 var it = mem.splitScalar(u8, headers_list_str, '\n');204 var it = mem.splitScalar(u8, headers_list_str, '\n');
tools/gen_spirv_spec.zig+15-15
...@@ -136,7 +136,7 @@ fn readExtRegistry(exts: *std.array_list.Managed(Extension), dir: std.fs.Dir, su...@@ -136,7 +136,7 @@ fn readExtRegistry(exts: *std.array_list.Managed(Extension), dir: std.fs.Dir, su
136}136}
137137
138fn readRegistry(comptime RegistryType: type, dir: std.fs.Dir, path: []const u8) !RegistryType {138fn readRegistry(comptime RegistryType: type, dir: std.fs.Dir, path: []const u8) !RegistryType {
139 const spec = try dir.readFileAlloc(allocator, path, std.math.maxInt(usize));139 const spec = try dir.readFileAlloc(path, allocator, .unlimited);
140 // Required for json parsing.140 // Required for json parsing.
141 // TODO: ALI141 // TODO: ALI
142 @setEvalBranchQuota(10000);142 @setEvalBranchQuota(10000);
...@@ -189,7 +189,7 @@ fn tagPriorityScore(tag: []const u8) usize {...@@ -189,7 +189,7 @@ fn tagPriorityScore(tag: []const u8) usize {
189}189}
190190
191fn render(191fn render(
192 writer: *std.io.Writer,192 writer: *std.Io.Writer,
193 registry: CoreRegistry,193 registry: CoreRegistry,
194 extensions: []const Extension,194 extensions: []const Extension,
195) !void {195) !void {
...@@ -214,7 +214,7 @@ fn render(...@@ -214,7 +214,7 @@ fn render(
214 \\ none,214 \\ none,
215 \\ _,215 \\ _,
216 \\216 \\
217 \\ pub fn format(self: Id, writer: *std.io.Writer) std.io.Writer.Error!void {217 \\ pub fn format(self: Id, writer: *std.Io.Writer) std.Io.Writer.Error!void {
218 \\ switch (self) {218 \\ switch (self) {
219 \\ .none => try writer.writeAll("(none)"),219 \\ .none => try writer.writeAll("(none)"),
220 \\ else => try writer.print("%{d}", .{@intFromEnum(self)}),220 \\ else => try writer.print("%{d}", .{@intFromEnum(self)}),
...@@ -327,7 +327,7 @@ fn render(...@@ -327,7 +327,7 @@ fn render(
327}327}
328328
329fn renderInstructionSet(329fn renderInstructionSet(
330 writer: *std.io.Writer,330 writer: *std.Io.Writer,
331 core: CoreRegistry,331 core: CoreRegistry,
332 extensions: []const Extension,332 extensions: []const Extension,
333 all_operand_kinds: OperandKindMap,333 all_operand_kinds: OperandKindMap,
...@@ -362,7 +362,7 @@ fn renderInstructionSet(...@@ -362,7 +362,7 @@ fn renderInstructionSet(
362}362}
363363
364fn renderInstructionsCase(364fn renderInstructionsCase(
365 writer: *std.io.Writer,365 writer: *std.Io.Writer,
366 set_name: []const u8,366 set_name: []const u8,
367 instructions: []const Instruction,367 instructions: []const Instruction,
368 all_operand_kinds: OperandKindMap,368 all_operand_kinds: OperandKindMap,
...@@ -409,7 +409,7 @@ fn renderInstructionsCase(...@@ -409,7 +409,7 @@ fn renderInstructionsCase(
409 );409 );
410}410}
411411
412fn renderClass(writer: *std.io.Writer, instructions: []const Instruction) !void {412fn renderClass(writer: *std.Io.Writer, instructions: []const Instruction) !void {
413 var class_map = std.StringArrayHashMap(void).init(allocator);413 var class_map = std.StringArrayHashMap(void).init(allocator);
414414
415 for (instructions) |inst| {415 for (instructions) |inst| {
...@@ -427,7 +427,7 @@ fn renderClass(writer: *std.io.Writer, instructions: []const Instruction) !void...@@ -427,7 +427,7 @@ fn renderClass(writer: *std.io.Writer, instructions: []const Instruction) !void
427const Formatter = struct {427const Formatter = struct {
428 data: []const u8,428 data: []const u8,
429429
430 fn format(f: Formatter, writer: *std.Io.Writer) std.io.Writer.Error!void {430 fn format(f: Formatter, writer: *std.Io.Writer) std.Io.Writer.Error!void {
431 var id_buf: [128]u8 = undefined;431 var id_buf: [128]u8 = undefined;
432 var fw: std.Io.Writer = .fixed(&id_buf);432 var fw: std.Io.Writer = .fixed(&id_buf);
433 for (f.data, 0..) |c, i| {433 for (f.data, 0..) |c, i| {
...@@ -457,7 +457,7 @@ fn formatId(identifier: []const u8) std.fmt.Alt(Formatter, Formatter.format) {...@@ -457,7 +457,7 @@ fn formatId(identifier: []const u8) std.fmt.Alt(Formatter, Formatter.format) {
457 return .{ .data = .{ .data = identifier } };457 return .{ .data = .{ .data = identifier } };
458}458}
459459
460fn renderOperandKind(writer: *std.io.Writer, operands: []const OperandKind) !void {460fn renderOperandKind(writer: *std.Io.Writer, operands: []const OperandKind) !void {
461 try writer.writeAll(461 try writer.writeAll(
462 \\pub const OperandKind = enum {462 \\pub const OperandKind = enum {
463 \\ opcode,463 \\ opcode,
...@@ -513,7 +513,7 @@ fn renderOperandKind(writer: *std.io.Writer, operands: []const OperandKind) !voi...@@ -513,7 +513,7 @@ fn renderOperandKind(writer: *std.io.Writer, operands: []const OperandKind) !voi
513 try writer.writeAll("};\n}\n};\n");513 try writer.writeAll("};\n}\n};\n");
514}514}
515515
516fn renderEnumerant(writer: *std.io.Writer, enumerant: Enumerant) !void {516fn renderEnumerant(writer: *std.Io.Writer, enumerant: Enumerant) !void {
517 try writer.print(".{{.name = \"{s}\", .value = ", .{enumerant.enumerant});517 try writer.print(".{{.name = \"{s}\", .value = ", .{enumerant.enumerant});
518 switch (enumerant.value) {518 switch (enumerant.value) {
519 .bitflag => |flag| try writer.writeAll(flag),519 .bitflag => |flag| try writer.writeAll(flag),
...@@ -530,7 +530,7 @@ fn renderEnumerant(writer: *std.io.Writer, enumerant: Enumerant) !void {...@@ -530,7 +530,7 @@ fn renderEnumerant(writer: *std.io.Writer, enumerant: Enumerant) !void {
530}530}
531531
532fn renderOpcodes(532fn renderOpcodes(
533 writer: *std.io.Writer,533 writer: *std.Io.Writer,
534 opcode_type_name: []const u8,534 opcode_type_name: []const u8,
535 want_operands: bool,535 want_operands: bool,
536 instructions: []const Instruction,536 instructions: []const Instruction,
...@@ -629,7 +629,7 @@ fn renderOpcodes(...@@ -629,7 +629,7 @@ fn renderOpcodes(
629}629}
630630
631fn renderOperandKinds(631fn renderOperandKinds(
632 writer: *std.io.Writer,632 writer: *std.Io.Writer,
633 kinds: []const OperandKind,633 kinds: []const OperandKind,
634 extended_structs: ExtendedStructSet,634 extended_structs: ExtendedStructSet,
635) !void {635) !void {
...@@ -643,7 +643,7 @@ fn renderOperandKinds(...@@ -643,7 +643,7 @@ fn renderOperandKinds(
643}643}
644644
645fn renderValueEnum(645fn renderValueEnum(
646 writer: *std.io.Writer,646 writer: *std.Io.Writer,
647 enumeration: OperandKind,647 enumeration: OperandKind,
648 extended_structs: ExtendedStructSet,648 extended_structs: ExtendedStructSet,
649) !void {649) !void {
...@@ -721,7 +721,7 @@ fn renderValueEnum(...@@ -721,7 +721,7 @@ fn renderValueEnum(
721}721}
722722
723fn renderBitEnum(723fn renderBitEnum(
724 writer: *std.io.Writer,724 writer: *std.Io.Writer,
725 enumeration: OperandKind,725 enumeration: OperandKind,
726 extended_structs: ExtendedStructSet,726 extended_structs: ExtendedStructSet,
727) !void {727) !void {
...@@ -804,7 +804,7 @@ fn renderBitEnum(...@@ -804,7 +804,7 @@ fn renderBitEnum(
804}804}
805805
806fn renderOperand(806fn renderOperand(
807 writer: *std.io.Writer,807 writer: *std.Io.Writer,
808 kind: enum {808 kind: enum {
809 @"union",809 @"union",
810 instruction,810 instruction,
...@@ -888,7 +888,7 @@ fn renderOperand(...@@ -888,7 +888,7 @@ fn renderOperand(
888 try writer.writeAll(",\n");888 try writer.writeAll(",\n");
889}889}
890890
891fn renderFieldName(writer: *std.io.Writer, operands: []const Operand, field_index: usize) !void {891fn renderFieldName(writer: *std.Io.Writer, operands: []const Operand, field_index: usize) !void {
892 const operand = operands[field_index];892 const operand = operands[field_index];
893893
894 derive_from_kind: {894 derive_from_kind: {
tools/gen_stubs.zig+2-3
...@@ -299,10 +299,9 @@ pub fn main() !void {...@@ -299,10 +299,9 @@ pub fn main() !void {
299299
300 // Read the ELF header.300 // Read the ELF header.
301 const elf_bytes = build_all_dir.readFileAllocOptions(301 const elf_bytes = build_all_dir.readFileAllocOptions(
302 arena,
303 libc_so_path,302 libc_so_path,
304 100 * 1024 * 1024,303 arena,
305 1 * 1024 * 1024,304 .limited(100 * 1024 * 1024),
306 .of(elf.Elf64_Ehdr),305 .of(elf.Elf64_Ehdr),
307 null,306 null,
308 ) catch |err| {307 ) catch |err| {
tools/generate_JSONTestSuite.zig+1-1
...@@ -32,7 +32,7 @@ pub fn main() !void {...@@ -32,7 +32,7 @@ pub fn main() !void {
32 }).lessThan);32 }).lessThan);
3333
34 for (names.items) |name| {34 for (names.items) |name| {
35 const contents = try std.fs.cwd().readFileAlloc(allocator, name, 250001);35 const contents = try std.fs.cwd().readFileAlloc(name, allocator, .limited(250001));
36 try output.writeAll("test ");36 try output.writeAll("test ");
37 try writeString(output, name);37 try writeString(output, name);
38 try output.writeAll(" {\n try ");38 try output.writeAll(" {\n try ");
tools/generate_linux_syscalls.zig+1-1
...@@ -248,7 +248,7 @@ pub fn main() !void {...@@ -248,7 +248,7 @@ pub fn main() !void {
248 try Io.Writer.flush(stdout);248 try Io.Writer.flush(stdout);
249}249}
250250
251fn usage(w: *std.io.Writer, arg0: []const u8) std.io.Writer.Error!void {251fn usage(w: *std.Io.Writer, arg0: []const u8) std.Io.Writer.Error!void {
252 try w.print(252 try w.print(
253 \\Usage: {s} /path/to/zig /path/to/linux253 \\Usage: {s} /path/to/zig /path/to/linux
254 \\Alternative Usage: zig run /path/to/git/zig/tools/generate_linux_syscalls.zig -- /path/to/zig /path/to/linux254 \\Alternative Usage: zig run /path/to/git/zig/tools/generate_linux_syscalls.zig -- /path/to/zig /path/to/linux
tools/incr-check.zig+2-2
...@@ -52,7 +52,7 @@ pub fn main() !void {...@@ -52,7 +52,7 @@ pub fn main() !void {
52 const zig_exe = opt_zig_exe orelse fatal("missing path to zig\n{s}", .{usage});52 const zig_exe = opt_zig_exe orelse fatal("missing path to zig\n{s}", .{usage});
53 const input_file_name = opt_input_file_name orelse fatal("missing input file\n{s}", .{usage});53 const input_file_name = opt_input_file_name orelse fatal("missing input file\n{s}", .{usage});
5454
55 const input_file_bytes = try std.fs.cwd().readFileAlloc(arena, input_file_name, std.math.maxInt(u32));55 const input_file_bytes = try std.fs.cwd().readFileAlloc(input_file_name, arena, .limited(std.math.maxInt(u32)));
56 const case = try Case.parse(arena, input_file_bytes);56 const case = try Case.parse(arena, input_file_bytes);
5757
58 // Check now: if there are any targets using the `cbe` backend, we need the lib dir.58 // Check now: if there are any targets using the `cbe` backend, we need the lib dir.
...@@ -226,7 +226,7 @@ const Eval = struct {...@@ -226,7 +226,7 @@ const Eval = struct {
226 cc_child_args: *std.ArrayListUnmanaged([]const u8),226 cc_child_args: *std.ArrayListUnmanaged([]const u8),
227227
228 const StreamEnum = enum { stdout, stderr };228 const StreamEnum = enum { stdout, stderr };
229 const Poller = std.io.Poller(StreamEnum);229 const Poller = std.Io.Poller(StreamEnum);
230230
231 /// Currently this function assumes the previous updates have already been written.231 /// Currently this function assumes the previous updates have already been written.
232 fn write(eval: *Eval, update: Case.Update) void {232 fn write(eval: *Eval, update: Case.Update) void {
tools/migrate_langref.zig+2-2
...@@ -1,6 +1,5 @@...@@ -1,6 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const io = std.io;
4const fs = std.fs;3const fs = std.fs;
5const print = std.debug.print;4const print = std.debug.print;
6const mem = std.mem;5const mem = std.mem;
...@@ -29,7 +28,8 @@ pub fn main() !void {...@@ -29,7 +28,8 @@ pub fn main() !void {
29 var out_dir = try fs.cwd().openDir(fs.path.dirname(output_file).?, .{});28 var out_dir = try fs.cwd().openDir(fs.path.dirname(output_file).?, .{});
30 defer out_dir.close();29 defer out_dir.close();
3130
32 const input_file_bytes = try in_file.deprecatedReader().readAllAlloc(arena, std.math.maxInt(u32));31 var in_file_reader = in_file.reader(&.{});
32 const input_file_bytes = try in_file_reader.interface.allocRemaining(arena, .unlimited);
3333
34 var tokenizer = Tokenizer.init(input_file, input_file_bytes);34 var tokenizer = Tokenizer.init(input_file, input_file_bytes);
3535
tools/process_headers.zig+1-1
...@@ -254,7 +254,7 @@ pub fn main() !void {...@@ -254,7 +254,7 @@ pub fn main() !void {
254 .file, .sym_link => {254 .file, .sym_link => {
255 const rel_path = try std.fs.path.relative(allocator, target_include_dir, full_path);255 const rel_path = try std.fs.path.relative(allocator, target_include_dir, full_path);
256 const max_size = 2 * 1024 * 1024 * 1024;256 const max_size = 2 * 1024 * 1024 * 1024;
257 const raw_bytes = try std.fs.cwd().readFileAlloc(allocator, full_path, max_size);257 const raw_bytes = try std.fs.cwd().readFileAlloc(full_path, allocator, .limited(max_size));
258 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");258 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");
259 total_bytes += raw_bytes.len;259 total_bytes += raw_bytes.len;
260 const hash = try allocator.alloc(u8, 32);260 const hash = try allocator.alloc(u8, 32);
tools/update-linux-headers.zig+1-1
...@@ -206,7 +206,7 @@ pub fn main() !void {...@@ -206,7 +206,7 @@ pub fn main() !void {
206 .file => {206 .file => {
207 const rel_path = try std.fs.path.relative(arena, target_include_dir, full_path);207 const rel_path = try std.fs.path.relative(arena, target_include_dir, full_path);
208 const max_size = 2 * 1024 * 1024 * 1024;208 const max_size = 2 * 1024 * 1024 * 1024;
209 const raw_bytes = try std.fs.cwd().readFileAlloc(arena, full_path, max_size);209 const raw_bytes = try std.fs.cwd().readFileAlloc(full_path, arena, .limited(max_size));
210 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");210 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");
211 total_bytes += raw_bytes.len;211 total_bytes += raw_bytes.len;
212 const hash = try arena.alloc(u8, 32);212 const hash = try arena.alloc(u8, 32);
tools/update_clang_options.zig+1-1
...@@ -965,7 +965,7 @@ fn printUsageAndExit(arg0: []const u8) noreturn {...@@ -965,7 +965,7 @@ fn printUsageAndExit(arg0: []const u8) noreturn {
965 std.process.exit(1);965 std.process.exit(1);
966}966}
967967
968fn printUsage(w: *std.io.Writer, arg0: []const u8) std.io.Writer.Error!void {968fn printUsage(w: *std.Io.Writer, arg0: []const u8) std.Io.Writer.Error!void {
969 try w.print(969 try w.print(
970 \\Usage: {s} /path/to/llvm-tblgen /path/to/git/llvm/llvm-project970 \\Usage: {s} /path/to/llvm-tblgen /path/to/git/llvm/llvm-project
971 \\Alternative Usage: zig run /path/to/git/zig/tools/update_clang_options.zig -- /path/to/llvm-tblgen /path/to/git/llvm/llvm-project971 \\Alternative Usage: zig run /path/to/git/zig/tools/update_clang_options.zig -- /path/to/llvm-tblgen /path/to/git/llvm/llvm-project
tools/update_crc_catalog.zig+1-1
...@@ -194,7 +194,7 @@ fn printUsageAndExit(arg0: []const u8) noreturn {...@@ -194,7 +194,7 @@ fn printUsageAndExit(arg0: []const u8) noreturn {
194 std.process.exit(1);194 std.process.exit(1);
195}195}
196196
197fn printUsage(w: *std.io.Writer, arg0: []const u8) std.io.Writer.Error!void {197fn printUsage(w: *std.Io.Writer, arg0: []const u8) std.Io.Writer.Error!void {
198 return w.print(198 return w.print(
199 \\Usage: {s} /path/git/zig199 \\Usage: {s} /path/git/zig
200 \\200 \\
tools/update_glibc.zig+4-4
...@@ -116,9 +116,9 @@ pub fn main() !void {...@@ -116,9 +116,9 @@ pub fn main() !void {
116 const max_file_size = 10 * 1024 * 1024;116 const max_file_size = 10 * 1024 * 1024;
117117
118 const generic_glibc_contents = generic_glibc_dir.readFileAlloc(118 const generic_glibc_contents = generic_glibc_dir.readFileAlloc(
119 arena,
120 entry.path,119 entry.path,
121 max_file_size,120 arena,
121 .limited(max_file_size),
122 ) catch |err| switch (err) {122 ) catch |err| switch (err) {
123 error.FileNotFound => continue,123 error.FileNotFound => continue,
124 else => |e| fatal("unable to load '{s}/include/{s}': {s}", .{124 else => |e| fatal("unable to load '{s}/include/{s}': {s}", .{
...@@ -126,9 +126,9 @@ pub fn main() !void {...@@ -126,9 +126,9 @@ pub fn main() !void {
126 }),126 }),
127 };127 };
128 const glibc_include_contents = include_dir.readFileAlloc(128 const glibc_include_contents = include_dir.readFileAlloc(
129 arena,
130 entry.path,129 entry.path,
131 max_file_size,130 arena,
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}': {s}", .{
134 dest_dir_path, entry.path, @errorName(err),134 dest_dir_path, entry.path, @errorName(err),