| author | |
| committer | |
| log | 3204fb756980c19b7a95534acdd7a1bba837fbc3 |
| tree | 45b5525ead2923de83ea85eacca351da64d55c46 |
| parent | 1b1fb7fab623e40f4ddc24d7b5ef7e48949e8a17 |
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 |
| 1646 | 1646 | return comp.addSourceFromFile(file, path, kind); |
| 1647 | 1647 | } |
| 1648 | 1648 | |
| 1649 | pub fn addSourceFromFile(comp: *Compilation, file: std.fs.File, path: []const u8, kind: Source.Kind) !Source { | |
| 1649 | pub fn addSourceFromFile(comp: *Compilation, file: Io.File, path: []const u8, kind: Source.Kind) !Source { | |
| 1650 | 1650 | const contents = try comp.getFileContents(file, .unlimited); |
| 1651 | 1651 | errdefer comp.gpa.free(contents); |
| 1652 | 1652 | return comp.addSourceFromOwnedBuffer(path, contents, kind); |
| ... | ... | @@ -1980,7 +1980,7 @@ fn getPathContents(comp: *Compilation, path: []const u8, limit: Io.Limit) ![]u8 |
| 1980 | 1980 | return comp.getFileContents(file, limit); |
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | fn getFileContents(comp: *Compilation, file: std.fs.File, limit: Io.Limit) ![]u8 { | |
| 1983 | fn getFileContents(comp: *Compilation, file: Io.File, limit: Io.Limit) ![]u8 { | |
| 1984 | 1984 | var file_buf: [4096]u8 = undefined; |
| 1985 | 1985 | var file_reader = file.reader(comp.io, &file_buf); |
| 1986 | 1986 |
lib/compiler/aro/aro/Driver.zig+8-7| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const mem = std.mem; |
| 3 | 4 | const Allocator = mem.Allocator; |
| 4 | 5 | const process = std.process; |
| ... | ... | @@ -1061,7 +1062,7 @@ pub fn printDiagnosticsStats(d: *Driver) void { |
| 1061 | 1062 | } |
| 1062 | 1063 | } |
| 1063 | 1064 | |
| 1064 | pub fn detectConfig(d: *Driver, file: std.fs.File) std.Io.tty.Config { | |
| 1065 | pub fn detectConfig(d: *Driver, file: Io.File) std.Io.tty.Config { | |
| 1065 | 1066 | if (d.diagnostics.color == false) return .no_color; |
| 1066 | 1067 | const force_color = d.diagnostics.color == true; |
| 1067 | 1068 | |
| ... | ... | @@ -1109,7 +1110,7 @@ pub fn main(d: *Driver, tc: *Toolchain, args: []const []const u8, comptime fast_ |
| 1109 | 1110 | defer macro_buf.deinit(d.comp.gpa); |
| 1110 | 1111 | |
| 1111 | 1112 | 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); | |
| 1113 | 1114 | if (parseArgs(d, &stdout.interface, &macro_buf, args) catch |er| switch (er) { |
| 1114 | 1115 | error.WriteFailed => return d.fatal("failed to write to stdout: {s}", .{errorDescription(er)}), |
| 1115 | 1116 | error.OutOfMemory => return error.OutOfMemory, |
| ... | ... | @@ -1329,7 +1330,7 @@ fn processSource( |
| 1329 | 1330 | d.comp.cwd.createFile(path, .{}) catch |er| |
| 1330 | 1331 | return d.fatal("unable to create dependency file '{s}': {s}", .{ path, errorDescription(er) }) |
| 1331 | 1332 | else |
| 1332 | std.fs.File.stdout(); | |
| 1333 | Io.File.stdout(); | |
| 1333 | 1334 | defer if (dep_file_name != null) file.close(io); |
| 1334 | 1335 | |
| 1335 | 1336 | var file_writer = file.writer(&writer_buf); |
| ... | ... | @@ -1354,7 +1355,7 @@ fn processSource( |
| 1354 | 1355 | d.comp.cwd.createFile(some, .{}) catch |er| |
| 1355 | 1356 | return d.fatal("unable to create output file '{s}': {s}", .{ some, errorDescription(er) }) |
| 1356 | 1357 | else |
| 1357 | std.fs.File.stdout(); | |
| 1358 | Io.File.stdout(); | |
| 1358 | 1359 | defer if (d.output_name != null) file.close(io); |
| 1359 | 1360 | |
| 1360 | 1361 | var file_writer = file.writer(&writer_buf); |
| ... | ... | @@ -1369,7 +1370,7 @@ fn processSource( |
| 1369 | 1370 | defer tree.deinit(); |
| 1370 | 1371 | |
| 1371 | 1372 | if (d.verbose_ast) { |
| 1372 | var stdout = std.fs.File.stdout().writer(&writer_buf); | |
| 1373 | var stdout = Io.File.stdout().writer(&writer_buf); | |
| 1373 | 1374 | tree.dump(d.detectConfig(stdout.file), &stdout.interface) catch {}; |
| 1374 | 1375 | } |
| 1375 | 1376 | |
| ... | ... | @@ -1433,7 +1434,7 @@ fn processSource( |
| 1433 | 1434 | defer ir.deinit(gpa); |
| 1434 | 1435 | |
| 1435 | 1436 | if (d.verbose_ir) { |
| 1436 | var stdout = std.fs.File.stdout().writer(&writer_buf); | |
| 1437 | var stdout = Io.File.stdout().writer(&writer_buf); | |
| 1437 | 1438 | ir.dump(gpa, d.detectConfig(stdout.file), &stdout.interface) catch {}; |
| 1438 | 1439 | } |
| 1439 | 1440 | |
| ... | ... | @@ -1499,7 +1500,7 @@ pub fn invokeLinker(d: *Driver, tc: *Toolchain, comptime fast_exit: bool) Compil |
| 1499 | 1500 | |
| 1500 | 1501 | if (d.verbose_linker_args) { |
| 1501 | 1502 | 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); | |
| 1503 | 1504 | dumpLinkerArgs(&stdout.interface, argv.items) catch { |
| 1504 | 1505 | return d.fatal("unable to dump linker args: {s}", .{errorDescription(stdout.err.?)}); |
| 1505 | 1506 | }; |
lib/compiler/aro/aro/Preprocessor.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const mem = std.mem; |
| 3 | 4 | const Allocator = mem.Allocator; |
| 4 | 5 | const assert = std.debug.assert; |
| ... | ... | @@ -1068,7 +1069,7 @@ fn verboseLog(pp: *Preprocessor, raw: RawToken, comptime fmt: []const u8, args: |
| 1068 | 1069 | const line_col = source.lineCol(.{ .id = raw.source, .line = raw.line, .byte_offset = raw.start }); |
| 1069 | 1070 | |
| 1070 | 1071 | 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); | |
| 1072 | 1073 | const w = &stderr.interface; |
| 1073 | 1074 | |
| 1074 | 1075 | 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 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const Allocator = std.mem.Allocator; |
| 3 | 4 | |
| 4 | 5 | data: []const u8, |
| ... | ... | @@ -11,7 +12,7 @@ pub fn deinit(self: *const Assembly, gpa: Allocator) void { |
| 11 | 12 | gpa.free(self.text); |
| 12 | 13 | } |
| 13 | 14 | |
| 14 | pub fn writeToFile(self: Assembly, file: std.fs.File) !void { | |
| 15 | pub fn writeToFile(self: Assembly, file: Io.File) !void { | |
| 15 | 16 | var file_writer = file.writer(&.{}); |
| 16 | 17 | |
| 17 | 18 | var buffers = [_][]const u8{ self.data, self.text }; |
lib/compiler/aro/main.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const Allocator = mem.Allocator; |
| 3 | 4 | const mem = std.mem; |
| 4 | 5 | const process = std.process; |
| ... | ... | @@ -50,7 +51,7 @@ pub fn main() u8 { |
| 50 | 51 | defer gpa.free(aro_name); |
| 51 | 52 | |
| 52 | 53 | 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); | |
| 54 | 55 | var diagnostics: Diagnostics = .{ |
| 55 | 56 | .output = .{ .to_writer = .{ |
| 56 | 57 | .color = .detect(stderr.file), |
lib/compiler/build_runner.zig+3-3| ... | ... | @@ -7,7 +7,7 @@ const assert = std.debug.assert; |
| 7 | 7 | const fmt = std.fmt; |
| 8 | 8 | const mem = std.mem; |
| 9 | 9 | const process = std.process; |
| 10 | const File = std.fs.File; | |
| 10 | const File = std.Io.File; | |
| 11 | 11 | const Step = std.Build.Step; |
| 12 | 12 | const Watch = std.Build.Watch; |
| 13 | 13 | const WebServer = std.Build.WebServer; |
| ... | ... | @@ -1845,9 +1845,9 @@ fn createModuleDependenciesForStep(step: *Step) Allocator.Error!void { |
| 1845 | 1845 | } |
| 1846 | 1846 | |
| 1847 | 1847 | var stdio_buffer_allocation: [256]u8 = undefined; |
| 1848 | var stdout_writer_allocation: std.fs.File.Writer = undefined; | |
| 1848 | var stdout_writer_allocation: Io.File.Writer = undefined; | |
| 1849 | 1849 | |
| 1850 | 1850 | fn 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); | |
| 1852 | 1852 | return &stdout_writer_allocation.interface; |
| 1853 | 1853 | } |
lib/compiler/libc.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const mem = std.mem; |
| 3 | 4 | const LibCInstallation = std.zig.LibCInstallation; |
| 4 | 5 | |
| ... | ... | @@ -39,7 +40,7 @@ pub fn main() !void { |
| 39 | 40 | var input_file: ?[]const u8 = null; |
| 40 | 41 | var target_arch_os_abi: []const u8 = "native"; |
| 41 | 42 | 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); | |
| 43 | 44 | const stdout = &stdout_writer.interface; |
| 44 | 45 | { |
| 45 | 46 | var i: usize = 2; |
lib/compiler/objcopy.zig+7-6| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | ||
| 2 | 3 | const std = @import("std"); |
| 4 | const Io = std.Io; | |
| 3 | 5 | const mem = std.mem; |
| 4 | 6 | const fs = std.fs; |
| 5 | 7 | const elf = std.elf; |
| 6 | 8 | const Allocator = std.mem.Allocator; |
| 7 | const File = std.fs.File; | |
| 9 | const File = std.Io.File; | |
| 8 | 10 | const assert = std.debug.assert; |
| 9 | ||
| 10 | 11 | const fatal = std.process.fatal; |
| 11 | 12 | const Server = std.zig.Server; |
| 12 | 13 | |
| ... | ... | @@ -56,7 +57,7 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void |
| 56 | 57 | fatal("unexpected positional argument: '{s}'", .{arg}); |
| 57 | 58 | } |
| 58 | 59 | } 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); | |
| 60 | 61 | } else if (mem.eql(u8, arg, "-O") or mem.eql(u8, arg, "--output-target")) { |
| 61 | 62 | i += 1; |
| 62 | 63 | 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 |
| 177 | 178 | } |
| 178 | 179 | }; |
| 179 | 180 | |
| 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; | |
| 181 | 182 | |
| 182 | 183 | var output_file = try fs.cwd().createFile(output, .{ .mode = mode }); |
| 183 | 184 | defer output_file.close(io); |
| ... | ... | @@ -221,8 +222,8 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void |
| 221 | 222 | try out.end(); |
| 222 | 223 | |
| 223 | 224 | 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); | |
| 226 | 227 | var server = try Server.init(.{ |
| 227 | 228 | .in = &stdin_reader.interface, |
| 228 | 229 | .out = &stdout_writer.interface, |
lib/compiler/reduce.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const mem = std.mem; |
| 3 | 4 | const Allocator = std.mem.Allocator; |
| 4 | 5 | const assert = std.debug.assert; |
| ... | ... | @@ -68,7 +69,7 @@ pub fn main() !void { |
| 68 | 69 | const arg = args[i]; |
| 69 | 70 | if (mem.startsWith(u8, arg, "-")) { |
| 70 | 71 | 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(); | |
| 72 | 73 | try stdout.writeAll(usage); |
| 73 | 74 | return std.process.cleanExit(); |
| 74 | 75 | } else if (mem.eql(u8, arg, "--")) { |
lib/compiler/resinator/cli.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const code_pages = @import("code_pages.zig"); |
| 3 | 4 | const SupportedCodePage = code_pages.SupportedCodePage; |
| 4 | 5 | const lang = @import("lang.zig"); |
| ... | ... | @@ -169,7 +170,7 @@ pub const Options = struct { |
| 169 | 170 | coff_options: cvtres.CoffOptions = .{}, |
| 170 | 171 | |
| 171 | 172 | pub const IoSource = union(enum) { |
| 172 | stdio: std.fs.File, | |
| 173 | stdio: Io.File, | |
| 173 | 174 | filename: []const u8, |
| 174 | 175 | }; |
| 175 | 176 | pub const AutoIncludes = enum { any, msvc, gnu, none }; |
lib/compiler/resinator/errors.zig+4-4| ... | ... | @@ -169,9 +169,9 @@ pub const ErrorDetails = struct { |
| 169 | 169 | filename_string_index: FilenameStringIndex, |
| 170 | 170 | |
| 171 | 171 | 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); | |
| 173 | 173 | |
| 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 { | |
| 175 | 175 | return switch (err) { |
| 176 | 176 | inline else => |e| @field(ErrorDetails.FileOpenError.FileOpenErrorEnum, @errorName(e)), |
| 177 | 177 | }; |
| ... | ... | @@ -1094,8 +1094,8 @@ const CorrespondingLines = struct { |
| 1094 | 1094 | last_byte: u8 = 0, |
| 1095 | 1095 | at_eof: bool = false, |
| 1096 | 1096 | 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, | |
| 1099 | 1099 | code_page: SupportedCodePage, |
| 1100 | 1100 | |
| 1101 | 1101 | pub fn init( |
lib/compiler/resinator/main.zig+5-5| ... | ... | @@ -45,7 +45,7 @@ pub fn main() !void { |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | 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); | |
| 49 | 49 | const stdout = &stdout_writer.interface; |
| 50 | 50 | var error_handler: ErrorHandler = switch (zig_integration) { |
| 51 | 51 | true => .{ |
| ... | ... | @@ -447,8 +447,8 @@ const IoStream = struct { |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | pub const Source = union(enum) { |
| 450 | file: std.fs.File, | |
| 451 | stdio: std.fs.File, | |
| 450 | file: Io.File, | |
| 451 | stdio: Io.File, | |
| 452 | 452 | memory: std.ArrayList(u8), |
| 453 | 453 | /// The source has been closed and any usage of the Source in this state is illegal (except deinit). |
| 454 | 454 | closed: void, |
| ... | ... | @@ -500,10 +500,10 @@ const IoStream = struct { |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | pub const Writer = union(enum) { |
| 503 | file: std.fs.File.Writer, | |
| 503 | file: Io.File.Writer, | |
| 504 | 504 | allocating: std.Io.Writer.Allocating, |
| 505 | 505 | |
| 506 | pub const Error = Allocator.Error || std.fs.File.WriteError; | |
| 506 | pub const Error = Allocator.Error || Io.File.WriteError; | |
| 507 | 507 | |
| 508 | 508 | pub fn interface(this: *@This()) *std.Io.Writer { |
| 509 | 509 | return switch (this.*) { |
lib/compiler/resinator/utils.zig+2-2| ... | ... | @@ -32,8 +32,8 @@ pub fn openFileNotDir( |
| 32 | 32 | cwd: std.fs.Dir, |
| 33 | 33 | io: Io, |
| 34 | 34 | 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 { | |
| 37 | 37 | const file = try cwd.openFile(io, path, flags); |
| 38 | 38 | errdefer file.close(io); |
| 39 | 39 | // https://github.com/ziglang/zig/issues/5732 |
lib/compiler/test_runner.zig+5-5| ... | ... | @@ -74,8 +74,8 @@ pub fn main() void { |
| 74 | 74 | |
| 75 | 75 | fn mainServer() !void { |
| 76 | 76 | @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); | |
| 79 | 79 | var server = try std.zig.Server.init(.{ |
| 80 | 80 | .in = &stdin_reader.interface, |
| 81 | 81 | .out = &stdout_writer.interface, |
| ... | ... | @@ -228,7 +228,7 @@ fn mainTerminal() void { |
| 228 | 228 | .root_name = "Test", |
| 229 | 229 | .estimated_total_items = test_fn_list.len, |
| 230 | 230 | }); |
| 231 | const have_tty = std.fs.File.stderr().isTty(); | |
| 231 | const have_tty = Io.File.stderr().isTty(); | |
| 232 | 232 | |
| 233 | 233 | var leaks: usize = 0; |
| 234 | 234 | for (test_fn_list, 0..) |test_fn, i| { |
| ... | ... | @@ -318,7 +318,7 @@ pub fn log( |
| 318 | 318 | /// work-in-progress backends can handle it. |
| 319 | 319 | pub fn mainSimple() anyerror!void { |
| 320 | 320 | @disableInstrumentation(); |
| 321 | // is the backend capable of calling `std.fs.File.writeAll`? | |
| 321 | // is the backend capable of calling `Io.File.writeAll`? | |
| 322 | 322 | const enable_write = switch (builtin.zig_backend) { |
| 323 | 323 | .stage2_aarch64, .stage2_riscv64 => true, |
| 324 | 324 | else => false, |
| ... | ... | @@ -334,7 +334,7 @@ pub fn mainSimple() anyerror!void { |
| 334 | 334 | var failed: u64 = 0; |
| 335 | 335 | |
| 336 | 336 | // 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 {}; | |
| 338 | 338 | |
| 339 | 339 | for (builtin.test_functions) |test_fn| { |
| 340 | 340 | if (enable_write) { |
lib/compiler/translate-c/main.zig+7-6| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const assert = std.debug.assert; |
| 3 | 4 | const mem = std.mem; |
| 4 | 5 | const process = std.process; |
| ... | ... | @@ -34,7 +35,7 @@ pub fn main() u8 { |
| 34 | 35 | } |
| 35 | 36 | |
| 36 | 37 | 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); | |
| 38 | 39 | var diagnostics: aro.Diagnostics = switch (zig_integration) { |
| 39 | 40 | false => .{ .output = .{ .to_writer = .{ |
| 40 | 41 | .color = .detect(stderr.file), |
| ... | ... | @@ -99,7 +100,7 @@ fn serveErrorBundle(arena: std.mem.Allocator, diagnostics: *const aro.Diagnostic |
| 99 | 100 | "translation failure", |
| 100 | 101 | ); |
| 101 | 102 | 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); | |
| 103 | 104 | var server: std.zig.Server = .{ |
| 104 | 105 | .out = &stdout_writer.interface, |
| 105 | 106 | .in = undefined, |
| ... | ... | @@ -129,13 +130,13 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: [][:0]u8, zig_integration |
| 129 | 130 | args[i] = arg; |
| 130 | 131 | if (mem.eql(u8, arg, "--help")) { |
| 131 | 132 | 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); | |
| 133 | 134 | try stdout.interface.print(usage, .{args[0]}); |
| 134 | 135 | try stdout.interface.flush(); |
| 135 | 136 | return; |
| 136 | 137 | } else if (mem.eql(u8, arg, "--version")) { |
| 137 | 138 | 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); | |
| 139 | 140 | // TODO add version |
| 140 | 141 | try stdout.interface.writeAll("0.0.0-dev\n"); |
| 141 | 142 | try stdout.interface.flush(); |
| ... | ... | @@ -228,7 +229,7 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: [][:0]u8, zig_integration |
| 228 | 229 | d.comp.cwd.createFile(path, .{}) catch |er| |
| 229 | 230 | return d.fatal("unable to create dependency file '{s}': {s}", .{ path, aro.Driver.errorDescription(er) }) |
| 230 | 231 | else |
| 231 | std.fs.File.stdout(); | |
| 232 | Io.File.stdout(); | |
| 232 | 233 | defer if (dep_file_name != null) file.close(io); |
| 233 | 234 | |
| 234 | 235 | var file_writer = file.writer(&out_buf); |
| ... | ... | @@ -246,7 +247,7 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: [][:0]u8, zig_integration |
| 246 | 247 | |
| 247 | 248 | var close_out_file = false; |
| 248 | 249 | var out_file_path: []const u8 = "<stdout>"; |
| 249 | var out_file: std.fs.File = .stdout(); | |
| 250 | var out_file: Io.File = .stdout(); | |
| 250 | 251 | defer if (close_out_file) out_file.close(io); |
| 251 | 252 | |
| 252 | 253 | if (d.output_name) |path| blk: { |
lib/std/Build.zig+3-3| ... | ... | @@ -1,3 +1,4 @@ |
| 1 | const Build = @This(); | |
| 1 | 2 | const builtin = @import("builtin"); |
| 2 | 3 | |
| 3 | 4 | const std = @import("std.zig"); |
| ... | ... | @@ -9,13 +10,12 @@ const panic = std.debug.panic; |
| 9 | 10 | const assert = debug.assert; |
| 10 | 11 | const log = std.log; |
| 11 | 12 | const StringHashMap = std.StringHashMap; |
| 12 | const Allocator = mem.Allocator; | |
| 13 | const Allocator = std.mem.Allocator; | |
| 13 | 14 | const Target = std.Target; |
| 14 | 15 | const process = std.process; |
| 15 | 16 | const EnvMap = std.process.EnvMap; |
| 16 | const File = fs.File; | |
| 17 | const File = std.Io.File; | |
| 17 | 18 | const Sha256 = std.crypto.hash.sha2.Sha256; |
| 18 | const Build = @This(); | |
| 19 | 19 | const ArrayList = std.ArrayList; |
| 20 | 20 | |
| 21 | 21 | pub const Cache = @import("Build/Cache.zig"); |
lib/std/Build/Step.zig+1-1| ... | ... | @@ -667,7 +667,7 @@ fn clearZigProcess(s: *Step, gpa: Allocator) void { |
| 667 | 667 | } |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | fn sendMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag) !void { | |
| 670 | fn sendMessage(file: Io.File, tag: std.zig.Client.Message.Tag) !void { | |
| 671 | 671 | const header: std.zig.Client.Message.Header = .{ |
| 672 | 672 | .tag = tag, |
| 673 | 673 | .bytes_len = 0, |
lib/std/Build/Step/ObjCopy.zig+1-1| ... | ... | @@ -3,7 +3,7 @@ const ObjCopy = @This(); |
| 3 | 3 | |
| 4 | 4 | const Allocator = std.mem.Allocator; |
| 5 | 5 | const ArenaAllocator = std.heap.ArenaAllocator; |
| 6 | const File = std.fs.File; | |
| 6 | const File = std.Io.File; | |
| 7 | 7 | const InstallDir = std.Build.InstallDir; |
| 8 | 8 | const Step = std.Build.Step; |
| 9 | 9 | const elf = std.elf; |
lib/std/Build/Step/Run.zig+11-10| ... | ... | @@ -1,15 +1,16 @@ |
| 1 | const std = @import("std"); | |
| 1 | const Run = @This(); | |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | ||
| 4 | const std = @import("std"); | |
| 5 | const Io = std.Io; | |
| 3 | 6 | const Build = std.Build; |
| 4 | const Step = Build.Step; | |
| 7 | const Step = std.Build.Step; | |
| 5 | 8 | const fs = std.fs; |
| 6 | 9 | const mem = std.mem; |
| 7 | 10 | const process = std.process; |
| 8 | const EnvMap = process.EnvMap; | |
| 11 | const EnvMap = std.process.EnvMap; | |
| 9 | 12 | const assert = std.debug.assert; |
| 10 | const Path = Build.Cache.Path; | |
| 11 | ||
| 12 | const Run = @This(); | |
| 13 | const Path = std.Build.Cache.Path; | |
| 13 | 14 | |
| 14 | 15 | pub const base_id: Step.Id = .run; |
| 15 | 16 | |
| ... | ... | @@ -2095,7 +2096,7 @@ pub const CachedTestMetadata = struct { |
| 2095 | 2096 | } |
| 2096 | 2097 | }; |
| 2097 | 2098 | |
| 2098 | fn requestNextTest(in: fs.File, metadata: *TestMetadata, sub_prog_node: *?std.Progress.Node) !void { | |
| 2099 | fn requestNextTest(in: Io.File, metadata: *TestMetadata, sub_prog_node: *?std.Progress.Node) !void { | |
| 2099 | 2100 | while (metadata.next_index < metadata.names.len) { |
| 2100 | 2101 | const i = metadata.next_index; |
| 2101 | 2102 | metadata.next_index += 1; |
| ... | ... | @@ -2114,7 +2115,7 @@ fn requestNextTest(in: fs.File, metadata: *TestMetadata, sub_prog_node: *?std.Pr |
| 2114 | 2115 | } |
| 2115 | 2116 | } |
| 2116 | 2117 | |
| 2117 | fn sendMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag) !void { | |
| 2118 | fn sendMessage(file: Io.File, tag: std.zig.Client.Message.Tag) !void { | |
| 2118 | 2119 | const header: std.zig.Client.Message.Header = .{ |
| 2119 | 2120 | .tag = tag, |
| 2120 | 2121 | .bytes_len = 0, |
| ... | ... | @@ -2125,7 +2126,7 @@ fn sendMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag) !void { |
| 2125 | 2126 | }; |
| 2126 | 2127 | } |
| 2127 | 2128 | |
| 2128 | fn sendRunTestMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag, index: u32) !void { | |
| 2129 | fn sendRunTestMessage(file: Io.File, tag: std.zig.Client.Message.Tag, index: u32) !void { | |
| 2129 | 2130 | const header: std.zig.Client.Message.Header = .{ |
| 2130 | 2131 | .tag = tag, |
| 2131 | 2132 | .bytes_len = 4, |
| ... | ... | @@ -2140,7 +2141,7 @@ fn sendRunTestMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag, index: |
| 2140 | 2141 | } |
| 2141 | 2142 | |
| 2142 | 2143 | fn sendRunFuzzTestMessage( |
| 2143 | file: std.fs.File, | |
| 2144 | file: Io.File, | |
| 2144 | 2145 | index: u32, |
| 2145 | 2146 | kind: std.Build.abi.fuzz.LimitKind, |
| 2146 | 2147 | amount_or_instance: u64, |
lib/std/Io.zig+1-1| ... | ... | @@ -528,7 +528,7 @@ pub fn Poller(comptime StreamEnum: type) type { |
| 528 | 528 | /// Given an enum, returns a struct with fields of that enum, each field |
| 529 | 529 | /// representing an I/O stream for polling. |
| 530 | 530 | pub 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(.{})); | |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | test { |
lib/std/Io/Writer.zig+5-4| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | const Writer = @This(); | |
| 2 | ||
| 1 | 3 | const builtin = @import("builtin"); |
| 2 | 4 | const native_endian = builtin.target.cpu.arch.endian(); |
| 3 | 5 | |
| 4 | const Writer = @This(); | |
| 5 | 6 | const std = @import("../std.zig"); |
| 6 | 7 | const assert = std.debug.assert; |
| 7 | 8 | const Limit = std.Io.Limit; |
| ... | ... | @@ -2837,7 +2838,7 @@ test "discarding sendFile" { |
| 2837 | 2838 | const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true }); |
| 2838 | 2839 | defer file.close(io); |
| 2839 | 2840 | 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); | |
| 2841 | 2842 | try file_writer.interface.writeByte('h'); |
| 2842 | 2843 | try file_writer.interface.flush(); |
| 2843 | 2844 | |
| ... | ... | @@ -2859,7 +2860,7 @@ test "allocating sendFile" { |
| 2859 | 2860 | const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true }); |
| 2860 | 2861 | defer file.close(io); |
| 2861 | 2862 | 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); | |
| 2863 | 2864 | try file_writer.interface.writeAll("abcd"); |
| 2864 | 2865 | try file_writer.interface.flush(); |
| 2865 | 2866 | |
| ... | ... | @@ -2883,7 +2884,7 @@ test sendFileReading { |
| 2883 | 2884 | const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true }); |
| 2884 | 2885 | defer file.close(io); |
| 2885 | 2886 | 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); | |
| 2887 | 2888 | try file_writer.interface.writeAll("abcd"); |
| 2888 | 2889 | try file_writer.interface.flush(); |
| 2889 | 2890 |
lib/std/Io/test.zig+1-1| ... | ... | @@ -10,7 +10,7 @@ const expectError = std.testing.expectError; |
| 10 | 10 | const DefaultPrng = std.Random.DefaultPrng; |
| 11 | 11 | const mem = std.mem; |
| 12 | 12 | const fs = std.fs; |
| 13 | const File = std.fs.File; | |
| 13 | const File = std.Io.File; | |
| 14 | 14 | const assert = std.debug.assert; |
| 15 | 15 | |
| 16 | 16 | const tmpDir = std.testing.tmpDir; |
lib/std/Io/tty.zig+4-3| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | const std = @import("std"); | |
| 2 | 1 | const builtin = @import("builtin"); |
| 3 | const File = std.fs.File; | |
| 2 | const native_os = builtin.os.tag; | |
| 3 | ||
| 4 | const std = @import("std"); | |
| 5 | const File = std.Io.File; | |
| 4 | 6 | const process = std.process; |
| 5 | 7 | const windows = std.os.windows; |
| 6 | const native_os = builtin.os.tag; | |
| 7 | 8 | |
| 8 | 9 | pub const Color = enum { |
| 9 | 10 | black, |
lib/std/Progress.zig+10-8| ... | ... | @@ -1,19 +1,21 @@ |
| 1 | 1 | //! This API is non-allocating, non-fallible, thread-safe, and lock-free. |
| 2 | const Progress = @This(); | |
| 2 | 3 | |
| 3 | const std = @import("std"); | |
| 4 | 4 | const builtin = @import("builtin"); |
| 5 | const is_big_endian = builtin.cpu.arch.endian() == .big; | |
| 6 | const is_windows = builtin.os.tag == .windows; | |
| 7 | ||
| 8 | const std = @import("std"); | |
| 9 | const Io = std.Io; | |
| 5 | 10 | const windows = std.os.windows; |
| 6 | 11 | const testing = std.testing; |
| 7 | 12 | const assert = std.debug.assert; |
| 8 | const Progress = @This(); | |
| 9 | 13 | const posix = std.posix; |
| 10 | const is_big_endian = builtin.cpu.arch.endian() == .big; | |
| 11 | const is_windows = builtin.os.tag == .windows; | |
| 12 | 14 | const Writer = std.Io.Writer; |
| 13 | 15 | |
| 14 | 16 | /// `null` if the current node (and its children) should |
| 15 | 17 | /// not print on update() |
| 16 | terminal: std.fs.File, | |
| 18 | terminal: Io.File, | |
| 17 | 19 | |
| 18 | 20 | terminal_mode: TerminalMode, |
| 19 | 21 | |
| ... | ... | @@ -472,7 +474,7 @@ pub fn start(options: Options) Node { |
| 472 | 474 | if (options.disable_printing) { |
| 473 | 475 | return Node.none; |
| 474 | 476 | } |
| 475 | const stderr: std.fs.File = .stderr(); | |
| 477 | const stderr: Io.File = .stderr(); | |
| 476 | 478 | global_progress.terminal = stderr; |
| 477 | 479 | if (stderr.enableAnsiEscapeCodes()) |_| { |
| 478 | 480 | global_progress.terminal_mode = .ansi_escape_codes; |
| ... | ... | @@ -633,8 +635,8 @@ pub fn unlockStdErr() void { |
| 633 | 635 | /// Protected by `stderr_mutex`. |
| 634 | 636 | const stderr_writer: *Writer = &stderr_file_writer.interface; |
| 635 | 637 | /// Protected by `stderr_mutex`. |
| 636 | var stderr_file_writer: std.fs.File.Writer = .{ | |
| 637 | .interface = std.fs.File.Writer.initInterface(&.{}), | |
| 638 | var stderr_file_writer: Io.File.Writer = .{ | |
| 639 | .interface = Io.File.Writer.initInterface(&.{}), | |
| 638 | 640 | .file = if (is_windows) undefined else .stderr(), |
| 639 | 641 | .mode = .streaming, |
| 640 | 642 | }; |
lib/std/Random/benchmark.zig+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | 1 | // zig run -O ReleaseFast --zig-lib-dir ../.. benchmark.zig |
| 2 | 2 | |
| 3 | const std = @import("std"); | |
| 4 | 3 | const builtin = @import("builtin"); |
| 4 | ||
| 5 | const std = @import("std"); | |
| 6 | const Io = std.Io; | |
| 5 | 7 | const time = std.time; |
| 6 | 8 | const Timer = time.Timer; |
| 7 | 9 | const Random = std.Random; |
| ... | ... | @@ -123,7 +125,7 @@ fn mode(comptime x: comptime_int) comptime_int { |
| 123 | 125 | |
| 124 | 126 | pub fn main() !void { |
| 125 | 127 | 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); | |
| 127 | 129 | const stdout = &stdout_writer.interface; |
| 128 | 130 | |
| 129 | 131 | var buffer: [1024]u8 = undefined; |
lib/std/Thread.zig+2-2| ... | ... | @@ -175,7 +175,7 @@ pub const SetNameError = error{ |
| 175 | 175 | Unsupported, |
| 176 | 176 | Unexpected, |
| 177 | 177 | InvalidWtf8, |
| 178 | } || posix.PrctlError || posix.WriteError || std.fs.File.OpenError || std.fmt.BufPrintError; | |
| 178 | } || posix.PrctlError || posix.WriteError || Io.File.OpenError || std.fmt.BufPrintError; | |
| 179 | 179 | |
| 180 | 180 | pub fn setName(self: Thread, io: Io, name: []const u8) SetNameError!void { |
| 181 | 181 | 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 { |
| 293 | 293 | pub const GetNameError = error{ |
| 294 | 294 | Unsupported, |
| 295 | 295 | Unexpected, |
| 296 | } || posix.PrctlError || posix.ReadError || std.fs.File.OpenError || std.fmt.BufPrintError; | |
| 296 | } || posix.PrctlError || posix.ReadError || Io.File.OpenError || std.fmt.BufPrintError; | |
| 297 | 297 | |
| 298 | 298 | /// On Windows, the result is encoded as [WTF-8](https://wtf-8.codeberg.page/). |
| 299 | 299 | /// 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 |
| 171 | 171 | cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | pub const AddCertsFromDirPathError = fs.File.OpenError || AddCertsFromDirError; | |
| 174 | pub const AddCertsFromDirPathError = Io.File.OpenError || AddCertsFromDirError; | |
| 175 | 175 | |
| 176 | 176 | pub fn addCertsFromDirPath( |
| 177 | 177 | cb: *Bundle, |
| ... | ... | @@ -212,7 +212,7 @@ pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp, i |
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | pub const AddCertsFromFilePathError = fs.File.OpenError || AddCertsFromFileError || Io.Clock.Error; | |
| 215 | pub const AddCertsFromFilePathError = Io.File.OpenError || AddCertsFromFileError || Io.Clock.Error; | |
| 216 | 216 | |
| 217 | 217 | pub fn addCertsFromFilePathAbsolute( |
| 218 | 218 | cb: *Bundle, |
| ... | ... | @@ -242,8 +242,8 @@ pub fn addCertsFromFilePath( |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | pub const AddCertsFromFileError = Allocator.Error || |
| 245 | fs.File.GetSeekPosError || | |
| 246 | fs.File.ReadError || | |
| 245 | Io.File.GetSeekPosError || | |
| 246 | Io.File.ReadError || | |
| 247 | 247 | ParseCertError || |
| 248 | 248 | std.base64.Error || |
| 249 | 249 | error{ CertificateAuthorityBundleTooBig, MissingEndCertificateMarker, Streaming }; |
lib/std/crypto/Certificate/Bundle/macos.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ const mem = std.mem; |
| 6 | 6 | const Allocator = std.mem.Allocator; |
| 7 | 7 | const Bundle = @import("../Bundle.zig"); |
| 8 | 8 | |
| 9 | pub const RescanMacError = Allocator.Error || fs.File.OpenError || fs.File.ReadError || fs.File.SeekError || Bundle.ParseCertError || error{EndOfStream}; | |
| 9 | pub const RescanMacError = Allocator.Error || Io.File.OpenError || Io.File.ReadError || Io.File.SeekError || Bundle.ParseCertError || error{EndOfStream}; | |
| 10 | 10 | |
| 11 | 11 | pub fn rescanMac(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp) RescanMacError!void { |
| 12 | 12 | cb.bytes.clearRetainingCapacity(); |
lib/std/crypto/benchmark.zig+5-3| ... | ... | @@ -1,10 +1,12 @@ |
| 1 | 1 | // zig run -O ReleaseFast --zig-lib-dir ../.. benchmark.zig |
| 2 | 2 | |
| 3 | const std = @import("std"); | |
| 4 | 3 | const builtin = @import("builtin"); |
| 4 | ||
| 5 | const std = @import("std"); | |
| 6 | const Io = std.Io; | |
| 5 | 7 | const mem = std.mem; |
| 6 | 8 | const time = std.time; |
| 7 | const Timer = time.Timer; | |
| 9 | const Timer = std.time.Timer; | |
| 8 | 10 | const crypto = std.crypto; |
| 9 | 11 | |
| 10 | 12 | const KiB = 1024; |
| ... | ... | @@ -504,7 +506,7 @@ fn mode(comptime x: comptime_int) comptime_int { |
| 504 | 506 | pub fn main() !void { |
| 505 | 507 | // Size of buffer is about size of printed message. |
| 506 | 508 | 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); | |
| 508 | 510 | const stdout = &stdout_writer.interface; |
| 509 | 511 | |
| 510 | 512 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
lib/std/debug.zig+3-3| ... | ... | @@ -8,7 +8,7 @@ const posix = std.posix; |
| 8 | 8 | const fs = std.fs; |
| 9 | 9 | const testing = std.testing; |
| 10 | 10 | const Allocator = mem.Allocator; |
| 11 | const File = std.fs.File; | |
| 11 | const File = std.Io.File; | |
| 12 | 12 | const windows = std.os.windows; |
| 13 | 13 | |
| 14 | 14 | const builtin = @import("builtin"); |
| ... | ... | @@ -575,7 +575,7 @@ pub fn defaultPanic( |
| 575 | 575 | // A panic happened while trying to print a previous panic message. |
| 576 | 576 | // We're still holding the mutex but that's fine as we're going to |
| 577 | 577 | // 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 {}; | |
| 579 | 579 | }, |
| 580 | 580 | else => {}, // Panicked while printing the recursive panic message. |
| 581 | 581 | } |
| ... | ... | @@ -1596,7 +1596,7 @@ pub fn defaultHandleSegfault(addr: ?usize, name: []const u8, opt_ctx: ?CpuContex |
| 1596 | 1596 | // A segfault happened while trying to print a previous panic message. |
| 1597 | 1597 | // We're still holding the mutex but that's fine as we're going to |
| 1598 | 1598 | // 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 {}; | |
| 1600 | 1600 | }, |
| 1601 | 1601 | else => {}, // Panicked while printing the recursive panic message. |
| 1602 | 1602 | } |
lib/std/debug/ElfFile.zig+2-2| ... | ... | @@ -123,7 +123,7 @@ pub const LoadError = error{ |
| 123 | 123 | |
| 124 | 124 | pub fn load( |
| 125 | 125 | gpa: Allocator, |
| 126 | elf_file: std.fs.File, | |
| 126 | elf_file: Io.File, | |
| 127 | 127 | opt_build_id: ?[]const u8, |
| 128 | 128 | di_search_paths: *const DebugInfoSearchPaths, |
| 129 | 129 | ) LoadError!ElfFile { |
| ... | ... | @@ -423,7 +423,7 @@ const LoadInnerResult = struct { |
| 423 | 423 | }; |
| 424 | 424 | fn loadInner( |
| 425 | 425 | arena: Allocator, |
| 426 | elf_file: std.fs.File, | |
| 426 | elf_file: Io.File, | |
| 427 | 427 | opt_crc: ?u32, |
| 428 | 428 | ) (LoadError || error{ CrcMismatch, Streaming, Canceled })!LoadInnerResult { |
| 429 | 429 | 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, |
| 27 | 27 | pub const LoadError = error{ |
| 28 | 28 | MissingDebugInfo, |
| 29 | 29 | 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; | |
| 31 | 31 | |
| 32 | 32 | pub fn load( |
| 33 | 33 | gpa: Allocator, |
lib/std/debug/Pdb.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const File = std.fs.File; | |
| 2 | const File = std.Io.File; | |
| 3 | 3 | const Allocator = std.mem.Allocator; |
| 4 | 4 | const pdb = std.pdb; |
| 5 | 5 | const assert = std.debug.assert; |
lib/std/debug/SelfInfo/Windows.zig+1-1| ... | ... | @@ -204,7 +204,7 @@ const Module = struct { |
| 204 | 204 | coff_section_headers: []coff.SectionHeader, |
| 205 | 205 | |
| 206 | 206 | const MappedFile = struct { |
| 207 | file: fs.File, | |
| 207 | file: Io.File, | |
| 208 | 208 | section_handle: windows.HANDLE, |
| 209 | 209 | section_view: []const u8, |
| 210 | 210 | 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 { |
| 15 | 15 | @branchHint(.cold); |
| 16 | 16 | _ = ra; |
| 17 | 17 | std.debug.lockStdErr(); |
| 18 | const stderr: std.fs.File = .stderr(); | |
| 18 | const stderr: std.Io.File = .stderr(); | |
| 19 | 19 | stderr.writeAll(msg) catch {}; |
| 20 | 20 | @trap(); |
| 21 | 21 | } |
lib/std/dynamic_library.zig+1-1| ... | ... | @@ -225,7 +225,7 @@ pub const ElfDynLib = struct { |
| 225 | 225 | const fd = try resolveFromName(io, path); |
| 226 | 226 | defer posix.close(fd); |
| 227 | 227 | |
| 228 | const file: std.fs.File = .{ .handle = fd }; | |
| 228 | const file: Io.File = .{ .handle = fd }; | |
| 229 | 229 | const stat = try file.stat(); |
| 230 | 230 | const size = std.math.cast(usize, stat.size) orelse return error.FileTooBig; |
| 231 | 231 |
lib/std/fs/test.zig+4-4| ... | ... | @@ -12,7 +12,7 @@ const posix = std.posix; |
| 12 | 12 | |
| 13 | 13 | const ArenaAllocator = std.heap.ArenaAllocator; |
| 14 | 14 | const Dir = std.fs.Dir; |
| 15 | const File = std.fs.File; | |
| 15 | const File = std.Io.File; | |
| 16 | 16 | const tmpDir = testing.tmpDir; |
| 17 | 17 | const SymLinkFlags = std.fs.Dir.SymLinkFlags; |
| 18 | 18 | |
| ... | ... | @@ -2231,7 +2231,7 @@ test "read file non vectored" { |
| 2231 | 2231 | const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true }); |
| 2232 | 2232 | defer file.close(io); |
| 2233 | 2233 | { |
| 2234 | var file_writer: std.fs.File.Writer = .init(file, &.{}); | |
| 2234 | var file_writer: File.Writer = .init(file, &.{}); | |
| 2235 | 2235 | try file_writer.interface.writeAll(contents); |
| 2236 | 2236 | try file_writer.interface.flush(); |
| 2237 | 2237 | } |
| ... | ... | @@ -2263,7 +2263,7 @@ test "seek keeping partial buffer" { |
| 2263 | 2263 | const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true }); |
| 2264 | 2264 | defer file.close(io); |
| 2265 | 2265 | { |
| 2266 | var file_writer: std.fs.File.Writer = .init(file, &.{}); | |
| 2266 | var file_writer: File.Writer = .init(file, &.{}); | |
| 2267 | 2267 | try file_writer.interface.writeAll(contents); |
| 2268 | 2268 | try file_writer.interface.flush(); |
| 2269 | 2269 | } |
| ... | ... | @@ -2325,7 +2325,7 @@ test "seekTo flushes buffered data" { |
| 2325 | 2325 | defer file.close(io); |
| 2326 | 2326 | { |
| 2327 | 2327 | var buf: [16]u8 = undefined; |
| 2328 | var file_writer = std.fs.File.writer(file, &buf); | |
| 2328 | var file_writer = File.writer(file, &buf); | |
| 2329 | 2329 | |
| 2330 | 2330 | try file_writer.interface.writeAll(contents); |
| 2331 | 2331 | try file_writer.seekTo(8); |
lib/std/hash/benchmark.zig+3-2| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | // zig run -O ReleaseFast --zig-lib-dir ../.. benchmark.zig |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | const std = @import("std"); |
| 4 | const builtin = @import("builtin"); | |
| 5 | const Io = std.Io; | |
| 5 | 6 | const time = std.time; |
| 6 | 7 | const Timer = time.Timer; |
| 7 | 8 | const hash = std.hash; |
| ... | ... | @@ -354,7 +355,7 @@ fn mode(comptime x: comptime_int) comptime_int { |
| 354 | 355 | |
| 355 | 356 | pub fn main() !void { |
| 356 | 357 | 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); | |
| 358 | 359 | const stdout = &stdout_writer.interface; |
| 359 | 360 | |
| 360 | 361 | var buffer: [1024]u8 = undefined; |
lib/std/http.zig+1-1| ... | ... | @@ -2,7 +2,7 @@ const builtin = @import("builtin"); |
| 2 | 2 | const std = @import("std.zig"); |
| 3 | 3 | const assert = std.debug.assert; |
| 4 | 4 | const Writer = std.Io.Writer; |
| 5 | const File = std.fs.File; | |
| 5 | const File = std.Io.File; | |
| 6 | 6 | |
| 7 | 7 | pub const Client = @import("http/Client.zig"); |
| 8 | 8 | pub const Server = @import("http/Server.zig"); |
lib/std/pdb.zig+1-1| ... | ... | @@ -12,7 +12,7 @@ const math = std.math; |
| 12 | 12 | const mem = std.mem; |
| 13 | 13 | const coff = std.coff; |
| 14 | 14 | const fs = std.fs; |
| 15 | const File = std.fs.File; | |
| 15 | const File = std.Io.File; | |
| 16 | 16 | const debug = std.debug; |
| 17 | 17 | |
| 18 | 18 | const ArrayList = std.ArrayList; |
lib/std/posix/test.zig+9-9| ... | ... | @@ -1,20 +1,20 @@ |
| 1 | const builtin = @import("builtin"); | |
| 2 | const native_os = builtin.target.os.tag; | |
| 3 | ||
| 1 | 4 | const std = @import("../std.zig"); |
| 5 | const Io = std.Io; | |
| 2 | 6 | const posix = std.posix; |
| 3 | 7 | const testing = std.testing; |
| 4 | const expect = testing.expect; | |
| 5 | const expectEqual = testing.expectEqual; | |
| 6 | const expectError = testing.expectError; | |
| 8 | const expect = std.testing.expect; | |
| 9 | const expectEqual = std.testing.expectEqual; | |
| 10 | const expectError = std.testing.expectError; | |
| 7 | 11 | const fs = std.fs; |
| 8 | 12 | const mem = std.mem; |
| 9 | 13 | const elf = std.elf; |
| 10 | 14 | const linux = std.os.linux; |
| 11 | ||
| 12 | 15 | const a = std.testing.allocator; |
| 13 | ||
| 14 | const builtin = @import("builtin"); | |
| 15 | 16 | const AtomicRmwOp = std.builtin.AtomicRmwOp; |
| 16 | 17 | const AtomicOrder = std.builtin.AtomicOrder; |
| 17 | const native_os = builtin.target.os.tag; | |
| 18 | 18 | const tmpDir = std.testing.tmpDir; |
| 19 | 19 | const AT = posix.AT; |
| 20 | 20 | |
| ... | ... | @@ -663,14 +663,14 @@ test "dup & dup2" { |
| 663 | 663 | var file = try tmp.dir.createFile("os_dup_test", .{}); |
| 664 | 664 | defer file.close(io); |
| 665 | 665 | |
| 666 | var duped = std.fs.File{ .handle = try posix.dup(file.handle) }; | |
| 666 | var duped = Io.File{ .handle = try posix.dup(file.handle) }; | |
| 667 | 667 | defer duped.close(io); |
| 668 | 668 | try duped.writeAll("dup"); |
| 669 | 669 | |
| 670 | 670 | // Tests aren't run in parallel so using the next fd shouldn't be an issue. |
| 671 | 671 | const new_fd = duped.handle + 1; |
| 672 | 672 | try posix.dup2(file.handle, new_fd); |
| 673 | var dup2ed = std.fs.File{ .handle = new_fd }; | |
| 673 | var dup2ed = Io.File{ .handle = new_fd }; | |
| 674 | 674 | defer dup2ed.close(io); |
| 675 | 675 | try dup2ed.writeAll("dup2"); |
| 676 | 676 | } |
lib/std/process/Child.zig+2-2| ... | ... | @@ -8,7 +8,7 @@ const Io = std.Io; |
| 8 | 8 | const unicode = std.unicode; |
| 9 | 9 | const fs = std.fs; |
| 10 | 10 | const process = std.process; |
| 11 | const File = std.fs.File; | |
| 11 | const File = std.Io.File; | |
| 12 | 12 | const windows = std.os.windows; |
| 13 | 13 | const linux = std.os.linux; |
| 14 | 14 | const posix = std.posix; |
| ... | ... | @@ -1055,7 +1055,7 @@ fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn { |
| 1055 | 1055 | |
| 1056 | 1056 | fn writeIntFd(fd: i32, value: ErrInt) !void { |
| 1057 | 1057 | 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); | |
| 1059 | 1059 | fw.interface.writeInt(u64, value, .little) catch unreachable; |
| 1060 | 1060 | fw.interface.flush() catch return error.SystemResources; |
| 1061 | 1061 | } |
lib/std/unicode/throughput_test.zig+3-3| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const time = std.time; |
| 3 | 4 | const unicode = std.unicode; |
| 4 | ||
| 5 | const Timer = time.Timer; | |
| 5 | const Timer = std.time.Timer; | |
| 6 | 6 | |
| 7 | 7 | const N = 1_000_000; |
| 8 | 8 | |
| ... | ... | @@ -41,7 +41,7 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount { |
| 41 | 41 | pub fn main() !void { |
| 42 | 42 | // Size of buffer is about size of printed message. |
| 43 | 43 | 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); | |
| 45 | 45 | const stdout = &stdout_writer.interface; |
| 46 | 46 | |
| 47 | 47 | try stdout.print("short ASCII strings\n", .{}); |
lib/std/zig/Zir.zig+4-4| ... | ... | @@ -11,9 +11,11 @@ |
| 11 | 11 | //! * In the future, possibly inline assembly, which needs to get parsed and |
| 12 | 12 | //! handled by the codegen backend, and errors reported there. However for now, |
| 13 | 13 | //! inline assembly is not an exception. |
| 14 | const Zir = @This(); | |
| 15 | const builtin = @import("builtin"); | |
| 14 | 16 | |
| 15 | 17 | const std = @import("std"); |
| 16 | const builtin = @import("builtin"); | |
| 18 | const Io = std.Io; | |
| 17 | 19 | const mem = std.mem; |
| 18 | 20 | const Allocator = std.mem.Allocator; |
| 19 | 21 | const assert = std.debug.assert; |
| ... | ... | @@ -21,8 +23,6 @@ const BigIntConst = std.math.big.int.Const; |
| 21 | 23 | const BigIntMutable = std.math.big.int.Mutable; |
| 22 | 24 | const Ast = std.zig.Ast; |
| 23 | 25 | |
| 24 | const Zir = @This(); | |
| 25 | ||
| 26 | 26 | instructions: std.MultiArrayList(Inst).Slice, |
| 27 | 27 | /// In order to store references to strings in fewer bytes, we copy all |
| 28 | 28 | /// string bytes into here. String bytes can be null. It is up to whomever |
| ... | ... | @@ -45,7 +45,7 @@ pub const Header = extern struct { |
| 45 | 45 | /// it's essentially free to have a zero field here and makes the warning go away, |
| 46 | 46 | /// making it more likely that following Valgrind warnings will be taken seriously. |
| 47 | 47 | unused: u32 = 0, |
| 48 | stat_inode: std.fs.File.INode, | |
| 48 | stat_inode: Io.File.INode, | |
| 49 | 49 | stat_size: u64, |
| 50 | 50 | stat_mtime: i128, |
| 51 | 51 | }; |
lib/std/zig/Zoir.zig+8-7| ... | ... | @@ -1,6 +1,13 @@ |
| 1 | 1 | //! Zig Object Intermediate Representation. |
| 2 | 2 | //! Simplified AST for the ZON (Zig Object Notation) format. |
| 3 | 3 | //! `ZonGen` converts `Ast` to `Zoir`. |
| 4 | const Zoir = @This(); | |
| 5 | ||
| 6 | const std = @import("std"); | |
| 7 | const Io = std.Io; | |
| 8 | const assert = std.debug.assert; | |
| 9 | const Allocator = std.mem.Allocator; | |
| 10 | const Ast = std.zig.Ast; | |
| 4 | 11 | |
| 5 | 12 | nodes: std.MultiArrayList(Node.Repr).Slice, |
| 6 | 13 | extra: []u32, |
| ... | ... | @@ -25,7 +32,7 @@ pub const Header = extern struct { |
| 25 | 32 | /// making it more likely that following Valgrind warnings will be taken seriously. |
| 26 | 33 | unused: u64 = 0, |
| 27 | 34 | |
| 28 | stat_inode: std.fs.File.INode, | |
| 35 | stat_inode: Io.File.INode, | |
| 29 | 36 | stat_size: u64, |
| 30 | 37 | stat_mtime: i128, |
| 31 | 38 | |
| ... | ... | @@ -254,9 +261,3 @@ pub const CompileError = extern struct { |
| 254 | 261 | assert(std.meta.hasUniqueRepresentation(Note)); |
| 255 | 262 | } |
| 256 | 263 | }; |
| 257 | ||
| 258 | const std = @import("std"); | |
| 259 | const assert = std.debug.assert; | |
| 260 | const Allocator = std.mem.Allocator; | |
| 261 | const Ast = std.zig.Ast; | |
| 262 | const Zoir = @This(); |
lib/std/zig/llvm/Builder.zig+2-2| ... | ... | @@ -9578,7 +9578,7 @@ pub fn asmValue( |
| 9578 | 9578 | |
| 9579 | 9579 | pub fn dump(b: *Builder) void { |
| 9580 | 9580 | var buffer: [4000]u8 = undefined; |
| 9581 | const stderr: std.fs.File = .stderr(); | |
| 9581 | const stderr: Io.File = .stderr(); | |
| 9582 | 9582 | b.printToFile(stderr, &buffer) catch {}; |
| 9583 | 9583 | } |
| 9584 | 9584 | |
| ... | ... | @@ -9589,7 +9589,7 @@ pub fn printToFilePath(b: *Builder, io: Io, dir: std.fs.Dir, path: []const u8) ! |
| 9589 | 9589 | try b.printToFile(io, file, &buffer); |
| 9590 | 9590 | } |
| 9591 | 9591 | |
| 9592 | pub fn printToFile(b: *Builder, file: std.fs.File, buffer: []u8) !void { | |
| 9592 | pub fn printToFile(b: *Builder, file: Io.File, buffer: []u8) !void { | |
| 9593 | 9593 | var fw = file.writer(buffer); |
| 9594 | 9594 | try print(b, &fw.interface); |
| 9595 | 9595 | try fw.interface.flush(); |
lib/std/zig/perf_test.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const mem = std.mem; |
| 3 | 4 | const Tokenizer = std.zig.Tokenizer; |
| 4 | 5 | const fmtIntSizeBin = std.fmt.fmtIntSizeBin; |
| ... | ... | @@ -22,7 +23,7 @@ pub fn main() !void { |
| 22 | 23 | const bytes_per_sec = @as(u64, @intFromFloat(@floor(bytes_per_sec_float))); |
| 23 | 24 | |
| 24 | 25 | 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); | |
| 26 | 27 | const stdout = &stdout_writer.interface; |
| 27 | 28 | try stdout.print("parsing speed: {Bi:.2}/s, {Bi:.2} used \n", .{ bytes_per_sec, memory_used }); |
| 28 | 29 | try stdout.flush(); |
lib/std/zip.zig+3-2| ... | ... | @@ -4,9 +4,10 @@ |
| 4 | 4 | //! Note that this file uses the abbreviation "cd" for "central directory" |
| 5 | 5 | |
| 6 | 6 | const builtin = @import("builtin"); |
| 7 | const std = @import("std"); | |
| 8 | const File = std.fs.File; | |
| 9 | 7 | const is_le = builtin.target.cpu.arch.endian() == .little; |
| 8 | ||
| 9 | const std = @import("std"); | |
| 10 | const File = std.Io.File; | |
| 10 | 11 | const Writer = std.Io.Writer; |
| 11 | 12 | const Reader = std.Io.Reader; |
| 12 | 13 | const flate = std.compress.flate; |
src/Compilation.zig+2-2| ... | ... | @@ -5325,7 +5325,7 @@ fn docsCopyModule( |
| 5325 | 5325 | comp: *Compilation, |
| 5326 | 5326 | module: *Package.Module, |
| 5327 | 5327 | name: []const u8, |
| 5328 | tar_file_writer: *fs.File.Writer, | |
| 5328 | tar_file_writer: *Io.File.Writer, | |
| 5329 | 5329 | ) !void { |
| 5330 | 5330 | const io = comp.io; |
| 5331 | 5331 | const root = module.root; |
| ... | ... | @@ -5361,7 +5361,7 @@ fn docsCopyModule( |
| 5361 | 5361 | }; |
| 5362 | 5362 | defer file.close(io); |
| 5363 | 5363 | 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); | |
| 5365 | 5365 | |
| 5366 | 5366 | archiver.writeFileTimestamp(entry.path, &file_reader, stat.mtime) catch |err| { |
| 5367 | 5367 | 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 { |
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | const Resource = union(enum) { |
| 885 | file: fs.File.Reader, | |
| 885 | file: Io.File.Reader, | |
| 886 | 886 | http_request: HttpRequest, |
| 887 | 887 | git: Git, |
| 888 | 888 | dir: Io.Dir, |
| ... | ... | @@ -1653,7 +1653,7 @@ fn computeHash(f: *Fetch, pkg_path: Cache.Path, filter: Filter) RunError!Compute |
| 1653 | 1653 | |
| 1654 | 1654 | fn dumpHashInfo(all_files: []const *const HashedFile) !void { |
| 1655 | 1655 | 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); | |
| 1657 | 1657 | const w = &stdout_writer.interface; |
| 1658 | 1658 | for (all_files) |hashed_file| { |
| 1659 | 1659 | 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 |
| 1712 | 1712 | try dir.deleteFile(deleted_file.fs_path); |
| 1713 | 1713 | } |
| 1714 | 1714 | |
| 1715 | fn setExecutable(file: fs.File) !void { | |
| 1715 | fn setExecutable(file: Io.File) !void { | |
| 1716 | 1716 | if (!std.fs.has_executable_bit) return; |
| 1717 | 1717 | |
| 1718 | 1718 | 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; | |
| 1720 | 1720 | try file.chmod(mode); |
| 1721 | 1721 | } |
| 1722 | 1722 | |
| ... | ... | @@ -1738,10 +1738,10 @@ const HashedFile = struct { |
| 1738 | 1738 | size: u64, |
| 1739 | 1739 | |
| 1740 | 1740 | 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 || | |
| 1745 | 1745 | Io.Dir.ReadLinkError; |
| 1746 | 1746 | |
| 1747 | 1747 | const Kind = enum { file, link }; |
src/Package/Fetch/git.zig+11-11| ... | ... | @@ -198,8 +198,8 @@ pub const Repository = struct { |
| 198 | 198 | repo: *Repository, |
| 199 | 199 | allocator: Allocator, |
| 200 | 200 | 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, | |
| 203 | 203 | ) !void { |
| 204 | 204 | repo.* = .{ .odb = undefined }; |
| 205 | 205 | try repo.odb.init(allocator, format, pack_file, index_file); |
| ... | ... | @@ -372,9 +372,9 @@ pub const Repository = struct { |
| 372 | 372 | /// [pack-format](https://git-scm.com/docs/pack-format). |
| 373 | 373 | const Odb = struct { |
| 374 | 374 | format: Oid.Format, |
| 375 | pack_file: *std.fs.File.Reader, | |
| 375 | pack_file: *Io.File.Reader, | |
| 376 | 376 | index_header: IndexHeader, |
| 377 | index_file: *std.fs.File.Reader, | |
| 377 | index_file: *Io.File.Reader, | |
| 378 | 378 | cache: ObjectCache = .{}, |
| 379 | 379 | allocator: Allocator, |
| 380 | 380 | |
| ... | ... | @@ -383,8 +383,8 @@ const Odb = struct { |
| 383 | 383 | odb: *Odb, |
| 384 | 384 | allocator: Allocator, |
| 385 | 385 | 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, | |
| 388 | 388 | ) !void { |
| 389 | 389 | try pack_file.seekTo(0); |
| 390 | 390 | try index_file.seekTo(0); |
| ... | ... | @@ -1272,8 +1272,8 @@ const IndexEntry = struct { |
| 1272 | 1272 | pub fn indexPack( |
| 1273 | 1273 | allocator: Allocator, |
| 1274 | 1274 | 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, | |
| 1277 | 1277 | ) !void { |
| 1278 | 1278 | try pack.seekTo(0); |
| 1279 | 1279 | |
| ... | ... | @@ -1372,7 +1372,7 @@ pub fn indexPack( |
| 1372 | 1372 | fn indexPackFirstPass( |
| 1373 | 1373 | allocator: Allocator, |
| 1374 | 1374 | format: Oid.Format, |
| 1375 | pack: *std.fs.File.Reader, | |
| 1375 | pack: *Io.File.Reader, | |
| 1376 | 1376 | index_entries: *std.AutoHashMapUnmanaged(Oid, IndexEntry), |
| 1377 | 1377 | pending_deltas: *std.ArrayList(IndexEntry), |
| 1378 | 1378 | ) !Oid { |
| ... | ... | @@ -1425,7 +1425,7 @@ fn indexPackFirstPass( |
| 1425 | 1425 | fn indexPackHashDelta( |
| 1426 | 1426 | allocator: Allocator, |
| 1427 | 1427 | format: Oid.Format, |
| 1428 | pack: *std.fs.File.Reader, | |
| 1428 | pack: *Io.File.Reader, | |
| 1429 | 1429 | delta: IndexEntry, |
| 1430 | 1430 | index_entries: std.AutoHashMapUnmanaged(Oid, IndexEntry), |
| 1431 | 1431 | cache: *ObjectCache, |
| ... | ... | @@ -1477,7 +1477,7 @@ fn indexPackHashDelta( |
| 1477 | 1477 | fn resolveDeltaChain( |
| 1478 | 1478 | allocator: Allocator, |
| 1479 | 1479 | format: Oid.Format, |
| 1480 | pack: *std.fs.File.Reader, | |
| 1480 | pack: *Io.File.Reader, | |
| 1481 | 1481 | base_object: Object, |
| 1482 | 1482 | delta_offsets: []const u64, |
| 1483 | 1483 | cache: *ObjectCache, |
src/Zcu.zig+4-4| ... | ... | @@ -1200,7 +1200,7 @@ pub const EmbedFile = struct { |
| 1200 | 1200 | /// `.none` means the file was not loaded, so `stat` is undefined. |
| 1201 | 1201 | val: InternPool.Index, |
| 1202 | 1202 | /// 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}), | |
| 1204 | 1204 | stat: Cache.File.Stat, |
| 1205 | 1205 | |
| 1206 | 1206 | pub const Index = enum(u32) { |
| ... | ... | @@ -2927,7 +2927,7 @@ comptime { |
| 2927 | 2927 | } |
| 2928 | 2928 | } |
| 2929 | 2929 | |
| 2930 | pub fn loadZirCache(gpa: Allocator, io: Io, cache_file: std.fs.File) !Zir { | |
| 2930 | pub fn loadZirCache(gpa: Allocator, io: Io, cache_file: Io.File) !Zir { | |
| 2931 | 2931 | var buffer: [2000]u8 = undefined; |
| 2932 | 2932 | var file_reader = cache_file.reader(io, &buffer); |
| 2933 | 2933 | return result: { |
| ... | ... | @@ -2986,7 +2986,7 @@ pub fn loadZirCacheBody(gpa: Allocator, header: Zir.Header, cache_br: *Io.Reader |
| 2986 | 2986 | return zir; |
| 2987 | 2987 | } |
| 2988 | 2988 | |
| 2989 | pub fn saveZirCache(gpa: Allocator, cache_file: std.fs.File, stat: std.fs.File.Stat, zir: Zir) (std.fs.File.WriteError || Allocator.Error)!void { | |
| 2989 | pub fn saveZirCache(gpa: Allocator, cache_file: Io.File, stat: Io.File.Stat, zir: Zir) (Io.File.WriteError || Allocator.Error)!void { | |
| 2990 | 2990 | const safety_buffer = if (data_has_safety_tag) |
| 2991 | 2991 | try gpa.alloc([8]u8, zir.instructions.len) |
| 2992 | 2992 | else |
| ... | ... | @@ -3026,7 +3026,7 @@ pub fn saveZirCache(gpa: Allocator, cache_file: std.fs.File, stat: std.fs.File.S |
| 3026 | 3026 | }; |
| 3027 | 3027 | } |
| 3028 | 3028 | |
| 3029 | pub fn saveZoirCache(cache_file: std.fs.File, stat: std.fs.File.Stat, zoir: Zoir) std.fs.File.WriteError!void { | |
| 3029 | pub fn saveZoirCache(cache_file: Io.File, stat: Io.File.Stat, zoir: Zoir) Io.File.WriteError!void { | |
| 3030 | 3030 | const header: Zoir.Header = .{ |
| 3031 | 3031 | .nodes_len = @intCast(zoir.nodes.len), |
| 3032 | 3032 | .extra_len = @intCast(zoir.extra.len), |
src/Zcu/PerThread.zig+3-3| ... | ... | @@ -118,7 +118,7 @@ pub fn updateFile( |
| 118 | 118 | const zir_dir = cache_directory.handle; |
| 119 | 119 | |
| 120 | 120 | // 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) { | |
| 122 | 122 | .never_loaded, .retryable_failure => lock: { |
| 123 | 123 | // First, load the cached ZIR code, if any. |
| 124 | 124 | log.debug("AstGen checking cache: {f} (local={}, digest={s})", .{ |
| ... | ... | @@ -346,8 +346,8 @@ pub fn updateFile( |
| 346 | 346 | |
| 347 | 347 | fn loadZirZoirCache( |
| 348 | 348 | zcu: *Zcu, |
| 349 | cache_file: std.fs.File, | |
| 350 | stat: std.fs.File.Stat, | |
| 349 | cache_file: Io.File, | |
| 350 | stat: Io.File.Stat, | |
| 351 | 351 | file: *Zcu.File, |
| 352 | 352 | comptime mode: Ast.Mode, |
| 353 | 353 | ) !enum { success, invalid, truncated, stale } { |
src/fmt.zig+8-8| ... | ... | @@ -37,9 +37,9 @@ const Fmt = struct { |
| 37 | 37 | arena: Allocator, |
| 38 | 38 | io: Io, |
| 39 | 39 | out_buffer: std.Io.Writer.Allocating, |
| 40 | stdout_writer: *fs.File.Writer, | |
| 40 | stdout_writer: *Io.File.Writer, | |
| 41 | 41 | |
| 42 | const SeenMap = std.AutoHashMap(fs.File.INode, void); | |
| 42 | const SeenMap = std.AutoHashMap(Io.File.INode, void); | |
| 43 | 43 | }; |
| 44 | 44 | |
| 45 | 45 | pub 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) ! |
| 59 | 59 | const arg = args[i]; |
| 60 | 60 | if (mem.startsWith(u8, arg, "-")) { |
| 61 | 61 | 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); | |
| 63 | 63 | return process.cleanExit(); |
| 64 | 64 | } else if (mem.eql(u8, arg, "--color")) { |
| 65 | 65 | if (i + 1 >= args.len) { |
| ... | ... | @@ -99,9 +99,9 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) ! |
| 99 | 99 | fatal("cannot use --stdin with positional arguments", .{}); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | const stdin: fs.File = .stdin(); | |
| 102 | const stdin: Io.File = .stdin(); | |
| 103 | 103 | 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); | |
| 105 | 105 | const source_code = std.zig.readSourceFileToEndAlloc(gpa, &file_reader) catch |err| { |
| 106 | 106 | fatal("unable to read stdin: {}", .{err}); |
| 107 | 107 | }; |
| ... | ... | @@ -154,7 +154,7 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) ! |
| 154 | 154 | process.exit(code); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | return fs.File.stdout().writeAll(formatted); | |
| 157 | return Io.File.stdout().writeAll(formatted); | |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | if (input_files.items.len == 0) { |
| ... | ... | @@ -162,7 +162,7 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) ! |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | 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); | |
| 166 | 166 | |
| 167 | 167 | var fmt: Fmt = .{ |
| 168 | 168 | .gpa = gpa, |
| ... | ... | @@ -272,7 +272,7 @@ fn fmtPathFile( |
| 272 | 272 | return error.IsDir; |
| 273 | 273 | |
| 274 | 274 | 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); | |
| 276 | 276 | file_reader.size = stat.size; |
| 277 | 277 | |
| 278 | 278 | const gpa = fmt.gpa; |
src/link.zig+10-10| ... | ... | @@ -393,7 +393,7 @@ pub const File = struct { |
| 393 | 393 | comp: *Compilation, |
| 394 | 394 | emit: Path, |
| 395 | 395 | |
| 396 | file: ?fs.File, | |
| 396 | file: ?Io.File, | |
| 397 | 397 | /// When using the LLVM backend, the emitted object is written to a file with this name. This |
| 398 | 398 | /// object file then becomes a normal link input to LLD or a self-hosted linker. |
| 399 | 399 | /// |
| ... | ... | @@ -1110,7 +1110,7 @@ pub const File = struct { |
| 1110 | 1110 | }; |
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 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 { | |
| 1114 | 1114 | const comp = base.comp; |
| 1115 | 1115 | const diags = &comp.link_diags; |
| 1116 | 1116 | const gpa = comp.gpa; |
| ... | ... | @@ -1238,7 +1238,7 @@ pub const File = struct { |
| 1238 | 1238 | pub fn determineMode( |
| 1239 | 1239 | output_mode: std.builtin.OutputMode, |
| 1240 | 1240 | link_mode: std.builtin.LinkMode, |
| 1241 | ) fs.File.Mode { | |
| 1241 | ) Io.File.Mode { | |
| 1242 | 1242 | // On common systems with a 0o022 umask, 0o777 will still result in a file created |
| 1243 | 1243 | // with 0o755 permissions, but it works appropriately if the system is configured |
| 1244 | 1244 | // more leniently. As another data point, C's fopen seems to open files with the |
| ... | ... | @@ -1247,10 +1247,10 @@ pub const File = struct { |
| 1247 | 1247 | switch (output_mode) { |
| 1248 | 1248 | .Lib => return switch (link_mode) { |
| 1249 | 1249 | .dynamic => executable_mode, |
| 1250 | .static => fs.File.default_mode, | |
| 1250 | .static => Io.File.default_mode, | |
| 1251 | 1251 | }, |
| 1252 | 1252 | .Exe => return executable_mode, |
| 1253 | .Obj => return fs.File.default_mode, | |
| 1253 | .Obj => return Io.File.default_mode, | |
| 1254 | 1254 | } |
| 1255 | 1255 | } |
| 1256 | 1256 | |
| ... | ... | @@ -1660,19 +1660,19 @@ pub const Input = union(enum) { |
| 1660 | 1660 | |
| 1661 | 1661 | pub const Object = struct { |
| 1662 | 1662 | path: Path, |
| 1663 | file: fs.File, | |
| 1663 | file: Io.File, | |
| 1664 | 1664 | must_link: bool, |
| 1665 | 1665 | hidden: bool, |
| 1666 | 1666 | }; |
| 1667 | 1667 | |
| 1668 | 1668 | pub const Res = struct { |
| 1669 | 1669 | path: Path, |
| 1670 | file: fs.File, | |
| 1670 | file: Io.File, | |
| 1671 | 1671 | }; |
| 1672 | 1672 | |
| 1673 | 1673 | pub const Dso = struct { |
| 1674 | 1674 | path: Path, |
| 1675 | file: fs.File, | |
| 1675 | file: Io.File, | |
| 1676 | 1676 | needed: bool, |
| 1677 | 1677 | weak: bool, |
| 1678 | 1678 | reexport: bool, |
| ... | ... | @@ -1694,7 +1694,7 @@ pub const Input = union(enum) { |
| 1694 | 1694 | } |
| 1695 | 1695 | |
| 1696 | 1696 | /// 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 } { | |
| 1698 | 1698 | return switch (input) { |
| 1699 | 1699 | .object, .archive => |obj| .{ obj.path, obj.file }, |
| 1700 | 1700 | inline .res, .dso => |x| .{ x.path, x.file }, |
| ... | ... | @@ -2075,7 +2075,7 @@ fn resolveLibInput( |
| 2075 | 2075 | fn finishResolveLibInput( |
| 2076 | 2076 | resolved_inputs: *std.ArrayList(Input), |
| 2077 | 2077 | path: Path, |
| 2078 | file: std.fs.File, | |
| 2078 | file: Io.File, | |
| 2079 | 2079 | link_mode: std.builtin.LinkMode, |
| 2080 | 2080 | query: UnresolvedInput.Query, |
| 2081 | 2081 | ) ResolveLibInputResult { |
src/link/Dwarf.zig+28-25| ... | ... | @@ -1,3 +1,24 @@ |
| 1 | const Dwarf = @This(); | |
| 2 | ||
| 3 | const std = @import("std"); | |
| 4 | const Io = std.Io; | |
| 5 | const Allocator = std.mem.Allocator; | |
| 6 | const DW = std.dwarf; | |
| 7 | const Zir = std.zig.Zir; | |
| 8 | const assert = std.debug.assert; | |
| 9 | const log = std.log.scoped(.dwarf); | |
| 10 | const Writer = std.Io.Writer; | |
| 11 | ||
| 12 | const InternPool = @import("../InternPool.zig"); | |
| 13 | const Module = @import("../Package.zig").Module; | |
| 14 | const Type = @import("../Type.zig"); | |
| 15 | const Value = @import("../Value.zig"); | |
| 16 | const Zcu = @import("../Zcu.zig"); | |
| 17 | const codegen = @import("../codegen.zig"); | |
| 18 | const dev = @import("../dev.zig"); | |
| 19 | const link = @import("../link.zig"); | |
| 20 | const target_info = @import("../target.zig"); | |
| 21 | ||
| 1 | 22 | gpa: Allocator, |
| 2 | 23 | bin_file: *link.File, |
| 3 | 24 | format: DW.Format, |
| ... | ... | @@ -29,16 +50,16 @@ pub const UpdateError = error{ |
| 29 | 50 | UnexpectedEndOfFile, |
| 30 | 51 | } || |
| 31 | 52 | 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; | |
| 37 | 58 | |
| 38 | 59 | pub const FlushError = UpdateError; |
| 39 | 60 | |
| 40 | 61 | pub const RelocError = |
| 41 | std.fs.File.PWriteError; | |
| 62 | Io.File.PWriteError; | |
| 42 | 63 | |
| 43 | 64 | pub const AddressSize = enum(u8) { |
| 44 | 65 | @"32" = 4, |
| ... | ... | @@ -6350,7 +6371,7 @@ const AbbrevCode = enum { |
| 6350 | 6371 | }); |
| 6351 | 6372 | }; |
| 6352 | 6373 | |
| 6353 | fn getFile(dwarf: *Dwarf) ?std.fs.File { | |
| 6374 | fn getFile(dwarf: *Dwarf) ?Io.File { | |
| 6354 | 6375 | if (dwarf.bin_file.cast(.macho)) |macho_file| if (macho_file.d_sym) |*d_sym| return d_sym.file; |
| 6355 | 6376 | return dwarf.bin_file.file; |
| 6356 | 6377 | } |
| ... | ... | @@ -6429,21 +6450,3 @@ const force_incremental = false; |
| 6429 | 6450 | inline fn incremental(dwarf: Dwarf) bool { |
| 6430 | 6451 | return force_incremental or dwarf.bin_file.comp.config.incremental; |
| 6431 | 6452 | } |
| 6432 | ||
| 6433 | const Allocator = std.mem.Allocator; | |
| 6434 | const DW = std.dwarf; | |
| 6435 | const Dwarf = @This(); | |
| 6436 | const InternPool = @import("../InternPool.zig"); | |
| 6437 | const Module = @import("../Package.zig").Module; | |
| 6438 | const Type = @import("../Type.zig"); | |
| 6439 | const Value = @import("../Value.zig"); | |
| 6440 | const Zcu = @import("../Zcu.zig"); | |
| 6441 | const Zir = std.zig.Zir; | |
| 6442 | const assert = std.debug.assert; | |
| 6443 | const codegen = @import("../codegen.zig"); | |
| 6444 | const dev = @import("../dev.zig"); | |
| 6445 | const link = @import("../link.zig"); | |
| 6446 | const log = std.log.scoped(.dwarf); | |
| 6447 | const std = @import("std"); | |
| 6448 | const target_info = @import("../target.zig"); | |
| 6449 | const 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 |
| 3651 | 3651 | pub fn addFileHandle( |
| 3652 | 3652 | gpa: Allocator, |
| 3653 | 3653 | file_handles: *std.ArrayList(File.Handle), |
| 3654 | handle: fs.File, | |
| 3654 | handle: Io.File, | |
| 3655 | 3655 | ) Allocator.Error!File.HandleIndex { |
| 3656 | 3656 | try file_handles.append(gpa, handle); |
| 3657 | 3657 | return @intCast(file_handles.items.len - 1); |
| ... | ... | @@ -4068,7 +4068,7 @@ fn fmtDumpState(self: *Elf, writer: *std.Io.Writer) std.Io.Writer.Error!void { |
| 4068 | 4068 | } |
| 4069 | 4069 | |
| 4070 | 4070 | /// Caller owns the memory. |
| 4071 | pub fn preadAllAlloc(allocator: Allocator, handle: fs.File, offset: u64, size: u64) ![]u8 { | |
| 4071 | pub fn preadAllAlloc(allocator: Allocator, handle: Io.File, offset: u64, size: u64) ![]u8 { | |
| 4072 | 4072 | const buffer = try allocator.alloc(u8, math.cast(usize, size) orelse return error.Overflow); |
| 4073 | 4073 | errdefer allocator.free(buffer); |
| 4074 | 4074 | 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 { |
| 4460 | 4460 | } |
| 4461 | 4461 | |
| 4462 | 4462 | const std = @import("std"); |
| 4463 | const Io = std.Io; | |
| 4463 | 4464 | const build_options = @import("build_options"); |
| 4464 | 4465 | const builtin = @import("builtin"); |
| 4465 | 4466 | const assert = std.debug.assert; |
src/link/Elf/Object.zig+33-32| ... | ... | @@ -1,3 +1,30 @@ |
| 1 | const Object = @This(); | |
| 2 | ||
| 3 | const std = @import("std"); | |
| 4 | const Io = std.Io; | |
| 5 | const assert = std.debug.assert; | |
| 6 | const eh_frame = @import("eh_frame.zig"); | |
| 7 | const elf = std.elf; | |
| 8 | const fs = std.fs; | |
| 9 | const log = std.log.scoped(.link); | |
| 10 | const math = std.math; | |
| 11 | const mem = std.mem; | |
| 12 | const Path = std.Build.Cache.Path; | |
| 13 | const Allocator = std.mem.Allocator; | |
| 14 | ||
| 15 | const Diags = @import("../../link.zig").Diags; | |
| 16 | const Archive = @import("Archive.zig"); | |
| 17 | const Atom = @import("Atom.zig"); | |
| 18 | const AtomList = @import("AtomList.zig"); | |
| 19 | const Cie = eh_frame.Cie; | |
| 20 | const Elf = @import("../Elf.zig"); | |
| 21 | const Fde = eh_frame.Fde; | |
| 22 | const File = @import("file.zig").File; | |
| 23 | const Merge = @import("Merge.zig"); | |
| 24 | const Symbol = @import("Symbol.zig"); | |
| 25 | const Alignment = Atom.Alignment; | |
| 26 | const riscv = @import("../riscv.zig"); | |
| 27 | ||
| 1 | 28 | archive: ?InArchive = null, |
| 2 | 29 | /// Archive files cannot contain subdirectories, so only the basename is needed |
| 3 | 30 | /// for output. However, the full path is kept for error reporting. |
| ... | ... | @@ -68,7 +95,7 @@ pub fn parse( |
| 68 | 95 | diags: *Diags, |
| 69 | 96 | /// For error reporting purposes only. |
| 70 | 97 | path: Path, |
| 71 | handle: fs.File, | |
| 98 | handle: Io.File, | |
| 72 | 99 | target: *const std.Target, |
| 73 | 100 | debug_fmt_strip: bool, |
| 74 | 101 | default_sym_version: elf.Versym, |
| ... | ... | @@ -97,7 +124,7 @@ pub fn parseCommon( |
| 97 | 124 | gpa: Allocator, |
| 98 | 125 | diags: *Diags, |
| 99 | 126 | path: Path, |
| 100 | handle: fs.File, | |
| 127 | handle: Io.File, | |
| 101 | 128 | target: *const std.Target, |
| 102 | 129 | ) !void { |
| 103 | 130 | const offset = if (self.archive) |ar| ar.offset else 0; |
| ... | ... | @@ -264,7 +291,7 @@ fn initAtoms( |
| 264 | 291 | gpa: Allocator, |
| 265 | 292 | diags: *Diags, |
| 266 | 293 | path: Path, |
| 267 | handle: fs.File, | |
| 294 | handle: Io.File, | |
| 268 | 295 | debug_fmt_strip: bool, |
| 269 | 296 | target: *const std.Target, |
| 270 | 297 | ) !void { |
| ... | ... | @@ -421,7 +448,7 @@ fn initSymbols( |
| 421 | 448 | fn parseEhFrame( |
| 422 | 449 | self: *Object, |
| 423 | 450 | gpa: Allocator, |
| 424 | handle: fs.File, | |
| 451 | handle: Io.File, | |
| 425 | 452 | shndx: u32, |
| 426 | 453 | target: *const std.Target, |
| 427 | 454 | ) !void { |
| ... | ... | @@ -1310,7 +1337,7 @@ fn addString(self: *Object, gpa: Allocator, str: []const u8) !u32 { |
| 1310 | 1337 | } |
| 1311 | 1338 | |
| 1312 | 1339 | /// Caller owns the memory. |
| 1313 | fn preadShdrContentsAlloc(self: Object, gpa: Allocator, handle: fs.File, index: u32) ![]u8 { | |
| 1340 | fn preadShdrContentsAlloc(self: Object, gpa: Allocator, handle: Io.File, index: u32) ![]u8 { | |
| 1314 | 1341 | assert(index < self.shdrs.items.len); |
| 1315 | 1342 | const offset = if (self.archive) |ar| ar.offset else 0; |
| 1316 | 1343 | const shdr = self.shdrs.items[index]; |
| ... | ... | @@ -1320,7 +1347,7 @@ fn preadShdrContentsAlloc(self: Object, gpa: Allocator, handle: fs.File, index: |
| 1320 | 1347 | } |
| 1321 | 1348 | |
| 1322 | 1349 | /// Caller owns the memory. |
| 1323 | fn preadRelocsAlloc(self: Object, gpa: Allocator, handle: fs.File, shndx: u32) ![]align(1) const elf.Elf64_Rela { | |
| 1350 | fn preadRelocsAlloc(self: Object, gpa: Allocator, handle: Io.File, shndx: u32) ![]align(1) const elf.Elf64_Rela { | |
| 1324 | 1351 | const raw = try self.preadShdrContentsAlloc(gpa, handle, shndx); |
| 1325 | 1352 | const num = @divExact(raw.len, @sizeOf(elf.Elf64_Rela)); |
| 1326 | 1353 | return @as([*]align(1) const elf.Elf64_Rela, @ptrCast(raw.ptr))[0..num]; |
| ... | ... | @@ -1552,29 +1579,3 @@ const InArchive = struct { |
| 1552 | 1579 | offset: u64, |
| 1553 | 1580 | size: u32, |
| 1554 | 1581 | }; |
| 1555 | ||
| 1556 | const Object = @This(); | |
| 1557 | ||
| 1558 | const std = @import("std"); | |
| 1559 | const assert = std.debug.assert; | |
| 1560 | const eh_frame = @import("eh_frame.zig"); | |
| 1561 | const elf = std.elf; | |
| 1562 | const fs = std.fs; | |
| 1563 | const log = std.log.scoped(.link); | |
| 1564 | const math = std.math; | |
| 1565 | const mem = std.mem; | |
| 1566 | const Path = std.Build.Cache.Path; | |
| 1567 | const Allocator = std.mem.Allocator; | |
| 1568 | ||
| 1569 | const Diags = @import("../../link.zig").Diags; | |
| 1570 | const Archive = @import("Archive.zig"); | |
| 1571 | const Atom = @import("Atom.zig"); | |
| 1572 | const AtomList = @import("AtomList.zig"); | |
| 1573 | const Cie = eh_frame.Cie; | |
| 1574 | const Elf = @import("../Elf.zig"); | |
| 1575 | const Fde = eh_frame.Fde; | |
| 1576 | const File = @import("file.zig").File; | |
| 1577 | const Merge = @import("Merge.zig"); | |
| 1578 | const Symbol = @import("Symbol.zig"); | |
| 1579 | const Alignment = Atom.Alignment; | |
| 1580 | const riscv = @import("../riscv.zig"); |
src/link/Elf/SharedObject.zig+19-18| ... | ... | @@ -1,3 +1,20 @@ |
| 1 | const SharedObject = @This(); | |
| 2 | ||
| 3 | const std = @import("std"); | |
| 4 | const Io = std.Io; | |
| 5 | const assert = std.debug.assert; | |
| 6 | const elf = std.elf; | |
| 7 | const log = std.log.scoped(.elf); | |
| 8 | const mem = std.mem; | |
| 9 | const Path = std.Build.Cache.Path; | |
| 10 | const Stat = std.Build.Cache.File.Stat; | |
| 11 | const Allocator = mem.Allocator; | |
| 12 | ||
| 13 | const Elf = @import("../Elf.zig"); | |
| 14 | const File = @import("file.zig").File; | |
| 15 | const Symbol = @import("Symbol.zig"); | |
| 16 | const Diags = @import("../../link.zig").Diags; | |
| 17 | ||
| 1 | 18 | path: Path, |
| 2 | 19 | index: File.Index, |
| 3 | 20 | |
| ... | ... | @@ -94,7 +111,7 @@ pub fn parseHeader( |
| 94 | 111 | gpa: Allocator, |
| 95 | 112 | diags: *Diags, |
| 96 | 113 | file_path: Path, |
| 97 | fs_file: std.fs.File, | |
| 114 | fs_file: Io.File, | |
| 98 | 115 | stat: Stat, |
| 99 | 116 | target: *const std.Target, |
| 100 | 117 | ) !Header { |
| ... | ... | @@ -192,7 +209,7 @@ pub fn parse( |
| 192 | 209 | gpa: Allocator, |
| 193 | 210 | /// Moves resources from header. Caller may unconditionally deinit. |
| 194 | 211 | header: *Header, |
| 195 | fs_file: std.fs.File, | |
| 212 | fs_file: Io.File, | |
| 196 | 213 | ) !Parsed { |
| 197 | 214 | const symtab = if (header.dynsym_sect_index) |index| st: { |
| 198 | 215 | const shdr = header.sections[index]; |
| ... | ... | @@ -534,19 +551,3 @@ const Format = struct { |
| 534 | 551 | } |
| 535 | 552 | } |
| 536 | 553 | }; |
| 537 | ||
| 538 | const SharedObject = @This(); | |
| 539 | ||
| 540 | const std = @import("std"); | |
| 541 | const assert = std.debug.assert; | |
| 542 | const elf = std.elf; | |
| 543 | const log = std.log.scoped(.elf); | |
| 544 | const mem = std.mem; | |
| 545 | const Path = std.Build.Cache.Path; | |
| 546 | const Stat = std.Build.Cache.File.Stat; | |
| 547 | const Allocator = mem.Allocator; | |
| 548 | ||
| 549 | const Elf = @import("../Elf.zig"); | |
| 550 | const File = @import("file.zig").File; | |
| 551 | const Symbol = @import("Symbol.zig"); | |
| 552 | const Diags = @import("../../link.zig").Diags; |
src/link/Elf/file.zig+18-17| ... | ... | @@ -1,3 +1,20 @@ |
| 1 | const std = @import("std"); | |
| 2 | const Io = std.Io; | |
| 3 | const elf = std.elf; | |
| 4 | const log = std.log.scoped(.link); | |
| 5 | const Path = std.Build.Cache.Path; | |
| 6 | const Allocator = std.mem.Allocator; | |
| 7 | ||
| 8 | const Archive = @import("Archive.zig"); | |
| 9 | const Atom = @import("Atom.zig"); | |
| 10 | const Cie = @import("eh_frame.zig").Cie; | |
| 11 | const Elf = @import("../Elf.zig"); | |
| 12 | const LinkerDefined = @import("LinkerDefined.zig"); | |
| 13 | const Object = @import("Object.zig"); | |
| 14 | const SharedObject = @import("SharedObject.zig"); | |
| 15 | const Symbol = @import("Symbol.zig"); | |
| 16 | const ZigObject = @import("ZigObject.zig"); | |
| 17 | ||
| 1 | 18 | pub const File = union(enum) { |
| 2 | 19 | zig_object: *ZigObject, |
| 3 | 20 | linker_defined: *LinkerDefined, |
| ... | ... | @@ -279,22 +296,6 @@ pub const File = union(enum) { |
| 279 | 296 | shared_object: SharedObject, |
| 280 | 297 | }; |
| 281 | 298 | |
| 282 | pub const Handle = std.fs.File; | |
| 299 | pub const Handle = Io.File; | |
| 283 | 300 | pub const HandleIndex = Index; |
| 284 | 301 | }; |
| 285 | ||
| 286 | const std = @import("std"); | |
| 287 | const elf = std.elf; | |
| 288 | const log = std.log.scoped(.link); | |
| 289 | const Path = std.Build.Cache.Path; | |
| 290 | const Allocator = std.mem.Allocator; | |
| 291 | ||
| 292 | const Archive = @import("Archive.zig"); | |
| 293 | const Atom = @import("Atom.zig"); | |
| 294 | const Cie = @import("eh_frame.zig").Cie; | |
| 295 | const Elf = @import("../Elf.zig"); | |
| 296 | const LinkerDefined = @import("LinkerDefined.zig"); | |
| 297 | const Object = @import("Object.zig"); | |
| 298 | const SharedObject = @import("SharedObject.zig"); | |
| 299 | const Symbol = @import("Symbol.zig"); | |
| 300 | const ZigObject = @import("ZigObject.zig"); |
src/link/Elf2.zig+25-21| ... | ... | @@ -1,3 +1,23 @@ |
| 1 | const Elf = @This(); | |
| 2 | ||
| 3 | const builtin = @import("builtin"); | |
| 4 | const native_endian = builtin.cpu.arch.endian(); | |
| 5 | ||
| 6 | const std = @import("std"); | |
| 7 | const Io = std.Io; | |
| 8 | const assert = std.debug.assert; | |
| 9 | const log = std.log.scoped(.link); | |
| 10 | ||
| 11 | const codegen = @import("../codegen.zig"); | |
| 12 | const Compilation = @import("../Compilation.zig"); | |
| 13 | const InternPool = @import("../InternPool.zig"); | |
| 14 | const link = @import("../link.zig"); | |
| 15 | const MappedFile = @import("MappedFile.zig"); | |
| 16 | const target_util = @import("../target.zig"); | |
| 17 | const Type = @import("../Type.zig"); | |
| 18 | const Value = @import("../Value.zig"); | |
| 19 | const Zcu = @import("../Zcu.zig"); | |
| 20 | ||
| 1 | 21 | base: link.File, |
| 2 | 22 | options: link.File.OpenOptions, |
| 3 | 23 | mf: MappedFile, |
| ... | ... | @@ -1973,8 +1993,8 @@ pub fn lazySymbol(elf: *Elf, lazy: link.File.LazySymbol) !Symbol.Index { |
| 1973 | 1993 | return lazy_gop.value_ptr.*; |
| 1974 | 1994 | } |
| 1975 | 1995 | |
| 1976 | pub 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 { | |
| 1996 | pub fn loadInput(elf: *Elf, input: link.Input) (Io.File.Reader.SizeError || | |
| 1997 | Io.File.Reader.Error || MappedFile.Error || error{ EndOfStream, BadMagic, LinkFailure })!void { | |
| 1978 | 1998 | const io = elf.base.comp.io; |
| 1979 | 1999 | var buf: [4096]u8 = undefined; |
| 1980 | 2000 | switch (input) { |
| ... | ... | @@ -2007,7 +2027,7 @@ pub fn loadInput(elf: *Elf, input: link.Input) (std.fs.File.Reader.SizeError || |
| 2007 | 2027 | .dso_exact => |dso_exact| try elf.loadDsoExact(dso_exact.name), |
| 2008 | 2028 | } |
| 2009 | 2029 | } |
| 2010 | fn loadArchive(elf: *Elf, path: std.Build.Cache.Path, fr: *std.Io.File.Reader) !void { | |
| 2030 | fn loadArchive(elf: *Elf, path: std.Build.Cache.Path, fr: *Io.File.Reader) !void { | |
| 2011 | 2031 | const comp = elf.base.comp; |
| 2012 | 2032 | const gpa = comp.gpa; |
| 2013 | 2033 | const diags = &comp.link_diags; |
| ... | ... | @@ -2067,7 +2087,7 @@ fn loadObject( |
| 2067 | 2087 | elf: *Elf, |
| 2068 | 2088 | path: std.Build.Cache.Path, |
| 2069 | 2089 | member: ?[]const u8, |
| 2070 | fr: *std.Io.File.Reader, | |
| 2090 | fr: *Io.File.Reader, | |
| 2071 | 2091 | fl: MappedFile.Node.FileLocation, |
| 2072 | 2092 | ) !void { |
| 2073 | 2093 | const comp = elf.base.comp; |
| ... | ... | @@ -2310,7 +2330,7 @@ fn loadObject( |
| 2310 | 2330 | }, |
| 2311 | 2331 | } |
| 2312 | 2332 | } |
| 2313 | fn loadDso(elf: *Elf, path: std.Build.Cache.Path, fr: *std.Io.File.Reader) !void { | |
| 2333 | fn loadDso(elf: *Elf, path: std.Build.Cache.Path, fr: *Io.File.Reader) !void { | |
| 2314 | 2334 | const comp = elf.base.comp; |
| 2315 | 2335 | const diags = &comp.link_diags; |
| 2316 | 2336 | const r = &fr.interface; |
| ... | ... | @@ -3822,19 +3842,3 @@ pub fn printNode( |
| 3822 | 3842 | try w.writeByte('\n'); |
| 3823 | 3843 | } |
| 3824 | 3844 | } |
| 3825 | ||
| 3826 | const assert = std.debug.assert; | |
| 3827 | const builtin = @import("builtin"); | |
| 3828 | const codegen = @import("../codegen.zig"); | |
| 3829 | const Compilation = @import("../Compilation.zig"); | |
| 3830 | const Elf = @This(); | |
| 3831 | const InternPool = @import("../InternPool.zig"); | |
| 3832 | const link = @import("../link.zig"); | |
| 3833 | const log = std.log.scoped(.link); | |
| 3834 | const MappedFile = @import("MappedFile.zig"); | |
| 3835 | const native_endian = builtin.cpu.arch.endian(); | |
| 3836 | const std = @import("std"); | |
| 3837 | const target_util = @import("../target.zig"); | |
| 3838 | const Type = @import("../Type.zig"); | |
| 3839 | const Value = @import("../Value.zig"); | |
| 3840 | const Zcu = @import("../Zcu.zig"); |
src/link/MachO.zig+12-11| ... | ... | @@ -890,7 +890,7 @@ pub fn classifyInputFile(self: *MachO, input: link.Input) !void { |
| 890 | 890 | _ = try self.addTbd(.fromLinkInput(input), true, fh); |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | fn parseFatFile(self: *MachO, file: std.fs.File, path: Path) !?fat.Arch { | |
| 893 | fn parseFatFile(self: *MachO, file: Io.File, path: Path) !?fat.Arch { | |
| 894 | 894 | const diags = &self.base.comp.link_diags; |
| 895 | 895 | const fat_h = fat.readFatHeader(file) catch return null; |
| 896 | 896 | 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 { |
| 903 | 903 | return diags.failParse(path, "missing arch in universal file: expected {s}", .{@tagName(cpu_arch)}); |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | pub fn readMachHeader(file: std.fs.File, offset: usize) !macho.mach_header_64 { | |
| 906 | pub fn readMachHeader(file: Io.File, offset: usize) !macho.mach_header_64 { | |
| 907 | 907 | var buffer: [@sizeOf(macho.mach_header_64)]u8 = undefined; |
| 908 | 908 | const nread = try file.preadAll(&buffer, offset); |
| 909 | 909 | if (nread != buffer.len) return error.InputOutput; |
| ... | ... | @@ -911,7 +911,7 @@ pub fn readMachHeader(file: std.fs.File, offset: usize) !macho.mach_header_64 { |
| 911 | 911 | return hdr; |
| 912 | 912 | } |
| 913 | 913 | |
| 914 | pub fn readArMagic(file: std.fs.File, offset: usize, buffer: *[Archive.SARMAG]u8) ![]const u8 { | |
| 914 | pub fn readArMagic(file: Io.File, offset: usize, buffer: *[Archive.SARMAG]u8) ![]const u8 { | |
| 915 | 915 | const nread = try file.preadAll(buffer, offset); |
| 916 | 916 | if (nread != buffer.len) return error.InputOutput; |
| 917 | 917 | return buffer[0..Archive.SARMAG]; |
| ... | ... | @@ -3768,7 +3768,7 @@ pub fn getInternalObject(self: *MachO) ?*InternalObject { |
| 3768 | 3768 | return self.getFile(index).?.internal; |
| 3769 | 3769 | } |
| 3770 | 3770 | |
| 3771 | pub fn addFileHandle(self: *MachO, file: fs.File) !File.HandleIndex { | |
| 3771 | pub fn addFileHandle(self: *MachO, file: Io.File) !File.HandleIndex { | |
| 3772 | 3772 | const gpa = self.base.comp.gpa; |
| 3773 | 3773 | const index: File.HandleIndex = @intCast(self.file_handles.items.len); |
| 3774 | 3774 | const fh = try self.file_handles.addOne(gpa); |
| ... | ... | @@ -5373,10 +5373,11 @@ const max_distance = (1 << (jump_bits - 1)); |
| 5373 | 5373 | const max_allowed_distance = max_distance - 0x500_000; |
| 5374 | 5374 | |
| 5375 | 5375 | const MachO = @This(); |
| 5376 | ||
| 5377 | const std = @import("std"); | |
| 5378 | 5376 | const build_options = @import("build_options"); |
| 5379 | 5377 | const builtin = @import("builtin"); |
| 5378 | ||
| 5379 | const std = @import("std"); | |
| 5380 | const Io = std.Io; | |
| 5380 | 5381 | const assert = std.debug.assert; |
| 5381 | 5382 | const fs = std.fs; |
| 5382 | 5383 | const log = std.log.scoped(.link); |
| ... | ... | @@ -5386,6 +5387,11 @@ const math = std.math; |
| 5386 | 5387 | const mem = std.mem; |
| 5387 | 5388 | const meta = std.meta; |
| 5388 | 5389 | const Writer = std.Io.Writer; |
| 5390 | const AtomicBool = std.atomic.Value(bool); | |
| 5391 | const Cache = std.Build.Cache; | |
| 5392 | const Hash = std.hash.Wyhash; | |
| 5393 | const Md5 = std.crypto.hash.Md5; | |
| 5394 | const Allocator = std.mem.Allocator; | |
| 5389 | 5395 | |
| 5390 | 5396 | const aarch64 = codegen.aarch64.encoding; |
| 5391 | 5397 | const bind = @import("MachO/dyld_info/bind.zig"); |
| ... | ... | @@ -5403,11 +5409,8 @@ const trace = @import("../tracy.zig").trace; |
| 5403 | 5409 | const synthetic = @import("MachO/synthetic.zig"); |
| 5404 | 5410 | |
| 5405 | 5411 | const Alignment = Atom.Alignment; |
| 5406 | const Allocator = mem.Allocator; | |
| 5407 | 5412 | const Archive = @import("MachO/Archive.zig"); |
| 5408 | const AtomicBool = std.atomic.Value(bool); | |
| 5409 | 5413 | const Bind = bind.Bind; |
| 5410 | const Cache = std.Build.Cache; | |
| 5411 | 5414 | const CodeSignature = @import("MachO/CodeSignature.zig"); |
| 5412 | 5415 | const Compilation = @import("../Compilation.zig"); |
| 5413 | 5416 | const DataInCode = synthetic.DataInCode; |
| ... | ... | @@ -5417,14 +5420,12 @@ const ExportTrie = @import("MachO/dyld_info/Trie.zig"); |
| 5417 | 5420 | const Path = Cache.Path; |
| 5418 | 5421 | const File = @import("MachO/file.zig").File; |
| 5419 | 5422 | const GotSection = synthetic.GotSection; |
| 5420 | const Hash = std.hash.Wyhash; | |
| 5421 | 5423 | const Indsymtab = synthetic.Indsymtab; |
| 5422 | 5424 | const InternalObject = @import("MachO/InternalObject.zig"); |
| 5423 | 5425 | const ObjcStubsSection = synthetic.ObjcStubsSection; |
| 5424 | 5426 | const Object = @import("MachO/Object.zig"); |
| 5425 | 5427 | const LazyBind = bind.LazyBind; |
| 5426 | 5428 | const LaSymbolPtrSection = synthetic.LaSymbolPtrSection; |
| 5427 | const Md5 = std.crypto.hash.Md5; | |
| 5428 | 5429 | const Zcu = @import("../Zcu.zig"); |
| 5429 | 5430 | const InternPool = @import("../InternPool.zig"); |
| 5430 | 5431 | const Rebase = @import("MachO/dyld_info/Rebase.zig"); |
src/link/MachO/CodeSignature.zig+5-3| ... | ... | @@ -1,17 +1,19 @@ |
| 1 | 1 | const CodeSignature = @This(); |
| 2 | 2 | |
| 3 | 3 | const std = @import("std"); |
| 4 | const Io = std.Io; | |
| 4 | 5 | const assert = std.debug.assert; |
| 5 | 6 | const fs = std.fs; |
| 6 | 7 | const log = std.log.scoped(.link); |
| 7 | 8 | const macho = std.macho; |
| 8 | 9 | const mem = std.mem; |
| 9 | 10 | const testing = std.testing; |
| 11 | const Sha256 = std.crypto.hash.sha2.Sha256; | |
| 12 | const Allocator = std.mem.Allocator; | |
| 13 | ||
| 10 | 14 | const trace = @import("../../tracy.zig").trace; |
| 11 | const Allocator = mem.Allocator; | |
| 12 | 15 | const Hasher = @import("hasher.zig").ParallelHasher; |
| 13 | 16 | const MachO = @import("../MachO.zig"); |
| 14 | const Sha256 = std.crypto.hash.sha2.Sha256; | |
| 15 | 17 | |
| 16 | 18 | const hash_size = Sha256.digest_length; |
| 17 | 19 | |
| ... | ... | @@ -250,7 +252,7 @@ pub fn addEntitlements(self: *CodeSignature, allocator: Allocator, path: []const |
| 250 | 252 | } |
| 251 | 253 | |
| 252 | 254 | pub const WriteOpts = struct { |
| 253 | file: fs.File, | |
| 255 | file: Io.File, | |
| 254 | 256 | exec_seg_base: u64, |
| 255 | 257 | exec_seg_limit: u64, |
| 256 | 258 | file_size: u32, |
src/link/MachO/fat.zig+7-5| ... | ... | @@ -1,18 +1,20 @@ |
| 1 | const builtin = @import("builtin"); | |
| 2 | const native_endian = builtin.target.cpu.arch.endian(); | |
| 3 | ||
| 1 | 4 | const std = @import("std"); |
| 5 | const Io = std.Io; | |
| 2 | 6 | const assert = std.debug.assert; |
| 3 | const builtin = @import("builtin"); | |
| 4 | 7 | const log = std.log.scoped(.macho); |
| 5 | 8 | const macho = std.macho; |
| 6 | 9 | const mem = std.mem; |
| 7 | const native_endian = builtin.target.cpu.arch.endian(); | |
| 8 | 10 | |
| 9 | 11 | const MachO = @import("../MachO.zig"); |
| 10 | 12 | |
| 11 | pub fn readFatHeader(file: std.fs.File) !macho.fat_header { | |
| 13 | pub fn readFatHeader(file: Io.File) !macho.fat_header { | |
| 12 | 14 | return readFatHeaderGeneric(macho.fat_header, file, 0); |
| 13 | 15 | } |
| 14 | 16 | |
| 15 | fn readFatHeaderGeneric(comptime Hdr: type, file: std.fs.File, offset: usize) !Hdr { | |
| 17 | fn readFatHeaderGeneric(comptime Hdr: type, file: Io.File, offset: usize) !Hdr { | |
| 16 | 18 | var buffer: [@sizeOf(Hdr)]u8 = undefined; |
| 17 | 19 | const nread = try file.preadAll(&buffer, offset); |
| 18 | 20 | if (nread != buffer.len) return error.InputOutput; |
| ... | ... | @@ -27,7 +29,7 @@ pub const Arch = struct { |
| 27 | 29 | size: u32, |
| 28 | 30 | }; |
| 29 | 31 | |
| 30 | pub fn parseArchs(file: std.fs.File, fat_header: macho.fat_header, out: *[2]Arch) ![]const Arch { | |
| 32 | pub fn parseArchs(file: Io.File, fat_header: macho.fat_header, out: *[2]Arch) ![]const Arch { | |
| 31 | 33 | var count: usize = 0; |
| 32 | 34 | var fat_arch_index: u32 = 0; |
| 33 | 35 | 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) { |
| 355 | 355 | dylib: Dylib, |
| 356 | 356 | }; |
| 357 | 357 | |
| 358 | pub const Handle = std.fs.File; | |
| 358 | pub const Handle = Io.File; | |
| 359 | 359 | pub const HandleIndex = Index; |
| 360 | 360 | }; |
| 361 | 361 | |
| 362 | 362 | const std = @import("std"); |
| 363 | const Io = std.Io; | |
| 363 | 364 | const assert = std.debug.assert; |
| 364 | 365 | const log = std.log.scoped(.link); |
| 365 | 366 | const macho = std.macho; |
src/link/MachO/hasher.zig+10-12| ... | ... | @@ -1,3 +1,9 @@ |
| 1 | const std = @import("std"); | |
| 2 | const Io = std.Io; | |
| 3 | const Allocator = std.mem.Allocator; | |
| 4 | ||
| 5 | const trace = @import("../../tracy.zig").trace; | |
| 6 | ||
| 1 | 7 | pub fn ParallelHasher(comptime Hasher: type) type { |
| 2 | 8 | const hash_size = Hasher.digest_length; |
| 3 | 9 | |
| ... | ... | @@ -5,7 +11,7 @@ pub fn ParallelHasher(comptime Hasher: type) type { |
| 5 | 11 | allocator: Allocator, |
| 6 | 12 | io: std.Io, |
| 7 | 13 | |
| 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 { | |
| 9 | 15 | chunk_size: u64 = 0x4000, |
| 10 | 16 | max_file_size: ?u64 = null, |
| 11 | 17 | }) !void { |
| ... | ... | @@ -23,7 +29,7 @@ pub fn ParallelHasher(comptime Hasher: type) type { |
| 23 | 29 | const buffer = try self.allocator.alloc(u8, chunk_size * out.len); |
| 24 | 30 | defer self.allocator.free(buffer); |
| 25 | 31 | |
| 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); | |
| 27 | 33 | defer self.allocator.free(results); |
| 28 | 34 | |
| 29 | 35 | { |
| ... | ... | @@ -51,11 +57,11 @@ pub fn ParallelHasher(comptime Hasher: type) type { |
| 51 | 57 | } |
| 52 | 58 | |
| 53 | 59 | fn worker( |
| 54 | file: fs.File, | |
| 60 | file: Io.File, | |
| 55 | 61 | fstart: usize, |
| 56 | 62 | buffer: []u8, |
| 57 | 63 | out: *[hash_size]u8, |
| 58 | err: *fs.File.PReadError!usize, | |
| 64 | err: *Io.File.PReadError!usize, | |
| 59 | 65 | ) void { |
| 60 | 66 | const tracy = trace(@src()); |
| 61 | 67 | defer tracy.end(); |
| ... | ... | @@ -66,11 +72,3 @@ pub fn ParallelHasher(comptime Hasher: type) type { |
| 66 | 72 | const Self = @This(); |
| 67 | 73 | }; |
| 68 | 74 | } |
| 69 | ||
| 70 | const assert = std.debug.assert; | |
| 71 | const fs = std.fs; | |
| 72 | const mem = std.mem; | |
| 73 | const std = @import("std"); | |
| 74 | const trace = @import("../../tracy.zig").trace; | |
| 75 | ||
| 76 | const Allocator = mem.Allocator; |
src/link/MachO/uuid.zig+9-10| ... | ... | @@ -1,10 +1,18 @@ |
| 1 | const std = @import("std"); | |
| 2 | const Io = std.Io; | |
| 3 | const Md5 = std.crypto.hash.Md5; | |
| 4 | ||
| 5 | const trace = @import("../../tracy.zig").trace; | |
| 6 | const Compilation = @import("../../Compilation.zig"); | |
| 7 | const Hasher = @import("hasher.zig").ParallelHasher; | |
| 8 | ||
| 1 | 9 | /// Calculates Md5 hash of each chunk in parallel and then hashes all Md5 hashes to produce |
| 2 | 10 | /// the final digest. |
| 3 | 11 | /// While this is NOT a correct MD5 hash of the contents, this methodology is used by LLVM/LLD |
| 4 | 12 | /// and we will use it too as it seems accepted by Apple OSes. |
| 5 | 13 | /// TODO LLD also hashes the output filename to disambiguate between same builds with different |
| 6 | 14 | /// output files. Should we also do that? |
| 7 | pub fn calcUuid(comp: *const Compilation, file: fs.File, file_size: u64, out: *[Md5.digest_length]u8) !void { | |
| 15 | pub fn calcUuid(comp: *const Compilation, file: Io.File, file_size: u64, out: *[Md5.digest_length]u8) !void { | |
| 8 | 16 | const tracy = trace(@src()); |
| 9 | 17 | defer tracy.end(); |
| 10 | 18 | |
| ... | ... | @@ -37,12 +45,3 @@ inline fn conform(out: *[Md5.digest_length]u8) void { |
| 37 | 45 | out[6] = (out[6] & 0x0F) | (3 << 4); |
| 38 | 46 | out[8] = (out[8] & 0x3F) | 0x80; |
| 39 | 47 | } |
| 40 | ||
| 41 | const fs = std.fs; | |
| 42 | const mem = std.mem; | |
| 43 | const std = @import("std"); | |
| 44 | const trace = @import("../../tracy.zig").trace; | |
| 45 | ||
| 46 | const Compilation = @import("../../Compilation.zig"); | |
| 47 | const Md5 = std.crypto.hash.Md5; | |
| 48 | const Hasher = @import("hasher.zig").ParallelHasher; |
src/link/MappedFile.zig+14-11| ... | ... | @@ -1,3 +1,15 @@ |
| 1 | const MappedFile = @This(); | |
| 2 | ||
| 3 | const builtin = @import("builtin"); | |
| 4 | const is_linux = builtin.os.tag == .linux; | |
| 5 | const is_windows = builtin.os.tag == .windows; | |
| 6 | ||
| 7 | const std = @import("std"); | |
| 8 | const Io = std.Io; | |
| 9 | const assert = std.debug.assert; | |
| 10 | const linux = std.os.linux; | |
| 11 | const windows = std.os.windows; | |
| 12 | ||
| 1 | 13 | file: std.Io.File, |
| 2 | 14 | flags: packed struct { |
| 3 | 15 | block_size: std.mem.Alignment, |
| ... | ... | @@ -16,7 +28,7 @@ writers: std.SinglyLinkedList, |
| 16 | 28 | |
| 17 | 29 | pub const growth_factor = 4; |
| 18 | 30 | |
| 19 | pub const Error = std.posix.MMapError || std.posix.MRemapError || std.fs.File.SetEndPosError || error{ | |
| 31 | pub const Error = std.posix.MMapError || std.posix.MRemapError || Io.File.SetEndPosError || error{ | |
| 20 | 32 | NotFile, |
| 21 | 33 | SystemResources, |
| 22 | 34 | IsDir, |
| ... | ... | @@ -618,7 +630,7 @@ fn resizeNode(mf: *MappedFile, gpa: std.mem.Allocator, ni: Node.Index, requested |
| 618 | 630 | // Resize the entire file |
| 619 | 631 | if (ni == Node.Index.root) { |
| 620 | 632 | 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); | |
| 622 | 634 | try mf.ensureTotalCapacity(@intCast(new_size)); |
| 623 | 635 | ni.setLocationAssumeCapacity(mf, old_offset, new_size); |
| 624 | 636 | return; |
| ... | ... | @@ -1059,12 +1071,3 @@ fn verifyNode(mf: *MappedFile, parent_ni: Node.Index) void { |
| 1059 | 1071 | ni = node.next; |
| 1060 | 1072 | } |
| 1061 | 1073 | } |
| 1062 | ||
| 1063 | const assert = std.debug.assert; | |
| 1064 | const builtin = @import("builtin"); | |
| 1065 | const is_linux = builtin.os.tag == .linux; | |
| 1066 | const is_windows = builtin.os.tag == .windows; | |
| 1067 | const linux = std.os.linux; | |
| 1068 | const MappedFile = @This(); | |
| 1069 | const std = @import("std"); | |
| 1070 | const windows = std.os.windows; |
src/link/Wasm.zig+3-2| ... | ... | @@ -20,6 +20,7 @@ const native_endian = builtin.cpu.arch.endian(); |
| 20 | 20 | const build_options = @import("build_options"); |
| 21 | 21 | |
| 22 | 22 | const std = @import("std"); |
| 23 | const Io = std.Io; | |
| 23 | 24 | const Allocator = std.mem.Allocator; |
| 24 | 25 | const Cache = std.Build.Cache; |
| 25 | 26 | const Path = Cache.Path; |
| ... | ... | @@ -3001,9 +3002,9 @@ pub fn createEmpty( |
| 3001 | 3002 | .read = true, |
| 3002 | 3003 | .mode = if (fs.has_executable_bit) |
| 3003 | 3004 | 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 | |
| 3005 | 3006 | else |
| 3006 | fs.File.default_mode | |
| 3007 | Io.File.default_mode | |
| 3007 | 3008 | else |
| 3008 | 3009 | 0, |
| 3009 | 3010 | }); |
src/link/tapi.zig+5-5| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const fs = std.fs; | |
| 2 | const Io = std.Io; | |
| 3 | 3 | const mem = std.mem; |
| 4 | 4 | const log = std.log.scoped(.tapi); |
| 5 | const yaml = @import("tapi/yaml.zig"); | |
| 5 | const Allocator = std.mem.Allocator; | |
| 6 | 6 | |
| 7 | const Allocator = mem.Allocator; | |
| 7 | const yaml = @import("tapi/yaml.zig"); | |
| 8 | 8 | const Yaml = yaml.Yaml; |
| 9 | 9 | |
| 10 | 10 | const VersionField = union(enum) { |
| ... | ... | @@ -130,7 +130,7 @@ pub const Tbd = union(enum) { |
| 130 | 130 | pub const TapiError = error{ |
| 131 | 131 | NotLibStub, |
| 132 | 132 | InputOutput, |
| 133 | } || yaml.YamlError || std.fs.File.PReadError; | |
| 133 | } || yaml.YamlError || Io.File.PReadError; | |
| 134 | 134 | |
| 135 | 135 | pub const LibStub = struct { |
| 136 | 136 | /// Underlying memory for stub's contents. |
| ... | ... | @@ -139,7 +139,7 @@ pub const LibStub = struct { |
| 139 | 139 | /// Typed contents of the tbd file. |
| 140 | 140 | inner: []Tbd, |
| 141 | 141 | |
| 142 | pub fn loadFromFile(allocator: Allocator, file: fs.File) TapiError!LibStub { | |
| 142 | pub fn loadFromFile(allocator: Allocator, file: Io.File) TapiError!LibStub { | |
| 143 | 143 | const filesize = blk: { |
| 144 | 144 | const stat = file.stat() catch break :blk std.math.maxInt(u32); |
| 145 | 145 | break :blk @min(stat.size, std.math.maxInt(u32)); |