rivet/sync/atomic.rs
1//! Atomic shim: `loom::sync::atomic` under permutation testing, otherwise
2//! `core::sync::atomic` — or, on a target with no native RMW atomics (see
3//! the `atomics-polyfill` feature), `portable_atomic` instead (plan.md
4//! §1.3).
5//!
6//! The lock-free core (`waker`, `sync/semaphore`, `sync/channel`,
7//! `preempt/tcb`) is written against this module. Under normal builds
8//! (`--cfg loom` absent, `atomics-polyfill` off) this is a zero-cost
9//! alias of the core atomics; with `RUSTFLAGS='--cfg loom'` the same code
10//! compiles against loom's atomics, letting the models in `tests/loom.rs`
11//! explore every interleaving of the Acquire/Release orderings that are
12//! otherwise justified only by prose comments. With `atomics-polyfill` on
13//! (ARMv6-M boards — no LDREX/STREX, so `core`'s `AtomicU32` etc. don't
14//! even have `compare_exchange`/`fetch_or`/`swap` on that target),
15//! `portable_atomic` provides the identical API via a critical-section-
16//! guarded fallback — every call site elsewhere in this crate is
17//! unaffected either way.
18
19#[cfg(loom)]
20pub use loom::sync::atomic::*;
21
22#[cfg(all(not(loom), feature = "atomics-polyfill"))]
23pub use portable_atomic::*;
24
25#[cfg(all(not(loom), not(feature = "atomics-polyfill")))]
26pub use core::sync::atomic::*;