use super::super::c;
#[cfg(any(target_os = "android", target_os = "linux"))]
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
#[repr(u32)]
pub enum MembarrierCommand {
#[doc(alias = "Shared")]
#[doc(alias = "MEMBARRIER_CMD_SHARED")]
Global = 1,
GlobalExpedited = 2,
RegisterGlobalExpedited = 4,
PrivateExpedited = 8,
RegisterPrivateExpedited = 16,
PrivateExpeditedSyncCore = 32,
RegisterPrivateExpeditedSyncCore = 64,
PrivateExpeditedRseq = 128,
RegisterPrivateExpeditedRseq = 256,
}
#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "wasi")))]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[repr(i32)]
pub enum Resource {
Cpu = c::RLIMIT_CPU as c::c_int,
Fsize = c::RLIMIT_FSIZE as c::c_int,
Data = c::RLIMIT_DATA as c::c_int,
Stack = c::RLIMIT_STACK as c::c_int,
#[cfg(not(target_os = "haiku"))]
Core = c::RLIMIT_CORE as c::c_int,
#[cfg(not(any(
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "solaris",
)))]
Rss = c::RLIMIT_RSS as c::c_int,
#[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
Nproc = c::RLIMIT_NPROC as c::c_int,
Nofile = c::RLIMIT_NOFILE as c::c_int,
#[cfg(not(any(
target_os = "aix",
target_os = "haiku",
target_os = "illumos",
target_os = "solaris"
)))]
Memlock = c::RLIMIT_MEMLOCK as c::c_int,
#[cfg(not(target_os = "openbsd"))]
As = c::RLIMIT_AS as c::c_int,
#[cfg(not(any(
target_os = "aix",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
Locks = c::RLIMIT_LOCKS as c::c_int,
#[cfg(not(any(
target_os = "aix",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
Sigpending = c::RLIMIT_SIGPENDING as c::c_int,
#[cfg(not(any(
target_os = "aix",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
Msgqueue = c::RLIMIT_MSGQUEUE as c::c_int,
#[cfg(not(any(
target_os = "aix",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
Nice = c::RLIMIT_NICE as c::c_int,
#[cfg(not(any(
target_os = "aix",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
Rtprio = c::RLIMIT_RTPRIO as c::c_int,
#[cfg(not(any(
target_os = "aix",
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
)))]
Rttime = c::RLIMIT_RTTIME as c::c_int,
}
#[cfg(any(target_os = "ios", target_os = "macos"))]
impl Resource {
#[allow(non_upper_case_globals)]
pub const Rss: Self = Self::As;
}
#[cfg(not(target_os = "wasi"))]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[repr(i32)]
pub enum Signal {
Hup = c::SIGHUP,
Int = c::SIGINT,
Quit = c::SIGQUIT,
Ill = c::SIGILL,
Trap = c::SIGTRAP,
#[doc(alias = "Iot")]
#[doc(alias = "Abrt")]
Abort = c::SIGABRT,
Bus = c::SIGBUS,
Fpe = c::SIGFPE,
Kill = c::SIGKILL,
Usr1 = c::SIGUSR1,
Segv = c::SIGSEGV,
Usr2 = c::SIGUSR2,
Pipe = c::SIGPIPE,
#[doc(alias = "Alrm")]
Alarm = c::SIGALRM,
Term = c::SIGTERM,
#[cfg(not(any(
target_os = "aix",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
all(
any(target_os = "android", target_os = "linux"),
any(
target_arch = "mips",
target_arch = "mips64",
target_arch = "sparc",
target_arch = "sparc64"
),
)
)))]
Stkflt = c::SIGSTKFLT,
#[doc(alias = "Chld")]
Child = c::SIGCHLD,
Cont = c::SIGCONT,
Stop = c::SIGSTOP,
Tstp = c::SIGTSTP,
Ttin = c::SIGTTIN,
Ttou = c::SIGTTOU,
Urg = c::SIGURG,
Xcpu = c::SIGXCPU,
Xfsz = c::SIGXFSZ,
#[doc(alias = "Vtalrm")]
Vtalarm = c::SIGVTALRM,
Prof = c::SIGPROF,
Winch = c::SIGWINCH,
#[doc(alias = "Poll")]
#[cfg(not(target_os = "haiku"))]
Io = c::SIGIO,
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
)))]
#[doc(alias = "Pwr")]
Power = c::SIGPWR,
#[doc(alias = "Unused")]
Sys = c::SIGSYS,
}
#[cfg(not(target_os = "wasi"))]
impl Signal {
pub fn from_raw(sig: i32) -> Option<Self> {
match sig as _ {
c::SIGHUP => Some(Self::Hup),
c::SIGINT => Some(Self::Int),
c::SIGQUIT => Some(Self::Quit),
c::SIGILL => Some(Self::Ill),
c::SIGTRAP => Some(Self::Trap),
c::SIGABRT => Some(Self::Abort),
c::SIGBUS => Some(Self::Bus),
c::SIGFPE => Some(Self::Fpe),
c::SIGKILL => Some(Self::Kill),
c::SIGUSR1 => Some(Self::Usr1),
c::SIGSEGV => Some(Self::Segv),
c::SIGUSR2 => Some(Self::Usr2),
c::SIGPIPE => Some(Self::Pipe),
c::SIGALRM => Some(Self::Alarm),
c::SIGTERM => Some(Self::Term),
#[cfg(not(any(
target_os = "aix",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
all(
any(target_os = "android", target_os = "linux"),
any(
target_arch = "mips",
target_arch = "mips64",
target_arch = "sparc",
target_arch = "sparc64"
),
)
)))]
c::SIGSTKFLT => Some(Self::Stkflt),
c::SIGCHLD => Some(Self::Child),
c::SIGCONT => Some(Self::Cont),
c::SIGSTOP => Some(Self::Stop),
c::SIGTSTP => Some(Self::Tstp),
c::SIGTTIN => Some(Self::Ttin),
c::SIGTTOU => Some(Self::Ttou),
c::SIGURG => Some(Self::Urg),
c::SIGXCPU => Some(Self::Xcpu),
c::SIGXFSZ => Some(Self::Xfsz),
c::SIGVTALRM => Some(Self::Vtalarm),
c::SIGPROF => Some(Self::Prof),
c::SIGWINCH => Some(Self::Winch),
#[cfg(not(target_os = "haiku"))]
c::SIGIO => Some(Self::Io),
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "haiku",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
)))]
c::SIGPWR => Some(Self::Power),
c::SIGSYS => Some(Self::Sys),
_ => None,
}
}
}
pub const EXIT_SUCCESS: c::c_int = c::EXIT_SUCCESS;
pub const EXIT_FAILURE: c::c_int = c::EXIT_FAILURE;
#[cfg(not(target_os = "wasi"))]
pub const EXIT_SIGNALED_SIGABRT: c::c_int = 128 + c::SIGABRT;
#[cfg(not(target_os = "wasi"))]
pub type RawPid = c::pid_t;
#[cfg(not(target_os = "wasi"))]
pub type RawNonZeroPid = core::num::NonZeroI32;
#[cfg(not(target_os = "wasi"))]
pub type RawGid = c::gid_t;
#[cfg(not(target_os = "wasi"))]
pub type RawUid = c::uid_t;
#[cfg(any(target_os = "android", target_os = "linux"))]
pub type RawCpuid = u32;
#[cfg(target_os = "freebsd")]
pub type RawId = c::id_t;
#[cfg(not(target_os = "wasi"))]
pub(crate) type RawUname = c::utsname;
#[cfg(any(
target_os = "android",
target_os = "dragonfly",
target_os = "fuchsia",
target_os = "linux",
))]
pub(crate) type RawCpuSet = c::cpu_set_t;
#[cfg(any(
target_os = "android",
target_os = "dragonfly",
target_os = "fuchsia",
target_os = "linux",
))]
#[inline]
pub(crate) fn raw_cpu_set_new() -> RawCpuSet {
let mut set = unsafe { core::mem::zeroed() };
super::cpu_set::CPU_ZERO(&mut set);
set
}
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
pub(crate) const CPU_SETSIZE: usize = c::CPU_SETSIZE as usize;
#[cfg(target_os = "dragonfly")]
pub(crate) const CPU_SETSIZE: usize = 256;