Try to somehow implement clock_res_get on Windows. (#124)

* Implement clock_time_get on Windows.

Also update misc_testsuite to include latest clock_time_get test
changes.

* Try to somehow implement clock_res_get on Windows.

* Fix 55ms

* Cache the perf counter resolution

* Fix integration tests
This commit is contained in:
Marcin Mielniczuk
2019-11-06 17:02:58 +01:00
committed by Jakub Konka
parent 3757b8b1c2
commit 22494057df
4 changed files with 71 additions and 1 deletions

View File

@@ -25,6 +25,7 @@
extern crate bitflags;
pub mod file;
pub mod time;
pub mod winerror;
use winerror::WinError;

10
winx/src/time.rs Normal file
View File

@@ -0,0 +1,10 @@
use cvt::cvt;
use winapi::um::{profileapi::QueryPerformanceFrequency, winnt::LARGE_INTEGER};
pub fn perf_counter_frequency() -> std::io::Result<u64> {
unsafe {
let mut frequency: LARGE_INTEGER = std::mem::zeroed();
cvt(QueryPerformanceFrequency(&mut frequency))?;
Ok(*frequency.QuadPart() as u64)
}
}