From f2643a00764955138f88943b7f40c12a16ef4740 Mon Sep 17 00:00:00 2001 From: Yandrik Date: Wed, 15 Mar 2023 14:33:29 +0100 Subject: [PATCH 1/6] fix(rtic-sync): used fully qualified paths in Channel Macro --- rtic-sync/src/channel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtic-sync/src/channel.rs b/rtic-sync/src/channel.rs index 8a817c81ba..aad02801f2 100644 --- a/rtic-sync/src/channel.rs +++ b/rtic-sync/src/channel.rs @@ -102,7 +102,7 @@ impl Channel { #[macro_export] macro_rules! make_channel { ($type:path, $size:expr) => {{ - static mut CHANNEL: Channel<$type, $size> = Channel::new(); + static mut CHANNEL: ::rtic_sync::channel::Channel<$type, $size> = ::rtic_sync::channel::Channel::new(); // SAFETY: This is safe as we hide the static mut from others to access it. // Only this point is where the mutable access happens. From 15b9db4c5d60f8cc7c192261ad01b1ebf74faa83 Mon Sep 17 00:00:00 2001 From: Yandrik Date: Wed, 15 Mar 2023 15:18:31 +0100 Subject: [PATCH 2/6] refactor: re-formatted channel.rs file --- rtic-sync/src/channel.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/rtic-sync/src/channel.rs b/rtic-sync/src/channel.rs index aad02801f2..ee5ea9c183 100644 --- a/rtic-sync/src/channel.rs +++ b/rtic-sync/src/channel.rs @@ -38,6 +38,7 @@ pub struct Channel { } unsafe impl Send for Channel {} + unsafe impl Sync for Channel {} struct UnsafeAccess<'a, const N: usize> { @@ -124,8 +125,8 @@ pub enum TrySendError { } impl core::fmt::Debug for NoReceiver -where - T: core::fmt::Debug, + where + T: core::fmt::Debug, { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "NoReceiver({:?})", self.0) @@ -133,8 +134,8 @@ where } impl core::fmt::Debug for TrySendError -where - T: core::fmt::Debug, + where + T: core::fmt::Debug, { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { @@ -145,8 +146,8 @@ where } impl PartialEq for TrySendError -where - T: PartialEq, + where + T: PartialEq, { fn eq(&self, other: &Self) -> bool { match (self, other) { @@ -176,6 +177,7 @@ impl LinkPtr { } unsafe impl Send for LinkPtr {} + unsafe impl Sync for LinkPtr {} impl<'a, T, const N: usize> core::fmt::Debug for Sender<'a, T, N> { @@ -299,7 +301,7 @@ impl<'a, T, const N: usize> Sender<'a, T, N> { Poll::Pending } }) - .await; + .await; // Make sure the link is removed from the queue. drop(dropper); @@ -429,7 +431,7 @@ impl<'a, T, const N: usize> Receiver<'a, T, N> { Poll::Pending }) - .await + .await } /// Returns true if there are no `Sender`s. From a071ab05b2bb443672c0c21386522d5ebcbcb63a Mon Sep 17 00:00:00 2001 From: Yandrik Date: Wed, 15 Mar 2023 20:04:27 +0100 Subject: [PATCH 3/6] refactor(macro): used $crate for better interop --- rtic-monotonics/src/rp2040.rs | 4 ++-- rtic-monotonics/src/systick.rs | 4 ++-- rtic-sync/src/channel.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rtic-monotonics/src/rp2040.rs b/rtic-monotonics/src/rp2040.rs index 93472e6d39..9b66bca059 100644 --- a/rtic-monotonics/src/rp2040.rs +++ b/rtic-monotonics/src/rp2040.rs @@ -144,12 +144,12 @@ macro_rules! make_rp2040_monotonic_handler { #[no_mangle] #[allow(non_snake_case)] unsafe extern "C" fn TIMER_IRQ_0() { - rtic_monotonics::rp2040::Timer::__tq().on_monotonic_interrupt(); + $crate::rp2040::Timer::__tq().on_monotonic_interrupt(); } pub struct Rp2040Token; - unsafe impl rtic_monotonics::InterruptToken + unsafe impl $crate::InterruptToken for Rp2040Token { } diff --git a/rtic-monotonics/src/systick.rs b/rtic-monotonics/src/systick.rs index feefc7ea05..85184dbda1 100644 --- a/rtic-monotonics/src/systick.rs +++ b/rtic-monotonics/src/systick.rs @@ -162,12 +162,12 @@ macro_rules! make_systick_handler { #[no_mangle] #[allow(non_snake_case)] unsafe extern "C" fn SysTick() { - rtic_monotonics::systick::Systick::__tq().on_monotonic_interrupt(); + $crate::systick::Systick::__tq().on_monotonic_interrupt(); } pub struct SystickToken; - unsafe impl rtic_monotonics::InterruptToken + unsafe impl $crate::InterruptToken for SystickToken { } diff --git a/rtic-sync/src/channel.rs b/rtic-sync/src/channel.rs index ee5ea9c183..d0670c2df6 100644 --- a/rtic-sync/src/channel.rs +++ b/rtic-sync/src/channel.rs @@ -103,7 +103,7 @@ impl Channel { #[macro_export] macro_rules! make_channel { ($type:path, $size:expr) => {{ - static mut CHANNEL: ::rtic_sync::channel::Channel<$type, $size> = ::rtic_sync::channel::Channel::new(); + static mut CHANNEL: $crate::channel::Channel<$type, $size> = $crate::channel::Channel::new(); // SAFETY: This is safe as we hide the static mut from others to access it. // Only this point is where the mutable access happens. From 28790218c0cd6c6ea421aa691d904ac466059087 Mon Sep 17 00:00:00 2001 From: Yandrik Date: Wed, 15 Mar 2023 20:15:20 +0100 Subject: [PATCH 4/6] refactor(macro): changed not-yet-changed crate names to $crate --- rtic-monotonics/src/rp2040.rs | 2 +- rtic-monotonics/src/systick.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rtic-monotonics/src/rp2040.rs b/rtic-monotonics/src/rp2040.rs index 9b66bca059..f2cc7b64ab 100644 --- a/rtic-monotonics/src/rp2040.rs +++ b/rtic-monotonics/src/rp2040.rs @@ -149,7 +149,7 @@ macro_rules! make_rp2040_monotonic_handler { pub struct Rp2040Token; - unsafe impl $crate::InterruptToken + unsafe impl $crate::InterruptToken<$crate::rp2040::Timer> for Rp2040Token { } diff --git a/rtic-monotonics/src/systick.rs b/rtic-monotonics/src/systick.rs index 85184dbda1..a2817832a1 100644 --- a/rtic-monotonics/src/systick.rs +++ b/rtic-monotonics/src/systick.rs @@ -167,7 +167,7 @@ macro_rules! make_systick_handler { pub struct SystickToken; - unsafe impl $crate::InterruptToken + unsafe impl $crate::InterruptToken<$crate::systick::Systick> for SystickToken { } From 60e5232ee90c8b05e92b1ffa16c2d770e726e2b1 Mon Sep 17 00:00:00 2001 From: Yandrik Date: Wed, 15 Mar 2023 20:15:44 +0100 Subject: [PATCH 5/6] doc(monotonic): added update description to changelog --- rtic-monotonics/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/rtic-monotonics/CHANGELOG.md b/rtic-monotonics/CHANGELOG.md index 89f401fdd6..816bc24783 100644 --- a/rtic-monotonics/CHANGELOG.md +++ b/rtic-monotonics/CHANGELOG.md @@ -16,5 +16,6 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top! ### Fixed - Unmask the `rp2040` interrupt +- Use `$crate` and fully qualified paths in macros ## [v1.0.0] - 2023-xx-xx From ef12ae6b04fa57371507e4ab49f49cb51c30ee4c Mon Sep 17 00:00:00 2001 From: Yandrik Date: Wed, 15 Mar 2023 20:17:26 +0100 Subject: [PATCH 6/6] refactor: re-formatted files --- rtic-monotonics/src/rp2040.rs | 11 +++-------- rtic-monotonics/src/systick.rs | 11 +++-------- rtic-sync/src/channel.rs | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/rtic-monotonics/src/rp2040.rs b/rtic-monotonics/src/rp2040.rs index f2cc7b64ab..6aa66ce0bc 100644 --- a/rtic-monotonics/src/rp2040.rs +++ b/rtic-monotonics/src/rp2040.rs @@ -139,8 +139,7 @@ impl embedded_hal_async::delay::DelayUs for Timer { /// Register the Timer interrupt for the monotonic. #[macro_export] macro_rules! make_rp2040_monotonic_handler { - () => { - { + () => {{ #[no_mangle] #[allow(non_snake_case)] unsafe extern "C" fn TIMER_IRQ_0() { @@ -149,12 +148,8 @@ macro_rules! make_rp2040_monotonic_handler { pub struct Rp2040Token; - unsafe impl $crate::InterruptToken<$crate::rp2040::Timer> - for Rp2040Token - { - } + unsafe impl $crate::InterruptToken<$crate::rp2040::Timer> for Rp2040Token {} Rp2040Token - } - }; + }}; } diff --git a/rtic-monotonics/src/systick.rs b/rtic-monotonics/src/systick.rs index a2817832a1..b228e204d5 100644 --- a/rtic-monotonics/src/systick.rs +++ b/rtic-monotonics/src/systick.rs @@ -157,8 +157,7 @@ impl embedded_hal_async::delay::DelayUs for Systick { /// Register the Systick interrupt for the monotonic. #[macro_export] macro_rules! make_systick_handler { - () => { - { + () => {{ #[no_mangle] #[allow(non_snake_case)] unsafe extern "C" fn SysTick() { @@ -167,12 +166,8 @@ macro_rules! make_systick_handler { pub struct SystickToken; - unsafe impl $crate::InterruptToken<$crate::systick::Systick> - for SystickToken - { - } + unsafe impl $crate::InterruptToken<$crate::systick::Systick> for SystickToken {} SystickToken - } - }; + }}; } diff --git a/rtic-sync/src/channel.rs b/rtic-sync/src/channel.rs index d0670c2df6..b7b5a485fa 100644 --- a/rtic-sync/src/channel.rs +++ b/rtic-sync/src/channel.rs @@ -103,7 +103,8 @@ impl Channel { #[macro_export] macro_rules! make_channel { ($type:path, $size:expr) => {{ - static mut CHANNEL: $crate::channel::Channel<$type, $size> = $crate::channel::Channel::new(); + static mut CHANNEL: $crate::channel::Channel<$type, $size> = + $crate::channel::Channel::new(); // SAFETY: This is safe as we hide the static mut from others to access it. // Only this point is where the mutable access happens. @@ -125,8 +126,8 @@ pub enum TrySendError { } impl core::fmt::Debug for NoReceiver - where - T: core::fmt::Debug, +where + T: core::fmt::Debug, { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "NoReceiver({:?})", self.0) @@ -134,8 +135,8 @@ impl core::fmt::Debug for NoReceiver } impl core::fmt::Debug for TrySendError - where - T: core::fmt::Debug, +where + T: core::fmt::Debug, { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { @@ -146,8 +147,8 @@ impl core::fmt::Debug for TrySendError } impl PartialEq for TrySendError - where - T: PartialEq, +where + T: PartialEq, { fn eq(&self, other: &Self) -> bool { match (self, other) { @@ -301,7 +302,7 @@ impl<'a, T, const N: usize> Sender<'a, T, N> { Poll::Pending } }) - .await; + .await; // Make sure the link is removed from the queue. drop(dropper); @@ -431,7 +432,7 @@ impl<'a, T, const N: usize> Receiver<'a, T, N> { Poll::Pending }) - .await + .await } /// Returns true if there are no `Sender`s.