X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=liblttng-ust%2Flttng-ust-dynamic-type.c;h=6913ca4b1d1877a82844abaa70eeb46acb60a7ba;hb=dc11f93f7d30cd383e35be41483cc024da59c7b8;hp=c654f019b715769749a8575b40dc4a0e8d927433;hpb=53569322d40ed45abe0368ddb08eb4a2738afc37;p=lttng-ust.git diff --git a/liblttng-ust/lttng-ust-dynamic-type.c b/liblttng-ust/lttng-ust-dynamic-type.c index c654f019..6913ca4b 100644 --- a/liblttng-ust/lttng-ust-dynamic-type.c +++ b/liblttng-ust/lttng-ust-dynamic-type.c @@ -1,95 +1,48 @@ /* - * lttng-ust-dynamic-type.c - * - * UST dynamic type implementation. + * SPDX-License-Identifier: LGPL-2.1-only * * Copyright (C) 2016 Mathieu Desnoyers * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; only - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * UST dynamic type implementation. */ -#define _GNU_SOURCE +#define _LGPL_SOURCE #include #include #include #include -#include -#include +#include +#include -static const struct lttng_enum_entry dt_enum[_NR_LTTNG_UST_DYNAMIC_TYPES] = { - [LTTNG_UST_DYNAMIC_TYPE_NONE] = { - .start = 0, - .end = 0, - .string = "_none", - }, - [LTTNG_UST_DYNAMIC_TYPE_S8] = { - .start = 1, - .end = 1, - .string = "_int8", - }, - [LTTNG_UST_DYNAMIC_TYPE_S16] = { - .start = 2, - .end = 2, - .string = "_int16", - }, - [LTTNG_UST_DYNAMIC_TYPE_S32] = { - .start = 3, - .end = 3, - .string = "_int32", - }, - [LTTNG_UST_DYNAMIC_TYPE_S64] = { - .start = 4, - .end = 4, - .string = "_int64", - }, - [LTTNG_UST_DYNAMIC_TYPE_U8] = { - .start = 5, - .end = 5, - .string = "_uint8", - }, - [LTTNG_UST_DYNAMIC_TYPE_U16] = { - .start = 6, - .end = 6, - .string = "_uint16", - }, - [LTTNG_UST_DYNAMIC_TYPE_U32] = { - .start = 7, - .end = 7, - .string = "_uint32", - }, - [LTTNG_UST_DYNAMIC_TYPE_U64] = { - .start = 8, - .end = 8, - .string = "_uint64", - }, - [LTTNG_UST_DYNAMIC_TYPE_FLOAT] = { - .start = 9, - .end = 9, - .string = "_float", - }, - [LTTNG_UST_DYNAMIC_TYPE_DOUBLE] = { - .start = 10, - .end = 10, - .string = "_double", - }, - [LTTNG_UST_DYNAMIC_TYPE_STRING] = { - .start = 11, - .end = 11, - .string = "_string", +#define ctf_enum_value(_string, _value) \ + { \ + .start = { \ + .signedness = lttng_is_signed_type(__typeof__(_value)), \ + .value = lttng_is_signed_type(__typeof__(_value)) ? \ + (long long) (_value) : (_value), \ + }, \ + .end = { \ + .signedness = lttng_is_signed_type(__typeof__(_value)), \ + .value = lttng_is_signed_type(__typeof__(_value)) ? \ + (long long) (_value) : (_value), \ + }, \ + .string = (_string), \ }, + +static const struct lttng_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) }; static const struct lttng_enum_desc dt_enum_desc = { @@ -102,8 +55,9 @@ const struct lttng_event_field dt_var_fields[_NR_LTTNG_UST_DYNAMIC_TYPES] = { [LTTNG_UST_DYNAMIC_TYPE_NONE] = { .name = "none", .type = { - .atype = atype_struct, - .u._struct.nr_fields = 0, /* empty struct. */ + .atype = atype_struct_nestable, + .u.struct_nestable.nr_fields = 0, /* empty struct. */ + .u.struct_nestable.alignment = 0, }, .nowrite = 0, }, @@ -161,7 +115,7 @@ const struct lttng_event_field dt_var_fields[_NR_LTTNG_UST_DYNAMIC_TYPES] = { .name = "string", .type = { .atype = atype_string, - .u.basic.string.encoding = lttng_encode_UTF8, + .u.string.encoding = lttng_encode_UTF8, }, .nowrite = 0, }, @@ -169,16 +123,11 @@ const struct lttng_event_field dt_var_fields[_NR_LTTNG_UST_DYNAMIC_TYPES] = { static const struct lttng_event_field dt_enum_field = { .name = NULL, - .type.atype = atype_enum, - .type.u.basic.enumeration.desc = &dt_enum_desc, - .type.u.basic.enumeration.container_type = { - .size = sizeof(char) * CHAR_BIT, - .alignment = lttng_alignof(char) * CHAR_BIT, - .signedness = lttng_is_signed_type(char), - .reverse_byte_order = 0, - .base = 10, - .encoding = lttng_encode_none, - }, + .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)), .nowrite = 0, };