Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: switch to clock_gettime(3) for macOS/iOS for monotonic clock #97

Merged
merged 2 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

Expand Down
24 changes: 0 additions & 24 deletions src/clocks/monotonic/macos.rs

This file was deleted.

19 changes: 2 additions & 17 deletions src/clocks/monotonic/mod.rs
Original file line number Diff line number Diff line change
@@ -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")]
Expand All @@ -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;