Skip to content

Commit

Permalink
Auto merge of #32244 - Amanieu:compare_exchange_result, r=alexcrichton
Browse files Browse the repository at this point in the history
Change compare_exchange to return a Result<T, T>

As per the discussion in #31767

I also changed the feature name from `extended_compare_and_swap` to `compare_exchange`.

r? @alexcrichton
  • Loading branch information
bors committed Mar 19, 2016
2 parents 151be09 + 421fed1 commit 8eeb506
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 134 deletions.
24 changes: 20 additions & 4 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,35 @@ extern "rust-intrinsic" {
// NB: These intrinsics take raw pointers because they mutate aliased
// memory, which is not valid for either `&` or `&mut`.

#[cfg(stage0)]
pub fn atomic_cxchg<T>(dst: *mut T, old: T, src: T) -> T;
#[cfg(stage0)]
pub fn atomic_cxchg_acq<T>(dst: *mut T, old: T, src: T) -> T;
#[cfg(stage0)]
pub fn atomic_cxchg_rel<T>(dst: *mut T, old: T, src: T) -> T;
#[cfg(stage0)]
pub fn atomic_cxchg_acqrel<T>(dst: *mut T, old: T, src: T) -> T;
#[cfg(stage0)]
pub fn atomic_cxchg_relaxed<T>(dst: *mut T, old: T, src: T) -> T;

#[cfg(not(stage0))]
pub fn atomic_cxchg<T>(dst: *mut T, old: T, src: T) -> (T, bool);
#[cfg(not(stage0))]
pub fn atomic_cxchg_acq<T>(dst: *mut T, old: T, src: T) -> (T, bool);
#[cfg(not(stage0))]
pub fn atomic_cxchg_rel<T>(dst: *mut T, old: T, src: T) -> (T, bool);
#[cfg(not(stage0))]
pub fn atomic_cxchg_acqrel<T>(dst: *mut T, old: T, src: T) -> (T, bool);
#[cfg(not(stage0))]
pub fn atomic_cxchg_relaxed<T>(dst: *mut T, old: T, src: T) -> (T, bool);
#[cfg(not(stage0))]
pub fn atomic_cxchg_failrelaxed<T>(dst: *mut T, old: T, src: T) -> T;
pub fn atomic_cxchg_failrelaxed<T>(dst: *mut T, old: T, src: T) -> (T, bool);
#[cfg(not(stage0))]
pub fn atomic_cxchg_failacq<T>(dst: *mut T, old: T, src: T) -> T;
pub fn atomic_cxchg_failacq<T>(dst: *mut T, old: T, src: T) -> (T, bool);
#[cfg(not(stage0))]
pub fn atomic_cxchg_acq_failrelaxed<T>(dst: *mut T, old: T, src: T) -> T;
pub fn atomic_cxchg_acq_failrelaxed<T>(dst: *mut T, old: T, src: T) -> (T, bool);
#[cfg(not(stage0))]
pub fn atomic_cxchg_acqrel_failrelaxed<T>(dst: *mut T, old: T, src: T) -> T;
pub fn atomic_cxchg_acqrel_failrelaxed<T>(dst: *mut T, old: T, src: T) -> (T, bool);

#[cfg(not(stage0))]
pub fn atomic_cxchgweak<T>(dst: *mut T, old: T, src: T) -> (T, bool);
Expand Down
Loading

0 comments on commit 8eeb506

Please sign in to comment.