diff options
| author | Dániel Buga <[email protected]> | 2023-08-14 15:59:47 +0200 |
|---|---|---|
| committer | Dániel Buga <[email protected]> | 2023-08-14 16:04:11 +0200 |
| commit | 995434614384bc5c218a16a026ce7c06737ca860 (patch) | |
| tree | 961131c33677aad1ec1ff33daf69b716d104ef10 /embassy-executor/src/arch | |
| parent | 3a51e2d9cae6fad2fd903c07634b4a66de59b3bf (diff) | |
Remove interrupt executor, remove PenderContext
Diffstat (limited to 'embassy-executor/src/arch')
| -rw-r--r-- | embassy-executor/src/arch/cortex_m.rs | 9 | ||||
| -rw-r--r-- | embassy-executor/src/arch/riscv32.rs | 4 | ||||
| -rw-r--r-- | embassy-executor/src/arch/std.rs | 6 | ||||
| -rw-r--r-- | embassy-executor/src/arch/wasm.rs | 7 | ||||
| -rw-r--r-- | embassy-executor/src/arch/xtensa.rs | 4 |
5 files changed, 14 insertions, 16 deletions
diff --git a/embassy-executor/src/arch/cortex_m.rs b/embassy-executor/src/arch/cortex_m.rs index 2ed70dd1e..8fe5644d7 100644 --- a/embassy-executor/src/arch/cortex_m.rs +++ b/embassy-executor/src/arch/cortex_m.rs | |||
| @@ -2,12 +2,12 @@ const THREAD_PENDER: usize = usize::MAX; | |||
| 2 | 2 | ||
| 3 | #[export_name = "__pender"] | 3 | #[export_name = "__pender"] |
| 4 | #[cfg(any(feature = "executor-thread", feature = "executor-interrupt"))] | 4 | #[cfg(any(feature = "executor-thread", feature = "executor-interrupt"))] |
| 5 | fn __pender(context: crate::raw::PenderContext) { | 5 | fn __pender(context: *mut ()) { |
| 6 | unsafe { | 6 | unsafe { |
| 7 | // Safety: `context` is either `usize::MAX` created by `Executor::run`, or a valid interrupt | 7 | // Safety: `context` is either `usize::MAX` created by `Executor::run`, or a valid interrupt |
| 8 | // request number given to `InterruptExecutor::start`. | 8 | // request number given to `InterruptExecutor::start`. |
| 9 | 9 | ||
| 10 | let context: usize = core::mem::transmute(context); | 10 | let context = context as usize; |
| 11 | 11 | ||
| 12 | #[cfg(feature = "executor-thread")] | 12 | #[cfg(feature = "executor-thread")] |
| 13 | if context == THREAD_PENDER { | 13 | if context == THREAD_PENDER { |
| @@ -75,7 +75,7 @@ mod thread { | |||
| 75 | /// Create a new Executor. | 75 | /// Create a new Executor. |
| 76 | pub fn new() -> Self { | 76 | pub fn new() -> Self { |
| 77 | Self { | 77 | Self { |
| 78 | inner: raw::Executor::new(unsafe { core::mem::transmute(THREAD_PENDER) }), | 78 | inner: raw::Executor::new(THREAD_PENDER as *mut ()), |
| 79 | not_send: PhantomData, | 79 | not_send: PhantomData, |
| 80 | } | 80 | } |
| 81 | } | 81 | } |
| @@ -205,10 +205,9 @@ mod interrupt { | |||
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | unsafe { | 207 | unsafe { |
| 208 | let context = core::mem::transmute(irq.number() as usize); | ||
| 209 | (&mut *self.executor.get()) | 208 | (&mut *self.executor.get()) |
| 210 | .as_mut_ptr() | 209 | .as_mut_ptr() |
| 211 | .write(raw::Executor::new(context)) | 210 | .write(raw::Executor::new(irq.number() as *mut ())) |
| 212 | } | 211 | } |
| 213 | 212 | ||
| 214 | let executor = unsafe { (&*self.executor.get()).assume_init_ref() }; | 213 | let executor = unsafe { (&*self.executor.get()).assume_init_ref() }; |
diff --git a/embassy-executor/src/arch/riscv32.rs b/embassy-executor/src/arch/riscv32.rs index 551d7527f..ce78bc258 100644 --- a/embassy-executor/src/arch/riscv32.rs +++ b/embassy-executor/src/arch/riscv32.rs | |||
| @@ -17,7 +17,7 @@ mod thread { | |||
| 17 | static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false); | 17 | static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false); |
| 18 | 18 | ||
| 19 | #[export_name = "__pender"] | 19 | #[export_name = "__pender"] |
| 20 | fn __thread_mode_pender(_context: crate::raw::PenderContext) { | 20 | fn __thread_mode_pender(_context: *mut ()) { |
| 21 | SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst); | 21 | SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| @@ -31,7 +31,7 @@ mod thread { | |||
| 31 | /// Create a new Executor. | 31 | /// Create a new Executor. |
| 32 | pub fn new() -> Self { | 32 | pub fn new() -> Self { |
| 33 | Self { | 33 | Self { |
| 34 | inner: raw::Executor::new(unsafe { core::mem::transmute(0) }), | 34 | inner: raw::Executor::new(core::ptr::null_mut()), |
| 35 | not_send: PhantomData, | 35 | not_send: PhantomData, |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
diff --git a/embassy-executor/src/arch/std.rs b/embassy-executor/src/arch/std.rs index f490084d6..5b2f7e2e4 100644 --- a/embassy-executor/src/arch/std.rs +++ b/embassy-executor/src/arch/std.rs | |||
| @@ -14,7 +14,7 @@ mod thread { | |||
| 14 | use crate::{raw, Spawner}; | 14 | use crate::{raw, Spawner}; |
| 15 | 15 | ||
| 16 | #[export_name = "__pender"] | 16 | #[export_name = "__pender"] |
| 17 | fn __pender(context: crate::raw::PenderContext) { | 17 | fn __pender(context: *mut ()) { |
| 18 | let signaler: &'static Signaler = unsafe { std::mem::transmute(context) }; | 18 | let signaler: &'static Signaler = unsafe { std::mem::transmute(context) }; |
| 19 | signaler.signal() | 19 | signaler.signal() |
| 20 | } | 20 | } |
| @@ -29,9 +29,9 @@ mod thread { | |||
| 29 | impl Executor { | 29 | impl Executor { |
| 30 | /// Create a new Executor. | 30 | /// Create a new Executor. |
| 31 | pub fn new() -> Self { | 31 | pub fn new() -> Self { |
| 32 | let signaler = &*Box::leak(Box::new(Signaler::new())); | 32 | let signaler = Box::leak(Box::new(Signaler::new())); |
| 33 | Self { | 33 | Self { |
| 34 | inner: raw::Executor::new(unsafe { std::mem::transmute(signaler) }), | 34 | inner: raw::Executor::new(signaler as *mut Signaler as *mut ()), |
| 35 | not_send: PhantomData, | 35 | not_send: PhantomData, |
| 36 | signaler, | 36 | signaler, |
| 37 | } | 37 | } |
diff --git a/embassy-executor/src/arch/wasm.rs b/embassy-executor/src/arch/wasm.rs index 452c3e394..5f9b2e705 100644 --- a/embassy-executor/src/arch/wasm.rs +++ b/embassy-executor/src/arch/wasm.rs | |||
| @@ -14,11 +14,10 @@ mod thread { | |||
| 14 | use wasm_bindgen::prelude::*; | 14 | use wasm_bindgen::prelude::*; |
| 15 | 15 | ||
| 16 | use crate::raw::util::UninitCell; | 16 | use crate::raw::util::UninitCell; |
| 17 | use crate::raw::PenderContext; | ||
| 18 | use crate::{raw, Spawner}; | 17 | use crate::{raw, Spawner}; |
| 19 | 18 | ||
| 20 | #[export_name = "__thread_mode_pender"] | 19 | #[export_name = "__thread_mode_pender"] |
| 21 | fn __thread_mode_pender(context: PenderContext) { | 20 | fn __thread_mode_pender(context: *mut ()) { |
| 22 | let signaler: &'static WasmContext = unsafe { std::mem::transmute(context) }; | 21 | let signaler: &'static WasmContext = unsafe { std::mem::transmute(context) }; |
| 23 | let _ = signaler.promise.then(unsafe { signaler.closure.as_mut() }); | 22 | let _ = signaler.promise.then(unsafe { signaler.closure.as_mut() }); |
| 24 | } | 23 | } |
| @@ -47,9 +46,9 @@ mod thread { | |||
| 47 | impl Executor { | 46 | impl Executor { |
| 48 | /// Create a new Executor. | 47 | /// Create a new Executor. |
| 49 | pub fn new() -> Self { | 48 | pub fn new() -> Self { |
| 50 | let ctx = &*Box::leak(Box::new(WasmContext::new())); | 49 | let ctx = Box::leak(Box::new(WasmContext::new())); |
| 51 | Self { | 50 | Self { |
| 52 | inner: raw::Executor::new(unsafe { core::mem::transmute(ctx) }), | 51 | inner: raw::Executor::new(ctx as *mut WasmContext as *mut ()), |
| 53 | ctx, | 52 | ctx, |
| 54 | not_send: PhantomData, | 53 | not_send: PhantomData, |
| 55 | } | 54 | } |
diff --git a/embassy-executor/src/arch/xtensa.rs b/embassy-executor/src/arch/xtensa.rs index 8665a9cb6..66b3351c5 100644 --- a/embassy-executor/src/arch/xtensa.rs +++ b/embassy-executor/src/arch/xtensa.rs | |||
| @@ -14,7 +14,7 @@ mod thread { | |||
| 14 | static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false); | 14 | static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false); |
| 15 | 15 | ||
| 16 | #[export_name = "__thread_mode_pender"] | 16 | #[export_name = "__thread_mode_pender"] |
| 17 | fn __thread_mode_pender(_context: crate::raw::PenderContext) { | 17 | fn __thread_mode_pender(_context: *mut ()) { |
| 18 | SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst); | 18 | SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| @@ -28,7 +28,7 @@ mod thread { | |||
| 28 | /// Create a new Executor. | 28 | /// Create a new Executor. |
| 29 | pub fn new() -> Self { | 29 | pub fn new() -> Self { |
| 30 | Self { | 30 | Self { |
| 31 | inner: raw::Executor::new(unsafe { core::mem::transmute(0) }), | 31 | inner: raw::Executor::new(core::ptr::null_mut()), |
| 32 | not_send: PhantomData, | 32 | not_send: PhantomData, |
| 33 | } | 33 | } |
| 34 | } | 34 | } |
