Skip to content

Commit

Permalink
replace the ?UNUSED? thumbv6 with target_has_atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
Anatol Ulrich committed Aug 10, 2024
1 parent 84b33de commit a9e59b1
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions source/abi/src/bbqueue_ipc/bbbuffer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
use crate::bbqueue_ipc::{
framed::{FrameConsumer, FrameProducer},
Error, Result,
};
use core::{
cmp::min,
marker::PhantomData,
Expand All @@ -14,6 +10,11 @@ use core::{
Ordering::{AcqRel, Acquire, Relaxed, Release, SeqCst},
},
};

use crate::bbqueue_ipc::{
framed::{FrameConsumer, FrameProducer},
Error, Result,
};
#[derive(Debug)]
#[repr(C)]
/// A backing structure for a BBQueue. Can be used to create either
Expand Down Expand Up @@ -442,7 +443,7 @@ impl<'a> Consumer<'a> {
/// automatically be committed with `to_commit()`, then no bytes
/// will be comitted for writing.
///
/// If the `thumbv6` feature is selected, dropping the grant
/// if the target doesn't have atomics, dropping the grant
/// without committing it takes a short critical section,
#[derive(Debug, PartialEq)]
pub struct GrantW<'a> {
Expand All @@ -463,7 +464,7 @@ unsafe impl<'a> Send for GrantW<'a> {}
/// as read.
///
///
/// If the `thumbv6` feature is selected, dropping the grant
/// if the target doesn't have atomics, dropping the grant
/// without releasing it takes a short critical section,
#[derive(Debug, PartialEq)]
pub struct GrantR<'a> {
Expand Down Expand Up @@ -495,7 +496,7 @@ impl<'a> GrantW<'a> {
/// If `used` is larger than the given grant, the maximum amount will
/// be commited
///
/// NOTE: If the `thumbv6` feature is selected, this function takes a short critical
/// NOTE: if the target doesn't have atomics, this function takes a short critical
/// section while committing.
pub fn commit(mut self, used: usize) {
self.commit_inner(used);
Expand Down Expand Up @@ -588,7 +589,7 @@ impl<'a> GrantR<'a> {
/// If `used` is larger than the given grant, the full grant will
/// be released.
///
/// NOTE: If the `thumbv6` feature is selected, this function takes a short critical
/// NOTE: if the target doesn't have atomics, this function takes a short critical
/// section while releasing.
pub fn release(mut self, used: usize) {
// Saturate the grant release
Expand Down Expand Up @@ -666,7 +667,7 @@ impl<'a> SplitGrantR<'a> {
/// If `used` is larger than the given grant, the full grant will
/// be released.
///
/// NOTE: If the `thumbv6` feature is selected, this function takes a short critical
/// NOTE: if the target doesn't have atomics, this function takes a short critical
/// section while releasing.
pub fn release(mut self, used: usize) {
// Saturate the grant release
Expand Down Expand Up @@ -771,12 +772,13 @@ impl<'a> DerefMut for GrantR<'a> {
}
}

#[cfg(feature = "thumbv6")]
#[cfg(not(target_has_atomic))]
mod atomic {
use core::sync::atomic::{
AtomicBool, AtomicUsize,
Ordering::{self, Acquire, Release},
};

use cortex_m::interrupt::free;

#[inline(always)]
Expand Down Expand Up @@ -807,7 +809,7 @@ mod atomic {
}
}

#[cfg(not(feature = "thumbv6"))]
#[cfg(target_has_atomic)]
mod atomic {
use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};

Expand Down

0 comments on commit a9e59b1

Please sign in to comment.