diff --git a/src/concurrency/data_race.rs b/src/concurrency/data_race.rs index 410c2b9c3d..0e176ec91f 100644 --- a/src/concurrency/data_race.rs +++ b/src/concurrency/data_race.rs @@ -54,7 +54,10 @@ use rustc_target::abi::{Align, Size}; use crate::*; -use super::weak_memory::EvalContextExt as _; +use super::{ + vector_clock::{VClock, VTimestamp, VectorIdx}, + weak_memory::EvalContextExt as _, +}; pub type AllocExtra = VClockAlloc; diff --git a/src/concurrency/mod.rs b/src/concurrency/mod.rs index 5f8bba8027..07c3f0d599 100644 --- a/src/concurrency/mod.rs +++ b/src/concurrency/mod.rs @@ -1,3 +1,5 @@ pub mod data_race; mod range_object_map; +pub mod sync; +mod vector_clock; pub mod weak_memory; diff --git a/src/sync.rs b/src/concurrency/sync.rs similarity index 99% rename from src/sync.rs rename to src/concurrency/sync.rs index de7d528d33..81e5a83a1f 100644 --- a/src/sync.rs +++ b/src/concurrency/sync.rs @@ -7,6 +7,7 @@ use log::trace; use rustc_data_structures::fx::FxHashMap; use rustc_index::vec::{Idx, IndexVec}; +use super::vector_clock::VClock; use crate::*; /// We cannot use the `newtype_index!` macro because we have to use 0 as a @@ -150,7 +151,7 @@ struct FutexWaiter { /// The state of all synchronization variables. #[derive(Default, Debug)] -pub(super) struct SynchronizationState { +pub(crate) struct SynchronizationState { mutexes: IndexVec, rwlocks: IndexVec, condvars: IndexVec, diff --git a/src/vector_clock.rs b/src/concurrency/vector_clock.rs similarity index 100% rename from src/vector_clock.rs rename to src/concurrency/vector_clock.rs diff --git a/src/concurrency/weak_memory.rs b/src/concurrency/weak_memory.rs index 317258a028..30037b6394 100644 --- a/src/concurrency/weak_memory.rs +++ b/src/concurrency/weak_memory.rs @@ -87,6 +87,7 @@ use crate::*; use super::{ data_race::{GlobalState as DataRaceState, ThreadClockSet}, range_object_map::{AccessType, RangeObjectMap}, + vector_clock::{VClock, VTimestamp, VectorIdx}, }; pub type AllocExtra = StoreBufferAlloc; diff --git a/src/lib.rs b/src/lib.rs index 8ca3e8d15e..550d9b9d7b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -61,9 +61,7 @@ mod operator; mod range_map; mod shims; mod stacked_borrows; -mod sync; -mod thread; -mod vector_clock; +pub mod thread; // Establish a "crate-wide prelude": we often import `crate::*`. @@ -105,12 +103,10 @@ pub use crate::range_map::RangeMap; pub use crate::stacked_borrows::{ CallId, EvalContextExt as StackedBorEvalContextExt, Item, Permission, SbTag, Stack, Stacks, }; -pub use crate::sync::{CondvarId, EvalContextExt as SyncEvalContextExt, MutexId, RwLockId}; pub use crate::thread::{ EvalContextExt as ThreadsEvalContextExt, SchedulingAction, ThreadId, ThreadManager, ThreadState, }; -pub use crate::vector_clock::{VClock, VTimestamp, VectorIdx}; - +pub use concurrency::sync::{CondvarId, EvalContextExt as SyncEvalContextExt, MutexId, RwLockId}; /// Insert rustc arguments at the beginning of the argument list that Miri wants to be /// set per default, for maximal validation power. pub const MIRI_DEFAULT_ARGS: &[&str] = &[ diff --git a/src/shims/time.rs b/src/shims/time.rs index 67303c47db..d639939ec5 100644 --- a/src/shims/time.rs +++ b/src/shims/time.rs @@ -1,7 +1,7 @@ use std::time::{Duration, Instant, SystemTime}; +use crate::thread::Time; use crate::*; -use thread::Time; /// Returns the time elapsed between the provided time and the unix epoch as a `Duration`. pub fn system_time_to_duration<'tcx>(time: &SystemTime) -> InterpResult<'tcx, Duration> { diff --git a/src/shims/unix/sync.rs b/src/shims/unix/sync.rs index 69e632915b..246cb100bc 100644 --- a/src/shims/unix/sync.rs +++ b/src/shims/unix/sync.rs @@ -3,8 +3,8 @@ use std::time::SystemTime; use rustc_hir::LangItem; use rustc_middle::ty::{layout::TyAndLayout, query::TyCtxtAt, subst::Subst, Ty}; +use crate::thread::Time; use crate::*; -use thread::Time; // pthread_mutexattr_t is either 4 or 8 bytes, depending on the platform. diff --git a/src/thread.rs b/src/thread.rs index b92728be20..dc8b1c2911 100644 --- a/src/thread.rs +++ b/src/thread.rs @@ -15,7 +15,7 @@ use rustc_middle::ty::layout::TyAndLayout; use rustc_target::spec::abi::Abi; use crate::concurrency::data_race; -use crate::sync::SynchronizationState; +use crate::concurrency::sync::SynchronizationState; use crate::*; #[derive(Clone, Copy, Debug, PartialEq, Eq)]