aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2019-06-24 14:09:12 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2019-06-24 14:09:12 +0200
commit596cf585ea8dc278d88e0652dffbacbc75de04c6 (patch)
tree147bad178f15a7e7a91d847f39d501ecc1051821 /macros/src/codegen
parent4e51bb68b976c6bb6a9a989dc560d2a8123a84ca (diff)
downloadrtic-596cf585ea8dc278d88e0652dffbacbc75de04c6.tar.gz
rtic-596cf585ea8dc278d88e0652dffbacbc75de04c6.tar.zst
rtic-596cf585ea8dc278d88e0652dffbacbc75de04c6.zip
Monotonic trait is safe; add MultiCore trait
Diffstat (limited to 'macros/src/codegen')
-rw-r--r--macros/src/codegen/assertions.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/macros/src/codegen/assertions.rs b/macros/src/codegen/assertions.rs
index 95268a2c..4a77352f 100644
--- a/macros/src/codegen/assertions.rs
+++ b/macros/src/codegen/assertions.rs
@@ -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
}