Skip to content

Commit a189335

Browse files
committed
zig std: update std.Io.poll API usage
fixes FTBFS
1 parent 4236ca4 commit a189335

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

lib/compiler/std-docs.zig

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -319,21 +319,17 @@ fn buildWasmBinary(
319319
try sendMessage(child.stdin.?, .update);
320320
try sendMessage(child.stdin.?, .exit);
321321

322-
const Header = std.zig.Server.Message.Header;
323322
var result: ?Cache.Path = null;
324323
var result_error_bundle = std.zig.ErrorBundle.empty;
325324

326-
const stdout = poller.fifo(.stdout);
325+
const stdout = poller.reader(.stdout);
327326

328327
poll: while (true) {
329-
while (stdout.readableLength() < @sizeOf(Header)) {
330-
if (!(try poller.poll())) break :poll;
331-
}
332-
const header = stdout.reader().readStruct(Header) catch unreachable;
333-
while (stdout.readableLength() < header.bytes_len) {
334-
if (!(try poller.poll())) break :poll;
335-
}
336-
const body = stdout.readableSliceOfLen(header.bytes_len);
328+
const Header = std.zig.Server.Message.Header;
329+
while (stdout.buffered().len < @sizeOf(Header)) if (!try poller.poll()) break :poll;
330+
const header = stdout.takeStruct(Header, .little) catch unreachable;
331+
while (stdout.buffered().len < header.bytes_len) if (!try poller.poll()) break :poll;
332+
const body = stdout.take(header.bytes_len) catch unreachable;
337333

338334
switch (header.tag) {
339335
.zig_version => {
@@ -373,15 +369,11 @@ fn buildWasmBinary(
373369
},
374370
else => {}, // ignore other messages
375371
}
376-
377-
stdout.discard(body.len);
378372
}
379373

380-
const stderr = poller.fifo(.stderr);
381-
if (stderr.readableLength() > 0) {
382-
const owned_stderr = try stderr.toOwnedSlice();
383-
defer gpa.free(owned_stderr);
384-
std.debug.print("{s}", .{owned_stderr});
374+
const stderr = poller.reader(.stderr);
375+
if (stderr.bufferedLen() > 0) {
376+
std.debug.print("{s}", .{stderr.buffered()});
385377
}
386378

387379
// Send EOF to stdin.

0 commit comments

Comments
 (0)