struct side_type_float side_float;
/* Stack-copy compound types */
- struct side_type_array side_array;
- struct side_type_vla side_vla;
+ side_ptr_t(const struct side_type_array) side_array;
+ side_ptr_t(const struct side_type_vla) side_vla;
side_ptr_t(const struct side_type_vla_visitor) side_vla_visitor;
side_ptr_t(const struct side_type_struct) side_struct;
side_ptr_t(const struct side_type_variant) side_variant;
.side_struct = SIDE_PTR_INIT(_struct), \
}, \
}
+
#define side_field_struct(_name, _struct) \
_side_field(_name, side_type_struct(SIDE_PARAM(_struct)))
#define side_field_optional_literal(_name, _type) \
_side_field(_name, side_type_optional(SIDE_PARAM(_type)))
-#define side_type_array(_elem_type, _length, _attr...) \
- { \
- .type = SIDE_ENUM_INIT(SIDE_TYPE_ARRAY), \
- .u = { \
- .side_array = { \
- .elem_type = SIDE_PTR_INIT(_elem_type), \
- .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
- .length = _length, \
- .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
- }, \
- }, \
+#define side_type_array(_array) \
+ { \
+ .type = SIDE_ENUM_INIT(SIDE_TYPE_ARRAY), \
+ .u = { \
+ .side_array = SIDE_PTR_INIT(_array) \
+ } \
}
-#define side_field_array(_name, _elem_type, _length, _attr...) \
- _side_field(_name, side_type_array(SIDE_PARAM(_elem_type), _length, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
-#define side_type_vla(_elem_type, _length_type, _attr...) \
- { \
- .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA), \
- .u = { \
- .side_vla = { \
- .elem_type = SIDE_PTR_INIT(_elem_type), \
- .length_type = SIDE_PTR_INIT(_length_type), \
- .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
- .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
- }, \
- }, \
+#define side_field_array(_name, _array) \
+ _side_field(_name, side_type_array(_array))
+
+#define side_define_array(_identifier, _elem_type, _length, _attr...) \
+ const struct side_type_array _identifier = { \
+ .elem_type = SIDE_PTR_INIT(SIDE_PARAM(_elem_type)), \
+ .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
+ .length = _length, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
+ }
+
+#define side_type_vla(_vla) \
+ { \
+ .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA), \
+ .u = { \
+ .side_vla = SIDE_PTR_INIT(_vla), \
+ }, \
+ }
+
+#define side_field_vla(_name, _vla) \
+ _side_field(_name, side_type_vla(_vla))
+
+#define side_define_vla(_identifier, _elem_type, _length_type, _attr...) \
+ const struct side_type_vla _identifier = { \
+ .elem_type = SIDE_PTR_INIT(SIDE_PARAM(_elem_type)), \
+ .length_type = SIDE_PTR_INIT(SIDE_PARAM(_length_type)), \
+ .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
}
-#define side_field_vla(_name, _elem_type, _length_type, _attr...) \
- _side_field(_name, side_type_vla(SIDE_PARAM(_elem_type), SIDE_PARAM(_length_type), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
#define _side_type_vla_visitor_define(_elem_type, _length_type, _visitor, _attr...) \
{ \
nr_items = 1;
break;
case SIDE_TYPE_ARRAY:
- elem_type = side_ptr_get(enum_elem_type->u.side_array.elem_type);
+ elem_type = side_ptr_get(side_ptr_get(enum_elem_type->u.side_array)->elem_type);
array_item = side_ptr_get(side_ptr_get(item->u.side_static.side_array)->sav);
- nr_items = type_desc->u.side_array.length;
+ nr_items = side_ptr_get(type_desc->u.side_array)->length;
break;
case SIDE_TYPE_VLA:
- elem_type = side_ptr_get(enum_elem_type->u.side_vla.elem_type);
+ elem_type = side_ptr_get(side_ptr_get(enum_elem_type->u.side_vla)->elem_type);
array_item = side_ptr_get(side_ptr_get(item->u.side_static.side_vla)->sav);
nr_items = side_ptr_get(item->u.side_static.side_vla)->len;
break;
const struct side_arg *sav = side_ptr_get(side_arg_vec->sav);
uint32_t i, side_sav_len = side_arg_vec->len;
- if (type_desc->u.side_array.length != side_sav_len) {
+ if (side_ptr_get(type_desc->u.side_array)->length != side_sav_len) {
fprintf(stderr, "ERROR: length mismatch between description and arguments of array\n");
abort();
}
if (type_visitor->before_array_type_func)
- type_visitor->before_array_type_func(&type_desc->u.side_array, side_arg_vec, priv);
+ type_visitor->before_array_type_func(side_ptr_get(type_desc->u.side_array), side_arg_vec, priv);
for (i = 0; i < side_sav_len; i++) {
struct visit_context new_ctx = {
.type = CONTEXT_ARRAY,
.array_index = i,
.parent = ctx
};
- side_visit_elem(type_visitor, &new_ctx, side_ptr_get(type_desc->u.side_array.elem_type), &sav[i], priv);
+ side_visit_elem(type_visitor, &new_ctx, side_ptr_get(side_ptr_get(type_desc->u.side_array)->elem_type), &sav[i], priv);
}
if (type_visitor->after_array_type_func)
- type_visitor->after_array_type_func(&type_desc->u.side_array, side_arg_vec, priv);
+ type_visitor->after_array_type_func(side_ptr_get(type_desc->u.side_array), side_arg_vec, priv);
}
static
uint32_t i, side_sav_len = side_arg_vec->len;
if (type_visitor->before_vla_type_func)
- type_visitor->before_vla_type_func(&type_desc->u.side_vla, side_arg_vec, priv);
+ type_visitor->before_vla_type_func(side_ptr_get(type_desc->u.side_vla), side_arg_vec, priv);
for (i = 0; i < side_sav_len; i++) {
struct visit_context new_ctx = {
.type = CONTEXT_ARRAY,
.array_index = i,
.parent = ctx
};
- side_visit_elem(type_visitor, &new_ctx, side_ptr_get(type_desc->u.side_vla.elem_type), &sav[i], priv);
+ side_visit_elem(type_visitor, &new_ctx, side_ptr_get(side_ptr_get(type_desc->u.side_vla)->elem_type), &sav[i], priv);
}
if (type_visitor->after_vla_type_func)
- type_visitor->after_vla_type_func(&type_desc->u.side_vla, side_arg_vec, priv);
+ type_visitor->after_vla_type_func(side_ptr_get(type_desc->u.side_vla), side_arg_vec, priv);
}
struct tracer_visitor_priv {
void description_visitor_array(const struct side_description_visitor *description_visitor, const struct side_type *type_desc, void *priv)
{
if (description_visitor->before_array_type_func)
- description_visitor->before_array_type_func(&type_desc->u.side_array, priv);
- side_visit_elem(description_visitor, side_ptr_get(type_desc->u.side_array.elem_type), priv);
+ description_visitor->before_array_type_func(side_ptr_get(type_desc->u.side_array), priv);
+ side_visit_elem(description_visitor, side_ptr_get(side_ptr_get(type_desc->u.side_array)->elem_type), priv);
if (description_visitor->after_array_type_func)
- description_visitor->after_array_type_func(&type_desc->u.side_array, priv);
+ description_visitor->after_array_type_func(side_ptr_get(type_desc->u.side_array), priv);
}
static
void description_visitor_vla(const struct side_description_visitor *description_visitor, const struct side_type *type_desc, void *priv)
{
if (description_visitor->before_vla_type_func)
- description_visitor->before_vla_type_func(&type_desc->u.side_vla, priv);
- side_visit_elem(description_visitor, side_ptr_get(type_desc->u.side_vla.length_type), priv);
+ description_visitor->before_vla_type_func(side_ptr_get(type_desc->u.side_vla), priv);
+ side_visit_elem(description_visitor, side_ptr_get(side_ptr_get(type_desc->u.side_vla)->length_type), priv);
if (description_visitor->after_length_vla_type_func)
- description_visitor->after_length_vla_type_func(&type_desc->u.side_vla, priv);
- side_visit_elem(description_visitor, side_ptr_get(type_desc->u.side_vla.elem_type), priv);
+ description_visitor->after_length_vla_type_func(side_ptr_get(type_desc->u.side_vla), priv);
+ side_visit_elem(description_visitor, side_ptr_get(side_ptr_get(type_desc->u.side_vla)->elem_type), priv);
if (description_visitor->after_element_vla_type_func)
- description_visitor->after_element_vla_type_func(&type_desc->u.side_vla, priv);
+ description_visitor->after_element_vla_type_func(side_ptr_get(type_desc->u.side_vla), priv);
}
static
}
}
+static side_define_array(my_array_u32_3,
+ side_elem(side_type_u32()),
+ 3
+);
+
side_static_event(my_provider_event_array, "myprovider", "myarray", SIDE_LOGLEVEL_DEBUG,
side_field_list(
- side_field_array("arr", side_elem(side_type_u32()), 3),
+ side_field_array("arr", &my_array_u32_3),
side_field_s64("v"),
)
);
}
}
+static side_define_vla(my_vla_u32,
+ side_elem(side_type_u32()),
+ side_elem(side_type_u32())
+);
+
side_static_event(my_provider_event_vla, "myprovider", "myvla", SIDE_LOGLEVEL_DEBUG,
side_field_list(
- side_field_vla("vla", side_elem(side_type_u32()), side_elem(side_type_u32())),
+ side_field_vla("vla", &my_vla_u32),
side_field_s64("v"),
)
);
)
);
+static side_define_array(my_array_u32_5,
+ side_elem(side_type_u32()),
+ 5
+);
+
+static side_define_vla(my_vla_u32_for_bitmap,
+ side_elem(side_type_u32()),
+ side_elem(side_type_u32())
+);
+
side_static_event(my_provider_event_enum_bitmap, "myprovider", "myeventenumbitmap", SIDE_LOGLEVEL_DEBUG,
side_field_list(
side_field_enum_bitmap("bit_0", &myenum_bitmap, side_elem(side_type_u32())),
side_field_enum_bitmap("bits_1+63", &myenum_bitmap, side_elem(side_type_u64())),
side_field_enum_bitmap("byte_bit_2", &myenum_bitmap, side_elem(side_type_byte())),
side_field_enum_bitmap("bit_159", &myenum_bitmap,
- side_elem(side_type_array(side_elem(side_type_u32()), 5))),
+ side_elem(side_type_array(&my_array_u32_5))),
side_field_enum_bitmap("bit_159", &myenum_bitmap,
- side_elem(side_type_vla(side_elem(side_type_u32()), side_elem(side_type_u32())))),
+ side_elem(side_type_vla(&my_vla_u32_for_bitmap))),
side_field_enum_bitmap("bit_2_be", &myenum_bitmap, side_elem(side_type_u32_be())),
side_field_enum_bitmap("bit_2_le", &myenum_bitmap, side_elem(side_type_u32_le())),
)
}
}
+static side_define_array(my_array_byte,
+ side_elem(side_type_byte()),
+ 3
+);
+
side_static_event_variadic(my_provider_event_blob, "myprovider", "myeventblob", SIDE_LOGLEVEL_DEBUG,
side_field_list(
side_field_byte("blobfield"),
- side_field_array("arrayblob", side_elem(side_type_byte()), 3),
+ side_field_array("arrayblob", &my_array_byte),
)
);