use crate::time::Timespec;
use crate::{imp, io};
#[cfg(any(linux_raw, all(libc, not(any(
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd", // FreeBSD 12 has clock_nanosleep, but libc targets FreeBSD 11.
target_os = "ios",
target_os = "macos",
target_os = "openbsd",
target_os = "redox",
target_os = "wasi",
)))))]
use imp::time::ClockId;
#[cfg(any(linux_raw, all(libc, not(any(
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd", // FreeBSD 12 has clock_nanosleep, but libc targets FreeBSD 11.
target_os = "ios",
target_os = "macos",
target_os = "openbsd",
target_os = "redox",
target_os = "wasi",
)))))]
#[inline]
pub fn clock_nanosleep_relative(id: ClockId, request: &Timespec) -> NanosleepRelativeResult {
imp::thread::syscalls::clock_nanosleep_relative(id, request)
}
#[cfg(any(linux_raw, all(libc, not(any(
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd", // FreeBSD 12 has clock_nanosleep, but libc targets FreeBSD 11.
target_os = "ios",
target_os = "macos",
target_os = "openbsd",
target_os = "redox",
target_os = "wasi",
)))))]
#[inline]
pub fn clock_nanosleep_absolute(id: ClockId, request: &Timespec) -> io::Result<()> {
imp::thread::syscalls::clock_nanosleep_absolute(id, request)
}
#[inline]
pub fn nanosleep(request: &Timespec) -> NanosleepRelativeResult {
imp::thread::syscalls::nanosleep(request)
}
#[derive(Debug, Clone)]
#[must_use]
pub enum NanosleepRelativeResult {
Ok,
Interrupted(Timespec),
Err(io::Error),
}