diff --git a/Cargo.toml b/Cargo.toml index e59b414..36eb24b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ members = ["xtask"] [dependencies] parking_lot_core = { version = "0.9.10", optional = true, default-features = false } -portable-atomic = { version = "1.7", optional = true } +portable-atomic = { version = "1.3", optional = true, default-features = false } critical-section = { version = "1.1.3", optional = true } [dev-dependencies] @@ -38,17 +38,23 @@ std = ["alloc"] alloc = ["race"] # Enables `once_cell::race` module. -race = [] +race = ["portable-atomic?/require-cas"] # Uses parking_lot to implement once_cell::sync::OnceCell. # This makes no speed difference, but makes each OnceCell # up to 16 bytes smaller, depending on the size of the T. parking_lot = ["dep:parking_lot_core"] -# Uses `critical-section` to implement `sync` and `race` modules. in +# Uses `portable-atomic` to implement `race` module. in +# `#![no_std]` mode. Please read `portable-atomic` docs carefully +# before enabling this feature. +portable-atomic = ["dep:portable-atomic"] + +# Uses `critical-section` to implement `sync` module. in # `#![no_std]` mode. Please read `critical-section` docs carefully # before enabling this feature. -critical-section = ["dep:critical-section", "portable-atomic/critical-section"] +# `portable-atomic` feature is enabled for backwards compatibility. +critical-section = ["dep:critical-section", "portable-atomic"] # Enables semver-exempt APIs of this crate. # At the moment, this feature is unused. diff --git a/src/race.rs b/src/race.rs index 89e4367..9c09323 100644 --- a/src/race.rs +++ b/src/race.rs @@ -19,9 +19,9 @@ //! `Acquire` and `Release` have very little performance overhead on most //! architectures versus `Relaxed`. -#[cfg(not(feature = "critical-section"))] +#[cfg(not(feature = "portable-atomic"))] use core::sync::atomic; -#[cfg(feature = "critical-section")] +#[cfg(feature = "portable-atomic")] use portable_atomic as atomic; use atomic::{AtomicPtr, AtomicUsize, Ordering};