Cargo Features

portable-atomic = { version = "1.6.0", default-features = false, features = ["fallback", "float", "std", "require-cas", "unsafe-assume-single-core", "s-mode", "force-amo", "disable-fiq", "serde", "critical-section"] }
default = fallback

The fallback feature is set by default whenever portable-atomic is added without default-features = false somewhere in the dependency tree.

fallback default

(enabled by default) Enable fallback implementations.

Disabling this allows only atomic types for which the platform natively supports atomic operations.


Provide AtomicF{32,64}.

See documentation for more:


Use std.


Emit compile error if atomic CAS is not available.

See documentation for more:


Assume the target is single core, to enable implementations based on disabling interrupts. IMPORTANT: This feature is unsafe. See the documentation for the safety contract:


The following are sub-features of the unsafe-assume-single-core feature and if enabled without the unsafe-assume-single-core feature will result in a compile error. There is no explicit "unsafe-" prefix because the user has already opted in to "unsafe" by enabling the unsafe-assume-single-core feature, but misuse of these features is also usually considered unsound. See the interrupt module's readme for more:

For RISC-V targets, generate code for S mode to disable interrupts.


For RISC-V targets, use AMO instructions even if A-extension is disabled.
This feature requires Rust 1.72+.


For ARM targets, also disable FIQs when disabling interrupts.

Features from optional dependencies

Note: serde and critical-section are public dependencies.

serde implicit feature

Enables serde

Implements serde::{Serialize,Deserialize} for atomic types.

See documentation for more:

critical-section implicit feature

Enables critical-section

Use critical-section.

See documentation for more: