aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/raw
diff options
context:
space:
mode:
authorRaul Alimbekov <[email protected]>2025-12-16 09:05:22 +0300
committerGitHub <[email protected]>2025-12-16 09:05:22 +0300
commitc9a04b4b732b7a3b696eb8223664c1a7942b1875 (patch)
tree6dbe5c02e66eed8d8762f13f95afd24f8db2b38c /embassy-executor/src/raw
parentcde24a3ef1117653ba5ed4184102b33f745782fb (diff)
parent5ae6e060ec1c90561719aabdc29d5b6e7b8b0a82 (diff)
Merge branch 'main' into main
Diffstat (limited to 'embassy-executor/src/raw')
-rw-r--r--embassy-executor/src/raw/mod.rs6
-rw-r--r--embassy-executor/src/raw/run_queue.rs4
-rw-r--r--embassy-executor/src/raw/state_atomics_arm.rs2
-rw-r--r--embassy-executor/src/raw/state_critical_section.rs2
-rw-r--r--embassy-executor/src/raw/trace.rs8
-rw-r--r--embassy-executor/src/raw/waker.rs6
-rw-r--r--embassy-executor/src/raw/waker_turbo.rs4
7 files changed, 15 insertions, 17 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs
index dbd70cbf4..ab845ed3b 100644
--- a/embassy-executor/src/raw/mod.rs
+++ b/embassy-executor/src/raw/mod.rs
@@ -52,7 +52,7 @@ pub use self::waker::task_from_waker;
52use super::SpawnToken; 52use super::SpawnToken;
53use crate::{Metadata, SpawnError}; 53use crate::{Metadata, SpawnError};
54 54
55#[no_mangle] 55#[unsafe(no_mangle)]
56extern "Rust" fn __embassy_time_queue_item_from_waker(waker: &Waker) -> &'static mut TimerQueueItem { 56extern "Rust" fn __embassy_time_queue_item_from_waker(waker: &Waker) -> &'static mut TimerQueueItem {
57 unsafe { task_from_waker(waker).timer_queue_item() } 57 unsafe { task_from_waker(waker).timer_queue_item() }
58} 58}
@@ -407,7 +407,7 @@ unsafe impl Sync for Pender {}
407 407
408impl Pender { 408impl Pender {
409 pub(crate) fn pend(self) { 409 pub(crate) fn pend(self) {
410 extern "Rust" { 410 unsafe extern "Rust" {
411 fn __pender(context: *mut ()); 411 fn __pender(context: *mut ());
412 } 412 }
413 unsafe { __pender(self.0) }; 413 unsafe { __pender(self.0) };
@@ -507,7 +507,7 @@ impl SyncExecutor {
507/// The pender function must be exported with the name `__pender` and have the following signature: 507/// The pender function must be exported with the name `__pender` and have the following signature:
508/// 508///
509/// ```rust 509/// ```rust
510/// #[export_name = "__pender"] 510/// #[unsafe(export_name = "__pender")]
511/// fn pender(context: *mut ()) { 511/// fn pender(context: *mut ()) {
512/// // schedule `poll()` to be called 512/// // schedule `poll()` to be called
513/// } 513/// }
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 @@
1use core::ptr::{addr_of_mut, NonNull}; 1use core::ptr::{NonNull, addr_of_mut};
2 2
3use cordyceps::sorted_list::Links;
4use cordyceps::Linked; 3use cordyceps::Linked;
5#[cfg(any(feature = "scheduler-priority", feature = "scheduler-deadline"))] 4#[cfg(any(feature = "scheduler-priority", feature = "scheduler-deadline"))]
6use cordyceps::SortedList; 5use cordyceps::SortedList;
6use cordyceps::sorted_list::Links;
7 7
8#[cfg(target_has_atomic = "ptr")] 8#[cfg(target_has_atomic = "ptr")]
9type TransferStack<T> = cordyceps::TransferStack<T>; 9type 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 @@
1use core::sync::atomic::{compiler_fence, AtomicBool, AtomicU32, Ordering}; 1use core::sync::atomic::{AtomicBool, AtomicU32, Ordering, compiler_fence};
2 2
3#[derive(Clone, Copy)] 3#[derive(Clone, Copy)]
4pub(crate) struct Token(()); 4pub(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 @@
1use core::cell::Cell; 1use core::cell::Cell;
2 2
3pub(crate) use critical_section::{with as locked, CriticalSection as Token};
4use critical_section::{CriticalSection, Mutex}; 3use critical_section::{CriticalSection, Mutex};
4pub(crate) use critical_section::{CriticalSection as Token, with as locked};
5 5
6#[cfg(target_arch = "avr")] 6#[cfg(target_arch = "avr")]
7type StateBits = u8; 7type StateBits = u8;
diff --git a/embassy-executor/src/raw/trace.rs b/embassy-executor/src/raw/trace.rs
index b3086948c..830162039 100644
--- a/embassy-executor/src/raw/trace.rs
+++ b/embassy-executor/src/raw/trace.rs
@@ -169,7 +169,7 @@ impl TaskTracker {
169} 169}
170 170
171#[cfg(feature = "trace")] 171#[cfg(feature = "trace")]
172extern "Rust" { 172unsafe extern "Rust" {
173 /// This callback is called when the executor begins polling. This will always 173 /// This callback is called when the executor begins polling. This will always
174 /// be paired with a later call to `_embassy_trace_executor_idle`. 174 /// be paired with a later call to `_embassy_trace_executor_idle`.
175 /// 175 ///
@@ -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 @@
1use core::task::{RawWaker, RawWakerVTable, Waker}; 1use core::task::{RawWaker, RawWakerVTable, Waker};
2 2
3use super::{wake_task, TaskHeader, TaskRef}; 3use super::{TaskHeader, TaskRef, wake_task};
4 4
5static VTABLE: RawWakerVTable = RawWakerVTable::new(clone, wake, wake, drop); 5static 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 435a0ff7e..919bcc61a 100644
--- a/embassy-executor/src/raw/waker_turbo.rs
+++ b/embassy-executor/src/raw/waker_turbo.rs
@@ -1,7 +1,7 @@
1use core::ptr::NonNull; 1use core::ptr::NonNull;
2use core::task::Waker; 2use core::task::Waker;
3 3
4use super::{wake_task, TaskHeader, TaskRef}; 4use super::{TaskHeader, TaskRef, wake_task};
5 5
6pub(crate) unsafe fn from_task(p: TaskRef) -> Waker { 6pub(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 _))
@@ -26,7 +26,7 @@ pub fn task_from_waker(waker: &Waker) -> TaskRef {
26} 26}
27 27
28#[inline(never)] 28#[inline(never)]
29#[no_mangle] 29#[unsafe(no_mangle)]
30fn _turbo_wake(ptr: NonNull<()>) { 30fn _turbo_wake(ptr: NonNull<()>) {
31 // safety: our wakers are always created with `TaskRef::as_ptr` 31 // safety: our wakers are always created with `TaskRef::as_ptr`
32 let task = unsafe { TaskRef::from_ptr(ptr.as_ptr() as *const TaskHeader) }; 32 let task = unsafe { TaskRef::from_ptr(ptr.as_ptr() as *const TaskHeader) };