rustix/backend/linux_raw/time/types.rs
1use crate::ffi;
2use bitflags::bitflags;
3
4bitflags! {
5 /// `TFD_*` flags for use with [`timerfd_create`].
6 ///
7 /// [`timerfd_create`]: crate::time::timerfd_create
8 #[repr(transparent)]
9 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
10 pub struct TimerfdFlags: ffi::c_uint {
11 /// `TFD_NONBLOCK`
12 #[doc(alias = "TFD_NONBLOCK")]
13 const NONBLOCK = linux_raw_sys::general::TFD_NONBLOCK;
14
15 /// `TFD_CLOEXEC`
16 #[doc(alias = "TFD_CLOEXEC")]
17 const CLOEXEC = linux_raw_sys::general::TFD_CLOEXEC;
18
19 /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
20 const _ = !0;
21 }
22}
23
24bitflags! {
25 /// `TFD_TIMER_*` flags for use with [`timerfd_settime`].
26 ///
27 /// [`timerfd_settime`]: crate::time::timerfd_settime
28 #[repr(transparent)]
29 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
30 pub struct TimerfdTimerFlags: ffi::c_uint {
31 /// `TFD_TIMER_ABSTIME`
32 #[doc(alias = "TFD_TIMER_ABSTIME")]
33 const ABSTIME = linux_raw_sys::general::TFD_TIMER_ABSTIME;
34
35 /// `TFD_TIMER_CANCEL_ON_SET`
36 #[doc(alias = "TFD_TIMER_CANCEL_ON_SET")]
37 const CANCEL_ON_SET = linux_raw_sys::general::TFD_TIMER_CANCEL_ON_SET;
38
39 /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
40 const _ = !0;
41 }
42}
43
44/// `CLOCK_*` constants for use with [`timerfd_create`].
45///
46/// [`timerfd_create`]: crate::time::timerfd_create
47#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
48#[repr(u32)]
49#[non_exhaustive]
50pub enum TimerfdClockId {
51 /// `CLOCK_REALTIME`—A clock that tells the “real” time.
52 ///
53 /// This is a clock that tells the amount of time elapsed since the Unix
54 /// epoch, 1970-01-01T00:00:00Z. The clock is externally settable, so it is
55 /// not monotonic. Successive reads may see decreasing times, so it isn't
56 /// reliable for measuring durations.
57 #[doc(alias = "CLOCK_REALTIME")]
58 Realtime = linux_raw_sys::general::CLOCK_REALTIME,
59
60 /// `CLOCK_MONOTONIC`—A clock that tells an abstract time.
61 ///
62 /// Unlike `Realtime`, this clock is not based on a fixed known epoch, so
63 /// individual times aren't meaningful. However, since it isn't settable,
64 /// it is reliable for measuring durations.
65 ///
66 /// This clock does not advance while the system is suspended; see
67 /// `Boottime` for a clock that does.
68 #[doc(alias = "CLOCK_MONOTONIC")]
69 Monotonic = linux_raw_sys::general::CLOCK_MONOTONIC,
70
71 /// `CLOCK_BOOTTIME`—Like `Monotonic`, but advances while suspended.
72 ///
73 /// This clock is similar to `Monotonic`, but does advance while the system
74 /// is suspended.
75 #[doc(alias = "CLOCK_BOOTTIME")]
76 Boottime = linux_raw_sys::general::CLOCK_BOOTTIME,
77
78 /// `CLOCK_REALTIME_ALARM`—Like `Realtime`, but wakes a suspended system.
79 ///
80 /// This clock is like `Realtime`, but can wake up a suspended system.
81 ///
82 /// Use of this clock requires the `CAP_WAKE_ALARM` Linux capability.
83 #[doc(alias = "CLOCK_REALTIME_ALARM")]
84 RealtimeAlarm = linux_raw_sys::general::CLOCK_REALTIME_ALARM,
85
86 /// `CLOCK_BOOTTIME_ALARM`—Like `Boottime`, but wakes a suspended system.
87 ///
88 /// This clock is like `Boottime`, but can wake up a suspended system.
89 ///
90 /// Use of this clock requires the `CAP_WAKE_ALARM` Linux capability.
91 #[doc(alias = "CLOCK_BOOTTIME_ALARM")]
92 BoottimeAlarm = linux_raw_sys::general::CLOCK_BOOTTIME_ALARM,
93}