authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-06 17:23:07-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-23 22:15:07-08:00
log3204fb756980c19b7a95534acdd7a1bba837fbc3
tree45b5525ead2923de83ea85eacca351da64d55c46
parent1b1fb7fab623e40f4ddc24d7b5ef7e48949e8a17

update all occurrences of std.fs.File to std.Io.File


70 files changed, 399 insertions(+), 359 deletions(-)

lib/compiler/aro/aro/Compilation.zig+2-2
......@@ -1646,7 +1646,7 @@ fn addSourceFromPathExtra(comp: *Compilation, path: []const u8, kind: Source.Kin
16461646 return comp.addSourceFromFile(file, path, kind);
16471647}
16481648
1649pub fn addSourceFromFile(comp: *Compilation, file: std.fs.File, path: []const u8, kind: Source.Kind) !Source {
1649pub fn addSourceFromFile(comp: *Compilation, file: Io.File, path: []const u8, kind: Source.Kind) !Source {
16501650 const contents = try comp.getFileContents(file, .unlimited);
16511651 errdefer comp.gpa.free(contents);
16521652 return comp.addSourceFromOwnedBuffer(path, contents, kind);
......@@ -1980,7 +1980,7 @@ fn getPathContents(comp: *Compilation, path: []const u8, limit: Io.Limit) ![]u8
19801980 return comp.getFileContents(file, limit);
19811981}
19821982
1983fn getFileContents(comp: *Compilation, file: std.fs.File, limit: Io.Limit) ![]u8 {
1983fn getFileContents(comp: *Compilation, file: Io.File, limit: Io.Limit) ![]u8 {
19841984 var file_buf: [4096]u8 = undefined;
19851985 var file_reader = file.reader(comp.io, &file_buf);
19861986
lib/compiler/aro/aro/Driver.zig+8-7
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const Io = std.Io;
23const mem = std.mem;
34const Allocator = mem.Allocator;
45const process = std.process;
......@@ -1061,7 +1062,7 @@ pub fn printDiagnosticsStats(d: *Driver) void {
10611062 }
10621063}
10631064
1064pub fn detectConfig(d: *Driver, file: std.fs.File) std.Io.tty.Config {
1065pub fn detectConfig(d: *Driver, file: Io.File) std.Io.tty.Config {
10651066 if (d.diagnostics.color == false) return .no_color;
10661067 const force_color = d.diagnostics.color == true;
10671068
......@@ -1109,7 +1110,7 @@ pub fn main(d: *Driver, tc: *Toolchain, args: []const []const u8, comptime fast_
11091110 defer macro_buf.deinit(d.comp.gpa);
11101111
11111112 var stdout_buf: [256]u8 = undefined;
1112 var stdout = std.fs.File.stdout().writer(&stdout_buf);
1113 var stdout = Io.File.stdout().writer(&stdout_buf);
11131114 if (parseArgs(d, &stdout.interface, &macro_buf, args) catch |er| switch (er) {
11141115 error.WriteFailed => return d.fatal("failed to write to stdout: {s}", .{errorDescription(er)}),
11151116 error.OutOfMemory => return error.OutOfMemory,
......@@ -1329,7 +1330,7 @@ fn processSource(
13291330 d.comp.cwd.createFile(path, .{}) catch |er|
13301331 return d.fatal("unable to create dependency file '{s}': {s}", .{ path, errorDescription(er) })
13311332 else
1332 std.fs.File.stdout();
1333 Io.File.stdout();
13331334 defer if (dep_file_name != null) file.close(io);
13341335
13351336 var file_writer = file.writer(&writer_buf);
......@@ -1354,7 +1355,7 @@ fn processSource(
13541355 d.comp.cwd.createFile(some, .{}) catch |er|
13551356 return d.fatal("unable to create output file '{s}': {s}", .{ some, errorDescription(er) })
13561357 else
1357 std.fs.File.stdout();
1358 Io.File.stdout();
13581359 defer if (d.output_name != null) file.close(io);
13591360
13601361 var file_writer = file.writer(&writer_buf);
......@@ -1369,7 +1370,7 @@ fn processSource(
13691370 defer tree.deinit();
13701371
13711372 if (d.verbose_ast) {
1372 var stdout = std.fs.File.stdout().writer(&writer_buf);
1373 var stdout = Io.File.stdout().writer(&writer_buf);
13731374 tree.dump(d.detectConfig(stdout.file), &stdout.interface) catch {};
13741375 }
13751376
......@@ -1433,7 +1434,7 @@ fn processSource(
14331434 defer ir.deinit(gpa);
14341435
14351436 if (d.verbose_ir) {
1436 var stdout = std.fs.File.stdout().writer(&writer_buf);
1437 var stdout = Io.File.stdout().writer(&writer_buf);
14371438 ir.dump(gpa, d.detectConfig(stdout.file), &stdout.interface) catch {};
14381439 }
14391440
......@@ -1499,7 +1500,7 @@ pub fn invokeLinker(d: *Driver, tc: *Toolchain, comptime fast_exit: bool) Compil
14991500
15001501 if (d.verbose_linker_args) {
15011502 var stdout_buf: [4096]u8 = undefined;
1502 var stdout = std.fs.File.stdout().writer(&stdout_buf);
1503 var stdout = Io.File.stdout().writer(&stdout_buf);
15031504 dumpLinkerArgs(&stdout.interface, argv.items) catch {
15041505 return d.fatal("unable to dump linker args: {s}", .{errorDescription(stdout.err.?)});
15051506 };
lib/compiler/aro/aro/Preprocessor.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const Io = std.Io;
23const mem = std.mem;
34const Allocator = mem.Allocator;
45const assert = std.debug.assert;
......@@ -1068,7 +1069,7 @@ fn verboseLog(pp: *Preprocessor, raw: RawToken, comptime fmt: []const u8, args:
10681069 const line_col = source.lineCol(.{ .id = raw.source, .line = raw.line, .byte_offset = raw.start });
10691070
10701071 var stderr_buf: [4096]u8 = undefined;
1071 var stderr = std.fs.File.stderr().writer(&stderr_buf);
1072 var stderr = Io.File.stderr().writer(&stderr_buf);
10721073 const w = &stderr.interface;
10731074
10741075 w.print("{s}:{d}:{d}: ", .{ source.path, line_col.line_no, line_col.col }) catch return;
lib/compiler/aro/backend/Assembly.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const Io = std.Io;
23const Allocator = std.mem.Allocator;
34
45data: []const u8,
......@@ -11,7 +12,7 @@ pub fn deinit(self: *const Assembly, gpa: Allocator) void {
1112 gpa.free(self.text);
1213}
1314
14pub fn writeToFile(self: Assembly, file: std.fs.File) !void {
15pub fn writeToFile(self: Assembly, file: Io.File) !void {
1516 var file_writer = file.writer(&.{});
1617
1718 var buffers = [_][]const u8{ self.data, self.text };
lib/compiler/aro/main.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const Io = std.Io;
23const Allocator = mem.Allocator;
34const mem = std.mem;
45const process = std.process;
......@@ -50,7 +51,7 @@ pub fn main() u8 {
5051 defer gpa.free(aro_name);
5152
5253 var stderr_buf: [1024]u8 = undefined;
53 var stderr = std.fs.File.stderr().writer(&stderr_buf);
54 var stderr = Io.File.stderr().writer(&stderr_buf);
5455 var diagnostics: Diagnostics = .{
5556 .output = .{ .to_writer = .{
5657 .color = .detect(stderr.file),
lib/compiler/build_runner.zig+3-3
......@@ -7,7 +7,7 @@ const assert = std.debug.assert;
77const fmt = std.fmt;
88const mem = std.mem;
99const process = std.process;
10const File = std.fs.File;
10const File = std.Io.File;
1111const Step = std.Build.Step;
1212const Watch = std.Build.Watch;
1313const WebServer = std.Build.WebServer;
......@@ -1845,9 +1845,9 @@ fn createModuleDependenciesForStep(step: *Step) Allocator.Error!void {
18451845}
18461846
18471847var stdio_buffer_allocation: [256]u8 = undefined;
1848var stdout_writer_allocation: std.fs.File.Writer = undefined;
1848var stdout_writer_allocation: Io.File.Writer = undefined;
18491849
18501850fn initStdoutWriter() *Writer {
1851 stdout_writer_allocation = std.fs.File.stdout().writerStreaming(&stdio_buffer_allocation);
1851 stdout_writer_allocation = Io.File.stdout().writerStreaming(&stdio_buffer_allocation);
18521852 return &stdout_writer_allocation.interface;
18531853}
lib/compiler/libc.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const Io = std.Io;
23const mem = std.mem;
34const LibCInstallation = std.zig.LibCInstallation;
45
......@@ -39,7 +40,7 @@ pub fn main() !void {
3940 var input_file: ?[]const u8 = null;
4041 var target_arch_os_abi: []const u8 = "native";
4142 var print_includes: bool = false;
42 var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
43 var stdout_writer = Io.File.stdout().writer(&stdout_buffer);
4344 const stdout = &stdout_writer.interface;
4445 {
4546 var i: usize = 2;
lib/compiler/objcopy.zig+7-6
......@@ -1,12 +1,13 @@
11const builtin = @import("builtin");
2
23const std = @import("std");
4const Io = std.Io;
35const mem = std.mem;
46const fs = std.fs;
57const elf = std.elf;
68const Allocator = std.mem.Allocator;
7const File = std.fs.File;
9const File = std.Io.File;
810const assert = std.debug.assert;
9
1011const fatal = std.process.fatal;
1112const Server = std.zig.Server;
1213
......@@ -56,7 +57,7 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
5657 fatal("unexpected positional argument: '{s}'", .{arg});
5758 }
5859 } else if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {
59 return std.fs.File.stdout().writeAll(usage);
60 return Io.File.stdout().writeAll(usage);
6061 } else if (mem.eql(u8, arg, "-O") or mem.eql(u8, arg, "--output-target")) {
6162 i += 1;
6263 if (i >= args.len) fatal("expected another argument after '{s}'", .{arg});
......@@ -177,7 +178,7 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
177178 }
178179 };
179180
180 const mode = if (out_fmt != .elf or only_keep_debug) fs.File.default_mode else stat.mode;
181 const mode = if (out_fmt != .elf or only_keep_debug) Io.File.default_mode else stat.mode;
181182
182183 var output_file = try fs.cwd().createFile(output, .{ .mode = mode });
183184 defer output_file.close(io);
......@@ -221,8 +222,8 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
221222 try out.end();
222223
223224 if (listen) {
224 var stdin_reader = fs.File.stdin().reader(io, &stdin_buffer);
225 var stdout_writer = fs.File.stdout().writer(&stdout_buffer);
225 var stdin_reader = Io.File.stdin().reader(io, &stdin_buffer);
226 var stdout_writer = Io.File.stdout().writer(&stdout_buffer);
226227 var server = try Server.init(.{
227228 .in = &stdin_reader.interface,
228229 .out = &stdout_writer.interface,
lib/compiler/reduce.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const Io = std.Io;
23const mem = std.mem;
34const Allocator = std.mem.Allocator;
45const assert = std.debug.assert;
......@@ -68,7 +69,7 @@ pub fn main() !void {
6869 const arg = args[i];
6970 if (mem.startsWith(u8, arg, "-")) {
7071 if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {
71 const stdout = std.fs.File.stdout();
72 const stdout = Io.File.stdout();
7273 try stdout.writeAll(usage);
7374 return std.process.cleanExit();
7475 } else if (mem.eql(u8, arg, "--")) {
lib/compiler/resinator/cli.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const Io = std.Io;
23const code_pages = @import("code_pages.zig");
34const SupportedCodePage = code_pages.SupportedCodePage;
45const lang = @import("lang.zig");
......@@ -169,7 +170,7 @@ pub const Options = struct {
169170 coff_options: cvtres.CoffOptions = .{},
170171
171172 pub const IoSource = union(enum) {
172 stdio: std.fs.File,
173 stdio: Io.File,
173174 filename: []const u8,
174175 };
175176 pub const AutoIncludes = enum { any, msvc, gnu, none };
lib/compiler/resinator/errors.zig+4-4
......@@ -169,9 +169,9 @@ pub const ErrorDetails = struct {
169169 filename_string_index: FilenameStringIndex,
170170
171171 pub const FilenameStringIndex = std.meta.Int(.unsigned, 32 - @bitSizeOf(FileOpenErrorEnum));
172 pub const FileOpenErrorEnum = std.meta.FieldEnum(std.fs.File.OpenError || std.fs.File.StatError);
172 pub const FileOpenErrorEnum = std.meta.FieldEnum(Io.File.OpenError || Io.File.StatError);
173173
174 pub fn enumFromError(err: (std.fs.File.OpenError || std.fs.File.StatError)) FileOpenErrorEnum {
174 pub fn enumFromError(err: (Io.File.OpenError || Io.File.StatError)) FileOpenErrorEnum {
175175 return switch (err) {
176176 inline else => |e| @field(ErrorDetails.FileOpenError.FileOpenErrorEnum, @errorName(e)),
177177 };
......@@ -1094,8 +1094,8 @@ const CorrespondingLines = struct {
10941094 last_byte: u8 = 0,
10951095 at_eof: bool = false,
10961096 span: SourceMappings.CorrespondingSpan,
1097 file: std.fs.File,
1098 file_reader: std.fs.File.Reader,
1097 file: Io.File,
1098 file_reader: Io.File.Reader,
10991099 code_page: SupportedCodePage,
11001100
11011101 pub fn init(
lib/compiler/resinator/main.zig+5-5
......@@ -45,7 +45,7 @@ pub fn main() !void {
4545 }
4646
4747 var stdout_buffer: [1024]u8 = undefined;
48 var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
48 var stdout_writer = Io.File.stdout().writer(&stdout_buffer);
4949 const stdout = &stdout_writer.interface;
5050 var error_handler: ErrorHandler = switch (zig_integration) {
5151 true => .{
......@@ -447,8 +447,8 @@ const IoStream = struct {
447447 }
448448
449449 pub const Source = union(enum) {
450 file: std.fs.File,
451 stdio: std.fs.File,
450 file: Io.File,
451 stdio: Io.File,
452452 memory: std.ArrayList(u8),
453453 /// The source has been closed and any usage of the Source in this state is illegal (except deinit).
454454 closed: void,
......@@ -500,10 +500,10 @@ const IoStream = struct {
500500 }
501501
502502 pub const Writer = union(enum) {
503 file: std.fs.File.Writer,
503 file: Io.File.Writer,
504504 allocating: std.Io.Writer.Allocating,
505505
506 pub const Error = Allocator.Error || std.fs.File.WriteError;
506 pub const Error = Allocator.Error || Io.File.WriteError;
507507
508508 pub fn interface(this: *@This()) *std.Io.Writer {
509509 return switch (this.*) {
lib/compiler/resinator/utils.zig+2-2
......@@ -32,8 +32,8 @@ pub fn openFileNotDir(
3232 cwd: std.fs.Dir,
3333 io: Io,
3434 path: []const u8,
35 flags: std.fs.File.OpenFlags,
36) (std.fs.File.OpenError || std.fs.File.StatError)!std.fs.File {
35 flags: Io.File.OpenFlags,
36) (Io.File.OpenError || Io.File.StatError)!Io.File {
3737 const file = try cwd.openFile(io, path, flags);
3838 errdefer file.close(io);
3939 // https://github.com/ziglang/zig/issues/5732
lib/compiler/test_runner.zig+5-5
......@@ -74,8 +74,8 @@ pub fn main() void {
7474
7575fn mainServer() !void {
7676 @disableInstrumentation();
77 var stdin_reader = std.fs.File.stdin().readerStreaming(runner_threaded_io.io(), &stdin_buffer);
78 var stdout_writer = std.fs.File.stdout().writerStreaming(&stdout_buffer);
77 var stdin_reader = Io.File.stdin().readerStreaming(runner_threaded_io.io(), &stdin_buffer);
78 var stdout_writer = Io.File.stdout().writerStreaming(&stdout_buffer);
7979 var server = try std.zig.Server.init(.{
8080 .in = &stdin_reader.interface,
8181 .out = &stdout_writer.interface,
......@@ -228,7 +228,7 @@ fn mainTerminal() void {
228228 .root_name = "Test",
229229 .estimated_total_items = test_fn_list.len,
230230 });
231 const have_tty = std.fs.File.stderr().isTty();
231 const have_tty = Io.File.stderr().isTty();
232232
233233 var leaks: usize = 0;
234234 for (test_fn_list, 0..) |test_fn, i| {
......@@ -318,7 +318,7 @@ pub fn log(
318318/// work-in-progress backends can handle it.
319319pub fn mainSimple() anyerror!void {
320320 @disableInstrumentation();
321 // is the backend capable of calling `std.fs.File.writeAll`?
321 // is the backend capable of calling `Io.File.writeAll`?
322322 const enable_write = switch (builtin.zig_backend) {
323323 .stage2_aarch64, .stage2_riscv64 => true,
324324 else => false,
......@@ -334,7 +334,7 @@ pub fn mainSimple() anyerror!void {
334334 var failed: u64 = 0;
335335
336336 // we don't want to bring in File and Writer if the backend doesn't support it
337 const stdout = if (enable_write) std.fs.File.stdout() else {};
337 const stdout = if (enable_write) Io.File.stdout() else {};
338338
339339 for (builtin.test_functions) |test_fn| {
340340 if (enable_write) {
lib/compiler/translate-c/main.zig+7-6
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const Io = std.Io;
23const assert = std.debug.assert;
34const mem = std.mem;
45const process = std.process;
......@@ -34,7 +35,7 @@ pub fn main() u8 {
3435 }
3536
3637 var stderr_buf: [1024]u8 = undefined;
37 var stderr = std.fs.File.stderr().writer(&stderr_buf);
38 var stderr = Io.File.stderr().writer(&stderr_buf);
3839 var diagnostics: aro.Diagnostics = switch (zig_integration) {
3940 false => .{ .output = .{ .to_writer = .{
4041 .color = .detect(stderr.file),
......@@ -99,7 +100,7 @@ fn serveErrorBundle(arena: std.mem.Allocator, diagnostics: *const aro.Diagnostic
99100 "translation failure",
100101 );
101102 var stdout_buffer: [1024]u8 = undefined;
102 var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
103 var stdout_writer = Io.File.stdout().writer(&stdout_buffer);
103104 var server: std.zig.Server = .{
104105 .out = &stdout_writer.interface,
105106 .in = undefined,
......@@ -129,13 +130,13 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: [][:0]u8, zig_integration
129130 args[i] = arg;
130131 if (mem.eql(u8, arg, "--help")) {
131132 var stdout_buf: [512]u8 = undefined;
132 var stdout = std.fs.File.stdout().writer(&stdout_buf);
133 var stdout = Io.File.stdout().writer(&stdout_buf);
133134 try stdout.interface.print(usage, .{args[0]});
134135 try stdout.interface.flush();
135136 return;
136137 } else if (mem.eql(u8, arg, "--version")) {
137138 var stdout_buf: [512]u8 = undefined;
138 var stdout = std.fs.File.stdout().writer(&stdout_buf);
139 var stdout = Io.File.stdout().writer(&stdout_buf);
139140 // TODO add version
140141 try stdout.interface.writeAll("0.0.0-dev\n");
141142 try stdout.interface.flush();
......@@ -228,7 +229,7 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: [][:0]u8, zig_integration
228229 d.comp.cwd.createFile(path, .{}) catch |er|
229230 return d.fatal("unable to create dependency file '{s}': {s}", .{ path, aro.Driver.errorDescription(er) })
230231 else
231 std.fs.File.stdout();
232 Io.File.stdout();
232233 defer if (dep_file_name != null) file.close(io);
233234
234235 var file_writer = file.writer(&out_buf);
......@@ -246,7 +247,7 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: [][:0]u8, zig_integration
246247
247248 var close_out_file = false;
248249 var out_file_path: []const u8 = "<stdout>";
249 var out_file: std.fs.File = .stdout();
250 var out_file: Io.File = .stdout();
250251 defer if (close_out_file) out_file.close(io);
251252
252253 if (d.output_name) |path| blk: {
lib/std/Build.zig+3-3
......@@ -1,3 +1,4 @@
1const Build = @This();
12const builtin = @import("builtin");
23
34const std = @import("std.zig");
......@@ -9,13 +10,12 @@ const panic = std.debug.panic;
910const assert = debug.assert;
1011const log = std.log;
1112const StringHashMap = std.StringHashMap;
12const Allocator = mem.Allocator;
13const Allocator = std.mem.Allocator;
1314const Target = std.Target;
1415const process = std.process;
1516const EnvMap = std.process.EnvMap;
16const File = fs.File;
17const File = std.Io.File;
1718const Sha256 = std.crypto.hash.sha2.Sha256;
18const Build = @This();
1919const ArrayList = std.ArrayList;
2020
2121pub const Cache = @import("Build/Cache.zig");
lib/std/Build/Step.zig+1-1
......@@ -667,7 +667,7 @@ fn clearZigProcess(s: *Step, gpa: Allocator) void {
667667 }
668668}
669669
670fn sendMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag) !void {
670fn sendMessage(file: Io.File, tag: std.zig.Client.Message.Tag) !void {
671671 const header: std.zig.Client.Message.Header = .{
672672 .tag = tag,
673673 .bytes_len = 0,
lib/std/Build/Step/ObjCopy.zig+1-1
......@@ -3,7 +3,7 @@ const ObjCopy = @This();
33
44const Allocator = std.mem.Allocator;
55const ArenaAllocator = std.heap.ArenaAllocator;
6const File = std.fs.File;
6const File = std.Io.File;
77const InstallDir = std.Build.InstallDir;
88const Step = std.Build.Step;
99const elf = std.elf;
lib/std/Build/Step/Run.zig+11-10
......@@ -1,15 +1,16 @@
1const std = @import("std");
1const Run = @This();
22const builtin = @import("builtin");
3
4const std = @import("std");
5const Io = std.Io;
36const Build = std.Build;
4const Step = Build.Step;
7const Step = std.Build.Step;
58const fs = std.fs;
69const mem = std.mem;
710const process = std.process;
8const EnvMap = process.EnvMap;
11const EnvMap = std.process.EnvMap;
912const assert = std.debug.assert;
10const Path = Build.Cache.Path;
11
12const Run = @This();
13const Path = std.Build.Cache.Path;
1314
1415pub const base_id: Step.Id = .run;
1516
......@@ -2095,7 +2096,7 @@ pub const CachedTestMetadata = struct {
20952096 }
20962097};
20972098
2098fn requestNextTest(in: fs.File, metadata: *TestMetadata, sub_prog_node: *?std.Progress.Node) !void {
2099fn requestNextTest(in: Io.File, metadata: *TestMetadata, sub_prog_node: *?std.Progress.Node) !void {
20992100 while (metadata.next_index < metadata.names.len) {
21002101 const i = metadata.next_index;
21012102 metadata.next_index += 1;
......@@ -2114,7 +2115,7 @@ fn requestNextTest(in: fs.File, metadata: *TestMetadata, sub_prog_node: *?std.Pr
21142115 }
21152116}
21162117
2117fn sendMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag) !void {
2118fn sendMessage(file: Io.File, tag: std.zig.Client.Message.Tag) !void {
21182119 const header: std.zig.Client.Message.Header = .{
21192120 .tag = tag,
21202121 .bytes_len = 0,
......@@ -2125,7 +2126,7 @@ fn sendMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag) !void {
21252126 };
21262127}
21272128
2128fn sendRunTestMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag, index: u32) !void {
2129fn sendRunTestMessage(file: Io.File, tag: std.zig.Client.Message.Tag, index: u32) !void {
21292130 const header: std.zig.Client.Message.Header = .{
21302131 .tag = tag,
21312132 .bytes_len = 4,
......@@ -2140,7 +2141,7 @@ fn sendRunTestMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag, index:
21402141}
21412142
21422143fn sendRunFuzzTestMessage(
2143 file: std.fs.File,
2144 file: Io.File,
21442145 index: u32,
21452146 kind: std.Build.abi.fuzz.LimitKind,
21462147 amount_or_instance: u64,
lib/std/Io.zig+1-1
......@@ -528,7 +528,7 @@ pub fn Poller(comptime StreamEnum: type) type {
528528/// Given an enum, returns a struct with fields of that enum, each field
529529/// representing an I/O stream for polling.
530530pub fn PollFiles(comptime StreamEnum: type) type {
531 return @Struct(.auto, null, std.meta.fieldNames(StreamEnum), &@splat(std.fs.File), &@splat(.{}));
531 return @Struct(.auto, null, std.meta.fieldNames(StreamEnum), &@splat(Io.File), &@splat(.{}));
532532}
533533
534534test {
lib/std/Io/Writer.zig+5-4
......@@ -1,7 +1,8 @@
1const Writer = @This();
2
13const builtin = @import("builtin");
24const native_endian = builtin.target.cpu.arch.endian();
35
4const Writer = @This();
56const std = @import("../std.zig");
67const assert = std.debug.assert;
78const Limit = std.Io.Limit;
......@@ -2837,7 +2838,7 @@ test "discarding sendFile" {
28372838 const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true });
28382839 defer file.close(io);
28392840 var r_buffer: [256]u8 = undefined;
2840 var file_writer: std.fs.File.Writer = .init(file, &r_buffer);
2841 var file_writer: File.Writer = .init(file, &r_buffer);
28412842 try file_writer.interface.writeByte('h');
28422843 try file_writer.interface.flush();
28432844
......@@ -2859,7 +2860,7 @@ test "allocating sendFile" {
28592860 const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true });
28602861 defer file.close(io);
28612862 var r_buffer: [2]u8 = undefined;
2862 var file_writer: std.fs.File.Writer = .init(file, &r_buffer);
2863 var file_writer: File.Writer = .init(file, &r_buffer);
28632864 try file_writer.interface.writeAll("abcd");
28642865 try file_writer.interface.flush();
28652866
......@@ -2883,7 +2884,7 @@ test sendFileReading {
28832884 const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true });
28842885 defer file.close(io);
28852886 var r_buffer: [2]u8 = undefined;
2886 var file_writer: std.fs.File.Writer = .init(file, &r_buffer);
2887 var file_writer: File.Writer = .init(file, &r_buffer);
28872888 try file_writer.interface.writeAll("abcd");
28882889 try file_writer.interface.flush();
28892890
lib/std/Io/test.zig+1-1
......@@ -10,7 +10,7 @@ const expectError = std.testing.expectError;
1010const DefaultPrng = std.Random.DefaultPrng;
1111const mem = std.mem;
1212const fs = std.fs;
13const File = std.fs.File;
13const File = std.Io.File;
1414const assert = std.debug.assert;
1515
1616const tmpDir = std.testing.tmpDir;
lib/std/Io/tty.zig+4-3
......@@ -1,9 +1,10 @@
1const std = @import("std");
21const builtin = @import("builtin");
3const File = std.fs.File;
2const native_os = builtin.os.tag;
3
4const std = @import("std");
5const File = std.Io.File;
46const process = std.process;
57const windows = std.os.windows;
6const native_os = builtin.os.tag;
78
89pub const Color = enum {
910 black,
lib/std/Progress.zig+10-8
......@@ -1,19 +1,21 @@
11//! This API is non-allocating, non-fallible, thread-safe, and lock-free.
2const Progress = @This();
23
3const std = @import("std");
44const builtin = @import("builtin");
5const is_big_endian = builtin.cpu.arch.endian() == .big;
6const is_windows = builtin.os.tag == .windows;
7
8const std = @import("std");
9const Io = std.Io;
510const windows = std.os.windows;
611const testing = std.testing;
712const assert = std.debug.assert;
8const Progress = @This();
913const posix = std.posix;
10const is_big_endian = builtin.cpu.arch.endian() == .big;
11const is_windows = builtin.os.tag == .windows;
1214const Writer = std.Io.Writer;
1315
1416/// `null` if the current node (and its children) should
1517/// not print on update()
16terminal: std.fs.File,
18terminal: Io.File,
1719
1820terminal_mode: TerminalMode,
1921
......@@ -472,7 +474,7 @@ pub fn start(options: Options) Node {
472474 if (options.disable_printing) {
473475 return Node.none;
474476 }
475 const stderr: std.fs.File = .stderr();
477 const stderr: Io.File = .stderr();
476478 global_progress.terminal = stderr;
477479 if (stderr.enableAnsiEscapeCodes()) |_| {
478480 global_progress.terminal_mode = .ansi_escape_codes;
......@@ -633,8 +635,8 @@ pub fn unlockStdErr() void {
633635/// Protected by `stderr_mutex`.
634636const stderr_writer: *Writer = &stderr_file_writer.interface;
635637/// Protected by `stderr_mutex`.
636var stderr_file_writer: std.fs.File.Writer = .{
637 .interface = std.fs.File.Writer.initInterface(&.{}),
638var stderr_file_writer: Io.File.Writer = .{
639 .interface = Io.File.Writer.initInterface(&.{}),
638640 .file = if (is_windows) undefined else .stderr(),
639641 .mode = .streaming,
640642};
lib/std/Random/benchmark.zig+4-2
......@@ -1,7 +1,9 @@
11// zig run -O ReleaseFast --zig-lib-dir ../.. benchmark.zig
22
3const std = @import("std");
43const builtin = @import("builtin");
4
5const std = @import("std");
6const Io = std.Io;
57const time = std.time;
68const Timer = time.Timer;
79const Random = std.Random;
......@@ -123,7 +125,7 @@ fn mode(comptime x: comptime_int) comptime_int {
123125
124126pub fn main() !void {
125127 var stdout_buffer: [0x100]u8 = undefined;
126 var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
128 var stdout_writer = Io.File.stdout().writer(&stdout_buffer);
127129 const stdout = &stdout_writer.interface;
128130
129131 var buffer: [1024]u8 = undefined;
lib/std/Thread.zig+2-2
......@@ -175,7 +175,7 @@ pub const SetNameError = error{
175175 Unsupported,
176176 Unexpected,
177177 InvalidWtf8,
178} || posix.PrctlError || posix.WriteError || std.fs.File.OpenError || std.fmt.BufPrintError;
178} || posix.PrctlError || posix.WriteError || Io.File.OpenError || std.fmt.BufPrintError;
179179
180180pub fn setName(self: Thread, io: Io, name: []const u8) SetNameError!void {
181181 if (name.len > max_name_len) return error.NameTooLong;
......@@ -293,7 +293,7 @@ pub fn setName(self: Thread, io: Io, name: []const u8) SetNameError!void {
293293pub const GetNameError = error{
294294 Unsupported,
295295 Unexpected,
296} || posix.PrctlError || posix.ReadError || std.fs.File.OpenError || std.fmt.BufPrintError;
296} || posix.PrctlError || posix.ReadError || Io.File.OpenError || std.fmt.BufPrintError;
297297
298298/// On Windows, the result is encoded as [WTF-8](https://wtf-8.codeberg.page/).
299299/// On other platforms, the result is an opaque sequence of bytes with no particular encoding.
lib/std/crypto/Certificate/Bundle.zig+4-4
......@@ -171,7 +171,7 @@ fn rescanWindows(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp) RescanW
171171 cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len);
172172}
173173
174pub const AddCertsFromDirPathError = fs.File.OpenError || AddCertsFromDirError;
174pub const AddCertsFromDirPathError = Io.File.OpenError || AddCertsFromDirError;
175175
176176pub fn addCertsFromDirPath(
177177 cb: *Bundle,
......@@ -212,7 +212,7 @@ pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp, i
212212 }
213213}
214214
215pub const AddCertsFromFilePathError = fs.File.OpenError || AddCertsFromFileError || Io.Clock.Error;
215pub const AddCertsFromFilePathError = Io.File.OpenError || AddCertsFromFileError || Io.Clock.Error;
216216
217217pub fn addCertsFromFilePathAbsolute(
218218 cb: *Bundle,
......@@ -242,8 +242,8 @@ pub fn addCertsFromFilePath(
242242}
243243
244244pub const AddCertsFromFileError = Allocator.Error ||
245 fs.File.GetSeekPosError ||
246 fs.File.ReadError ||
245 Io.File.GetSeekPosError ||
246 Io.File.ReadError ||
247247 ParseCertError ||
248248 std.base64.Error ||
249249 error{ CertificateAuthorityBundleTooBig, MissingEndCertificateMarker, Streaming };
lib/std/crypto/Certificate/Bundle/macos.zig+1-1
......@@ -6,7 +6,7 @@ const mem = std.mem;
66const Allocator = std.mem.Allocator;
77const Bundle = @import("../Bundle.zig");
88
9pub const RescanMacError = Allocator.Error || fs.File.OpenError || fs.File.ReadError || fs.File.SeekError || Bundle.ParseCertError || error{EndOfStream};
9pub const RescanMacError = Allocator.Error || Io.File.OpenError || Io.File.ReadError || Io.File.SeekError || Bundle.ParseCertError || error{EndOfStream};
1010
1111pub fn rescanMac(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp) RescanMacError!void {
1212 cb.bytes.clearRetainingCapacity();
lib/std/crypto/benchmark.zig+5-3
......@@ -1,10 +1,12 @@
11// zig run -O ReleaseFast --zig-lib-dir ../.. benchmark.zig
22
3const std = @import("std");
43const builtin = @import("builtin");
4
5const std = @import("std");
6const Io = std.Io;
57const mem = std.mem;
68const time = std.time;
7const Timer = time.Timer;
9const Timer = std.time.Timer;
810const crypto = std.crypto;
911
1012const KiB = 1024;
......@@ -504,7 +506,7 @@ fn mode(comptime x: comptime_int) comptime_int {
504506pub fn main() !void {
505507 // Size of buffer is about size of printed message.
506508 var stdout_buffer: [0x100]u8 = undefined;
507 var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
509 var stdout_writer = Io.File.stdout().writer(&stdout_buffer);
508510 const stdout = &stdout_writer.interface;
509511
510512 var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
lib/std/debug.zig+3-3
......@@ -8,7 +8,7 @@ const posix = std.posix;
88const fs = std.fs;
99const testing = std.testing;
1010const Allocator = mem.Allocator;
11const File = std.fs.File;
11const File = std.Io.File;
1212const windows = std.os.windows;
1313
1414const builtin = @import("builtin");
......@@ -575,7 +575,7 @@ pub fn defaultPanic(
575575 // A panic happened while trying to print a previous panic message.
576576 // We're still holding the mutex but that's fine as we're going to
577577 // call abort().
578 fs.File.stderr().writeAll("aborting due to recursive panic\n") catch {};
578 File.stderr().writeAll("aborting due to recursive panic\n") catch {};
579579 },
580580 else => {}, // Panicked while printing the recursive panic message.
581581 }
......@@ -1596,7 +1596,7 @@ pub fn defaultHandleSegfault(addr: ?usize, name: []const u8, opt_ctx: ?CpuContex
15961596 // A segfault happened while trying to print a previous panic message.
15971597 // We're still holding the mutex but that's fine as we're going to
15981598 // call abort().
1599 fs.File.stderr().writeAll("aborting due to recursive panic\n") catch {};
1599 File.stderr().writeAll("aborting due to recursive panic\n") catch {};
16001600 },
16011601 else => {}, // Panicked while printing the recursive panic message.
16021602 }
lib/std/debug/ElfFile.zig+2-2
......@@ -123,7 +123,7 @@ pub const LoadError = error{
123123
124124pub fn load(
125125 gpa: Allocator,
126 elf_file: std.fs.File,
126 elf_file: Io.File,
127127 opt_build_id: ?[]const u8,
128128 di_search_paths: *const DebugInfoSearchPaths,
129129) LoadError!ElfFile {
......@@ -423,7 +423,7 @@ const LoadInnerResult = struct {
423423};
424424fn loadInner(
425425 arena: Allocator,
426 elf_file: std.fs.File,
426 elf_file: Io.File,
427427 opt_crc: ?u32,
428428) (LoadError || error{ CrcMismatch, Streaming, Canceled })!LoadInnerResult {
429429 const mapped_mem: []align(std.heap.page_size_min) const u8 = mapped: {
lib/std/debug/Info.zig+1-1
......@@ -27,7 +27,7 @@ coverage: *Coverage,
2727pub const LoadError = error{
2828 MissingDebugInfo,
2929 UnsupportedDebugInfo,
30} || std.fs.File.OpenError || ElfFile.LoadError || MachOFile.Error || std.debug.Dwarf.ScanError;
30} || Io.File.OpenError || ElfFile.LoadError || MachOFile.Error || std.debug.Dwarf.ScanError;
3131
3232pub fn load(
3333 gpa: Allocator,
lib/std/debug/Pdb.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("../std.zig");
2const File = std.fs.File;
2const File = std.Io.File;
33const Allocator = std.mem.Allocator;
44const pdb = std.pdb;
55const assert = std.debug.assert;
lib/std/debug/SelfInfo/Windows.zig+1-1
......@@ -204,7 +204,7 @@ const Module = struct {
204204 coff_section_headers: []coff.SectionHeader,
205205
206206 const MappedFile = struct {
207 file: fs.File,
207 file: Io.File,
208208 section_handle: windows.HANDLE,
209209 section_view: []const u8,
210210 fn deinit(mf: *const MappedFile, io: Io) void {
lib/std/debug/simple_panic.zig+1-1
......@@ -15,7 +15,7 @@ pub fn call(msg: []const u8, ra: ?usize) noreturn {
1515 @branchHint(.cold);
1616 _ = ra;
1717 std.debug.lockStdErr();
18 const stderr: std.fs.File = .stderr();
18 const stderr: std.Io.File = .stderr();
1919 stderr.writeAll(msg) catch {};
2020 @trap();
2121}
lib/std/dynamic_library.zig+1-1
......@@ -225,7 +225,7 @@ pub const ElfDynLib = struct {
225225 const fd = try resolveFromName(io, path);
226226 defer posix.close(fd);
227227
228 const file: std.fs.File = .{ .handle = fd };
228 const file: Io.File = .{ .handle = fd };
229229 const stat = try file.stat();
230230 const size = std.math.cast(usize, stat.size) orelse return error.FileTooBig;
231231
lib/std/fs/test.zig+4-4
......@@ -12,7 +12,7 @@ const posix = std.posix;
1212
1313const ArenaAllocator = std.heap.ArenaAllocator;
1414const Dir = std.fs.Dir;
15const File = std.fs.File;
15const File = std.Io.File;
1616const tmpDir = testing.tmpDir;
1717const SymLinkFlags = std.fs.Dir.SymLinkFlags;
1818
......@@ -2231,7 +2231,7 @@ test "read file non vectored" {
22312231 const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true });
22322232 defer file.close(io);
22332233 {
2234 var file_writer: std.fs.File.Writer = .init(file, &.{});
2234 var file_writer: File.Writer = .init(file, &.{});
22352235 try file_writer.interface.writeAll(contents);
22362236 try file_writer.interface.flush();
22372237 }
......@@ -2263,7 +2263,7 @@ test "seek keeping partial buffer" {
22632263 const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true });
22642264 defer file.close(io);
22652265 {
2266 var file_writer: std.fs.File.Writer = .init(file, &.{});
2266 var file_writer: File.Writer = .init(file, &.{});
22672267 try file_writer.interface.writeAll(contents);
22682268 try file_writer.interface.flush();
22692269 }
......@@ -2325,7 +2325,7 @@ test "seekTo flushes buffered data" {
23252325 defer file.close(io);
23262326 {
23272327 var buf: [16]u8 = undefined;
2328 var file_writer = std.fs.File.writer(file, &buf);
2328 var file_writer = File.writer(file, &buf);
23292329
23302330 try file_writer.interface.writeAll(contents);
23312331 try file_writer.seekTo(8);
lib/std/hash/benchmark.zig+3-2
......@@ -1,7 +1,8 @@
11// zig run -O ReleaseFast --zig-lib-dir ../.. benchmark.zig
2const builtin = @import("builtin");
23
34const std = @import("std");
4const builtin = @import("builtin");
5const Io = std.Io;
56const time = std.time;
67const Timer = time.Timer;
78const hash = std.hash;
......@@ -354,7 +355,7 @@ fn mode(comptime x: comptime_int) comptime_int {
354355
355356pub fn main() !void {
356357 var stdout_buffer: [0x100]u8 = undefined;
357 var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
358 var stdout_writer = Io.File.stdout().writer(&stdout_buffer);
358359 const stdout = &stdout_writer.interface;
359360
360361 var buffer: [1024]u8 = undefined;
lib/std/http.zig+1-1
......@@ -2,7 +2,7 @@ const builtin = @import("builtin");
22const std = @import("std.zig");
33const assert = std.debug.assert;
44const Writer = std.Io.Writer;
5const File = std.fs.File;
5const File = std.Io.File;
66
77pub const Client = @import("http/Client.zig");
88pub const Server = @import("http/Server.zig");
lib/std/pdb.zig+1-1
......@@ -12,7 +12,7 @@ const math = std.math;
1212const mem = std.mem;
1313const coff = std.coff;
1414const fs = std.fs;
15const File = std.fs.File;
15const File = std.Io.File;
1616const debug = std.debug;
1717
1818const ArrayList = std.ArrayList;
lib/std/posix/test.zig+9-9
......@@ -1,20 +1,20 @@
1const builtin = @import("builtin");
2const native_os = builtin.target.os.tag;
3
14const std = @import("../std.zig");
5const Io = std.Io;
26const posix = std.posix;
37const testing = std.testing;
4const expect = testing.expect;
5const expectEqual = testing.expectEqual;
6const expectError = testing.expectError;
8const expect = std.testing.expect;
9const expectEqual = std.testing.expectEqual;
10const expectError = std.testing.expectError;
711const fs = std.fs;
812const mem = std.mem;
913const elf = std.elf;
1014const linux = std.os.linux;
11
1215const a = std.testing.allocator;
13
14const builtin = @import("builtin");
1516const AtomicRmwOp = std.builtin.AtomicRmwOp;
1617const AtomicOrder = std.builtin.AtomicOrder;
17const native_os = builtin.target.os.tag;
1818const tmpDir = std.testing.tmpDir;
1919const AT = posix.AT;
2020
......@@ -663,14 +663,14 @@ test "dup & dup2" {
663663 var file = try tmp.dir.createFile("os_dup_test", .{});
664664 defer file.close(io);
665665
666 var duped = std.fs.File{ .handle = try posix.dup(file.handle) };
666 var duped = Io.File{ .handle = try posix.dup(file.handle) };
667667 defer duped.close(io);
668668 try duped.writeAll("dup");
669669
670670 // Tests aren't run in parallel so using the next fd shouldn't be an issue.
671671 const new_fd = duped.handle + 1;
672672 try posix.dup2(file.handle, new_fd);
673 var dup2ed = std.fs.File{ .handle = new_fd };
673 var dup2ed = Io.File{ .handle = new_fd };
674674 defer dup2ed.close(io);
675675 try dup2ed.writeAll("dup2");
676676 }
lib/std/process/Child.zig+2-2
......@@ -8,7 +8,7 @@ const Io = std.Io;
88const unicode = std.unicode;
99const fs = std.fs;
1010const process = std.process;
11const File = std.fs.File;
11const File = std.Io.File;
1212const windows = std.os.windows;
1313const linux = std.os.linux;
1414const posix = std.posix;
......@@ -1055,7 +1055,7 @@ fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn {
10551055
10561056fn writeIntFd(fd: i32, value: ErrInt) !void {
10571057 var buffer: [8]u8 = undefined;
1058 var fw: std.fs.File.Writer = .initStreaming(.{ .handle = fd }, &buffer);
1058 var fw: File.Writer = .initStreaming(.{ .handle = fd }, &buffer);
10591059 fw.interface.writeInt(u64, value, .little) catch unreachable;
10601060 fw.interface.flush() catch return error.SystemResources;
10611061}
lib/std/unicode/throughput_test.zig+3-3
......@@ -1,8 +1,8 @@
11const std = @import("std");
2const Io = std.Io;
23const time = std.time;
34const unicode = std.unicode;
4
5const Timer = time.Timer;
5const Timer = std.time.Timer;
66
77const N = 1_000_000;
88
......@@ -41,7 +41,7 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount {
4141pub fn main() !void {
4242 // Size of buffer is about size of printed message.
4343 var stdout_buffer: [0x100]u8 = undefined;
44 var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
44 var stdout_writer = Io.File.stdout().writer(&stdout_buffer);
4545 const stdout = &stdout_writer.interface;
4646
4747 try stdout.print("short ASCII strings\n", .{});
lib/std/zig/Zir.zig+4-4
......@@ -11,9 +11,11 @@
1111//! * In the future, possibly inline assembly, which needs to get parsed and
1212//! handled by the codegen backend, and errors reported there. However for now,
1313//! inline assembly is not an exception.
14const Zir = @This();
15const builtin = @import("builtin");
1416
1517const std = @import("std");
16const builtin = @import("builtin");
18const Io = std.Io;
1719const mem = std.mem;
1820const Allocator = std.mem.Allocator;
1921const assert = std.debug.assert;
......@@ -21,8 +23,6 @@ const BigIntConst = std.math.big.int.Const;
2123const BigIntMutable = std.math.big.int.Mutable;
2224const Ast = std.zig.Ast;
2325
24const Zir = @This();
25
2626instructions: std.MultiArrayList(Inst).Slice,
2727/// In order to store references to strings in fewer bytes, we copy all
2828/// string bytes into here. String bytes can be null. It is up to whomever
......@@ -45,7 +45,7 @@ pub const Header = extern struct {
4545 /// it's essentially free to have a zero field here and makes the warning go away,
4646 /// making it more likely that following Valgrind warnings will be taken seriously.
4747 unused: u32 = 0,
48 stat_inode: std.fs.File.INode,
48 stat_inode: Io.File.INode,
4949 stat_size: u64,
5050 stat_mtime: i128,
5151};
lib/std/zig/Zoir.zig+8-7
......@@ -1,6 +1,13 @@
11//! Zig Object Intermediate Representation.
22//! Simplified AST for the ZON (Zig Object Notation) format.
33//! `ZonGen` converts `Ast` to `Zoir`.
4const Zoir = @This();
5
6const std = @import("std");
7const Io = std.Io;
8const assert = std.debug.assert;
9const Allocator = std.mem.Allocator;
10const Ast = std.zig.Ast;
411
512nodes: std.MultiArrayList(Node.Repr).Slice,
613extra: []u32,
......@@ -25,7 +32,7 @@ pub const Header = extern struct {
2532 /// making it more likely that following Valgrind warnings will be taken seriously.
2633 unused: u64 = 0,
2734
28 stat_inode: std.fs.File.INode,
35 stat_inode: Io.File.INode,
2936 stat_size: u64,
3037 stat_mtime: i128,
3138
......@@ -254,9 +261,3 @@ pub const CompileError = extern struct {
254261 assert(std.meta.hasUniqueRepresentation(Note));
255262 }
256263};
257
258const std = @import("std");
259const assert = std.debug.assert;
260const Allocator = std.mem.Allocator;
261const Ast = std.zig.Ast;
262const Zoir = @This();
lib/std/zig/llvm/Builder.zig+2-2
......@@ -9578,7 +9578,7 @@ pub fn asmValue(
95789578
95799579pub fn dump(b: *Builder) void {
95809580 var buffer: [4000]u8 = undefined;
9581 const stderr: std.fs.File = .stderr();
9581 const stderr: Io.File = .stderr();
95829582 b.printToFile(stderr, &buffer) catch {};
95839583}
95849584
......@@ -9589,7 +9589,7 @@ pub fn printToFilePath(b: *Builder, io: Io, dir: std.fs.Dir, path: []const u8) !
95899589 try b.printToFile(io, file, &buffer);
95909590}
95919591
9592pub fn printToFile(b: *Builder, file: std.fs.File, buffer: []u8) !void {
9592pub fn printToFile(b: *Builder, file: Io.File, buffer: []u8) !void {
95939593 var fw = file.writer(buffer);
95949594 try print(b, &fw.interface);
95959595 try fw.interface.flush();
lib/std/zig/perf_test.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const Io = std.Io;
23const mem = std.mem;
34const Tokenizer = std.zig.Tokenizer;
45const fmtIntSizeBin = std.fmt.fmtIntSizeBin;
......@@ -22,7 +23,7 @@ pub fn main() !void {
2223 const bytes_per_sec = @as(u64, @intFromFloat(@floor(bytes_per_sec_float)));
2324
2425 var stdout_buffer: [1024]u8 = undefined;
25 var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
26 var stdout_writer = Io.File.stdout().writer(&stdout_buffer);
2627 const stdout = &stdout_writer.interface;
2728 try stdout.print("parsing speed: {Bi:.2}/s, {Bi:.2} used \n", .{ bytes_per_sec, memory_used });
2829 try stdout.flush();
lib/std/zip.zig+3-2
......@@ -4,9 +4,10 @@
44//! Note that this file uses the abbreviation "cd" for "central directory"
55
66const builtin = @import("builtin");
7const std = @import("std");
8const File = std.fs.File;
97const is_le = builtin.target.cpu.arch.endian() == .little;
8
9const std = @import("std");
10const File = std.Io.File;
1011const Writer = std.Io.Writer;
1112const Reader = std.Io.Reader;
1213const flate = std.compress.flate;
src/Compilation.zig+2-2
......@@ -5325,7 +5325,7 @@ fn docsCopyModule(
53255325 comp: *Compilation,
53265326 module: *Package.Module,
53275327 name: []const u8,
5328 tar_file_writer: *fs.File.Writer,
5328 tar_file_writer: *Io.File.Writer,
53295329) !void {
53305330 const io = comp.io;
53315331 const root = module.root;
......@@ -5361,7 +5361,7 @@ fn docsCopyModule(
53615361 };
53625362 defer file.close(io);
53635363 const stat = try file.stat();
5364 var file_reader: fs.File.Reader = .initSize(file.adaptToNewApi(), io, &buffer, stat.size);
5364 var file_reader: Io.File.Reader = .initSize(file.adaptToNewApi(), io, &buffer, stat.size);
53655365
53665366 archiver.writeFileTimestamp(entry.path, &file_reader, stat.mtime) catch |err| {
53675367 return comp.lockAndSetMiscFailure(.docs_copy, "unable to archive {f}{s}: {t}", .{
src/Package/Fetch.zig+8-8
......@@ -882,7 +882,7 @@ fn fail(f: *Fetch, msg_tok: std.zig.Ast.TokenIndex, msg_str: u32) RunError {
882882}
883883
884884const Resource = union(enum) {
885 file: fs.File.Reader,
885 file: Io.File.Reader,
886886 http_request: HttpRequest,
887887 git: Git,
888888 dir: Io.Dir,
......@@ -1653,7 +1653,7 @@ fn computeHash(f: *Fetch, pkg_path: Cache.Path, filter: Filter) RunError!Compute
16531653
16541654fn dumpHashInfo(all_files: []const *const HashedFile) !void {
16551655 var stdout_buffer: [1024]u8 = undefined;
1656 var stdout_writer: fs.File.Writer = .initStreaming(.stdout(), &stdout_buffer);
1656 var stdout_writer: Io.File.Writer = .initStreaming(.stdout(), &stdout_buffer);
16571657 const w = &stdout_writer.interface;
16581658 for (all_files) |hashed_file| {
16591659 try w.print("{t}: {x}: {s}\n", .{ hashed_file.kind, &hashed_file.hash, hashed_file.normalized_path });
......@@ -1712,11 +1712,11 @@ fn deleteFileFallible(dir: Io.Dir, deleted_file: *DeletedFile) DeletedFile.Error
17121712 try dir.deleteFile(deleted_file.fs_path);
17131713}
17141714
1715fn setExecutable(file: fs.File) !void {
1715fn setExecutable(file: Io.File) !void {
17161716 if (!std.fs.has_executable_bit) return;
17171717
17181718 const S = std.posix.S;
1719 const mode = fs.File.default_mode | S.IXUSR | S.IXGRP | S.IXOTH;
1719 const mode = Io.File.default_mode | S.IXUSR | S.IXGRP | S.IXOTH;
17201720 try file.chmod(mode);
17211721}
17221722
......@@ -1738,10 +1738,10 @@ const HashedFile = struct {
17381738 size: u64,
17391739
17401740 const Error =
1741 fs.File.OpenError ||
1742 fs.File.ReadError ||
1743 fs.File.StatError ||
1744 fs.File.ChmodError ||
1741 Io.File.OpenError ||
1742 Io.File.ReadError ||
1743 Io.File.StatError ||
1744 Io.File.ChmodError ||
17451745 Io.Dir.ReadLinkError;
17461746
17471747 const Kind = enum { file, link };
src/Package/Fetch/git.zig+11-11
......@@ -198,8 +198,8 @@ pub const Repository = struct {
198198 repo: *Repository,
199199 allocator: Allocator,
200200 format: Oid.Format,
201 pack_file: *std.fs.File.Reader,
202 index_file: *std.fs.File.Reader,
201 pack_file: *Io.File.Reader,
202 index_file: *Io.File.Reader,
203203 ) !void {
204204 repo.* = .{ .odb = undefined };
205205 try repo.odb.init(allocator, format, pack_file, index_file);
......@@ -372,9 +372,9 @@ pub const Repository = struct {
372372/// [pack-format](https://git-scm.com/docs/pack-format).
373373const Odb = struct {
374374 format: Oid.Format,
375 pack_file: *std.fs.File.Reader,
375 pack_file: *Io.File.Reader,
376376 index_header: IndexHeader,
377 index_file: *std.fs.File.Reader,
377 index_file: *Io.File.Reader,
378378 cache: ObjectCache = .{},
379379 allocator: Allocator,
380380
......@@ -383,8 +383,8 @@ const Odb = struct {
383383 odb: *Odb,
384384 allocator: Allocator,
385385 format: Oid.Format,
386 pack_file: *std.fs.File.Reader,
387 index_file: *std.fs.File.Reader,
386 pack_file: *Io.File.Reader,
387 index_file: *Io.File.Reader,
388388 ) !void {
389389 try pack_file.seekTo(0);
390390 try index_file.seekTo(0);
......@@ -1272,8 +1272,8 @@ const IndexEntry = struct {
12721272pub fn indexPack(
12731273 allocator: Allocator,
12741274 format: Oid.Format,
1275 pack: *std.fs.File.Reader,
1276 index_writer: *std.fs.File.Writer,
1275 pack: *Io.File.Reader,
1276 index_writer: *Io.File.Writer,
12771277) !void {
12781278 try pack.seekTo(0);
12791279
......@@ -1372,7 +1372,7 @@ pub fn indexPack(
13721372fn indexPackFirstPass(
13731373 allocator: Allocator,
13741374 format: Oid.Format,
1375 pack: *std.fs.File.Reader,
1375 pack: *Io.File.Reader,
13761376 index_entries: *std.AutoHashMapUnmanaged(Oid, IndexEntry),
13771377 pending_deltas: *std.ArrayList(IndexEntry),
13781378) !Oid {
......@@ -1425,7 +1425,7 @@ fn indexPackFirstPass(
14251425fn indexPackHashDelta(
14261426 allocator: Allocator,
14271427 format: Oid.Format,
1428 pack: *std.fs.File.Reader,
1428 pack: *Io.File.Reader,
14291429 delta: IndexEntry,
14301430 index_entries: std.AutoHashMapUnmanaged(Oid, IndexEntry),
14311431 cache: *ObjectCache,
......@@ -1477,7 +1477,7 @@ fn indexPackHashDelta(
14771477fn resolveDeltaChain(
14781478 allocator: Allocator,
14791479 format: Oid.Format,
1480 pack: *std.fs.File.Reader,
1480 pack: *Io.File.Reader,
14811481 base_object: Object,
14821482 delta_offsets: []const u64,
14831483 cache: *ObjectCache,
src/Zcu.zig+4-4
......@@ -1200,7 +1200,7 @@ pub const EmbedFile = struct {
12001200 /// `.none` means the file was not loaded, so `stat` is undefined.
12011201 val: InternPool.Index,
12021202 /// If this is `null` and `val` is `.none`, the file has never been loaded.
1203 err: ?(std.fs.File.OpenError || std.fs.File.StatError || std.fs.File.ReadError || error{UnexpectedEof}),
1203 err: ?(Io.File.OpenError || Io.File.StatError || Io.File.ReadError || error{UnexpectedEof}),
12041204 stat: Cache.File.Stat,
12051205
12061206 pub const Index = enum(u32) {
......@@ -2927,7 +2927,7 @@ comptime {
29272927 }
29282928}
29292929
2930pub fn loadZirCache(gpa: Allocator, io: Io, cache_file: std.fs.File) !Zir {
2930pub fn loadZirCache(gpa: Allocator, io: Io, cache_file: Io.File) !Zir {
29312931 var buffer: [2000]u8 = undefined;
29322932 var file_reader = cache_file.reader(io, &buffer);
29332933 return result: {
......@@ -2986,7 +2986,7 @@ pub fn loadZirCacheBody(gpa: Allocator, header: Zir.Header, cache_br: *Io.Reader
29862986 return zir;
29872987}
29882988
2989pub fn saveZirCache(gpa: Allocator, cache_file: std.fs.File, stat: std.fs.File.Stat, zir: Zir) (std.fs.File.WriteError || Allocator.Error)!void {
2989pub fn saveZirCache(gpa: Allocator, cache_file: Io.File, stat: Io.File.Stat, zir: Zir) (Io.File.WriteError || Allocator.Error)!void {
29902990 const safety_buffer = if (data_has_safety_tag)
29912991 try gpa.alloc([8]u8, zir.instructions.len)
29922992 else
......@@ -3026,7 +3026,7 @@ pub fn saveZirCache(gpa: Allocator, cache_file: std.fs.File, stat: std.fs.File.S
30263026 };
30273027}
30283028
3029pub fn saveZoirCache(cache_file: std.fs.File, stat: std.fs.File.Stat, zoir: Zoir) std.fs.File.WriteError!void {
3029pub fn saveZoirCache(cache_file: Io.File, stat: Io.File.Stat, zoir: Zoir) Io.File.WriteError!void {
30303030 const header: Zoir.Header = .{
30313031 .nodes_len = @intCast(zoir.nodes.len),
30323032 .extra_len = @intCast(zoir.extra.len),
src/Zcu/PerThread.zig+3-3
......@@ -118,7 +118,7 @@ pub fn updateFile(
118118 const zir_dir = cache_directory.handle;
119119
120120 // Determine whether we need to reload the file from disk and redo parsing and AstGen.
121 var lock: std.fs.File.Lock = switch (file.status) {
121 var lock: Io.File.Lock = switch (file.status) {
122122 .never_loaded, .retryable_failure => lock: {
123123 // First, load the cached ZIR code, if any.
124124 log.debug("AstGen checking cache: {f} (local={}, digest={s})", .{
......@@ -346,8 +346,8 @@ pub fn updateFile(
346346
347347fn loadZirZoirCache(
348348 zcu: *Zcu,
349 cache_file: std.fs.File,
350 stat: std.fs.File.Stat,
349 cache_file: Io.File,
350 stat: Io.File.Stat,
351351 file: *Zcu.File,
352352 comptime mode: Ast.Mode,
353353) !enum { success, invalid, truncated, stale } {
src/fmt.zig+8-8
......@@ -37,9 +37,9 @@ const Fmt = struct {
3737 arena: Allocator,
3838 io: Io,
3939 out_buffer: std.Io.Writer.Allocating,
40 stdout_writer: *fs.File.Writer,
40 stdout_writer: *Io.File.Writer,
4141
42 const SeenMap = std.AutoHashMap(fs.File.INode, void);
42 const SeenMap = std.AutoHashMap(Io.File.INode, void);
4343};
4444
4545pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) !void {
......@@ -59,7 +59,7 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) !
5959 const arg = args[i];
6060 if (mem.startsWith(u8, arg, "-")) {
6161 if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {
62 try fs.File.stdout().writeAll(usage_fmt);
62 try Io.File.stdout().writeAll(usage_fmt);
6363 return process.cleanExit();
6464 } else if (mem.eql(u8, arg, "--color")) {
6565 if (i + 1 >= args.len) {
......@@ -99,9 +99,9 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) !
9999 fatal("cannot use --stdin with positional arguments", .{});
100100 }
101101
102 const stdin: fs.File = .stdin();
102 const stdin: Io.File = .stdin();
103103 var stdio_buffer: [1024]u8 = undefined;
104 var file_reader: fs.File.Reader = stdin.reader(io, &stdio_buffer);
104 var file_reader: Io.File.Reader = stdin.reader(io, &stdio_buffer);
105105 const source_code = std.zig.readSourceFileToEndAlloc(gpa, &file_reader) catch |err| {
106106 fatal("unable to read stdin: {}", .{err});
107107 };
......@@ -154,7 +154,7 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) !
154154 process.exit(code);
155155 }
156156
157 return fs.File.stdout().writeAll(formatted);
157 return Io.File.stdout().writeAll(formatted);
158158 }
159159
160160 if (input_files.items.len == 0) {
......@@ -162,7 +162,7 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) !
162162 }
163163
164164 var stdout_buffer: [4096]u8 = undefined;
165 var stdout_writer = fs.File.stdout().writer(&stdout_buffer);
165 var stdout_writer = Io.File.stdout().writer(&stdout_buffer);
166166
167167 var fmt: Fmt = .{
168168 .gpa = gpa,
......@@ -272,7 +272,7 @@ fn fmtPathFile(
272272 return error.IsDir;
273273
274274 var read_buffer: [1024]u8 = undefined;
275 var file_reader: fs.File.Reader = source_file.reader(io, &read_buffer);
275 var file_reader: Io.File.Reader = source_file.reader(io, &read_buffer);
276276 file_reader.size = stat.size;
277277
278278 const gpa = fmt.gpa;
src/link.zig+10-10
......@@ -393,7 +393,7 @@ pub const File = struct {
393393 comp: *Compilation,
394394 emit: Path,
395395
396 file: ?fs.File,
396 file: ?Io.File,
397397 /// When using the LLVM backend, the emitted object is written to a file with this name. This
398398 /// object file then becomes a normal link input to LLD or a self-hosted linker.
399399 ///
......@@ -1110,7 +1110,7 @@ pub const File = struct {
11101110 };
11111111 }
11121112
1113 fn loadGnuLdScript(base: *File, path: Path, parent_query: UnresolvedInput.Query, file: fs.File) anyerror!void {
1113 fn loadGnuLdScript(base: *File, path: Path, parent_query: UnresolvedInput.Query, file: Io.File) anyerror!void {
11141114 const comp = base.comp;
11151115 const diags = &comp.link_diags;
11161116 const gpa = comp.gpa;
......@@ -1238,7 +1238,7 @@ pub const File = struct {
12381238 pub fn determineMode(
12391239 output_mode: std.builtin.OutputMode,
12401240 link_mode: std.builtin.LinkMode,
1241 ) fs.File.Mode {
1241 ) Io.File.Mode {
12421242 // On common systems with a 0o022 umask, 0o777 will still result in a file created
12431243 // with 0o755 permissions, but it works appropriately if the system is configured
12441244 // more leniently. As another data point, C's fopen seems to open files with the
......@@ -1247,10 +1247,10 @@ pub const File = struct {
12471247 switch (output_mode) {
12481248 .Lib => return switch (link_mode) {
12491249 .dynamic => executable_mode,
1250 .static => fs.File.default_mode,
1250 .static => Io.File.default_mode,
12511251 },
12521252 .Exe => return executable_mode,
1253 .Obj => return fs.File.default_mode,
1253 .Obj => return Io.File.default_mode,
12541254 }
12551255 }
12561256
......@@ -1660,19 +1660,19 @@ pub const Input = union(enum) {
16601660
16611661 pub const Object = struct {
16621662 path: Path,
1663 file: fs.File,
1663 file: Io.File,
16641664 must_link: bool,
16651665 hidden: bool,
16661666 };
16671667
16681668 pub const Res = struct {
16691669 path: Path,
1670 file: fs.File,
1670 file: Io.File,
16711671 };
16721672
16731673 pub const Dso = struct {
16741674 path: Path,
1675 file: fs.File,
1675 file: Io.File,
16761676 needed: bool,
16771677 weak: bool,
16781678 reexport: bool,
......@@ -1694,7 +1694,7 @@ pub const Input = union(enum) {
16941694 }
16951695
16961696 /// Returns `null` in the case of `dso_exact`.
1697 pub fn pathAndFile(input: Input) ?struct { Path, fs.File } {
1697 pub fn pathAndFile(input: Input) ?struct { Path, Io.File } {
16981698 return switch (input) {
16991699 .object, .archive => |obj| .{ obj.path, obj.file },
17001700 inline .res, .dso => |x| .{ x.path, x.file },
......@@ -2075,7 +2075,7 @@ fn resolveLibInput(
20752075fn finishResolveLibInput(
20762076 resolved_inputs: *std.ArrayList(Input),
20772077 path: Path,
2078 file: std.fs.File,
2078 file: Io.File,
20792079 link_mode: std.builtin.LinkMode,
20802080 query: UnresolvedInput.Query,
20812081) ResolveLibInputResult {
src/link/Dwarf.zig+28-25
......@@ -1,3 +1,24 @@
1const Dwarf = @This();
2
3const std = @import("std");
4const Io = std.Io;
5const Allocator = std.mem.Allocator;
6const DW = std.dwarf;
7const Zir = std.zig.Zir;
8const assert = std.debug.assert;
9const log = std.log.scoped(.dwarf);
10const Writer = std.Io.Writer;
11
12const InternPool = @import("../InternPool.zig");
13const Module = @import("../Package.zig").Module;
14const Type = @import("../Type.zig");
15const Value = @import("../Value.zig");
16const Zcu = @import("../Zcu.zig");
17const codegen = @import("../codegen.zig");
18const dev = @import("../dev.zig");
19const link = @import("../link.zig");
20const target_info = @import("../target.zig");
21
122gpa: Allocator,
223bin_file: *link.File,
324format: DW.Format,
......@@ -29,16 +50,16 @@ pub const UpdateError = error{
2950 UnexpectedEndOfFile,
3051} ||
3152 codegen.GenerateSymbolError ||
32 std.fs.File.OpenError ||
33 std.fs.File.SetEndPosError ||
34 std.fs.File.CopyRangeError ||
35 std.fs.File.PReadError ||
36 std.fs.File.PWriteError;
53 Io.File.OpenError ||
54 Io.File.SetEndPosError ||
55 Io.File.CopyRangeError ||
56 Io.File.PReadError ||
57 Io.File.PWriteError;
3758
3859pub const FlushError = UpdateError;
3960
4061pub const RelocError =
41 std.fs.File.PWriteError;
62 Io.File.PWriteError;
4263
4364pub const AddressSize = enum(u8) {
4465 @"32" = 4,
......@@ -6350,7 +6371,7 @@ const AbbrevCode = enum {
63506371 });
63516372};
63526373
6353fn getFile(dwarf: *Dwarf) ?std.fs.File {
6374fn getFile(dwarf: *Dwarf) ?Io.File {
63546375 if (dwarf.bin_file.cast(.macho)) |macho_file| if (macho_file.d_sym) |*d_sym| return d_sym.file;
63556376 return dwarf.bin_file.file;
63566377}
......@@ -6429,21 +6450,3 @@ const force_incremental = false;
64296450inline fn incremental(dwarf: Dwarf) bool {
64306451 return force_incremental or dwarf.bin_file.comp.config.incremental;
64316452}
6432
6433const Allocator = std.mem.Allocator;
6434const DW = std.dwarf;
6435const Dwarf = @This();
6436const InternPool = @import("../InternPool.zig");
6437const Module = @import("../Package.zig").Module;
6438const Type = @import("../Type.zig");
6439const Value = @import("../Value.zig");
6440const Zcu = @import("../Zcu.zig");
6441const Zir = std.zig.Zir;
6442const assert = std.debug.assert;
6443const codegen = @import("../codegen.zig");
6444const dev = @import("../dev.zig");
6445const link = @import("../link.zig");
6446const log = std.log.scoped(.dwarf);
6447const std = @import("std");
6448const target_info = @import("../target.zig");
6449const Writer = std.Io.Writer;
src/link/Elf.zig+3-2
......@@ -3651,7 +3651,7 @@ fn fileLookup(files: std.MultiArrayList(File.Entry), index: File.Index, zig_obje
36513651pub fn addFileHandle(
36523652 gpa: Allocator,
36533653 file_handles: *std.ArrayList(File.Handle),
3654 handle: fs.File,
3654 handle: Io.File,
36553655) Allocator.Error!File.HandleIndex {
36563656 try file_handles.append(gpa, handle);
36573657 return @intCast(file_handles.items.len - 1);
......@@ -4068,7 +4068,7 @@ fn fmtDumpState(self: *Elf, writer: *std.Io.Writer) std.Io.Writer.Error!void {
40684068}
40694069
40704070/// Caller owns the memory.
4071pub fn preadAllAlloc(allocator: Allocator, handle: fs.File, offset: u64, size: u64) ![]u8 {
4071pub fn preadAllAlloc(allocator: Allocator, handle: Io.File, offset: u64, size: u64) ![]u8 {
40724072 const buffer = try allocator.alloc(u8, math.cast(usize, size) orelse return error.Overflow);
40734073 errdefer allocator.free(buffer);
40744074 const amt = try handle.preadAll(buffer, offset);
......@@ -4460,6 +4460,7 @@ pub fn cast(elf_file: *Elf, comptime T: type, x: anytype) error{LinkFailure}!T {
44604460}
44614461
44624462const std = @import("std");
4463const Io = std.Io;
44634464const build_options = @import("build_options");
44644465const builtin = @import("builtin");
44654466const assert = std.debug.assert;
src/link/Elf/Object.zig+33-32
......@@ -1,3 +1,30 @@
1const Object = @This();
2
3const std = @import("std");
4const Io = std.Io;
5const assert = std.debug.assert;
6const eh_frame = @import("eh_frame.zig");
7const elf = std.elf;
8const fs = std.fs;
9const log = std.log.scoped(.link);
10const math = std.math;
11const mem = std.mem;
12const Path = std.Build.Cache.Path;
13const Allocator = std.mem.Allocator;
14
15const Diags = @import("../../link.zig").Diags;
16const Archive = @import("Archive.zig");
17const Atom = @import("Atom.zig");
18const AtomList = @import("AtomList.zig");
19const Cie = eh_frame.Cie;
20const Elf = @import("../Elf.zig");
21const Fde = eh_frame.Fde;
22const File = @import("file.zig").File;
23const Merge = @import("Merge.zig");
24const Symbol = @import("Symbol.zig");
25const Alignment = Atom.Alignment;
26const riscv = @import("../riscv.zig");
27
128archive: ?InArchive = null,
229/// Archive files cannot contain subdirectories, so only the basename is needed
330/// for output. However, the full path is kept for error reporting.
......@@ -68,7 +95,7 @@ pub fn parse(
6895 diags: *Diags,
6996 /// For error reporting purposes only.
7097 path: Path,
71 handle: fs.File,
98 handle: Io.File,
7299 target: *const std.Target,
73100 debug_fmt_strip: bool,
74101 default_sym_version: elf.Versym,
......@@ -97,7 +124,7 @@ pub fn parseCommon(
97124 gpa: Allocator,
98125 diags: *Diags,
99126 path: Path,
100 handle: fs.File,
127 handle: Io.File,
101128 target: *const std.Target,
102129) !void {
103130 const offset = if (self.archive) |ar| ar.offset else 0;
......@@ -264,7 +291,7 @@ fn initAtoms(
264291 gpa: Allocator,
265292 diags: *Diags,
266293 path: Path,
267 handle: fs.File,
294 handle: Io.File,
268295 debug_fmt_strip: bool,
269296 target: *const std.Target,
270297) !void {
......@@ -421,7 +448,7 @@ fn initSymbols(
421448fn parseEhFrame(
422449 self: *Object,
423450 gpa: Allocator,
424 handle: fs.File,
451 handle: Io.File,
425452 shndx: u32,
426453 target: *const std.Target,
427454) !void {
......@@ -1310,7 +1337,7 @@ fn addString(self: *Object, gpa: Allocator, str: []const u8) !u32 {
13101337}
13111338
13121339/// Caller owns the memory.
1313fn preadShdrContentsAlloc(self: Object, gpa: Allocator, handle: fs.File, index: u32) ![]u8 {
1340fn preadShdrContentsAlloc(self: Object, gpa: Allocator, handle: Io.File, index: u32) ![]u8 {
13141341 assert(index < self.shdrs.items.len);
13151342 const offset = if (self.archive) |ar| ar.offset else 0;
13161343 const shdr = self.shdrs.items[index];
......@@ -1320,7 +1347,7 @@ fn preadShdrContentsAlloc(self: Object, gpa: Allocator, handle: fs.File, index:
13201347}
13211348
13221349/// Caller owns the memory.
1323fn preadRelocsAlloc(self: Object, gpa: Allocator, handle: fs.File, shndx: u32) ![]align(1) const elf.Elf64_Rela {
1350fn preadRelocsAlloc(self: Object, gpa: Allocator, handle: Io.File, shndx: u32) ![]align(1) const elf.Elf64_Rela {
13241351 const raw = try self.preadShdrContentsAlloc(gpa, handle, shndx);
13251352 const num = @divExact(raw.len, @sizeOf(elf.Elf64_Rela));
13261353 return @as([*]align(1) const elf.Elf64_Rela, @ptrCast(raw.ptr))[0..num];
......@@ -1552,29 +1579,3 @@ const InArchive = struct {
15521579 offset: u64,
15531580 size: u32,
15541581};
1555
1556const Object = @This();
1557
1558const std = @import("std");
1559const assert = std.debug.assert;
1560const eh_frame = @import("eh_frame.zig");
1561const elf = std.elf;
1562const fs = std.fs;
1563const log = std.log.scoped(.link);
1564const math = std.math;
1565const mem = std.mem;
1566const Path = std.Build.Cache.Path;
1567const Allocator = std.mem.Allocator;
1568
1569const Diags = @import("../../link.zig").Diags;
1570const Archive = @import("Archive.zig");
1571const Atom = @import("Atom.zig");
1572const AtomList = @import("AtomList.zig");
1573const Cie = eh_frame.Cie;
1574const Elf = @import("../Elf.zig");
1575const Fde = eh_frame.Fde;
1576const File = @import("file.zig").File;
1577const Merge = @import("Merge.zig");
1578const Symbol = @import("Symbol.zig");
1579const Alignment = Atom.Alignment;
1580const riscv = @import("../riscv.zig");
src/link/Elf/SharedObject.zig+19-18
......@@ -1,3 +1,20 @@
1const SharedObject = @This();
2
3const std = @import("std");
4const Io = std.Io;
5const assert = std.debug.assert;
6const elf = std.elf;
7const log = std.log.scoped(.elf);
8const mem = std.mem;
9const Path = std.Build.Cache.Path;
10const Stat = std.Build.Cache.File.Stat;
11const Allocator = mem.Allocator;
12
13const Elf = @import("../Elf.zig");
14const File = @import("file.zig").File;
15const Symbol = @import("Symbol.zig");
16const Diags = @import("../../link.zig").Diags;
17
118path: Path,
219index: File.Index,
320
......@@ -94,7 +111,7 @@ pub fn parseHeader(
94111 gpa: Allocator,
95112 diags: *Diags,
96113 file_path: Path,
97 fs_file: std.fs.File,
114 fs_file: Io.File,
98115 stat: Stat,
99116 target: *const std.Target,
100117) !Header {
......@@ -192,7 +209,7 @@ pub fn parse(
192209 gpa: Allocator,
193210 /// Moves resources from header. Caller may unconditionally deinit.
194211 header: *Header,
195 fs_file: std.fs.File,
212 fs_file: Io.File,
196213) !Parsed {
197214 const symtab = if (header.dynsym_sect_index) |index| st: {
198215 const shdr = header.sections[index];
......@@ -534,19 +551,3 @@ const Format = struct {
534551 }
535552 }
536553};
537
538const SharedObject = @This();
539
540const std = @import("std");
541const assert = std.debug.assert;
542const elf = std.elf;
543const log = std.log.scoped(.elf);
544const mem = std.mem;
545const Path = std.Build.Cache.Path;
546const Stat = std.Build.Cache.File.Stat;
547const Allocator = mem.Allocator;
548
549const Elf = @import("../Elf.zig");
550const File = @import("file.zig").File;
551const Symbol = @import("Symbol.zig");
552const Diags = @import("../../link.zig").Diags;
src/link/Elf/file.zig+18-17
......@@ -1,3 +1,20 @@
1const std = @import("std");
2const Io = std.Io;
3const elf = std.elf;
4const log = std.log.scoped(.link);
5const Path = std.Build.Cache.Path;
6const Allocator = std.mem.Allocator;
7
8const Archive = @import("Archive.zig");
9const Atom = @import("Atom.zig");
10const Cie = @import("eh_frame.zig").Cie;
11const Elf = @import("../Elf.zig");
12const LinkerDefined = @import("LinkerDefined.zig");
13const Object = @import("Object.zig");
14const SharedObject = @import("SharedObject.zig");
15const Symbol = @import("Symbol.zig");
16const ZigObject = @import("ZigObject.zig");
17
118pub const File = union(enum) {
219 zig_object: *ZigObject,
320 linker_defined: *LinkerDefined,
......@@ -279,22 +296,6 @@ pub const File = union(enum) {
279296 shared_object: SharedObject,
280297 };
281298
282 pub const Handle = std.fs.File;
299 pub const Handle = Io.File;
283300 pub const HandleIndex = Index;
284301};
285
286const std = @import("std");
287const elf = std.elf;
288const log = std.log.scoped(.link);
289const Path = std.Build.Cache.Path;
290const Allocator = std.mem.Allocator;
291
292const Archive = @import("Archive.zig");
293const Atom = @import("Atom.zig");
294const Cie = @import("eh_frame.zig").Cie;
295const Elf = @import("../Elf.zig");
296const LinkerDefined = @import("LinkerDefined.zig");
297const Object = @import("Object.zig");
298const SharedObject = @import("SharedObject.zig");
299const Symbol = @import("Symbol.zig");
300const ZigObject = @import("ZigObject.zig");
src/link/Elf2.zig+25-21
......@@ -1,3 +1,23 @@
1const Elf = @This();
2
3const builtin = @import("builtin");
4const native_endian = builtin.cpu.arch.endian();
5
6const std = @import("std");
7const Io = std.Io;
8const assert = std.debug.assert;
9const log = std.log.scoped(.link);
10
11const codegen = @import("../codegen.zig");
12const Compilation = @import("../Compilation.zig");
13const InternPool = @import("../InternPool.zig");
14const link = @import("../link.zig");
15const MappedFile = @import("MappedFile.zig");
16const target_util = @import("../target.zig");
17const Type = @import("../Type.zig");
18const Value = @import("../Value.zig");
19const Zcu = @import("../Zcu.zig");
20
121base: link.File,
222options: link.File.OpenOptions,
323mf: MappedFile,
......@@ -1973,8 +1993,8 @@ pub fn lazySymbol(elf: *Elf, lazy: link.File.LazySymbol) !Symbol.Index {
19731993 return lazy_gop.value_ptr.*;
19741994}
19751995
1976pub fn loadInput(elf: *Elf, input: link.Input) (std.fs.File.Reader.SizeError ||
1977 std.Io.File.Reader.Error || MappedFile.Error || error{ EndOfStream, BadMagic, LinkFailure })!void {
1996pub fn loadInput(elf: *Elf, input: link.Input) (Io.File.Reader.SizeError ||
1997 Io.File.Reader.Error || MappedFile.Error || error{ EndOfStream, BadMagic, LinkFailure })!void {
19781998 const io = elf.base.comp.io;
19791999 var buf: [4096]u8 = undefined;
19802000 switch (input) {
......@@ -2007,7 +2027,7 @@ pub fn loadInput(elf: *Elf, input: link.Input) (std.fs.File.Reader.SizeError ||
20072027 .dso_exact => |dso_exact| try elf.loadDsoExact(dso_exact.name),
20082028 }
20092029}
2010fn loadArchive(elf: *Elf, path: std.Build.Cache.Path, fr: *std.Io.File.Reader) !void {
2030fn loadArchive(elf: *Elf, path: std.Build.Cache.Path, fr: *Io.File.Reader) !void {
20112031 const comp = elf.base.comp;
20122032 const gpa = comp.gpa;
20132033 const diags = &comp.link_diags;
......@@ -2067,7 +2087,7 @@ fn loadObject(
20672087 elf: *Elf,
20682088 path: std.Build.Cache.Path,
20692089 member: ?[]const u8,
2070 fr: *std.Io.File.Reader,
2090 fr: *Io.File.Reader,
20712091 fl: MappedFile.Node.FileLocation,
20722092) !void {
20732093 const comp = elf.base.comp;
......@@ -2310,7 +2330,7 @@ fn loadObject(
23102330 },
23112331 }
23122332}
2313fn loadDso(elf: *Elf, path: std.Build.Cache.Path, fr: *std.Io.File.Reader) !void {
2333fn loadDso(elf: *Elf, path: std.Build.Cache.Path, fr: *Io.File.Reader) !void {
23142334 const comp = elf.base.comp;
23152335 const diags = &comp.link_diags;
23162336 const r = &fr.interface;
......@@ -3822,19 +3842,3 @@ pub fn printNode(
38223842 try w.writeByte('\n');
38233843 }
38243844}
3825
3826const assert = std.debug.assert;
3827const builtin = @import("builtin");
3828const codegen = @import("../codegen.zig");
3829const Compilation = @import("../Compilation.zig");
3830const Elf = @This();
3831const InternPool = @import("../InternPool.zig");
3832const link = @import("../link.zig");
3833const log = std.log.scoped(.link);
3834const MappedFile = @import("MappedFile.zig");
3835const native_endian = builtin.cpu.arch.endian();
3836const std = @import("std");
3837const target_util = @import("../target.zig");
3838const Type = @import("../Type.zig");
3839const Value = @import("../Value.zig");
3840const Zcu = @import("../Zcu.zig");
src/link/MachO.zig+12-11
......@@ -890,7 +890,7 @@ pub fn classifyInputFile(self: *MachO, input: link.Input) !void {
890890 _ = try self.addTbd(.fromLinkInput(input), true, fh);
891891}
892892
893fn parseFatFile(self: *MachO, file: std.fs.File, path: Path) !?fat.Arch {
893fn parseFatFile(self: *MachO, file: Io.File, path: Path) !?fat.Arch {
894894 const diags = &self.base.comp.link_diags;
895895 const fat_h = fat.readFatHeader(file) catch return null;
896896 if (fat_h.magic != macho.FAT_MAGIC and fat_h.magic != macho.FAT_MAGIC_64) return null;
......@@ -903,7 +903,7 @@ fn parseFatFile(self: *MachO, file: std.fs.File, path: Path) !?fat.Arch {
903903 return diags.failParse(path, "missing arch in universal file: expected {s}", .{@tagName(cpu_arch)});
904904}
905905
906pub fn readMachHeader(file: std.fs.File, offset: usize) !macho.mach_header_64 {
906pub fn readMachHeader(file: Io.File, offset: usize) !macho.mach_header_64 {
907907 var buffer: [@sizeOf(macho.mach_header_64)]u8 = undefined;
908908 const nread = try file.preadAll(&buffer, offset);
909909 if (nread != buffer.len) return error.InputOutput;
......@@ -911,7 +911,7 @@ pub fn readMachHeader(file: std.fs.File, offset: usize) !macho.mach_header_64 {
911911 return hdr;
912912}
913913
914pub fn readArMagic(file: std.fs.File, offset: usize, buffer: *[Archive.SARMAG]u8) ![]const u8 {
914pub fn readArMagic(file: Io.File, offset: usize, buffer: *[Archive.SARMAG]u8) ![]const u8 {
915915 const nread = try file.preadAll(buffer, offset);
916916 if (nread != buffer.len) return error.InputOutput;
917917 return buffer[0..Archive.SARMAG];
......@@ -3768,7 +3768,7 @@ pub fn getInternalObject(self: *MachO) ?*InternalObject {
37683768 return self.getFile(index).?.internal;
37693769}
37703770
3771pub fn addFileHandle(self: *MachO, file: fs.File) !File.HandleIndex {
3771pub fn addFileHandle(self: *MachO, file: Io.File) !File.HandleIndex {
37723772 const gpa = self.base.comp.gpa;
37733773 const index: File.HandleIndex = @intCast(self.file_handles.items.len);
37743774 const fh = try self.file_handles.addOne(gpa);
......@@ -5373,10 +5373,11 @@ const max_distance = (1 << (jump_bits - 1));
53735373const max_allowed_distance = max_distance - 0x500_000;
53745374
53755375const MachO = @This();
5376
5377const std = @import("std");
53785376const build_options = @import("build_options");
53795377const builtin = @import("builtin");
5378
5379const std = @import("std");
5380const Io = std.Io;
53805381const assert = std.debug.assert;
53815382const fs = std.fs;
53825383const log = std.log.scoped(.link);
......@@ -5386,6 +5387,11 @@ const math = std.math;
53865387const mem = std.mem;
53875388const meta = std.meta;
53885389const Writer = std.Io.Writer;
5390const AtomicBool = std.atomic.Value(bool);
5391const Cache = std.Build.Cache;
5392const Hash = std.hash.Wyhash;
5393const Md5 = std.crypto.hash.Md5;
5394const Allocator = std.mem.Allocator;
53895395
53905396const aarch64 = codegen.aarch64.encoding;
53915397const bind = @import("MachO/dyld_info/bind.zig");
......@@ -5403,11 +5409,8 @@ const trace = @import("../tracy.zig").trace;
54035409const synthetic = @import("MachO/synthetic.zig");
54045410
54055411const Alignment = Atom.Alignment;
5406const Allocator = mem.Allocator;
54075412const Archive = @import("MachO/Archive.zig");
5408const AtomicBool = std.atomic.Value(bool);
54095413const Bind = bind.Bind;
5410const Cache = std.Build.Cache;
54115414const CodeSignature = @import("MachO/CodeSignature.zig");
54125415const Compilation = @import("../Compilation.zig");
54135416const DataInCode = synthetic.DataInCode;
......@@ -5417,14 +5420,12 @@ const ExportTrie = @import("MachO/dyld_info/Trie.zig");
54175420const Path = Cache.Path;
54185421const File = @import("MachO/file.zig").File;
54195422const GotSection = synthetic.GotSection;
5420const Hash = std.hash.Wyhash;
54215423const Indsymtab = synthetic.Indsymtab;
54225424const InternalObject = @import("MachO/InternalObject.zig");
54235425const ObjcStubsSection = synthetic.ObjcStubsSection;
54245426const Object = @import("MachO/Object.zig");
54255427const LazyBind = bind.LazyBind;
54265428const LaSymbolPtrSection = synthetic.LaSymbolPtrSection;
5427const Md5 = std.crypto.hash.Md5;
54285429const Zcu = @import("../Zcu.zig");
54295430const InternPool = @import("../InternPool.zig");
54305431const Rebase = @import("MachO/dyld_info/Rebase.zig");
src/link/MachO/CodeSignature.zig+5-3
......@@ -1,17 +1,19 @@
11const CodeSignature = @This();
22
33const std = @import("std");
4const Io = std.Io;
45const assert = std.debug.assert;
56const fs = std.fs;
67const log = std.log.scoped(.link);
78const macho = std.macho;
89const mem = std.mem;
910const testing = std.testing;
11const Sha256 = std.crypto.hash.sha2.Sha256;
12const Allocator = std.mem.Allocator;
13
1014const trace = @import("../../tracy.zig").trace;
11const Allocator = mem.Allocator;
1215const Hasher = @import("hasher.zig").ParallelHasher;
1316const MachO = @import("../MachO.zig");
14const Sha256 = std.crypto.hash.sha2.Sha256;
1517
1618const hash_size = Sha256.digest_length;
1719
......@@ -250,7 +252,7 @@ pub fn addEntitlements(self: *CodeSignature, allocator: Allocator, path: []const
250252}
251253
252254pub const WriteOpts = struct {
253 file: fs.File,
255 file: Io.File,
254256 exec_seg_base: u64,
255257 exec_seg_limit: u64,
256258 file_size: u32,
src/link/MachO/fat.zig+7-5
......@@ -1,18 +1,20 @@
1const builtin = @import("builtin");
2const native_endian = builtin.target.cpu.arch.endian();
3
14const std = @import("std");
5const Io = std.Io;
26const assert = std.debug.assert;
3const builtin = @import("builtin");
47const log = std.log.scoped(.macho);
58const macho = std.macho;
69const mem = std.mem;
7const native_endian = builtin.target.cpu.arch.endian();
810
911const MachO = @import("../MachO.zig");
1012
11pub fn readFatHeader(file: std.fs.File) !macho.fat_header {
13pub fn readFatHeader(file: Io.File) !macho.fat_header {
1214 return readFatHeaderGeneric(macho.fat_header, file, 0);
1315}
1416
15fn readFatHeaderGeneric(comptime Hdr: type, file: std.fs.File, offset: usize) !Hdr {
17fn readFatHeaderGeneric(comptime Hdr: type, file: Io.File, offset: usize) !Hdr {
1618 var buffer: [@sizeOf(Hdr)]u8 = undefined;
1719 const nread = try file.preadAll(&buffer, offset);
1820 if (nread != buffer.len) return error.InputOutput;
......@@ -27,7 +29,7 @@ pub const Arch = struct {
2729 size: u32,
2830};
2931
30pub fn parseArchs(file: std.fs.File, fat_header: macho.fat_header, out: *[2]Arch) ![]const Arch {
32pub fn parseArchs(file: Io.File, fat_header: macho.fat_header, out: *[2]Arch) ![]const Arch {
3133 var count: usize = 0;
3234 var fat_arch_index: u32 = 0;
3335 while (fat_arch_index < fat_header.nfat_arch and count < out.len) : (fat_arch_index += 1) {
src/link/MachO/file.zig+2-1
......@@ -355,11 +355,12 @@ pub const File = union(enum) {
355355 dylib: Dylib,
356356 };
357357
358 pub const Handle = std.fs.File;
358 pub const Handle = Io.File;
359359 pub const HandleIndex = Index;
360360};
361361
362362const std = @import("std");
363const Io = std.Io;
363364const assert = std.debug.assert;
364365const log = std.log.scoped(.link);
365366const macho = std.macho;
src/link/MachO/hasher.zig+10-12
......@@ -1,3 +1,9 @@
1const std = @import("std");
2const Io = std.Io;
3const Allocator = std.mem.Allocator;
4
5const trace = @import("../../tracy.zig").trace;
6
17pub fn ParallelHasher(comptime Hasher: type) type {
28 const hash_size = Hasher.digest_length;
39
......@@ -5,7 +11,7 @@ pub fn ParallelHasher(comptime Hasher: type) type {
511 allocator: Allocator,
612 io: std.Io,
713
8 pub fn hash(self: Self, file: fs.File, out: [][hash_size]u8, opts: struct {
14 pub fn hash(self: Self, file: Io.File, out: [][hash_size]u8, opts: struct {
915 chunk_size: u64 = 0x4000,
1016 max_file_size: ?u64 = null,
1117 }) !void {
......@@ -23,7 +29,7 @@ pub fn ParallelHasher(comptime Hasher: type) type {
2329 const buffer = try self.allocator.alloc(u8, chunk_size * out.len);
2430 defer self.allocator.free(buffer);
2531
26 const results = try self.allocator.alloc(fs.File.PReadError!usize, out.len);
32 const results = try self.allocator.alloc(Io.File.PReadError!usize, out.len);
2733 defer self.allocator.free(results);
2834
2935 {
......@@ -51,11 +57,11 @@ pub fn ParallelHasher(comptime Hasher: type) type {
5157 }
5258
5359 fn worker(
54 file: fs.File,
60 file: Io.File,
5561 fstart: usize,
5662 buffer: []u8,
5763 out: *[hash_size]u8,
58 err: *fs.File.PReadError!usize,
64 err: *Io.File.PReadError!usize,
5965 ) void {
6066 const tracy = trace(@src());
6167 defer tracy.end();
......@@ -66,11 +72,3 @@ pub fn ParallelHasher(comptime Hasher: type) type {
6672 const Self = @This();
6773 };
6874}
69
70const assert = std.debug.assert;
71const fs = std.fs;
72const mem = std.mem;
73const std = @import("std");
74const trace = @import("../../tracy.zig").trace;
75
76const Allocator = mem.Allocator;
src/link/MachO/uuid.zig+9-10
......@@ -1,10 +1,18 @@
1const std = @import("std");
2const Io = std.Io;
3const Md5 = std.crypto.hash.Md5;
4
5const trace = @import("../../tracy.zig").trace;
6const Compilation = @import("../../Compilation.zig");
7const Hasher = @import("hasher.zig").ParallelHasher;
8
19/// Calculates Md5 hash of each chunk in parallel and then hashes all Md5 hashes to produce
210/// the final digest.
311/// While this is NOT a correct MD5 hash of the contents, this methodology is used by LLVM/LLD
412/// and we will use it too as it seems accepted by Apple OSes.
513/// TODO LLD also hashes the output filename to disambiguate between same builds with different
614/// output files. Should we also do that?
7pub fn calcUuid(comp: *const Compilation, file: fs.File, file_size: u64, out: *[Md5.digest_length]u8) !void {
15pub fn calcUuid(comp: *const Compilation, file: Io.File, file_size: u64, out: *[Md5.digest_length]u8) !void {
816 const tracy = trace(@src());
917 defer tracy.end();
1018
......@@ -37,12 +45,3 @@ inline fn conform(out: *[Md5.digest_length]u8) void {
3745 out[6] = (out[6] & 0x0F) | (3 << 4);
3846 out[8] = (out[8] & 0x3F) | 0x80;
3947}
40
41const fs = std.fs;
42const mem = std.mem;
43const std = @import("std");
44const trace = @import("../../tracy.zig").trace;
45
46const Compilation = @import("../../Compilation.zig");
47const Md5 = std.crypto.hash.Md5;
48const Hasher = @import("hasher.zig").ParallelHasher;
src/link/MappedFile.zig+14-11
......@@ -1,3 +1,15 @@
1const MappedFile = @This();
2
3const builtin = @import("builtin");
4const is_linux = builtin.os.tag == .linux;
5const is_windows = builtin.os.tag == .windows;
6
7const std = @import("std");
8const Io = std.Io;
9const assert = std.debug.assert;
10const linux = std.os.linux;
11const windows = std.os.windows;
12
113file: std.Io.File,
214flags: packed struct {
315 block_size: std.mem.Alignment,
......@@ -16,7 +28,7 @@ writers: std.SinglyLinkedList,
1628
1729pub const growth_factor = 4;
1830
19pub const Error = std.posix.MMapError || std.posix.MRemapError || std.fs.File.SetEndPosError || error{
31pub const Error = std.posix.MMapError || std.posix.MRemapError || Io.File.SetEndPosError || error{
2032 NotFile,
2133 SystemResources,
2234 IsDir,
......@@ -618,7 +630,7 @@ fn resizeNode(mf: *MappedFile, gpa: std.mem.Allocator, ni: Node.Index, requested
618630 // Resize the entire file
619631 if (ni == Node.Index.root) {
620632 try mf.ensureCapacityForSetLocation(gpa);
621 try std.fs.File.adaptFromNewApi(mf.file).setEndPos(new_size);
633 try Io.File.adaptFromNewApi(mf.file).setEndPos(new_size);
622634 try mf.ensureTotalCapacity(@intCast(new_size));
623635 ni.setLocationAssumeCapacity(mf, old_offset, new_size);
624636 return;
......@@ -1059,12 +1071,3 @@ fn verifyNode(mf: *MappedFile, parent_ni: Node.Index) void {
10591071 ni = node.next;
10601072 }
10611073}
1062
1063const assert = std.debug.assert;
1064const builtin = @import("builtin");
1065const is_linux = builtin.os.tag == .linux;
1066const is_windows = builtin.os.tag == .windows;
1067const linux = std.os.linux;
1068const MappedFile = @This();
1069const std = @import("std");
1070const windows = std.os.windows;
src/link/Wasm.zig+3-2
......@@ -20,6 +20,7 @@ const native_endian = builtin.cpu.arch.endian();
2020const build_options = @import("build_options");
2121
2222const std = @import("std");
23const Io = std.Io;
2324const Allocator = std.mem.Allocator;
2425const Cache = std.Build.Cache;
2526const Path = Cache.Path;
......@@ -3001,9 +3002,9 @@ pub fn createEmpty(
30013002 .read = true,
30023003 .mode = if (fs.has_executable_bit)
30033004 if (target.os.tag == .wasi and output_mode == .Exe)
3004 fs.File.default_mode | 0b001_000_000
3005 Io.File.default_mode | 0b001_000_000
30053006 else
3006 fs.File.default_mode
3007 Io.File.default_mode
30073008 else
30083009 0,
30093010 });
src/link/tapi.zig+5-5
......@@ -1,10 +1,10 @@
11const std = @import("std");
2const fs = std.fs;
2const Io = std.Io;
33const mem = std.mem;
44const log = std.log.scoped(.tapi);
5const yaml = @import("tapi/yaml.zig");
5const Allocator = std.mem.Allocator;
66
7const Allocator = mem.Allocator;
7const yaml = @import("tapi/yaml.zig");
88const Yaml = yaml.Yaml;
99
1010const VersionField = union(enum) {
......@@ -130,7 +130,7 @@ pub const Tbd = union(enum) {
130130pub const TapiError = error{
131131 NotLibStub,
132132 InputOutput,
133} || yaml.YamlError || std.fs.File.PReadError;
133} || yaml.YamlError || Io.File.PReadError;
134134
135135pub const LibStub = struct {
136136 /// Underlying memory for stub's contents.
......@@ -139,7 +139,7 @@ pub const LibStub = struct {
139139 /// Typed contents of the tbd file.
140140 inner: []Tbd,
141141
142 pub fn loadFromFile(allocator: Allocator, file: fs.File) TapiError!LibStub {
142 pub fn loadFromFile(allocator: Allocator, file: Io.File) TapiError!LibStub {
143143 const filesize = blk: {
144144 const stat = file.stat() catch break :blk std.math.maxInt(u32);
145145 break :blk @min(stat.size, std.math.maxInt(u32));