Use caa_unlikely, depend on liburcu >= 0.6.6
[ust.git] / include / ust / tracepoint.h
index 4d84eaddbe19bdbf9c0fb253c2eb967978a85f1e..ade567726e9c4cffeffc5e0c39d61a8b66927a35 100644 (file)
@@ -26,8 +26,8 @@
  */
 
 #include <urcu-bp.h>
-#include <ust/core.h>
 #include <urcu/list.h>
+#include <urcu/compiler.h>
 
 struct tracepoint_probe {
        void *func;
@@ -71,12 +71,13 @@ struct tracepoint {
 /*
  * it_func[0] is never NULL because there is at least one element in the array
  * when the array itself is non NULL.
+ * __attribute__((unused)) is for backward compatibility API.
  */
 #define __DO_TRACE(tp, proto, args)                                    \
        do {                                                            \
                struct tracepoint_probe *__tp_it_probe_ptr;             \
                void *__tp_it_func;                                     \
-               void *__tp_cb_data;                                     \
+               void *__tp_cb_data __attribute__((unused));             \
                                                                        \
                rcu_read_lock();                                        \
                __tp_it_probe_ptr = rcu_dereference((tp)->probes);      \
@@ -96,7 +97,7 @@ struct tracepoint {
 
 #define __CHECK_TRACE(name, proto, args)                               \
        do {                                                            \
-               if (unlikely(__tracepoint_##name.state))                \
+               if (caa_unlikely(__tracepoint_##name.state))            \
                        __DO_TRACE(&__tracepoint_##name,                \
                                TP_PROTO(proto), TP_ARGS(args));        \
        } while (0)
@@ -125,6 +126,29 @@ struct tracepoint {
        {                                                               \
                return __tracepoint_probe_unregister(#name, (void *)probe, \
                                                   data);               \
+       }                                                               \
+       /*                                                              \
+        * Backward-compatibility API (will be deprecated):             \
+        * trace_*                                                      \
+        * register_trace_*                                             \
+        * unregister_trace_*                                           \
+        */                                                             \
+       static inline void trace_##name(proto)                          \
+       {                                                               \
+               __CHECK_TRACE(name, TP_PROTO(proto),                    \
+                             TP_ARGS(args));                           \
+       }                                                               \
+       static inline int                                               \
+       register_trace_##name(void (*probe)(proto))                     \
+       {                                                               \
+               return __tracepoint_probe_register(#name, (void *)probe,\
+                                                  NULL);               \
+       }                                                               \
+       static inline int                                               \
+       unregister_trace_##name(void (*probe)(proto))                   \
+       {                                                               \
+               return __tracepoint_probe_unregister(#name, (void *)probe, \
+                                                    NULL);             \
        }
 
 /*
@@ -195,6 +219,16 @@ int tracepoint_register_lib(struct tracepoint * const *tracepoints_start,
 extern
 int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_start);
 
+/*
+ * Backward-compatibility API (will be deprecated):
+ * DEFINE_TRACE
+ * DECLARE_TRACE
+ * register_tracepoint
+ * unregister_tracepoint
+ */
+#define DEFINE_TRACE   _DEFINE_TRACEPOINT
+#define DECLARE_TRACE(name, proto, args)       \
+               _DECLARE_TRACEPOINT(name, TP_PARAMS(proto), TP_PARAMS(args))
 
 #ifndef TRACEPOINT_EVENT
 /*
This page took 0.023397 seconds and 4 git commands to generate.