Skip to content

Commit 6a3c1b9

Browse files
authored
Unrolled build for rust-lang#121633
Rollup merge of rust-lang#121633 - ChrisDenton:precise, r=Nilstrieb Win10: Use `GetSystemTimePreciseAsFileTime` directly On Windows 10 we can use `GetSystemTimePreciseAsFileTime` directly instead of lazy loading it (with a fallback).
2 parents 6639672 + eb40adb commit 6a3c1b9

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

library/std/src/sys/pal/windows/c.rs

+1
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ compat_fn_with_fallback! {
344344

345345
// >= Win8 / Server 2012
346346
// https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime
347+
#[cfg(target_vendor = "win7")]
347348
pub fn GetSystemTimePreciseAsFileTime(lpsystemtimeasfiletime: *mut FILETIME) -> () {
348349
GetSystemTimeAsFileTime(lpsystemtimeasfiletime)
349350
}

library/std/src/sys/pal/windows/c/bindings.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2476,6 +2476,7 @@ Windows.Win32.System.Pipes.PIPE_WAIT
24762476
Windows.Win32.System.SystemInformation.GetSystemDirectoryW
24772477
Windows.Win32.System.SystemInformation.GetSystemInfo
24782478
Windows.Win32.System.SystemInformation.GetSystemTimeAsFileTime
2479+
Windows.Win32.System.SystemInformation.GetSystemTimePreciseAsFileTime
24792480
Windows.Win32.System.SystemInformation.GetWindowsDirectoryW
24802481
Windows.Win32.System.SystemInformation.PROCESSOR_ARCHITECTURE
24812482
Windows.Win32.System.SystemInformation.SYSTEM_INFO

library/std/src/sys/pal/windows/c/windows_sys.rs

+4
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,10 @@ extern "system" {
345345
pub fn GetSystemTimeAsFileTime(lpsystemtimeasfiletime: *mut FILETIME) -> ();
346346
}
347347
#[link(name = "kernel32")]
348+
extern "system" {
349+
pub fn GetSystemTimePreciseAsFileTime(lpsystemtimeasfiletime: *mut FILETIME) -> ();
350+
}
351+
#[link(name = "kernel32")]
348352
extern "system" {
349353
pub fn GetTempPathW(nbufferlength: u32, lpbuffer: PWSTR) -> u32;
350354
}

src/tools/miri/src/shims/time.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
110110
#[allow(non_snake_case, clippy::arithmetic_side_effects)]
111111
fn GetSystemTimeAsFileTime(
112112
&mut self,
113+
shim_name: &str,
113114
LPFILETIME_op: &OpTy<'tcx, Provenance>,
114115
) -> InterpResult<'tcx> {
115116
let this = self.eval_context_mut();
116117

117-
this.assert_target_os("windows", "GetSystemTimeAsFileTime");
118-
this.check_no_isolation("`GetSystemTimeAsFileTime`")?;
118+
this.assert_target_os("windows", shim_name);
119+
this.check_no_isolation(shim_name)?;
119120

120121
let filetime = this.deref_pointer_as(LPFILETIME_op, this.windows_ty_layout("FILETIME"))?;
121122

src/tools/miri/src/shims/windows/foreign_items.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
257257
}
258258

259259
// Time related shims
260-
"GetSystemTimeAsFileTime" => {
260+
"GetSystemTimeAsFileTime" | "GetSystemTimePreciseAsFileTime" => {
261261
#[allow(non_snake_case)]
262262
let [LPFILETIME] =
263263
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
264-
this.GetSystemTimeAsFileTime(LPFILETIME)?;
264+
this.GetSystemTimeAsFileTime(link_name.as_str(), LPFILETIME)?;
265265
}
266266
"QueryPerformanceCounter" => {
267267
#[allow(non_snake_case)]

0 commit comments

Comments
 (0)