Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b073fe2

Browse files
committed
move vector_clock and sync into concurrency & make vector_clock private
move thread it back
1 parent ab88e64 commit b073fe2

File tree

9 files changed

+18
-15
lines changed

9 files changed

+18
-15
lines changed

src/concurrency/data_race.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ use rustc_target::abi::{Align, Size};
5454

5555
use crate::*;
5656

57-
use super::weak_memory::EvalContextExt as _;
57+
use super::{
58+
vector_clock::{VClock, VTimestamp, VectorIdx},
59+
weak_memory::EvalContextExt as _,
60+
};
5861

5962
pub type AllocExtra = VClockAlloc;
6063

src/concurrency/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
pub mod data_race;
22
mod range_object_map;
3+
pub mod sync;
4+
mod vector_clock;
35
pub mod weak_memory;

src/sync.rs renamed to src/concurrency/sync.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use log::trace;
77
use rustc_data_structures::fx::FxHashMap;
88
use rustc_index::vec::{Idx, IndexVec};
99

10+
use super::vector_clock::VClock;
1011
use crate::*;
1112

1213
/// We cannot use the `newtype_index!` macro because we have to use 0 as a
@@ -150,7 +151,7 @@ struct FutexWaiter {
150151

151152
/// The state of all synchronization variables.
152153
#[derive(Default, Debug)]
153-
pub(super) struct SynchronizationState {
154+
pub(crate) struct SynchronizationState {
154155
mutexes: IndexVec<MutexId, Mutex>,
155156
rwlocks: IndexVec<RwLockId, RwLock>,
156157
condvars: IndexVec<CondvarId, Condvar>,
File renamed without changes.

src/concurrency/weak_memory.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ use crate::*;
8787
use super::{
8888
data_race::{GlobalState as DataRaceState, ThreadClockSet},
8989
range_object_map::{AccessType, RangeObjectMap},
90+
vector_clock::{VClock, VTimestamp, VectorIdx},
9091
};
9192

9293
pub type AllocExtra = StoreBufferAlloc;

src/lib.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ mod operator;
6161
mod range_map;
6262
mod shims;
6363
mod stacked_borrows;
64-
mod sync;
65-
mod thread;
66-
mod vector_clock;
64+
pub mod thread;
6765

6866
// Establish a "crate-wide prelude": we often import `crate::*`.
6967

@@ -87,30 +85,28 @@ pub use crate::concurrency::data_race::{
8785
EvalContextExt as DataRaceEvalContextExt,
8886
};
8987
pub use crate::diagnostics::{
90-
register_diagnostic, report_error, EvalContextExt as DiagnosticsEvalContextExt,
91-
NonHaltingDiagnostic, TerminationInfo,
88+
EvalContextExt as DiagnosticsEvalContextExt, NonHaltingDiagnostic, register_diagnostic,
89+
report_error, TerminationInfo,
9290
};
9391
pub use crate::eval::{
94-
create_ecx, eval_entry, AlignmentCheck, BacktraceStyle, IsolatedOp, MiriConfig, RejectOpWith,
92+
AlignmentCheck, BacktraceStyle, create_ecx, eval_entry, IsolatedOp, MiriConfig, RejectOpWith,
9593
};
9694
pub use crate::helpers::{CurrentSpan, EvalContextExt as HelpersEvalContextExt};
9795
pub use crate::intptrcast::ProvenanceMode;
9896
pub use crate::machine::{
9997
AllocExtra, Evaluator, FrameData, MiriEvalContext, MiriEvalContextExt, MiriMemoryKind,
100-
Provenance, ProvenanceExtra, NUM_CPUS, PAGE_SIZE, STACK_ADDR, STACK_SIZE,
98+
NUM_CPUS, PAGE_SIZE, Provenance, ProvenanceExtra, STACK_ADDR, STACK_SIZE,
10199
};
102100
pub use crate::mono_hash_map::MonoHashMap;
103101
pub use crate::operator::EvalContextExt as OperatorEvalContextExt;
104102
pub use crate::range_map::RangeMap;
105103
pub use crate::stacked_borrows::{
106104
CallId, EvalContextExt as StackedBorEvalContextExt, Item, Permission, SbTag, Stack, Stacks,
107105
};
108-
pub use crate::sync::{CondvarId, EvalContextExt as SyncEvalContextExt, MutexId, RwLockId};
106+
pub use concurrency::sync::{CondvarId, EvalContextExt as SyncEvalContextExt, MutexId, RwLockId};
109107
pub use crate::thread::{
110108
EvalContextExt as ThreadsEvalContextExt, SchedulingAction, ThreadId, ThreadManager, ThreadState,
111109
};
112-
pub use crate::vector_clock::{VClock, VTimestamp, VectorIdx};
113-
114110
/// Insert rustc arguments at the beginning of the argument list that Miri wants to be
115111
/// set per default, for maximal validation power.
116112
pub const MIRI_DEFAULT_ARGS: &[&str] = &[

src/shims/time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::time::{Duration, Instant, SystemTime};
22

3+
use crate::thread::Time;
34
use crate::*;
4-
use thread::Time;
55

66
/// Returns the time elapsed between the provided time and the unix epoch as a `Duration`.
77
pub fn system_time_to_duration<'tcx>(time: &SystemTime) -> InterpResult<'tcx, Duration> {

src/shims/unix/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::time::SystemTime;
33
use rustc_hir::LangItem;
44
use rustc_middle::ty::{layout::TyAndLayout, query::TyCtxtAt, subst::Subst, Ty};
55

6+
use crate::thread::Time;
67
use crate::*;
7-
use thread::Time;
88

99
// pthread_mutexattr_t is either 4 or 8 bytes, depending on the platform.
1010

src/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_middle::ty::layout::TyAndLayout;
1515
use rustc_target::spec::abi::Abi;
1616

1717
use crate::concurrency::data_race;
18-
use crate::sync::SynchronizationState;
18+
use crate::concurrency::sync::SynchronizationState;
1919
use crate::*;
2020

2121
#[derive(Clone, Copy, Debug, PartialEq, Eq)]

0 commit comments

Comments
 (0)