trace.h: Use side_ptr_t for stack-copy compound type args
[libside.git] / include / side / trace.h
index f7bf90122cf5c4a4fffe5fedc99a9062c530d41e..76c82b84dcaa328329542f616e1305696498c6ee 100644 (file)
@@ -260,7 +260,7 @@ union side_float_value {
 } SIDE_PACKED;
 
 struct side_type_raw_string {
-       const void *p;                  /* pointer to string */
+       side_ptr_t(const void) p;       /* pointer to string */
        uint8_t unit_size;              /* 1, 2, or 4 bytes */
        uint8_t byte_order;             /* enum side_type_label_byte_order */
 } SIDE_PACKED;
@@ -283,12 +283,12 @@ struct side_attr {
 
 /* Type descriptions */
 struct side_type_null {
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t nr_attr;
 } SIDE_PACKED;
 
 struct side_type_bool {
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t nr_attr;
        uint16_t bool_size;             /* bytes */
        uint16_t len_bits;              /* bits. 0 for (bool_size * CHAR_BITS) */
@@ -296,19 +296,19 @@ struct side_type_bool {
 } SIDE_PACKED;
 
 struct side_type_byte {
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t nr_attr;
 } SIDE_PACKED;
 
 struct side_type_string {
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t nr_attr;
        uint8_t unit_size;              /* 1, 2, or 4 bytes */
        uint8_t byte_order;             /* enum side_type_label_byte_order */
 } SIDE_PACKED;
 
 struct side_type_integer {
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t nr_attr;
        uint16_t integer_size;          /* bytes */
        uint16_t len_bits;              /* bits. 0 for (integer_size * CHAR_BITS) */
@@ -317,7 +317,7 @@ struct side_type_integer {
 } SIDE_PACKED;
 
 struct side_type_float {
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t nr_attr;
        uint16_t float_size;            /* bytes */
        uint8_t byte_order;             /* enum side_type_label_byte_order */
@@ -330,8 +330,8 @@ struct side_enum_mapping {
 } SIDE_PACKED;
 
 struct side_enum_mappings {
-       const struct side_enum_mapping *mappings;
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_enum_mapping) mappings;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t nr_mappings;
        uint32_t nr_attr;
 } SIDE_PACKED;
@@ -343,47 +343,47 @@ struct side_enum_bitmap_mapping {
 } SIDE_PACKED;
 
 struct side_enum_bitmap_mappings {
-       const struct side_enum_bitmap_mapping *mappings;
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_enum_bitmap_mapping) mappings;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t nr_mappings;
        uint32_t nr_attr;
 } SIDE_PACKED;
 
 struct side_type_struct {
-       const struct side_event_field *fields;
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_event_field) fields;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t nr_fields;
        uint32_t nr_attr;
 } SIDE_PACKED;
 
 struct side_type_array {
-       const struct side_type *elem_type;
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_type) elem_type;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t length;
        uint32_t nr_attr;
 } SIDE_PACKED;
 
 struct side_type_vla {
-       const struct side_type *elem_type;
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_type) elem_type;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t nr_attr;
 } SIDE_PACKED;
 
 struct side_type_vla_visitor {
-       const struct side_type *elem_type;
+       side_ptr_t(const struct side_type) elem_type;
        side_visitor_func visitor;
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t nr_attr;
 } SIDE_PACKED;
 
 struct side_type_enum {
-       const struct side_enum_mappings *mappings;
-       const struct side_type *elem_type;
+       side_ptr_t(const struct side_enum_mappings) mappings;
+       side_ptr_t(const struct side_type) elem_type;
 } SIDE_PACKED;
 
 struct side_type_enum_bitmap {
-       const struct side_enum_bitmap_mappings *mappings;
-       const struct side_type *elem_type;
+       side_ptr_t(const struct side_enum_bitmap_mappings) mappings;
+       side_ptr_t(const struct side_type) elem_type;
 } SIDE_PACKED;
 
 struct side_type_gather_bool {
@@ -419,14 +419,14 @@ struct side_type_gather_string {
 } SIDE_PACKED;
 
 struct side_type_gather_enum {
-       const struct side_enum_mappings *mappings;
-       const struct side_type *elem_type;
+       side_ptr_t(const struct side_enum_mappings) mappings;
+       side_ptr_t(const struct side_type) elem_type;
 } SIDE_PACKED;
 
 struct side_type_gather_struct {
        uint64_t offset;        /* bytes */
        uint8_t access_mode;    /* enum side_type_gather_access_mode */
-       const struct side_type_struct *type;
+       side_ptr_t(const struct side_type_struct) type;
        uint32_t size;          /* bytes */
 } SIDE_PACKED;
 
@@ -437,7 +437,7 @@ struct side_type_gather_array {
 } SIDE_PACKED;
 
 struct side_type_gather_vla {
-       const struct side_type *length_type;    /* side_length() */
+       side_ptr_t(const struct side_type) length_type; /* side_length() */
 
        uint64_t offset;        /* bytes */
        uint8_t access_mode;    /* enum side_type_gather_access_mode */
@@ -473,8 +473,8 @@ struct side_type {
                struct side_type_array side_array;
                struct side_type_vla side_vla;
                struct side_type_vla_visitor side_vla_visitor;
-               const struct side_type_struct *side_struct;
-               const struct side_type_variant *side_variant;
+               side_ptr_t(const struct side_type_struct) side_struct;
+               side_ptr_t(const struct side_type_variant) side_variant;
 
                /* Stack-copy enumeration types */
                struct side_type_enum side_enum;
@@ -493,14 +493,14 @@ struct side_variant_option {
 
 struct side_type_variant {
        const struct side_type selector;
-       const struct side_variant_option *options;
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_variant_option) options;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t nr_options;
        uint32_t nr_attr;
 } SIDE_PACKED;
 
 struct side_event_field {
-       const char *field_name;
+       side_ptr_t(const char) field_name;
        struct side_type side_type;
 } SIDE_PACKED;
 
@@ -530,10 +530,10 @@ union side_arg_static {
        union side_float_value float_value;
 
        /* Stack-copy compound types */
-       const struct side_arg_vec *side_struct;
-       const struct side_arg_variant *side_variant;
-       const struct side_arg_vec *side_array;
-       const struct side_arg_vec *side_vla;
+       side_ptr_t(const struct side_arg_vec) side_struct;
+       side_ptr_t(const struct side_arg_variant) side_variant;
+       side_ptr_t(const struct side_arg_vec) side_array;
+       side_ptr_t(const struct side_arg_vec) side_vla;
        void *side_vla_app_visitor_ctx;
 
        /* Gather basic types */
@@ -554,14 +554,14 @@ union side_arg_static {
 
 struct side_arg_dynamic_vla {
        const struct side_arg *sav;
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t len;
        uint32_t nr_attr;
 } SIDE_PACKED;
 
 struct side_arg_dynamic_struct {
        const struct side_arg_dynamic_field *fields;
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t len;
        uint32_t nr_attr;
 } SIDE_PACKED;
@@ -569,14 +569,14 @@ struct side_arg_dynamic_struct {
 struct side_dynamic_struct_visitor {
        void *app_ctx;
        side_dynamic_struct_visitor_func visitor;
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t nr_attr;
 } SIDE_PACKED;
 
 struct side_dynamic_vla_visitor {
        void *app_ctx;
        side_visitor_func visitor;
-       const struct side_attr *attr;
+       side_ptr_t(const struct side_attr) attr;
        uint32_t nr_attr;
 } SIDE_PACKED;
 
@@ -650,19 +650,27 @@ struct side_tracer_dynamic_struct_visitor_ctx {
        void *priv;             /* Private tracer context. */
 } SIDE_PACKED;
 
+/*
+ * This structure is _not_ packed to allow atomic operations on its
+ * fields.
+ */
+struct side_event_state {
+       uintptr_t enabled;
+       const struct side_callback *callbacks;
+       uint32_t nr_callbacks;
+};
+
 struct side_event_description {
-       uintptr_t *enabled;
+       struct side_event_state *state;
        const char *provider_name;
        const char *event_name;
        const struct side_event_field *fields;
-       const struct side_attr *attr;
-       const struct side_callback *callbacks;
+       side_ptr_t(const struct side_attr) attr;
        uint64_t flags;
        uint32_t version;
        uint32_t loglevel;      /* enum side_loglevel */
        uint32_t nr_fields;
        uint32_t nr_attr;
-       uint32_t nr_callbacks;
 } SIDE_PACKED;
 
 /* Event and type attributes */
@@ -670,7 +678,7 @@ struct side_event_description {
 #define side_attr(_key, _value)        \
        { \
                .key = { \
-                       .p = (_key), \
+                       .p = SIDE_PTR_INIT(_key), \
                        .unit_size = sizeof(uint8_t), \
                        .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
                }, \
@@ -700,7 +708,7 @@ struct side_event_description {
                .type = SIDE_ATTR_TYPE_STRING, \
                .u = { \
                        .string_value = { \
-                               .p = (const void *) (_val), \
+                               .p = SIDE_PTR_INIT(_val), \
                                .unit_size = _unit_size, \
                                .byte_order = _byte_order, \
                        }, \
@@ -715,8 +723,8 @@ struct side_event_description {
 
 #define side_define_enum(_identifier, _mappings, _attr...) \
        const struct side_enum_mappings _identifier = { \
-               .mappings = _mappings, \
-               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+               .mappings = SIDE_PTR_INIT(_mappings), \
+               .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
                .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \
                .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
        }
@@ -729,7 +737,7 @@ struct side_event_description {
                .range_begin = _begin, \
                .range_end = _end, \
                .label = { \
-                       .p = (_label), \
+                       .p = SIDE_PTR_INIT(_label), \
                        .unit_size = sizeof(uint8_t), \
                        .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
                }, \
@@ -740,7 +748,7 @@ struct side_event_description {
                .range_begin = _value, \
                .range_end = _value, \
                .label = { \
-                       .p = (_label), \
+                       .p = SIDE_PTR_INIT(_label), \
                        .unit_size = sizeof(uint8_t), \
                        .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
                }, \
@@ -748,8 +756,8 @@ struct side_event_description {
 
 #define side_define_enum_bitmap(_identifier, _mappings, _attr...) \
        const struct side_enum_bitmap_mappings _identifier = { \
-               .mappings = _mappings, \
-               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+               .mappings = SIDE_PTR_INIT(_mappings), \
+               .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
                .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \
                .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
        }
@@ -762,7 +770,7 @@ struct side_event_description {
                .range_begin = _begin, \
                .range_end = _end, \
                .label = { \
-                       .p = (_label), \
+                       .p = SIDE_PTR_INIT(_label), \
                        .unit_size = sizeof(uint8_t), \
                        .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
                }, \
@@ -773,7 +781,7 @@ struct side_event_description {
                .range_begin = _value, \
                .range_end = _value, \
                .label = { \
-                       .p = (_label), \
+                       .p = SIDE_PTR_INIT(_label), \
                        .unit_size = sizeof(uint8_t), \
                        .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
                }, \
@@ -786,7 +794,7 @@ struct side_event_description {
                .type = SIDE_TYPE_NULL, \
                .u = { \
                        .side_null = { \
-                               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                               .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())), \
                        }, \
                }, \
@@ -797,7 +805,7 @@ struct side_event_description {
                .type = SIDE_TYPE_BOOL, \
                .u = { \
                        .side_bool = { \
-                               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                               .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())), \
                                .bool_size = sizeof(uint8_t), \
                                .len_bits = 0, \
@@ -811,7 +819,7 @@ struct side_event_description {
                .type = SIDE_TYPE_BYTE, \
                .u = { \
                        .side_byte = { \
-                               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                               .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())), \
                        }, \
                }, \
@@ -822,7 +830,7 @@ struct side_event_description {
                .type = _type, \
                .u = { \
                        .side_string = { \
-                               .attr = _attr, \
+                               .attr = SIDE_PTR_INIT(_attr), \
                                .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
                                .unit_size = _unit_size, \
                                .byte_order = _byte_order, \
@@ -840,7 +848,7 @@ struct side_event_description {
                .type = _type, \
                .u = { \
                        .side_integer = { \
-                               .attr = _attr, \
+                               .attr = SIDE_PTR_INIT(_attr), \
                                .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
                                .integer_size = _integer_size, \
                                .len_bits = _len_bits, \
@@ -855,7 +863,7 @@ struct side_event_description {
                .type = _type, \
                .u = { \
                        .side_float = { \
-                               .attr = _attr, \
+                               .attr = SIDE_PTR_INIT(_attr), \
                                .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
                                .float_size = _float_size, \
                                .byte_order = _byte_order, \
@@ -865,7 +873,7 @@ struct side_event_description {
 
 #define _side_field(_name, _type) \
        { \
-               .field_name = _name, \
+               .field_name = SIDE_PTR_INIT(_name), \
                .side_type = _type, \
        }
 
@@ -981,8 +989,8 @@ struct side_event_description {
                .type = SIDE_TYPE_ENUM, \
                .u = { \
                        .side_enum = { \
-                               .mappings = _mappings, \
-                               .elem_type = _elem_type, \
+                               .mappings = SIDE_PTR_INIT(_mappings), \
+                               .elem_type = SIDE_PTR_INIT(_elem_type), \
                        }, \
                }, \
        }
@@ -994,8 +1002,8 @@ struct side_event_description {
                .type = SIDE_TYPE_ENUM_BITMAP, \
                .u = { \
                        .side_enum_bitmap = { \
-                               .mappings = _mappings, \
-                               .elem_type = _elem_type, \
+                               .mappings = SIDE_PTR_INIT(_mappings), \
+                               .elem_type = SIDE_PTR_INIT(_elem_type), \
                        }, \
                }, \
        }
@@ -1006,7 +1014,7 @@ struct side_event_description {
        { \
                .type = SIDE_TYPE_STRUCT, \
                .u = { \
-                       .side_struct = _struct, \
+                       .side_struct = SIDE_PTR_INIT(_struct), \
                }, \
        }
 #define side_field_struct(_name, _struct) \
@@ -1014,8 +1022,8 @@ struct side_event_description {
 
 #define _side_type_struct_define(_fields, _attr) \
        { \
-               .fields = _fields, \
-               .attr = _attr, \
+               .fields = SIDE_PTR_INIT(_fields), \
+               .attr = SIDE_PTR_INIT(_attr), \
                .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
                .nr_attr  = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
        }
@@ -1031,7 +1039,7 @@ struct side_event_description {
        { \
                .type = SIDE_TYPE_VARIANT, \
                .u = { \
-                       .side_variant = _variant, \
+                       .side_variant = SIDE_PTR_INIT(_variant), \
                }, \
        }
 #define side_field_variant(_name, _variant) \
@@ -1040,8 +1048,8 @@ struct side_event_description {
 #define _side_type_variant_define(_selector, _options, _attr) \
        { \
                .selector = _selector, \
-               .options = _options, \
-               .attr = _attr, \
+               .options = SIDE_PTR_INIT(_options), \
+               .attr = SIDE_PTR_INIT(_attr), \
                .nr_options = SIDE_ARRAY_SIZE(SIDE_PARAM(_options)), \
                .nr_attr  = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
        }
@@ -1059,8 +1067,8 @@ struct side_event_description {
                .type = SIDE_TYPE_ARRAY, \
                .u = { \
                        .side_array = { \
-                               .elem_type = _elem_type, \
-                               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                               .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())), \
                        }, \
@@ -1074,8 +1082,8 @@ struct side_event_description {
                .type = SIDE_TYPE_VLA, \
                .u = { \
                        .side_vla = { \
-                               .elem_type = _elem_type, \
-                               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                               .elem_type = SIDE_PTR_INIT(_elem_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())), \
                        }, \
                }, \
@@ -1088,9 +1096,9 @@ struct side_event_description {
                .type = SIDE_TYPE_VLA_VISITOR, \
                .u = { \
                        .side_vla_visitor = { \
-                               .elem_type = SIDE_PARAM(_elem_type), \
+                               .elem_type = SIDE_PTR_INIT(_elem_type), \
                                .visitor = _visitor, \
-                               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                               .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())), \
                        }, \
                }, \
@@ -1110,7 +1118,7 @@ struct side_event_description {
                                                .offset = _offset, \
                                                .access_mode = _access_mode, \
                                                .type = { \
-                                                       .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                                       .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())), \
                                                }, \
                                        }, \
@@ -1131,7 +1139,7 @@ struct side_event_description {
                                                .offset = _offset, \
                                                .access_mode = _access_mode, \
                                                .type = { \
-                                                       .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                                       .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())), \
                                                        .bool_size = _bool_size, \
                                                        .len_bits = _len_bits, \
@@ -1168,7 +1176,7 @@ struct side_event_description {
                                                .offset = _offset, \
                                                .access_mode = _access_mode, \
                                                .type = { \
-                                                       .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                                       .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())), \
                                                        .integer_size = _integer_size, \
                                                        .len_bits = _len_bits, \
@@ -1246,7 +1254,7 @@ struct side_event_description {
                                                .offset = _offset, \
                                                .access_mode = _access_mode, \
                                                .type = { \
-                                                       .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                                       .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())), \
                                                        .float_size = _float_size, \
                                                        .byte_order = _byte_order, \
@@ -1281,7 +1289,7 @@ struct side_event_description {
                                                .offset = _offset, \
                                                .access_mode = _access_mode, \
                                                .type = { \
-                                                       .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                                       .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())), \
                                                        .unit_size = _unit_size, \
                                                        .byte_order = _byte_order, \
@@ -1329,8 +1337,8 @@ struct side_event_description {
                .type = SIDE_TYPE_GATHER_ENUM, \
                .u = { \
                        .side_enum = { \
-                               .mappings = _mappings, \
-                               .elem_type = _elem_type, \
+                               .mappings = SIDE_PTR_INIT(_mappings), \
+                               .elem_type = SIDE_PTR_INIT(_elem_type), \
                        }, \
                }, \
        }
@@ -1346,7 +1354,7 @@ struct side_event_description {
                                        .side_struct = { \
                                                .offset = _offset, \
                                                .access_mode = _access_mode, \
-                                               .type = _struct_gather, \
+                                               .type = SIDE_PTR_INIT(_struct_gather), \
                                                .size = _size, \
                                        }, \
                                }, \
@@ -1366,8 +1374,8 @@ struct side_event_description {
                                                .offset = _offset, \
                                                .access_mode = _access_mode, \
                                                .type = { \
-                                                       .elem_type = _elem_type_gather, \
-                                                       .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                                       .elem_type = SIDE_PTR_INIT(_elem_type_gather), \
+                                                       .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())), \
                                                }, \
@@ -1386,12 +1394,12 @@ struct side_event_description {
                        .side_gather = { \
                                .u = { \
                                        .side_vla = { \
-                                               .length_type = _length_type_gather, \
+                                               .length_type = SIDE_PTR_INIT(_length_type_gather), \
                                                .offset = _offset, \
                                                .access_mode = _access_mode, \
                                                .type = { \
-                                                       .elem_type = _elem_type_gather, \
-                                                       .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                                       .elem_type = SIDE_PTR_INIT(_elem_type_gather), \
+                                                       .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())), \
                                                }, \
                                        }, \
@@ -1437,7 +1445,7 @@ struct side_event_description {
 #define side_arg_float_binary64(_val)  { .type = SIDE_TYPE_FLOAT_BINARY64, .u = { .side_static = { .float_value = { .side_float_binary64 = (_val) } } } }
 #define side_arg_float_binary128(_val) { .type = SIDE_TYPE_FLOAT_BINARY128, .u = { .side_static = { .float_value = { .side_float_binary128 = (_val) } } } }
 
-#define side_arg_struct(_side_type)    { .type = SIDE_TYPE_STRUCT, .u = { .side_static = { .side_struct = (_side_type) } } }
+#define side_arg_struct(_side_type)    { .type = SIDE_TYPE_STRUCT, .u = { .side_static = { .side_struct = SIDE_PTR_INIT(_side_type) } } }
 
 #define side_arg_define_variant(_identifier, _selector_val, _option) \
        const struct side_arg_variant _identifier = { \
@@ -1449,13 +1457,13 @@ struct side_event_description {
                .type = SIDE_TYPE_VARIANT, \
                .u = { \
                        .side_static = { \
-                               .side_variant = (_side_variant), \
+                               .side_variant = SIDE_PTR_INIT(_side_variant), \
                        }, \
                }, \
        }
 
-#define side_arg_array(_side_type)     { .type = SIDE_TYPE_ARRAY, .u = { .side_static = { .side_array = (_side_type) } } }
-#define side_arg_vla(_side_type)       { .type = SIDE_TYPE_VLA, .u = { .side_static = { .side_vla = (_side_type) } } }
+#define side_arg_array(_side_type)     { .type = SIDE_TYPE_ARRAY, .u = { .side_static = { .side_array = SIDE_PTR_INIT(_side_type) } } }
+#define side_arg_vla(_side_type)       { .type = SIDE_TYPE_VLA, .u = { .side_static = { .side_vla = SIDE_PTR_INIT(_side_type) } } }
 #define side_arg_vla_visitor(_ctx)     { .type = SIDE_TYPE_VLA_VISITOR, .u = { .side_static = { .side_vla_app_visitor_ctx = (_ctx) } } }
 
 /* Gather field arguments */
@@ -1478,7 +1486,7 @@ struct side_event_description {
                .u = { \
                        .side_dynamic = { \
                                .side_null = { \
-                                       .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                       .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())), \
                                }, \
                        }, \
@@ -1492,7 +1500,7 @@ struct side_event_description {
                        .side_dynamic = { \
                                .side_bool = { \
                                        .type = { \
-                                               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                               .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())), \
                                                .bool_size = sizeof(uint8_t), \
                                                .len_bits = 0, \
@@ -1513,7 +1521,7 @@ struct side_event_description {
                        .side_dynamic = { \
                                .side_byte = { \
                                        .type = { \
-                                               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                               .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())), \
                                        }, \
                                        .value = (_val), \
@@ -1529,7 +1537,7 @@ struct side_event_description {
                        .side_dynamic = { \
                                .side_string = { \
                                        .type = { \
-                                               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                               .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())), \
                                                .unit_size = _unit_size, \
                                                .byte_order = _byte_order, \
@@ -1561,7 +1569,7 @@ struct side_event_description {
                        .side_dynamic = { \
                                .side_integer = { \
                                        .type = { \
-                                               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                               .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())), \
                                                .integer_size = _integer_size, \
                                                .len_bits = _len_bits, \
@@ -1606,7 +1614,7 @@ struct side_event_description {
                        .side_dynamic = { \
                                .side_float = { \
                                        .type = { \
-                                               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                               .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())), \
                                                .float_size = _float_size, \
                                                .byte_order = _byte_order, \
@@ -1685,7 +1693,7 @@ struct side_event_description {
                                .side_dynamic_vla_visitor = { \
                                        .app_ctx = _ctx, \
                                        .visitor = _dynamic_vla_visitor, \
-                                       .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                       .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())), \
                                }, \
                        }, \
@@ -1710,7 +1718,7 @@ struct side_event_description {
                                .side_dynamic_struct_visitor = { \
                                        .app_ctx = _ctx, \
                                        .visitor = _dynamic_struct_visitor, \
-                                       .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                                       .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())), \
                                }, \
                        }, \
@@ -1721,7 +1729,7 @@ struct side_event_description {
        const struct side_arg _identifier##_vec[] = { _sav }; \
        const struct side_arg_dynamic_vla _identifier = { \
                .sav = _identifier##_vec, \
-               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+               .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
                .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
                .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
        }
@@ -1730,7 +1738,7 @@ struct side_event_description {
        const struct side_arg_dynamic_field _identifier##_fields[] = { _struct_fields }; \
        const struct side_arg_dynamic_struct _identifier = { \
                .fields = _identifier##_fields, \
-               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+               .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
                .len = SIDE_ARRAY_SIZE(_identifier##_fields), \
                .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
        }
@@ -1756,7 +1764,7 @@ struct side_event_description {
 #define side_arg_list(...)     __VA_ARGS__
 
 #define side_event_cond(_identifier) \
-       if (side_unlikely(__atomic_load_n(&side_event_enable__##_identifier, \
+       if (side_unlikely(__atomic_load_n(&side_event_state__##_identifier.enabled, \
                                        __ATOMIC_RELAXED)))
 
 #define side_event_call(_identifier, _sav) \
@@ -1783,7 +1791,7 @@ struct side_event_description {
                const struct side_arg_dynamic_field side_fields[] = { _var_fields }; \
                const struct side_arg_dynamic_struct var_struct = { \
                        .fields = side_fields, \
-                       .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
+                       .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
                        .len = SIDE_ARRAY_SIZE(side_fields), \
                        .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
                }; \
@@ -1795,21 +1803,24 @@ struct side_event_description {
                side_event_call_variadic(_identifier, SIDE_PARAM(_sav), SIDE_PARAM(_var), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
 
 #define _side_define_event(_linkage, _identifier, _provider, _event, _loglevel, _fields, _flags, _attr...) \
-       _linkage uintptr_t side_event_enable__##_identifier __attribute__((section("side_event_enable"))); \
+       _linkage struct side_event_state __attribute__((section("side_event_state"))) \
+                       side_event_state__##_identifier = { \
+               .enabled = 0, \
+               .callbacks = &side_empty_callback, \
+               .nr_callbacks = 0, \
+       }; \
        _linkage struct side_event_description __attribute__((section("side_event_description"))) \
                        _identifier = { \
-               .enabled = &(side_event_enable__##_identifier), \
+               .state = &(side_event_state__##_identifier), \
                .provider_name = _provider, \
                .event_name = _event, \
                .fields = _fields, \
-               .attr = SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()), \
-               .callbacks = &side_empty_callback, \
+               .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
                .flags = (_flags), \
                .version = 0, \
                .loglevel = _loglevel, \
                .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
                .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
-               .nr_callbacks = 0, \
        }; \
        static const struct side_event_description *side_event_ptr__##_identifier \
                __attribute__((section("side_event_description_ptr"), used)) = &(_identifier);
@@ -1839,7 +1850,7 @@ struct side_event_description {
                        _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
 
 #define side_declare_event(_identifier) \
-       extern uintptr_t side_event_enable_##_identifier; \
+       extern struct side_event_state side_event_state_##_identifier; \
        extern struct side_event_description _identifier
 
 #ifdef __cplusplus
This page took 0.036667 seconds and 4 git commands to generate.