Skip to content

Commit

Permalink
Merge pull request #260 from brodycj/propagate-critical-section-to-po…
Browse files Browse the repository at this point in the history
…rtable-atomic

propagate critical-section feature selection into portable-atomic; other minor updates for v1.20.0
  • Loading branch information
matklad authored Sep 13, 2024
2 parents c48d3c2 + be6b623 commit 72f7c2e
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 62 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

-

## 1.20.0

- propagate `critical-section` feature selection into `portable-atomic`; other minor updates [#260](https://github.com/matklad/once_cell/pull/260)

## 1.19.0

- Use `portable-atomic` instead of `atomic-polyfill`, [#251](https://github.com/matklad/once_cell/pull/251).
Expand Down
117 changes: 65 additions & 52 deletions Cargo.lock.msrv

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

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "once_cell"
version = "1.19.0"
version = "1.20.0"
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
license = "MIT OR Apache-2.0"
edition = "2021"
Expand All @@ -20,13 +20,13 @@ exclude = ["*.png", "*.svg", "/Cargo.lock.msrv", "rustfmt.toml"]
members = ["xtask"]

[dependencies]
parking_lot_core = { version = "0.9.3", optional = true, default_features = false }
portable-atomic = { version = "1", optional = true }
critical-section = { version = "1", optional = true }
parking_lot_core = { version = "0.9.10", optional = true, default-features = false }
portable-atomic = { version = "1.7", optional = true }
critical-section = { version = "1.1.3", optional = true }

[dev-dependencies]
regex = "1.2.0"
critical-section = { version = "1.1.1", features = ["std"] }
regex = "1.10.6"
critical-section = { version = "1.1.3", features = ["std"] }

[features]
default = ["std"]
Expand All @@ -48,7 +48,7 @@ parking_lot = ["dep:parking_lot_core"]
# Uses `critical-section` to implement `sync` and `race` modules. in
# `#![no_std]` mode. Please read `critical-section` docs carefully
# before enabling this feature.
critical-section = ["dep:critical-section", "portable-atomic" ]
critical-section = ["dep:critical-section", "portable-atomic/critical-section"]

# Enables semver-exempt APIs of this crate.
# At the moment, this feature is unused.
Expand Down
2 changes: 1 addition & 1 deletion src/imp_cs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::panic::{RefUnwindSafe, UnwindSafe};

use portable_atomic::{AtomicBool, Ordering};
use critical_section::{CriticalSection, Mutex};
use portable_atomic::{AtomicBool, Ordering};

use crate::unsync;

Expand Down
4 changes: 2 additions & 2 deletions src/race.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
//! `Acquire` and `Release` have very little performance overhead on most
//! architectures versus `Relaxed`.

#[cfg(feature = "critical-section")]
use portable_atomic as atomic;
#[cfg(not(feature = "critical-section"))]
use core::sync::atomic;
#[cfg(feature = "critical-section")]
use portable_atomic as atomic;

use atomic::{AtomicPtr, AtomicUsize, Ordering};
use core::cell::UnsafeCell;
Expand Down
7 changes: 7 additions & 0 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ fn main() -> xshell::Result<()> {
{
let _s = section("TEST");

cmd!(sh, "cargo test --workspace").run()?;

for &release in &[None, Some("--release")] {
cmd!(sh, "cargo test --features unstable {release...}").run()?;
cmd!(
Expand All @@ -41,6 +43,11 @@ fn main() -> xshell::Result<()> {
{
let _s = section("TEST_BETA");
let _e = push_toolchain(&sh, "beta")?;
// TEMPORARY WORKAROUND for Rust compiler issue ref:
// - https://github.com/rust-lang/rust/issues/129352
// - https://github.com/matklad/once_cell/issues/261
let _e = sh.push_env("RUSTFLAGS", "-A unreachable_patterns");

cmd!(sh, "cargo test --features unstable").run()?;
}

Expand Down

0 comments on commit 72f7c2e

Please sign in to comment.