trace.h: Use side_enum_t for enum side_type_label_byte_order
[libside.git] / include / side / trace.h
index 1c5aafcc6b6b556e0b3b844accf0f09d0d780719..42efeefda9803ca5a474a89ba576b736c268767f 100644 (file)
@@ -187,6 +187,7 @@ enum side_visitor_status {
        SIDE_VISITOR_STATUS_ERROR = -1,
 };
 
+//TODO: side_error enum is currently unused.
 enum side_error {
        SIDE_ERROR_OK = 0,
        SIDE_ERROR_INVAL = 1,
@@ -262,11 +263,11 @@ union side_float_value {
 struct side_type_raw_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_enum_t(enum side_type_label_byte_order, uint8_t) byte_order;
 } SIDE_PACKED;
 
 struct side_attr_value {
-       uint32_t type;  /* enum side_attr_type */
+       side_enum_t(enum side_attr_type, uint32_t) type;
        union {
                uint8_t bool_value;
                struct side_type_raw_string string_value;
@@ -292,7 +293,7 @@ struct side_type_bool {
        uint32_t nr_attr;
        uint16_t bool_size;             /* bytes */
        uint16_t len_bits;              /* bits. 0 for (bool_size * CHAR_BITS) */
-       uint8_t byte_order;             /* enum side_type_label_byte_order */
+       side_enum_t(enum side_type_label_byte_order, uint8_t) byte_order;
 } SIDE_PACKED;
 
 struct side_type_byte {
@@ -304,7 +305,7 @@ struct side_type_string {
        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_enum_t(enum side_type_label_byte_order, uint8_t) byte_order;
 } SIDE_PACKED;
 
 struct side_type_integer {
@@ -313,14 +314,14 @@ struct side_type_integer {
        uint16_t integer_size;          /* bytes */
        uint16_t len_bits;              /* bits. 0 for (integer_size * CHAR_BITS) */
        uint8_t signedness;             /* true/false */
-       uint8_t byte_order;             /* enum side_type_label_byte_order */
+       side_enum_t(enum side_type_label_byte_order, uint8_t) byte_order;
 } SIDE_PACKED;
 
 struct side_type_float {
        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 */
+       side_enum_t(enum side_type_label_byte_order, uint8_t) byte_order;
 } SIDE_PACKED;
 
 struct side_enum_mapping {
@@ -668,7 +669,7 @@ struct side_event_description {
        side_ptr_t(const struct side_attr) attr;
        uint64_t flags;
        uint32_t version;
-       uint32_t loglevel;      /* enum side_loglevel */
+       side_enum_t(enum side_loglevel, uint32_t) loglevel;
        uint32_t nr_fields;
        uint32_t nr_attr;
 } SIDE_PACKED;
@@ -680,7 +681,7 @@ struct side_event_description {
                .key = { \
                        .p = SIDE_PTR_INIT(_key), \
                        .unit_size = sizeof(uint8_t), \
-                       .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
+                       .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
                }, \
                .value = SIDE_PARAM(_value), \
        }
@@ -689,28 +690,28 @@ struct side_event_description {
        SIDE_COMPOUND_LITERAL(const struct side_attr, __VA_ARGS__)
 
 #define side_attr_null(_val)           { .type = SIDE_ATTR_TYPE_NULL }
-#define side_attr_bool(_val)           { .type = SIDE_ATTR_TYPE_BOOL, .u = { .bool_value = !!(_val) } }
-#define side_attr_u8(_val)             { .type = SIDE_ATTR_TYPE_U8, .u = { .integer_value = { .side_u8 = (_val) } } }
-#define side_attr_u16(_val)            { .type = SIDE_ATTR_TYPE_U16, .u = { .integer_value = { .side_u16 = (_val) } } }
-#define side_attr_u32(_val)            { .type = SIDE_ATTR_TYPE_U32, .u = { .integer_value = { .side_u32 = (_val) } } }
-#define side_attr_u64(_val)            { .type = SIDE_ATTR_TYPE_U64, .u = { .integer_value = { .side_u64 = (_val) } } }
-#define side_attr_s8(_val)             { .type = SIDE_ATTR_TYPE_S8, .u = { .integer_value = { .side_s8 = (_val) } } }
-#define side_attr_s16(_val)            { .type = SIDE_ATTR_TYPE_S16, .u = { .integer_value = { .side_s16 = (_val) } } }
-#define side_attr_s32(_val)            { .type = SIDE_ATTR_TYPE_S32, .u = { .integer_value = { .side_s32 = (_val) } } }
-#define side_attr_s64(_val)            { .type = SIDE_ATTR_TYPE_S64, .u = { .integer_value = { .side_s64 = (_val) } } }
-#define side_attr_float_binary16(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY16, .u = { .float_value = { .side_float_binary16 = (_val) } } }
-#define side_attr_float_binary32(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY32, .u = { .float_value = { .side_float_binary32 = (_val) } } }
-#define side_attr_float_binary64(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY64, .u = { .float_value = { .side_float_binary64 = (_val) } } }
-#define side_attr_float_binary128(_val)        { .type = SIDE_ATTR_TYPE_FLOAT_BINARY128, .u = { .float_value = { .side_float_binary128 = (_val) } } }
+#define side_attr_bool(_val)           { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_BOOL), .u = { .bool_value = !!(_val) } }
+#define side_attr_u8(_val)             { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U8), .u = { .integer_value = { .side_u8 = (_val) } } }
+#define side_attr_u16(_val)            { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U16), .u = { .integer_value = { .side_u16 = (_val) } } }
+#define side_attr_u32(_val)            { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U32), .u = { .integer_value = { .side_u32 = (_val) } } }
+#define side_attr_u64(_val)            { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U64), .u = { .integer_value = { .side_u64 = (_val) } } }
+#define side_attr_s8(_val)             { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S8), .u = { .integer_value = { .side_s8 = (_val) } } }
+#define side_attr_s16(_val)            { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S16), .u = { .integer_value = { .side_s16 = (_val) } } }
+#define side_attr_s32(_val)            { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S32), .u = { .integer_value = { .side_s32 = (_val) } } }
+#define side_attr_s64(_val)            { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S64), .u = { .integer_value = { .side_s64 = (_val) } } }
+#define side_attr_float_binary16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY16), .u = { .float_value = { .side_float_binary16 = (_val) } } }
+#define side_attr_float_binary32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY32), .u = { .float_value = { .side_float_binary32 = (_val) } } }
+#define side_attr_float_binary64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY64), .u = { .float_value = { .side_float_binary64 = (_val) } } }
+#define side_attr_float_binary128(_val)        { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY128), .u = { .float_value = { .side_float_binary128 = (_val) } } }
 
 #define _side_attr_string(_val, _byte_order, _unit_size) \
        { \
-               .type = SIDE_ATTR_TYPE_STRING, \
+               .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_STRING), \
                .u = { \
                        .string_value = { \
                                .p = SIDE_PTR_INIT(_val), \
                                .unit_size = _unit_size, \
-                               .byte_order = _byte_order, \
+                               .byte_order = SIDE_ENUM_INIT(_byte_order), \
                        }, \
                }, \
        }
@@ -739,7 +740,7 @@ struct side_event_description {
                .label = { \
                        .p = SIDE_PTR_INIT(_label), \
                        .unit_size = sizeof(uint8_t), \
-                       .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
+                       .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
                }, \
        }
 
@@ -750,7 +751,7 @@ struct side_event_description {
                .label = { \
                        .p = SIDE_PTR_INIT(_label), \
                        .unit_size = sizeof(uint8_t), \
-                       .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
+                       .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
                }, \
        }
 
@@ -772,7 +773,7 @@ struct side_event_description {
                .label = { \
                        .p = SIDE_PTR_INIT(_label), \
                        .unit_size = sizeof(uint8_t), \
-                       .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
+                       .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
                }, \
        }
 
@@ -783,7 +784,7 @@ struct side_event_description {
                .label = { \
                        .p = SIDE_PTR_INIT(_label), \
                        .unit_size = sizeof(uint8_t), \
-                       .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
+                       .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
                }, \
        }
 
@@ -809,7 +810,7 @@ struct side_event_description {
                                .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
                                .bool_size = sizeof(uint8_t), \
                                .len_bits = 0, \
-                               .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
+                               .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
                        }, \
                }, \
        }
@@ -833,7 +834,7 @@ struct side_event_description {
                                .attr = SIDE_PTR_INIT(_attr), \
                                .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
                                .unit_size = _unit_size, \
-                               .byte_order = _byte_order, \
+                               .byte_order = SIDE_ENUM_INIT(_byte_order), \
                        }, \
                }, \
        }
@@ -853,7 +854,7 @@ struct side_event_description {
                                .integer_size = _integer_size, \
                                .len_bits = _len_bits, \
                                .signedness = _signedness, \
-                               .byte_order = _byte_order, \
+                               .byte_order = SIDE_ENUM_INIT(_byte_order), \
                        }, \
                }, \
        }
@@ -866,7 +867,7 @@ struct side_event_description {
                                .attr = SIDE_PTR_INIT(_attr), \
                                .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
                                .float_size = _float_size, \
-                               .byte_order = _byte_order, \
+                               .byte_order = SIDE_ENUM_INIT(_byte_order), \
                        }, \
                }, \
        }
@@ -1143,7 +1144,7 @@ struct side_event_description {
                                                        .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
                                                        .bool_size = _bool_size, \
                                                        .len_bits = _len_bits, \
-                                                       .byte_order = _byte_order, \
+                                                       .byte_order = SIDE_ENUM_INIT(_byte_order), \
                                                }, \
                                                .offset_bits = _offset_bits, \
                                        }, \
@@ -1181,7 +1182,7 @@ struct side_event_description {
                                                        .integer_size = _integer_size, \
                                                        .len_bits = _len_bits, \
                                                        .signedness = _signedness, \
-                                                       .byte_order = _byte_order, \
+                                                       .byte_order = SIDE_ENUM_INIT(_byte_order), \
                                                }, \
                                                .offset_bits = _offset_bits, \
                                        }, \
@@ -1257,7 +1258,7 @@ struct side_event_description {
                                                        .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, \
+                                                       .byte_order = SIDE_ENUM_INIT(_byte_order), \
                                                }, \
                                        }, \
                                }, \
@@ -1292,7 +1293,7 @@ struct side_event_description {
                                                        .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, \
+                                                       .byte_order = SIDE_ENUM_INIT(_byte_order), \
                                                }, \
                                        }, \
                                }, \
@@ -1504,7 +1505,7 @@ struct side_event_description {
                                                .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
                                                .bool_size = sizeof(uint8_t), \
                                                .len_bits = 0, \
-                                               .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
+                                               .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
                                        }, \
                                        .value = { \
                                                .side_bool8 = !!(_val), \
@@ -1540,7 +1541,7 @@ struct side_event_description {
                                                .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, \
+                                               .byte_order = SIDE_ENUM_INIT(_byte_order), \
                                        }, \
                                        .value = (uintptr_t) (_val), \
                                }, \
@@ -1574,7 +1575,7 @@ struct side_event_description {
                                                .integer_size = _integer_size, \
                                                .len_bits = _len_bits, \
                                                .signedness = _signedness, \
-                                               .byte_order = _byte_order, \
+                                               .byte_order = SIDE_ENUM_INIT(_byte_order), \
                                        }, \
                                        .value = { \
                                                _field = (_val), \
@@ -1617,7 +1618,7 @@ struct side_event_description {
                                                .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, \
+                                               .byte_order = SIDE_ENUM_INIT(_byte_order), \
                                        }, \
                                        .value = { \
                                                _field = (_val), \
@@ -1818,7 +1819,7 @@ struct side_event_description {
                .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
                .flags = (_flags), \
                .version = 0, \
-               .loglevel = _loglevel, \
+               .loglevel = SIDE_ENUM_INIT(_loglevel), \
                .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
                .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
        }; \
This page took 0.027933 seconds and 4 git commands to generate.