From: Mathieu Desnoyers Date: Mon, 15 Mar 2021 21:23:57 +0000 (-0400) Subject: Refactoring: struct lttng_event_field X-Git-Tag: v2.13.0-rc1~291 X-Git-Url: https://git.lttng.org/?a=commitdiff_plain;h=25cff019d711338b8a7efe1cc54e4b1870157348;p=lttng-ust.git Refactoring: struct lttng_event_field - Namespace this structure with lttng_ust_ prefix, - Use struct_size extensibility scheme, - Remove padding, - Use an array of pointers to structure rather than array of event fields to allow easier handling of extensibility. This is achieved by using __LTTNG_COMPOUND_LITERAL(). - Move nofilter field into structure. Signed-off-by: Mathieu Desnoyers Change-Id: Iaa0056ff2d67042d0b6fca156c8f8072ae1820ea --- diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index b43b49e1..acea9910 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -43,7 +43,7 @@ extern "C" { struct lttng_channel; struct lttng_session; struct lttng_ust_lib_ring_buffer_ctx; -struct lttng_event_field; +struct lttng_ust_event_field; struct lttng_event_notifier_group; /* @@ -183,7 +183,7 @@ struct lttng_type { } sequence_nestable; struct { unsigned int nr_fields; - const struct lttng_event_field *fields; /* Array of fields. */ + const struct lttng_ust_event_field **fields; /* Array of pointers to fields. */ unsigned int alignment; } struct_nestable; @@ -205,19 +205,21 @@ struct lttng_enum_desc { * IMPORTANT: this structure is part of the ABI between the probe and * UST. Fields need to be only added at the end, never reordered, never * removed. + * + * The field @struct_size should be used to determine the size of the + * structure. It should be queried before using additional fields added + * at the end of the structure. */ -#define LTTNG_UST_EVENT_FIELD_PADDING 28 -struct lttng_event_field { +struct lttng_ust_event_field { + uint32_t struct_size; + const char *name; struct lttng_type type; - unsigned int nowrite; /* do not write into trace */ - union { - struct { - unsigned int nofilter:1; /* do not consider for filter */ - } ext; - char padding[LTTNG_UST_EVENT_FIELD_PADDING]; - } u; + unsigned int nowrite:1, /* do not write into trace */ + nofilter:1; /* do not consider for filter */ + + /* End of base ABI. Fields below should be used after checking struct_size. */ }; enum lttng_ust_dynamic_type { @@ -250,7 +252,7 @@ struct lttng_perf_counter_field; #define LTTNG_UST_CTX_FIELD_PADDING 40 struct lttng_ctx_field { - struct lttng_event_field event_field; + struct lttng_ust_event_field event_field; size_t (*get_size)(struct lttng_ctx_field *field, size_t offset); void (*record)(struct lttng_ctx_field *field, struct lttng_ust_lib_ring_buffer_ctx *ctx, @@ -288,7 +290,7 @@ struct lttng_ust_event_desc { const char *name; void (*probe_callback)(void); const struct lttng_event_ctx *ctx; /* context */ - const struct lttng_event_field *fields; /* event payload */ + const struct lttng_ust_event_field **fields; /* event payload */ unsigned int nr_fields; const int **loglevel; const char *signature; /* Argument types/names received */ diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 9fbe70e8..872dfa57 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -254,120 +254,95 @@ void __event_template_proto___##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args) #include #undef _ctf_integer_ext -#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \ - { \ - .name = #_item, \ - .type = __type_integer(_type, _byte_order, _base, none),\ - .nowrite = _nowrite, \ - .u = { \ - .ext = { \ - .nofilter = 0, \ - }, \ - }, \ - }, +#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \ + __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { \ + .struct_size = sizeof(struct lttng_ust_event_field), \ + .name = #_item, \ + .type = __type_integer(_type, _byte_order, _base, none), \ + .nowrite = _nowrite, \ + .nofilter = 0, \ + }), #undef _ctf_float #define _ctf_float(_type, _item, _src, _nowrite) \ - { \ - .name = #_item, \ - .type = __type_float(_type), \ - .nowrite = _nowrite, \ - .u = { \ - .ext = { \ - .nofilter = 0, \ - }, \ - }, \ - }, + __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { \ + .struct_size = sizeof(struct lttng_ust_event_field), \ + .name = #_item, \ + .type = __type_float(_type), \ + .nowrite = _nowrite, \ + .nofilter = 0, \ + }), #undef _ctf_array_encoded #define _ctf_array_encoded(_type, _item, _src, _byte_order, \ _length, _encoding, _nowrite, \ _elem_type_base) \ - { \ - .name = #_item, \ - .type = \ - { \ - .atype = atype_array_nestable, \ - .u = \ - { \ - .array_nestable = \ - { \ - .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \ + __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { \ + .struct_size = sizeof(struct lttng_ust_event_field), \ + .name = #_item, \ + .type = { \ + .atype = atype_array_nestable, \ + .u = { \ + .array_nestable = { \ + .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \ __type_integer(_type, _byte_order, _elem_type_base, _encoding)), \ - .length = _length, \ - .alignment = 0, \ + .length = _length, \ + .alignment = 0, \ } \ } \ }, \ - .nowrite = _nowrite, \ - .u = { \ - .ext = { \ - .nofilter = 0, \ - }, \ - }, \ - }, + .nowrite = _nowrite, \ + .nofilter = 0, \ + }), #undef _ctf_sequence_encoded #define _ctf_sequence_encoded(_type, _item, _src, _byte_order, \ _length_type, _src_length, _encoding, _nowrite, \ _elem_type_base) \ - { \ - .name = "_" #_item "_length", \ - .type = __type_integer(_length_type, BYTE_ORDER, 10, none), \ - .nowrite = _nowrite, \ - .u = { \ - .ext = { \ - .nofilter = 1, \ - }, \ - }, \ - }, \ - { \ - .name = #_item, \ - .type = \ - { \ - .atype = atype_sequence_nestable, \ - .u = \ - { \ - .sequence_nestable = \ - { \ - .length_name = "_" #_item "_length", \ - .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \ - __type_integer(_type, _byte_order, _elem_type_base, _encoding)), \ - .alignment = 0, \ + __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { \ + .struct_size = sizeof(struct lttng_ust_event_field), \ + .name = "_" #_item "_length", \ + .type = __type_integer(_length_type, BYTE_ORDER, 10, none), \ + .nowrite = _nowrite, \ + .nofilter = 1, \ + }), \ + __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { \ + .struct_size = sizeof(struct lttng_ust_event_field), \ + .name = #_item, \ + .type = { \ + .atype = atype_sequence_nestable, \ + .u = { \ + .sequence_nestable = { \ + .length_name = "_" #_item "_length", \ + .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \ + __type_integer(_type, _byte_order, _elem_type_base, _encoding)), \ + .alignment = 0, \ }, \ }, \ }, \ - .nowrite = _nowrite, \ - .u = { \ - .ext = { \ - .nofilter = 0, \ - }, \ - }, \ - }, + .nowrite = _nowrite, \ + .nofilter = 0, \ + }), #undef _ctf_string #define _ctf_string(_item, _src, _nowrite) \ - { \ - .name = #_item, \ - .type = \ - { \ - .atype = atype_string, \ - .u = \ - { \ - .string = { .encoding = lttng_encode_UTF8 } \ + __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { \ + .struct_size = sizeof(struct lttng_ust_event_field), \ + .name = #_item, \ + .type = { \ + .atype = atype_string, \ + .u = { \ + .string = { .encoding = lttng_encode_UTF8 } \ }, \ }, \ - .nowrite = _nowrite, \ - .u = { \ - .ext = { \ - .nofilter = 0, \ - }, \ - }, \ - }, + .nowrite = _nowrite, \ + .nofilter = 0, \ + }), #undef _ctf_enum #define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \ - { \ + __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { \ + .struct_size = sizeof(struct lttng_ust_event_field), \ .name = #_item, \ .type = { \ .atype = atype_enum_nestable, \ @@ -380,19 +355,15 @@ void __event_template_proto___##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args) }, \ }, \ .nowrite = _nowrite, \ - .u = { \ - .ext = { \ - .nofilter = 0, \ - }, \ - }, \ - }, + .nofilter = 0, \ + }), #undef TP_FIELDS #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */ #undef _TRACEPOINT_EVENT_CLASS #define _TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \ - static const struct lttng_event_field __event_fields___##_provider##___##_name[] = { \ + static const struct lttng_ust_event_field *__event_fields___##_provider##___##_name[] = { \ _fields \ ctf_integer(int, dummy, 0) /* Dummy, C99 forbids 0-len array. */ \ }; diff --git a/include/ust-comm.h b/include/ust-comm.h index bc185669..3d1ba372 100644 --- a/include/ust-comm.h +++ b/include/ust-comm.h @@ -42,7 +42,7 @@ #define LTTNG_UST_COMM_MAX_LISTEN 10 #define LTTNG_UST_COMM_REG_MSG_PADDING 64 -struct lttng_event_field; +struct lttng_ust_event_field; struct lttng_ctx_field; struct lttng_enum_entry; struct lttng_integer_type; @@ -279,7 +279,7 @@ int ustcomm_register_event(int sock, int loglevel, const char *signature, /* event signature (input) */ size_t nr_fields, /* fields */ - const struct lttng_event_field *fields, + const struct lttng_ust_event_field **fields, const char *model_emf_uri, uint32_t *id); /* event id (output) */ diff --git a/include/ust-dynamic-type.h b/include/ust-dynamic-type.h index d88e3c09..e7425048 100644 --- a/include/ust-dynamic-type.h +++ b/include/ust-dynamic-type.h @@ -13,10 +13,10 @@ LTTNG_HIDDEN int lttng_ust_dynamic_type_choices(size_t *nr_choices, - const struct lttng_event_field **choices); + const struct lttng_ust_event_field ***choices); LTTNG_HIDDEN -const struct lttng_event_field *lttng_ust_dynamic_type_field(int64_t value); +const struct lttng_ust_event_field *lttng_ust_dynamic_type_field(int64_t value); LTTNG_HIDDEN -const struct lttng_event_field *lttng_ust_dynamic_type_tag_field(void); +const struct lttng_ust_event_field *lttng_ust_dynamic_type_tag_field(void); #endif /* _LTTNG_UST_DYNAMIC_TYPE_H */ diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c index cfd4ddf6..e0b7d73b 100644 --- a/liblttng-ust-comm/lttng-ust-comm.c +++ b/liblttng-ust-comm/lttng-ust-comm.c @@ -37,16 +37,16 @@ static ssize_t count_fields_recursive(size_t nr_fields, - const struct lttng_event_field *lttng_fields); + const struct lttng_ust_event_field **lttng_fields); static int serialize_one_field(struct lttng_session *session, struct ustctl_field *fields, size_t *iter_output, - const struct lttng_event_field *lf); + const struct lttng_ust_event_field *lf); static int serialize_fields(struct lttng_session *session, struct ustctl_field *ustctl_fields, size_t *iter_output, size_t nr_lttng_fields, - const struct lttng_event_field *lttng_fields); + const struct lttng_ust_event_field **lttng_fields); /* * Human readable error message. @@ -884,7 +884,7 @@ ssize_t count_one_type(const struct lttng_type *lt) case atype_dynamic: { - const struct lttng_event_field *choices; + const struct lttng_ust_event_field **choices; size_t nr_choices; int ret; @@ -907,15 +907,15 @@ ssize_t count_one_type(const struct lttng_type *lt) static ssize_t count_fields_recursive(size_t nr_fields, - const struct lttng_event_field *lttng_fields) + const struct lttng_ust_event_field **lttng_fields) { int i; ssize_t ret, count = 0; for (i = 0; i < nr_fields; i++) { - const struct lttng_event_field *lf; + const struct lttng_ust_event_field *lf; - lf = <tng_fields[i]; + lf = lttng_fields[i]; /* skip 'nowrite' fields */ if (lf->nowrite) continue; @@ -935,7 +935,7 @@ ssize_t count_ctx_fields_recursive(size_t nr_fields, ssize_t ret, count = 0; for (i = 0; i < nr_fields; i++) { - const struct lttng_event_field *lf; + const struct lttng_ust_event_field *lf; lf = <tng_fields[i].event_field; /* skip 'nowrite' fields */ @@ -991,11 +991,11 @@ int serialize_dynamic_type(struct lttng_session *session, struct ustctl_field *fields, size_t *iter_output, const char *field_name) { - const struct lttng_event_field *choices; + const struct lttng_ust_event_field **choices; char tag_field_name[LTTNG_UST_ABI_SYM_NAME_LEN]; const struct lttng_type *tag_type; - const struct lttng_event_field *tag_field_generic; - struct lttng_event_field tag_field = { + const struct lttng_ust_event_field *tag_field_generic; + struct lttng_ust_event_field tag_field = { .name = tag_field_name, .nowrite = 0, }; @@ -1038,7 +1038,7 @@ int serialize_dynamic_type(struct lttng_session *session, /* Serialize choice fields after variant. */ for (i = 0; i < nr_choices; i++) { ret = serialize_one_field(session, fields, - iter_output, &choices[i]); + iter_output, choices[i]); if (ret) return ret; } @@ -1238,7 +1238,7 @@ int serialize_one_type(struct lttng_session *session, static int serialize_one_field(struct lttng_session *session, struct ustctl_field *fields, size_t *iter_output, - const struct lttng_event_field *lf) + const struct lttng_ust_event_field *lf) { /* skip 'nowrite' fields */ if (lf->nowrite) @@ -1251,14 +1251,14 @@ static int serialize_fields(struct lttng_session *session, struct ustctl_field *ustctl_fields, size_t *iter_output, size_t nr_lttng_fields, - const struct lttng_event_field *lttng_fields) + const struct lttng_ust_event_field **lttng_fields) { int ret; size_t i; for (i = 0; i < nr_lttng_fields; i++) { ret = serialize_one_field(session, ustctl_fields, - iter_output, <tng_fields[i]); + iter_output, lttng_fields[i]); if (ret) return ret; } @@ -1270,7 +1270,7 @@ int alloc_serialize_fields(struct lttng_session *session, size_t *_nr_write_fields, struct ustctl_field **ustctl_fields, size_t nr_fields, - const struct lttng_event_field *lttng_fields) + const struct lttng_ust_event_field **lttng_fields) { struct ustctl_field *fields; int ret; @@ -1384,7 +1384,7 @@ int ustcomm_register_event(int sock, int loglevel, const char *signature, /* event signature (input) */ size_t nr_fields, /* fields */ - const struct lttng_event_field *lttng_fields, + const struct lttng_ust_event_field **lttng_fields, const char *model_emf_uri, uint32_t *id) /* event id (output) */ { diff --git a/liblttng-ust/lttng-bytecode-interpreter.c b/liblttng-ust/lttng-bytecode-interpreter.c index 65d06576..46351a25 100644 --- a/liblttng-ust/lttng-bytecode-interpreter.c +++ b/liblttng-ust/lttng-bytecode-interpreter.c @@ -223,7 +223,7 @@ static int context_get_index(struct lttng_ctx *ctx, { struct lttng_ctx_field *ctx_field; - struct lttng_event_field *field; + struct lttng_ust_event_field *field; struct lttng_ctx_value v; ctx_field = &ctx->fields[idx]; diff --git a/liblttng-ust/lttng-bytecode-specialize.c b/liblttng-ust/lttng-bytecode-specialize.c index 2982a793..3cb31ba2 100644 --- a/liblttng-ust/lttng-bytecode-specialize.c +++ b/liblttng-ust/lttng-bytecode-specialize.c @@ -253,7 +253,7 @@ static int specialize_get_index(struct bytecode_runtime *runtime, case OBJECT_TYPE_ARRAY: { const struct lttng_integer_type *integer_type; - const struct lttng_event_field *field; + const struct lttng_ust_event_field *field; uint32_t elem_len, num_elems; int signedness; @@ -293,7 +293,7 @@ static int specialize_get_index(struct bytecode_runtime *runtime, case OBJECT_TYPE_SEQUENCE: { const struct lttng_integer_type *integer_type; - const struct lttng_event_field *field; + const struct lttng_ust_event_field *field; uint32_t elem_len; int signedness; @@ -377,7 +377,7 @@ static int specialize_context_lookup_name(struct lttng_ctx *ctx, return lttng_get_context_index(ctx, name); } -static int specialize_load_object(const struct lttng_event_field *field, +static int specialize_load_object(const struct lttng_ust_event_field *field, struct vstack_load *load, bool is_context) { load->type = LOAD_OBJECT; @@ -458,7 +458,7 @@ static int specialize_context_lookup(struct lttng_ctx *ctx, { int idx, ret; struct lttng_ctx_field *ctx_field; - struct lttng_event_field *field; + struct lttng_ust_event_field *field; struct bytecode_get_index_data gid; ssize_t data_offset; @@ -497,7 +497,7 @@ static int specialize_app_context_lookup(struct lttng_ctx **pctx, char *name = NULL; int idx, ret; struct lttng_ctx_field *ctx_field; - struct lttng_event_field *field; + struct lttng_ust_event_field *field; struct bytecode_get_index_data gid; ssize_t data_offset; @@ -556,7 +556,7 @@ static int specialize_payload_lookup(const struct lttng_ust_event_desc *event_de unsigned int i, nr_fields; bool found = false; uint32_t field_offset = 0; - const struct lttng_event_field *field; + const struct lttng_ust_event_field *field; int ret; struct bytecode_get_index_data gid; ssize_t data_offset; @@ -565,8 +565,8 @@ static int specialize_payload_lookup(const struct lttng_ust_event_desc *event_de offset = ((struct get_symbol *) insn->data)->offset; name = runtime->p.priv->bc->bc.data + runtime->p.priv->bc->bc.reloc_offset + offset; for (i = 0; i < nr_fields; i++) { - field = &event_desc->fields[i]; - if (field->u.ext.nofilter) { + field = event_desc->fields[i]; + if (field->nofilter) { continue; } if (!strcmp(field->name, name)) { diff --git a/liblttng-ust/lttng-bytecode.c b/liblttng-ust/lttng-bytecode.c index ef458055..39881be0 100644 --- a/liblttng-ust/lttng-bytecode.c +++ b/liblttng-ust/lttng-bytecode.c @@ -178,7 +178,7 @@ int apply_field_reloc(const struct lttng_ust_event_desc *event_desc, const char *field_name, enum bytecode_op bytecode_op) { - const struct lttng_event_field *fields, *field = NULL; + const struct lttng_ust_event_field **fields, *field = NULL; unsigned int nr_fields, i; struct load_op *op; uint32_t field_offset = 0; @@ -193,15 +193,15 @@ int apply_field_reloc(const struct lttng_ust_event_desc *event_desc, return -EINVAL; nr_fields = event_desc->nr_fields; for (i = 0; i < nr_fields; i++) { - if (fields[i].u.ext.nofilter) { + if (fields[i]->nofilter) { continue; } - if (!strcmp(fields[i].name, field_name)) { - field = &fields[i]; + if (!strcmp(fields[i]->name, field_name)) { + field = fields[i]; break; } /* compute field offset */ - switch (fields[i].type.atype) { + switch (fields[i]->type.atype) { case atype_integer: case atype_enum_nestable: field_offset += sizeof(int64_t); diff --git a/liblttng-ust/lttng-bytecode.h b/liblttng-ust/lttng-bytecode.h index 8caf15ec..90b4c332 100644 --- a/liblttng-ust/lttng-bytecode.h +++ b/liblttng-ust/lttng-bytecode.h @@ -119,7 +119,7 @@ struct bytecode_get_index_data { * interpreter needs to find it from the event fields and types to * support variants. */ - const struct lttng_event_field *field; + const struct lttng_ust_event_field *field; struct { size_t len; enum object_type type; @@ -131,7 +131,7 @@ struct bytecode_get_index_data { struct vstack_load { enum load_type type; enum object_type object_type; - const struct lttng_event_field *field; + const struct lttng_ust_event_field *field; bool rev_bo; /* reverse byte order */ }; @@ -208,7 +208,7 @@ struct load_ptr { uint64_t u64; double d; } u; - const struct lttng_event_field *field; + const struct lttng_ust_event_field *field; }; struct estack_entry { diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index 7dfe6b7a..3c78734f 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -475,7 +475,7 @@ int lttng_create_enum_check(const struct lttng_type *type, } case atype_dynamic: { - const struct lttng_event_field *tag_field_generic; + const struct lttng_ust_event_field *tag_field_generic; const struct lttng_enum_desc *enum_desc; int ret; @@ -497,7 +497,7 @@ int lttng_create_enum_check(const struct lttng_type *type, static int lttng_create_all_event_enums(size_t nr_fields, - const struct lttng_event_field *event_fields, + const struct lttng_ust_event_field **event_fields, struct lttng_session *session) { size_t i; @@ -505,7 +505,7 @@ int lttng_create_all_event_enums(size_t nr_fields, /* For each field, ensure enum is part of the session. */ for (i = 0; i < nr_fields; i++) { - const struct lttng_type *type = &event_fields[i].type; + const struct lttng_type *type = &event_fields[i]->type; ret = lttng_create_enum_check(type, session); if (ret) @@ -1141,10 +1141,10 @@ void _event_enum_destroy(struct lttng_ust_event_common *event) /* Destroy enums of the current event. */ for (i = 0; i < event_recorder->parent->priv->desc->nr_fields; i++) { const struct lttng_enum_desc *enum_desc; - const struct lttng_event_field *field; + const struct lttng_ust_event_field *field; struct lttng_enum *curr_enum; - field = &(event_recorder->parent->priv->desc->fields[i]); + field = event_recorder->parent->priv->desc->fields[i]; switch (field->type.atype) { case atype_enum_nestable: enum_desc = field->type.u.enum_nestable.desc; diff --git a/liblttng-ust/lttng-probes.c b/liblttng-ust/lttng-probes.c index d009a874..98998b0f 100644 --- a/liblttng-ust/lttng-probes.c +++ b/liblttng-ust/lttng-probes.c @@ -338,8 +338,8 @@ int lttng_probes_get_field_list(struct lttng_ust_field_list *list) } for (j = 0; j < event_desc->nr_fields; j++) { - const struct lttng_event_field *event_field = - &event_desc->fields[j]; + const struct lttng_ust_event_field *event_field = + event_desc->fields[j]; struct tp_field_list_entry *list_entry; list_entry = zmalloc(sizeof(*list_entry)); diff --git a/liblttng-ust/lttng-ust-dynamic-type.c b/liblttng-ust/lttng-ust-dynamic-type.c index 6913ca4b..1647094f 100644 --- a/liblttng-ust/lttng-ust-dynamic-type.c +++ b/liblttng-ust/lttng-ust-dynamic-type.c @@ -51,8 +51,9 @@ static const struct lttng_enum_desc dt_enum_desc = { .nr_entries = LTTNG_ARRAY_SIZE(dt_enum), }; -const struct lttng_event_field dt_var_fields[_NR_LTTNG_UST_DYNAMIC_TYPES] = { - [LTTNG_UST_DYNAMIC_TYPE_NONE] = { +const struct lttng_ust_event_field *dt_var_fields[_NR_LTTNG_UST_DYNAMIC_TYPES] = { + [LTTNG_UST_DYNAMIC_TYPE_NONE] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + .struct_size = sizeof(struct lttng_ust_event_field), .name = "none", .type = { .atype = atype_struct_nestable, @@ -60,68 +61,79 @@ const struct lttng_event_field dt_var_fields[_NR_LTTNG_UST_DYNAMIC_TYPES] = { .u.struct_nestable.alignment = 0, }, .nowrite = 0, - }, - [LTTNG_UST_DYNAMIC_TYPE_S8] = { + }), + [LTTNG_UST_DYNAMIC_TYPE_S8] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + .struct_size = sizeof(struct lttng_ust_event_field), .name = "int8", .type = __type_integer(int8_t, BYTE_ORDER, 10, none), .nowrite = 0, - }, - [LTTNG_UST_DYNAMIC_TYPE_S16] = { + }), + [LTTNG_UST_DYNAMIC_TYPE_S16] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + .struct_size = sizeof(struct lttng_ust_event_field), .name = "int16", .type = __type_integer(int16_t, BYTE_ORDER, 10, none), .nowrite = 0, - }, - [LTTNG_UST_DYNAMIC_TYPE_S32] = { + }), + [LTTNG_UST_DYNAMIC_TYPE_S32] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + .struct_size = sizeof(struct lttng_ust_event_field), .name = "int32", .type = __type_integer(int32_t, BYTE_ORDER, 10, none), .nowrite = 0, - }, - [LTTNG_UST_DYNAMIC_TYPE_S64] = { + }), + [LTTNG_UST_DYNAMIC_TYPE_S64] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + .struct_size = sizeof(struct lttng_ust_event_field), .name = "int64", .type = __type_integer(int64_t, BYTE_ORDER, 10, none), .nowrite = 0, - }, - [LTTNG_UST_DYNAMIC_TYPE_U8] = { + }), + [LTTNG_UST_DYNAMIC_TYPE_U8] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + .struct_size = sizeof(struct lttng_ust_event_field), .name = "uint8", .type = __type_integer(uint8_t, BYTE_ORDER, 10, none), .nowrite = 0, - }, - [LTTNG_UST_DYNAMIC_TYPE_U16] = { + }), + [LTTNG_UST_DYNAMIC_TYPE_U16] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + .struct_size = sizeof(struct lttng_ust_event_field), .name = "uint16", .type = __type_integer(uint16_t, BYTE_ORDER, 10, none), .nowrite = 0, - }, - [LTTNG_UST_DYNAMIC_TYPE_U32] = { + }), + [LTTNG_UST_DYNAMIC_TYPE_U32] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + .struct_size = sizeof(struct lttng_ust_event_field), .name = "uint32", .type = __type_integer(uint32_t, BYTE_ORDER, 10, none), .nowrite = 0, - }, - [LTTNG_UST_DYNAMIC_TYPE_U64] = { + }), + [LTTNG_UST_DYNAMIC_TYPE_U64] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + .struct_size = sizeof(struct lttng_ust_event_field), .name = "uint64", .type = __type_integer(uint64_t, BYTE_ORDER, 10, none), .nowrite = 0, - }, - [LTTNG_UST_DYNAMIC_TYPE_FLOAT] = { + }), + [LTTNG_UST_DYNAMIC_TYPE_FLOAT] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + .struct_size = sizeof(struct lttng_ust_event_field), .name = "float", .type = __type_float(float), .nowrite = 0, - }, - [LTTNG_UST_DYNAMIC_TYPE_DOUBLE] = { + }), + [LTTNG_UST_DYNAMIC_TYPE_DOUBLE] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + .struct_size = sizeof(struct lttng_ust_event_field), .name = "double", .type = __type_float(double), .nowrite = 0, - }, - [LTTNG_UST_DYNAMIC_TYPE_STRING] = { + }), + [LTTNG_UST_DYNAMIC_TYPE_STRING] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + .struct_size = sizeof(struct lttng_ust_event_field), .name = "string", .type = { .atype = atype_string, .u.string.encoding = lttng_encode_UTF8, }, .nowrite = 0, - }, + }), }; -static const struct lttng_event_field dt_enum_field = { +static const struct lttng_ust_event_field dt_enum_field = { .name = NULL, .type.atype = atype_enum_nestable, .type.u.enum_nestable.desc = &dt_enum_desc, @@ -131,21 +143,21 @@ static const struct lttng_event_field dt_enum_field = { .nowrite = 0, }; -const struct lttng_event_field *lttng_ust_dynamic_type_field(int64_t value) +const struct lttng_ust_event_field *lttng_ust_dynamic_type_field(int64_t value) { if (value >= _NR_LTTNG_UST_DYNAMIC_TYPES || value < 0) return NULL; - return &dt_var_fields[value]; + return dt_var_fields[value]; } -int lttng_ust_dynamic_type_choices(size_t *nr_choices, const struct lttng_event_field **choices) +int lttng_ust_dynamic_type_choices(size_t *nr_choices, const struct lttng_ust_event_field ***choices) { *nr_choices = _NR_LTTNG_UST_DYNAMIC_TYPES; *choices = dt_var_fields; return 0; } -const struct lttng_event_field *lttng_ust_dynamic_type_tag_field(void) +const struct lttng_ust_event_field *lttng_ust_dynamic_type_tag_field(void) { return &dt_enum_field; }