Skip to content

Commit

Permalink
Merge pull request #265 from taiki-e/portable-atomic
Browse files Browse the repository at this point in the history
Add portable-atomic feature and disable portable-atomic/critical-section by default
  • Loading branch information
matklad authored Sep 29, 2024
2 parents 72f7c2e + 449e5d7 commit f61508a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock.msrv

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.7", 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 f61508a

Please sign in to comment.