1 const NS_PER_S: u64 = 1_000_000_000; 2 timespec_to_ns(ts: libc::timespec) -> u643fn timespec_to_ns(ts: libc::timespec) -> u64 { 4 (ts.tv_sec as u64) * NS_PER_S + (ts.tv_nsec as u64) 5 } 6 7 /// The time from a clock that cannot be set 8 /// and represents monotonic time since some unspecified starting point, 9 /// that also includes any time that the system is suspended. 10 /// 11 /// See [`clock_gettime`]. 12 /// 13 /// [`clock_gettime`]: https://manpages.debian.org/buster/manpages-dev/clock_gettime.3.en.html now_including_suspend() -> u6414pub fn now_including_suspend() -> u64 { 15 let mut ts = libc::timespec { 16 tv_sec: 0, 17 tv_nsec: 0, 18 }; 19 unsafe { 20 libc::clock_gettime(libc::CLOCK_BOOTTIME, &mut ts); 21 } 22 23 timespec_to_ns(ts) 24 } 25