Skip to content

Fix: os.nanosleep for Windows #14795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/std/os.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5338,11 +5338,13 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
}
}

const nanosize = if (is_windows) c_long else isize;

/// Spurious wakeups are possible and no precision of timing is guaranteed.
pub fn nanosleep(seconds: u64, nanoseconds: u64) void {
var req = timespec{
.tv_sec = math.cast(isize, seconds) orelse math.maxInt(isize),
.tv_nsec = math.cast(isize, nanoseconds) orelse math.maxInt(isize),
.tv_nsec = math.cast(nanosize, nanoseconds) orelse math.maxInt(nanosize),
};
var rem: timespec = undefined;
while (true) {
Expand Down