SIDE_TYPE_ARRAY_S32,
SIDE_TYPE_ARRAY_S64,
+ SIDE_TYPE_VLA_U8,
+ SIDE_TYPE_VLA_U16,
+ SIDE_TYPE_VLA_U32,
+ SIDE_TYPE_VLA_U64,
+ SIDE_TYPE_VLA_S8,
+ SIDE_TYPE_VLA_S16,
+ SIDE_TYPE_VLA_S32,
+ SIDE_TYPE_VLA_S64,
+
//TODO:
- //specialized vla for fixed-size integers (optimization)
//variants (discriminated unions)
};
void *side_vla_visitor_ctx;
void *side_array_fixint;
+ struct {
+ void *p;
+ uint32_t length;
+ } side_vla_fixint;
} u;
};
#define side_arg_vla(_side_type) { .type = SIDE_TYPE_VLA, .u = { .side_vla = (_side_type) } }
#define side_arg_vla_visitor(_ctx) { .type = SIDE_TYPE_VLA_VISITOR, .u = { .side_vla_visitor_ctx = (_ctx) } }
-#define side_arg_array_u8(ptr) { .type = SIDE_TYPE_ARRAY_U8, .u = { .side_array_fixint = (ptr) } }
-#define side_arg_array_u16(ptr) { .type = SIDE_TYPE_ARRAY_U16, .u = { .side_array_fixint = (ptr) } }
-#define side_arg_array_u32(ptr) { .type = SIDE_TYPE_ARRAY_U32, .u = { .side_array_fixint = (ptr) } }
-#define side_arg_array_u64(ptr) { .type = SIDE_TYPE_ARRAY_U64, .u = { .side_array_fixint = (ptr) } }
-#define side_arg_array_s8(ptr) { .type = SIDE_TYPE_ARRAY_S8, .u = { .side_array_fixint = (ptr) } }
-#define side_arg_array_s16(ptr) { .type = SIDE_TYPE_ARRAY_S16, .u = { .side_array_fixint = (ptr) } }
-#define side_arg_array_s32(ptr) { .type = SIDE_TYPE_ARRAY_S32, .u = { .side_array_fixint = (ptr) } }
-#define side_arg_array_s64(ptr) { .type = SIDE_TYPE_ARRAY_S64, .u = { .side_array_fixint = (ptr) } }
+#define side_arg_array_u8(_ptr) { .type = SIDE_TYPE_ARRAY_U8, .u = { .side_array_fixint = (_ptr) } }
+#define side_arg_array_u16(_ptr) { .type = SIDE_TYPE_ARRAY_U16, .u = { .side_array_fixint = (_ptr) } }
+#define side_arg_array_u32(_ptr) { .type = SIDE_TYPE_ARRAY_U32, .u = { .side_array_fixint = (_ptr) } }
+#define side_arg_array_u64(_ptr) { .type = SIDE_TYPE_ARRAY_U64, .u = { .side_array_fixint = (_ptr) } }
+#define side_arg_array_s8(_ptr) { .type = SIDE_TYPE_ARRAY_S8, .u = { .side_array_fixint = (_ptr) } }
+#define side_arg_array_s16(_ptr) { .type = SIDE_TYPE_ARRAY_S16, .u = { .side_array_fixint = (_ptr) } }
+#define side_arg_array_s32(_ptr) { .type = SIDE_TYPE_ARRAY_S32, .u = { .side_array_fixint = (_ptr) } }
+#define side_arg_array_s64(_ptr) { .type = SIDE_TYPE_ARRAY_S64, .u = { .side_array_fixint = (_ptr) } }
+
+#define side_arg_vla_u8(_ptr, _length) { .type = SIDE_TYPE_VLA_U8, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } }
+#define side_arg_vla_u16(_ptr, _length) { .type = SIDE_TYPE_VLA_U16, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
+#define side_arg_vla_u32(_ptr, _length) { .type = SIDE_TYPE_VLA_U32, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
+#define side_arg_vla_u64(_ptr, _length) { .type = SIDE_TYPE_VLA_U64, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
+#define side_arg_vla_s8(_ptr, _length) { .type = SIDE_TYPE_VLA_S8, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
+#define side_arg_vla_s16(_ptr, _length) { .type = SIDE_TYPE_VLA_S16, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
+#define side_arg_vla_s32(_ptr, _length) { .type = SIDE_TYPE_VLA_S32, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
+#define side_arg_vla_s64(_ptr, _length) { .type = SIDE_TYPE_VLA_S64, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
#define side_arg_define_vec(_identifier, _sav) \
const struct side_arg_vec _identifier##_vec[] = { _sav }; \
void test_array_fixint(void)
{
my_provider_event_array_fixint.enabled = 1;
- side_event_cond(&my_provider_event_array_fixint) {
- side_event_call(&my_provider_event_array_fixint,
- side_arg_list(side_arg_array_s64(array_fixint), side_arg_s64(42)));
- }
+ side_event(&my_provider_event_array_fixint,
+ side_arg_list(side_arg_array_s64(array_fixint), side_arg_s64(42)));
+}
+
+static int64_t vla_fixint[] = { -444, 555, 123, 2897432587 };
+
+static side_define_event(my_provider_event_vla_fixint, "myprovider", "myvlafixint", SIDE_LOGLEVEL_DEBUG,
+ side_field_list(
+ side_field_vla("vlafixint", side_elem(SIDE_TYPE_S64)),
+ side_field(SIDE_TYPE_S64, "v"),
+ )
+);
+
+static
+void test_vla_fixint(void)
+{
+ my_provider_event_vla_fixint.enabled = 1;
+ side_event(&my_provider_event_vla_fixint,
+ side_arg_list(side_arg_vla_s64(vla_fixint, SIDE_ARRAY_SIZE(vla_fixint)), side_arg_s64(42)));
}
int main()
test_vla();
test_vla_visitor();
test_array_fixint();
+ test_vla_fixint();
return 0;
}
void tracer_print_vla_visitor(const struct side_type_description *type_desc, void *ctx);
static
void tracer_print_array_fixint(const struct side_type_description *type_desc, const struct side_arg_vec *item);
+static
+void tracer_print_vla_fixint(const struct side_type_description *type_desc, const struct side_arg_vec *item);
static
void tracer_print_type(const struct side_type_description *type_desc, const struct side_arg_vec *item)
abort();
}
break;
+ case SIDE_TYPE_VLA_U8:
+ case SIDE_TYPE_VLA_U16:
+ case SIDE_TYPE_VLA_U32:
+ case SIDE_TYPE_VLA_U64:
+ case SIDE_TYPE_VLA_S8:
+ case SIDE_TYPE_VLA_S16:
+ case SIDE_TYPE_VLA_S32:
+ case SIDE_TYPE_VLA_S64:
+ if (type_desc->type != SIDE_TYPE_VLA) {
+ printf("ERROR: type mismatch between description and arguments\n");
+ abort();
+ }
+ break;
+
default:
if (type_desc->type != SIDE_TYPE_DYNAMIC && type_desc->type != item->type) {
printf("ERROR: type mismatch between description and arguments\n");
case SIDE_TYPE_ARRAY_S64:
tracer_print_array_fixint(type_desc, item);
break;
+ case SIDE_TYPE_VLA_U8:
+ case SIDE_TYPE_VLA_U16:
+ case SIDE_TYPE_VLA_U32:
+ case SIDE_TYPE_VLA_U64:
+ case SIDE_TYPE_VLA_S8:
+ case SIDE_TYPE_VLA_S16:
+ case SIDE_TYPE_VLA_S32:
+ case SIDE_TYPE_VLA_S64:
+ tracer_print_vla_fixint(type_desc, item);
+ break;
default:
printf("<UNKNOWN TYPE>");
abort();
abort();
}
+void tracer_print_vla_fixint(const struct side_type_description *type_desc, const struct side_arg_vec *item)
+{
+ const struct side_type_description *elem_type = type_desc->u.side_vla.elem_type;
+ uint32_t side_sav_len = item->u.side_vla_fixint.length;
+ void *p = item->u.side_vla_fixint.p;
+ enum side_type side_type;
+ int i;
+
+ if (elem_type->type != SIDE_TYPE_DYNAMIC) {
+ switch (item->type) {
+ case SIDE_TYPE_VLA_U8:
+ if (elem_type->type != SIDE_TYPE_U8)
+ goto type_error;
+ break;
+ case SIDE_TYPE_VLA_U16:
+ if (elem_type->type != SIDE_TYPE_U16)
+ goto type_error;
+ break;
+ case SIDE_TYPE_VLA_U32:
+ if (elem_type->type != SIDE_TYPE_U32)
+ goto type_error;
+ break;
+ case SIDE_TYPE_VLA_U64:
+ if (elem_type->type != SIDE_TYPE_U64)
+ goto type_error;
+ break;
+ case SIDE_TYPE_VLA_S8:
+ if (elem_type->type != SIDE_TYPE_S8)
+ goto type_error;
+ break;
+ case SIDE_TYPE_VLA_S16:
+ if (elem_type->type != SIDE_TYPE_S16)
+ goto type_error;
+ break;
+ case SIDE_TYPE_VLA_S32:
+ if (elem_type->type != SIDE_TYPE_S32)
+ goto type_error;
+ break;
+ case SIDE_TYPE_VLA_S64:
+ if (elem_type->type != SIDE_TYPE_S64)
+ goto type_error;
+ break;
+ default:
+ goto type_error;
+ }
+ side_type = elem_type->type;
+ } else {
+ switch (item->type) {
+ case SIDE_TYPE_VLA_U8:
+ side_type = SIDE_TYPE_U8;
+ break;
+ case SIDE_TYPE_VLA_U16:
+ side_type = SIDE_TYPE_U16;
+ break;
+ case SIDE_TYPE_VLA_U32:
+ side_type = SIDE_TYPE_U32;
+ break;
+ case SIDE_TYPE_VLA_U64:
+ side_type = SIDE_TYPE_U64;
+ break;
+ case SIDE_TYPE_VLA_S8:
+ side_type = SIDE_TYPE_S8;
+ break;
+ case SIDE_TYPE_VLA_S16:
+ side_type = SIDE_TYPE_S16;
+ break;
+ case SIDE_TYPE_VLA_S32:
+ side_type = SIDE_TYPE_S32;
+ break;
+ case SIDE_TYPE_VLA_S64:
+ side_type = SIDE_TYPE_S64;
+ break;
+ default:
+ goto type_error;
+ }
+ }
+
+ printf("[ ");
+ for (i = 0; i < side_sav_len; i++) {
+ struct side_arg_vec sav_elem = {
+ .type = side_type,
+ };
+
+ switch (side_type) {
+ case SIDE_TYPE_U8:
+ sav_elem.u.side_u8 = ((const uint8_t *) p)[i];
+ break;
+ case SIDE_TYPE_S8:
+ sav_elem.u.side_s8 = ((const int8_t *) p)[i];
+ break;
+ case SIDE_TYPE_U16:
+ sav_elem.u.side_u16 = ((const uint16_t *) p)[i];
+ break;
+ case SIDE_TYPE_S16:
+ sav_elem.u.side_s16 = ((const int16_t *) p)[i];
+ break;
+ case SIDE_TYPE_U32:
+ sav_elem.u.side_u32 = ((const uint32_t *) p)[i];
+ break;
+ case SIDE_TYPE_S32:
+ sav_elem.u.side_s32 = ((const int32_t *) p)[i];
+ break;
+ case SIDE_TYPE_U64:
+ sav_elem.u.side_u64 = ((const uint64_t *) p)[i];
+ break;
+ case SIDE_TYPE_S64:
+ sav_elem.u.side_s64 = ((const int64_t *) p)[i];
+ break;
+
+ default:
+ printf("ERROR: Unexpected type\n");
+ abort();
+ }
+
+ printf("%s", i ? ", " : "");
+ tracer_print_type(elem_type, &sav_elem);
+ }
+ printf(" ]");
+ return;
+
+type_error:
+ printf("ERROR: type mismatch\n");
+ abort();
+}
+
void tracer_call(const struct side_event_description *desc, const struct side_arg_vec_description *sav_desc)
{
const struct side_arg_vec *sav = sav_desc->sav;