callsite: move after the call
[lttng-ust.git] / include / lttng / tracepoint.h
index 8086b648a2a4be8d9b7ed04cbe21977a3f039929..8e4704c47f3e264e653b1539f45e30234f4080cf 100644 (file)
 extern "C" {
 #endif
 
-#define tracepoint(provider, name, ...)                                            \
-       do {                                                                \
-               TRACEPOINT_CALLSITE(provider, name);                        \
-               STAP_PROBEV(provider, name, ## __VA_ARGS__);                \
-               if (caa_unlikely(__tracepoint_##provider##___##name.state)) \
-                       __tracepoint_cb_##provider##___##name(__VA_ARGS__); \
+#define tracepoint(provider, name, ...)                                              \
+       do {                                                                  \
+               STAP_PROBEV(provider, name, ## __VA_ARGS__);                  \
+               if (caa_unlikely(__tracepoint_##provider##___##name.state)) { \
+                       __tracepoint_cb_##provider##___##name(__VA_ARGS__);   \
+                       TRACEPOINT_CALLSITE(provider, name);                  \
+               }                                                             \
        } while (0)
 
 #define TP_ARGS(...)       __VA_ARGS__
@@ -220,25 +221,34 @@ struct tracepoint_callsite_dlopen tracepoint_callsite_dlopen
 int __tracepoint_callsite_registered
        __attribute__((weak, visibility("hidden")));
 
+#if (CAA_BITS_PER_LONG == 64)
+#define __TP_ASM_PTR   ".quad "
+#else
+#define __TP_ASM_PTR   ".long "
+#endif
+
 /*
  * Note: to allow PIC code, we need to allow the linker to update the pointers
  * in the __tracepoints_callsite_ptrs section.
  * Therefore, this section is _not_ const (read-only).
  */
 #define TRACEPOINT_CALLSITE(_provider, _name)                                  \
-       static struct tracepoint_callsite                                       \
-               __tracepoint_callsite_##_provider##___##_name                   \
-               __attribute__((section("__tracepoint_callsite"))) =             \
-               {                                                               \
-                       .tp = &__tracepoint_##_provider##___##_name,            \
-                       .func = __func__,                                       \
-                       .file = __FILE__,                                       \
-                       .lineno = __LINE__,                                     \
-               };                                                              \
-       static struct tracepoint_callsite *                                     \
-               __tracepoint_callsite_ptr_##_provider##___##_name               \
-               __attribute__((used, section("__tracepoint_callsite_ptrs"))) =  \
-                       &__tracepoint_callsite_##_provider##___##_name
+do {                                                                           \
+       asm volatile (  ".pushsection __tracepoint_callsite, \"aw\"\n\t"        \
+                       "1:\n\t"                                                \
+                       __TP_ASM_PTR "%c0, %c1, %c2, 2f\n\t"                    \
+                       ".int %c3\n\t"                                          \
+                       ".space 16\n\t" /* padding */                           \
+                       ".popsection\n\t"                                       \
+                       ".pushsection __tracepoint_callsite_ptrs, \"aw\"\n\t"   \
+                       __TP_ASM_PTR "1b\n\t"                                   \
+                       ".popsection\n\t"                                       \
+                       "2:\n\t"                                                \
+               : : "i" (#_provider ":" #_name),                                \
+                       "i" (__func__),                                         \
+                       "i" (__FILE__),                                         \
+                       "i" (__LINE__));                                        \
+} while (0)
 
 /*
  * These weak symbols, the constructor, and destructor take care of
This page took 0.032427 seconds and 4 git commands to generate.