Skip to content

Commit

Permalink
Merge #135
Browse files Browse the repository at this point in the history
135: remove spsc / pool / mpmc modules on targets w/o atomic / CAS support r=japaric a=japaric

closes #123

Co-authored-by: Jorge Aparicio <[email protected]>
  • Loading branch information
bors[bot] and japaric authored Dec 17, 2019
2 parents fe1e56c + 8d1849c commit e4abb7e
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 151 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ matrix:
rust: stable
if: branch != master

# does not support atomic loads
- env: TARGET=riscv32imc-unknown-none-elf
rust: stable
if: branch != master

# build docs on master
- env: TARGET=x86_64-unknown-linux-gnu
rust: nightly
Expand Down
21 changes: 21 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,26 @@ fn main() -> Result<(), Box<dyn Error>> {
println!("cargo:rustc-cfg=armv8m_main");
}

// built-in targets with no atomic / CAS support as of nightly-2019-12-17
// see the `no-atomics.sh` / `no-cas.sh` script sitting next to this file
match &target[..] {
"thumbv6m-none-eabi"
| "msp430-none-elf"
| "riscv32i-unknown-none-elf"
| "riscv32imc-unknown-none-elf" => {}

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

match &target[..] {
"msp430-none-elf" | "riscv32i-unknown-none-elf" | "riscv32imc-unknown-none-elf" => {}

_ => {
println!("cargo:rustc-cfg=has_atomics");
}
};

Ok(())
}
14 changes: 14 additions & 0 deletions no-atomics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -euo pipefail

main() {
IFS='
'
for t in $(rustc --print target-list); do
rustc +nightly --print cfg --target $t | grep 'target_has_atomic_load_store=' >/dev/null || echo $t
done

}

main
14 changes: 14 additions & 0 deletions no-cas.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -euo pipefail

main() {
IFS='
'
for t in $(rustc --print target-list); do
rustc +nightly --print cfg --target $t | grep 'target_has_atomic=' >/dev/null || echo $t
done

}

main
2 changes: 2 additions & 0 deletions src/i.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use core::{marker::PhantomData, mem::MaybeUninit};

#[cfg(has_atomics)]
use crate::spsc::{Atomic, MultiCore};

/// `const-fn` version of [`BinaryHeap`](../binary_heap/struct.BinaryHeap.html)
Expand All @@ -16,6 +17,7 @@ pub struct LinearMap<A> {
}

/// `const-fn` version of [`spsc::Queue`](../spsc/struct.Queue.html)
#[cfg(has_atomics)]
pub struct Queue<A, U = usize, C = MultiCore> {
// this is from where we dequeue items
pub(crate) head: Atomic<U, C>,
Expand Down
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ mod ser;

pub mod binary_heap;
pub mod i;
#[cfg(not(armv6m))]
#[cfg(has_cas)]
pub mod mpmc;
#[cfg(not(armv6m))]
#[cfg(has_cas)]
pub mod pool;
#[cfg(has_atomics)]
pub mod spsc;

mod sealed;
2 changes: 2 additions & 0 deletions src/mpmc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! A fixed capacity Multiple-Producer Multiple-Consumer (MPMC) lock-free queue
//!
//! NOTE: This module is not available on targets that do *not* support CAS operations, e.g. ARMv6-M
//!
//! # Example
//!
//! This queue can be constructed in "const context". Placing it in a `static` variable lets *all*
Expand Down
2 changes: 2 additions & 0 deletions src/pool/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! A heap-less, interrupt-safe, lock-free memory pool (\*)
//!
//! NOTE: This module is not available on targets that do *not* support CAS operations, e.g. ARMv6-M
//!
//! (\*) Currently, the implementation is only lock-free *and* `Sync` on ARMv7-M devices
//!
//! # Examples
Expand Down
Loading

0 comments on commit e4abb7e

Please sign in to comment.