Refactoring: UST types public interfaces
[lttng-ust.git] / liblttng-ust / lttng-ust-dynamic-type.c
index ccda6475d7a773793aeaaee05f44f8b27cb5b605..4b58d82cde474a2990b5f07021075ee83bb1284c 100644 (file)
@@ -31,7 +31,7 @@
                .string = (_string),                                    \
        }),
 
-static const struct lttng_ust_enum_entry *dt_enum[_NR_LTTNG_UST_DYNAMIC_TYPES] = {
+static 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)
@@ -46,119 +46,129 @@ static const struct lttng_ust_enum_entry *dt_enum[_NR_LTTNG_UST_DYNAMIC_TYPES] =
        [LTTNG_UST_DYNAMIC_TYPE_STRING] = ctf_enum_value("_string", 11)
 };
 
-static const struct lttng_ust_enum_desc dt_enum_desc = {
+static struct lttng_ust_enum_desc dt_enum_desc = {
        .name = "dynamic_type_enum",
        .entries = dt_enum,
        .nr_entries = LTTNG_ARRAY_SIZE(dt_enum),
 };
 
-const struct lttng_ust_event_field *dt_var_fields[_NR_LTTNG_UST_DYNAMIC_TYPES] = {
+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,
-                       .u.struct_nestable.nr_fields = 0,       /* empty struct. */
-                       .u.struct_nestable.alignment = 0,
-               },
+               .type = (struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_struct, {
+                       .parent = {
+                               .type = lttng_ust_type_struct,
+                       },
+                       .struct_size = sizeof(struct lttng_ust_type_struct),
+                       .nr_fields = 0, /* empty struct */
+                       .alignment = 0,
+               }),
                .nowrite = 0,
        }),
        [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),
+               .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, {
                .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "int16",
-               .type = __type_integer(int16_t, BYTE_ORDER, 10, none),
+               .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, {
                .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "int32",
-               .type = __type_integer(int32_t, BYTE_ORDER, 10, none),
+               .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, {
                .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "int64",
-               .type = __type_integer(int64_t, BYTE_ORDER, 10, none),
+               .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, {
                .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "uint8",
-               .type = __type_integer(uint8_t, BYTE_ORDER, 10, none),
+               .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, {
                .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "uint16",
-               .type = __type_integer(uint16_t, BYTE_ORDER, 10, none),
+               .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, {
                .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "uint32",
-               .type = __type_integer(uint32_t, BYTE_ORDER, 10, none),
+               .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, {
                .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "uint64",
-               .type = __type_integer(uint64_t, BYTE_ORDER, 10, none),
+               .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, {
                .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "float",
-               .type = __type_float(float),
+               .type = lttng_ust_type_float_define(float),
                .nowrite = 0,
        }),
        [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),
+               .type = lttng_ust_type_float_define(double),
                .nowrite = 0,
        }),
        [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,
-               },
+               .type = (struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_string, {
+                       .parent = {
+                               .type = lttng_ust_type_string,
+                       },
+                       .struct_size = sizeof(struct lttng_ust_type_string),
+                       .encoding = lttng_ust_string_encoding_UTF8,
+               }),
                .nowrite = 0,
        }),
 };
 
-static const struct lttng_ust_event_field dt_enum_field = {
+static struct lttng_ust_event_field dt_enum_field = {
+       .struct_size = sizeof(struct lttng_ust_event_field),
        .name = NULL,
-       .type.atype = atype_enum_nestable,
-       .type.u.enum_nestable.desc = &dt_enum_desc,
-       .type.u.enum_nestable.container_type =
-               __LTTNG_COMPOUND_LITERAL(struct lttng_type,
-                       __type_integer(char, BYTE_ORDER, 10, none)),
+       .type = (struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_enum, {
+               .parent = {
+                       .type = lttng_ust_type_enum,
+               },
+               .struct_size = sizeof(struct lttng_ust_type_enum),
+               .desc = &dt_enum_desc,
+               .container_type = lttng_ust_type_integer_define(char, BYTE_ORDER, 10),
+       }),
        .nowrite = 0,
 };
 
-const struct lttng_ust_event_field *lttng_ust_dynamic_type_field(int64_t value)
+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, const struct lttng_ust_event_field ***choices)
+int lttng_ust_dynamic_type_choices(size_t *nr_choices, struct lttng_ust_event_field ***choices)
 {
        *nr_choices = _NR_LTTNG_UST_DYNAMIC_TYPES;
        *choices = dt_var_fields;
        return 0;
 }
 
-const struct lttng_ust_event_field *lttng_ust_dynamic_type_tag_field(void)
+struct lttng_ust_event_field *lttng_ust_dynamic_type_tag_field(void)
 {
        return &dt_enum_field;
 }
This page took 0.025925 seconds and 4 git commands to generate.