Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use atomic-polyfill for AtomicCheckMutex #30

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use atomic-polyfill for AtomicCheckMutex
This will allow using shared-bus on thumbv6 platforms which do not have
real atomics.
  • Loading branch information
Rahix committed Feb 8, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 4b66f0a6ac49e9c2a1883c1d14976f4e4886f9db
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 2 additions & 2 deletions src/mutex.rs
Original file line number Diff line number Diff line change
@@ -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
@@ -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),
}
}