Skip to content

Commit 19c4fa6

Browse files
committed
CLOCK_UPTIME_RAW exists on all macos targets, not just the ARM ones
1 parent 3751fb0 commit 19c4fa6

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

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

+4-8
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
5151
"macos" => {
5252
absolute_clocks = vec![this.eval_libc_i32("CLOCK_REALTIME")];
5353
relative_clocks = vec![this.eval_libc_i32("CLOCK_MONOTONIC")];
54-
// Some clocks only seem to exist in the aarch64 version of the target.
55-
if this.tcx.sess.target.arch == "aarch64" {
56-
// `CLOCK_UPTIME_RAW` supposed to not increment while the system is asleep... but
57-
// that's not really something a program running inside Miri can tell, anyway.
58-
// We need to support it because std uses it.
59-
relative_clocks.push(this.eval_libc_i32("CLOCK_UPTIME_RAW"));
60-
}
54+
// `CLOCK_UPTIME_RAW` supposed to not increment while the system is asleep... but
55+
// that's not really something a program running inside Miri can tell, anyway.
56+
// We need to support it because std uses it.
57+
relative_clocks.push(this.eval_libc_i32("CLOCK_UPTIME_RAW"));
6158
}
6259
target => throw_unsup_format!("`clock_gettime` is not supported on target OS {target}"),
6360
}
@@ -68,7 +65,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
6865
} else if relative_clocks.contains(&clk_id) {
6966
this.machine.clock.now().duration_since(this.machine.clock.anchor())
7067
} else {
71-
// Unsupported clock.
7268
let einval = this.eval_libc("EINVAL");
7369
this.set_last_error(einval)?;
7470
return Ok(Scalar::from_i32(-1));

src/tools/miri/tests/pass-dep/shims/libc-misc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ fn test_clocks() {
186186
unsafe { libc::clock_gettime(libc::CLOCK_MONOTONIC_COARSE, tp.as_mut_ptr()) };
187187
assert_eq!(is_error, 0);
188188
}
189-
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
189+
#[cfg(target_os = "macos")]
190190
{
191191
let is_error = unsafe { libc::clock_gettime(libc::CLOCK_UPTIME_RAW, tp.as_mut_ptr()) };
192192
assert_eq!(is_error, 0);

0 commit comments

Comments
 (0)