Fix strict ISO-C compatibility for ust-tracepoint-event.h public header
[lttng-ust.git] / include / lttng / ust-tracepoint-event.h
index 0bdc35be4f85ce6a7650efcea86745b5768b26cf..28ac8d8075dc71a7518a43148d0bc746a5bd3715 100644 (file)
@@ -1,14 +1,15 @@
 /*
- * Copyright (c) 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (c) 2011-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
  *
- * Permission is hereby granted to use or copy this program
- * for any purpose,  provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
  */
 
 #include <stdio.h>
@@ -76,7 +77,7 @@
                         _TP_PARAMS(_args),                     \
                         _TP_PARAMS(_fields))                   \
        TRACEPOINT_EVENT_INSTANCE(_provider, _name, _name,      \
-                        _TP_PARAMS(args))
+                        _TP_PARAMS(_args))
 
 /* Helpers */
 #define _TP_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
@@ -203,7 +204,7 @@ static const char                                                   \
        },
 
 #undef TP_FIELDS
-#define TP_FIELDS(args...) args        /* Only one used in this phase */
+#define TP_FIELDS(...) __VA_ARGS__     /* Only one used in this phase */
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)                            \
@@ -223,7 +224,7 @@ static const char                                                   \
 #include <lttng/ust-tracepoint-event-reset.h>
 
 #undef TP_ARGS
-#define TP_ARGS(args...) args
+#define TP_ARGS(...) __VA_ARGS__
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)               \
@@ -270,10 +271,10 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
        __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1;
 
 #undef TP_ARGS
-#define TP_ARGS(args...) args
+#define TP_ARGS(...) __VA_ARGS__
 
 #undef TP_FIELDS
-#define TP_FIELDS(args...) args
+#define TP_FIELDS(...) __VA_ARGS__
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)      \
@@ -321,10 +322,10 @@ static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic
 #define ctf_string(_item, _src)
 
 #undef TP_ARGS
-#define TP_ARGS(args...) args
+#define TP_ARGS(...) __VA_ARGS__
 
 #undef TP_FIELDS
-#define TP_FIELDS(args...) args
+#define TP_FIELDS(...) __VA_ARGS__
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)             \
@@ -392,10 +393,10 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
 #define __get_dynamic_len(field)       __dynamic_len[__dynamic_len_idx++]
 
 #undef TP_ARGS
-#define TP_ARGS(args...) args
+#define TP_ARGS(...) __VA_ARGS__
 
 #undef TP_FIELDS
-#define TP_FIELDS(args...) args
+#define TP_FIELDS(...) __VA_ARGS__
 
 #undef TRACEPOINT_EVENT_CLASS
 #define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)             \
@@ -434,76 +435,30 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args))\
 #undef __get_dynamic_len
 
 /*
- * Stage 6.1 of tracepoint event generation.
+ * Stage 5.1 of tracepoint event generation.
  *
- * Tracepoint loglevel enumeration definition generation.
+ * Create probe signature
  */
 
 /* Reset all macros within TRACEPOINT_EVENT */
 #include <lttng/ust-tracepoint-event-reset.h>
 
-#undef TRACEPOINT_LOGLEVEL_ENUM
-#define TRACEPOINT_LOGLEVEL_ENUM(...)  __VA_ARGS__
-
-#undef tp_loglevel
-#define tp_loglevel(_identifier, _value)               \
-static const struct tracepoint_loglevel_entry          \
-       _TP_COMBINE_TOKENS4(__tp_loglevel_entry__, TRACEPOINT_PROVIDER, ___, _identifier) = {   \
-               .identifier = #_identifier,             \
-               .value = (_value),                      \
-       };
+#undef TP_ARGS
+#define TP_ARGS(...) __VA_ARGS__
 
-tp_loglevel(TRACE_EMERG,       0)
-tp_loglevel(TRACE_ALERT,       1)
-tp_loglevel(TRACE_CRIT,                2)
-tp_loglevel(TRACE_ERR,         3)
-tp_loglevel(TRACE_WARNING,     4)
-tp_loglevel(TRACE_NOTICE,      5)
-tp_loglevel(TRACE_INFO,                6)
-tp_loglevel(TRACE_SYSTEM,      7)
-tp_loglevel(TRACE_PROCESS,     8)
-tp_loglevel(TRACE_MODULE,      9)
-tp_loglevel(TRACE_UNIT,                10)
-tp_loglevel(TRACE_CLASS,       11)
-tp_loglevel(TRACE_OBJECT,      12)
-tp_loglevel(TRACE_FUNCTION,    13)
-tp_loglevel(TRACE_PRINTF,      14)
-tp_loglevel(TRACE_DEBUG,       15)
+#define _TP_EXTRACT_STRING2(...)       #__VA_ARGS__
 
-/*
- * Stage 6.2 of tracepoint event generation.
- *
- * Tracepoint loglevel enumeration array generation.
- */
+#undef TRACEPOINT_EVENT_CLASS
+#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)       \
+const char __tp_event_signature___##_provider##___##_name[] =          \
+               _TP_EXTRACT_STRING2(_args);
 
-/* Reset all macros within TRACEPOINT_EVENT */
-#include <lttng/ust-tracepoint-event-reset.h>
+#include TRACEPOINT_INCLUDE
 
-#undef tp_loglevel
-#define tp_loglevel(_identifier, _value)               \
-       &_TP_COMBINE_TOKENS4(__tp_loglevel_entry__, TRACEPOINT_PROVIDER, ___, _identifier),     \
-
-static const struct tracepoint_loglevel_entry *_TP_COMBINE_TOKENS(__tracepoint_loglevel_enum__, TRACEPOINT_PROVIDER)[] = {
-       tp_loglevel(TRACE_EMERG,        0)
-       tp_loglevel(TRACE_ALERT,        1)
-       tp_loglevel(TRACE_CRIT,         2)
-       tp_loglevel(TRACE_ERR,          3)
-       tp_loglevel(TRACE_WARNING,      4)
-       tp_loglevel(TRACE_NOTICE,       5)
-       tp_loglevel(TRACE_INFO,         6)
-       tp_loglevel(TRACE_SYSTEM,       7)
-       tp_loglevel(TRACE_PROCESS,      8)
-       tp_loglevel(TRACE_MODULE,       9)
-       tp_loglevel(TRACE_UNIT,         10)
-       tp_loglevel(TRACE_CLASS,        11)
-       tp_loglevel(TRACE_OBJECT,       12)
-       tp_loglevel(TRACE_FUNCTION,     13)
-       tp_loglevel(TRACE_PRINTF,       14)
-       tp_loglevel(TRACE_DEBUG,        15)
-};
+#undef _TP_EXTRACT_STRING2
 
 /*
- * Stage 7 of tracepoint event generation.
+ * Stage 6 of tracepoint event generation.
  *
  * Tracepoint loglevel mapping definition generation. We generate a
  * symbol for each mapping for a provider/event to ensure at most a 1 to
@@ -515,15 +470,15 @@ static const struct tracepoint_loglevel_entry *_TP_COMBINE_TOKENS(__tracepoint_l
 #include <lttng/ust-tracepoint-event-reset.h>
 
 #undef TRACEPOINT_LOGLEVEL
-#define TRACEPOINT_LOGLEVEL(__provider, __name, __loglevel)            \
-static const struct tracepoint_loglevel_entry *                                \
-       _loglevel_mapping___##__provider##___##__name =                 \
-               &__tp_loglevel_entry__##__provider##___##__loglevel;
+#define TRACEPOINT_LOGLEVEL(__provider, __name, __loglevel)               \
+static const int _loglevel_value___##__provider##___##__name = __loglevel; \
+static const int *_loglevel___##__provider##___##__name =                 \
+               &_loglevel_value___##__provider##___##__name;
 
 #include TRACEPOINT_INCLUDE
 
 /*
- * Stage 8.1 of tracepoint event generation.
+ * Stage 7.1 of tracepoint event generation.
  *
  * Create events description structures. We use a weakref because
  * loglevels are optional. If not declared, the event will point to the
@@ -535,21 +490,22 @@ static const struct tracepoint_loglevel_entry *                           \
 
 #undef TRACEPOINT_EVENT_INSTANCE
 #define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args)         \
-static const struct tracepoint_loglevel_entry *                                       \
-       __ref_loglevel_mapping___##_provider##___##_name                       \
-       __attribute__((weakref ("_loglevel_mapping___" #_provider "___" #_name))); \
+static const int *                                                            \
+       __ref_loglevel___##_provider##___##_name                               \
+       __attribute__((weakref ("_loglevel___" #_provider "___" #_name)));     \
 const struct lttng_event_desc __event_desc___##_provider##_##_name = {        \
        .fields = __event_fields___##_provider##___##_template,                \
        .name = #_provider ":" #_name,                                         \
        .probe_callback = (void *) &__event_probe__##_provider##___##_template,\
        .nr_fields = _TP_ARRAY_SIZE(__event_fields___##_provider##___##_template), \
-       .loglevel = &__ref_loglevel_mapping___##_provider##___##_name,         \
+       .loglevel = &__ref_loglevel___##_provider##___##_name,                 \
+       .signature = __tp_event_signature___##_provider##___##_template,       \
 };
 
 #include TRACEPOINT_INCLUDE
 
 /*
- * Stage 8.2 of tracepoint event generation.
+ * Stage 7.2 of tracepoint event generation.
  *
  * Create array of events.
  */
@@ -567,7 +523,7 @@ static const struct lttng_event_desc *_TP_COMBINE_TOKENS(__event_desc___, TRACEP
 
 
 /*
- * Stage 9 of tracepoint event generation.
+ * Stage 8 of tracepoint event generation.
  *
  * Create a toplevel descriptor for the whole probe.
  */
@@ -577,19 +533,19 @@ static struct lttng_probe_desc _TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PR
        .provider = __tp_stringify(TRACEPOINT_PROVIDER),
        .event_desc = _TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER),
        .nr_events = _TP_ARRAY_SIZE(_TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER)),
-       .loglevels = _TP_COMBINE_TOKENS(__tracepoint_loglevel_enum__, TRACEPOINT_PROVIDER),
-       .nr_loglevels = _TP_ARRAY_SIZE(_TP_COMBINE_TOKENS(__tracepoint_loglevel_enum__, TRACEPOINT_PROVIDER)),
 };
 
 /*
- * Stage 10 of tracepoint event generation.
+ * Stage 9 of tracepoint event generation.
  *
  * Register/unregister probes at module load/unload.
+ *
+ * Generate the constructor as an externally visible symbol for use when
+ * linking the probe statically.
  */
 
 /* Reset all macros within TRACEPOINT_EVENT */
 #include <lttng/ust-tracepoint-event-reset.h>
-
 static void __attribute__((constructor))
 _TP_COMBINE_TOKENS(__lttng_events_init__, TRACEPOINT_PROVIDER)(void)
 {
@@ -604,3 +560,5 @@ _TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
 {
        ltt_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
 }
+
+int _TP_COMBINE_TOKENS(__tracepoint_provider_, TRACEPOINT_PROVIDER);
This page took 0.028046 seconds and 4 git commands to generate.