fn impl_mutex(
    cfgs: &[Attribute],
    cfg_core: Option<proc_macro2::TokenStream>,
    resources_prefix: bool,
    name: &Ident,
    ty: proc_macro2::TokenStream,
    ceiling: u8,
    ptr: proc_macro2::TokenStream,
) -> proc_macro2::TokenStream {
    let path = if resources_prefix {
        quote!(resources::#name)
    } else {
        quote!(#name)
    };

    let priority = if resources_prefix {
        quote!(self.priority())
    } else {
        quote!(self.priority)
    };

    quote!(
        #(#cfgs)*
        #cfg_core
        impl<'a> rtfm::Mutex for #path<'a> {
            type T = #ty;

            #[inline(always)]
            fn lock<R>(&mut self, f: impl FnOnce(&mut #ty) -> R) -> R {
                /// Priority ceiling
                const CEILING: u8 = #ceiling;

                unsafe {
                    rtfm::export::lock(
                        #ptr,
                        #priority,
                        CEILING,
                        f,
                    )
                }
            }
        }
    )
}
/// Creates a `Mutex` implementation
Creates a `Mutex` implementation
Creates a ` Mutex ` implementation
fn impl_mutex(
    cfgs: &[Attribute],
    cfg_core: Option<proc_macro2::TokenStream>,
    resources_prefix: bool,
    name: &Ident,
    ty: proc_macro2::TokenStream,
    ceiling: u8,
    ptr: proc_macro2::TokenStream,
) -> proc_macro2::TokenStream {
    let path = if resources_prefix {
        quote!(resources::#name)
    } else {
        quote!(#name)
    };
    let priority = if resources_prefix {
        quote!(self.priority())
    } else {
        quote!(self.priority)
    };
    quote!(
        #(#cfgs)*
        #cfg_core
        impl<'a> rtfm::Mutex for #path<'a> {
            type T = #ty;
            #[inline(always)]
            fn lock<R>(&mut self, f: impl FnOnce(&mut #ty) -> R) -> R {
                /// Priority ceiling
                const CEILING: u8 = #ceiling;
                unsafe {
                    rtfm::export::lock(
                        #ptr,
                        #priority,
                        CEILING,
                        f,
                    )
                }
            }
        }
    )
}
fn impl_mutex ( cfgs : & [ Attribute ] , cfg_core : Option < proc_macro2 :: TokenStream > , resources_prefix : bool , name : & Ident , ty : proc_macro2 :: TokenStream , ceiling : u8 , ptr : proc_macro2 :: TokenStream , ) -> proc_macro2 :: TokenStream { let path = if resources_prefix { quote ! ( resources name ) } else { quote ! ( name ) } ; let priority = if resources_prefix { quote ! ( self priority ( ) ) } else { quote ! ( self priority ) } ; quote ! ( ( cfgs ) cfg_core impl ' a rtfm Mutex for path ' a { type T ty [ inline ( always ) ] fn lock R ( mut self f impl FnOnce ( mut ty ) R ) R { /// Priority ceiling const CEILING u8 ceiling unsafe { rtfm export lock ( ptr priority CEILING f ) } } } ) }
Creates a `Mutex` implementation
Creates a ` Mutex ` implementation
cfgs
&[Attribute]
cfg_core
Option<proc_macro2::TokenStream>
resources_prefix
bool
name
&Ident
ty
proc_macro2::TokenStream
ceiling
u8
ptr
proc_macro2::TokenStream
cfgs
&[Attribute]
cfg_core
Option<proc_macro2::TokenStream>
resources_prefix
bool
name
&Ident
ty
proc_macro2::TokenStream
ceiling
u8
ptr
proc_macro2::TokenStream