mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-16 21:05:35 +01:00
Monotonic trait is safe; add MultiCore trait
This commit is contained in:
parent
4e51bb68b9
commit
596cf585ea
7 changed files with 35 additions and 9 deletions
|
|
@ -32,7 +32,7 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
|||
|
||||
// generate a `main` function for each core
|
||||
for core in 0..app.args.cores {
|
||||
let assertion_stmts = assertions::codegen(core, analysis);
|
||||
let assertion_stmts = assertions::codegen(core, analysis, extra);
|
||||
|
||||
let (const_app_pre_init, pre_init_stmts) = pre_init::codegen(core, &app, analysis, extra);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::quote;
|
||||
|
||||
use crate::analyze::Analysis;
|
||||
use crate::{analyze::Analysis, check::Extra};
|
||||
|
||||
/// Generates compile-time assertions that check that types implement the `Send` / `Sync` traits
|
||||
pub fn codegen(core: u8, analysis: &Analysis) -> Vec<TokenStream2> {
|
||||
pub fn codegen(core: u8, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream2> {
|
||||
let mut stmts = vec![];
|
||||
|
||||
// we don't generate *all* assertions on all cores because the user could conditionally import a
|
||||
|
|
@ -22,5 +22,12 @@ pub fn codegen(core: u8, analysis: &Analysis) -> Vec<TokenStream2> {
|
|||
}
|
||||
}
|
||||
|
||||
// if the `schedule` API is used in more than one core then we need to check that the
|
||||
// `monotonic` timer can be used in multi-core context
|
||||
if analysis.timer_queues.len() > 1 && analysis.timer_queues.contains_key(&core) {
|
||||
let monotonic = extra.monotonic();
|
||||
stmts.push(quote!(rtfm::export::assert_multicore::<#monotonic>();));
|
||||
}
|
||||
|
||||
stmts
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue