use crate::{imp, io};
mod auxv;
#[cfg(not(target_os = "wasi"))]
mod chdir;
#[cfg(not(target_os = "wasi"))] mod id;
#[cfg(any(linux_raw, all(libc, any(target_os = "android", target_os = "linux"))))]
mod membarrier;
#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))] mod priority;
#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
mod rlimit;
#[cfg(any(
target_os = "linux",
target_os = "android",
target_os = "fuchsia",
target_os = "dragonfly"
))]
mod sched;
#[cfg(not(target_os = "wasi"))] mod uname;
#[cfg(not(target_os = "wasi"))]
mod wait;
#[cfg(not(target_os = "wasi"))]
pub use auxv::clock_ticks_per_second;
#[cfg(target_vendor = "mustang")]
pub use auxv::init;
pub use auxv::page_size;
#[cfg(any(
linux_raw,
all(
libc,
any(
all(target_os = "android", target_pointer_width = "64"),
target_os = "linux"
)
)
))]
pub use auxv::{linux_execfn, linux_hwcap};
#[cfg(not(target_os = "wasi"))]
pub use chdir::chdir;
#[cfg(not(any(target_os = "wasi", target_os = "fuchsia")))]
pub use chdir::fchdir;
#[cfg(not(target_os = "wasi"))]
pub use chdir::getcwd;
#[cfg(any(linux_raw, all(libc, any(target_os = "android", target_os = "linux"))))]
pub use id::Cpuid;
#[cfg(not(target_os = "wasi"))]
pub use id::{
getegid, geteuid, getgid, getpid, getppid, getuid, Gid, Pid, RawGid, RawNonZeroPid, RawPid,
RawUid, Uid,
};
#[cfg(not(target_os = "wasi"))]
pub use imp::process::Signal;
#[cfg(any(linux_raw, all(libc, any(target_os = "android", target_os = "linux"))))]
pub use membarrier::{
membarrier, membarrier_cpu, membarrier_query, MembarrierCommand, MembarrierQuery,
};
#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))]
pub use priority::nice;
#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
pub use priority::{
getpriority_pgrp, getpriority_process, getpriority_user, setpriority_pgrp, setpriority_process,
setpriority_user,
};
#[cfg(any(target_os = "android", target_os = "linux"))]
pub use rlimit::prlimit;
#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
pub use rlimit::{getrlimit, setrlimit, Resource, Rlimit};
#[cfg(any(
target_os = "linux",
target_os = "android",
target_os = "fuchsia",
target_os = "dragonfly"
))]
pub use sched::{sched_getaffinity, sched_setaffinity, CpuSet};
#[cfg(not(target_os = "wasi"))]
pub use uname::{uname, Uname};
#[cfg(not(target_os = "wasi"))]
pub use wait::{WaitOptions, WaitStatus};
pub const EXIT_SUCCESS: i32 = imp::process::EXIT_SUCCESS;
pub const EXIT_FAILURE: i32 = imp::process::EXIT_FAILURE;
#[cfg(not(target_os = "wasi"))]
pub const EXIT_SIGNALED_SIGABRT: i32 = imp::process::EXIT_SIGNALED_SIGABRT;
#[inline]
pub fn sched_yield() {
imp::process::syscalls::sched_yield()
}
#[cfg(not(target_os = "wasi"))]
#[inline]
pub fn waitpid(pid: Option<Pid>, waitopts: WaitOptions) -> io::Result<Option<WaitStatus>> {
Ok(imp::process::syscalls::waitpid(pid, waitopts)?.map(|(_, status)| status))
}
#[cfg(not(target_os = "wasi"))]
#[inline]
pub fn wait(waitopts: WaitOptions) -> io::Result<Option<(Pid, WaitStatus)>> {
imp::process::syscalls::wait(waitopts)
}
#[cfg(not(target_os = "wasi"))]
#[inline]
pub fn setsid() -> io::Result<Pid> {
imp::process::syscalls::setsid()
}
#[cfg(not(target_os = "wasi"))]
#[inline]
#[doc(alias = "kill")]
pub fn kill_process(pid: Pid, sig: Signal) -> io::Result<()> {
imp::process::syscalls::kill_process(pid, sig)
}
#[cfg(not(target_os = "wasi"))]
#[inline]
#[doc(alias = "kill")]
pub fn kill_process_group(pid: Pid, sig: Signal) -> io::Result<()> {
imp::process::syscalls::kill_process_group(pid, sig)
}
#[cfg(not(target_os = "wasi"))]
#[inline]
#[doc(alias = "kill")]
pub fn kill_current_process_group(sig: Signal) -> io::Result<()> {
imp::process::syscalls::kill_current_process_group(sig)
}