commit 791baefff2c0130dadbce7fd5abc69ec7df8cc53 (tree)
parent 45b931a23fb9a1c68c8de181ac02d39f51f7712b
Author: Andrew Kelley <andrew@ziglang.org>
Date: Wed, 7 Jan 2026 15:02:27 -0800
goodbye posix.nanosleep
see #6600
Diffstat:
1 file changed, 0 insertions(+), 25 deletions(-)
diff --git 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));