mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
Fixed UB in spawn_at
This commit is contained in:
parent
2068eae928
commit
51500a1d70
4 changed files with 11 additions and 17 deletions
|
@ -1,4 +1,4 @@
|
||||||
//! examples/smallest.rs
|
//! examples/type-usage.rs
|
||||||
|
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
|
@ -22,6 +22,4 @@ proc-macro2 = "1"
|
||||||
proc-macro-error = "1"
|
proc-macro-error = "1"
|
||||||
quote = "1"
|
quote = "1"
|
||||||
syn = "1"
|
syn = "1"
|
||||||
# rtic-syntax = "0.5.0-alpha.2"
|
rtic-syntax = "0.5.0-alpha.2"
|
||||||
rtic-syntax = { path = "../../rtic-syntax", version = "0.5.0-alpha.2" }
|
|
||||||
|
|
||||||
|
|
|
@ -414,17 +414,11 @@ pub fn codegen(
|
||||||
|
|
||||||
let tq = unsafe { &mut *#app_path::#tq.as_mut_ptr() };
|
let tq = unsafe { &mut *#app_path::#tq.as_mut_ptr() };
|
||||||
|
|
||||||
if let Some(mono) = #app_path::#m_ident.as_mut() {
|
tq.enqueue_unchecked(
|
||||||
tq.enqueue_unchecked(
|
nr,
|
||||||
nr,
|
|| #enable_interrupt,
|
||||||
|| #enable_interrupt,
|
|| #pend,
|
||||||
|| #pend,
|
#app_path::#m_ident.as_mut());
|
||||||
mono)
|
|
||||||
} else {
|
|
||||||
// We can only use the timer queue if `init` has returned, and it
|
|
||||||
// writes the `Some(monotonic)` we are accessing here.
|
|
||||||
core::hint::unreachable_unchecked()
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(SpawnHandle { marker })
|
Ok(SpawnHandle { marker })
|
||||||
})
|
})
|
||||||
|
|
|
@ -42,7 +42,7 @@ where
|
||||||
nr: NotReady<Mono, Task>,
|
nr: NotReady<Mono, Task>,
|
||||||
enable_interrupt: F1,
|
enable_interrupt: F1,
|
||||||
pend_handler: F2,
|
pend_handler: F2,
|
||||||
mono: &mut Mono,
|
mono: Option<&mut Mono>,
|
||||||
) where
|
) where
|
||||||
F1: FnOnce(),
|
F1: FnOnce(),
|
||||||
F2: FnOnce(),
|
F2: FnOnce(),
|
||||||
|
@ -57,7 +57,9 @@ where
|
||||||
|
|
||||||
if if_heap_max_greater_than_nr {
|
if if_heap_max_greater_than_nr {
|
||||||
if Mono::DISABLE_INTERRUPT_ON_EMPTY_QUEUE && self.0.is_empty() {
|
if Mono::DISABLE_INTERRUPT_ON_EMPTY_QUEUE && self.0.is_empty() {
|
||||||
mono.enable_timer();
|
if let Some(mono) = mono {
|
||||||
|
mono.enable_timer();
|
||||||
|
}
|
||||||
enable_interrupt();
|
enable_interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue