Skip to content

Commit

Permalink
Remove unnecessary use of atomic-polyfill.
Browse files Browse the repository at this point in the history
Only use it when CAS is actually needed.
  • Loading branch information
Dirbaio committed Dec 23, 2022
1 parent cd9a65b commit 10c9cc3
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 28 deletions.
11 changes: 6 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@
"rust-analyzer.checkOnSave.noDefaultFeatures": true,
"rust-analyzer.cargo.noDefaultFeatures": true,
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.cargo.target": "thumbv7em-none-eabi",
//"rust-analyzer.cargo.target": "thumbv7em-none-eabi",
"rust-analyzer.cargo.target": "thumbv8m.main-none-eabihf",
"rust-analyzer.cargo.features": [
// These are needed to prevent embassy-net from failing to build
//"embassy-net/medium-ethernet",
//"embassy-net/tcp",
//"embassy-net/pool-16",
//"time-tick-16mhz",
//"defmt-timestamp-uptime",
"nightly",
//"nightly",
//"unstable-traits",
],
"rust-analyzer.linkedProjects": [
// Declare for the target you wish to develop
//"embassy-executor/Cargo.toml",
//"embassy-sync/Cargo.toml",
"examples/nrf/Cargo.toml",
//"examples/nrf/Cargo.toml",
// "examples/nrf-rtos-trace/Cargo.toml",
// "examples/rp/Cargo.toml",
// "examples/std/Cargo.toml",
// "examples/stm32f0/Cargo.toml",
// "examples/stm32f1/Cargo.toml",
//"examples/stm32f1/Cargo.toml",
// "examples/stm32f2/Cargo.toml",
// "examples/stm32f3/Cargo.toml",
// "examples/stm32f4/Cargo.toml",
Expand All @@ -35,7 +36,7 @@
// "examples/stm32l0/Cargo.toml",
// "examples/stm32l1/Cargo.toml",
// "examples/stm32l4/Cargo.toml",
// "examples/stm32l5/Cargo.toml",
"examples/stm32l5/Cargo.toml",
// "examples/stm32u5/Cargo.toml",
// "examples/stm32wb/Cargo.toml",
// "examples/stm32wb55/Cargo.toml",
Expand Down
3 changes: 1 addition & 2 deletions embassy-executor/src/arch/riscv32.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use core::marker::PhantomData;
use core::ptr;

use atomic_polyfill::{AtomicBool, Ordering};
use core::sync::atomic::{AtomicBool, Ordering};

use super::{raw, Spawner};

Expand Down
3 changes: 1 addition & 2 deletions embassy-executor/src/arch/xtensa.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use core::marker::PhantomData;
use core::ptr;

use atomic_polyfill::{AtomicBool, Ordering};
use core::sync::atomic::{AtomicBool, Ordering};

use super::{raw, Spawner};

Expand Down
1 change: 0 additions & 1 deletion embassy-net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ generic-array = { version = "0.14.4", default-features = false }
stable_deref_trait = { version = "1.2.0", default-features = false }
futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] }
atomic-pool = "1.0"
atomic-polyfill = "1.0.1"
embedded-nal-async = { version = "0.3.0", optional = true }

[dependencies.smoltcp]
Expand Down
2 changes: 1 addition & 1 deletion embassy-net/src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ pub mod client {
use core::cell::UnsafeCell;
use core::mem::MaybeUninit;
use core::ptr::NonNull;
use core::sync::atomic::{AtomicBool, Ordering};

use atomic_polyfill::{AtomicBool, Ordering};
use embedded_nal_async::IpAddr;

use super::*;
Expand Down
4 changes: 1 addition & 3 deletions embassy-rp/src/multicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
//! ```

use core::mem::ManuallyDrop;
use core::sync::atomic::{compiler_fence, Ordering};

use atomic_polyfill::AtomicBool;
use core::sync::atomic::{compiler_fence, AtomicBool, Ordering};

use crate::interrupt::{Interrupt, InterruptExt};
use crate::peripherals::CORE1;
Expand Down
3 changes: 1 addition & 2 deletions embassy-rp/src/usb.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use core::future::poll_fn;
use core::marker::PhantomData;
use core::slice;
use core::sync::atomic::Ordering;
use core::sync::atomic::{compiler_fence, Ordering};
use core::task::Poll;

use atomic_polyfill::compiler_fence;
use embassy_hal_common::into_ref;
use embassy_sync::waitqueue::AtomicWaker;
use embassy_usb_driver as driver;
Expand Down
3 changes: 2 additions & 1 deletion embassy-stm32/src/adc/v4.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use atomic_polyfill::{AtomicU8, Ordering};
use core::sync::atomic::{AtomicU8, Ordering};

use embedded_hal_02::blocking::delay::DelayUs;
use pac::adc::vals::{Adcaldif, Boost, Difsel, Exten, Pcsel};
use pac::adccommon::vals::Presc;
Expand Down
3 changes: 1 addition & 2 deletions embassy-stm32/src/flash/f4.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use core::convert::TryInto;
use core::ptr::write_volatile;

use atomic_polyfill::{fence, Ordering};
use core::sync::atomic::{fence, Ordering};

use super::{ERASE_SIZE, FLASH_BASE, FLASH_SIZE};
use crate::flash::Error;
Expand Down
3 changes: 1 addition & 2 deletions embassy-stm32/src/flash/f7.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use core::convert::TryInto;
use core::ptr::write_volatile;

use atomic_polyfill::{fence, Ordering};
use core::sync::atomic::{fence, Ordering};

use crate::flash::Error;
use crate::pac;
Expand Down
4 changes: 2 additions & 2 deletions embassy-stm32/src/flash/h7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub(crate) unsafe fn blocking_write(offset: u32, buf: &[u8]) -> Result<(), Error

cortex_m::asm::isb();
cortex_m::asm::dsb();
atomic_polyfill::fence(atomic_polyfill::Ordering::SeqCst);
core::sync::atomic::fence(core::sync::atomic::Ordering::SeqCst);

let ret = {
let mut ret: Result<(), Error> = Ok(());
Expand Down Expand Up @@ -70,7 +70,7 @@ pub(crate) unsafe fn blocking_write(offset: u32, buf: &[u8]) -> Result<(), Error

cortex_m::asm::isb();
cortex_m::asm::dsb();
atomic_polyfill::fence(atomic_polyfill::Ordering::SeqCst);
core::sync::atomic::fence(core::sync::atomic::Ordering::SeqCst);

ret
}
Expand Down
5 changes: 3 additions & 2 deletions embassy-stm32/src/i2c/v2.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use core::cmp;
use core::future::poll_fn;
use core::sync::atomic::{AtomicUsize, Ordering};
use core::task::Poll;

use atomic_polyfill::{AtomicUsize, Ordering};
use embassy_embedded_hal::SetConfig;
use embassy_hal_common::drop::OnDrop;
use embassy_hal_common::{into_ref, PeripheralRef};
Expand Down Expand Up @@ -131,7 +131,8 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {

if isr.tcr() || isr.tc() {
let state = T::state();
state.chunks_transferred.fetch_add(1, Ordering::Relaxed);
let transferred = state.chunks_transferred.load(Ordering::Relaxed);
state.chunks_transferred.store(transferred + 1, Ordering::Relaxed);
state.waker.wake();
}
// The flag can only be cleared by writting to nbytes, we won't do that here, so disable
Expand Down
2 changes: 1 addition & 1 deletion embassy-stm32/src/usart/buffered.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use core::cell::RefCell;
use core::future::poll_fn;
use core::sync::atomic::{compiler_fence, Ordering};
use core::task::Poll;

use atomic_polyfill::{compiler_fence, Ordering};
use embassy_cortex_m::peripheral::{PeripheralMutex, PeripheralState, StateStorage};
use embassy_hal_common::ring_buffer::RingBuffer;
use embassy_sync::waitqueue::WakerRegistration;
Expand Down
2 changes: 1 addition & 1 deletion embassy-stm32/src/usart/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

use core::future::poll_fn;
use core::marker::PhantomData;
use core::sync::atomic::{compiler_fence, Ordering};
use core::task::Poll;

use atomic_polyfill::{compiler_fence, Ordering};
use embassy_cortex_m::interrupt::InterruptExt;
use embassy_futures::select::{select, Either};
use embassy_hal_common::drop::OnDrop;
Expand Down
1 change: 0 additions & 1 deletion embassy-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ defmt = { version = "0.3", optional = true }
log = { version = "0.4.14", optional = true }

futures-util = { version = "0.3.17", default-features = false }
atomic-polyfill = "1.0.1"
critical-section = "1.1"
heapless = "0.7.5"
cfg-if = "1.0.0"
Expand Down

0 comments on commit 10c9cc3

Please sign in to comment.