Skip to content

Commit 2c248a3

Browse files
committed
Fixed so pool and MPMC works on thumbv6
1 parent 1fac593 commit 2c248a3

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ __trybuild = []
3232
[target.x86_64-unknown-linux-gnu.dev-dependencies]
3333
scoped_threadpool = "0.1.8"
3434

35+
[target.thumbv6m-none-eabi.dependencies]
36+
atomic-polyfill = "0.1.2"
37+
3538
[dependencies]
3639
hash32 = "0.1.0"
3740

build.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ fn main() -> Result<(), Box<dyn Error>> {
2424
// built-in targets with no atomic / CAS support as of nightly-2019-12-17
2525
// see the `no-atomics.sh` / `no-cas.sh` script sitting next to this file
2626
match &target[..] {
27-
"thumbv6m-none-eabi"
28-
| "msp430-none-elf"
29-
| "riscv32i-unknown-none-elf"
30-
| "riscv32imc-unknown-none-elf" => {}
27+
"msp430-none-elf" | "riscv32i-unknown-none-elf" | "riscv32imc-unknown-none-elf" => {}
3128

3229
_ => {
3330
println!("cargo:rustc-cfg=has_cas");

src/mpmc.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@
8282
//!
8383
//! [0]: http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue
8484
85-
use core::{
86-
cell::UnsafeCell,
87-
mem::MaybeUninit,
88-
sync::atomic::{AtomicU8, Ordering},
89-
};
85+
use core::{cell::UnsafeCell, mem::MaybeUninit};
86+
87+
#[cfg(armv6m)]
88+
use atomic_polyfill::{AtomicU8, Ordering};
89+
90+
#[cfg(not(armv6m))]
91+
use core::sync::atomic::{AtomicU8, Ordering};
9092

9193
/// MPMC queue with a capacity for 2 elements
9294
pub struct Q2<T> {

src/pool/llsc.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
//! Stack based on LL/SC atomics
22
33
pub use core::ptr::NonNull as Ptr;
4-
use core::{
5-
cell::UnsafeCell,
6-
ptr,
7-
sync::atomic::{AtomicPtr, Ordering},
8-
};
4+
use core::{cell::UnsafeCell, ptr};
5+
6+
#[cfg(armv6m)]
7+
use atomic_polyfill::{AtomicPtr, Ordering};
8+
9+
#[cfg(not(armv6m))]
10+
use core::sync::atomic::{AtomicPtr, Ordering};
911

1012
/// Unfortunate implementation detail required to use the
1113
/// [`Pool.grow_exact`](struct.Pool.html#method.grow_exact) method

0 commit comments

Comments
 (0)