Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ extern "rust-intrinsic" {
///
/// The stabilized version of this intrinsic is available on the
/// `std::sync::atomic` types via the `compare_exchange` method by passing
/// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html)
/// as the `success` and
/// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
/// as the `failure` parameters. For example,
/// [`AtomicBool::compare_exchange`][compare_exchange].
///
/// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange
pub fn atomic_cxchg_rel_acq<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
/// Stores a value if the current value is the same as the `old` value.
///
/// The stabilized version of this intrinsic is available on the
/// `std::sync::atomic` types via the `compare_exchange` method by passing
/// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html)
/// as the `success` and
/// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
Expand Down Expand Up @@ -207,6 +219,18 @@ extern "rust-intrinsic" {
///
/// The stabilized version of this intrinsic is available on the
/// `std::sync::atomic` types via the `compare_exchange_weak` method by passing
/// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html)
/// as the `success` and
/// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
/// as the `failure` parameters. For example,
/// [`AtomicBool::compare_exchange_weak`][cew].
///
/// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak
pub fn atomic_cxchgweak_rel_acq<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
/// Stores a value if the current value is the same as the `old` value.
///
/// The stabilized version of this intrinsic is available on the
/// `std::sync::atomic` types via the `compare_exchange_weak` method by passing
/// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html)
/// as the `success` and
/// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
Expand Down
4 changes: 4 additions & 0 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2421,6 +2421,8 @@ unsafe fn atomic_compare_exchange<T: Copy>(
let (val, ok) = unsafe {
match (success, failure) {
(Acquire, Acquire) => intrinsics::atomic_cxchg_acq(dst, old, new),
#[cfg(not(bootstrap))]
(Release, Acquire) => intrinsics::atomic_cxchg_rel_acq(dst, old, new),
(Release, Relaxed) => intrinsics::atomic_cxchg_rel(dst, old, new),
(AcqRel, Acquire) => intrinsics::atomic_cxchg_acqrel(dst, old, new),
(Relaxed, Relaxed) => intrinsics::atomic_cxchg_relaxed(dst, old, new),
Expand Down Expand Up @@ -2450,6 +2452,8 @@ unsafe fn atomic_compare_exchange_weak<T: Copy>(
let (val, ok) = unsafe {
match (success, failure) {
(Acquire, Acquire) => intrinsics::atomic_cxchgweak_acq(dst, old, new),
#[cfg(not(bootstrap))]
(Release, Acquire) => intrinsics::atomic_cxchgweak_rel_acq(dst, old, new),
(Release, Relaxed) => intrinsics::atomic_cxchgweak_rel(dst, old, new),
(AcqRel, Acquire) => intrinsics::atomic_cxchgweak_acqrel(dst, old, new),
(Relaxed, Relaxed) => intrinsics::atomic_cxchgweak_relaxed(dst, old, new),
Expand Down
1 change: 1 addition & 0 deletions src/librustc_codegen_llvm/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
_ => self.sess().fatal("unknown ordering in atomic intrinsic"),
},
4 => match (split[2], split[3]) {
("rel", "acq") if is_cxchg => (Release, Acquire),
("acq", "failrelaxed") if is_cxchg => (Acquire, Monotonic),
("acqrel", "failrelaxed") if is_cxchg => (AcquireRelease, Monotonic),
_ => self.sess().fatal("unknown ordering in atomic intrinsic"),
Expand Down