From 791baefff2c0130dadbce7fd5abc69ec7df8cc53 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 7 Jan 2026 15:02:27 -0800 Subject: [PATCH] goodbye posix.nanosleep see #6600 --- lib/std/posix.zig | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/lib/std/posix.zig b/lib/std/posix.zig index bba202423e..f3976f6909 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -1274,31 +1274,6 @@ pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) FcntlError!usize { } } -/// Spurious wakeups are possible and no precision of timing is guaranteed. -pub fn nanosleep(seconds: u64, nanoseconds: u64) void { - var req = timespec{ - .sec = cast(isize, seconds) orelse maxInt(isize), - .nsec = cast(isize, nanoseconds) orelse maxInt(isize), - }; - var rem: timespec = undefined; - while (true) { - switch (errno(system.nanosleep(&req, &rem))) { - .FAULT => unreachable, - .INVAL => { - // Sometimes Darwin returns EINVAL for no reason. - // We treat it as a spurious wakeup. - return; - }, - .INTR => { - req = rem; - continue; - }, - // This prong handles success as well as unexpected errors. - else => return, - } - } -} - pub fn getSelfPhdrs() []std.elf.ElfN.Phdr { const getauxval = if (builtin.link_libc) std.c.getauxval else std.os.linux.getauxval; assert(getauxval(std.elf.AT_PHENT) == @sizeOf(std.elf.ElfN.Phdr));