X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=liblttng-ust%2Flttng-ust-dynamic-type.c;h=3012869971e9ea3a321d4ff8c4a8fdbc16425192;hb=4e48b5d2debaf6c0c598489c183cc6cb2125c8a3;hp=c94d6cc4ae139a0a87d4197a2cf1dfbdd913f86d;hpb=5152f6df156d6ccb234965d1b3d26b167bd6b94e;p=lttng-ust.git diff --git a/liblttng-ust/lttng-ust-dynamic-type.c b/liblttng-ust/lttng-ust-dynamic-type.c index c94d6cc4..30128699 100644 --- a/liblttng-ust/lttng-ust-dynamic-type.c +++ b/liblttng-ust/lttng-ust-dynamic-type.c @@ -31,7 +31,7 @@ .string = (_string), \ }), -static struct lttng_ust_enum_entry *dt_enum[_NR_LTTNG_UST_DYNAMIC_TYPES] = { +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) @@ -52,8 +52,8 @@ static struct lttng_ust_enum_desc dt_enum_desc = { .nr_entries = LTTNG_ARRAY_SIZE(dt_enum), }; -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, { +const struct lttng_ust_event_field *dt_var_fields[_NR_LTTNG_UST_DYNAMIC_TYPES] = { + [LTTNG_UST_DYNAMIC_TYPE_NONE] = __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_event_field, { .struct_size = sizeof(struct lttng_ust_event_field), .name = "none", .type = (struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_struct, { @@ -66,67 +66,67 @@ struct lttng_ust_event_field *dt_var_fields[_NR_LTTNG_UST_DYNAMIC_TYPES] = { }), .nowrite = 0, }), - [LTTNG_UST_DYNAMIC_TYPE_S8] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + [LTTNG_UST_DYNAMIC_TYPE_S8] = __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_event_field, { .struct_size = sizeof(struct lttng_ust_event_field), .name = "int8", .type = lttng_ust_type_integer_define(int8_t, BYTE_ORDER, 10), .nowrite = 0, }), - [LTTNG_UST_DYNAMIC_TYPE_S16] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + [LTTNG_UST_DYNAMIC_TYPE_S16] = __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_event_field, { .struct_size = sizeof(struct lttng_ust_event_field), .name = "int16", .type = lttng_ust_type_integer_define(int16_t, BYTE_ORDER, 10), .nowrite = 0, }), - [LTTNG_UST_DYNAMIC_TYPE_S32] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + [LTTNG_UST_DYNAMIC_TYPE_S32] = __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_event_field, { .struct_size = sizeof(struct lttng_ust_event_field), .name = "int32", .type = lttng_ust_type_integer_define(int32_t, BYTE_ORDER, 10), .nowrite = 0, }), - [LTTNG_UST_DYNAMIC_TYPE_S64] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + [LTTNG_UST_DYNAMIC_TYPE_S64] = __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_event_field, { .struct_size = sizeof(struct lttng_ust_event_field), .name = "int64", .type = lttng_ust_type_integer_define(int64_t, BYTE_ORDER, 10), .nowrite = 0, }), - [LTTNG_UST_DYNAMIC_TYPE_U8] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + [LTTNG_UST_DYNAMIC_TYPE_U8] = __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_event_field, { .struct_size = sizeof(struct lttng_ust_event_field), .name = "uint8", .type = lttng_ust_type_integer_define(uint8_t, BYTE_ORDER, 10), .nowrite = 0, }), - [LTTNG_UST_DYNAMIC_TYPE_U16] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + [LTTNG_UST_DYNAMIC_TYPE_U16] = __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_event_field, { .struct_size = sizeof(struct lttng_ust_event_field), .name = "uint16", .type = lttng_ust_type_integer_define(uint16_t, BYTE_ORDER, 10), .nowrite = 0, }), - [LTTNG_UST_DYNAMIC_TYPE_U32] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + [LTTNG_UST_DYNAMIC_TYPE_U32] = __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_event_field, { .struct_size = sizeof(struct lttng_ust_event_field), .name = "uint32", .type = lttng_ust_type_integer_define(uint32_t, BYTE_ORDER, 10), .nowrite = 0, }), - [LTTNG_UST_DYNAMIC_TYPE_U64] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + [LTTNG_UST_DYNAMIC_TYPE_U64] = __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_event_field, { .struct_size = sizeof(struct lttng_ust_event_field), .name = "uint64", .type = lttng_ust_type_integer_define(uint64_t, BYTE_ORDER, 10), .nowrite = 0, }), - [LTTNG_UST_DYNAMIC_TYPE_FLOAT] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + [LTTNG_UST_DYNAMIC_TYPE_FLOAT] = __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_event_field, { .struct_size = sizeof(struct lttng_ust_event_field), .name = "float", .type = lttng_ust_type_float_define(float), .nowrite = 0, }), - [LTTNG_UST_DYNAMIC_TYPE_DOUBLE] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + [LTTNG_UST_DYNAMIC_TYPE_DOUBLE] = __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_event_field, { .struct_size = sizeof(struct lttng_ust_event_field), .name = "double", .type = lttng_ust_type_float_define(double), .nowrite = 0, }), - [LTTNG_UST_DYNAMIC_TYPE_STRING] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { + [LTTNG_UST_DYNAMIC_TYPE_STRING] = __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_event_field, { .struct_size = sizeof(struct lttng_ust_event_field), .name = "string", .type = (struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_string, { @@ -140,7 +140,7 @@ struct lttng_ust_event_field *dt_var_fields[_NR_LTTNG_UST_DYNAMIC_TYPES] = { }), }; -static struct lttng_ust_event_field dt_enum_field = { +static const struct lttng_ust_event_field dt_enum_field = { .struct_size = sizeof(struct lttng_ust_event_field), .name = NULL, .type = (struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_enum, { @@ -154,21 +154,21 @@ static struct lttng_ust_event_field dt_enum_field = { .nowrite = 0, }; -struct lttng_ust_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]; } -int lttng_ust_dynamic_type_choices(size_t *nr_choices, struct lttng_ust_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; } -struct lttng_ust_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; }