diff --git a/Cargo.toml b/Cargo.toml index e139b06..7a0eb33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,9 @@ keywords = ["cortex-m", "nxp", "lpc"] categories = ["development-tools", "embedded"] rust-version = "1.79" +[dependencies] +portable-atomic = { version = "1", optional = true } + [target.'cfg(loom)'.dependencies] loom = "0.5" diff --git a/src/lib.rs b/src/lib.rs index 5b34126..6023aee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -118,10 +118,13 @@ use loom::{ }; #[cfg(not(loom))] -use core::{ - cell::UnsafeCell, - sync::atomic::{AtomicBool, AtomicU8, AtomicUsize}, -}; +use core::cell::UnsafeCell; + +#[cfg(all(not(loom), not(feature = "portable-atomic")))] +use core::sync::atomic::{AtomicBool, AtomicU8, AtomicUsize}; + +#[cfg(all(not(loom), feature = "portable-atomic"))] +use portable_atomic::{AtomicBool, AtomicU8, AtomicUsize}; #[derive(Clone, Copy)] pub struct Error;