aboutsummaryrefslogtreecommitdiff
path: root/rtic-macros/src/codegen/assertions.rs
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2023-02-11 08:55:19 +0100
committerGravatar Henrik Tjäder <henrik@tjaders.com> 2023-03-01 00:35:20 +0100
commit60f0342b697cdddbab9c0e8c6d772bc7aab9de38 (patch)
tree5bbb73e299f416f4c10adf329704b734379caa41 /rtic-macros/src/codegen/assertions.rs
parent1cda61fbda205920517f7b63af90c97c38ff9af6 (diff)
downloadrtic-60f0342b697cdddbab9c0e8c6d772bc7aab9de38.tar.gz
rtic-60f0342b697cdddbab9c0e8c6d772bc7aab9de38.tar.zst
rtic-60f0342b697cdddbab9c0e8c6d772bc7aab9de38.zip
Break out core specific codegen to bindings
Diffstat (limited to 'rtic-macros/src/codegen/assertions.rs')
-rw-r--r--rtic-macros/src/codegen/assertions.rs36
1 files changed, 3 insertions, 33 deletions
diff --git a/rtic-macros/src/codegen/assertions.rs b/rtic-macros/src/codegen/assertions.rs
index dd94aa6d..2f5dd523 100644
--- a/rtic-macros/src/codegen/assertions.rs
+++ b/rtic-macros/src/codegen/assertions.rs
@@ -1,8 +1,9 @@
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
+use super::bindings::extra_assertions;
+use crate::analyze::Analysis;
use crate::syntax::ast::App;
-use crate::{analyze::Analysis, codegen::util};
/// Generates compile-time assertions that check that types implement the `Send` / `Sync` traits
pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
@@ -16,38 +17,7 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
stmts.push(quote!(rtic::export::assert_sync::<#ty>();));
}
- let device = &app.args.device;
- let chunks_name = util::priority_mask_chunks_ident();
- let no_basepri_checks: Vec<_> = app
- .hardware_tasks
- .iter()
- .filter_map(|(_, task)| {
- if !util::is_exception(&task.args.binds) {
- let interrupt_name = &task.args.binds;
- Some(quote!(
- if (#device::Interrupt::#interrupt_name as usize) >= (#chunks_name * 32) {
- ::core::panic!("An interrupt out of range is used while in armv6 or armv8m.base");
- }
- ))
- } else {
- None
- }
- })
- .collect();
-
- let const_check = quote! {
- const _CONST_CHECK: () = {
- if !rtic::export::have_basepri() {
- #(#no_basepri_checks)*
- } else {
- // TODO: Add armv7 checks here
- }
- };
-
- let _ = _CONST_CHECK;
- };
-
- stmts.push(const_check);
+ stmts.append(&mut extra_assertions(app, analysis));
stmts
}