aboutsummaryrefslogtreecommitdiff
path: root/macros/src
diff options
context:
space:
mode:
Diffstat (limited to 'macros/src')
-rw-r--r--macros/src/codegen.rs1
-rw-r--r--macros/src/codegen/dispatchers.rs6
-rw-r--r--macros/src/codegen/local_resources.rs9
-rw-r--r--macros/src/codegen/local_resources_struct.rs8
-rw-r--r--macros/src/codegen/module.rs23
-rw-r--r--macros/src/codegen/post_init.rs5
-rw-r--r--macros/src/codegen/pre_init.rs11
-rw-r--r--macros/src/codegen/shared_resources.rs3
-rw-r--r--macros/src/codegen/shared_resources_struct.rs4
-rw-r--r--macros/src/codegen/software_tasks.rs9
-rw-r--r--macros/src/codegen/timer_queue.rs24
-rw-r--r--macros/src/codegen/util.rs81
12 files changed, 76 insertions, 108 deletions
diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs
index 6920031a..63a4e3ca 100644
--- a/macros/src/codegen.rs
+++ b/macros/src/codegen.rs
@@ -108,7 +108,6 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
let name = &monotonic.ident;
let name_str = &name.to_string();
let ident = util::monotonic_ident(&name_str);
- let ident = util::mark_internal_ident(&ident);
let panic_str = &format!(
"Use of monotonic '{}' before it was passed to the runtime",
name_str
diff --git a/macros/src/codegen/dispatchers.rs b/macros/src/codegen/dispatchers.rs
index c239b0f8..57103acd 100644
--- a/macros/src/codegen/dispatchers.rs
+++ b/macros/src/codegen/dispatchers.rs
@@ -33,6 +33,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
// );
let t = util::spawn_t_ident(level);
items.push(quote!(
+ #[allow(non_snake_case)]
#[allow(non_camel_case_types)]
#[derive(Clone, Copy)]
// #[doc = #doc]
@@ -44,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 rq = util::rq_ident(level);
- let rq = util::mark_internal_ident(&rq);
let (rq_ty, rq_expr) = {
(
quote!(rtic::export::SCRQ<#t, #n>),
@@ -59,6 +59,8 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
// );
items.push(quote!(
#[doc(hidden)]
+ #[allow(non_camel_case_types)]
+ #[allow(non_upper_case_globals)]
static #rq: rtic::RacyCell<#rq_ty> = rtic::RacyCell::new(#rq_expr);
));
@@ -69,9 +71,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
let task = &app.software_tasks[name];
let cfgs = &task.cfgs;
let fq = util::fq_ident(name);
- let fq = util::mark_internal_ident(&fq);
let inputs = util::inputs_ident(name);
- let inputs = util::mark_internal_ident(&inputs);
let (_, tupled, pats, _) = util::regroup_inputs(&task.inputs);
quote!(
diff --git a/macros/src/codegen/local_resources.rs b/macros/src/codegen/local_resources.rs
index a9ffa925..ff534862 100644
--- a/macros/src/codegen/local_resources.rs
+++ b/macros/src/codegen/local_resources.rs
@@ -24,7 +24,7 @@ pub fn codegen(
for (name, res) in &app.local_resources {
let cfgs = &res.cfgs;
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;
// late resources in `util::link_section_uninit`
@@ -33,6 +33,7 @@ pub fn codegen(
// For future use
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
mod_app.push(quote!(
+ #[allow(non_camel_case_types)]
#[allow(non_upper_case_globals)]
// #[doc = #doc]
#[doc(hidden)]
@@ -50,14 +51,12 @@ pub fn codegen(
let expr = &task_local.expr;
let attrs = &task_local.attrs;
- let mangled_name = util::mark_internal_ident(&util::declared_static_local_resource_ident(
- resource_name,
- &task_name,
- ));
+ let mangled_name = util::declared_static_local_resource_ident(resource_name, &task_name);
// For future use
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
mod_app.push(quote!(
+ #[allow(non_camel_case_types)]
#[allow(non_upper_case_globals)]
// #[doc = #doc]
#[doc(hidden)]
diff --git a/macros/src/codegen/local_resources_struct.rs b/macros/src/codegen/local_resources_struct.rs
index 4bd9e2a4..cdbfccca 100644
--- a/macros/src/codegen/local_resources_struct.rs
+++ b/macros/src/codegen/local_resources_struct.rs
@@ -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) {
- util::mark_internal_ident(&util::static_local_resource_ident(name))
+ util::static_local_resource_ident(name)
} else {
- util::mark_internal_ident(&util::declared_static_local_resource_ident(
- name, &task_name,
- ))
+ util::declared_static_local_resource_ident(name, &task_name)
};
fields.push(quote!(
@@ -86,9 +84,9 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
let doc = format!("Local resources `{}` has access to", ctxt.ident(app));
let ident = util::local_resources_ident(ctxt, app);
- let ident = util::mark_internal_ident(&ident);
let item = quote!(
#[allow(non_snake_case)]
+ #[allow(non_camel_case_types)]
#[doc = #doc]
pub struct #ident<#lt> {
#(#fields,)*
diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs
index c7092bd3..4db2c0c2 100644
--- a/macros/src/codegen/module.rs
+++ b/macros/src/codegen/module.rs
@@ -67,7 +67,6 @@ pub fn codegen(
if ctxt.has_local_resources(app) {
let ident = util::local_resources_ident(ctxt, app);
- let ident = util::mark_internal_ident(&ident);
let lt = if local_resources_tick {
lt = Some(quote!('a));
Some(quote!('a))
@@ -90,7 +89,6 @@ pub fn codegen(
if ctxt.has_shared_resources(app) {
let ident = util::shared_resources_ident(ctxt, app);
- let ident = util::mark_internal_ident(&ident);
let lt = if shared_resources_tick {
lt = Some(quote!('a));
Some(quote!('a))
@@ -131,6 +129,7 @@ pub fn codegen(
items.push(quote!(
/// Monotonics used by the system
#[allow(non_snake_case)]
+ #[allow(non_camel_case_types)]
pub struct #internal_monotonics_ident(
#(pub #monotonic_types),*
);
@@ -178,6 +177,8 @@ pub fn codegen(
items.push(quote!(
#(#cfgs)*
/// Execution context
+ #[allow(non_snake_case)]
+ #[allow(non_camel_case_types)]
pub struct #internal_context_name<#lt> {
#(#fields,)*
}
@@ -209,11 +210,8 @@ pub fn codegen(
let args = &args;
let tupled = &tupled;
let fq = util::fq_ident(name);
- let fq = util::mark_internal_ident(&fq);
let rq = util::rq_ident(priority);
- let rq = util::mark_internal_ident(&rq);
let inputs = util::inputs_ident(name);
- let inputs = util::mark_internal_ident(&inputs);
let device = &extra.device;
let enum_ = util::interrupt_ident();
@@ -263,16 +261,13 @@ pub fn codegen(
// Schedule caller
for (_, monotonic) in &app.monotonics {
let instants = util::monotonic_instants_ident(name, &monotonic.ident);
- let instants = util::mark_internal_ident(&instants);
let monotonic_name = 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 m = &monotonic.ident;
let mono_type = &monotonic.ident;
let m_ident = util::monotonic_ident(&monotonic_name);
- let m_ident = util::mark_internal_ident(&m_ident);
let m_isr = &monotonic.args.binds;
let enum_ = util::interrupt_ident();
@@ -290,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
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
@@ -318,6 +313,8 @@ pub fn codegen(
items.push(quote!(
#(#cfgs)*
+ #[allow(non_snake_case)]
+ #[allow(non_camel_case_types)]
pub struct #internal_spawn_handle_ident {
#[doc(hidden)]
marker: u32,
@@ -327,7 +324,7 @@ pub fn codegen(
impl #internal_spawn_handle_ident {
pub fn cancel(self) -> Result<#ty, ()> {
rtic::export::interrupt::free(|_| unsafe {
- let tq = &mut *#tq.get_mut_unchecked().as_mut_ptr();
+ let tq = #tq.get_mut_unchecked();
if let Some((_task, index)) = tq.cancel_marker(self.marker) {
// Get the message
let msg = #inputs
@@ -359,7 +356,7 @@ pub fn codegen(
let marker = *#tq_marker.get_mut_unchecked();
*#tq_marker.get_mut_unchecked() = #tq_marker.get_mut_unchecked().wrapping_add(1);
- let tq = &mut *#tq.get_mut_unchecked().as_mut_ptr();
+ let tq = #tq.get_mut_unchecked();
tq.update_marker(self.marker, marker, instant, || #pend).map(|_| #name::#m::SpawnHandle { marker })
})
@@ -371,6 +368,7 @@ pub fn codegen(
///
/// This will use the time `Instant::new(0)` as baseline if called in `#[init]`,
/// so if you use a non-resetable timer use `spawn_at` when in `#[init]`
+ #[allow(non_snake_case)]
pub fn #internal_spawn_after_ident<D>(
duration: D
#(,#args)*
@@ -390,6 +388,7 @@ pub fn codegen(
#(#cfgs)*
/// Spawns the task at a fixed time instant
+ #[allow(non_snake_case)]
pub fn #internal_spawn_at_ident(
instant: rtic::time::Instant<#mono_type>
#(,#args)*
@@ -420,7 +419,7 @@ pub fn codegen(
*#tq_marker.get_mut_unchecked() = #tq_marker.get_mut_unchecked().wrapping_add(1);
- let tq = &mut *#tq.get_mut_unchecked().as_mut_ptr();
+ let tq = #tq.get_mut_unchecked();
tq.enqueue_unchecked(
nr,
diff --git a/macros/src/codegen/post_init.rs b/macros/src/codegen/post_init.rs
index 161068d2..5624b20a 100644
--- a/macros/src/codegen/post_init.rs
+++ b/macros/src/codegen/post_init.rs
@@ -11,7 +11,7 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
// Initialize 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
let cfgs = res.cfgs.clone();
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
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
let cfgs = res.cfgs.clone();
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
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);));
}
diff --git a/macros/src/codegen/pre_init.rs b/macros/src/codegen/pre_init.rs
index ae628f6e..d3c4f54d 100644
--- a/macros/src/codegen/pre_init.rs
+++ b/macros/src/codegen/pre_init.rs
@@ -17,7 +17,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
for (name, task) in &app.software_tasks {
let cap = task.args.capacity;
let fq_ident = util::fq_ident(name);
- let fq_ident = util::mark_internal_ident(&fq_ident);
stmts.push(quote!(
(0..#cap).for_each(|i| #fq_ident.get_mut_unchecked().enqueue_unchecked(i));
@@ -77,18 +76,10 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
);));
}
- // Initialize monotonic's interrupts and timer queues
+ // Initialize monotonic's interrupts
for (_, monotonic) in &app.monotonics {
let priority = &monotonic.args.priority;
let binds = &monotonic.args.binds;
- let monotonic_name = monotonic.ident.to_string();
- let tq = util::tq_ident(&monotonic_name);
- let tq = util::mark_internal_ident(&tq);
-
- // Initialize timer queues
- stmts.push(
- quote!(#tq.get_mut_unchecked().as_mut_ptr().write(rtic::export::TimerQueue::new());),
- );
// Compile time assert that this priority is supported by the device
stmts.push(quote!(let _ = [(); ((1 << #nvic_prio_bits) - #priority as usize)];));
diff --git a/macros/src/codegen/shared_resources.rs b/macros/src/codegen/shared_resources.rs
index 181832fd..07f8c36a 100644
--- a/macros/src/codegen/shared_resources.rs
+++ b/macros/src/codegen/shared_resources.rs
@@ -21,7 +21,7 @@ pub fn codegen(
for (name, res) in &app.shared_resources {
let cfgs = &res.cfgs;
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`
let section = util::link_section_uninit();
@@ -30,6 +30,7 @@ pub fn codegen(
// For future use
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
mod_app.push(quote!(
+ #[allow(non_camel_case_types)]
#[allow(non_upper_case_globals)]
// #[doc = #doc]
#[doc(hidden)]
diff --git a/macros/src/codegen/shared_resources_struct.rs b/macros/src/codegen/shared_resources_struct.rs
index 301bef73..5a805412 100644
--- a/macros/src/codegen/shared_resources_struct.rs
+++ b/macros/src/codegen/shared_resources_struct.rs
@@ -32,7 +32,7 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
None
};
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 access.is_shared() {
@@ -102,9 +102,9 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
let doc = format!("Shared resources `{}` has access to", ctxt.ident(app));
let ident = util::shared_resources_ident(ctxt, app);
- let ident = util::mark_internal_ident(&ident);
let item = quote!(
#[allow(non_snake_case)]
+ #[allow(non_camel_case_types)]
#[doc = #doc]
pub struct #ident<#lt> {
#(#fields,)*
diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs
index 0b073359..1669a3fb 100644
--- a/macros/src/codegen/software_tasks.rs
+++ b/macros/src/codegen/software_tasks.rs
@@ -37,7 +37,6 @@ pub fn codegen(
// Create free queues and inputs / instants buffers
let fq = util::fq_ident(name);
- let fq = util::mark_internal_ident(&fq);
let (fq_ty, fq_expr, mk_uninit): (_, _, Box<dyn Fn() -> Option<_>>) = {
(
@@ -49,6 +48,8 @@ pub fn codegen(
mod_app.push(quote!(
// /// Queue version of a free-list that keeps track of empty slots in
// /// the following buffers
+ #[allow(non_camel_case_types)]
+ #[allow(non_upper_case_globals)]
#[doc(hidden)]
static #fq: rtic::RacyCell<#fq_ty> = rtic::RacyCell::new(#fq_expr);
));
@@ -59,7 +60,6 @@ pub fn codegen(
for (_, monotonic) in &app.monotonics {
let instants = util::monotonic_instants_ident(name, &monotonic.ident);
- let instants = util::mark_internal_ident(&instants);
let mono_type = &monotonic.ty;
let uninit = mk_uninit();
@@ -69,6 +69,8 @@ pub fn codegen(
#uninit
// /// Buffer that holds the instants associated to the inputs of a task
// #[doc = #doc]
+ #[allow(non_camel_case_types)]
+ #[allow(non_upper_case_globals)]
#[doc(hidden)]
static #instants:
rtic::RacyCell<[core::mem::MaybeUninit<rtic::time::Instant<#mono_type>>; #cap_lit]> =
@@ -78,10 +80,11 @@ pub fn codegen(
let uninit = mk_uninit();
let inputs_ident = util::inputs_ident(name);
- let inputs_ident = util::mark_internal_ident(&inputs_ident);
mod_app.push(quote!(
#uninit
// /// Buffer that holds the inputs of a task
+ #[allow(non_camel_case_types)]
+ #[allow(non_upper_case_globals)]
#[doc(hidden)]
static #inputs_ident: rtic::RacyCell<[core::mem::MaybeUninit<#input_ty>; #cap_lit]> =
rtic::RacyCell::new([#(#elems,)*]);
diff --git a/macros/src/codegen/timer_queue.rs b/macros/src/codegen/timer_queue.rs
index abddbadc..fdfa6381 100644
--- a/macros/src/codegen/timer_queue.rs
+++ b/macros/src/codegen/timer_queue.rs
@@ -10,11 +10,12 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
if !app.monotonics.is_empty() {
// 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!(
// #[doc = #doc]
#[doc(hidden)]
#[allow(non_camel_case_types)]
+ #[allow(non_upper_case_globals)]
static #tq_marker: rtic::RacyCell<u32> = rtic::RacyCell::new(0);
));
@@ -52,40 +53,40 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
for (_, monotonic) in &app.monotonics {
let monotonic_name = monotonic.ident.to_string();
let tq = util::tq_ident(&monotonic_name);
- let tq = util::mark_internal_ident(&tq);
let t = util::schedule_t_ident();
let mono_type = &monotonic.ty;
let m_ident = util::monotonic_ident(&monotonic_name);
- let m_ident = util::mark_internal_ident(&m_ident);
// Static variables and resource proxy
{
// For future use
// let doc = &format!("Timer queue for {}", monotonic_name);
- let cap: u8 = app
+ let cap: usize = app
.software_tasks
.iter()
- .map(|(_name, task)| task.args.capacity)
+ .map(|(_name, task)| task.args.capacity as usize)
.sum();
- let n = util::capacity_literal(cap as usize);
- let tq_ty =
- quote!(core::mem::MaybeUninit<rtic::export::TimerQueue<#mono_type, #t, #n>>);
+ let n = util::capacity_literal(cap);
+ let tq_ty = quote!(rtic::export::TimerQueue<#mono_type, #t, #n>);
// For future use
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
items.push(quote!(
#[doc(hidden)]
+ #[allow(non_camel_case_types)]
+ #[allow(non_upper_case_globals)]
static #tq: rtic::RacyCell<#tq_ty> =
- rtic::RacyCell::new(core::mem::MaybeUninit::uninit());
+ rtic::RacyCell::new(rtic::export::TimerQueue(rtic::export::SortedLinkedList::new_u16()));
));
let mono = util::monotonic_ident(&monotonic_name);
- let mono = util::mark_internal_ident(&mono);
// For future use
// let doc = &format!("Storage for {}", monotonic_name);
items.push(quote!(
#[doc(hidden)]
+ #[allow(non_camel_case_types)]
+ #[allow(non_upper_case_globals)]
static #mono: rtic::RacyCell<Option<#mono_type>> = rtic::RacyCell::new(None);
));
}
@@ -102,7 +103,6 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
let cfgs = &task.cfgs;
let priority = task.args.priority;
let rq = util::rq_ident(priority);
- let rq = util::mark_internal_ident(&rq);
let rqt = util::spawn_t_ident(priority);
// The interrupt that runs the task dispatcher
@@ -138,7 +138,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
unsafe fn #bound_interrupt() {
while let Some((task, index)) = rtic::export::interrupt::free(|_|
if let Some(mono) = #m_ident.get_mut_unchecked().as_mut() {
- (&mut *#tq.get_mut_unchecked().as_mut_ptr()).dequeue(|| #disable_isr, mono)
+ #tq.get_mut_unchecked().dequeue(|| #disable_isr, mono)
} else {
// We can only use the timer queue if `init` has returned, and it
// writes the `Some(monotonic)` we are accessing here.
diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs
index c2330d46..8e40ad61 100644
--- a/macros/src/codegen/util.rs
+++ b/macros/src/codegen/util.rs
@@ -7,6 +7,8 @@ use syn::{Attribute, Ident, LitInt, PatType};
use crate::check::Extra;
+const RTIC_INTERNAL: &str = "__rtic_internal";
+
/// Turns `capacity` into an unsuffixed integer literal
pub fn capacity_literal(capacity: usize) -> LitInt {
LitInt::new(&capacity.to_string(), Span::call_site())
@@ -14,7 +16,7 @@ pub fn capacity_literal(capacity: usize) -> LitInt {
/// Identifier for the free queue
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
@@ -60,15 +62,12 @@ pub fn impl_mutex(
/// Generates an identifier for the `INPUTS` buffer (`spawn` & `schedule` API)
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)
pub fn monotonic_instants_ident(task: &Ident, monotonic: &Ident) -> Ident {
- Ident::new(
- &format!("{}_{}_INSTANTS", task, monotonic),
- Span::call_site(),
- )
+ mark_internal_name(&format!("{}_{}_INSTANTS", task, monotonic))
}
pub fn interrupt_ident() -> Ident {
@@ -77,8 +76,7 @@ pub fn interrupt_ident() -> Ident {
}
pub fn timer_queue_marker_ident() -> Ident {
- let span = Span::call_site();
- Ident::new("TIMER_QUEUE_MARKER", span)
+ mark_internal_name(&"TIMER_QUEUE_MARKER")
}
/// 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
pub fn internal_monotonics_ident(task: &Ident, monotonic: &Ident, ident_name: &str) -> Ident {
- Ident::new(
- &format!(
- "__rtic_internal_{}_{}_{}",
- task.to_string(),
- monotonic.to_string(),
- ident_name,
- ),
- Span::call_site(),
- )
+ mark_internal_name(&format!(
+ "{}_{}_{}",
+ task.to_string(),
+ monotonic.to_string(),
+ ident_name,
+ ))
}
/// Generate an internal identifier for tasks
pub fn internal_task_ident(task: &Ident, ident_name: &str) -> Ident {
- Ident::new(
- &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())
+ mark_internal_name(&format!("{}_{}", task.to_string(), ident_name))
}
fn link_section_index() -> usize {
@@ -215,7 +199,7 @@ pub fn shared_resources_ident(ctxt: Context, app: &App) -> Ident {
s.push_str("SharedResources");
- Ident::new(&s, Span::call_site())
+ mark_internal_name(&s)
}
/// 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");
- Ident::new(&s, Span::call_site())
+ mark_internal_name(&s)
}
/// 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.
/// The ready queues are SPSC queues
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
@@ -260,33 +244,28 @@ pub fn suffixed(name: &str) -> Ident {
/// Generates an identifier for a timer queue
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
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 {
- Ident::new(
- &format!("shared_resource_{}", name.to_string()),
- Span::call_site(),
- )
+ mark_internal_name(&format!("shared_resource_{}", name.to_string()))
}
pub fn static_local_resource_ident(name: &Ident) -> Ident {
- Ident::new(
- &format!("local_resource_{}", name.to_string()),
- Span::call_site(),
- )
+ mark_internal_name(&format!("local_resource_{}", name.to_string()))
}
pub fn declared_static_local_resource_ident(name: &Ident, task_name: &Ident) -> Ident {
- Ident::new(
- &format!("local_{}_{}", task_name.to_string(), name.to_string()),
- Span::call_site(),
- )
+ mark_internal_name(&format!(
+ "local_{}_{}",
+ task_name.to_string(),
+ name.to_string()
+ ))
}
/// The name to get better RT flag errors