From 78684808fe09e0a094a75042e4f4383b2346bce6 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 21 Apr 2021 17:44:07 -0400 Subject: [PATCH] Tracepoint API namespacing ctf_enum 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: I377d89338735a6cc3b2b436e69fefd2e81f39e9a Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- include/lttng/tracepoint.h | 22 +++++++----- include/lttng/ust-tracepoint-event-nowrite.h | 6 ++-- include/lttng/ust-tracepoint-event-reset.h | 12 +++---- include/lttng/ust-tracepoint-event-write.h | 6 ++-- include/lttng/ust-tracepoint-event.h | 34 +++++++++---------- src/lib/lttng-ust/lttng-ust-dynamic-type.c | 26 +++++++------- tests/compile/ctf-types/ust_tests_ctf_types.h | 22 ++++++------ tests/compile/hello.cxx/ust_tests_hello.h | 14 ++++---- 8 files changed, 74 insertions(+), 68 deletions(-) diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h index beb2c409..a8532796 100644 --- a/include/lttng/tracepoint.h +++ b/include/lttng/tracepoint.h @@ -624,6 +624,12 @@ lttng_ust__tracepoints__ptrs_destroy(void) #define ctf_unused lttng_ust_field_unused #define ctf_unused_nowrite lttng_ust_field_unused_nowrite + +#define ctf_enum lttng_ust_field_enum +#define ctf_enum_nowrite lttng_ust_field_enum_nowrite +#define ctf_enum_value lttng_ust_field_enum_value +#define ctf_enum_range lttng_ust_field_enum_range +#define ctf_enum_auto lttng_ust_field_enum_auto #endif /* #if LTTNG_UST_COMPAT_API(0) */ #ifdef __cplusplus @@ -647,18 +653,18 @@ lttng_ust__tracepoints__ptrs_destroy(void) * * LTTNG_UST_TRACEPOINT_ENUM(someproject_component, enumname, * LTTNG_UST_TP_ENUM_VALUES( - * ctf_enum_value("even", 0) - * ctf_enum_value("uneven", 1) - * ctf_enum_range("twoto4", 2, 4) - * ctf_enum_value("five", 5) + * lttng_ust_field_enum_value("even", 0) + * lttng_ust_field_enum_value("uneven", 1) + * lttng_ust_field_enum_range("twoto4", 2, 4) + * lttng_ust_field_enum_value("five", 5) * ) * ) * * Where "someproject_component" is the name of the component this enumeration * belongs to and "enumname" identifies this enumeration. Inside the * LTTNG_UST_TP_ENUM_VALUES macro is the actual mapping. Each string value can map - * to either a single value with ctf_enum_value or a range of values - * with ctf_enum_range. + * to either a single value with lttng_ust_field_enum_value or a range of values + * with lttng_ust_field_enum_range. * * Enumeration ranges may overlap, but the behavior is implementation-defined, * each trace reader will handle overlapping as it wishes. @@ -666,7 +672,7 @@ lttng_ust__tracepoints__ptrs_destroy(void) * That enumeration can then be used in a field inside the TP_FIELD macro using * the following line: * - * ctf_enum(someproject_component, enumname, enumtype, enumfield, enumval) + * lttng_ust_field_enum(someproject_component, enumname, enumtype, enumfield, enumval) * * Where "someproject_component" and "enumname" match those in the * LTTNG_UST_TRACEPOINT_ENUM, "enumtype" is a signed or unsigned integer type @@ -706,7 +712,7 @@ lttng_ust__tracepoints__ptrs_destroy(void) * lttng_ust_field_integer_hex(unsigned long, field_d, arg1) * * * Enumeration * - * ctf_enum(someproject_component, enum_name, int, field_e, arg0) + * lttng_ust_field_enum(someproject_component, enum_name, int, field_e, arg0) * * * Array Sequence, printed as UTF8-encoded array of bytes * * lttng_ust_field_array_text(char, field_b, string, FIXED_LEN) diff --git a/include/lttng/ust-tracepoint-event-nowrite.h b/include/lttng/ust-tracepoint-event-nowrite.h index d5406c83..552955b6 100644 --- a/include/lttng/ust-tracepoint-event-nowrite.h +++ b/include/lttng/ust-tracepoint-event-nowrite.h @@ -67,6 +67,6 @@ #define lttng_ust_field_unused_nowrite(_src) \ lttng_ust__field_unused(_src) -#undef ctf_enum_nowrite -#define ctf_enum_nowrite(_provider, _name, _type, _item, _src) \ - _ctf_enum(_provider, _name, _type, _item, _src, 1) +#undef lttng_ust_field_enum_nowrite +#define lttng_ust_field_enum_nowrite(_provider, _name, _type, _item, _src) \ + lttng_ust__field_enum(_provider, _name, _type, _item, _src, 1) diff --git a/include/lttng/ust-tracepoint-event-reset.h b/include/lttng/ust-tracepoint-event-reset.h index ed1c465e..2bc255fa 100644 --- a/include/lttng/ust-tracepoint-event-reset.h +++ b/include/lttng/ust-tracepoint-event-reset.h @@ -48,8 +48,8 @@ #undef lttng_ust__field_unused #define lttng_ust__field_unused(_src) -#undef _ctf_enum -#define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) +#undef lttng_ust__field_enum +#define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) /* "write" */ #undef lttng_ust_field_integer @@ -103,8 +103,8 @@ #undef lttng_ust_field_unused #define lttng_ust_field_unused(_src) -#undef ctf_enum -#define ctf_enum(_provider, _name, _type, _item, _src) +#undef lttng_ust_field_enum +#define lttng_ust_field_enum(_provider, _name, _type, _item, _src) /* "nowrite" */ #undef lttng_ust_field_integer_nowrite @@ -149,5 +149,5 @@ #undef lttng_ust_field_unused_nowrite #define lttng_ust_field_unused_nowrite(_src) -#undef ctf_enum_nowrite -#define ctf_enum_nowrite(_provider, _name, _type, _item, _src) +#undef lttng_ust_field_enum_nowrite +#define lttng_ust_field_enum_nowrite(_provider, _name, _type, _item, _src) diff --git a/include/lttng/ust-tracepoint-event-write.h b/include/lttng/ust-tracepoint-event-write.h index 3c542980..f43fd4c3 100644 --- a/include/lttng/ust-tracepoint-event-write.h +++ b/include/lttng/ust-tracepoint-event-write.h @@ -82,6 +82,6 @@ #define lttng_ust_field_unused(_src) \ lttng_ust__field_unused(_src) -#undef ctf_enum -#define ctf_enum(_provider, _name, _type, _item, _src) \ - _ctf_enum(_provider, _name, _type, _item, _src, 0) +#undef lttng_ust_field_enum +#define lttng_ust_field_enum(_provider, _name, _type, _item, _src) \ + lttng_ust__field_enum(_provider, _name, _type, _item, _src, 0) diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 9399be21..cec6239e 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -146,8 +146,8 @@ void lttng_ust__event_template_proto___##_provider##___##_name(LTTNG_UST__TP_ARG #include /* Enumeration entry (single value) */ -#undef ctf_enum_value -#define ctf_enum_value(_string, _value) \ +#undef lttng_ust_field_enum_value +#define lttng_ust_field_enum_value(_string, _value) \ LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_enum_entry, { \ .struct_size = sizeof(struct lttng_ust_enum_entry), \ .start = { \ @@ -164,8 +164,8 @@ void lttng_ust__event_template_proto___##_provider##___##_name(LTTNG_UST__TP_ARG }), /* Enumeration entry (range) */ -#undef ctf_enum_range -#define ctf_enum_range(_string, _range_start, _range_end) \ +#undef lttng_ust_field_enum_range +#define lttng_ust_field_enum_range(_string, _range_start, _range_end) \ LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_enum_entry, { \ .struct_size = sizeof(struct lttng_ust_enum_entry), \ .start = { \ @@ -182,8 +182,8 @@ void lttng_ust__event_template_proto___##_provider##___##_name(LTTNG_UST__TP_ARG }), /* Enumeration entry (automatic value; follows the rules of CTF) */ -#undef ctf_enum_auto -#define ctf_enum_auto(_string) \ +#undef lttng_ust_field_enum_auto +#define lttng_ust_field_enum_auto(_string) \ LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_enum_entry, { \ .struct_size = sizeof(struct lttng_ust_enum_entry), \ .start = { \ @@ -211,7 +211,7 @@ void lttng_ust__event_template_proto___##_provider##___##_name(LTTNG_UST__TP_ARG #define LTTNG_UST_TRACEPOINT_ENUM(_provider, _name, _values) \ const struct lttng_ust_enum_entry * const __enum_values__##_provider##_##_name[] = { \ _values \ - ctf_enum_value("", 0) /* Dummy, 0-len array forbidden by C99. */ \ + lttng_ust_field_enum_value("", 0) /* Dummy, 0-len array forbidden by C99. */ \ }; #include LTTNG_UST_TRACEPOINT_INCLUDE @@ -346,8 +346,8 @@ void lttng_ust__event_template_proto___##_provider##___##_name(LTTNG_UST__TP_ARG #undef lttng_ust__field_unused #define lttng_ust__field_unused(_src) -#undef _ctf_enum -#define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \ +#undef lttng_ust__field_enum +#define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \ LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \ .struct_size = sizeof(struct lttng_ust_event_field), \ .name = #_item, \ @@ -456,8 +456,8 @@ static void lttng_ust__event_probe__##_provider##___##_name(LTTNG_UST__TP_ARGS_D if (0) \ (void) (_src); /* Unused */ -#undef _ctf_enum -#define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \ +#undef lttng_ust__field_enum +#define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \ lttng_ust__field_integer_ext(_type, _item, _src, LTTNG_UST_BYTE_ORDER, 10, _nowrite) #undef LTTNG_UST_TP_ARGS @@ -625,8 +625,8 @@ size_t lttng_ust__event_get_size__##_provider##___##_name( \ if (0) \ (void) (_src); -#undef _ctf_enum -#define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \ +#undef lttng_ust__field_enum +#define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \ lttng_ust__field_integer_ext(_type, _item, _src, LTTNG_UST_BYTE_ORDER, 10, _nowrite) #undef LTTNG_UST_TP_ARGS @@ -700,8 +700,8 @@ void lttng_ust__event_prepare_interpreter_stack__##_provider##___##_name(char *_ if (0) \ (void) (_src); /* Unused */ -#undef _ctf_enum -#define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \ +#undef lttng_ust__field_enum +#define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \ lttng_ust__field_integer_ext(_type, _item, _src, LTTNG_UST_BYTE_ORDER, 10, _nowrite) #undef LTTNG_UST_TP_ARGS @@ -784,8 +784,8 @@ size_t lttng_ust__event_get_align__##_provider##___##_name(LTTNG_UST__TP_ARGS_PR #undef lttng_ust__field_unused #define lttng_ust__field_unused(_src) -#undef _ctf_enum -#define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \ +#undef lttng_ust__field_enum +#define lttng_ust__field_enum(_provider, _name, _type, _item, _src, _nowrite) \ lttng_ust__field_integer_ext(_type, _item, _src, LTTNG_UST_BYTE_ORDER, 10, _nowrite) /* Beware: this get len actually consumes the len value */ diff --git a/src/lib/lttng-ust/lttng-ust-dynamic-type.c b/src/lib/lttng-ust/lttng-ust-dynamic-type.c index 4147e3a7..2b3ebd65 100644 --- a/src/lib/lttng-ust/lttng-ust-dynamic-type.c +++ b/src/lib/lttng-ust/lttng-ust-dynamic-type.c @@ -15,7 +15,7 @@ #include "common/macros.h" #include "common/dynamic-type.h" -#define ctf_enum_value(_string, _value) \ +#define lttng_ust_field_enum_value(_string, _value) \ LTTNG_UST_COMPOUND_LITERAL(struct lttng_ust_enum_entry, { \ .struct_size = sizeof(struct lttng_ust_enum_entry), \ .start = { \ @@ -32,18 +32,18 @@ }), static const struct lttng_ust_enum_entry *dt_enum[_NR_LTTNG_UST_DYNAMIC_TYPES] = { - [LTTNG_UST_DYNAMIC_TYPE_NONE] = ctf_enum_value("_none", 0) - [LTTNG_UST_DYNAMIC_TYPE_S8] = ctf_enum_value("_int8", 1) - [LTTNG_UST_DYNAMIC_TYPE_S16] = ctf_enum_value("_int16", 2) - [LTTNG_UST_DYNAMIC_TYPE_S32] = ctf_enum_value("_int32", 3) - [LTTNG_UST_DYNAMIC_TYPE_S64] = ctf_enum_value("_int64", 4) - [LTTNG_UST_DYNAMIC_TYPE_U8] = ctf_enum_value("_uint8", 5) - [LTTNG_UST_DYNAMIC_TYPE_U16] = ctf_enum_value("_uint16", 6) - [LTTNG_UST_DYNAMIC_TYPE_U32] = ctf_enum_value("_uint32", 7) - [LTTNG_UST_DYNAMIC_TYPE_U64] = ctf_enum_value("_uint64", 8) - [LTTNG_UST_DYNAMIC_TYPE_FLOAT] = ctf_enum_value("_float", 9) - [LTTNG_UST_DYNAMIC_TYPE_DOUBLE] = ctf_enum_value("_double", 10) - [LTTNG_UST_DYNAMIC_TYPE_STRING] = ctf_enum_value("_string", 11) + [LTTNG_UST_DYNAMIC_TYPE_NONE] = lttng_ust_field_enum_value("_none", 0) + [LTTNG_UST_DYNAMIC_TYPE_S8] = lttng_ust_field_enum_value("_int8", 1) + [LTTNG_UST_DYNAMIC_TYPE_S16] = lttng_ust_field_enum_value("_int16", 2) + [LTTNG_UST_DYNAMIC_TYPE_S32] = lttng_ust_field_enum_value("_int32", 3) + [LTTNG_UST_DYNAMIC_TYPE_S64] = lttng_ust_field_enum_value("_int64", 4) + [LTTNG_UST_DYNAMIC_TYPE_U8] = lttng_ust_field_enum_value("_uint8", 5) + [LTTNG_UST_DYNAMIC_TYPE_U16] = lttng_ust_field_enum_value("_uint16", 6) + [LTTNG_UST_DYNAMIC_TYPE_U32] = lttng_ust_field_enum_value("_uint32", 7) + [LTTNG_UST_DYNAMIC_TYPE_U64] = lttng_ust_field_enum_value("_uint64", 8) + [LTTNG_UST_DYNAMIC_TYPE_FLOAT] = lttng_ust_field_enum_value("_float", 9) + [LTTNG_UST_DYNAMIC_TYPE_DOUBLE] = lttng_ust_field_enum_value("_double", 10) + [LTTNG_UST_DYNAMIC_TYPE_STRING] = lttng_ust_field_enum_value("_string", 11) }; static struct lttng_ust_enum_desc dt_enum_desc = { diff --git a/tests/compile/ctf-types/ust_tests_ctf_types.h b/tests/compile/ctf-types/ust_tests_ctf_types.h index a0fb0b34..489f04a2 100644 --- a/tests/compile/ctf-types/ust_tests_ctf_types.h +++ b/tests/compile/ctf-types/ust_tests_ctf_types.h @@ -14,18 +14,18 @@ LTTNG_UST_TRACEPOINT_ENUM(ust_tests_ctf_types, testenum, LTTNG_UST_TP_ENUM_VALUES( - ctf_enum_value("even", 0) - ctf_enum_value("uneven", 1) - ctf_enum_range("twoto4", 2, 4) - ctf_enum_value("five\"extra\\test", 5) + lttng_ust_field_enum_value("even", 0) + lttng_ust_field_enum_value("uneven", 1) + lttng_ust_field_enum_range("twoto4", 2, 4) + lttng_ust_field_enum_value("five\"extra\\test", 5) ) ) LTTNG_UST_TRACEPOINT_ENUM(ust_tests_ctf_types, testenum2, LTTNG_UST_TP_ENUM_VALUES( - ctf_enum_value("zero", 0) - ctf_enum_value("five", 5) - ctf_enum_range("ten_to_twenty", 10, 20) + lttng_ust_field_enum_value("zero", 0) + lttng_ust_field_enum_value("five", 5) + lttng_ust_field_enum_range("ten_to_twenty", 10, 20) ) ) @@ -37,10 +37,10 @@ LTTNG_UST_TRACEPOINT_EVENT(ust_tests_ctf_types, tptest, LTTNG_UST_TP_ARGS(int, anint, int, enumval, int, enumval2), LTTNG_UST_TP_FIELDS( lttng_ust_field_integer(int, intfield, anint) - ctf_enum(ust_tests_ctf_types, testenum, int, enumfield, enumval) - ctf_enum(ust_tests_ctf_types, testenum, long long, + lttng_ust_field_enum(ust_tests_ctf_types, testenum, int, enumfield, enumval) + lttng_ust_field_enum(ust_tests_ctf_types, testenum, long long, enumfield_bis, enumval) - ctf_enum(ust_tests_ctf_types, testenum2, unsigned int, + lttng_ust_field_enum(ust_tests_ctf_types, testenum2, unsigned int, enumfield_third, enumval2) ) ) @@ -53,7 +53,7 @@ LTTNG_UST_TRACEPOINT_EVENT(ust_tests_ctf_types, tptest_bis, LTTNG_UST_TP_ARGS(int, anint, int, enumval), LTTNG_UST_TP_FIELDS( lttng_ust_field_integer(int, intfield, anint) - ctf_enum(ust_tests_ctf_types, testenum, unsigned char, + lttng_ust_field_enum(ust_tests_ctf_types, testenum, unsigned char, enumfield, enumval) ) ) diff --git a/tests/compile/hello.cxx/ust_tests_hello.h b/tests/compile/hello.cxx/ust_tests_hello.h index 3fd0f76a..9088aaf1 100644 --- a/tests/compile/hello.cxx/ust_tests_hello.h +++ b/tests/compile/hello.cxx/ust_tests_hello.h @@ -15,12 +15,12 @@ LTTNG_UST_TRACEPOINT_ENUM(ust_tests_hello, my_enum, LTTNG_UST_TP_ENUM_VALUES( - ctf_enum_value("zero", 0) - ctf_enum_value("one", 1) - ctf_enum_auto("two") - ctf_enum_value("three", 3) - ctf_enum_range("ten to twenty", 10, 20) - ctf_enum_auto("21!") + lttng_ust_field_enum_value("zero", 0) + lttng_ust_field_enum_value("one", 1) + lttng_ust_field_enum_auto("two") + lttng_ust_field_enum_value("three", 3) + lttng_ust_field_enum_range("ten to twenty", 10, 20) + lttng_ust_field_enum_auto("21!") ) ) @@ -44,7 +44,7 @@ LTTNG_UST_TRACEPOINT_EVENT(ust_tests_hello, tptest, lttng_ust_field_string(stringfield, text) lttng_ust_field_float(float, floatfield, floatarg) lttng_ust_field_float(double, doublefield, doublearg) - ctf_enum(ust_tests_hello, my_enum, int, enumfield, enumarg) + lttng_ust_field_enum(ust_tests_hello, my_enum, int, enumfield, enumarg) ) ) -- 2.34.1