From c8346376264ea99cafd6550b5b5f460cf82b326f Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Mon, 12 Sep 2022 16:32:09 -0500 Subject: [PATCH] address review comments --- src/clock.rs | 14 +++++--------- src/shims/time.rs | 2 +- tests/pass/shims/time-with-isolation.rs | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/clock.rs b/src/clock.rs index 4fab2b2c5f3..3f33273e1e5 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -1,13 +1,9 @@ -use std::sync::atomic::AtomicU64; +use std::sync::atomic::{AtomicU64, Ordering}; use std::time::{Duration, Instant as StdInstant}; -use rustc_data_structures::sync::Ordering; - -use crate::*; - -/// When using a virtual clock, this defines how many nanoseconds do we pretend -/// are passing for each basic block. -const NANOSECOND_PER_BASIC_BLOCK: u64 = 10; +/// When using a virtual clock, this defines how many nanoseconds we pretend are passing for each +/// basic block. +const NANOSECONDS_PER_BASIC_BLOCK: u64 = 10; #[derive(Debug)] pub struct Instant { @@ -83,7 +79,7 @@ impl Clock { // Time will pass without us doing anything. } ClockKind::Virtual { nanoseconds } => { - nanoseconds.fetch_add(NANOSECOND_PER_BASIC_BLOCK, Ordering::SeqCst); + nanoseconds.fetch_add(NANOSECONDS_PER_BASIC_BLOCK, Ordering::SeqCst); } } } diff --git a/src/shims/time.rs b/src/shims/time.rs index 933c298ee4d..f083ab49900 100644 --- a/src/shims/time.rs +++ b/src/shims/time.rs @@ -38,7 +38,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx [this.eval_libc_i32("CLOCK_MONOTONIC")?, this.eval_libc_i32("CLOCK_MONOTONIC_COARSE")?]; let duration = if absolute_clocks.contains(&clk_id) { - this.check_no_isolation("`clock_gettime` with real time clocks")?; + this.check_no_isolation("`clock_gettime` with `REALTIME` clocks")?; system_time_to_duration(&SystemTime::now())? } else if relative_clocks.contains(&clk_id) { this.machine.clock.now().duration_since(this.machine.clock.anchor()) diff --git a/tests/pass/shims/time-with-isolation.rs b/tests/pass/shims/time-with-isolation.rs index 7e6c74d71cb..b6444319b59 100644 --- a/tests/pass/shims/time-with-isolation.rs +++ b/tests/pass/shims/time-with-isolation.rs @@ -8,7 +8,7 @@ fn test_sleep() { assert!((after - before).as_secs() >= 3600); } -/// Ensure that time passes even if we don't sleep (but just wor). +/// Ensure that time passes even if we don't sleep (but just work). fn test_time_passes() { // Check `Instant`. let now1 = Instant::now();