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" 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) -}