1 // SPDX-License-Identifier: MIT
3 * Copyright 2022 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
14 #include <side/macros.h>
16 /* SIDE stands for "Static Instrumentation Dynamically Enabled" */
18 //TODO: as those structures will be ABI, we need to either consider them
19 //fixed forever, or think of a scheme that would allow their binary
20 //representation to be extended if need be.
23 struct side_arg_vec_description
;
24 struct side_arg_dynamic_vec
;
25 struct side_arg_dynamic_vec_vla
;
26 struct side_type_description
;
27 struct side_event_field
;
28 struct side_tracer_visitor_ctx
;
29 struct side_tracer_dynamic_struct_visitor_ctx
;
30 struct side_tracer_dynamic_vla_visitor_ctx
;
44 SIDE_TYPE_FLOAT_BINARY16
,
45 SIDE_TYPE_FLOAT_BINARY32
,
46 SIDE_TYPE_FLOAT_BINARY64
,
47 SIDE_TYPE_FLOAT_BINARY128
,
54 SIDE_TYPE_VLA_VISITOR
,
77 enum side_dynamic_type
{
78 SIDE_DYNAMIC_TYPE_NULL
,
80 SIDE_DYNAMIC_TYPE_BOOL
,
83 SIDE_DYNAMIC_TYPE_U16
,
84 SIDE_DYNAMIC_TYPE_U32
,
85 SIDE_DYNAMIC_TYPE_U64
,
87 SIDE_DYNAMIC_TYPE_S16
,
88 SIDE_DYNAMIC_TYPE_S32
,
89 SIDE_DYNAMIC_TYPE_S64
,
91 SIDE_DYNAMIC_TYPE_FLOAT_BINARY16
,
92 SIDE_DYNAMIC_TYPE_FLOAT_BINARY32
,
93 SIDE_DYNAMIC_TYPE_FLOAT_BINARY64
,
94 SIDE_DYNAMIC_TYPE_FLOAT_BINARY128
,
96 SIDE_DYNAMIC_TYPE_STRING
,
98 SIDE_DYNAMIC_TYPE_STRUCT
,
99 SIDE_DYNAMIC_TYPE_STRUCT_VISITOR
,
101 SIDE_DYNAMIC_TYPE_VLA
,
102 SIDE_DYNAMIC_TYPE_VLA_VISITOR
,
105 enum side_attr_type
{
117 SIDE_ATTR_TYPE_FLOAT_BINARY16
,
118 SIDE_ATTR_TYPE_FLOAT_BINARY32
,
119 SIDE_ATTR_TYPE_FLOAT_BINARY64
,
120 SIDE_ATTR_TYPE_FLOAT_BINARY128
,
122 SIDE_ATTR_TYPE_STRING
,
126 SIDE_LOGLEVEL_EMERG
= 0,
127 SIDE_LOGLEVEL_ALERT
= 1,
128 SIDE_LOGLEVEL_CRIT
= 2,
129 SIDE_LOGLEVEL_ERR
= 3,
130 SIDE_LOGLEVEL_WARNING
= 4,
131 SIDE_LOGLEVEL_NOTICE
= 5,
132 SIDE_LOGLEVEL_INFO
= 6,
133 SIDE_LOGLEVEL_DEBUG
= 7,
136 enum side_visitor_status
{
137 SIDE_VISITOR_STATUS_OK
= 0,
138 SIDE_VISITOR_STATUS_ERROR
= -1,
141 typedef enum side_visitor_status (*side_visitor
)(
142 const struct side_tracer_visitor_ctx
*tracer_ctx
,
144 typedef enum side_visitor_status (*side_dynamic_struct_visitor
)(
145 const struct side_tracer_dynamic_struct_visitor_ctx
*tracer_ctx
,
147 typedef enum side_visitor_status (*side_dynamic_vla_visitor
)(
148 const struct side_tracer_dynamic_vla_visitor_ctx
*tracer_ctx
,
151 struct side_attr_value
{
152 uint32_t type
; /* enum side_attr_type */
166 _Float16 side_float_binary16
;
169 _Float32 side_float_binary32
;
172 _Float64 side_float_binary64
;
175 _Float128 side_float_binary128
;
182 /* User attributes. */
185 const struct side_attr_value value
;
188 struct side_type_description
{
189 uint32_t type
; /* enum side_type */
191 const struct side_attr
*attr
;
195 const struct side_event_field
*fields
;
199 const struct side_type_description
*elem_type
;
202 const struct side_type_description
*elem_type
;
205 const struct side_type_description
*elem_type
;
206 side_visitor visitor
;
211 struct side_event_field
{
212 const char *field_name
;
213 struct side_type_description side_type
;
216 enum side_event_flags
{
217 SIDE_EVENT_FLAG_VARIADIC
= (1 << 0),
220 struct side_event_description
{
223 uint32_t loglevel
; /* enum side_loglevel */
228 const char *provider_name
;
229 const char *event_name
;
230 const struct side_event_field
*fields
;
231 const struct side_attr
*attr
;
234 struct side_arg_dynamic_vec_vla
{
235 const struct side_arg_dynamic_vec
*sav
;
239 struct side_arg_dynamic_vec
{
240 uint32_t dynamic_type
; /* enum side_dynamic_type */
242 const struct side_attr
*attr
;
256 _Float16 side_float_binary16
;
259 _Float32 side_float_binary32
;
262 _Float64 side_float_binary64
;
265 _Float128 side_float_binary128
;
270 const struct side_arg_dynamic_event_struct
*side_dynamic_struct
;
273 side_dynamic_struct_visitor visitor
;
274 } side_dynamic_struct_visitor
;
276 const struct side_arg_dynamic_vec_vla
*side_dynamic_vla
;
279 side_dynamic_vla_visitor visitor
;
280 } side_dynamic_vla_visitor
;
284 struct side_arg_dynamic_event_field
{
285 const char *field_name
;
286 const struct side_arg_dynamic_vec elem
;
289 struct side_arg_dynamic_event_struct
{
290 const struct side_arg_dynamic_event_field
*fields
;
294 struct side_arg_vec
{
309 _Float16 side_float_binary16
;
312 _Float32 side_float_binary32
;
315 _Float64 side_float_binary64
;
318 _Float128 side_float_binary128
;
322 const struct side_arg_vec_description
*side_struct
;
323 const struct side_arg_vec_description
*side_array
;
324 const struct side_arg_vec_description
*side_vla
;
325 void *side_vla_app_visitor_ctx
;
327 void *side_array_fixint
;
333 struct side_arg_dynamic_vec dynamic
;
337 struct side_arg_vec_description
{
338 const struct side_arg_vec
*sav
;
342 /* The visitor pattern is a double-dispatch visitor. */
343 struct side_tracer_visitor_ctx
{
344 enum side_visitor_status (*write_elem
)(
345 const struct side_tracer_visitor_ctx
*tracer_ctx
,
346 const struct side_arg_vec
*elem
);
347 void *priv
; /* Private tracer context. */
350 struct side_tracer_dynamic_struct_visitor_ctx
{
351 enum side_visitor_status (*write_field
)(
352 const struct side_tracer_dynamic_struct_visitor_ctx
*tracer_ctx
,
353 const struct side_arg_dynamic_event_field
*dynamic_field
);
354 void *priv
; /* Private tracer context. */
357 struct side_tracer_dynamic_vla_visitor_ctx
{
358 enum side_visitor_status (*write_elem
)(
359 const struct side_tracer_dynamic_vla_visitor_ctx
*tracer_ctx
,
360 const struct side_arg_dynamic_vec
*elem
);
361 void *priv
; /* Private tracer context. */
364 #define side_attr(_key, _value) \
367 .value = SIDE_PARAM(_value), \
370 #define side_attr_list(...) \
371 SIDE_COMPOUND_LITERAL(const struct side_attr, __VA_ARGS__)
373 #define side_type_decl(_type, _attr) \
376 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
380 #define side_field(_name, _type, _attr) \
382 .field_name = _name, \
383 .side_type = side_type_decl(_type, SIDE_PARAM(_attr)), \
386 #define side_type_struct_decl(_fields, _attr) \
388 .type = SIDE_TYPE_STRUCT, \
389 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
393 .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
398 #define side_field_struct(_name, _fields, _attr) \
400 .field_name = _name, \
401 .side_type = side_type_struct_decl(SIDE_PARAM(_fields), SIDE_PARAM(_attr)), \
404 #define side_type_array_decl(_elem_type, _length, _attr) \
406 .type = SIDE_TYPE_ARRAY, \
407 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
412 .elem_type = _elem_type, \
416 #define side_field_array(_name, _elem_type, _length, _attr) \
418 .field_name = _name, \
419 .side_type = side_type_array_decl(SIDE_PARAM(_elem_type), _length, SIDE_PARAM(_attr)), \
422 #define side_type_vla_decl(_elem_type, _attr) \
424 .type = SIDE_TYPE_VLA, \
425 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
429 .elem_type = _elem_type, \
433 #define side_field_vla(_name, _elem_type, _attr) \
435 .field_name = _name, \
436 .side_type = side_type_vla_decl(SIDE_PARAM(_elem_type), SIDE_PARAM(_attr)), \
439 #define side_type_vla_visitor_decl(_elem_type, _visitor, _attr) \
441 .type = SIDE_TYPE_VLA_VISITOR, \
442 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
445 .side_vla_visitor = { \
446 .elem_type = SIDE_PARAM(_elem_type), \
447 .visitor = _visitor, \
451 #define side_field_vla_visitor(_name, _elem_type, _visitor, _attr) \
453 .field_name = _name, \
454 .side_type = side_type_vla_visitor_decl(SIDE_PARAM(_elem_type), _visitor, SIDE_PARAM(_attr)), \
457 #define side_elem(...) \
458 SIDE_COMPOUND_LITERAL(const struct side_type_description, __VA_ARGS__)
460 #define side_elem_type(_type, _attr) \
461 side_elem(side_type_decl(_type, SIDE_PARAM(_attr)))
463 #define side_field_list(...) \
464 SIDE_COMPOUND_LITERAL(const struct side_event_field, __VA_ARGS__)
466 #define side_arg_bool(val) { .type = SIDE_TYPE_BOOL, .u = { .side_bool = !!(val) } }
467 #define side_arg_u8(val) { .type = SIDE_TYPE_U8, .u = { .side_u8 = (val) } }
468 #define side_arg_u16(val) { .type = SIDE_TYPE_U16, .u = { .side_u16 = (val) } }
469 #define side_arg_u32(val) { .type = SIDE_TYPE_U32, .u = { .side_u32 = (val) } }
470 #define side_arg_u64(val) { .type = SIDE_TYPE_U64, .u = { .side_u64 = (val) } }
471 #define side_arg_s8(val) { .type = SIDE_TYPE_S8, .u = { .side_s8 = (val) } }
472 #define side_arg_s16(val) { .type = SIDE_TYPE_S16, .u = { .side_s16 = (val) } }
473 #define side_arg_s32(val) { .type = SIDE_TYPE_S32, .u = { .side_s32 = (val) } }
474 #define side_arg_s64(val) { .type = SIDE_TYPE_S64, .u = { .side_s64 = (val) } }
475 #define side_arg_float_binary16(val) { .type = SIDE_TYPE_FLOAT_BINARY16, .u = { .side_float_binary16 = (val) } }
476 #define side_arg_float_binary32(val) { .type = SIDE_TYPE_FLOAT_BINARY32, .u = { .side_float_binary32 = (val) } }
477 #define side_arg_float_binary64(val) { .type = SIDE_TYPE_FLOAT_BINARY64, .u = { .side_float_binary64 = (val) } }
478 #define side_arg_float_binary128(val) { .type = SIDE_TYPE_FLOAT_BINARY128, .u = { .side_float_binary128 = (val) } }
480 #define side_arg_string(val) { .type = SIDE_TYPE_STRING, .u = { .string = (val) } }
481 #define side_arg_struct(_side_type) { .type = SIDE_TYPE_STRUCT, .u = { .side_struct = (_side_type) } }
482 #define side_arg_array(_side_type) { .type = SIDE_TYPE_ARRAY, .u = { .side_array = (_side_type) } }
483 #define side_arg_vla(_side_type) { .type = SIDE_TYPE_VLA, .u = { .side_vla = (_side_type) } }
484 #define side_arg_vla_visitor(_ctx) { .type = SIDE_TYPE_VLA_VISITOR, .u = { .side_vla_app_visitor_ctx = (_ctx) } }
486 #define side_arg_array_u8(_ptr) { .type = SIDE_TYPE_ARRAY_U8, .u = { .side_array_fixint = (_ptr) } }
487 #define side_arg_array_u16(_ptr) { .type = SIDE_TYPE_ARRAY_U16, .u = { .side_array_fixint = (_ptr) } }
488 #define side_arg_array_u32(_ptr) { .type = SIDE_TYPE_ARRAY_U32, .u = { .side_array_fixint = (_ptr) } }
489 #define side_arg_array_u64(_ptr) { .type = SIDE_TYPE_ARRAY_U64, .u = { .side_array_fixint = (_ptr) } }
490 #define side_arg_array_s8(_ptr) { .type = SIDE_TYPE_ARRAY_S8, .u = { .side_array_fixint = (_ptr) } }
491 #define side_arg_array_s16(_ptr) { .type = SIDE_TYPE_ARRAY_S16, .u = { .side_array_fixint = (_ptr) } }
492 #define side_arg_array_s32(_ptr) { .type = SIDE_TYPE_ARRAY_S32, .u = { .side_array_fixint = (_ptr) } }
493 #define side_arg_array_s64(_ptr) { .type = SIDE_TYPE_ARRAY_S64, .u = { .side_array_fixint = (_ptr) } }
495 #define side_arg_vla_u8(_ptr, _length) { .type = SIDE_TYPE_VLA_U8, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } }
496 #define side_arg_vla_u16(_ptr, _length) { .type = SIDE_TYPE_VLA_U16, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
497 #define side_arg_vla_u32(_ptr, _length) { .type = SIDE_TYPE_VLA_U32, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
498 #define side_arg_vla_u64(_ptr, _length) { .type = SIDE_TYPE_VLA_U64, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
499 #define side_arg_vla_s8(_ptr, _length) { .type = SIDE_TYPE_VLA_S8, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
500 #define side_arg_vla_s16(_ptr, _length) { .type = SIDE_TYPE_VLA_S16, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
501 #define side_arg_vla_s32(_ptr, _length) { .type = SIDE_TYPE_VLA_S32, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
502 #define side_arg_vla_s64(_ptr, _length) { .type = SIDE_TYPE_VLA_S64, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
504 #define side_arg_dynamic(dynamic_arg_type) \
506 .type = SIDE_TYPE_DYNAMIC, \
508 .dynamic = dynamic_arg_type, \
512 #define side_arg_dynamic_null(_attr) \
514 .dynamic_type = SIDE_DYNAMIC_TYPE_NULL, \
515 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
519 #define side_arg_dynamic_bool(_val, _attr) \
521 .dynamic_type = SIDE_DYNAMIC_TYPE_BOOL, \
522 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
525 .side_bool = !!(_val), \
529 #define side_arg_dynamic_u8(_val, _attr) \
531 .dynamic_type = SIDE_DYNAMIC_TYPE_U8, \
532 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
538 #define side_arg_dynamic_u16(_val, _attr) \
540 .dynamic_type = SIDE_DYNAMIC_TYPE_U16, \
541 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
544 .side_u16 = (_val), \
547 #define side_arg_dynamic_u32(_val, _attr) \
549 .dynamic_type = SIDE_DYNAMIC_TYPE_U32, \
550 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
553 .side_u32 = (_val), \
556 #define side_arg_dynamic_u64(_val, _attr) \
558 .dynamic_type = SIDE_DYNAMIC_TYPE_U64, \
559 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
562 .side_u64 = (_val), \
566 #define side_arg_dynamic_s8(_val, _attr) \
568 .dynamic_type = SIDE_DYNAMIC_TYPE_S8, \
569 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
575 #define side_arg_dynamic_s16(_val, _attr) \
577 .dynamic_type = SIDE_DYNAMIC_TYPE_S16, \
578 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
581 .side_s16 = (_val), \
584 #define side_arg_dynamic_s32(_val, _attr) \
586 .dynamic_type = SIDE_DYNAMIC_TYPE_S32, \
587 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
590 .side_s32 = (_val), \
593 #define side_arg_dynamic_s64(_val, _attr) \
595 .dynamic_type = SIDE_DYNAMIC_TYPE_S64, \
596 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
599 .side_s64 = (_val), \
603 #define side_arg_dynamic_float_binary16(_val, _attr) \
605 .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY16, \
606 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
609 .side_float_binary16 = (_val), \
612 #define side_arg_dynamic_float_binary32(_val, _attr) \
614 .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY32, \
615 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
618 .side_float_binary32 = (_val), \
621 #define side_arg_dynamic_float_binary64(_val, _attr) \
623 .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY64, \
624 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
627 .side_float_binary64 = (_val), \
630 #define side_arg_dynamic_float_binary128(_val, _attr) \
632 .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY128, \
633 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
636 .side_float_binary128 = (_val), \
640 #define side_arg_dynamic_string(_val, _attr) \
642 .dynamic_type = SIDE_DYNAMIC_TYPE_STRING, \
643 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
650 #define side_arg_dynamic_vla(_vla, _attr) \
652 .dynamic_type = SIDE_DYNAMIC_TYPE_VLA, \
653 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
656 .side_dynamic_vla = (_vla), \
660 #define side_arg_dynamic_vla_visitor(_dynamic_vla_visitor, _ctx, _attr) \
662 .dynamic_type = SIDE_DYNAMIC_TYPE_VLA_VISITOR, \
663 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
666 .side_dynamic_vla_visitor = { \
668 .visitor = _dynamic_vla_visitor, \
673 #define side_arg_dynamic_struct(_struct, _attr) \
675 .dynamic_type = SIDE_DYNAMIC_TYPE_STRUCT, \
676 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
679 .side_dynamic_struct = (_struct), \
683 #define side_arg_dynamic_struct_visitor(_dynamic_struct_visitor, _ctx, _attr) \
685 .dynamic_type = SIDE_DYNAMIC_TYPE_STRUCT_VISITOR, \
686 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
689 .side_dynamic_struct_visitor = { \
691 .visitor = _dynamic_struct_visitor, \
696 #define side_arg_dynamic_define_vec(_identifier, _sav) \
697 const struct side_arg_dynamic_vec _identifier##_vec[] = { _sav }; \
698 const struct side_arg_dynamic_vec_vla _identifier = { \
699 .sav = _identifier##_vec, \
700 .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
703 #define side_arg_dynamic_define_struct(_identifier, _struct_fields) \
704 const struct side_arg_dynamic_event_field _identifier##_fields[] = { _struct_fields }; \
705 const struct side_arg_dynamic_event_struct _identifier = { \
706 .fields = _identifier##_fields, \
707 .len = SIDE_ARRAY_SIZE(_identifier##_fields), \
710 #define side_arg_define_vec(_identifier, _sav) \
711 const struct side_arg_vec _identifier##_vec[] = { _sav }; \
712 const struct side_arg_vec_description _identifier = { \
713 .sav = _identifier##_vec, \
714 .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
717 #define side_arg_dynamic_field(_name, _elem) \
719 .field_name = _name, \
723 #define side_arg_list(...) __VA_ARGS__
725 #define side_attr_bool(val) { .type = SIDE_ATTR_TYPE_BOOL, .u = { .side_bool = !!(val) } }
726 #define side_attr_u8(val) { .type = SIDE_ATTR_TYPE_U8, .u = { .side_u8 = (val) } }
727 #define side_attr_u16(val) { .type = SIDE_ATTR_TYPE_U16, .u = { .side_u16 = (val) } }
728 #define side_attr_u32(val) { .type = SIDE_ATTR_TYPE_U32, .u = { .side_u32 = (val) } }
729 #define side_attr_u64(val) { .type = SIDE_ATTR_TYPE_U64, .u = { .side_u64 = (val) } }
730 #define side_attr_s8(val) { .type = SIDE_ATTR_TYPE_S8, .u = { .side_s8 = (val) } }
731 #define side_attr_s16(val) { .type = SIDE_ATTR_TYPE_S16, .u = { .side_s16 = (val) } }
732 #define side_attr_s32(val) { .type = SIDE_ATTR_TYPE_S32, .u = { .side_s32 = (val) } }
733 #define side_attr_s64(val) { .type = SIDE_ATTR_TYPE_S64, .u = { .side_s64 = (val) } }
734 #define side_attr_float_binary16(val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY16, .u = { .side_float_binary16 = (val) } }
735 #define side_attr_float_binary32(val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY32, .u = { .side_float_binary32 = (val) } }
736 #define side_attr_float_binary64(val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY64, .u = { .side_float_binary64 = (val) } }
737 #define side_attr_float_binary128(val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY128, .u = { .side_float_binary128 = (val) } }
738 #define side_attr_string(val) { .type = SIDE_ATTR_TYPE_STRING, .u = { .string = (val) } }
740 #define side_event_cond(desc) if (side_unlikely((desc)->enabled))
742 #define side_event_call(desc, _sav) \
744 const struct side_arg_vec side_sav[] = { _sav }; \
745 const struct side_arg_vec_description sav_desc = { \
747 .len = SIDE_ARRAY_SIZE(side_sav), \
749 tracer_call(desc, &sav_desc); \
752 #define side_event(desc, sav) \
753 side_event_cond(desc) \
754 side_event_call(desc, SIDE_PARAM(sav))
756 #define side_event_call_variadic(desc, _sav, _var_fields) \
758 const struct side_arg_vec side_sav[] = { _sav }; \
759 const struct side_arg_vec_description sav_desc = { \
761 .len = SIDE_ARRAY_SIZE(side_sav), \
763 const struct side_arg_dynamic_event_field side_fields[] = { _var_fields }; \
764 const struct side_arg_dynamic_event_struct var_struct = { \
765 .fields = side_fields, \
766 .len = SIDE_ARRAY_SIZE(side_fields), \
768 tracer_call_variadic(desc, &sav_desc, &var_struct); \
771 #define side_event_variadic(desc, sav, var) \
772 side_event_cond(desc) \
773 side_event_call_variadic(desc, SIDE_PARAM(sav), SIDE_PARAM(var))
775 #define _side_define_event(_identifier, _provider, _event, _loglevel, _fields, _attr, _flags) \
776 struct side_event_description _identifier = { \
779 .loglevel = _loglevel, \
780 .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
781 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
783 .provider_name = _provider, \
784 .event_name = _event, \
789 #define side_define_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \
790 _side_define_event(_identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
791 SIDE_PARAM(_attr), 0)
793 #define side_define_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \
794 _side_define_event(_identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
795 SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC)
797 #define side_declare_event(_identifier) \
798 struct side_event_description _identifier
800 #endif /* _SIDE_TRACE_H */