| 1 | |
| 2 |
|
| 3 | |
| 4 |
|
| 5 | |
| 6 |
|
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | #[macro_export]
|
| 13 | macro_rules! declare_trace {
|
| 14 | ($($(#[$attr:meta])* $pub:vis unsafe fn $name:ident($($argname:ident : $argtyp:ty),* $(,)?);)*) => {$(
|
| 15 | $( #[$attr] )*
|
| 16 | #[inline(always)]
|
| 17 | $pub unsafe fn $name($($argname : $argtyp),*) {
|
| 18 | #[cfg(CONFIG_TRACEPOINTS)]
|
| 19 | {
|
| 20 | |
| 21 | let should_trace = unsafe {
|
| 22 | $crate::macros::paste! {
|
| 23 | $crate::jump_label::static_branch_unlikely!(
|
| 24 | $crate::bindings::[< __tracepoint_ $name >],
|
| 25 | $crate::bindings::tracepoint,
|
| 26 | key
|
| 27 | )
|
| 28 | }
|
| 29 | };
|
| 30 |
|
| 31 | if should_trace {
|
| 32 | $crate::macros::paste! {
|
| 33 | |
| 34 | unsafe { $crate::bindings::[< rust_do_trace_ $name >]($($argname),*) };
|
| 35 | }
|
| 36 | }
|
| 37 | }
|
| 38 |
|
| 39 | #[cfg(not(CONFIG_TRACEPOINTS))]
|
| 40 | {
|
| 41 | |
| 42 | |
| 43 | $( let _unused = $argname; )*
|
| 44 | }
|
| 45 | }
|
| 46 | )*}
|
| 47 | }
|
| 48 |
|
| 49 | pub use declare_trace;
|