Skip to main content

cmpxchg

Function cmpxchg 

Source
pub unsafe fn cmpxchg<T: AtomicType, Ordering: Ordering>(
    ptr: *mut T,
    old: T,
    new: T,
    o: Ordering,
) -> Result<T, T>
where T::Repr: AtomicExchangeOps,
Expand description

Atomic compare and exchange over raw pointers.

This function provides a short-cut of Atomic::from_ptr().cmpxchg(..), and can be used to work with C side on synchronizations.

ยงSafety

  • ptr is a valid pointer to T and aligned to align_of::<T>().
  • If there is a concurrent access from kernel (C or Rust), it has to be atomic.