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 40ef66c commit 03a6a54
Show file tree
Hide file tree
Showing 15 changed files with 15 additions and 24 deletions.
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
2 changes: 1 addition & 1 deletion 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
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
3 changes: 1 addition & 2 deletions embassy-stm32/src/usb/usb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

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

use atomic_polyfill::{AtomicBool, AtomicU8};
use embassy_hal_common::into_ref;
use embassy_sync::waitqueue::AtomicWaker;
use embassy_time::{block_for, Duration};
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 03a6a54

Please sign in to comment.