All notable changes to this project will be documented in this file.
This project adheres to Semantic Versioning.
RISC-V without A-extension: Support RMW when Zaamo extension enabled (even when unsafe-assume-single-core
disabled). (#185, 9983a8b) See “operations don't require disabling interrupts” list in interrupt
module's readme for the operations provided.
Support run-time detection of RISC-V Zacas extension (currently disabled by default). (#183)
Support 128-bit atomics on Arm64EC (currently nightly-only) (#184)
Improve compile-time detection of powerpc64 quadword-atomics. (3eb8507)
Improve diagnostics when method that requires CAS is unavailable. (#181)
Before:
error[E0599]: no method named `compare_exchange` found for struct `portable_atomic::AtomicUsize` in the current scope --> src/race.rs:60:24 | 60 | self.inner.compare_exchange(0, value.get(), Ordering::AcqRel, Ordering::Acquire); | ^^^^^^^^^^^^^^^^ method not found in `AtomicUsize`
After:
error[E0277]: `compare_exchange` requires atomic CAS but not available on this target by default --> src/race.rs:60:24 | 60 | self.inner.compare_exchange(0, value.get(), Ordering::AcqRel, Ordering::Acquire); | ^^^^^^^^^^^^^^^^ this associated function is not available on this target by default | = help: the trait `HasCompareExchange` is not implemented for `&portable_atomic::AtomicUsize` = note: consider enabling one of the `unsafe-assume-single-core` or `critical-section` Cargo features = note: see <https://docs.rs/portable-atomic/latest/portable_atomic/#optional-features> for more.
Improve compile error messages for some other cases (19716ac, 61dcaaa)
Various improvements to RISC-V.
Improve support of run-time detection and outline-atomics:
Support AArch64 FEAT_LRCPC3/FEAT_LSE128 with pre-16 LLVM. (#178)
Improve compile-time detection of AArch64 FEAT_LSE2/FEAT_LRCPC3/FEAT_LSE128. (10d47de)
Relax minimal version of serde
(supported via optional feature) to 1.0.60.
Support run-time detection for cmpxchg16b on x86_64 on pre-1.69 rustc. (#154)
Make into_inner
const fn
on Rust 1.56+. (align to the std atomic change in Rust 1.79) (dee1f89)
Work around rustc_codegen_gcc bug on x86_64. (d938f77)
Optimize x86_64 atomics.
Make rustc version detection robust for custom toolchains. (f8ea85e)
Respect RUSTC_WRAPPER
in rustc version detection.
Our build script is now less likely to be re-run unnecessarily in versions where the cargo bug fix is available (cargo 1.79+). (52c277b)
Add cfg_{has,no}_atomic_{8,16,32,64,128,ptr}
macros to enable code when the corresponding atomic implementation is available/unavailable.
Add cfg_{has,no}_atomic_cas
macros to enable code when atomic CAS/RMW implementation is available/unavailable.
Improve support for RISC-V targets without atomic CAS.
Fix bug in i{8,16}
fetch_{or,xor}
on RISC-V without A-extension where unsafe-assume-single-core
and force-amo
are enabled.
Optimize swap
for targets that do not have native atomic CAS instructions.
Note: This release has been yanked due to a bug fixed in 1.5.1.
Add from_ptr
.
Add force-amo
feature (portable_atomic_force_amo
cfg) for single-core RISC-V without A-extension. (#124)
Support run-time detection on AArch64 on pre-1.61 rustc. (#98)
This also solves a compatibility issue with rustc_codegen_cranelift.
Support run-time detection of FEAT_LSE2. (#126)
Support run-time detection of FEAT_LSE on AArch64 NetBSD. (#66)
Acknowledge ESP-IDF targets' 64-bit atomics are not lock-free. See #122 for more.
Optimize 128-bit weak CAS on powerpc64.
Optimize interrupt disable on no-std pre-v6 Arm where unsafe-assume-single-core
and disable-fiq
are enabled. (771c45d)
Improve detection of Apple hardware. (5c3a43b)
Improve compatibility with the future version of Miri.
Optimize AArch64 128-bit atomic store/swap/fetch_and/fetch_or when the lse128
target feature is enabled at compile-time. (#68)
Optimize AArch64 128-bit atomic load/store when the rcpc3
target feature is enabled at compile-time. (#68)
Optimize inline assemblies on Arm, AArch64, and MSP430.
AtomicBool
on RISC-V/LoongArch64. This is the same as rust-lang/rust#114034, but is available for all rustc versions.Allow using embedded-related cfgs as Cargo features. (#94, thanks @Dirbaio)
Originally, we were providing these as cfgs instead of features, but based on a strong request from the embedded ecosystem, we have agreed to provide them as features as well. See #94 for more.
cfgs are kept and can be used as aliases for features.
Acknowledge all x86_64 Apple targets support 128-bit atomics.
Our code already recognizes this via cfg(target_feature)
, so this only affects docs and users using pre-1.69 stable rustc.
See also rust-lang/rust#112150.
Optimize 128-bit atomics on AArch64/s390x.
Fix build error on AArch64 ILP32 ABI targets (tier 3).
Optimize 128-bit atomics on s390x.
Fix bug in powerpc64/s390x 128-bit atomic RMWs on old nightly.
Optimize 128-bit atomics on powerpc64/s390x.
Add require-cas
feature. (#100)
If your crate supports no-std environment and requires atomic CAS, enabling this feature will allow the portable-atomic
to display helpful error messages to users on targets requiring additional action on the user side to provide atomic CAS.
[dependencies] portable-atomic = { version = "1.3", default-features = false, features = ["require-cas"] }
See #100 for more.
Support portable_atomic_unsafe_assume_single_core
cfg on Xtensa targets without atomic CAS. (#86)
Fix bug in AArch64 128-bit SeqCst load when FEAT_LSE2 is enabled at compile-time. This is the same bug that was fixed in the recently released GCC 13.1. LLVM also has the same bug, which had not yet been fixed when the patch was created; I will open a bug report if necessary after looking into the situation in LLVM. (a29154b)
Fix compile error on bpf{eb,el}-unknown-none
(tier 3) and mipsel-sony-psx
(tier 3) when critical-section
feature is disabled.
Various optimizations
cmpxchg16b
target feature is not available at compile-time. (40c4cd4)--cfg portable_atomic_outline_atomics
. (#90)--cfg portable_atomic_outline_atomics
. See the atomic128
module's readme for more. (8418235, 31d0862)Make 64-bit atomics lock-free on Arm Linux/Android targets that do not have 64-bit atomics (e.g., armv5te-unknown-linux-gnueabi, arm-linux-androideabi, etc.) when the kernel version is 3.1 or later. (#82)
Fix AArch64 128-bit atomics performance regression on Apple hardware. (#89)
Optimize 128-bit atomics on AArch64, x86_64, powerpc64, and s390x.
Add Atomic{I,U}*::bit_{set,clear,toggle}
and AtomicPtr::bit_{set,clear,toggle}
. (#72)
They correspond to x86's lock bt{s,r,c}
, and the implementation calls them on x86/x86_64.
Add AtomicU*::{fetch_neg,neg}
methods. Previously it was only available on AtomicI*
and AtomicF*
.
Add as_ptr
method to all atomic types. (#79)
Make AtomicF{32,64}::as_bits
const fn
on Rust 1.58+. (#79)
Relax ordering in Serialize
impl to reflect the upstream change.
Optimize x86_64 outline-atomics for 128-bit atomics.
Optimize AArch64 outline-atomics for 128-bit atomics.
atomic128
module's readme for a list of platforms that support outline-atomics. Most of these improvements have already been submitted and accepted in rust-lang/stdarch and will soon be available in std::arch::is_aarch64_feature_detected
.Performance improvements. (#70, #81, 6c189ae, 13c92b0, etc.)
Documentation improvements.
Atomic{I,U}*::{fetch_not,not}
methods. (#62)Add critical-section
feature to use critical-section on targets where atomic CAS is not natively available. (#51, thanks @Dirbaio)
This is useful to get atomic CAS when --cfg portable_atomic_unsafe_assume_single_core
can't be used, such as multi-core targets, unprivileged code running under some RTOS, or environments where disabling interrupts needs extra care due to e.g. real-time requirements.
See documentation for more.
Remove outline-atomics
feature. This was no-op since 0.3.19.
Documentation improvements.
The latest version of portable-atomic is 1.x. This release makes portable-atomic 0.3 is built on top of portable-atomic 1.x to make bug fixes and improvements such as support for new targets in 1.x available to the ecosystem that depends on older portable-atomic. portable-atomic 0.3 is still maintained passively, but upgrading to portable-atomic 1.x is recommended. (There are no breaking changes from 0.3, except that a deprecated no-op outline-atomics
Cargo feature has been removed.) (#99)
Add AtomicI*::{fetch_neg,neg}
and AtomicF*::fetch_neg
methods. (#54)
AtomicI*::neg
are equivalent to the corresponding fetch_*
methods, but do not return the previous value. They are intended for optimization on platforms that have atomic instructions for the corresponding operation, such as x86's lock neg
.
Currently, optimizations by these methods (neg
) are only guaranteed for x86/x86_64.
Add Atomic{I,U}*::{fetch_not,not}
methods. (#54)
Atomic{I,U}*::not
are equivalent to the corresponding fetch_*
methods, but do not return the previous value. They are intended for optimization on platforms that have atomic instructions for the corresponding operation, such as x86‘s lock not
, MSP430’s inv
.
Currently, optimizations by these methods (not
) are only guaranteed for x86/x86_64 and MSP430.
(Note: AtomicBool
already has fetch_not
and not
methods.)
Enable outline-atomics for 128-bit atomics by default. (#57) See #57 for more.
Improve support for old nightly compilers.
Fix build error when not using portable_atomic_unsafe_assume_single_core
cfg on AVR and MSP430 custom targets. (#50)
Since 0.3.11, atomic CAS was supported without the cfg on AVR and MSP430 builtin targets, but that change was not applied to custom targets.
Optimize x86_64 128-bit atomic load/store on AMD CPU with AVX. (#49)
Improve support for custom targets on old rustc.
Add Atomic{I,U}*::{add,sub,and,or,xor}
and AtomicBool::{and,or,xor}
methods. (#47)
They are equivalent to the corresponding fetch_*
methods, but do not return the previous value. They are intended for optimization on platforms that implement atomics using inline assembly, such as the MSP430.
Currently, optimizations by these methods (add
,sub
,and
,or
,xor
) are only guaranteed for MSP430; on x86/x86_64, LLVM can optimize in most cases, so cases, where this would improve things, should be rare.
Various improvements to portable_atomic_unsafe_assume_single_core
cfg. (#44, #40)
portable_atomic_disable_fiq
cfg.portable_atomic_s_mode
cfg.See #44 for more.
Implement workaround for std cpuid bug due to LLVM bug (rust-lang/rust#101346, llvm/llvm-project#57550).
Optimize atomic load/store on no-std pre-v6 Arm when portable_atomic_unsafe_assume_single_core
cfg is used. (#36)
Support pre-power8 powerpc64le. powerpc64le's default cpu version is power8, but you can technically compile it for the old cpu using the unsafe -C target-cpu
rustc flag.
Use track_caller when debug assertions are enabled on Rust 1.46+.
Make powerpc64 128-bit atomics compatible with Miri and ThreadSanitizer on LLVM 15+.
Document that 128-bit atomics are compatible with Miri and ThreadSanitizer on recent nightly.
portable_atomic_unsafe_assume_single_core
. (#28)Always provide atomic CAS for MSP430 and AVR. (#31)
This previously required unsafe cfg portable_atomic_unsafe_assume_single_core
, but since all MSP430 and AVR are single-core, we can safely provide atomic CAS based on disabling interrupts.
Support fence
and compiler_fence
on MSP430. (On MSP430, the standard library's fences are currently unavailable due to LLVM errors.)
Update safety requirements for unsafe cfg portable_atomic_unsafe_assume_single_core
to mention use of privileged instructions to disable interrupts.
Atomic operations based on disabling interrupts on single-core systems are now considered lock-free.
The previous behavior was inconsistent because we consider the pre-v6 Arm Linux's atomic operations provided in a similar way by the Linux kernel to be lock-free.
Respect -Z allow-features
.
lse
target feature is enabled at compile-time. (#20)Fix build error on old Miri.
Documentation improvements.
Provide stable equivalent of #![feature(strict_provenance_atomic_ptr)]
. (#23)
AtomicPtr::fetch_ptr_{add,sub}
AtomicPtr::fetch_byte_{add,sub}
AtomicPtr::fetch_{or,and,xor}
These APIs are compatible with strict-provenance on cfg(miri)
. Otherwise, they are compatible with permissive-provenance. Once #![feature(strict_provenance_atomic_ptr)]
is stabilized, these APIs will be strict-provenance compatible in all cases from the version in which it is stabilized.
Provide stable equivalent of #![feature(atomic_bool_fetch_not)]
. (#24)
AtomicBool::fetch_not
Optimize x86_64 128-bit RMWs. (#22)
Optimize x86_64 outline-atomics.
Optimize inline assemblies on Arm and AArch64.
Revert thumbv6m atomic load/store changes made in 0.3.5. This is because rust-lang/rust#99595 has been reverted, so this is no longer needed.
Fix build failure due to the existence of the specs
directory.
Documentation improvements.
Optimize inline assemblies on x86_64, RISC-V, and MSP430.
Note: This release has been yanked due to a bug fixed in 0.3.6.
Provide thumbv6m atomic load/store which is planned to be removed from the standard library in rust-lang/rust#99595. (#18)
Optimize inline assemblies on AArch64, RISC-V, and powerpc64.
Optimize x86_64 128-bit atomic load/store on Intel CPU with AVX. (#16)
Support native 128-bit atomic operations for powerpc64 (le or pwr8+, currently nightly-only).
Fix behavior differences between stable and nightly. (#15)
Optimize AArch64 128-bit atomic load/store when the lse2
target feature is enabled at compile-time. (#11)
Relax ordering in Debug
impl to reflect std changes. (#12)
Support native 128-bit atomic operations for s390x (currently nightly-only).
Add AtomicF{32,64}::fetch_abs
.
Add #[must_use]
to constructors.
Use 128-bit atomic operation mappings same as LLVM on AArch64.
Remove parking_lot
optional feature to allow the use of this crate within global allocators.
Remove i128
feature. Atomic{I,U}128
are now always enabled.
Add outline-atomics
feature. Currently, this is the same as the 0.1's i128-dynamic
, except that fallback
feature is not implicitly enabled.
Remove i128-dynamic
feature in favor of outline-atomics
feature.
Add AtomicF{32,64}::as_bits
.
Note: This release has been yanked due to a bug fixed in 0.1.3.
Add parking_lot
feature to use parking_lot in global locks of fallback implementation.
Fix bug in cmpxchg16b support. (#5)
Note: This release has been yanked due to a bug fixed in 0.1.3.
Atomic{I,U}128
.Note: This release has been yanked due to a bug fixed in 0.1.3.
Initial release