From d657beddf5d259521209a9d78cfada905da7ec17 Mon Sep 17 00:00:00 2001 From: Calder White Date: Wed, 24 Jul 2024 11:33:25 -0700 Subject: [PATCH 1/2] Remove unix.rs --- src/platform/unix.rs | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 src/platform/unix.rs diff --git a/src/platform/unix.rs b/src/platform/unix.rs deleted file mode 100644 index bf69163..0000000 --- a/src/platform/unix.rs +++ /dev/null @@ -1,26 +0,0 @@ -use std::time::Duration; - -use libc::timespec; - -pub fn now() -> Duration { - // This excerpt of code is taken from the standard library's implementation of Instant: - // https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/unix/time.rs#L260 - // https://www.manpagez.com/man/3/clock_gettime/ - // - // CLOCK_UPTIME_RAW clock that increments monotonically, in the same man- - // ner as CLOCK_MONOTONIC_RAW, but that does not incre- - // ment while the system is asleep. The returned value - // is identical to the result of mach_absolute_time() - // after the appropriate mach_timebase conversion is - // applied. - let mut t: timespec = timespec { - tv_sec: 0, - tv_nsec: 0, - }; - unsafe { - libc::clock_gettime(libc::CLOCK_UPTIME_RAW, &mut t); - } - - // TODO: Is it possible for tv_sec/tv_nsec to be negative? Should we have code/panics/errors to handle this case? - Duration::from_secs(t.tv_sec as u64) + Duration::from_nanos(t.tv_nsec as u64) -} From bc1406ecf5210e5b573a95c8954082c1ecd17277 Mon Sep 17 00:00:00 2001 From: Calder White Date: Wed, 24 Jul 2024 11:35:26 -0700 Subject: [PATCH 2/2] Version 0.1.2 bump. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ec8a254..bdef022 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "suspend-time" -version = "0.1.1" +version = "0.1.2" edition = "2021" license = "MIT" homepage = "https://github.com/Rippling/suspend-time"