diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-10-06 22:56:31 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-10-06 23:19:53 +0200 |
| commit | 8730a013c395cf0bf4c2fa8eeb7f138288103039 (patch) | |
| tree | 39eca5fbc4570bd0129c9a291f134de5dab98820 /embassy-executor/src | |
| parent | abc8e450f936567ad42cb34b5d2a7941b206aa5d (diff) | |
Rustfmt for edition 2024.
Diffstat (limited to 'embassy-executor/src')
| -rw-r--r-- | embassy-executor/src/arch/avr.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/arch/cortex_ar.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/arch/cortex_m.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/arch/riscv32.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/arch/spin.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/arch/std.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/arch/wasm.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/metadata.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/raw/run_queue.rs | 4 | ||||
| -rw-r--r-- | embassy-executor/src/raw/state_atomics_arm.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/raw/state_critical_section.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/raw/trace.rs | 6 | ||||
| -rw-r--r-- | embassy-executor/src/raw/waker.rs | 6 | ||||
| -rw-r--r-- | embassy-executor/src/raw/waker_turbo.rs | 2 | ||||
| -rw-r--r-- | embassy-executor/src/spawner.rs | 12 |
15 files changed, 27 insertions, 23 deletions
diff --git a/embassy-executor/src/arch/avr.rs b/embassy-executor/src/arch/avr.rs index 4a19c523a..a841afe15 100644 --- a/embassy-executor/src/arch/avr.rs +++ b/embassy-executor/src/arch/avr.rs | |||
| @@ -10,7 +10,7 @@ mod thread { | |||
| 10 | pub use embassy_executor_macros::main_avr as main; | 10 | pub use embassy_executor_macros::main_avr as main; |
| 11 | use portable_atomic::{AtomicBool, Ordering}; | 11 | use portable_atomic::{AtomicBool, Ordering}; |
| 12 | 12 | ||
| 13 | use crate::{raw, Spawner}; | 13 | use crate::{Spawner, raw}; |
| 14 | 14 | ||
| 15 | static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false); | 15 | static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false); |
| 16 | 16 | ||
diff --git a/embassy-executor/src/arch/cortex_ar.rs b/embassy-executor/src/arch/cortex_ar.rs index 36d45944a..a9be3d323 100644 --- a/embassy-executor/src/arch/cortex_ar.rs +++ b/embassy-executor/src/arch/cortex_ar.rs | |||
| @@ -26,7 +26,7 @@ mod thread { | |||
| 26 | use cortex_ar::asm::wfe; | 26 | use cortex_ar::asm::wfe; |
| 27 | pub use embassy_executor_macros::main_cortex_ar as main; | 27 | pub use embassy_executor_macros::main_cortex_ar as main; |
| 28 | 28 | ||
| 29 | use crate::{raw, Spawner}; | 29 | use crate::{Spawner, raw}; |
| 30 | 30 | ||
| 31 | /// Thread mode executor, using WFE/SEV. | 31 | /// Thread mode executor, using WFE/SEV. |
| 32 | /// | 32 | /// |
diff --git a/embassy-executor/src/arch/cortex_m.rs b/embassy-executor/src/arch/cortex_m.rs index 9f1081e93..1ce96d1d5 100644 --- a/embassy-executor/src/arch/cortex_m.rs +++ b/embassy-executor/src/arch/cortex_m.rs | |||
| @@ -53,7 +53,7 @@ mod thread { | |||
| 53 | 53 | ||
| 54 | pub use embassy_executor_macros::main_cortex_m as main; | 54 | pub use embassy_executor_macros::main_cortex_m as main; |
| 55 | 55 | ||
| 56 | use crate::{raw, Spawner}; | 56 | use crate::{Spawner, raw}; |
| 57 | 57 | ||
| 58 | /// Thread mode executor, using WFE/SEV. | 58 | /// Thread mode executor, using WFE/SEV. |
| 59 | /// | 59 | /// |
diff --git a/embassy-executor/src/arch/riscv32.rs b/embassy-executor/src/arch/riscv32.rs index 13b93cf02..c70c1344a 100644 --- a/embassy-executor/src/arch/riscv32.rs +++ b/embassy-executor/src/arch/riscv32.rs | |||
| @@ -10,7 +10,7 @@ mod thread { | |||
| 10 | 10 | ||
| 11 | pub use embassy_executor_macros::main_riscv as main; | 11 | pub use embassy_executor_macros::main_riscv as main; |
| 12 | 12 | ||
| 13 | use crate::{raw, Spawner}; | 13 | use crate::{Spawner, raw}; |
| 14 | 14 | ||
| 15 | /// global atomic used to keep track of whether there is work to do since sev() is not available on RISCV | 15 | /// global atomic used to keep track of whether there is work to do since sev() is not available on RISCV |
| 16 | static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false); | 16 | static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false); |
diff --git a/embassy-executor/src/arch/spin.rs b/embassy-executor/src/arch/spin.rs index 40cb56a09..49f3356a6 100644 --- a/embassy-executor/src/arch/spin.rs +++ b/embassy-executor/src/arch/spin.rs | |||
| @@ -9,7 +9,7 @@ mod thread { | |||
| 9 | 9 | ||
| 10 | pub use embassy_executor_macros::main_spin as main; | 10 | pub use embassy_executor_macros::main_spin as main; |
| 11 | 11 | ||
| 12 | use crate::{raw, Spawner}; | 12 | use crate::{Spawner, raw}; |
| 13 | 13 | ||
| 14 | #[unsafe(export_name = "__pender")] | 14 | #[unsafe(export_name = "__pender")] |
| 15 | fn __pender(_context: *mut ()) {} | 15 | fn __pender(_context: *mut ()) {} |
diff --git a/embassy-executor/src/arch/std.rs b/embassy-executor/src/arch/std.rs index cdb9f7642..c62ab723b 100644 --- a/embassy-executor/src/arch/std.rs +++ b/embassy-executor/src/arch/std.rs | |||
| @@ -10,7 +10,7 @@ mod thread { | |||
| 10 | 10 | ||
| 11 | pub use embassy_executor_macros::main_std as main; | 11 | pub use embassy_executor_macros::main_std as main; |
| 12 | 12 | ||
| 13 | use crate::{raw, Spawner}; | 13 | use crate::{Spawner, raw}; |
| 14 | 14 | ||
| 15 | #[unsafe(export_name = "__pender")] | 15 | #[unsafe(export_name = "__pender")] |
| 16 | fn __pender(context: *mut ()) { | 16 | fn __pender(context: *mut ()) { |
diff --git a/embassy-executor/src/arch/wasm.rs b/embassy-executor/src/arch/wasm.rs index 6b36f8a5b..d2ff2fe51 100644 --- a/embassy-executor/src/arch/wasm.rs +++ b/embassy-executor/src/arch/wasm.rs | |||
| @@ -13,7 +13,7 @@ mod thread { | |||
| 13 | use wasm_bindgen::prelude::*; | 13 | use wasm_bindgen::prelude::*; |
| 14 | 14 | ||
| 15 | use crate::raw::util::UninitCell; | 15 | use crate::raw::util::UninitCell; |
| 16 | use crate::{raw, Spawner}; | 16 | use crate::{Spawner, raw}; |
| 17 | 17 | ||
| 18 | #[unsafe(export_name = "__pender")] | 18 | #[unsafe(export_name = "__pender")] |
| 19 | fn __pender(context: *mut ()) { | 19 | fn __pender(context: *mut ()) { |
diff --git a/embassy-executor/src/metadata.rs b/embassy-executor/src/metadata.rs index bc0df0f83..76504ab0b 100644 --- a/embassy-executor/src/metadata.rs +++ b/embassy-executor/src/metadata.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #[cfg(feature = "metadata-name")] | 1 | #[cfg(feature = "metadata-name")] |
| 2 | use core::cell::Cell; | 2 | use core::cell::Cell; |
| 3 | use core::future::{poll_fn, Future}; | 3 | use core::future::{Future, poll_fn}; |
| 4 | #[cfg(feature = "scheduler-priority")] | 4 | #[cfg(feature = "scheduler-priority")] |
| 5 | use core::sync::atomic::{AtomicU8, Ordering}; | 5 | use core::sync::atomic::{AtomicU8, Ordering}; |
| 6 | use core::task::Poll; | 6 | use core::task::Poll; |
diff --git a/embassy-executor/src/raw/run_queue.rs b/embassy-executor/src/raw/run_queue.rs index b8b052310..6f2abdbd0 100644 --- a/embassy-executor/src/raw/run_queue.rs +++ b/embassy-executor/src/raw/run_queue.rs | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | use core::ptr::{addr_of_mut, NonNull}; | 1 | use core::ptr::{NonNull, addr_of_mut}; |
| 2 | 2 | ||
| 3 | use cordyceps::sorted_list::Links; | ||
| 4 | use cordyceps::Linked; | 3 | use cordyceps::Linked; |
| 5 | #[cfg(any(feature = "scheduler-priority", feature = "scheduler-deadline"))] | 4 | #[cfg(any(feature = "scheduler-priority", feature = "scheduler-deadline"))] |
| 6 | use cordyceps::SortedList; | 5 | use cordyceps::SortedList; |
| 6 | use cordyceps::sorted_list::Links; | ||
| 7 | 7 | ||
| 8 | #[cfg(target_has_atomic = "ptr")] | 8 | #[cfg(target_has_atomic = "ptr")] |
| 9 | type TransferStack<T> = cordyceps::TransferStack<T>; | 9 | type TransferStack<T> = cordyceps::TransferStack<T>; |
diff --git a/embassy-executor/src/raw/state_atomics_arm.rs b/embassy-executor/src/raw/state_atomics_arm.rs index b743dcc2c..f68de955f 100644 --- a/embassy-executor/src/raw/state_atomics_arm.rs +++ b/embassy-executor/src/raw/state_atomics_arm.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use core::sync::atomic::{compiler_fence, AtomicBool, AtomicU32, Ordering}; | 1 | use core::sync::atomic::{AtomicBool, AtomicU32, Ordering, compiler_fence}; |
| 2 | 2 | ||
| 3 | #[derive(Clone, Copy)] | 3 | #[derive(Clone, Copy)] |
| 4 | pub(crate) struct Token(()); | 4 | pub(crate) struct Token(()); |
diff --git a/embassy-executor/src/raw/state_critical_section.rs b/embassy-executor/src/raw/state_critical_section.rs index b69a6ac66..8d7ef2892 100644 --- a/embassy-executor/src/raw/state_critical_section.rs +++ b/embassy-executor/src/raw/state_critical_section.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | use core::cell::Cell; | 1 | use core::cell::Cell; |
| 2 | 2 | ||
| 3 | pub(crate) use critical_section::{with as locked, CriticalSection as Token}; | ||
| 4 | use critical_section::{CriticalSection, Mutex}; | 3 | use critical_section::{CriticalSection, Mutex}; |
| 4 | pub(crate) use critical_section::{CriticalSection as Token, with as locked}; | ||
| 5 | 5 | ||
| 6 | #[cfg(target_arch = "avr")] | 6 | #[cfg(target_arch = "avr")] |
| 7 | type StateBits = u8; | 7 | type StateBits = u8; |
diff --git a/embassy-executor/src/raw/trace.rs b/embassy-executor/src/raw/trace.rs index b3086948c..74519b927 100644 --- a/embassy-executor/src/raw/trace.rs +++ b/embassy-executor/src/raw/trace.rs | |||
| @@ -368,11 +368,7 @@ impl rtos_trace::RtosTraceOSCallbacks for crate::raw::SyncExecutor { | |||
| 368 | } | 368 | } |
| 369 | fn time() -> u64 { | 369 | fn time() -> u64 { |
| 370 | const fn gcd(a: u64, b: u64) -> u64 { | 370 | const fn gcd(a: u64, b: u64) -> u64 { |
| 371 | if b == 0 { | 371 | if b == 0 { a } else { gcd(b, a % b) } |
| 372 | a | ||
| 373 | } else { | ||
| 374 | gcd(b, a % b) | ||
| 375 | } | ||
| 376 | } | 372 | } |
| 377 | 373 | ||
| 378 | const GCD_1M: u64 = gcd(embassy_time_driver::TICK_HZ, 1_000_000); | 374 | const GCD_1M: u64 = gcd(embassy_time_driver::TICK_HZ, 1_000_000); |
diff --git a/embassy-executor/src/raw/waker.rs b/embassy-executor/src/raw/waker.rs index d0d7b003d..2706f0fdf 100644 --- a/embassy-executor/src/raw/waker.rs +++ b/embassy-executor/src/raw/waker.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use core::task::{RawWaker, RawWakerVTable, Waker}; | 1 | use core::task::{RawWaker, RawWakerVTable, Waker}; |
| 2 | 2 | ||
| 3 | use super::{wake_task, TaskHeader, TaskRef}; | 3 | use super::{TaskHeader, TaskRef, wake_task}; |
| 4 | 4 | ||
| 5 | static VTABLE: RawWakerVTable = RawWakerVTable::new(clone, wake, wake, drop); | 5 | static VTABLE: RawWakerVTable = RawWakerVTable::new(clone, wake, wake, drop); |
| 6 | 6 | ||
| @@ -35,7 +35,9 @@ pub fn task_from_waker(waker: &Waker) -> TaskRef { | |||
| 35 | // make sure to compare vtable addresses. Doing `==` on the references | 35 | // make sure to compare vtable addresses. Doing `==` on the references |
| 36 | // will compare the contents, which is slower. | 36 | // will compare the contents, which is slower. |
| 37 | if waker.vtable() as *const _ != &VTABLE as *const _ { | 37 | if waker.vtable() as *const _ != &VTABLE as *const _ { |
| 38 | panic!("Found waker not created by the Embassy executor. `embassy_time::Timer` only works with the Embassy executor.") | 38 | panic!( |
| 39 | "Found waker not created by the Embassy executor. `embassy_time::Timer` only works with the Embassy executor." | ||
| 40 | ) | ||
| 39 | } | 41 | } |
| 40 | // safety: our wakers are always created with `TaskRef::as_ptr` | 42 | // safety: our wakers are always created with `TaskRef::as_ptr` |
| 41 | unsafe { TaskRef::from_ptr(waker.data() as *const TaskHeader) } | 43 | unsafe { TaskRef::from_ptr(waker.data() as *const TaskHeader) } |
diff --git a/embassy-executor/src/raw/waker_turbo.rs b/embassy-executor/src/raw/waker_turbo.rs index 9d0ad35ec..919bcc61a 100644 --- a/embassy-executor/src/raw/waker_turbo.rs +++ b/embassy-executor/src/raw/waker_turbo.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | use core::ptr::NonNull; | 1 | use core::ptr::NonNull; |
| 2 | use core::task::Waker; | 2 | use core::task::Waker; |
| 3 | 3 | ||
| 4 | use super::{wake_task, TaskHeader, TaskRef}; | 4 | use super::{TaskHeader, TaskRef, wake_task}; |
| 5 | 5 | ||
| 6 | pub(crate) unsafe fn from_task(p: TaskRef) -> Waker { | 6 | pub(crate) unsafe fn from_task(p: TaskRef) -> Waker { |
| 7 | Waker::from_turbo_ptr(NonNull::new_unchecked(p.as_ptr() as _)) | 7 | Waker::from_turbo_ptr(NonNull::new_unchecked(p.as_ptr() as _)) |
diff --git a/embassy-executor/src/spawner.rs b/embassy-executor/src/spawner.rs index 83d896b76..b73a1e7c6 100644 --- a/embassy-executor/src/spawner.rs +++ b/embassy-executor/src/spawner.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use core::future::{poll_fn, Future}; | 1 | use core::future::{Future, poll_fn}; |
| 2 | use core::marker::PhantomData; | 2 | use core::marker::PhantomData; |
| 3 | use core::mem; | 3 | use core::mem; |
| 4 | use core::sync::atomic::Ordering; | 4 | use core::sync::atomic::Ordering; |
| @@ -75,7 +75,10 @@ impl core::fmt::Debug for SpawnError { | |||
| 75 | impl core::fmt::Display for SpawnError { | 75 | impl core::fmt::Display for SpawnError { |
| 76 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | 76 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { |
| 77 | match self { | 77 | match self { |
| 78 | SpawnError::Busy => write!(f, "Busy - Too many instances of this task are already running. Check the `pool_size` attribute of the task."), | 78 | SpawnError::Busy => write!( |
| 79 | f, | ||
| 80 | "Busy - Too many instances of this task are already running. Check the `pool_size` attribute of the task." | ||
| 81 | ), | ||
| 79 | } | 82 | } |
| 80 | } | 83 | } |
| 81 | } | 84 | } |
| @@ -84,7 +87,10 @@ impl core::fmt::Display for SpawnError { | |||
| 84 | impl defmt::Format for SpawnError { | 87 | impl defmt::Format for SpawnError { |
| 85 | fn format(&self, f: defmt::Formatter) { | 88 | fn format(&self, f: defmt::Formatter) { |
| 86 | match self { | 89 | match self { |
| 87 | SpawnError::Busy => defmt::write!(f, "Busy - Too many instances of this task are already running. Check the `pool_size` attribute of the task."), | 90 | SpawnError::Busy => defmt::write!( |
| 91 | f, | ||
| 92 | "Busy - Too many instances of this task are already running. Check the `pool_size` attribute of the task." | ||
| 93 | ), | ||
| 88 | } | 94 | } |
| 89 | } | 95 | } |
| 90 | } | 96 | } |
