authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-16 21:39:03-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-30 12:10:01-08:00
log0f1a78b55405b586791d2a56ea96ff96a73f46d5
tree26ff6de99b9d296e996a097e767e1a719d5a1b3c
parentcfd142c4c6057bcfe66dfd2e98dfbf5111b1afcf

std.Io.Threaded: fix compilation failures on Windows

it's still broken as hell tho

1 files changed, 15 insertions(+), 11 deletions(-)

lib/std/Io/Threaded.zig+15-11
...@@ -1323,7 +1323,10 @@ fn waitForApcOrAlert() void {...@@ -1323,7 +1323,10 @@ fn waitForApcOrAlert() void {
13231323
1324const max_iovecs_len = 8;1324const max_iovecs_len = 8;
1325const splat_buffer_size = 64;1325const splat_buffer_size = 64;
1326const poll_buffer_len = 32;1326/// Happens to be the same number that matches maximum number of handles that
1327/// NtWaitForMultipleObjects accepts. We use this value also for poll() on
1328/// posix systems.
1329const poll_buffer_len = 64;
1327const default_PATH = "/usr/local/bin:/bin/:/usr/bin";1330const default_PATH = "/usr/local/bin:/bin/:/usr/bin";
13281331
1329comptime {1332comptime {
...@@ -2635,18 +2638,13 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa...@@ -2635,18 +2638,13 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa
2635 overlapped.* = .{2638 overlapped.* = .{
2636 .Internal = 0,2639 .Internal = 0,
2637 .InternalHigh = 0,2640 .InternalHigh = 0,
2638 .DUMMYUNIONNAME = .{2641 .DUMMYUNIONNAME = .{ .Pointer = null },
2639 .DUMMYSTRUCTNAME = .{
2640 .Offset = 0,
2641 .OffsetHigh = 0,
2642 },
2643 .Pointer = null,
2644 },
2645 .hEvent = null,2642 .hEvent = null,
2646 };2643 };
2647 var n: windows.DWORD = undefined;2644 var n: windows.DWORD = undefined;
2648 const buf = o.data[0];2645 const buf = o.data[0];
2649 if (windows.kernel32.ReadFile(o.file.handle, buf.ptr, buf.len, &n, overlapped) == 0) {2646 const buf_len = std.math.lossyCast(windows.DWORD, buf.len);
2647 if (windows.kernel32.ReadFile(o.file.handle, buf.ptr, buf_len, &n, overlapped) == 0) {
2650 @panic("TODO");2648 @panic("TODO");
2651 }2649 }
2652 handles_buffer[buffer_i] = o.file.handle;2650 handles_buffer[buffer_i] = o.file.handle;
...@@ -2663,6 +2661,7 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa...@@ -2663,6 +2661,7 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa
2663 try operate(t, &operations[op]);2661 try operate(t, &operations[op]);
2664 ring[complete_tail.index(len)] = op;2662 ring[complete_tail.index(len)] = op;
2665 complete_tail = complete_tail.next(len);2663 complete_tail = complete_tail.next(len);
2664 buffer_i = 0;
2666 return;2665 return;
2667 },2666 },
2668 else => {},2667 else => {},
...@@ -2672,10 +2671,15 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa...@@ -2672,10 +2671,15 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa
2672 const map = map_buffer[0..buffer_i];2671 const map = map_buffer[0..buffer_i];
26732672
2674 const syscall: Syscall = try .start();2673 const syscall: Syscall = try .start();
2675 const index = windows.WaitForMultipleObjectsEx(handles, false, windows.INFINITE, true);2674 const index_result = windows.WaitForMultipleObjectsEx(handles, false, windows.INFINITE, true);
2676 syscall.finish();2675 syscall.finish();
2676 const index = index_result catch |err| switch (err) {
2677 error.Unexpected => @panic("TODO"),
2678 error.WaitAbandoned => @panic("TODO"),
2679 error.WaitTimeOut => @panic("TODO"),
2680 };
2677 var n: windows.DWORD = undefined;2681 var n: windows.DWORD = undefined;
2678 if (0 == windows.kernel32.GetOverlappedResult(handles[index], overlapped_buffer[index], &n, 0)) {2682 if (0 == windows.kernel32.GetOverlappedResult(handles[index], &overlapped_buffer[index], &n, 0)) {
2679 switch (windows.GetLastError()) {2683 switch (windows.GetLastError()) {
2680 .BROKEN_PIPE => @panic("TODO"),2684 .BROKEN_PIPE => @panic("TODO"),
2681 .OPERATION_ABORTED => @panic("TODO"),2685 .OPERATION_ABORTED => @panic("TODO"),