fn generate_native_is_enabled(&self, provider: &ProviderTraitGenerator) -> TokenStream {
        //The only exception to the `providername-providerhash` naming convention is the semaphore,
        //because the C tracing macros make assumptions about its name based on the provider and
        //probe names.  Fortunately even if there is a collission here, it won't result in any UB;
        //it just means a probe might think it's enabled when it's not, leading to a slightly
        //inefficient call into the wrapper function which will end up being a no-op
        assert!(provider.build_info.implementation != TracingImplementation::Disabled);
        let is_real = provider
            .build_info
            .implementation
            .tracing_target()
            .is_enabled();
        let provider_name = provider.spec.name();

        let native_func_name = format!("{}_{}_enabled", provider_name, self.spec.name);
        let func_name = format!("{}_enabled", self.spec.name);
        let func_ident = syn::Ident::new(&func_name, self.spec.original_method.span());

        match provider.build_info.implementation.tracing_target() {
            TracingTarget::Disabled | TracingTarget::Stap | TracingTarget::NoOp => {
                let native_semaphore_name =
                    format!("{}_{}_semaphore", provider_name, self.spec.name);
                let semaphore_name = format!("{}_semaphore", self.spec.name).to_uppercase();
                let semaphore_ident =
                    syn::Ident::new(&semaphore_name, self.spec.original_method.span());
                let semaphore_attrs = if is_real {
                    quote! {
                       #[link_name = #native_semaphore_name]
                       #[link_section = ".probes"]
                    }
                } else {
                    quote! {}
                };

                let semaphore_initializer = if is_real {
                    quote! { ; }
                } else {
                    quote! { = 0; }
                };
                let span = self.spec.original_method.span();
                quote_spanned! {span=>
                    #semaphore_attrs
                    pub static #semaphore_ident: u16 #semaphore_initializer
                }
            }
            TracingTarget::Lttng => {
                //LTTng does not provide a simple semaphore flag, because it uses some fancy RCU
                //trickery that can't be expressed as an external variable declaration in Rust.
                //Instead generate a declaration for the native wrapper function which exposes the
                //is_enabled flag

                quote! {
                    #[link_name = #native_func_name]
                    pub fn #func_ident() -> bool;
                }
            }
        }
    }
/// Generates something which indicates if the probe is enabled or not.  In some cases it's a
/// static `u16`, in others it's a function that returns a bool.
///
/// Note that this will be _either_ a native C++ function that returns a bool, or an extern
/// static C++ semaphore variable.  If it's the latter, `generate_rust_is_enabled` will also
/// generate a corresponding Rust wrapper function around that variable
Generates something which indicates if the probe is enabled or not.  In some cases it's a
static `u16`, in others it's a function that returns a bool.

Note that this will be _either_ a native C++ function that returns a bool, or an extern
static C++ semaphore variable.  If it's the latter, `generate_rust_is_enabled` will also
generate a corresponding Rust wrapper function around that variable
Generates something which indicates if the probe is enabled or not . In some cases it ' s a static ` u16 ` in others it ' s a function that returns a bool . Note that this will be _either_ a native C ++ function that returns a bool or an extern static C ++ semaphore variable . If it ' s the latter ` generate_rust_is_enabled ` will also generate a corresponding Rust wrapper function around that variable
fn generate_native_is_enabled(&self, provider: &ProviderTraitGenerator) -> TokenStream {
        //The only exception to the `providername-providerhash` naming convention is the semaphore,
        //because the C tracing macros make assumptions about its name based on the provider and
        //probe names.  Fortunately even if there is a collission here, it won't result in any UB;
        //it just means a probe might think it's enabled when it's not, leading to a slightly
        //inefficient call into the wrapper function which will end up being a no-op
        assert!(provider.build_info.implementation != TracingImplementation::Disabled);
        let is_real = provider
            .build_info
            .implementation
            .tracing_target()
            .is_enabled();
        let provider_name = provider.spec.name();
        let native_func_name = format!("{}_{}_enabled", provider_name, self.spec.name);
        let func_name = format!("{}_enabled", self.spec.name);
        let func_ident = syn::Ident::new(&func_name, self.spec.original_method.span());
        match provider.build_info.implementation.tracing_target() {
            TracingTarget::Disabled | TracingTarget::Stap | TracingTarget::NoOp => {
                let native_semaphore_name =
                    format!("{}_{}_semaphore", provider_name, self.spec.name);
                let semaphore_name = format!("{}_semaphore", self.spec.name).to_uppercase();
                let semaphore_ident =
                    syn::Ident::new(&semaphore_name, self.spec.original_method.span());
                let semaphore_attrs = if is_real {
                    quote! {
                       #[link_name = #native_semaphore_name]
                       #[link_section = ".probes"]
                    }
                } else {
                    quote! {}
                };
                let semaphore_initializer = if is_real {
                    quote! { ; }
                } else {
                    quote! { = 0; }
                };
                let span = self.spec.original_method.span();
                quote_spanned! {span=>
                    #semaphore_attrs
                    pub static #semaphore_ident: u16 #semaphore_initializer
                }
            }
            TracingTarget::Lttng => {
                //LTTng does not provide a simple semaphore flag, because it uses some fancy RCU
                //trickery that can't be expressed as an external variable declaration in Rust.
                //Instead generate a declaration for the native wrapper function which exposes the
                //is_enabled flag
                quote! {
                    #[link_name = #native_func_name]
                    pub fn #func_ident() -> bool;
                }
            }
        }
    }
fn generate_native_is_enabled ( & self , provider : & ProviderTraitGenerator ) -> TokenStream { //The only exception to the `providername-providerhash` naming convention is the semaphore, //because the C tracing macros make assumptions about its name based on the provider and //probe names.  Fortunately even if there is a collission here, it won't result in any UB; //it just means a probe might think it's enabled when it's not, leading to a slightly //inefficient call into the wrapper function which will end up being a no-op assert ! ( provider build_info implementation TracingImplementation Disabled ) ; let is_real = provider . build_info . implementation . tracing_target ( ) . is_enabled ( ) ; let provider_name = provider . spec . name ( ) ; let native_func_name = format ! ( " " provider_name self spec name ) ; let func_name = format ! ( " " self spec name ) ; let func_ident = syn :: Ident :: new ( & func_name , self . spec . original_method . span ( ) ) ; match provider . build_info . implementation . tracing_target ( ) { TracingTarget :: Disabled | TracingTarget :: Stap | TracingTarget :: NoOp => { let native_semaphore_name = format ! ( " " provider_name self spec name ) ; let semaphore_name = format ! ( " " self spec name ) . to_uppercase ( ) ; let semaphore_ident = syn :: Ident :: new ( & semaphore_name , self . spec . original_method . span ( ) ) ; let semaphore_attrs = if is_real { quote ! { [ link_name native_semaphore_name ] [ link_section " " ] } } else { quote ! { } } ; let semaphore_initializer = if is_real { quote ! { } } else { quote ! { 0 } } ; let span = self . spec . original_method . span ( ) ; quote_spanned ! { span semaphore_attrs pub static semaphore_ident u16 semaphore_initializer } } TracingTarget :: Lttng => { //LTTng does not provide a simple semaphore flag, because it uses some fancy RCU //trickery that can't be expressed as an external variable declaration in Rust. //Instead generate a declaration for the native wrapper function which exposes the //is_enabled flag quote ! { [ link_name native_func_name ] pub fn func_ident ( ) bool } } } }
Generates something which indicates if the probe is enabled or not.
Generates something which indicates if the probe is enabled or not .
&self
provider
&ProviderTraitGenerator
&self
provider
&ProviderTraitGenerator