diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e2d47c..cc4211e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: strategy: matrix: rust_version: ['1.60.0', 'stable', 'nightly'] - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-20.04, ubuntu-22.04, macOS-11, macOS-12, windows-2019, windows-2022] steps: - uses: actions/checkout@v3 - name: Install Rust ${{ matrix.rust_version }} diff --git a/CHANGELOG.md b/CHANGELOG.md index fb96ea7..8bd3056 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] - ReleaseDate +### Fixed + +- Fixed an issue with the monotonic clock for macOS/iOS where it would undermeasure time compared to + what would be measured by `std::time::Instant` due to using a clock source that did not account + for device sleep. + ## [0.12.1] - 2023-10-31 ### Fixed diff --git a/Cargo.toml b/Cargo.toml index d9e4272..3ec5693 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,15 +47,9 @@ raw-cpuid = "11.0" [target.'cfg(target_arch = "x86_64")'.dependencies] raw-cpuid = "11.0" -[target.'cfg(not(any(target_os = "macos", target_os = "ios", target_os = "windows", target_arch = "wasm32")))'.dependencies] +[target.'cfg(not(any(target_os = "windows", target_arch = "wasm32")))'.dependencies] libc = "0.2" -[target.'cfg(target_os = "macos")'.dependencies] -mach2 = "0.4" - -[target.'cfg(target_os = "ios")'.dependencies] -mach2 = "0.4" - [target.'cfg(target_os = "windows")'.dependencies] winapi = { version = "0.3", features = ["profileapi"] } diff --git a/src/clocks/monotonic/macos.rs b/src/clocks/monotonic/macos.rs deleted file mode 100644 index 8c3ea9f..0000000 --- a/src/clocks/monotonic/macos.rs +++ /dev/null @@ -1,24 +0,0 @@ -use mach2::mach_time::{mach_absolute_time, mach_timebase_info}; - -#[derive(Clone, Copy, Debug)] -pub struct Monotonic { - factor: u64, -} -impl Monotonic { - pub fn now(&self) -> u64 { - let raw = unsafe { mach_absolute_time() }; - raw * self.factor - } -} - -impl Default for Monotonic { - fn default() -> Self { - let mut info = mach_timebase_info { numer: 0, denom: 0 }; - unsafe { - mach_timebase_info(&mut info); - } - - let factor = u64::from(info.numer) / u64::from(info.denom); - Self { factor } - } -} diff --git a/src/clocks/monotonic/mod.rs b/src/clocks/monotonic/mod.rs index 3960e4f..b746333 100644 --- a/src/clocks/monotonic/mod.rs +++ b/src/clocks/monotonic/mod.rs @@ -1,8 +1,3 @@ -#[cfg(any(target_os = "macos", target_os = "ios"))] -mod macos; -#[cfg(any(target_os = "macos", target_os = "ios"))] -pub use self::macos::Monotonic; - #[cfg(target_os = "windows")] mod windows; #[cfg(target_os = "windows")] @@ -13,17 +8,7 @@ mod wasm; #[cfg(target_arch = "wasm32")] pub use self::wasm::Monotonic; -#[cfg(not(any( - target_os = "macos", - target_os = "ios", - target_os = "windows", - target_arch = "wasm32" -)))] +#[cfg(not(any(target_os = "windows", target_arch = "wasm32")))] mod unix; -#[cfg(not(any( - target_os = "macos", - target_os = "ios", - target_os = "windows", - target_arch = "wasm32" -)))] +#[cfg(not(any(target_os = "windows", target_arch = "wasm32")))] pub use self::unix::Monotonic;