From 1e3a640b4f02e87afd704fc6f614205272ee3e48 Mon Sep 17 00:00:00 2001 From: Jack Hogan Date: Wed, 11 Sep 2024 23:06:07 -0400 Subject: [PATCH] Replaced deprecated atomic-polyfill crate with portable-atomic, release v2.0.0 --- CHANGELOG.md | 4 ++++ Cargo.toml | 11 +++-------- README.md | 16 ++++++++++++++++ ci.sh | 2 +- src/atomic_bitset.rs | 2 +- src/lib.rs | 2 +- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69093c7..a16681b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 2.0.0 - 2025-01-02 + +- Replace deprecated `atomic-polyfill` crate with `portable-atomic`. + ## 1.0.1 - 2022-12-11 - Use `atomic-polyfill`, to support targets without atomic CAS. diff --git a/Cargo.toml b/Cargo.toml index a826f1f..59093a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,21 +1,16 @@ [package] name = "atomic-pool" -version = "1.0.1" +version = "2.0.0" authors = ["Dario Nieuwenhuis "] description = "Statically allocated pool providing a std-like Box." repository = "https://github.com/embassy-rs/atomic-pool" edition = "2021" readme = "README.md" license = "MIT OR Apache-2.0" -categories = [ - "embedded", - "no-std", - "concurrency", - "memory-management", -] +categories = ["embedded", "no-std", "concurrency", "memory-management"] [dependencies] -atomic-polyfill = "1.0" as-slice-01 = { package = "as-slice", version = "0.1.5" } as-slice-02 = { package = "as-slice", version = "0.2.1" } +portable-atomic = { version = "1.7.0" } stable_deref_trait = { version = "1.2.0", default-features = false } diff --git a/README.md b/README.md index 66fbb16..18f356a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,22 @@ Statically allocated pool providing a std-like Box. +## Support for targets without atomic CAS + +This crate uses [`portable-atomic`](https://crates.io/crates/portable-atomic) to polyfill atomic +compare-and-swap operations on targets without native hardware support for it. + +To use it, you must add a dependency on `portable-atomic` and enable one of its features to +specify how the polyfilling is done. The feature is typically `unsafe-assume-single-core` for +single-core chips running in supervisor mode, or `critical-section` otherwise. Check `portable-atomic`'s +README for more details. + +```toml +[dependencies] +atomic-pool = "2.0" +portable-atomic = { version = "1", default-features = false, features = ["critical-section"] } +``` + ## License This work is licensed under either of diff --git a/ci.sh b/ci.sh index 4794a46..a3d6602 100755 --- a/ci.sh +++ b/ci.sh @@ -3,5 +3,5 @@ set -euxo pipefail cargo test -cargo build --target thumbv6m-none-eabi +cargo build --target thumbv6m-none-eabi --features portable-atomic/unsafe-assume-single-core cargo build --target thumbv7em-none-eabi diff --git a/src/atomic_bitset.rs b/src/atomic_bitset.rs index 81e8897..cc1cf4a 100644 --- a/src/atomic_bitset.rs +++ b/src/atomic_bitset.rs @@ -1,4 +1,4 @@ -use atomic_polyfill::{AtomicU32, Ordering}; +use portable_atomic::{AtomicU32, Ordering}; pub struct AtomicBitset where diff --git a/src/lib.rs b/src/lib.rs index 66ad238..cde33c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,12 +2,12 @@ mod atomic_bitset; -use atomic_polyfill::AtomicU32; use core::cell::UnsafeCell; use core::hash::{Hash, Hasher}; use core::mem::MaybeUninit; use core::ops::{Deref, DerefMut}; use core::{cmp, mem, ptr::NonNull}; +use portable_atomic::AtomicU32; use crate::atomic_bitset::AtomicBitset;