events.h API const-ness
[lttng-modules.git] / include / lttng / tracepoint-event-impl.h
index a1eff6c242f672576cddbd0f401467572a103b17..ce41fcb688d37102dc4e755f9c6aca9e530c264a 100644 (file)
@@ -201,13 +201,49 @@ void __event_template_proto___##_name(void);
 #ifndef LTTNG_TRACEPOINT_TYPE_EXTERN
 # undef LTTNG_TRACEPOINT_ENUM
 # define LTTNG_TRACEPOINT_ENUM(_name, _values)                         \
-       static const struct lttng_kernel_enum_entry *__enum_values__##_name[] = { \
+       static const struct lttng_kernel_enum_entry * const __enum_values__##_name[] = { \
                _values                                                 \
        };
 #endif
 
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
+/*
+ * Stage 1.3 of the trace events.
+ *
+ * Create probe callback prototypes.
+ */
+
+/* Reset all macros within TRACEPOINT_EVENT */
+#include <lttng/events-reset.h>
+
+#undef TP_PROTO
+#define TP_PROTO(...)  __VA_ARGS__
+
+#undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
+static void __event_probe__##_name(void *__data, _proto);
+
+#undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
+#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
+static void __event_probe__##_name(void *__data);
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
+/*
+ * Stage 1.4 of tracepoint event generation.
+ *
+ * Declare toplevel descriptor for the whole probe.
+ */
+
+#define TP_ID1(_token, _system)        _token##_system
+#define TP_ID(_token, _system) TP_ID1(_token, _system)
+
+static __used struct lttng_kernel_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM);
+
+#undef TP_ID1
+#undef TP_ID
+
 /*
  * Stage 2 of the trace events.
  *
@@ -299,10 +335,20 @@ void __event_template_proto___##_name(void);
 #undef TP_FIELDS
 #define TP_FIELDS(...) __VA_ARGS__     /* Only one used in this phase */
 
+#ifndef TP_PROBE_CB
+#define TP_PROBE_CB(_template) &__event_probe__##_template
+#endif
+
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
-       static const struct lttng_kernel_event_field *__event_fields___##_name[] = { \
+       static const struct lttng_kernel_event_field * const __event_fields___##_name[] = { \
                _fields                                                      \
+       };                                                                   \
+       static const struct lttng_kernel_tracepoint_class lttng_kernel__event_class___##_name = { \
+               .fields = __event_fields___##_name,                          \
+               .nr_fields = ARRAY_SIZE(__event_fields___##_name),           \
+               .probe_callback = (void (*)(void)) TP_PROBE_CB(_name),       \
+               .probe_desc = &TP_ID(__probe_desc___, TRACE_SYSTEM),         \
        };
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
@@ -332,35 +378,20 @@ void __event_template_proto___##_name(void);
                 .name = #_name,                                                         \
                 .entries = __enum_values__##_name,                                      \
                 .nr_entries = ARRAY_SIZE(__enum_values__##_name),                       \
+               .probe_desc = &TP_ID(__probe_desc___, TRACE_SYSTEM),                    \
         }))
 
+#define TP_ID1(_token, _system)        _token##_system
+#define TP_ID(_token, _system) TP_ID1(_token, _system)
+
 #define LTTNG_CREATE_FIELD_METADATA
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 #undef LTTNG_CREATE_FIELD_METADATA
 
 #undef LTTNG_TRACEPOINT_TYPE_VISIBILITY
 
-/*
- * Stage 3 of the trace events.
- *
- * Create probe callback prototypes.
- */
-
-/* Reset all macros within TRACEPOINT_EVENT */
-#include <lttng/events-reset.h>
-
-#undef TP_PROTO
-#define TP_PROTO(...)  __VA_ARGS__
-
-#undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
-static void __event_probe__##_name(void *__data, _proto);
-
-#undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
-#define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
-static void __event_probe__##_name(void *__data);
-
-#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+#undef TP_ID1
+#undef TP_ID
 
 /*
  * Stage 4 of the trace events.
@@ -1043,15 +1074,15 @@ static void __event_probe__##_name(_data_proto)                                         \
        {                                                                               \
                struct lttng_kernel_event_recorder *__event_recorder =                  \
                        container_of(__event, struct lttng_kernel_event_recorder, parent); \
-               struct lttng_channel *__chan = __event_recorder->chan;                  \
-               struct lttng_kernel_session *__session = __chan->session;               \
+               struct lttng_kernel_channel_buffer *__chan = __event_recorder->chan;    \
+               struct lttng_kernel_session *__session = __chan->parent.session;        \
                struct lttng_kernel_id_tracker_rcu *__lf;                               \
                                                                                        \
                if (!_TP_SESSION_CHECK(session, __session))                             \
                        return;                                                         \
                if (unlikely(!LTTNG_READ_ONCE(__session->active)))                      \
                        return;                                                         \
-               if (unlikely(!LTTNG_READ_ONCE(__chan->enabled)))                        \
+               if (unlikely(!LTTNG_READ_ONCE(__chan->parent.enabled)))                 \
                        return;                                                         \
                __lf = lttng_rcu_dereference(__session->pid_tracker.p);                 \
                if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid)))      \
@@ -1100,7 +1131,7 @@ static void __event_probe__##_name(_data_proto)                                           \
        {                                                                               \
                struct lttng_kernel_event_recorder *__event_recorder =                  \
                        container_of(__event, struct lttng_kernel_event_recorder, parent); \
-               struct lttng_channel *__chan = __event_recorder->chan;                  \
+               struct lttng_kernel_channel_buffer *__chan = __event_recorder->chan;    \
                struct lttng_kernel_ring_buffer_ctx __ctx;                              \
                ssize_t __event_len;                                                    \
                size_t __event_align;                                                   \
@@ -1108,7 +1139,7 @@ static void __event_probe__##_name(_data_proto)                                           \
                                                                                        \
                __event_len = __event_get_size__##_name(_locvar_args);                  \
                if (unlikely(__event_len < 0)) {                                        \
-                       lib_ring_buffer_lost_event_too_big(__chan->chan);               \
+                       __chan->ops->lost_event_too_big(__chan);                        \
                        goto __post;                                                    \
                }                                                                       \
                __event_align = __event_get_align__##_name(_locvar_args);               \
@@ -1163,20 +1194,6 @@ __post:                                                                                  \
 
 #undef __get_dynamic_len
 
-/*
- * Stage 7.0 of tracepoint event generation.
- *
- * Declare toplevel descriptor for the whole probe.
- */
-
-#define TP_ID1(_token, _system)        _token##_system
-#define TP_ID(_token, _system) TP_ID1(_token, _system)
-
-static __used struct lttng_kernel_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM);
-
-#undef TP_ID1
-#undef TP_ID
-
 /*
  * Stage 7.1 of the trace events.
  *
@@ -1187,19 +1204,13 @@ static __used struct lttng_kernel_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM
 
 #include <lttng/events-reset.h>        /* Reset all macros within LTTNG_TRACEPOINT_EVENT */
 
-#ifndef TP_PROBE_CB
-#define TP_PROBE_CB(_template) &__event_probe__##_template
-#endif
-
 #undef LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS
 #define LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP_NOARGS(_template, _name, _map)     \
 static const struct lttng_kernel_event_desc __event_desc___##_map = {  \
        .event_name = #_map,                                            \
        .event_kname = #_name,                                          \
+       .tp_class = &lttng_kernel__event_class___##_template,           \
        .probe_desc = &TP_ID(__probe_desc___, TRACE_SYSTEM),            \
-       .probe_callback = (void (*)(void)) TP_PROBE_CB(_template),      \
-       .fields = __event_fields___##_template,                         \
-       .nr_fields = ARRAY_SIZE(__event_fields___##_template),          \
        .owner = THIS_MODULE,                                           \
 };
 
@@ -1234,7 +1245,7 @@ static const struct lttng_kernel_event_desc __event_desc___##_map = {     \
 #define TP_ID1(_token, _system)        _token##_system
 #define TP_ID(_token, _system) TP_ID1(_token, _system)
 
-static const struct lttng_kernel_event_desc *TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
+static const struct lttng_kernel_event_desc * const TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 };
 
This page took 0.026062 seconds and 4 git commands to generate.