authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-22 05:01:37-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-29 06:20:51-07:00
log873bcb5aa66fd4fdd747b90ba0ed529117478368
treec3b5c1b083e99b3f114428ab4d4bf3786984be57
parent032152409be26f12031c6c16ac9de5e29cd08b8f

fix some std.Io compilation failures


2 files changed, 10 insertions(+), 3 deletions(-)

lib/compiler/objcopy.zig+5-2
...@@ -29,7 +29,6 @@ pub fn main() !void {...@@ -29,7 +29,6 @@ pub fn main() !void {
29}29}
3030
31fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {31fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
32 _ = gpa;
33 var i: usize = 0;32 var i: usize = 0;
34 var opt_out_fmt: ?std.Target.ObjectFormat = null;33 var opt_out_fmt: ?std.Target.ObjectFormat = null;
35 var opt_input: ?[]const u8 = null;34 var opt_input: ?[]const u8 = null;
...@@ -148,12 +147,16 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void...@@ -148,12 +147,16 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
148 const input = opt_input orelse fatal("expected input parameter", .{});147 const input = opt_input orelse fatal("expected input parameter", .{});
149 const output = opt_output orelse fatal("expected output parameter", .{});148 const output = opt_output orelse fatal("expected output parameter", .{});
150149
150 var threaded: std.Io.Threaded = .init(gpa);
151 defer threaded.deinit();
152 const io = threaded.io();
153
151 const input_file = fs.cwd().openFile(input, .{}) catch |err| fatal("failed to open {s}: {t}", .{ input, err });154 const input_file = fs.cwd().openFile(input, .{}) catch |err| fatal("failed to open {s}: {t}", .{ input, err });
152 defer input_file.close();155 defer input_file.close();
153156
154 const stat = input_file.stat() catch |err| fatal("failed to stat {s}: {t}", .{ input, err });157 const stat = input_file.stat() catch |err| fatal("failed to stat {s}: {t}", .{ input, err });
155158
156 var in: File.Reader = .initSize(input_file, &input_buffer, stat.size);159 var in: File.Reader = .initSize(input_file, io, &input_buffer, stat.size);
157160
158 const elf_hdr = std.elf.Header.read(&in.interface) catch |err| switch (err) {161 const elf_hdr = std.elf.Header.read(&in.interface) catch |err| switch (err) {
159 error.ReadFailed => fatal("unable to read {s}: {t}", .{ input, in.err.? }),162 error.ReadFailed => fatal("unable to read {s}: {t}", .{ input, in.err.? }),
test/standalone/child_process/main.zig+5-1
...@@ -20,6 +20,10 @@ pub fn main() !void {...@@ -20,6 +20,10 @@ pub fn main() !void {
20 };20 };
21 defer if (needs_free) gpa.free(child_path);21 defer if (needs_free) gpa.free(child_path);
2222
23 var threaded: std.Io.Threaded = .init(gpa);
24 defer threaded.deinit();
25 const io = threaded.io();
26
23 var child = std.process.Child.init(&.{ child_path, "hello arg" }, gpa);27 var child = std.process.Child.init(&.{ child_path, "hello arg" }, gpa);
24 child.stdin_behavior = .Pipe;28 child.stdin_behavior = .Pipe;
25 child.stdout_behavior = .Pipe;29 child.stdout_behavior = .Pipe;
...@@ -32,7 +36,7 @@ pub fn main() !void {...@@ -32,7 +36,7 @@ pub fn main() !void {
3236
33 const hello_stdout = "hello from stdout";37 const hello_stdout = "hello from stdout";
34 var buf: [hello_stdout.len]u8 = undefined;38 var buf: [hello_stdout.len]u8 = undefined;
35 var stdout_reader = child.stdout.?.readerStreaming(&.{});39 var stdout_reader = child.stdout.?.readerStreaming(io, &.{});
36 const n = try stdout_reader.interface.readSliceShort(&buf);40 const n = try stdout_reader.interface.readSliceShort(&buf);
37 if (!std.mem.eql(u8, buf[0..n], hello_stdout)) {41 if (!std.mem.eql(u8, buf[0..n], hello_stdout)) {
38 testError("child stdout: '{s}'; want '{s}'", .{ buf[0..n], hello_stdout });42 testError("child stdout: '{s}'; want '{s}'", .{ buf[0..n], hello_stdout });