#atomic #polyfill #shim #atomics

no-std atomic-polyfill

Atomic polyfills, for targets where they're not available

4 releases (stable)

1.0.2 Mar 12, 2023
1.0.1 Aug 12, 2022
0.1.11 Nov 29, 2022
0.1.8 Apr 12, 2022
0.1.2 Mar 28, 2021

#30 in Concurrency

Download history 34889/week @ 2022-11-30 35380/week @ 2022-12-07 35769/week @ 2022-12-14 25289/week @ 2022-12-21 21914/week @ 2022-12-28 37790/week @ 2023-01-04 35720/week @ 2023-01-11 33891/week @ 2023-01-18 37217/week @ 2023-01-25 40673/week @ 2023-02-01 41049/week @ 2023-02-08 41594/week @ 2023-02-15 50996/week @ 2023-02-22 50019/week @ 2023-03-01 47697/week @ 2023-03-08 37022/week @ 2023-03-15

192,946 downloads per month
Used in 467 crates (18 directly)


486 lines



This crate polyfills atomics on targets where they're not available, using critical sections. It is intended to be a drop-in replacement for core::sync::atomic.

There are two "levels" of polyfilling:

  • Native: No polyfilling is performed, the native core::sync::atomic::AtomicXX is reexported.
  • Full: Both load/store and compare-and-set operations are polyfilled.

Polyfilling requires a critical-section implementation for the current target. Check the critical-section README for details.

Target support

The right polyfill level is automatically picked based on the target and the atomic width:

Target Level Level for u64/i64
thumbv4t Full Full
thumbv6m Full Full
thumbv7*, thumbv8* Native Full
riscv32imc Full Full
riscv32imac Native Full
xtensa-*-espidf Native Native
xtensa-esp32-* Native Full
xtensa-esp32s2-* Full Full
xtensa-esp32s3-* Native Full
xtensa-esp8266-* Full Full
AVR Full Full

For targets not listed above, atomic-polyfill assumes nothing and reexports core::sync::atomic::*. No polyfilling is done. PRs for polyfilling more targets are welcome :)

Minimum Supported Rust Version (MSRV)

MSRV is currently Rust 1.54. MSRV may be upgraded at any new patch release as long as latest stable Rust is supported.


This work is licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.