Skip to content

Commit 56334c8

Browse files
authored
Remove restrictions on compare-exchange memory ordering. (#1315)
1 parent 9744ab5 commit 56334c8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

crates/core_arch/src/x86_64/cmpxchg16b.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use stdarch_test::assert_instr;
3434
/// support `cmpxchg16b` and the program enters an execution path that
3535
/// eventually would reach this function the behavior is undefined.
3636
///
37-
/// The `success` ordering must also be stronger or equal to `failure`, or this
37+
/// The failure ordering must be [`SeqCst`], [`Acquire`] or [`Relaxed`], or this
3838
/// function call is undefined. See the `Atomic*` documentation's
3939
/// `compare_exchange` function for more information. When `compare_exchange`
4040
/// panics, this is undefined behavior. Currently this function aborts the
@@ -54,15 +54,21 @@ pub unsafe fn cmpxchg16b(
5454
debug_assert!(dst as usize % 16 == 0);
5555

5656
let (val, _ok) = match (success, failure) {
57-
(Acquire, Acquire) => intrinsics::atomic_cxchg_acquire_acquire(dst, old, new),
58-
(Release, Relaxed) => intrinsics::atomic_cxchg_release_relaxed(dst, old, new),
59-
(AcqRel, Acquire) => intrinsics::atomic_cxchg_acqrel_acquire(dst, old, new),
6057
(Relaxed, Relaxed) => intrinsics::atomic_cxchg_relaxed_relaxed(dst, old, new),
61-
(SeqCst, SeqCst) => intrinsics::atomic_cxchg_seqcst_seqcst(dst, old, new),
58+
(Relaxed, Acquire) => intrinsics::atomic_cxchg_relaxed_acquire(dst, old, new),
59+
(Relaxed, SeqCst) => intrinsics::atomic_cxchg_relaxed_seqcst(dst, old, new),
6260
(Acquire, Relaxed) => intrinsics::atomic_cxchg_acquire_relaxed(dst, old, new),
61+
(Acquire, Acquire) => intrinsics::atomic_cxchg_acquire_acquire(dst, old, new),
62+
(Acquire, SeqCst) => intrinsics::atomic_cxchg_acquire_seqcst(dst, old, new),
63+
(Release, Relaxed) => intrinsics::atomic_cxchg_release_relaxed(dst, old, new),
64+
(Release, Acquire) => intrinsics::atomic_cxchg_release_acquire(dst, old, new),
65+
(Release, SeqCst) => intrinsics::atomic_cxchg_release_seqcst(dst, old, new),
6366
(AcqRel, Relaxed) => intrinsics::atomic_cxchg_acqrel_relaxed(dst, old, new),
67+
(AcqRel, Acquire) => intrinsics::atomic_cxchg_acqrel_acquire(dst, old, new),
68+
(AcqRel, SeqCst) => intrinsics::atomic_cxchg_acqrel_seqcst(dst, old, new),
6469
(SeqCst, Relaxed) => intrinsics::atomic_cxchg_seqcst_relaxed(dst, old, new),
6570
(SeqCst, Acquire) => intrinsics::atomic_cxchg_seqcst_acquire(dst, old, new),
71+
(SeqCst, SeqCst) => intrinsics::atomic_cxchg_seqcst_seqcst(dst, old, new),
6672

6773
// The above block is all copied from libcore, and this statement is
6874
// also copied from libcore except that it's a panic in libcore and we

0 commit comments

Comments
 (0)