From 8a96022600c60b898ee5e477227b1ed6dee69516 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Fri, 6 Oct 2023 01:16:36 +0100 Subject: [PATCH 1/3] Miri: Add `CreateWaitableTimerEx` stub This function will always fail, allowing std's `Sleep` fallback path to be taken instead. --- src/shims/windows/foreign_items.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/shims/windows/foreign_items.rs b/src/shims/windows/foreign_items.rs index d76d01b078..24bb51ef5c 100644 --- a/src/shims/windows/foreign_items.rs +++ b/src/shims/windows/foreign_items.rs @@ -267,6 +267,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { this.Sleep(timeout)?; } + "CreateWaitableTimerExW" => { + let [attributes, name, flags, access] = + this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?; + this.read_pointer(attributes)?; + this.read_pointer(name)?; + this.read_scalar(flags)?.to_u32()?; + this.read_scalar(access)?.to_u32()?; + // Unimplemented. Always return failure. + let not_supported = this.eval_windows("c", "ERROR_NOT_SUPPORTED"); + this.set_last_error(not_supported)?; + this.write_null(dest)?; + } // Synchronization primitives "AcquireSRWLockExclusive" => { From a657abbef76742e8e5bc58e13fabf29937a34635 Mon Sep 17 00:00:00 2001 From: The Miri Conjob Bot Date: Wed, 25 Oct 2023 05:31:14 +0000 Subject: [PATCH 2/3] Preparing for merge from rustc --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index 9600195a6a..60ae5d1259 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -f1a5ce19f5aa0cf61ed7b9f75b30e610befeed72 +2e4e2a8f288f642cafcc41fff211955ceddc453d From 9fbff113981788e2ab6b177ecc45aaad2eb31e11 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 25 Oct 2023 10:03:09 +0200 Subject: [PATCH 3/3] CLOCK_UPTIME_RAW exists on all macos targets, not just the ARM ones --- src/shims/time.rs | 12 ++++-------- tests/pass-dep/shims/libc-misc.rs | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/shims/time.rs b/src/shims/time.rs index d6d0483f5e..4918698c6b 100644 --- a/src/shims/time.rs +++ b/src/shims/time.rs @@ -51,13 +51,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { "macos" => { absolute_clocks = vec![this.eval_libc_i32("CLOCK_REALTIME")]; relative_clocks = vec![this.eval_libc_i32("CLOCK_MONOTONIC")]; - // Some clocks only seem to exist in the aarch64 version of the target. - if this.tcx.sess.target.arch == "aarch64" { - // `CLOCK_UPTIME_RAW` supposed to not increment while the system is asleep... but - // that's not really something a program running inside Miri can tell, anyway. - // We need to support it because std uses it. - relative_clocks.push(this.eval_libc_i32("CLOCK_UPTIME_RAW")); - } + // `CLOCK_UPTIME_RAW` supposed to not increment while the system is asleep... but + // that's not really something a program running inside Miri can tell, anyway. + // We need to support it because std uses it. + relative_clocks.push(this.eval_libc_i32("CLOCK_UPTIME_RAW")); } target => throw_unsup_format!("`clock_gettime` is not supported on target OS {target}"), } @@ -68,7 +65,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { } else if relative_clocks.contains(&clk_id) { this.machine.clock.now().duration_since(this.machine.clock.anchor()) } else { - // Unsupported clock. let einval = this.eval_libc("EINVAL"); this.set_last_error(einval)?; return Ok(Scalar::from_i32(-1)); diff --git a/tests/pass-dep/shims/libc-misc.rs b/tests/pass-dep/shims/libc-misc.rs index 82c49cfb17..40d3fa19e5 100644 --- a/tests/pass-dep/shims/libc-misc.rs +++ b/tests/pass-dep/shims/libc-misc.rs @@ -186,7 +186,7 @@ fn test_clocks() { unsafe { libc::clock_gettime(libc::CLOCK_MONOTONIC_COARSE, tp.as_mut_ptr()) }; assert_eq!(is_error, 0); } - #[cfg(all(target_os = "macos", target_arch = "aarch64"))] + #[cfg(target_os = "macos")] { let is_error = unsafe { libc::clock_gettime(libc::CLOCK_UPTIME_RAW, tp.as_mut_ptr()) }; assert_eq!(is_error, 0);