Skip to content

Commit

Permalink
Use atomic-polyfill for AtomicCheckMutex
Browse files Browse the repository at this point in the history
This will allow using shared-bus on thumbv6 platforms which do not have
real atomics.
  • Loading branch information
Rahix committed Feb 8, 2022
1 parent 0f42943 commit 4b66f0a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ once_cell = { version = "1.4.0", optional = true }
cortex-m = { version = "0.6.3", optional = true }
xtensa-lx = { version = "0.6.0", optional = true }
spin = { version = "0.9.2", optional = true }
atomic-polyfill = "0.1.6"

[dev-dependencies]
embedded-hal-mock = "0.8"
Expand Down
4 changes: 2 additions & 2 deletions src/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ mod tests {
#[derive(Debug)]
pub struct AtomicCheckMutex<BUS> {
bus: core::cell::UnsafeCell<BUS>,
busy: core::sync::atomic::AtomicBool,
busy: atomic_polyfill::AtomicBool,
}

// It is explicitly safe to share this across threads because there is a coherency check using an
Expand All @@ -199,7 +199,7 @@ impl<BUS> BusMutex for AtomicCheckMutex<BUS> {
fn create(v: BUS) -> Self {
Self {
bus: core::cell::UnsafeCell::new(v),
busy: core::sync::atomic::AtomicBool::from(false),
busy: atomic_polyfill::AtomicBool::from(false),
}
}

Expand Down

0 comments on commit 4b66f0a

Please sign in to comment.