Tracepoints: namespace cleanups
[ust.git] / include / ust / ust_trace.h
index e1b02576d6ef93b88c45bca1cdcdcf071e355d09..d70ad17833b567a4124c2e11bf78b9e3aa9c0dc3 100644 (file)
@@ -23,6 +23,8 @@
  * to a printf
  */
 
+#include <stdio.h>
+
 /*
  * Stage 1. Create a struct and a printf calling function
  * that is connected to the tracepoint at load time.
 #undef TRACE_EVENT
 #define TRACE_EVENT(name, proto, args, tstruct, assign, print)         \
        DECLARE_TRACE_EVENT_CLASS(name,                                 \
-                                 PARAMS(proto),                        \
-                                 PARAMS(args),                         \
-                                 PARAMS(tstruct),                      \
-                                 PARAMS(assign),                       \
-                                 PARAMS(print));                       \
-       DEFINE_TRACE_EVENT(name, name, PARAMS(proto), PARAMS(args));
+                                 TP_PARAMS(proto),                     \
+                                 TP_PARAMS(args),                      \
+                                 TP_PARAMS(tstruct),                   \
+                                 TP_PARAMS(assign),                    \
+                                 TP_PARAMS(print));                    \
+       DEFINE_TRACE_EVENT(name, name, TP_PARAMS(proto), TP_PARAMS(args));
 
 #undef __field
 #define __field(type, item)            type    item;
                                                                        \
                printf(print);                                          \
        }                                                               \
+       static inline int register_event_##name(void *data)             \
+       {                                                               \
+               return register_tracepoint(name, trace_printf_##name, data); \
+       }                                                               \
+       static inline int unregister_event_##name(void *data)           \
+       {                                                               \
+               return unregister_tracepoint(name, trace_printf_##name, data); \
+       }                                                               \
+       struct trace_event __event_##name = {                           \
+               __tpstrtab_##name,                                      \
+               register_event_##name,                                  \
+               unregister_event_##name                                 \
+       };                                                              \
+       static struct trace_event * const __event_ptrs_##name           \
+       __attribute__((used, section("__trace_events_ptrs"))) =         \
+               &__event_##name;                                        \
+                                                                       \
        static void __attribute__((constructor)) init_##name()          \
        {                                                               \
-               void *dummy;                                            \
-               printf("connecting tracepoint " #name "\n");            \
-               register_trace_##name(trace_printf_##name, dummy);      \
+               void *dummy = NULL;                                     \
+               register_tracepoint(name, trace_printf_##name, dummy);  \
        }
 
 
This page took 0.024106 seconds and 4 git commands to generate.