authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-29 15:03:33-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-30 12:10:02-08:00
log9121ee5168e63a6a14af4b8e58a2c869db826e69
tree33632aaa0e8529867158d101528b617eb354c142
parentb976f0d8ad14d503265f1740695f765f994b3c5a

std.Io.Threaded: handle TIMEOUT from NtDelayExceution


2 files changed, 8 insertions(+), 1 deletions(-)

lib/std/Io/Threaded.zig+1-1
...@@ -2761,7 +2761,7 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa...@@ -2761,7 +2761,7 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa
2761 const delay_rc = windows.ntdll.NtDelayExecution(windows.TRUE, &delay_interval);2761 const delay_rc = windows.ntdll.NtDelayExecution(windows.TRUE, &delay_interval);
2762 alertable_syscall.finish();2762 alertable_syscall.finish();
2763 switch (delay_rc) {2763 switch (delay_rc) {
2764 .SUCCESS => {2764 .SUCCESS, .TIMEOUT => {
2765 // The thread woke due to the timeout. Although spurious2765 // The thread woke due to the timeout. Although spurious
2766 // timeouts are OK, when no deadline is passed we must not2766 // timeouts are OK, when no deadline is passed we must not
2767 // return `error.Timeout`.2767 // return `error.Timeout`.
lib/std/os/windows/ntdll.zig+7
...@@ -594,6 +594,13 @@ pub extern "ntdll" fn NtCancelSynchronousIoFile(...@@ -594,6 +594,13 @@ pub extern "ntdll" fn NtCancelSynchronousIoFile(
594 IoStatusBlock: *IO_STATUS_BLOCK,594 IoStatusBlock: *IO_STATUS_BLOCK,
595) callconv(.winapi) NTSTATUS;595) callconv(.winapi) NTSTATUS;
596596
597/// This function has been observed to return SUCCESS on timeout on Windows 10
598/// and TIMEOUT on Wine 10.0.
599///
600/// This function has been observed on Windows 11 such that positive interval
601/// is real time, which can cause waits to be interrupted by changing system
602/// time, however negative intervals are not affected by changes to system
603/// time.
597pub extern "ntdll" fn NtDelayExecution(604pub extern "ntdll" fn NtDelayExecution(
598 Alertable: BOOLEAN,605 Alertable: BOOLEAN,
599 DelayInterval: *const LARGE_INTEGER,606 DelayInterval: *const LARGE_INTEGER,