rustix/
clockid.rs
1use crate::backend::c;
2use crate::fd::BorrowedFd;
3
4#[cfg(not(any(apple, target_os = "wasi")))]
13#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
14#[cfg_attr(
15 not(any(target_os = "aix", target_os = "cygwin", target_os = "dragonfly")),
16 repr(i32)
17)]
18#[cfg_attr(any(target_os = "cygwin", target_os = "dragonfly"), repr(u64))]
19#[cfg_attr(target_os = "aix", repr(i64))]
20#[non_exhaustive]
21pub enum ClockId {
22 #[doc(alias = "CLOCK_REALTIME")]
24 Realtime = bitcast!(c::CLOCK_REALTIME),
25
26 #[doc(alias = "CLOCK_MONOTONIC")]
28 Monotonic = bitcast!(c::CLOCK_MONOTONIC),
29
30 #[cfg(any(freebsdlike, target_os = "openbsd"))]
39 #[doc(alias = "CLOCK_UPTIME")]
40 Uptime = c::CLOCK_UPTIME,
41
42 #[cfg(not(any(
44 solarish,
45 target_os = "horizon",
46 target_os = "netbsd",
47 target_os = "redox",
48 target_os = "vita"
49 )))]
50 #[doc(alias = "CLOCK_PROCESS_CPUTIME_ID")]
51 ProcessCPUTime = c::CLOCK_PROCESS_CPUTIME_ID,
52
53 #[cfg(not(any(
55 solarish,
56 target_os = "horizon",
57 target_os = "netbsd",
58 target_os = "redox",
59 target_os = "vita"
60 )))]
61 #[doc(alias = "CLOCK_THREAD_CPUTIME_ID")]
62 ThreadCPUTime = c::CLOCK_THREAD_CPUTIME_ID,
63
64 #[cfg(any(linux_kernel, target_os = "freebsd"))]
66 #[doc(alias = "CLOCK_REALTIME_COARSE")]
67 RealtimeCoarse = c::CLOCK_REALTIME_COARSE,
68
69 #[cfg(any(linux_kernel, target_os = "freebsd"))]
71 #[doc(alias = "CLOCK_MONOTONIC_COARSE")]
72 MonotonicCoarse = c::CLOCK_MONOTONIC_COARSE,
73
74 #[cfg(linux_kernel)]
76 #[doc(alias = "CLOCK_MONOTONIC_RAW")]
77 MonotonicRaw = c::CLOCK_MONOTONIC_RAW,
78
79 #[cfg(linux_kernel)]
81 #[doc(alias = "CLOCK_REALTIME_ALARM")]
82 RealtimeAlarm = bitcast!(c::CLOCK_REALTIME_ALARM),
83
84 #[cfg(all(linux_kernel, feature = "linux_4_11"))]
86 #[doc(alias = "CLOCK_TAI")]
87 Tai = bitcast!(c::CLOCK_TAI),
88
89 #[cfg(any(linux_kernel, target_os = "fuchsia", target_os = "openbsd"))]
91 #[doc(alias = "CLOCK_BOOTTIME")]
92 Boottime = bitcast!(c::CLOCK_BOOTTIME),
93
94 #[cfg(any(linux_kernel, target_os = "fuchsia"))]
96 #[doc(alias = "CLOCK_BOOTTIME_ALARM")]
97 BoottimeAlarm = bitcast!(c::CLOCK_BOOTTIME_ALARM),
98}
99
100#[cfg(apple)]
109#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
110#[repr(u32)]
111#[non_exhaustive]
112pub enum ClockId {
113 #[doc(alias = "CLOCK_REALTIME")]
115 Realtime = c::CLOCK_REALTIME,
116
117 #[doc(alias = "CLOCK_MONOTONIC")]
119 Monotonic = c::CLOCK_MONOTONIC,
120
121 #[doc(alias = "CLOCK_PROCESS_CPUTIME_ID")]
123 ProcessCPUTime = c::CLOCK_PROCESS_CPUTIME_ID,
124
125 #[doc(alias = "CLOCK_THREAD_CPUTIME_ID")]
127 ThreadCPUTime = c::CLOCK_THREAD_CPUTIME_ID,
128}
129
130#[cfg(not(target_os = "wasi"))]
138#[derive(Debug, Copy, Clone)]
139#[non_exhaustive]
140pub enum DynamicClockId<'a> {
141 Known(ClockId),
143
144 Dynamic(BorrowedFd<'a>),
146
147 #[cfg(linux_kernel)]
149 #[doc(alias = "CLOCK_REALTIME_ALARM")]
150 RealtimeAlarm,
151
152 #[cfg(linux_kernel)]
154 #[doc(alias = "CLOCK_TAI")]
155 Tai,
156
157 #[cfg(any(
159 linux_kernel,
160 target_os = "freebsd",
161 target_os = "fuchsia",
162 target_os = "openbsd"
163 ))]
164 #[doc(alias = "CLOCK_BOOTTIME")]
165 Boottime,
166
167 #[cfg(any(linux_kernel, target_os = "fuchsia"))]
169 #[doc(alias = "CLOCK_BOOTTIME_ALARM")]
170 BoottimeAlarm,
171}