• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use crate::fd::{AsFd, OwnedFd};
2 use crate::{backend, io};
3 
4 pub use backend::time::types::{Itimerspec, TimerfdClockId, TimerfdFlags, TimerfdTimerFlags};
5 
6 /// `timerfd_create(clockid, flags)`—Create a timer.
7 ///
8 /// # References
9 ///  - [Linux]
10 ///
11 /// [Linux]: https://man7.org/linux/man-pages/man2/timerfd_create.2.html
12 #[inline]
timerfd_create(clockid: TimerfdClockId, flags: TimerfdFlags) -> io::Result<OwnedFd>13 pub fn timerfd_create(clockid: TimerfdClockId, flags: TimerfdFlags) -> io::Result<OwnedFd> {
14     backend::time::syscalls::timerfd_create(clockid, flags)
15 }
16 
17 /// `timerfd_settime(clockid, flags, new_value)`—Set the time on a timer.
18 ///
19 /// # References
20 ///  - [Linux]
21 ///
22 /// [Linux]: https://man7.org/linux/man-pages/man2/timerfd_settime.2.html
23 #[inline]
timerfd_settime<Fd: AsFd>( fd: Fd, flags: TimerfdTimerFlags, new_value: &Itimerspec, ) -> io::Result<Itimerspec>24 pub fn timerfd_settime<Fd: AsFd>(
25     fd: Fd,
26     flags: TimerfdTimerFlags,
27     new_value: &Itimerspec,
28 ) -> io::Result<Itimerspec> {
29     backend::time::syscalls::timerfd_settime(fd.as_fd(), flags, new_value)
30 }
31 
32 /// `timerfd_gettime(clockid, flags)`—Query a timer.
33 ///
34 /// # References
35 ///  - [Linux]
36 ///
37 /// [Linux]: https://man7.org/linux/man-pages/man2/timerfd_gettime.2.html
38 #[inline]
timerfd_gettime<Fd: AsFd>(fd: Fd) -> io::Result<Itimerspec>39 pub fn timerfd_gettime<Fd: AsFd>(fd: Fd) -> io::Result<Itimerspec> {
40     backend::time::syscalls::timerfd_gettime(fd.as_fd())
41 }
42