Skip to main content

rust_hawktracer_normal_macro/
lib.rs

1#[allow(dead_code)]
2#[cfg(feature = "profiling_enabled")]
3extern crate rust_hawktracer_sys;
4#[cfg(feature = "profiling_enabled")]
5pub use rust_hawktracer_sys::*;
6#[cfg(feature = "profiling_enabled")]
7use std::thread_local;
8#[cfg(not(feature = "profiling_enabled"))]
9mod dummy_structs;
10#[cfg(not(feature = "profiling_enabled"))]
11pub use dummy_structs::*;
12
13#[macro_export]
14#[cfg(feature = "profiling_enabled")]
15macro_rules! scoped_tracepoint {
16    ($name:ident) => {
17        thread_local! {
18            static tracepoint_id: u64 = add_cached_mapping(concat!(stringify!($name), "\0").as_ptr() as _);
19        };
20        
21        tracepoint_id.with(|id| {
22            ScopedTracepoint::start_trace_id(*id);
23        });
24        
25        let $name = ScopedTracepoint {};
26    };
27}
28
29#[macro_export]
30#[cfg(not(feature = "profiling_enabled"))]
31macro_rules! scoped_tracepoint {
32    ($name:ident) => {
33        ()
34    };
35}
36