Skip to content

Commit

Permalink
Add portable-atomic feature and disable portable-atomic/critical-sect…
Browse files Browse the repository at this point in the history
…ion by default
  • Loading branch information
taiki-e committed Sep 22, 2024
1 parent 72f7c2e commit 02b54df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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<T>
# 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.
Expand Down
4 changes: 2 additions & 2 deletions src/race.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit 02b54df

Please sign in to comment.