surelock 0.1.0

Deadlock-free locks for Rust with compile time guarantees, incremental locks, and atomic lock sets.
Documentation
//! Re-exports atomic types, using `portable-atomic` when the feature
//! is enabled. This centralizes the `cfg` logic so individual modules
//! don't need to repeat it.
//!
//! On targets without native CAS (e.g., thumbv6m), enable the
//! `portable-atomic` feature.

#[cfg(feature = "portable-atomic")]
pub(crate) use portable_atomic::Ordering;

#[cfg(not(feature = "portable-atomic"))]
pub(crate) use core::sync::atomic::Ordering;

// -- AtomicBool --

#[cfg(feature = "portable-atomic")]
pub(crate) use portable_atomic::AtomicBool;

#[cfg(not(feature = "portable-atomic"))]
pub(crate) use core::sync::atomic::AtomicBool;

// -- AtomicUsize --

#[cfg(feature = "portable-atomic")]
pub(crate) use portable_atomic::AtomicUsize;

#[cfg(not(feature = "portable-atomic"))]
pub(crate) use core::sync::atomic::AtomicUsize;

// -- LockId atomic + inner type --

#[cfg(all(feature = "atomic-u64", feature = "portable-atomic"))]
pub(crate) type AtomicId = portable_atomic::AtomicU64;
#[cfg(all(feature = "atomic-u64", feature = "portable-atomic"))]
pub(crate) type IdInner = u64;

#[cfg(all(feature = "atomic-u64", not(feature = "portable-atomic")))]
pub(crate) type AtomicId = core::sync::atomic::AtomicU64;
#[cfg(all(feature = "atomic-u64", not(feature = "portable-atomic")))]
pub(crate) type IdInner = u64;

#[cfg(all(not(feature = "atomic-u64"), feature = "portable-atomic"))]
pub(crate) type AtomicId = portable_atomic::AtomicU32;
#[cfg(all(not(feature = "atomic-u64"), feature = "portable-atomic"))]
pub(crate) type IdInner = u32;

#[cfg(not(any(feature = "atomic-u64", feature = "portable-atomic")))]
pub(crate) type AtomicId = core::sync::atomic::AtomicU32;
#[cfg(not(any(feature = "atomic-u64", feature = "portable-atomic")))]
pub(crate) type IdInner = u32;