struct side_tracer_dynamic_vla_visitor_ctx;
enum side_type {
+ SIDE_TYPE_BOOL,
+
SIDE_TYPE_U8,
SIDE_TYPE_U16,
SIDE_TYPE_U32,
enum side_dynamic_type {
SIDE_DYNAMIC_TYPE_NULL,
+ SIDE_DYNAMIC_TYPE_BOOL,
+
SIDE_DYNAMIC_TYPE_U8,
SIDE_DYNAMIC_TYPE_U16,
SIDE_DYNAMIC_TYPE_U32,
struct side_arg_dynamic_vec {
uint32_t dynamic_type; /* enum side_dynamic_type */
union {
+ uint8_t side_bool;
+
uint8_t side_u8;
uint16_t side_u16;
uint32_t side_u32;
struct side_arg_vec {
enum side_type type;
union {
+ uint8_t side_bool;
+
uint8_t side_u8;
uint16_t side_u16;
uint32_t side_u32;
#define side_field_list(...) \
SIDE_COMPOUND_LITERAL(const struct side_event_field, __VA_ARGS__)
+#define side_arg_bool(val) { .type = SIDE_TYPE_BOOL, .u = { .side_bool = !!(val) } }
#define side_arg_u8(val) { .type = SIDE_TYPE_U8, .u = { .side_u8 = (val) } }
#define side_arg_u16(val) { .type = SIDE_TYPE_U16, .u = { .side_u16 = (val) } }
#define side_arg_u32(val) { .type = SIDE_TYPE_U32, .u = { .side_u32 = (val) } }
#define side_arg_dynamic_null(val) { .dynamic_type = SIDE_DYNAMIC_TYPE_NULL }
+#define side_arg_dynamic_bool(val) { .dynamic_type = SIDE_DYNAMIC_TYPE_BOOL, .u = { .side_bool = !!(val) } }
#define side_arg_dynamic_u8(val) { .dynamic_type = SIDE_DYNAMIC_TYPE_U8, .u = { .side_u8 = (val) } }
#define side_arg_dynamic_u16(val) { .dynamic_type = SIDE_DYNAMIC_TYPE_U16, .u = { .side_u16 = (val) } }
#define side_arg_dynamic_u32(val) { .dynamic_type = SIDE_DYNAMIC_TYPE_U32, .u = { .side_u32 = (val) } }
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
+#include <stdbool.h>
#include <side/trace.h>
#include "tracer.h"
);
}
+static side_define_event(my_provider_event_bool, "myprovider", "myeventbool", SIDE_LOGLEVEL_DEBUG,
+ side_field_list(
+ side_field("a_false", SIDE_TYPE_BOOL),
+ side_field("b_true", SIDE_TYPE_BOOL),
+ side_field("c_true", SIDE_TYPE_BOOL),
+ side_field("d_true", SIDE_TYPE_BOOL),
+ side_field("e_true", SIDE_TYPE_BOOL),
+ side_field("f_false", SIDE_TYPE_BOOL),
+ side_field("g_true", SIDE_TYPE_BOOL),
+ )
+);
+
+static
+void test_bool(void)
+{
+ uint32_t a = 0;
+ uint32_t b = 1;
+ uint64_t c = 0x12345678;
+ int16_t d = -32768;
+ bool e = true;
+ bool f = false;
+ uint32_t g = 256;
+
+ my_provider_event_bool.enabled = 1;
+ side_event(&my_provider_event_bool,
+ side_arg_list(
+ side_arg_bool(a),
+ side_arg_bool(b),
+ side_arg_bool(c),
+ side_arg_bool(d),
+ side_arg_bool(e),
+ side_arg_bool(f),
+ side_arg_bool(g),
+ )
+ );
+}
+
+static side_define_event(my_provider_event_dynamic_bool,
+ "myprovider", "mydynamicbool", SIDE_LOGLEVEL_DEBUG,
+ side_field_list()
+);
+
+static
+void test_dynamic_bool(void)
+{
+ my_provider_event_dynamic_bool.enabled = 1;
+ side_event_variadic(&my_provider_event_dynamic_bool,
+ side_arg_list(),
+ side_arg_list(
+ side_arg_dynamic_field("a_true", side_arg_dynamic_bool(55)),
+ side_arg_dynamic_field("b_true", side_arg_dynamic_bool(-4)),
+ side_arg_dynamic_field("c_false", side_arg_dynamic_bool(0)),
+ side_arg_dynamic_field("d_true", side_arg_dynamic_bool(256)),
+ )
+ );
+}
+
int main()
{
test_fields();
test_dynamic_nested_vla();
test_variadic();
test_static_variadic();
+ test_bool();
+ test_dynamic_bool();
return 0;
}
break;
}
switch (item->type) {
+ case SIDE_TYPE_BOOL:
+ printf("%s", item->u.side_bool ? "true" : "false");
+ break;
case SIDE_TYPE_U8:
printf("%" PRIu8, item->u.side_u8);
break;
case SIDE_DYNAMIC_TYPE_NULL:
printf("<NULL TYPE>");
break;
+ case SIDE_DYNAMIC_TYPE_BOOL:
+ printf("%s", item->u.side_bool ? "true" : "false");
+ break;
case SIDE_DYNAMIC_TYPE_U8:
printf("%" PRIu8, item->u.side_u8);
break;