mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-12-25 19:39:32 +01:00
wip Priority leakage
This commit is contained in:
parent
4a8b0cd787
commit
8050304c9d
3 changed files with 33 additions and 26 deletions
|
@ -85,10 +85,10 @@ pub fn codegen(
|
||||||
mod_app.push(util::impl_mutex(
|
mod_app.push(util::impl_mutex(
|
||||||
extra,
|
extra,
|
||||||
cfgs,
|
cfgs,
|
||||||
true,
|
quote!(shared_resources::#name),
|
||||||
&name,
|
|
||||||
quote!(#ty),
|
quote!(#ty),
|
||||||
ceiling,
|
ceiling,
|
||||||
|
quote!(self.priority()),
|
||||||
ptr,
|
ptr,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ pub fn codegen(
|
||||||
let mut fields_mut = vec![];
|
let mut fields_mut = vec![];
|
||||||
let mut values_mut = vec![];
|
let mut values_mut = vec![];
|
||||||
let mut max_ceiling = 0;
|
let mut max_ceiling = 0;
|
||||||
|
let mut field_get_prio = None;
|
||||||
|
|
||||||
for (name, access) in resources {
|
for (name, access) in resources {
|
||||||
let res = app.shared_resources.get(name).expect("UNREACHABLE");
|
let res = app.shared_resources.get(name).expect("UNREACHABLE");
|
||||||
|
@ -63,6 +64,10 @@ pub fn codegen(
|
||||||
pub #name: shared_resources::#name<'a>
|
pub #name: shared_resources::#name<'a>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
field_get_prio = Some(quote!(
|
||||||
|
#name
|
||||||
|
));
|
||||||
|
|
||||||
values.push(quote!(
|
values.push(quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
#name: shared_resources::#name::new(priority)
|
#name: shared_resources::#name::new(priority)
|
||||||
|
@ -148,7 +153,6 @@ pub fn codegen(
|
||||||
#[doc = #doc]
|
#[doc = #doc]
|
||||||
pub struct #ident<#lt> {
|
pub struct #ident<#lt> {
|
||||||
#(#fields,)*
|
#(#fields,)*
|
||||||
priority: &'a rtic::export::Priority,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used by the lock-all API
|
// Used by the lock-all API
|
||||||
|
@ -166,16 +170,29 @@ pub fn codegen(
|
||||||
Some(quote!(priority: &#lt rtic::export::Priority))
|
Some(quote!(priority: &#lt rtic::export::Priority))
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generate code for the lock-all API
|
let (lock_all, get_prio) = if let Some(name) = field_get_prio {
|
||||||
let lock_all = util::impl_mutex(
|
(
|
||||||
extra,
|
util::impl_mutex(
|
||||||
&vec![], // TODO: what cfg should go here?
|
extra,
|
||||||
false, // resource proxy at top level (not in shared_resources)
|
&vec![], // TODO: what cfg should go here?
|
||||||
&ident,
|
quote!(#ident),
|
||||||
quote!(#ident_mut),
|
quote!(#ident_mut),
|
||||||
max_ceiling,
|
max_ceiling,
|
||||||
quote!(&mut #ident_mut::new()),
|
quote!(self.priority()),
|
||||||
);
|
quote!(&mut #ident_mut::new()),
|
||||||
|
),
|
||||||
|
quote!(
|
||||||
|
// Used by the lock-all API
|
||||||
|
#[inline(always)]
|
||||||
|
pub unsafe fn priority(&self) -> &rtic::export::Priority {
|
||||||
|
//panic!("here {:?}", self);
|
||||||
|
self.#name.priority()
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
(quote!(), quote!())
|
||||||
|
};
|
||||||
|
|
||||||
let implementations = quote!(
|
let implementations = quote!(
|
||||||
impl<#lt> #ident<#lt> {
|
impl<#lt> #ident<#lt> {
|
||||||
|
@ -183,14 +200,10 @@ pub fn codegen(
|
||||||
pub unsafe fn new(#arg) -> Self {
|
pub unsafe fn new(#arg) -> Self {
|
||||||
#ident {
|
#ident {
|
||||||
#(#values,)*
|
#(#values,)*
|
||||||
priority
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#get_prio
|
||||||
pub unsafe fn priority(&self) -> &rtic::export::Priority {
|
|
||||||
self.priority
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used by the lock-all API
|
// Used by the lock-all API
|
||||||
|
|
|
@ -23,18 +23,12 @@ pub fn fq_ident(task: &Ident) -> Ident {
|
||||||
pub fn impl_mutex(
|
pub fn impl_mutex(
|
||||||
extra: &Extra,
|
extra: &Extra,
|
||||||
cfgs: &[Attribute],
|
cfgs: &[Attribute],
|
||||||
resources_prefix: bool,
|
path: TokenStream2,
|
||||||
name: &Ident,
|
|
||||||
ty: TokenStream2,
|
ty: TokenStream2,
|
||||||
ceiling: u8,
|
ceiling: u8,
|
||||||
|
priority: TokenStream2,
|
||||||
ptr: TokenStream2,
|
ptr: TokenStream2,
|
||||||
) -> TokenStream2 {
|
) -> TokenStream2 {
|
||||||
let (path, priority) = if resources_prefix {
|
|
||||||
(quote!(shared_resources::#name), quote!(self.priority()))
|
|
||||||
} else {
|
|
||||||
(quote!(#name), quote!(self.priority))
|
|
||||||
};
|
|
||||||
|
|
||||||
let device = &extra.device;
|
let device = &extra.device;
|
||||||
quote!(
|
quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
|
|
Loading…
Reference in a new issue