mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-03 09:23:00 +00:00
Cleanup Windows CPUTimer
This commit is contained in:
1 parent
a596c70c33
commit
7db6178dfa
2 files changed
+7
-2
No files matched your search
@@ -34,6 +34,8 @@ libc = "0.2"
|
|||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
winapi = { version = "0.3", features = ["processthreadsapi", "minwindef", "winnt", "jobapi2", "tlhelp32"] }
|
winapi = { version = "0.3", features = ["processthreadsapi", "minwindef", "winnt", "jobapi2", "tlhelp32"] }
|
||||||
|
|
||||||
|
[target.'cfg(all(windows, not(windows_process_extensions_main_thread_handle)))'.dependencies]
|
||||||
once_cell = "1.13"
|
once_cell = "1.13"
|
||||||
|
|
||||||
[target.'cfg(target_os="linux")'.dependencies]
|
[target.'cfg(target_os="linux")'.dependencies]
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
use std::{mem, os::windows::io::AsRawHandle, process, ptr};
|
use std::{mem, os::windows::io::AsRawHandle, process, ptr};
|
||||||
|
|
||||||
use clap::__macro_refs::once_cell::sync::Lazy;
|
|
||||||
use winapi::{
|
use winapi::{
|
||||||
shared::{ntdef::NTSTATUS, ntstatus::STATUS_SUCCESS},
|
shared::{ntdef::NTSTATUS, ntstatus::STATUS_SUCCESS},
|
||||||
um::{
|
um::{
|
||||||
@@ -19,10 +18,14 @@ use winapi::{
|
|||||||
#[cfg(windows_process_extensions_main_thread_handle)]
|
#[cfg(windows_process_extensions_main_thread_handle)]
|
||||||
use winapi::shared::minwindef::DWORD;
|
use winapi::shared::minwindef::DWORD;
|
||||||
|
|
||||||
|
#[cfg(not(windows_process_extensions_main_thread_handle))]
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use crate::util::units::Second;
|
use crate::util::units::Second;
|
||||||
|
|
||||||
const HUNDRED_NS_PER_MS: i64 = 10;
|
const HUNDRED_NS_PER_MS: i64 = 10;
|
||||||
|
|
||||||
|
#[cfg(not(windows_process_extensions_main_thread_handle))]
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
static NtResumeProcess: Lazy<unsafe extern "system" fn(ProcessHandle: HANDLE) -> NTSTATUS> =
|
static NtResumeProcess: Lazy<unsafe extern "system" fn(ProcessHandle: HANDLE) -> NTSTATUS> =
|
||||||
Lazy::new(|| {
|
Lazy::new(|| {
|
||||||
@@ -57,7 +60,7 @@ impl CPUTimer {
|
|||||||
{
|
{
|
||||||
// SAFETY: The main thread handle is valid
|
// SAFETY: The main thread handle is valid
|
||||||
let ret = unsafe { ResumeThread(child.main_thread_handle().as_raw_handle()) };
|
let ret = unsafe { ResumeThread(child.main_thread_handle().as_raw_handle()) };
|
||||||
assert!(ret != -1 as DWORD, "NtResumeProcess failed");
|
assert!(ret != -1 as DWORD, "ResumeThread failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows_process_extensions_main_thread_handle))]
|
#[cfg(not(windows_process_extensions_main_thread_handle))]
|
||||||
|
|||||||
Reference in new issue
Block a user