| ... | ... | @@ -1274,31 +1274,6 @@ pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) FcntlError!usize { |
| 1274 | 1274 | } |
| 1275 | 1275 | } |
| 1276 | 1276 | |
| 1277 | | /// Spurious wakeups are possible and no precision of timing is guaranteed. |
| 1278 | | pub 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 | | |
| 1302 | 1277 | pub fn getSelfPhdrs() []std.elf.ElfN.Phdr { |
| 1303 | 1278 | const getauxval = if (builtin.link_libc) std.c.getauxval else std.os.linux.getauxval; |
| 1304 | 1279 | assert(getauxval(std.elf.AT_PHENT) == @sizeOf(std.elf.ElfN.Phdr)); |