Skip to content

Commit 9a76dde

Browse files
Patrick-6RalfJung
authored andcommitted
Make spin function naming more consistent
1 parent e1d35c5 commit 9a76dde

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/tools/miri/tests/pass/0weak_memory_consistency.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ fn static_atomic_bool(val: bool) -> &'static AtomicBool {
4141
}
4242

4343
/// Spins until it acquires a pre-determined value.
44-
fn loads_value(loc: &AtomicI32, ord: Ordering, val: i32) -> i32 {
44+
fn spin_until_i32(loc: &AtomicI32, ord: Ordering, val: i32) -> i32 {
4545
while loc.load(ord) != val {
4646
std::hint::spin_loop();
4747
}
4848
val
4949
}
5050

5151
/// Spins until it acquires a pre-determined boolean.
52-
fn loads_bool(loc: &AtomicBool, ord: Ordering, val: bool) -> bool {
52+
fn spin_until_bool(loc: &AtomicBool, ord: Ordering, val: bool) -> bool {
5353
while loc.load(ord) != val {
5454
std::hint::spin_loop();
5555
}
@@ -73,7 +73,7 @@ fn test_corr() {
7373
}); // | |
7474
#[rustfmt::skip] // |synchronizes-with |happens-before
7575
let j3 = spawn(move || { // | |
76-
loads_value(&y, Acquire, 1); // <------------+ |
76+
spin_until_i32(&y, Acquire, 1); // <---------+ |
7777
x.load(Relaxed) // <----------------------------------------------+
7878
// The two reads on x are ordered by hb, so they cannot observe values
7979
// differently from the modification order. If the first read observed
@@ -98,12 +98,12 @@ fn test_wrc() {
9898
}); // | |
9999
#[rustfmt::skip] // |synchronizes-with |
100100
let j2 = spawn(move || { // | |
101-
loads_value(&x, Acquire, 1); // <------------+ |
101+
spin_until_i32(&x, Acquire, 1); // <---------+ |
102102
y.store(1, Release); // ---------------------+ |happens-before
103103
}); // | |
104104
#[rustfmt::skip] // |synchronizes-with |
105105
let j3 = spawn(move || { // | |
106-
loads_value(&y, Acquire, 1); // <------------+ |
106+
spin_until_i32(&y, Acquire, 1); // <---------+ |
107107
x.load(Relaxed) // <-----------------------------------------------+
108108
});
109109

@@ -129,7 +129,7 @@ fn test_message_passing() {
129129
#[rustfmt::skip] // |synchronizes-with | happens-before
130130
let j2 = spawn(move || { // | |
131131
let x = x; // avoid field capturing | |
132-
loads_value(&y, Acquire, 1); // <------------+ |
132+
spin_until_i32(&y, Acquire, 1); // <---------+ |
133133
unsafe { *x.0 } // <---------------------------------------------+
134134
});
135135

@@ -224,12 +224,12 @@ fn test_sync_through_rmw_and_fences() {
224224
let go = static_atomic_bool(false);
225225

226226
let t1 = spawn(move || {
227-
loads_bool(go, Relaxed, true);
227+
spin_until_bool(go, Relaxed, true);
228228
rdmw(y, x, z)
229229
});
230230

231231
let t2 = spawn(move || {
232-
loads_bool(go, Relaxed, true);
232+
spin_until_bool(go, Relaxed, true);
233233
rdmw(z, x, y)
234234
});
235235

src/tools/miri/tests/pass/0weak_memory_consistency_sc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ fn static_atomic_bool(val: bool) -> &'static AtomicBool {
2020
}
2121

2222
/// Spins until it acquires a pre-determined value.
23-
fn loads_value(loc: &AtomicI32, ord: Ordering, val: i32) -> i32 {
23+
fn spin_until_i32(loc: &AtomicI32, ord: Ordering, val: i32) -> i32 {
2424
while loc.load(ord) != val {
2525
std::hint::spin_loop();
2626
}
2727
val
2828
}
2929

3030
/// Spins until it acquires a pre-determined boolean.
31-
fn loads_bool(loc: &AtomicBool, ord: Ordering, val: bool) -> bool {
31+
fn spin_until_bool(loc: &AtomicBool, ord: Ordering, val: bool) -> bool {
3232
while loc.load(ord) != val {
3333
std::hint::spin_loop();
3434
}
@@ -68,11 +68,11 @@ fn test_iriw_sc_rlx() {
6868
let a = spawn(move || x.store(true, Relaxed));
6969
let b = spawn(move || y.store(true, Relaxed));
7070
let c = spawn(move || {
71-
loads_bool(x, SeqCst, true);
71+
spin_until_bool(x, SeqCst, true);
7272
y.load(SeqCst)
7373
});
7474
let d = spawn(move || {
75-
loads_bool(y, SeqCst, true);
75+
spin_until_bool(y, SeqCst, true);
7676
x.load(SeqCst)
7777
});
7878

@@ -144,7 +144,7 @@ fn test_cpp20_rwc_syncs() {
144144
});
145145

146146
let j2 = spawn(move || {
147-
loads_value(&x, Relaxed, 1);
147+
spin_until_i32(&x, Relaxed, 1);
148148
fence(SeqCst);
149149
y.load(Relaxed)
150150
});

src/tools/miri/tests/pass/weak_memory/weak.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn static_atomic(val: usize) -> &'static AtomicUsize {
2424
}
2525

2626
// Spins until it reads the given value
27-
fn reads_value(loc: &AtomicUsize, val: usize) -> usize {
27+
fn spin_until(loc: &AtomicUsize, val: usize) -> usize {
2828
while loc.load(Relaxed) != val {
2929
std::hint::spin_loop();
3030
}
@@ -85,7 +85,7 @@ fn initialization_write(add_fence: bool) -> bool {
8585
});
8686

8787
let j2 = spawn(move || {
88-
reads_value(wait, 1);
88+
spin_until(wait, 1);
8989
if add_fence {
9090
fence(AcqRel);
9191
}
@@ -119,12 +119,12 @@ fn faa_replaced_by_load() -> bool {
119119
let go = static_atomic(0);
120120

121121
let t1 = spawn(move || {
122-
reads_value(go, 1);
122+
spin_until(go, 1);
123123
rdmw(y, x, z)
124124
});
125125

126126
let t2 = spawn(move || {
127-
reads_value(go, 1);
127+
spin_until(go, 1);
128128
rdmw(z, x, y)
129129
});
130130

0 commit comments

Comments
 (0)