mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-12-25 19:39:32 +01:00
Merge #515
515: `mark_internal_ident` cleanup r=korken89 a=datdenkikniet Refactor so that all `idents` that had to call `mark_ident_internal` before now call `mark_name_internal` in the `util` module by default. The commits can (and probably should) be squashed, they're separated for clarity. Fixes #512 Co-authored-by: datdenkikniet <jcdra1@gmail.com>
This commit is contained in:
commit
f77b81e0ee
12 changed files with 40 additions and 89 deletions
|
@ -108,7 +108,6 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||||
let name = &monotonic.ident;
|
let name = &monotonic.ident;
|
||||||
let name_str = &name.to_string();
|
let name_str = &name.to_string();
|
||||||
let ident = util::monotonic_ident(&name_str);
|
let ident = util::monotonic_ident(&name_str);
|
||||||
let ident = util::mark_internal_ident(&ident);
|
|
||||||
let panic_str = &format!(
|
let panic_str = &format!(
|
||||||
"Use of monotonic '{}' before it was passed to the runtime",
|
"Use of monotonic '{}' before it was passed to the runtime",
|
||||||
name_str
|
name_str
|
||||||
|
|
|
@ -45,7 +45,6 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
||||||
|
|
||||||
let n = util::capacity_literal(channel.capacity as usize + 1);
|
let n = util::capacity_literal(channel.capacity as usize + 1);
|
||||||
let rq = util::rq_ident(level);
|
let rq = util::rq_ident(level);
|
||||||
let rq = util::mark_internal_ident(&rq);
|
|
||||||
let (rq_ty, rq_expr) = {
|
let (rq_ty, rq_expr) = {
|
||||||
(
|
(
|
||||||
quote!(rtic::export::SCRQ<#t, #n>),
|
quote!(rtic::export::SCRQ<#t, #n>),
|
||||||
|
@ -72,9 +71,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
||||||
let task = &app.software_tasks[name];
|
let task = &app.software_tasks[name];
|
||||||
let cfgs = &task.cfgs;
|
let cfgs = &task.cfgs;
|
||||||
let fq = util::fq_ident(name);
|
let fq = util::fq_ident(name);
|
||||||
let fq = util::mark_internal_ident(&fq);
|
|
||||||
let inputs = util::inputs_ident(name);
|
let inputs = util::inputs_ident(name);
|
||||||
let inputs = util::mark_internal_ident(&inputs);
|
|
||||||
let (_, tupled, pats, _) = util::regroup_inputs(&task.inputs);
|
let (_, tupled, pats, _) = util::regroup_inputs(&task.inputs);
|
||||||
|
|
||||||
quote!(
|
quote!(
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub fn codegen(
|
||||||
for (name, res) in &app.local_resources {
|
for (name, res) in &app.local_resources {
|
||||||
let cfgs = &res.cfgs;
|
let cfgs = &res.cfgs;
|
||||||
let ty = &res.ty;
|
let ty = &res.ty;
|
||||||
let mangled_name = util::mark_internal_ident(&util::static_local_resource_ident(name));
|
let mangled_name = util::static_local_resource_ident(name);
|
||||||
|
|
||||||
let attrs = &res.attrs;
|
let attrs = &res.attrs;
|
||||||
// late resources in `util::link_section_uninit`
|
// late resources in `util::link_section_uninit`
|
||||||
|
@ -51,10 +51,7 @@ pub fn codegen(
|
||||||
let expr = &task_local.expr;
|
let expr = &task_local.expr;
|
||||||
let attrs = &task_local.attrs;
|
let attrs = &task_local.attrs;
|
||||||
|
|
||||||
let mangled_name = util::mark_internal_ident(&util::declared_static_local_resource_ident(
|
let mangled_name = util::declared_static_local_resource_ident(resource_name, &task_name);
|
||||||
resource_name,
|
|
||||||
&task_name,
|
|
||||||
));
|
|
||||||
|
|
||||||
// For future use
|
// For future use
|
||||||
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
|
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
|
||||||
|
|
|
@ -44,11 +44,9 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mangled_name = if matches!(task_local, TaskLocal::External) {
|
let mangled_name = if matches!(task_local, TaskLocal::External) {
|
||||||
util::mark_internal_ident(&util::static_local_resource_ident(name))
|
util::static_local_resource_ident(name)
|
||||||
} else {
|
} else {
|
||||||
util::mark_internal_ident(&util::declared_static_local_resource_ident(
|
util::declared_static_local_resource_ident(name, &task_name)
|
||||||
name, &task_name,
|
|
||||||
))
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fields.push(quote!(
|
fields.push(quote!(
|
||||||
|
@ -86,7 +84,6 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
||||||
|
|
||||||
let doc = format!("Local resources `{}` has access to", ctxt.ident(app));
|
let doc = format!("Local resources `{}` has access to", ctxt.ident(app));
|
||||||
let ident = util::local_resources_ident(ctxt, app);
|
let ident = util::local_resources_ident(ctxt, app);
|
||||||
let ident = util::mark_internal_ident(&ident);
|
|
||||||
let item = quote!(
|
let item = quote!(
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
|
|
|
@ -67,7 +67,6 @@ pub fn codegen(
|
||||||
|
|
||||||
if ctxt.has_local_resources(app) {
|
if ctxt.has_local_resources(app) {
|
||||||
let ident = util::local_resources_ident(ctxt, app);
|
let ident = util::local_resources_ident(ctxt, app);
|
||||||
let ident = util::mark_internal_ident(&ident);
|
|
||||||
let lt = if local_resources_tick {
|
let lt = if local_resources_tick {
|
||||||
lt = Some(quote!('a));
|
lt = Some(quote!('a));
|
||||||
Some(quote!('a))
|
Some(quote!('a))
|
||||||
|
@ -90,7 +89,6 @@ pub fn codegen(
|
||||||
|
|
||||||
if ctxt.has_shared_resources(app) {
|
if ctxt.has_shared_resources(app) {
|
||||||
let ident = util::shared_resources_ident(ctxt, app);
|
let ident = util::shared_resources_ident(ctxt, app);
|
||||||
let ident = util::mark_internal_ident(&ident);
|
|
||||||
let lt = if shared_resources_tick {
|
let lt = if shared_resources_tick {
|
||||||
lt = Some(quote!('a));
|
lt = Some(quote!('a));
|
||||||
Some(quote!('a))
|
Some(quote!('a))
|
||||||
|
@ -212,11 +210,8 @@ pub fn codegen(
|
||||||
let args = &args;
|
let args = &args;
|
||||||
let tupled = &tupled;
|
let tupled = &tupled;
|
||||||
let fq = util::fq_ident(name);
|
let fq = util::fq_ident(name);
|
||||||
let fq = util::mark_internal_ident(&fq);
|
|
||||||
let rq = util::rq_ident(priority);
|
let rq = util::rq_ident(priority);
|
||||||
let rq = util::mark_internal_ident(&rq);
|
|
||||||
let inputs = util::inputs_ident(name);
|
let inputs = util::inputs_ident(name);
|
||||||
let inputs = util::mark_internal_ident(&inputs);
|
|
||||||
|
|
||||||
let device = &extra.device;
|
let device = &extra.device;
|
||||||
let enum_ = util::interrupt_ident();
|
let enum_ = util::interrupt_ident();
|
||||||
|
@ -266,16 +261,13 @@ pub fn codegen(
|
||||||
// Schedule caller
|
// Schedule caller
|
||||||
for (_, monotonic) in &app.monotonics {
|
for (_, monotonic) in &app.monotonics {
|
||||||
let instants = util::monotonic_instants_ident(name, &monotonic.ident);
|
let instants = util::monotonic_instants_ident(name, &monotonic.ident);
|
||||||
let instants = util::mark_internal_ident(&instants);
|
|
||||||
let monotonic_name = monotonic.ident.to_string();
|
let monotonic_name = monotonic.ident.to_string();
|
||||||
|
|
||||||
let tq = util::tq_ident(&monotonic.ident.to_string());
|
let tq = util::tq_ident(&monotonic.ident.to_string());
|
||||||
let tq = util::mark_internal_ident(&tq);
|
|
||||||
let t = util::schedule_t_ident();
|
let t = util::schedule_t_ident();
|
||||||
let m = &monotonic.ident;
|
let m = &monotonic.ident;
|
||||||
let mono_type = &monotonic.ident;
|
let mono_type = &monotonic.ident;
|
||||||
let m_ident = util::monotonic_ident(&monotonic_name);
|
let m_ident = util::monotonic_ident(&monotonic_name);
|
||||||
let m_ident = util::mark_internal_ident(&m_ident);
|
|
||||||
let m_isr = &monotonic.args.binds;
|
let m_isr = &monotonic.args.binds;
|
||||||
let enum_ = util::interrupt_ident();
|
let enum_ = util::interrupt_ident();
|
||||||
|
|
||||||
|
@ -293,7 +285,7 @@ pub fn codegen(
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let tq_marker = util::mark_internal_ident(&util::timer_queue_marker_ident());
|
let tq_marker = &util::timer_queue_marker_ident();
|
||||||
|
|
||||||
// For future use
|
// For future use
|
||||||
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
|
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
|
||||||
|
|
||||||
// Initialize shared resources
|
// Initialize shared resources
|
||||||
for (name, res) in &app.shared_resources {
|
for (name, res) in &app.shared_resources {
|
||||||
let mangled_name = util::mark_internal_ident(&util::static_shared_resource_ident(name));
|
let mangled_name = util::static_shared_resource_ident(name);
|
||||||
// If it's live
|
// If it's live
|
||||||
let cfgs = res.cfgs.clone();
|
let cfgs = res.cfgs.clone();
|
||||||
if analysis.shared_resource_locations.get(name).is_some() {
|
if analysis.shared_resource_locations.get(name).is_some() {
|
||||||
|
@ -29,7 +29,7 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
|
||||||
|
|
||||||
// Initialize local resources
|
// Initialize local resources
|
||||||
for (name, res) in &app.local_resources {
|
for (name, res) in &app.local_resources {
|
||||||
let mangled_name = util::mark_internal_ident(&util::static_local_resource_ident(name));
|
let mangled_name = util::static_local_resource_ident(name);
|
||||||
// If it's live
|
// If it's live
|
||||||
let cfgs = res.cfgs.clone();
|
let cfgs = res.cfgs.clone();
|
||||||
if analysis.local_resource_locations.get(name).is_some() {
|
if analysis.local_resource_locations.get(name).is_some() {
|
||||||
|
@ -58,7 +58,6 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
|
||||||
|
|
||||||
// Store the monotonic
|
// Store the monotonic
|
||||||
let name = util::monotonic_ident(&monotonic.to_string());
|
let name = util::monotonic_ident(&monotonic.to_string());
|
||||||
let name = util::mark_internal_ident(&name);
|
|
||||||
stmts.push(quote!(*#name.get_mut_unchecked() = Some(monotonics.#idx);));
|
stmts.push(quote!(*#name.get_mut_unchecked() = Some(monotonics.#idx);));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
for (name, task) in &app.software_tasks {
|
for (name, task) in &app.software_tasks {
|
||||||
let cap = task.args.capacity;
|
let cap = task.args.capacity;
|
||||||
let fq_ident = util::fq_ident(name);
|
let fq_ident = util::fq_ident(name);
|
||||||
let fq_ident = util::mark_internal_ident(&fq_ident);
|
|
||||||
|
|
||||||
stmts.push(quote!(
|
stmts.push(quote!(
|
||||||
(0..#cap).for_each(|i| #fq_ident.get_mut_unchecked().enqueue_unchecked(i));
|
(0..#cap).for_each(|i| #fq_ident.get_mut_unchecked().enqueue_unchecked(i));
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub fn codegen(
|
||||||
for (name, res) in &app.shared_resources {
|
for (name, res) in &app.shared_resources {
|
||||||
let cfgs = &res.cfgs;
|
let cfgs = &res.cfgs;
|
||||||
let ty = &res.ty;
|
let ty = &res.ty;
|
||||||
let mangled_name = util::mark_internal_ident(&util::static_shared_resource_ident(&name));
|
let mangled_name = &util::static_shared_resource_ident(&name);
|
||||||
|
|
||||||
// late resources in `util::link_section_uninit`
|
// late resources in `util::link_section_uninit`
|
||||||
let section = util::link_section_uninit();
|
let section = util::link_section_uninit();
|
||||||
|
|
|
@ -32,7 +32,7 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let ty = &res.ty;
|
let ty = &res.ty;
|
||||||
let mangled_name = util::mark_internal_ident(&util::static_shared_resource_ident(&name));
|
let mangled_name = util::static_shared_resource_ident(&name);
|
||||||
|
|
||||||
if !res.properties.lock_free {
|
if !res.properties.lock_free {
|
||||||
if access.is_shared() {
|
if access.is_shared() {
|
||||||
|
@ -102,7 +102,6 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
||||||
|
|
||||||
let doc = format!("Shared resources `{}` has access to", ctxt.ident(app));
|
let doc = format!("Shared resources `{}` has access to", ctxt.ident(app));
|
||||||
let ident = util::shared_resources_ident(ctxt, app);
|
let ident = util::shared_resources_ident(ctxt, app);
|
||||||
let ident = util::mark_internal_ident(&ident);
|
|
||||||
let item = quote!(
|
let item = quote!(
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
|
|
|
@ -37,7 +37,6 @@ pub fn codegen(
|
||||||
|
|
||||||
// Create free queues and inputs / instants buffers
|
// Create free queues and inputs / instants buffers
|
||||||
let fq = util::fq_ident(name);
|
let fq = util::fq_ident(name);
|
||||||
let fq = util::mark_internal_ident(&fq);
|
|
||||||
|
|
||||||
let (fq_ty, fq_expr, mk_uninit): (_, _, Box<dyn Fn() -> Option<_>>) = {
|
let (fq_ty, fq_expr, mk_uninit): (_, _, Box<dyn Fn() -> Option<_>>) = {
|
||||||
(
|
(
|
||||||
|
@ -61,7 +60,6 @@ pub fn codegen(
|
||||||
|
|
||||||
for (_, monotonic) in &app.monotonics {
|
for (_, monotonic) in &app.monotonics {
|
||||||
let instants = util::monotonic_instants_ident(name, &monotonic.ident);
|
let instants = util::monotonic_instants_ident(name, &monotonic.ident);
|
||||||
let instants = util::mark_internal_ident(&instants);
|
|
||||||
let mono_type = &monotonic.ty;
|
let mono_type = &monotonic.ty;
|
||||||
|
|
||||||
let uninit = mk_uninit();
|
let uninit = mk_uninit();
|
||||||
|
@ -82,7 +80,6 @@ pub fn codegen(
|
||||||
|
|
||||||
let uninit = mk_uninit();
|
let uninit = mk_uninit();
|
||||||
let inputs_ident = util::inputs_ident(name);
|
let inputs_ident = util::inputs_ident(name);
|
||||||
let inputs_ident = util::mark_internal_ident(&inputs_ident);
|
|
||||||
mod_app.push(quote!(
|
mod_app.push(quote!(
|
||||||
#uninit
|
#uninit
|
||||||
// /// Buffer that holds the inputs of a task
|
// /// Buffer that holds the inputs of a task
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
||||||
|
|
||||||
if !app.monotonics.is_empty() {
|
if !app.monotonics.is_empty() {
|
||||||
// Generate the marker counter used to track for `cancel` and `reschedule`
|
// Generate the marker counter used to track for `cancel` and `reschedule`
|
||||||
let tq_marker = util::mark_internal_ident(&util::timer_queue_marker_ident());
|
let tq_marker = util::timer_queue_marker_ident();
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
// #[doc = #doc]
|
// #[doc = #doc]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
@ -53,11 +53,9 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
||||||
for (_, monotonic) in &app.monotonics {
|
for (_, monotonic) in &app.monotonics {
|
||||||
let monotonic_name = monotonic.ident.to_string();
|
let monotonic_name = monotonic.ident.to_string();
|
||||||
let tq = util::tq_ident(&monotonic_name);
|
let tq = util::tq_ident(&monotonic_name);
|
||||||
let tq = util::mark_internal_ident(&tq);
|
|
||||||
let t = util::schedule_t_ident();
|
let t = util::schedule_t_ident();
|
||||||
let mono_type = &monotonic.ty;
|
let mono_type = &monotonic.ty;
|
||||||
let m_ident = util::monotonic_ident(&monotonic_name);
|
let m_ident = util::monotonic_ident(&monotonic_name);
|
||||||
let m_ident = util::mark_internal_ident(&m_ident);
|
|
||||||
|
|
||||||
// Static variables and resource proxy
|
// Static variables and resource proxy
|
||||||
{
|
{
|
||||||
|
@ -82,7 +80,6 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
||||||
));
|
));
|
||||||
|
|
||||||
let mono = util::monotonic_ident(&monotonic_name);
|
let mono = util::monotonic_ident(&monotonic_name);
|
||||||
let mono = util::mark_internal_ident(&mono);
|
|
||||||
// For future use
|
// For future use
|
||||||
// let doc = &format!("Storage for {}", monotonic_name);
|
// let doc = &format!("Storage for {}", monotonic_name);
|
||||||
|
|
||||||
|
@ -106,7 +103,6 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
||||||
let cfgs = &task.cfgs;
|
let cfgs = &task.cfgs;
|
||||||
let priority = task.args.priority;
|
let priority = task.args.priority;
|
||||||
let rq = util::rq_ident(priority);
|
let rq = util::rq_ident(priority);
|
||||||
let rq = util::mark_internal_ident(&rq);
|
|
||||||
let rqt = util::spawn_t_ident(priority);
|
let rqt = util::spawn_t_ident(priority);
|
||||||
|
|
||||||
// The interrupt that runs the task dispatcher
|
// The interrupt that runs the task dispatcher
|
||||||
|
|
|
@ -7,6 +7,8 @@ use syn::{Attribute, Ident, LitInt, PatType};
|
||||||
|
|
||||||
use crate::check::Extra;
|
use crate::check::Extra;
|
||||||
|
|
||||||
|
const RTIC_INTERNAL: &str = "__rtic_internal";
|
||||||
|
|
||||||
/// Turns `capacity` into an unsuffixed integer literal
|
/// Turns `capacity` into an unsuffixed integer literal
|
||||||
pub fn capacity_literal(capacity: usize) -> LitInt {
|
pub fn capacity_literal(capacity: usize) -> LitInt {
|
||||||
LitInt::new(&capacity.to_string(), Span::call_site())
|
LitInt::new(&capacity.to_string(), Span::call_site())
|
||||||
|
@ -14,7 +16,7 @@ pub fn capacity_literal(capacity: usize) -> LitInt {
|
||||||
|
|
||||||
/// Identifier for the free queue
|
/// Identifier for the free queue
|
||||||
pub fn fq_ident(task: &Ident) -> Ident {
|
pub fn fq_ident(task: &Ident) -> Ident {
|
||||||
Ident::new(&format!("{}_FQ", task.to_string()), Span::call_site())
|
mark_internal_name(&format!("{}_FQ", task.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates a `Mutex` implementation
|
/// Generates a `Mutex` implementation
|
||||||
|
@ -60,15 +62,12 @@ pub fn impl_mutex(
|
||||||
|
|
||||||
/// Generates an identifier for the `INPUTS` buffer (`spawn` & `schedule` API)
|
/// Generates an identifier for the `INPUTS` buffer (`spawn` & `schedule` API)
|
||||||
pub fn inputs_ident(task: &Ident) -> Ident {
|
pub fn inputs_ident(task: &Ident) -> Ident {
|
||||||
Ident::new(&format!("{}_INPUTS", task), Span::call_site())
|
mark_internal_name(&format!("{}_INPUTS", task))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates an identifier for the `INSTANTS` buffer (`schedule` API)
|
/// Generates an identifier for the `INSTANTS` buffer (`schedule` API)
|
||||||
pub fn monotonic_instants_ident(task: &Ident, monotonic: &Ident) -> Ident {
|
pub fn monotonic_instants_ident(task: &Ident, monotonic: &Ident) -> Ident {
|
||||||
Ident::new(
|
mark_internal_name(&format!("{}_{}_INSTANTS", task, monotonic))
|
||||||
&format!("{}_{}_INSTANTS", task, monotonic),
|
|
||||||
Span::call_site(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn interrupt_ident() -> Ident {
|
pub fn interrupt_ident() -> Ident {
|
||||||
|
@ -77,8 +76,7 @@ pub fn interrupt_ident() -> Ident {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn timer_queue_marker_ident() -> Ident {
|
pub fn timer_queue_marker_ident() -> Ident {
|
||||||
let span = Span::call_site();
|
mark_internal_name(&"TIMER_QUEUE_MARKER")
|
||||||
Ident::new("TIMER_QUEUE_MARKER", span)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether `name` is an exception with configurable priority
|
/// Whether `name` is an exception with configurable priority
|
||||||
|
@ -98,38 +96,24 @@ pub fn is_exception(name: &Ident) -> bool {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Mark a name as internal
|
||||||
|
pub fn mark_internal_name(name: &str) -> Ident {
|
||||||
|
Ident::new(&format!("{}_{}", RTIC_INTERNAL, name), Span::call_site())
|
||||||
|
}
|
||||||
|
|
||||||
/// Generate an internal identifier for monotonics
|
/// Generate an internal identifier for monotonics
|
||||||
pub fn internal_monotonics_ident(task: &Ident, monotonic: &Ident, ident_name: &str) -> Ident {
|
pub fn internal_monotonics_ident(task: &Ident, monotonic: &Ident, ident_name: &str) -> Ident {
|
||||||
Ident::new(
|
mark_internal_name(&format!(
|
||||||
&format!(
|
"{}_{}_{}",
|
||||||
"__rtic_internal_{}_{}_{}",
|
task.to_string(),
|
||||||
task.to_string(),
|
monotonic.to_string(),
|
||||||
monotonic.to_string(),
|
ident_name,
|
||||||
ident_name,
|
))
|
||||||
),
|
|
||||||
Span::call_site(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate an internal identifier for tasks
|
/// Generate an internal identifier for tasks
|
||||||
pub fn internal_task_ident(task: &Ident, ident_name: &str) -> Ident {
|
pub fn internal_task_ident(task: &Ident, ident_name: &str) -> Ident {
|
||||||
Ident::new(
|
mark_internal_name(&format!("{}_{}", task.to_string(), ident_name))
|
||||||
&format!("__rtic_internal_{}_{}", task.to_string(), ident_name,),
|
|
||||||
Span::call_site(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Mark an ident as internal
|
|
||||||
pub fn mark_internal_ident(ident: &Ident) -> Ident {
|
|
||||||
Ident::new(
|
|
||||||
&format!("__rtic_internal_{}", ident.to_string()),
|
|
||||||
Span::call_site(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Mark an ident as internal
|
|
||||||
pub fn mark_internal_name(name: &str) -> Ident {
|
|
||||||
Ident::new(&format!("__rtic_internal_{}", name), Span::call_site())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn link_section_index() -> usize {
|
fn link_section_index() -> usize {
|
||||||
|
@ -215,7 +199,7 @@ pub fn shared_resources_ident(ctxt: Context, app: &App) -> Ident {
|
||||||
|
|
||||||
s.push_str("SharedResources");
|
s.push_str("SharedResources");
|
||||||
|
|
||||||
Ident::new(&s, Span::call_site())
|
mark_internal_name(&s)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates a pre-reexport identifier for the "local resources" struct
|
/// Generates a pre-reexport identifier for the "local resources" struct
|
||||||
|
@ -228,7 +212,7 @@ pub fn local_resources_ident(ctxt: Context, app: &App) -> Ident {
|
||||||
|
|
||||||
s.push_str("LocalResources");
|
s.push_str("LocalResources");
|
||||||
|
|
||||||
Ident::new(&s, Span::call_site())
|
mark_internal_name(&s)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates an identifier for a ready queue
|
/// Generates an identifier for a ready queue
|
||||||
|
@ -236,7 +220,7 @@ pub fn local_resources_ident(ctxt: Context, app: &App) -> Ident {
|
||||||
/// There may be several task dispatchers, one for each priority level.
|
/// There may be several task dispatchers, one for each priority level.
|
||||||
/// The ready queues are SPSC queues
|
/// The ready queues are SPSC queues
|
||||||
pub fn rq_ident(priority: u8) -> Ident {
|
pub fn rq_ident(priority: u8) -> Ident {
|
||||||
Ident::new(&format!("P{}_RQ", priority), Span::call_site())
|
mark_internal_name(&format!("P{}_RQ", priority))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates an identifier for the `enum` of `schedule`-able tasks
|
/// Generates an identifier for the `enum` of `schedule`-able tasks
|
||||||
|
@ -260,33 +244,28 @@ pub fn suffixed(name: &str) -> Ident {
|
||||||
|
|
||||||
/// Generates an identifier for a timer queue
|
/// Generates an identifier for a timer queue
|
||||||
pub fn tq_ident(name: &str) -> Ident {
|
pub fn tq_ident(name: &str) -> Ident {
|
||||||
Ident::new(&format!("TQ_{}", name), Span::call_site())
|
mark_internal_name(&format!("TQ_{}", name))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates an identifier for monotonic timer storage
|
/// Generates an identifier for monotonic timer storage
|
||||||
pub fn monotonic_ident(name: &str) -> Ident {
|
pub fn monotonic_ident(name: &str) -> Ident {
|
||||||
Ident::new(&format!("MONOTONIC_STORAGE_{}", name), Span::call_site())
|
mark_internal_name(&format!("MONOTONIC_STORAGE_{}", name))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_shared_resource_ident(name: &Ident) -> Ident {
|
pub fn static_shared_resource_ident(name: &Ident) -> Ident {
|
||||||
Ident::new(
|
mark_internal_name(&format!("shared_resource_{}", name.to_string()))
|
||||||
&format!("shared_resource_{}", name.to_string()),
|
|
||||||
Span::call_site(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_local_resource_ident(name: &Ident) -> Ident {
|
pub fn static_local_resource_ident(name: &Ident) -> Ident {
|
||||||
Ident::new(
|
mark_internal_name(&format!("local_resource_{}", name.to_string()))
|
||||||
&format!("local_resource_{}", name.to_string()),
|
|
||||||
Span::call_site(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn declared_static_local_resource_ident(name: &Ident, task_name: &Ident) -> Ident {
|
pub fn declared_static_local_resource_ident(name: &Ident, task_name: &Ident) -> Ident {
|
||||||
Ident::new(
|
mark_internal_name(&format!(
|
||||||
&format!("local_{}_{}", task_name.to_string(), name.to_string()),
|
"local_{}_{}",
|
||||||
Span::call_site(),
|
task_name.to_string(),
|
||||||
)
|
name.to_string()
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The name to get better RT flag errors
|
/// The name to get better RT flag errors
|
||||||
|
|
Loading…
Reference in a new issue