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