From ab01e0be3b2faa320ffc169a6aa629fe44a2080c Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 17 Mar 2021 01:47:45 +0100 Subject: [PATCH] Do not reexport atomic-polyfill --- embassy-macros/src/lib.rs | 8 ++++---- embassy/src/executor/mod.rs | 2 +- embassy/src/executor/raw.rs | 2 +- embassy/src/executor/run_queue.rs | 2 +- embassy/src/executor/timer_queue.rs | 2 +- embassy/src/interrupt.rs | 2 +- embassy/src/lib.rs | 7 ++++++- embassy/src/util/forever.rs | 2 +- 8 files changed, 16 insertions(+), 11 deletions(-) diff --git a/embassy-macros/src/lib.rs b/embassy-macros/src/lib.rs index 5b834ff13..710c5a151 100644 --- a/embassy-macros/src/lib.rs +++ b/embassy-macros/src/lib.rs @@ -157,17 +157,17 @@ pub fn interrupt_take(item: TokenStream) -> TokenStream { static HANDLER: ::embassy::interrupt::Handler; } - let func = HANDLER.func.load(::embassy::atomic::Ordering::Acquire); - let ctx = HANDLER.ctx.load(::embassy::atomic::Ordering::Acquire); + let func = HANDLER.func.load(::embassy::export::atomic::Ordering::Acquire); + let ctx = HANDLER.ctx.load(::embassy::export::atomic::Ordering::Acquire); if !func.is_null() { let func: fn(*mut ()) = ::core::mem::transmute(func); func(ctx) } } - static TAKEN: ::embassy::atomic::AtomicBool = ::embassy::atomic::AtomicBool::new(false); + static TAKEN: ::embassy::export::atomic::AtomicBool = ::embassy::export::atomic::AtomicBool::new(false); - if TAKEN.compare_exchange(false, true, ::embassy::atomic::Ordering::AcqRel, ::embassy::atomic::Ordering::Acquire).is_err() { + if TAKEN.compare_exchange(false, true, ::embassy::export::atomic::Ordering::AcqRel, ::embassy::export::atomic::Ordering::Acquire).is_err() { panic!("IRQ Already taken"); } diff --git a/embassy/src/executor/mod.rs b/embassy/src/executor/mod.rs index 7a6caf702..787230c0b 100644 --- a/embassy/src/executor/mod.rs +++ b/embassy/src/executor/mod.rs @@ -1,5 +1,6 @@ pub use embassy_macros::task; +use atomic_polyfill::Ordering; use core::future::Future; use core::marker::PhantomData; use core::pin::Pin; @@ -15,7 +16,6 @@ mod util; mod waker; use self::util::UninitCell; -use crate::atomic::Ordering; use crate::fmt::panic; use crate::interrupt::{Interrupt, InterruptExt}; use crate::time::Alarm; diff --git a/embassy/src/executor/raw.rs b/embassy/src/executor/raw.rs index 0c947080f..84e171dff 100644 --- a/embassy/src/executor/raw.rs +++ b/embassy/src/executor/raw.rs @@ -1,3 +1,4 @@ +use atomic_polyfill::{AtomicU32, Ordering}; use core::cell::Cell; use core::cmp::min; use core::marker::PhantomData; @@ -9,7 +10,6 @@ use super::run_queue::{RunQueue, RunQueueItem}; use super::timer_queue::{TimerQueue, TimerQueueItem}; use super::util::UninitCell; use super::waker; -use crate::atomic::{AtomicU32, Ordering}; use crate::time::{Alarm, Instant}; /// Task is spawned (has a future) diff --git a/embassy/src/executor/run_queue.rs b/embassy/src/executor/run_queue.rs index fb7c65e03..1d1023e51 100644 --- a/embassy/src/executor/run_queue.rs +++ b/embassy/src/executor/run_queue.rs @@ -1,8 +1,8 @@ +use atomic_polyfill::{AtomicPtr, Ordering}; use core::ptr; use core::ptr::NonNull; use super::raw::Task; -use crate::atomic::{AtomicPtr, Ordering}; pub(crate) struct RunQueueItem { next: AtomicPtr, diff --git a/embassy/src/executor/timer_queue.rs b/embassy/src/executor/timer_queue.rs index bd043aeb5..d72eb93b1 100644 --- a/embassy/src/executor/timer_queue.rs +++ b/embassy/src/executor/timer_queue.rs @@ -1,10 +1,10 @@ +use atomic_polyfill::{AtomicPtr, Ordering}; use core::cell::Cell; use core::cmp::min; use core::ptr; use core::ptr::NonNull; use super::raw::{Task, STATE_TIMER_QUEUED}; -use crate::atomic::{AtomicPtr, Ordering}; use crate::time::Instant; pub(crate) struct TimerQueueItem { diff --git a/embassy/src/interrupt.rs b/embassy/src/interrupt.rs index 6491a57d9..013e722e6 100644 --- a/embassy/src/interrupt.rs +++ b/embassy/src/interrupt.rs @@ -1,7 +1,7 @@ use core::ptr; use cortex_m::peripheral::NVIC; -use crate::atomic::{AtomicBool, AtomicPtr, Ordering}; +use atomic_polyfill::{AtomicBool, AtomicPtr, Ordering}; pub use embassy_macros::interrupt_declare as declare; pub use embassy_macros::interrupt_take as take; diff --git a/embassy/src/lib.rs b/embassy/src/lib.rs index 55c8d8575..b6fefc9f7 100644 --- a/embassy/src/lib.rs +++ b/embassy/src/lib.rs @@ -18,4 +18,9 @@ pub mod time; pub mod util; pub use embassy_traits as traits; -pub use atomic_polyfill as atomic; + +#[doc(hidden)] +/// Implementation details for embassy macros. DO NOT USE. +pub mod export { + pub use atomic_polyfill as atomic; +} diff --git a/embassy/src/util/forever.rs b/embassy/src/util/forever.rs index fac3c260b..ac23a3ce3 100644 --- a/embassy/src/util/forever.rs +++ b/embassy/src/util/forever.rs @@ -1,7 +1,7 @@ use core::cell::UnsafeCell; use core::mem::MaybeUninit; -use crate::atomic::{AtomicBool, Ordering}; +use atomic_polyfill::{AtomicBool, Ordering}; pub struct Forever { used: AtomicBool,