From eb40adbd4604e86a1b0bd3c89d71cec3d2a7d077 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Mon, 26 Feb 2024 12:01:55 -0300 Subject: [PATCH] Add shim for GetSystemTimePreciseAsFileTime This is exactly the same as GetSystemTimeAsFileTime except that it promises maximum precision. --- src/tools/miri/src/shims/time.rs | 5 +++-- src/tools/miri/src/shims/windows/foreign_items.rs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tools/miri/src/shims/time.rs b/src/tools/miri/src/shims/time.rs index 13ce9d119bc..4535bcf6dfe 100644 --- a/src/tools/miri/src/shims/time.rs +++ b/src/tools/miri/src/shims/time.rs @@ -110,12 +110,13 @@ fn gettimeofday( #[allow(non_snake_case, clippy::arithmetic_side_effects)] fn GetSystemTimeAsFileTime( &mut self, + shim_name: &str, LPFILETIME_op: &OpTy<'tcx, Provenance>, ) -> InterpResult<'tcx> { let this = self.eval_context_mut(); - this.assert_target_os("windows", "GetSystemTimeAsFileTime"); - this.check_no_isolation("`GetSystemTimeAsFileTime`")?; + this.assert_target_os("windows", shim_name); + this.check_no_isolation(shim_name)?; let filetime = this.deref_pointer_as(LPFILETIME_op, this.windows_ty_layout("FILETIME"))?; diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index fdd7fc5fad4..15ddd8a5846 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -246,11 +246,11 @@ fn emulate_foreign_item_inner( } // Time related shims - "GetSystemTimeAsFileTime" => { + "GetSystemTimeAsFileTime" | "GetSystemTimePreciseAsFileTime" => { #[allow(non_snake_case)] let [LPFILETIME] = this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?; - this.GetSystemTimeAsFileTime(LPFILETIME)?; + this.GetSystemTimeAsFileTime(link_name.as_str(), LPFILETIME)?; } "QueryPerformanceCounter" => { #[allow(non_snake_case)]