Skip to content

Commit de4a846

Browse files
committed
Auto merge of #979 - nico-abram:patch-1, r=oli-obk
Add missing atomic_fence intrinsics as nops Fixes #972
2 parents b0de1e9 + bd4a299 commit de4a846

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/shims/intrinsics.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
8888
this.write_scalar(val, place.into())?;
8989
}
9090

91-
"atomic_fence_acq" => {
91+
"atomic_fence_acq" |
92+
"atomic_fence_rel" |
93+
"atomic_fence_acqrel" |
94+
"atomic_fence" => {
9295
// we are inherently singlethreaded and singlecored, this is a nop
9396
}
9497

tests/run-pass/atomic.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicU64, Ordering::*};
1+
use std::sync::atomic::{fence, AtomicBool, AtomicIsize, AtomicU64, Ordering::*};
22

33
fn main() {
44
atomic_bool();
55
atomic_isize();
66
atomic_u64();
7+
atomic_fences();
78
}
89

910
fn atomic_bool() {
@@ -57,6 +58,15 @@ fn atomic_u64() {
5758

5859
ATOMIC.store(1, SeqCst);
5960
assert_eq!(ATOMIC.compare_exchange(0, 0x100, AcqRel, Acquire), Err(1));
60-
assert_eq!(ATOMIC.compare_exchange_weak(1, 0x100, AcqRel, Acquire), Ok(1));
61+
assert_eq!(
62+
ATOMIC.compare_exchange_weak(1, 0x100, AcqRel, Acquire),
63+
Ok(1)
64+
);
6165
assert_eq!(ATOMIC.load(Relaxed), 0x100);
6266
}
67+
68+
fn atomic_fences() {
69+
fence(SeqCst);
70+
fence(Release);
71+
fence(Acquire);
72+
}

0 commit comments

Comments
 (0)