From 06294ff90351f02d01c65d186e3d993f624fef8d Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 21 Apr 2021 11:07:58 -0400 Subject: [PATCH] Tracepoint API namespacing tracef The ABI bump gives us the opportunity to namespace all public symbols under the 'lttng_ust_' prefix. Namespace all API symbols and macros under 'lttng_ust_' / 'LTTNG_UST_' and add compat macros to keep compatibility with the previous API. Change-Id: I1a16b9af1dfabb9483cdf3e5225ebe50fe691935 Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- doc/examples/demo-tracef/demo-tracef.c | 2 +- doc/examples/demo-tracef/demo-vtracef.c | 2 +- include/lttng/tracef.h | 19 +++++++++++++------ src/lib/lttng-ust/tracef.c | 21 ++++++++------------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/doc/examples/demo-tracef/demo-tracef.c b/doc/examples/demo-tracef/demo-tracef.c index 8af0a583..b90c07bd 100644 --- a/doc/examples/demo-tracef/demo-tracef.c +++ b/doc/examples/demo-tracef/demo-tracef.c @@ -27,7 +27,7 @@ int main(int argc, char **argv) fprintf(stderr, "Tracing... "); for (i = 0; i < 5; i++) { - tracef("This is a \"%s\" formatted %d event %lx", + lttng_ust_tracef("This is a \"%s\" formatted %d event %lx", str, i, l); } fprintf(stderr, " done.\n"); diff --git a/doc/examples/demo-tracef/demo-vtracef.c b/doc/examples/demo-tracef/demo-vtracef.c index 8fe8bb36..13564f41 100644 --- a/doc/examples/demo-tracef/demo-vtracef.c +++ b/doc/examples/demo-tracef/demo-vtracef.c @@ -20,7 +20,7 @@ void print_debug(const char* msg, ...) va_list ap; va_start(ap, msg); - vtracef(msg, ap); + lttng_ust_vtracef(msg, ap); va_end(ap); } diff --git a/include/lttng/tracef.h b/include/lttng/tracef.h index 4526d3d8..37f7ae47 100644 --- a/include/lttng/tracef.h +++ b/include/lttng/tracef.h @@ -7,6 +7,7 @@ #ifndef _LTTNG_UST_TRACEF_H #define _LTTNG_UST_TRACEF_H +#include #include #ifdef __cplusplus @@ -14,25 +15,31 @@ extern "C" { #endif extern -void _lttng_ust_tracef(const char *fmt, ...) +void lttng_ust__tracef(const char *fmt, ...) __attribute__((format(printf, 1, 2))); extern -void _lttng_ust_vtracef(const char *fmt, va_list ap) +void lttng_ust__vtracef(const char *fmt, va_list ap) __attribute__((format(printf, 1, 0))); -#define tracef(fmt, ...) \ +#define lttng_ust_tracef(fmt, ...) \ do { \ LTTNG_UST_STAP_PROBEV(tracepoint_lttng_ust_tracef, event, ## __VA_ARGS__); \ if (caa_unlikely(lttng_ust_tracepoint_lttng_ust_tracef___event.state)) \ - _lttng_ust_tracef(fmt, ## __VA_ARGS__); \ + lttng_ust__tracef(fmt, ## __VA_ARGS__); \ } while (0) -#define vtracef(fmt, ap) \ +#define lttng_ust_vtracef(fmt, ap) \ do { \ if (caa_unlikely(lttng_ust_tracepoint_lttng_ust_tracef___event.state)) \ - _lttng_ust_vtracef(fmt, ap); \ + lttng_ust__vtracef(fmt, ap); \ } while (0) + +#if LTTNG_UST_COMPAT_API(0) +#define tracef lttng_ust_tracef +#define vtracef lttng_ust_vtracef +#endif + #ifdef __cplusplus } #endif diff --git a/src/lib/lttng-ust/tracef.c b/src/lib/lttng-ust/tracef.c index e1824e5c..e321ee07 100644 --- a/src/lib/lttng-ust/tracef.c +++ b/src/lib/lttng-ust/tracef.c @@ -13,10 +13,10 @@ #include "lttng-ust-tracef-provider.h" static inline -void __lttng_ust_vtracef(const char *fmt, va_list ap) +void lttng_ust___vtracef(const char *fmt, va_list ap) __attribute__((always_inline, format(printf, 1, 0))); static inline -void __lttng_ust_vtracef(const char *fmt, va_list ap) +void lttng_ust___vtracef(const char *fmt, va_list ap) { char *msg; const int len = vasprintf(&msg, fmt, ap); @@ -31,25 +31,20 @@ end: return; } -/* - * FIXME: We should include for the declarations here, but it - * fails with tracepoint magic above my paygrade. - */ - -void _lttng_ust_vtracef(const char *fmt, va_list ap) +void lttng_ust__vtracef(const char *fmt, va_list ap) __attribute__((format(printf, 1, 0))); -void _lttng_ust_vtracef(const char *fmt, va_list ap) +void lttng_ust__vtracef(const char *fmt, va_list ap) { - __lttng_ust_vtracef(fmt, ap); + lttng_ust___vtracef(fmt, ap); } -void _lttng_ust_tracef(const char *fmt, ...) +void lttng_ust__tracef(const char *fmt, ...) __attribute__((format(printf, 1, 2))); -void _lttng_ust_tracef(const char *fmt, ...) +void lttng_ust__tracef(const char *fmt, ...) { va_list ap; va_start(ap, fmt); - __lttng_ust_vtracef(fmt, ap); + lttng_ust___vtracef(fmt, ap); va_end(ap); } -- 2.34.1