Convert side_type_raw_string pointer to side_ptr
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 21 Sep 2023 05:56:03 +0000 (06:56 +0100)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 21 Sep 2023 05:56:03 +0000 (06:56 +0100)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/side/trace.h
src/tracer.c

index 8e0604d1c54c52b0838cd309304cfce11a5c2d30..d63a95e32717d9f1f71fc94476f0955cd889c31e 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;
@@ -678,7 +678,9 @@ struct side_event_description {
 #define side_attr(_key, _value)        \
        { \
                .key = { \
-                       .p = (_key), \
+                       .p = { \
+                               .v = (uintptr_t) (_key), \
+                       }, \
                        .unit_size = sizeof(uint8_t), \
                        .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
                }, \
@@ -708,7 +710,9 @@ struct side_event_description {
                .type = SIDE_ATTR_TYPE_STRING, \
                .u = { \
                        .string_value = { \
-                               .p = (const void *) (_val), \
+                               .p = { \
+                                       .v = (uintptr_t) (_val), \
+                               }, \
                                .unit_size = _unit_size, \
                                .byte_order = _byte_order, \
                        }, \
@@ -737,7 +741,9 @@ struct side_event_description {
                .range_begin = _begin, \
                .range_end = _end, \
                .label = { \
-                       .p = (_label), \
+                       .p = { \
+                               .v = (uintptr_t) (_label), \
+                       }, \
                        .unit_size = sizeof(uint8_t), \
                        .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
                }, \
@@ -748,7 +754,9 @@ struct side_event_description {
                .range_begin = _value, \
                .range_end = _value, \
                .label = { \
-                       .p = (_label), \
+                       .p = { \
+                               .v = (uintptr_t) (_label), \
+                       }, \
                        .unit_size = sizeof(uint8_t), \
                        .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
                }, \
@@ -770,7 +778,9 @@ struct side_event_description {
                .range_begin = _begin, \
                .range_end = _end, \
                .label = { \
-                       .p = (_label), \
+                       .p = { \
+                               .v = (uintptr_t) (_label), \
+                       }, \
                        .unit_size = sizeof(uint8_t), \
                        .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
                }, \
@@ -781,7 +791,9 @@ struct side_event_description {
                .range_begin = _value, \
                .range_end = _value, \
                .label = { \
-                       .p = (_label), \
+                       .p = { \
+                               .v = (uintptr_t) (_label), \
+                       }, \
                        .unit_size = sizeof(uint8_t), \
                        .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
                }, \
index a0567cb5b24fb5d2920ad3ec111be1da2594d7c8..dac746426df971a9f3b09d112ab8d4c5de4764d5 100644 (file)
@@ -229,10 +229,10 @@ enum tracer_display_base get_attr_display_base(const struct side_attr *_attr, ui
                char *utf8_str = NULL;
                bool cmp;
 
-               tracer_convert_string_to_utf8(attr->key.p, attr->key.unit_size,
+               tracer_convert_string_to_utf8(side_ptr_get(attr->key.p), attr->key.unit_size,
                        attr->key.byte_order, NULL, &utf8_str);
                cmp = strcmp(utf8_str, "std.integer.base");
-               if (utf8_str != attr->key.p)
+               if (utf8_str != side_ptr_get(attr->key.p))
                        free(utf8_str);
                if (!cmp) {
                        int64_t val = get_attr_integer_value(attr);
@@ -260,10 +260,10 @@ void tracer_print_attr_type(const char *separator, const struct side_attr *attr)
 {
        char *utf8_str = NULL;
 
-       tracer_convert_string_to_utf8(attr->key.p, attr->key.unit_size,
+       tracer_convert_string_to_utf8(side_ptr_get(attr->key.p), attr->key.unit_size,
                attr->key.byte_order, NULL, &utf8_str);
        printf("{ key%s \"%s\", value%s ", separator, utf8_str, separator);
-       if (utf8_str != attr->key.p)
+       if (utf8_str != side_ptr_get(attr->key.p))
                free(utf8_str);
        switch (attr->value.type) {
        case SIDE_ATTR_TYPE_BOOL:
@@ -326,7 +326,7 @@ void tracer_print_attr_type(const char *separator, const struct side_attr *attr)
                abort();
 #endif
        case SIDE_ATTR_TYPE_STRING:
-               tracer_print_string(attr->value.u.string_value.p,
+               tracer_print_string(side_ptr_get(attr->value.u.string_value.p),
                                attr->value.u.string_value.unit_size,
                                attr->value.u.string_value.byte_order, NULL);
                break;
@@ -460,7 +460,7 @@ void print_enum_labels(const struct side_enum_mappings *mappings, union int64_va
                }
                if (v64.s >= mapping->range_begin && v64.s <= mapping->range_end) {
                        printf("%s", print_count++ ? ", " : "");
-                       tracer_print_string(mapping->label.p, mapping->label.unit_size, mapping->label.byte_order, NULL);
+                       tracer_print_string(side_ptr_get(mapping->label.p), mapping->label.unit_size, mapping->label.byte_order, NULL);
                }
        }
        if (!print_count)
@@ -589,7 +589,7 @@ void tracer_print_enum_bitmap(const struct side_type *type_desc,
 match:
                if (match) {
                        printf("%s", print_count++ ? ", " : "");
-                       tracer_print_string(mapping->label.p, mapping->label.unit_size, mapping->label.byte_order, NULL);
+                       tracer_print_string(side_ptr_get(mapping->label.p), mapping->label.unit_size, mapping->label.byte_order, NULL);
                }
        }
        if (!print_count)
This page took 0.034909 seconds and 4 git commands to generate.