From fc1c9bda3fcb5070a2b22f3fc5c1d81a0ff051f6 Mon Sep 17 00:00:00 2001 From: Per Lindgren Date: Thu, 11 Mar 2021 22:59:16 +0100 Subject: [PATCH] task_lockal wip --- macros/src/codegen/locals.rs | 4 ++-- macros/src/codegen/resources.rs | 3 +++ macros/src/codegen/resources_struct.rs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/macros/src/codegen/locals.rs b/macros/src/codegen/locals.rs index 5725a1513f..0ff56f5982 100644 --- a/macros/src/codegen/locals.rs +++ b/macros/src/codegen/locals.rs @@ -50,7 +50,7 @@ pub fn codegen( items.push(quote!( #(#cfgs)* #[doc(hidden)] - static mut #name: #ty = #expr + static #name: rtic::RacyCell<#ty> = rtic::RacyCell::new(#expr) )); values.push(quote!( #(#cfgs)* @@ -64,7 +64,7 @@ pub fn codegen( } if lt.is_some() && has_cfgs { - fields.push(quote!(__marker__: core::marker::PhantomData<&'a mut ()>)); + fields.push(quote!(__marker__: core::marker::PhantomData<&'a ()>)); values.push(quote!(__marker__: core::marker::PhantomData)); } diff --git a/macros/src/codegen/resources.rs b/macros/src/codegen/resources.rs index 89f70f8402..68eea4d24d 100644 --- a/macros/src/codegen/resources.rs +++ b/macros/src/codegen/resources.rs @@ -66,8 +66,11 @@ pub fn codegen( } let r_prop = &res.properties; + let doc = format!(" RTIC internal: {}:{}", file!(), line!()); + if !r_prop.task_local && !r_prop.lock_free { mod_resources.push(quote!( + #[doc = #doc] #[allow(non_camel_case_types)] #(#cfgs)* pub struct #name<'a> { diff --git a/macros/src/codegen/resources_struct.rs b/macros/src/codegen/resources_struct.rs index 8ed8a2912c..6a21c3197c 100644 --- a/macros/src/codegen/resources_struct.rs +++ b/macros/src/codegen/resources_struct.rs @@ -79,7 +79,7 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2, let is_late = expr.is_none(); if is_late { let expr = if access.is_exclusive() { - quote!(&mut *#mangled_name.as_mut_ptr()) + quote!(&mut *#mangled_name.get_mut_unchecked().as_mut_ptr()) } else { quote!(&*#mangled_name.as_ptr()) };