diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs index f6fdf022a8..081c37fa21 100644 --- a/macros/src/codegen.rs +++ b/macros/src/codegen.rs @@ -84,7 +84,8 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { } )); - let (mod_app_resources, mod_resources) = resources::codegen(app, analysis, extra); + let (mod_app_shared_resources, mod_shared_resources) = shared_resources::codegen(app, analysis, extra); + let (mod_app_local_resources, mod_local_resources) = local_resources::codegen(app, analysis, extra); let (mod_app_hardware_tasks, root_hardware_tasks, user_hardware_tasks) = hardware_tasks::codegen(app, analysis, extra); @@ -186,7 +187,9 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { #(#root)* - #mod_resources + #mod_shared_resources + + #mod_local_resources #(#root_hardware_tasks)* @@ -195,7 +198,9 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { /// app module #(#mod_app)* - #(#mod_app_resources)* + #(#mod_app_shared_resources)* + + #(#mod_app_local_resources)* #(#mod_app_hardware_tasks)* diff --git a/macros/src/codegen/dispatchers.rs b/macros/src/codegen/dispatchers.rs index dfa52d5dc5..1c311954bc 100644 --- a/macros/src/codegen/dispatchers.rs +++ b/macros/src/codegen/dispatchers.rs @@ -76,11 +76,12 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec Vec ! { + fn #name(#context: #name::Context) -> ! { use rtic::Mutex as _; use rtic::mutex_prelude::*; @@ -74,9 +71,7 @@ pub fn codegen( } )); - let locals_new = locals_new.iter(); let call_idle = quote!(#name( - #(#locals_new,)* #name::Context::new(&rtic::export::Priority::new(0)) )); diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs index fe8a1263c0..e3f74086e7 100644 --- a/macros/src/codegen/init.rs +++ b/macros/src/codegen/init.rs @@ -5,7 +5,7 @@ use rtic_syntax::{ast::App, Context}; use crate::{ analyze::Analysis, check::Extra, - codegen::{locals, module, resources_struct}, + codegen::{local_resources_struct, module}, }; type CodegenResult = ( @@ -18,68 +18,96 @@ type CodegenResult = ( // - the `${init}` module, which contains types like `${init}::Context` Vec, // user_init -- the `#[init]` function written by the user - Option, - // call_init -- the call to the user `#[init]` if there's one - Option, + TokenStream2, + // call_init -- the call to the user `#[init]` + TokenStream2, ); /// Generates support code for `#[init]` functions pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult { - if !app.inits.is_empty() { - let init = &app.inits.first().unwrap(); - let mut needs_lt = false; - let name = &init.name; + let init = &app.init; + let mut needs_lt = false; + let name = &init.name; - let mut root_init = vec![]; + let mut root_init = vec![]; - let mut locals_pat = None; - let mut locals_new = None; - if !init.locals.is_empty() { - let (struct_, pat) = locals::codegen(Context::Init, &init.locals, app); + // TODO: Fix locals + // let mut locals_pat = None; + // let mut locals_new = None; + // if !init.locals.is_empty() { + // let (struct_, pat) = locals::codegen(Context::Init, &init.locals, app); - locals_new = Some(quote!(#name::Locals::new())); - locals_pat = Some(pat); - root_init.push(struct_); + // locals_new = Some(quote!(#name::Locals::new())); + // locals_pat = Some(pat); + // root_init.push(struct_); + // } + + let context = &init.context; + let attrs = &init.attrs; + let stmts = &init.stmts; + let shared = &init.user_shared_struct; + let local = &init.user_local_struct; + + let shared_resources: Vec<_> = app + .shared_resources + .iter() + .map(|(k, v)| { + let ty = &v.ty; + let cfgs = &v.cfgs; + quote!( + #(#cfgs)* + #k: #ty, + ) + }) + .collect(); + let local_resources: Vec<_> = app + .local_resources + .iter() + .map(|(k, v)| { + let ty = &v.ty; + let cfgs = &v.cfgs; + quote!( + #(#cfgs)* + #k: #ty, + ) + }) + .collect(); + root_init.push(quote! { + struct #shared { + #(#shared_resources)* } - let context = &init.context; - let attrs = &init.attrs; - let stmts = &init.stmts; - let locals_pat = locals_pat.iter(); - - let user_init_return = quote! {#name::LateResources, #name::Monotonics}; - - let user_init = Some(quote!( - #(#attrs)* - #[allow(non_snake_case)] - fn #name(#(#locals_pat,)* #context: #name::Context) -> (#user_init_return) { - #(#stmts)* - } - )); - - let mut mod_app = None; - if !init.args.resources.is_empty() { - let (item, constructor) = resources_struct::codegen(Context::Init, &mut needs_lt, app); - - root_init.push(item); - mod_app = Some(constructor); + struct #local { + #(#local_resources)* } + }); - let locals_new = locals_new.iter(); - let call_init = Some( - quote!(let (late, mut monotonics) = #name(#(#locals_new,)* #name::Context::new(core.into()));), - ); + // let locals_pat = locals_pat.iter(); - root_init.push(module::codegen( - Context::Init, - needs_lt, - app, - analysis, - extra, - )); + let user_init_return = quote! {#shared, #local, #name::Monotonics}; - (mod_app, root_init, user_init, call_init) - } else { - (None, vec![], None, None) - } + let user_init = quote!( + #(#attrs)* + #[allow(non_snake_case)] + fn #name(#context: #name::Context) -> (#user_init_return) { + #(#stmts)* + } + ); + + let mut mod_app = None; + + // let locals_new = locals_new.iter(); + let call_init = quote! { + let (shared_resources, local_resources, mut monotonics) = #name(#name::Context::new(core.into())); + }; + + root_init.push(module::codegen( + Context::Init, + needs_lt, + app, + analysis, + extra, + )); + + (mod_app, root_init, user_init, call_init) } diff --git a/macros/src/codegen/local_resources.rs b/macros/src/codegen/local_resources.rs index dd3cbb4435..13891f937d 100644 --- a/macros/src/codegen/local_resources.rs +++ b/macros/src/codegen/local_resources.rs @@ -1,10 +1,12 @@ use proc_macro2::TokenStream as TokenStream2; use quote::quote; -use rtic_syntax::{analyze::Ownership, ast::App}; +use rtic_syntax::ast::App; use crate::{analyze::Analysis, check::Extra, codegen::util}; /// Generates `local` variables and local resource proxies +/// +/// I.e. the `static` variables and theirs proxies. pub fn codegen( app: &App, analysis: &Analysis, @@ -16,131 +18,42 @@ pub fn codegen( TokenStream2, ) { let mut mod_app = vec![]; - let mut mod_resources = vec![]; + // let mut mod_resources: _ = vec![]; - for (name, res) in app.local_resources { + // All local resources declared in the `#[local]' struct + for (name, res) in &app.local_resources { // let expr = &res.expr; // TODO: Extract from tasks???... let cfgs = &res.cfgs; let ty = &res.ty; - let mangled_name = util::mark_internal_ident(&name); + let mangled_name = util::mark_internal_ident(&util::static_local_resource_ident(name)); - { - // late resources in `util::link_section_uninit` - let section = if expr.is_none() { - util::link_section_uninit(true) - } else { - None - }; + let ty = quote!(rtic::RacyCell>); + let expr = quote!(rtic::RacyCell::new(core::mem::MaybeUninit::uninit())); - // resource type and assigned value - let (ty, expr) = if let Some(expr) = expr { - // early resource - ( - quote!(rtic::RacyCell<#ty>), - quote!(rtic::RacyCell::new(#expr)), - ) - } else { - // late resource - ( - quote!(rtic::RacyCell>), - quote!(rtic::RacyCell::new(core::mem::MaybeUninit::uninit())), - ) - }; + let attrs = &res.attrs; + // late resources in `util::link_section_uninit` + let section = util::link_section_uninit(true); - let attrs = &res.attrs; - - // For future use - // let doc = format!(" RTIC internal: {}:{}", file!(), line!()); - mod_app.push(quote!( - #[allow(non_upper_case_globals)] - // #[doc = #doc] - #[doc(hidden)] - #(#attrs)* - #(#cfgs)* - #section - static #mangled_name: #ty = #expr; - )); - } - - let r_prop = &res.properties; // For future use // let doc = format!(" RTIC internal: {}:{}", file!(), line!()); - - if !r_prop.task_local && !r_prop.lock_free { - mod_resources.push(quote!( - // #[doc = #doc] - #[doc(hidden)] - #[allow(non_camel_case_types)] - #(#cfgs)* - pub struct #name<'a> { - priority: &'a Priority, - } - - #(#cfgs)* - impl<'a> #name<'a> { - #[inline(always)] - pub unsafe fn new(priority: &'a Priority) -> Self { - #name { priority } - } - - #[inline(always)] - pub unsafe fn priority(&self) -> &Priority { - self.priority - } - } - )); - - let (ptr, _doc) = if expr.is_none() { - // late resource - ( - quote!( - #(#cfgs)* - #mangled_name.get_mut_unchecked().as_mut_ptr() - ), - "late", - ) - } else { - // early resource - ( - quote!( - #(#cfgs)* - #mangled_name.get_mut_unchecked() - ), - "early", - ) - }; - - let ceiling = match analysis.ownerships.get(name) { - Some(Ownership::Owned { priority }) => *priority, - Some(Ownership::CoOwned { priority }) => *priority, - Some(Ownership::Contended { ceiling }) => *ceiling, - None => 0, - }; - - // For future use - // let doc = format!(" RTIC internal ({} resource): {}:{}", doc, file!(), line!()); - - mod_app.push(util::impl_mutex( - extra, - cfgs, - true, - name, - quote!(#ty), - ceiling, - ptr, - )); - } + mod_app.push(quote!( + #[allow(non_upper_case_globals)] + // #[doc = #doc] + #[doc(hidden)] + #(#attrs)* + #(#cfgs)* + #section + static #mangled_name: #ty = #expr; + )); } - let mod_resources = if mod_resources.is_empty() { - quote!() - } else { - quote!(mod resources { - use rtic::export::Priority; + // let mod_resources = if mod_resources.is_empty() { + // quote!() + // } else { + // quote!(mod local_resources { + // #(#mod_resources)* + // }) + // }; - #(#mod_resources)* - }) - }; - - (mod_app, mod_resources) + (mod_app, TokenStream2::new()) } diff --git a/macros/src/codegen/local_resources_struct.rs b/macros/src/codegen/local_resources_struct.rs index 3016f37997..14706a5b09 100644 --- a/macros/src/codegen/local_resources_struct.rs +++ b/macros/src/codegen/local_resources_struct.rs @@ -10,7 +10,7 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2, let resources = match ctxt { Context::Init => &app.init.args.local_resources, - Context::Idle => &app.idle.unwrap().args.local_resources, + Context::Idle => &app.idle.as_ref().unwrap().args.local_resources, Context::HardwareTask(name) => &app.hardware_tasks[name].args.local_resources, Context::SoftwareTask(name) => &app.software_tasks[name].args.local_resources, }; @@ -33,7 +33,7 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2, }; let ty = &res.ty; - let mangled_name = util::mark_internal_ident(&name); + let mangled_name = util::mark_internal_ident(&util::static_local_resource_ident(name)); fields.push(quote!( #(#cfgs)* diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index a3d3fab2e2..adf64d5bd2 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -56,16 +56,16 @@ pub fn codegen( Context::SoftwareTask(_) => {} } - if ctxt.has_locals(app) { - let ident = util::locals_ident(ctxt, app); - module_items.push(quote!( - #[doc(inline)] - pub use super::#ident as Locals; - )); - } + // if ctxt.has_locals(app) { + // let ident = util::locals_ident(ctxt, app); + // module_items.push(quote!( + // #[doc(inline)] + // pub use super::#ident as Locals; + // )); + // } - if ctxt.has_resources(app) { - let ident = util::resources_ident(ctxt, app); + if ctxt.has_local_resources(app) { + let ident = util::local_resources_ident(ctxt, app); let ident = util::mark_internal_ident(&ident); let lt = if resources_tick { lt = Some(quote!('a)); @@ -76,12 +76,35 @@ pub fn codegen( module_items.push(quote!( #[doc(inline)] - pub use super::#ident as Resources; + pub use super::#ident as LocalResources; )); fields.push(quote!( - /// Resources this task has access to - pub resources: #name::Resources<#lt> + /// Local Resources this task has access to + pub local: #name::LocalResources<#lt> + )); + + values.push(quote!(local: #name::LocalResources::new())); + } + + if ctxt.has_shared_resources(app) { + let ident = util::shared_resources_ident(ctxt, app); + let ident = util::mark_internal_ident(&ident); + let lt = if resources_tick { + lt = Some(quote!('a)); + Some(quote!('a)) + } else { + None + }; + + module_items.push(quote!( + #[doc(inline)] + pub use super::#ident as SharedResources; + )); + + fields.push(quote!( + /// Shared Resources this task has access to + pub shared: #name::SharedResources<#lt> )); let priority = if ctxt.is_init() { @@ -89,38 +112,10 @@ pub fn codegen( } else { Some(quote!(priority)) }; - values.push(quote!(resources: #name::Resources::new(#priority))); + values.push(quote!(shared: #name::SharedResources::new(#priority))); } if let Context::Init = ctxt { - let late_fields = analysis - .late_resources - .iter() - .flat_map(|resources| { - resources.iter().map(|name| { - let ty = &app.late_resources[name].ty; - let cfgs = &app.late_resources[name].cfgs; - - quote!( - #(#cfgs)* - pub #name: #ty - ) - }) - }) - .collect::>(); - - let internal_late_ident = util::mark_internal_name("LateResources"); - items.push(quote!( - /// Resources initialized at runtime - #[allow(non_snake_case)] - pub struct #internal_late_ident { - #(#late_fields),* - } - )); - module_items.push(quote!( - pub use super::#internal_late_ident as LateResources; - )); - let monotonic_types: Vec<_> = app .monotonics .iter() diff --git a/macros/src/codegen/post_init.rs b/macros/src/codegen/post_init.rs index 78548bcdaf..161068d2bd 100644 --- a/macros/src/codegen/post_init.rs +++ b/macros/src/codegen/post_init.rs @@ -9,24 +9,39 @@ use crate::{analyze::Analysis, codegen::util}; pub fn codegen(app: &App, analysis: &Analysis) -> Vec { let mut stmts = vec![]; - // Initialize late resources - if !analysis.late_resources.is_empty() { - // BTreeSet wrapped in a vector - for name in analysis.late_resources.first().unwrap() { - let mangled_name = util::mark_internal_ident(&name); - // If it's live - let cfgs = app.late_resources[name].cfgs.clone(); - if analysis.locations.get(name).is_some() { - stmts.push(quote!( - // We include the cfgs - #(#cfgs)* - // Late resource is a RacyCell> - // - `get_mut_unchecked` to obtain `MaybeUninit` - // - `as_mut_ptr` to obtain a raw pointer to `MaybeUninit` - // - `write` the defined value for the late resource T - #mangled_name.get_mut_unchecked().as_mut_ptr().write(late.#name); - )); - } + // Initialize shared resources + for (name, res) in &app.shared_resources { + let mangled_name = util::mark_internal_ident(&util::static_shared_resource_ident(name)); + // If it's live + let cfgs = res.cfgs.clone(); + if analysis.shared_resource_locations.get(name).is_some() { + stmts.push(quote!( + // We include the cfgs + #(#cfgs)* + // Resource is a RacyCell> + // - `get_mut_unchecked` to obtain `MaybeUninit` + // - `as_mut_ptr` to obtain a raw pointer to `MaybeUninit` + // - `write` the defined value for the late resource T + #mangled_name.get_mut_unchecked().as_mut_ptr().write(shared_resources.#name); + )); + } + } + + // Initialize local resources + for (name, res) in &app.local_resources { + let mangled_name = util::mark_internal_ident(&util::static_local_resource_ident(name)); + // If it's live + let cfgs = res.cfgs.clone(); + if analysis.local_resource_locations.get(name).is_some() { + stmts.push(quote!( + // We include the cfgs + #(#cfgs)* + // Resource is a RacyCell> + // - `get_mut_unchecked` to obtain `MaybeUninit` + // - `as_mut_ptr` to obtain a raw pointer to `MaybeUninit` + // - `write` the defined value for the late resource T + #mangled_name.get_mut_unchecked().as_mut_ptr().write(local_resources.#name); + )); } } diff --git a/macros/src/codegen/pre_init.rs b/macros/src/codegen/pre_init.rs index 531debac67..ae628f6eb9 100644 --- a/macros/src/codegen/pre_init.rs +++ b/macros/src/codegen/pre_init.rs @@ -126,7 +126,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec), - quote!(rtic::RacyCell::new(#expr)), - ) - } else { - // late resource - ( - quote!(rtic::RacyCell>), - quote!(rtic::RacyCell::new(core::mem::MaybeUninit::uninit())), - ) - }; + // For future use + // let doc = format!(" RTIC internal: {}:{}", file!(), line!()); + mod_app.push(quote!( + #[allow(non_upper_case_globals)] + // #[doc = #doc] + #[doc(hidden)] + #(#attrs)* + #(#cfgs)* + #section + static #mangled_name: rtic::RacyCell> = rtic::RacyCell::new(core::mem::MaybeUninit::uninit()); + )); - let attrs = &res.attrs; - - // For future use - // let doc = format!(" RTIC internal: {}:{}", file!(), line!()); - mod_app.push(quote!( - #[allow(non_upper_case_globals)] - // #[doc = #doc] - #[doc(hidden)] - #(#attrs)* - #(#cfgs)* - #section - static #mangled_name: #ty = #expr; - )); - } - - let r_prop = &res.properties; // For future use // let doc = format!(" RTIC internal: {}:{}", file!(), line!()); - if !r_prop.task_local && !r_prop.lock_free { + if !res.properties.lock_free { mod_resources.push(quote!( // #[doc = #doc] #[doc(hidden)] @@ -89,25 +66,10 @@ pub fn codegen( } )); - let (ptr, _doc) = if expr.is_none() { - // late resource - ( - quote!( - #(#cfgs)* - #mangled_name.get_mut_unchecked().as_mut_ptr() - ), - "late", - ) - } else { - // early resource - ( - quote!( - #(#cfgs)* - #mangled_name.get_mut_unchecked() - ), - "early", - ) - }; + let ptr = quote!( + #(#cfgs)* + #mangled_name.get_mut_unchecked().as_mut_ptr() + ); let ceiling = match analysis.ownerships.get(name) { Some(Ownership::Owned { priority }) => *priority, @@ -123,7 +85,7 @@ pub fn codegen( extra, cfgs, true, - name, + &name, quote!(#ty), ceiling, ptr, @@ -134,7 +96,7 @@ pub fn codegen( let mod_resources = if mod_resources.is_empty() { quote!() } else { - quote!(mod resources { + quote!(mod shared_resources { use rtic::export::Priority; #(#mod_resources)* diff --git a/macros/src/codegen/shared_resources_struct.rs b/macros/src/codegen/shared_resources_struct.rs index 4bdc8fa128..df7f38dedc 100644 --- a/macros/src/codegen/shared_resources_struct.rs +++ b/macros/src/codegen/shared_resources_struct.rs @@ -10,7 +10,7 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2, let resources = match ctxt { Context::Init => unreachable!("Tried to generate shared resources struct for init"), - Context::Idle => &app.idle.unwrap().args.shared_resources, + Context::Idle => &app.idle.as_ref().unwrap().args.shared_resources, Context::HardwareTask(name) => &app.hardware_tasks[name].args.shared_resources, Context::SoftwareTask(name) => &app.software_tasks[name].args.shared_resources, }; @@ -48,12 +48,12 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2, fields.push(quote!( #(#cfgs)* - pub #name: resources::#name<'a> + pub #name: shared_resources::#name<'a> )); values.push(quote!( #(#cfgs)* - #name: resources::#name::new(priority) + #name: shared_resources::#name::new(priority) )); diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index 0372e8ec83..da594e7d3a 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -5,7 +5,7 @@ use rtic_syntax::{ast::App, Context}; use crate::{ analyze::Analysis, check::Extra, - codegen::{locals, module, resources_struct, util}, + codegen::{local_resources_struct, module, shared_resources_struct, util}, }; pub fn codegen( @@ -91,35 +91,38 @@ pub fn codegen( // `${task}Resources` let mut needs_lt = false; - if !task.args.resources.is_empty() { + + // TODO: Fix locals + // `${task}Locals` + if !task.args.local_resources.is_empty() { let (item, constructor) = - resources_struct::codegen(Context::SoftwareTask(name), &mut needs_lt, app); + local_resources_struct::codegen(Context::SoftwareTask(name), &mut needs_lt, app); root.push(item); mod_app.push(constructor); } - // `${task}Locals` - let mut locals_pat = None; - if !task.locals.is_empty() { - let (struct_, pat) = locals::codegen(Context::SoftwareTask(name), &task.locals, app); + if !task.args.shared_resources.is_empty() { + let (item, constructor) = + shared_resources_struct::codegen(Context::SoftwareTask(name), &mut needs_lt, app); - locals_pat = Some(pat); - root.push(struct_); + root.push(item); + + mod_app.push(constructor); } + if !&task.is_extern { let context = &task.context; let attrs = &task.attrs; let cfgs = &task.cfgs; let stmts = &task.stmts; - let locals_pat = locals_pat.iter(); user_tasks.push(quote!( #(#attrs)* #(#cfgs)* #[allow(non_snake_case)] - fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) { + fn #name(#context: #name::Context #(,#inputs)*) { use rtic::Mutex as _; use rtic::mutex_prelude::*; diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs index 21b314116e..dd0fb6d91e 100644 --- a/macros/src/codegen/util.rs +++ b/macros/src/codegen/util.rs @@ -41,7 +41,7 @@ pub fn impl_mutex( ptr: TokenStream2, ) -> TokenStream2 { let (path, priority) = if resources_prefix { - (quote!(resources::#name), quote!(self.priority())) + (quote!(shared_resources::#name), quote!(self.priority())) } else { (quote!(#name), quote!(self.priority)) }; @@ -167,7 +167,7 @@ pub fn link_section_uninit(empty_expr: bool) -> Option { pub fn locals_ident(ctxt: Context, app: &App) -> Ident { let mut s = match ctxt { Context::Init => app.init.name.to_string(), - Context::Idle => app.idle.unwrap().name.to_string(), + Context::Idle => app.idle.as_ref().unwrap().name.to_string(), Context::HardwareTask(ident) | Context::SoftwareTask(ident) => ident.to_string(), }; @@ -229,7 +229,7 @@ pub fn regroup_inputs( pub fn shared_resources_ident(ctxt: Context, app: &App) -> Ident { let mut s = match ctxt { Context::Init => app.init.name.to_string(), - Context::Idle => app.idle.unwrap().name.to_string(), + Context::Idle => app.idle.as_ref().unwrap().name.to_string(), Context::HardwareTask(ident) | Context::SoftwareTask(ident) => ident.to_string(), }; @@ -242,7 +242,7 @@ pub fn shared_resources_ident(ctxt: Context, app: &App) -> Ident { pub fn local_resources_ident(ctxt: Context, app: &App) -> Ident { let mut s = match ctxt { Context::Init => app.init.name.to_string(), - Context::Idle => app.idle.unwrap().name.to_string(), + Context::Idle => app.idle.as_ref().unwrap().name.to_string(), Context::HardwareTask(ident) | Context::SoftwareTask(ident) => ident.to_string(), }; @@ -288,6 +288,14 @@ pub fn monotonic_ident(name: &str) -> Ident { Ident::new(&format!("MONOTONIC_STORAGE_{}", name), Span::call_site()) } +pub fn static_shared_resource_ident(name: &Ident) -> Ident { + Ident::new(&format!("shared_{}", name.to_string()), Span::call_site()) +} + +pub fn static_local_resource_ident(name: &Ident) -> Ident { + Ident::new(&format!("local_{}", name.to_string()), Span::call_site()) +} + /// The name to get better RT flag errors pub fn rt_err_ident() -> Ident { Ident::new(