From 72570d24a6ac9f6e0d4b7dd5cc9f6178170e543b Mon Sep 17 00:00:00 2001 From: Olivier Dion Date: Thu, 24 Oct 2024 12:14:12 -0400 Subject: [PATCH] Add attributes to optional types Change-Id: I3297006a806ec929a809dc09caca2cccbb99b96f Signed-off-by: Olivier Dion Signed-off-by: Mathieu Desnoyers --- include/side/abi/type-description.h | 2 ++ include/side/instrumentation-c-api.h | 17 ++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/side/abi/type-description.h b/include/side/abi/type-description.h index 431e0d2..6914223 100644 --- a/include/side/abi/type-description.h +++ b/include/side/abi/type-description.h @@ -414,6 +414,8 @@ side_check_size(struct side_type_variant, 40 + sizeof(const struct side_type)); struct side_type_optional { side_ptr_t(const struct side_type) elem_type; + side_ptr_t(const struct side_attr) attr; + uint32_t nr_attr; }; struct side_event_field { diff --git a/include/side/instrumentation-c-api.h b/include/side/instrumentation-c-api.h index 33e1e98..fedcaa2 100644 --- a/include/side/instrumentation-c-api.h +++ b/include/side/instrumentation-c-api.h @@ -642,19 +642,22 @@ enum { } \ } -#define _side_type_optional_define(_elem_type) \ - { \ - .elem_type = SIDE_PTR_INIT(_elem_type), \ +#define _side_type_optional_define(_elem_type, _attr...) \ + { \ + .elem_type = SIDE_PTR_INIT(_elem_type), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ } -#define _side_define_optional(_identifier, _elem_type) \ - const struct side_type_optional _identifier = _side_type_optional_define(SIDE_PARAM(_elem_type)) +#define _side_define_optional(_identifier, _elem_type, _attr...) \ + const struct side_type_optional _identifier = _side_type_optional_define(SIDE_PARAM(_elem_type), \ + SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) #define _side_field_optional(_name, _identifier) \ _side_field(_name, _side_type_optional(SIDE_PARAM(&(_identifier)))) -#define _side_field_optional_literal(_name, _elem_type) \ - _side_field(_name, _side_type_optional(SIDE_COMPOUND_LITERAL(struct side_type_optional, _side_type_optional_define(SIDE_PARAM(_elem_type))))) +#define _side_field_optional_literal(_name, _elem_type, _attr...) \ + _side_field(_name, _side_type_optional(SIDE_COMPOUND_LITERAL(struct side_type_optional, _side_type_optional_define(SIDE_PARAM(_elem_type), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))))) #define _side_type_array(_array) \ { \ -- 2.34.1