aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/assertions.rs
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2023-01-23 20:05:47 +0100
committerGravatar Henrik Tjäder <henrik@tjaders.com> 2023-03-01 00:33:31 +0100
commit306aa47170fd59369b7a184924e287dc3706d64d (patch)
tree75a331a63a4021f078e330bf2ce4edb1228e2ecf /macros/src/codegen/assertions.rs
parentb8b881f446a226d6f3c4a7db7c9174590b47dbf6 (diff)
downloadrtic-306aa47170fd59369b7a184924e287dc3706d64d.tar.gz
rtic-306aa47170fd59369b7a184924e287dc3706d64d.tar.zst
rtic-306aa47170fd59369b7a184924e287dc3706d64d.zip
Add rtic-timer (timerqueue + monotonic) and rtic-monotonics (systick-monotonic)
Diffstat (limited to 'macros/src/codegen/assertions.rs')
-rw-r--r--macros/src/codegen/assertions.rs53
1 files changed, 0 insertions, 53 deletions
diff --git a/macros/src/codegen/assertions.rs b/macros/src/codegen/assertions.rs
deleted file mode 100644
index dd94aa6d..00000000
--- a/macros/src/codegen/assertions.rs
+++ /dev/null
@@ -1,53 +0,0 @@
-use proc_macro2::TokenStream as TokenStream2;
-use quote::quote;
-
-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> {
- let mut stmts = vec![];
-
- for ty in &analysis.send_types {
- stmts.push(quote!(rtic::export::assert_send::<#ty>();));
- }
-
- for ty in &analysis.sync_types {
- 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
-}