#undef _ctf_integer_ext
#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
if (lttng_is_signed_type(_type)) { \
- int64_t __ctf_tmp_int64 = (int64_t) (_type) (_src); \
+ int64_t __ctf_tmp_int64; \
+ switch (sizeof(_type)) { \
+ case 1: \
+ { \
+ union { _type t; int8_t v; } __tmp = { (_type) (_src) }; \
+ __ctf_tmp_int64 = (int64_t) __tmp.v; \
+ break; \
+ } \
+ case 2: \
+ { \
+ union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
+ __ctf_tmp_int64 = (int64_t) __tmp.v; \
+ break; \
+ } \
+ case 4: \
+ { \
+ union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
+ __ctf_tmp_int64 = (int64_t) __tmp.v; \
+ break; \
+ } \
+ case 8: \
+ { \
+ union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
+ __ctf_tmp_int64 = (int64_t) __tmp.v; \
+ break; \
+ } \
+ default: \
+ abort(); \
+ }; \
memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \
} else { \
- uint64_t __ctf_tmp_uint64 = (uint64_t) (_type) (_src); \
+ uint64_t __ctf_tmp_uint64; \
+ switch (sizeof(_type)) { \
+ case 1: \
+ { \
+ union { _type t; uint8_t v; } __tmp = { (_type) (_src) }; \
+ __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
+ break; \
+ } \
+ case 2: \
+ { \
+ union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
+ __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
+ break; \
+ } \
+ case 4: \
+ { \
+ union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
+ __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
+ break; \
+ } \
+ case 8: \
+ { \
+ union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
+ __ctf_tmp_uint64 = (uint64_t) __tmp.v; \
+ break; \
+ } \
+ default: \
+ abort(); \
+ }; \
memcpy(__stack_data, &__ctf_tmp_uint64, sizeof(uint64_t)); \
} \
__stack_data += sizeof(int64_t);
#undef TP_FIELDS
#define TP_FIELDS(...) __VA_ARGS__
+/*
+ * For state dump, check that "session" argument (mandatory) matches the
+ * session this event belongs to. Ensures that we write state dump data only
+ * into the started session, not into all sessions.
+ */
+#undef _TP_SESSION_CHECK
+#ifdef TP_SESSION_CHECK
+#define _TP_SESSION_CHECK(session, csession) (session == csession)
+#else /* TP_SESSION_CHECK */
+#define _TP_SESSION_CHECK(session, csession) 1
+#endif /* TP_SESSION_CHECK */
+
/*
* Using twice size for filter stack data to hold size and pointer for
* each field (worse case). For integers, max size required is 64-bit.
\
if (0) \
(void) __dynamic_len_idx; /* don't warn if unused */ \
+ if (!_TP_SESSION_CHECK(session, __chan->session)) \
+ return; \
if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->session->active))) \
return; \
if (caa_unlikely(!CMM_ACCESS_ONCE(__chan->enabled))) \
.minor = LTTNG_UST_PROVIDER_MINOR,
};
+static int _TP_COMBINE_TOKENS(__probe_register_refcount___, TRACEPOINT_PROVIDER);
+
/*
* Stage 9 of tracepoint event generation.
*
*
* Generate the constructor as an externally visible symbol for use when
* linking the probe statically.
+ *
+ * Register refcount is protected by libc dynamic loader mutex.
*/
/* Reset all macros within TRACEPOINT_EVENT */
{
int ret;
+ if (_TP_COMBINE_TOKENS(__probe_register_refcount___,
+ TRACEPOINT_PROVIDER)++) {
+ return;
+ }
/*
* __tracepoint_provider_check_ ## TRACEPOINT_PROVIDER() is a
* static inline function that ensures every probe PROVIDER
static void
_TP_COMBINE_TOKENS(__lttng_events_exit__, TRACEPOINT_PROVIDER)(void)
{
+ if (--_TP_COMBINE_TOKENS(__probe_register_refcount___,
+ TRACEPOINT_PROVIDER)) {
+ return;
+ }
lttng_probe_unregister(&_TP_COMBINE_TOKENS(__probe_desc___, TRACEPOINT_PROVIDER));
}