Skip to main content

atomic_fetch_add_u32_acq_rel

Function atomic_fetch_add_u32_acq_rel 

Source
pub unsafe fn atomic_fetch_add_u32_acq_rel(ptr: *mut u32, value: u32) -> u32
Expand description

This performs an atomic fetch-add with Acquire and Release ordering of val to a 32-bit value at ptr. Use this to update the u32 lock.

Rust’s memory model defines how atomics work across threads, but doesn’t account for the way Starnix handles access across mutually distrusting address spaces. This Seqlock is intended to be mapped and read by different address spaces. Rust’s guarantees do not apply and reading across these address spaces is undefined behavior. Theoretically the Rust compiler could determine that the atomic is never read from within the process and optimize out the store. We work around this by directly including the assembly an atomic would generate to prevent the compiler from “helpfully” optimizing it away.

§Safety

The caller must ensure ptr is valid. The ptr must be writable by the current process.