Introduce union side_bool_value
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 8 Nov 2022 17:04:51 +0000 (12:04 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 8 Nov 2022 17:04:51 +0000 (12:04 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/side/trace.h
src/tracer.c

index 845a9acd5a5694679e19732ad1ac857d19244ca4..8f4f239b3fe15f713424a5d3f1dc88099b79811b 100644 (file)
@@ -241,6 +241,13 @@ union side_integer_value {
        int64_t side_s64;
 } SIDE_PACKED;
 
+union side_bool_value {
+       uint8_t side_bool8;
+       uint16_t side_bool16;
+       uint32_t side_bool32;
+       uint64_t side_bool64;
+} SIDE_PACKED;
+
 union side_float_value {
 #if __HAVE_FLOAT16
        _Float16 side_float_binary16;
@@ -484,7 +491,7 @@ struct side_callback {
 
 struct side_arg_static {
        /* Stack-copy basic types */
-       uint8_t bool_value;
+       union side_bool_value bool_value;
        uint8_t byte_value;
        uint64_t string_value;  /* const char * */
        union side_integer_value integer_value;
@@ -544,7 +551,7 @@ struct side_arg_dynamic {
        struct side_type_null side_null;
        struct {
                struct side_type_bool type;
-               uint8_t value;
+               union side_bool_value value;
        } SIDE_PACKED side_bool;
        struct {
                struct side_type_byte type;
@@ -1217,7 +1224,7 @@ struct side_event_description {
 /* Stack-copy field arguments */
 
 #define side_arg_null(_val)            { .type = SIDE_TYPE_NULL }
-#define side_arg_bool(_val)            { .type = SIDE_TYPE_BOOL, .u = { .side_static = { .bool_value = !!(_val) } } }
+#define side_arg_bool(_val)            { .type = SIDE_TYPE_BOOL, .u = { .side_static = { .bool_value.side_bool8 = !!(_val) } } }
 #define side_arg_byte(_val)            { .type = SIDE_TYPE_BYTE, .u = { .side_static = { .byte_value = (_val) } } }
 #define side_arg_string(_val)          { .type = SIDE_TYPE_STRING, .u = { .side_static = { .string_value = (uintptr_t) (_val) } } }
 
@@ -1285,7 +1292,9 @@ struct side_event_description {
                                                .len_bits = 1, \
                                                .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
                                        }, \
-                                       .value = !!(_val), \
+                                       .value = { \
+                                               .side_bool8 = !!(_val), \
+                                       }, \
                                }, \
                        }, \
                }, \
index 938946d109f853c1ae219aa989ecd30f5595cdee..ea4d5a183ea29663494e924519566f130e9194bb 100644 (file)
@@ -516,7 +516,7 @@ void tracer_print_type_header(const char *separator,
 static
 void tracer_print_type_bool(const char *separator,
                const struct side_type_bool *type_bool,
-               const union side_integer_value *value,
+               const union side_bool_value *value,
                uint16_t offset_bits)
 {
        bool reverse_bo;
@@ -528,13 +528,13 @@ void tracer_print_type_bool(const char *separator,
        reverse_bo = type_bool->byte_order != SIDE_TYPE_BYTE_ORDER_HOST;
        switch (type_bool->bool_size_bits) {
        case 8:
-               v = value->side_u8;
+               v = value->side_bool8;
                break;
        case 16:
        {
                uint16_t side_u16;
 
-               side_u16 = value->side_u16;
+               side_u16 = value->side_bool16;
                if (reverse_bo)
                        side_u16 = side_bswap_16(side_u16);
                v = side_u16;
@@ -544,7 +544,7 @@ void tracer_print_type_bool(const char *separator,
        {
                uint32_t side_u32;
 
-               side_u32 = value->side_u32;
+               side_u32 = value->side_bool32;
                if (reverse_bo)
                        side_u32 = side_bswap_32(side_u32);
                v = side_u32;
@@ -554,7 +554,7 @@ void tracer_print_type_bool(const char *separator,
        {
                uint64_t side_u64;
 
-               side_u64 = value->side_u64;
+               side_u64 = value->side_bool64;
                if (reverse_bo)
                        side_u64 = side_bswap_64(side_u64);
                v = side_u64;
@@ -870,13 +870,8 @@ void tracer_print_type(const struct side_type *type_desc, const struct side_arg
                break;
 
        case SIDE_TYPE_BOOL:
-       {
-               union side_integer_value value = {
-                       .side_u8 = item->u.side_static.bool_value,
-               };
-               tracer_print_type_bool(":", &type_desc->u.side_bool, &value, 0);
+               tracer_print_type_bool(":", &type_desc->u.side_bool, &item->u.side_static.bool_value, 0);
                break;
-       }
 
        case SIDE_TYPE_U8:
        case SIDE_TYPE_U16:
@@ -1111,7 +1106,7 @@ uint32_t tracer_print_gather_bool_type(const struct side_type_gather *type_gathe
        enum side_type_gather_access_mode access_mode = type_gather->u.side_bool.access_mode;
        uint32_t bool_size_bytes = type_gather->u.side_bool.type.bool_size_bits >> 3;
        const char *ptr = (const char *) _ptr;
-       union side_integer_value value;
+       union side_bool_value value;
 
        switch (type_gather->u.side_bool.type.bool_size_bits) {
        case 8:
@@ -1501,14 +1496,11 @@ void tracer_print_dynamic(const struct side_arg *item)
                tracer_print_type_header("::", item->u.side_dynamic.side_null.attr, item->u.side_dynamic.side_null.nr_attr);
                printf("<NULL TYPE>");
                break;
+
        case SIDE_TYPE_DYNAMIC_BOOL:
-       {
-               union side_integer_value value = {
-                       .side_u8 = item->u.side_dynamic.side_bool.value,
-               };
-               tracer_print_type_bool("::", &item->u.side_dynamic.side_bool.type, &value, 0);
+               tracer_print_type_bool("::", &item->u.side_dynamic.side_bool.type, &item->u.side_dynamic.side_bool.value, 0);
                break;
-       }
+
        case SIDE_TYPE_DYNAMIC_U8:
        case SIDE_TYPE_DYNAMIC_U16:
        case SIDE_TYPE_DYNAMIC_U32:
This page took 0.025759 seconds and 4 git commands to generate.