rustix/backend/libc/process/
types.rs

1#[cfg(not(any(
2    target_os = "espidf",
3    target_os = "fuchsia",
4    target_os = "redox",
5    target_os = "vita",
6    target_os = "wasi"
7)))]
8use crate::backend::c;
9
10/// A resource value for use with [`getrlimit`], [`setrlimit`], and
11/// [`prlimit`].
12///
13/// [`getrlimit`]: crate::process::getrlimit
14/// [`setrlimit`]: crate::process::setrlimit
15/// [`prlimit`]: crate::process::prlimit
16#[cfg(not(any(
17    target_os = "espidf",
18    target_os = "fuchsia",
19    target_os = "horizon",
20    target_os = "redox",
21    target_os = "vita",
22    target_os = "wasi"
23)))]
24#[derive(Copy, Clone, Debug, Eq, PartialEq)]
25#[cfg_attr(not(target_os = "l4re"), repr(u32))]
26#[cfg_attr(target_os = "l4re", repr(u64))]
27#[non_exhaustive]
28pub enum Resource {
29    /// `RLIMIT_CPU`
30    Cpu = bitcast!(c::RLIMIT_CPU),
31    /// `RLIMIT_FSIZE`
32    Fsize = bitcast!(c::RLIMIT_FSIZE),
33    /// `RLIMIT_DATA`
34    Data = bitcast!(c::RLIMIT_DATA),
35    /// `RLIMIT_STACK`
36    Stack = bitcast!(c::RLIMIT_STACK),
37    /// `RLIMIT_CORE`
38    #[cfg(not(target_os = "haiku"))]
39    Core = bitcast!(c::RLIMIT_CORE),
40    /// `RLIMIT_RSS`
41    // "nto" has `RLIMIT_RSS`, but it has the same value as `RLIMIT_AS`.
42    #[cfg(not(any(
43        apple,
44        solarish,
45        target_os = "cygwin",
46        target_os = "haiku",
47        target_os = "nto",
48    )))]
49    Rss = bitcast!(c::RLIMIT_RSS),
50    /// `RLIMIT_NPROC`
51    #[cfg(not(any(solarish, target_os = "cygwin", target_os = "haiku")))]
52    Nproc = bitcast!(c::RLIMIT_NPROC),
53    /// `RLIMIT_NOFILE`
54    Nofile = bitcast!(c::RLIMIT_NOFILE),
55    /// `RLIMIT_MEMLOCK`
56    #[cfg(not(any(solarish, target_os = "aix", target_os = "cygwin", target_os = "haiku")))]
57    Memlock = bitcast!(c::RLIMIT_MEMLOCK),
58    /// `RLIMIT_AS`
59    #[cfg(not(target_os = "openbsd"))]
60    As = bitcast!(c::RLIMIT_AS),
61    /// `RLIMIT_LOCKS`
62    #[cfg(not(any(
63        bsd,
64        solarish,
65        target_os = "aix",
66        target_os = "cygwin",
67        target_os = "haiku",
68        target_os = "hurd",
69        target_os = "nto",
70    )))]
71    Locks = bitcast!(c::RLIMIT_LOCKS),
72    /// `RLIMIT_SIGPENDING`
73    #[cfg(not(any(
74        bsd,
75        solarish,
76        target_os = "aix",
77        target_os = "cygwin",
78        target_os = "haiku",
79        target_os = "hurd",
80        target_os = "nto",
81    )))]
82    Sigpending = bitcast!(c::RLIMIT_SIGPENDING),
83    /// `RLIMIT_MSGQUEUE`
84    #[cfg(not(any(
85        bsd,
86        solarish,
87        target_os = "aix",
88        target_os = "cygwin",
89        target_os = "haiku",
90        target_os = "hurd",
91        target_os = "nto",
92    )))]
93    Msgqueue = bitcast!(c::RLIMIT_MSGQUEUE),
94    /// `RLIMIT_NICE`
95    #[cfg(not(any(
96        bsd,
97        solarish,
98        target_os = "aix",
99        target_os = "cygwin",
100        target_os = "haiku",
101        target_os = "hurd",
102        target_os = "nto",
103    )))]
104    Nice = bitcast!(c::RLIMIT_NICE),
105    /// `RLIMIT_RTPRIO`
106    #[cfg(not(any(
107        bsd,
108        solarish,
109        target_os = "aix",
110        target_os = "cygwin",
111        target_os = "haiku",
112        target_os = "hurd",
113        target_os = "nto",
114    )))]
115    Rtprio = bitcast!(c::RLIMIT_RTPRIO),
116    /// `RLIMIT_RTTIME`
117    #[cfg(not(any(
118        bsd,
119        solarish,
120        target_os = "aix",
121        target_os = "android",
122        target_os = "cygwin",
123        target_os = "emscripten",
124        target_os = "haiku",
125        target_os = "hurd",
126        target_os = "nto",
127    )))]
128    Rttime = bitcast!(c::RLIMIT_RTTIME),
129}
130
131#[cfg(apple)]
132#[allow(non_upper_case_globals)]
133impl Resource {
134    /// `RLIMIT_RSS`
135    pub const Rss: Self = Self::As;
136}
137
138#[cfg(freebsdlike)]
139pub type RawId = c::id_t;