Skip to content

Commit

Permalink
Use compiler_fence in full_fence on x86
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jul 20, 2022
1 parent 194cf15 commit bc4f426
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,10 @@ fn full_fence() {
// The ideal solution here would be to use inline assembly, but we're instead creating a
// temporary atomic variable and compare-and-exchanging its value. No sane compiler to
// x86 platforms is going to optimize this away.
atomic::compiler_fence(Ordering::SeqCst);
let a = AtomicUsize::new(0);
let _ = a.compare_exchange(0, 1, Ordering::SeqCst, Ordering::SeqCst);
atomic::compiler_fence(Ordering::SeqCst);
} else {
atomic::fence(Ordering::SeqCst);
}
Expand Down

0 comments on commit bc4f426

Please sign in to comment.