diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-12-17 13:06:31 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-12-17 13:06:31 +0100 |
| commit | fc25fca00b48630073575d14bcc713912d0b0104 (patch) | |
| tree | f9585a72940a2f39d53f49e73eddf6eb8e35178e /embassy-executor/src | |
| parent | d3f0294fb12e060c4a3ba557ff95766d1c3686e0 (diff) | |
Remove WakerHack for good.
Now that 1.83 xtensa is out, we can remove it unconditionally.
Diffstat (limited to 'embassy-executor/src')
| -rw-r--r-- | embassy-executor/src/raw/waker.rs | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/embassy-executor/src/raw/waker.rs b/embassy-executor/src/raw/waker.rs index 9c70f995a..b7d57c314 100644 --- a/embassy-executor/src/raw/waker.rs +++ b/embassy-executor/src/raw/waker.rs | |||
| @@ -32,22 +32,11 @@ pub(crate) unsafe fn from_task(p: TaskRef) -> Waker { | |||
| 32 | /// | 32 | /// |
| 33 | /// Panics if the waker is not created by the Embassy executor. | 33 | /// Panics if the waker is not created by the Embassy executor. |
| 34 | pub fn task_from_waker(waker: &Waker) -> TaskRef { | 34 | pub fn task_from_waker(waker: &Waker) -> TaskRef { |
| 35 | struct WakerHack { | ||
| 36 | data: *const (), | ||
| 37 | vtable: &'static RawWakerVTable, | ||
| 38 | } | ||
| 39 | |||
| 40 | // safety: OK because WakerHack has the same layout as Waker. | ||
| 41 | // This is not really guaranteed because the structs are `repr(Rust)`, it is | ||
| 42 | // indeed the case in the current implementation. | ||
| 43 | // TODO use waker_getters when stable. https://github.com/rust-lang/rust/issues/96992 | ||
| 44 | let hack: &WakerHack = unsafe { core::mem::transmute(waker) }; | ||
| 45 | |||
| 46 | // make sure to compare vtable addresses. Doing `==` on the references | 35 | // make sure to compare vtable addresses. Doing `==` on the references |
| 47 | // will compare the contents, which is slower. | 36 | // will compare the contents, which is slower. |
| 48 | if hack.vtable as *const _ != &VTABLE as *const _ { | 37 | if waker.vtable() as *const _ != &VTABLE as *const _ { |
| 49 | panic!("Found waker not created by the Embassy executor. `embassy_time::Timer` only works with the Embassy executor.") | 38 | panic!("Found waker not created by the Embassy executor. `embassy_time::Timer` only works with the Embassy executor.") |
| 50 | } | 39 | } |
| 51 | // safety: our wakers are always created with `TaskRef::as_ptr` | 40 | // safety: our wakers are always created with `TaskRef::as_ptr` |
| 52 | unsafe { TaskRef::from_ptr(hack.data as *const TaskHeader) } | 41 | unsafe { TaskRef::from_ptr(waker.data() as *const TaskHeader) } |
| 53 | } | 42 | } |
