diff --git a/Cargo.toml b/Cargo.toml index d331d58..12a979f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "quanta" version = "0.12.6" authors = ["Toby Lawrence "] edition = "2021" -rust-version = "1.70" +rust-version = "1.71" license = "MIT" @@ -51,7 +51,7 @@ raw-cpuid = "11.0" libc = "0.2" [target.'cfg(target_os = "windows")'.dependencies] -winapi = { version = "0.3", features = ["profileapi"] } +windows-sys = { version = "0.61", features = ["Win32_System_Performance"] } [target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies] web-sys = { version = "0.3", features = ["Window", "Performance"] } diff --git a/src/clocks/monotonic/windows.rs b/src/clocks/monotonic/windows.rs index ee48924..f88a2f7 100644 --- a/src/clocks/monotonic/windows.rs +++ b/src/clocks/monotonic/windows.rs @@ -1,5 +1,5 @@ use std::mem; -use winapi::um::profileapi; +use windows_sys::Win32::System::Performance; #[derive(Clone, Copy, Debug)] pub struct Monotonic { @@ -11,12 +11,12 @@ impl Monotonic { let raw = unsafe { // TODO: Can we do any better than the `mem::zeroed` call here? let mut count = mem::zeroed(); - if profileapi::QueryPerformanceCounter(&mut count) == 0 { + if Performance::QueryPerformanceCounter(&mut count) <= 0 { unreachable!( "QueryPerformanceCounter on Windows XP or later should never return zero!" ); } - *count.QuadPart() as u64 + count as u64 }; raw * self.factor } @@ -27,12 +27,12 @@ impl Default for Monotonic { let denom = unsafe { // TODO: Can we do any better than the `mem::zeroed` call here? let mut freq = mem::zeroed(); - if profileapi::QueryPerformanceFrequency(&mut freq) == 0 { + if Performance::QueryPerformanceFrequency(&mut freq) <= 0 { unreachable!( "QueryPerformanceFrequency on Windows XP or later should never return zero!" ); } - *freq.QuadPart() as u64 + freq as u64 }; Self {