authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-07 15:02:27-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-07 17:33:07-08:00
log791baefff2c0130dadbce7fd5abc69ec7df8cc53
tree60987f6644d8ec585c8920cbce9b70dbf1b0d2ff
parent45b931a23fb9a1c68c8de181ac02d39f51f7712b

goodbye posix.nanosleep

see #6600

1 files changed, 0 insertions(+), 25 deletions(-)

lib/std/posix.zig-25
......@@ -1274,31 +1274,6 @@ pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) FcntlError!usize {
12741274 }
12751275}
12761276
1277/// Spurious wakeups are possible and no precision of timing is guaranteed.
1278pub fn nanosleep(seconds: u64, nanoseconds: u64) void {
1279 var req = timespec{
1280 .sec = cast(isize, seconds) orelse maxInt(isize),
1281 .nsec = cast(isize, nanoseconds) orelse maxInt(isize),
1282 };
1283 var rem: timespec = undefined;
1284 while (true) {
1285 switch (errno(system.nanosleep(&req, &rem))) {
1286 .FAULT => unreachable,
1287 .INVAL => {
1288 // Sometimes Darwin returns EINVAL for no reason.
1289 // We treat it as a spurious wakeup.
1290 return;
1291 },
1292 .INTR => {
1293 req = rem;
1294 continue;
1295 },
1296 // This prong handles success as well as unexpected errors.
1297 else => return,
1298 }
1299 }
1300}
1301
13021277pub fn getSelfPhdrs() []std.elf.ElfN.Phdr {
13031278 const getauxval = if (builtin.link_libc) std.c.getauxval else std.os.linux.getauxval;
13041279 assert(getauxval(std.elf.AT_PHENT) == @sizeOf(std.elf.ElfN.Phdr));