1 // SPDX-License-Identifier: MIT
3 * Copyright 2022 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
14 #include <side/macros.h>
15 #include <side/endian.h>
17 /* SIDE stands for "Static Instrumentation Dynamically Enabled" */
19 //TODO: as those structures will be ABI, we need to either consider them
20 //fixed forever, or think of a scheme that would allow their binary
21 //representation to be extended if need be.
25 struct side_arg_dynamic
;
26 struct side_arg_dynamic_field
;
27 struct side_arg_dynamic_vla
;
29 struct side_event_field
;
30 struct side_tracer_visitor_ctx
;
31 struct side_tracer_dynamic_struct_visitor_ctx
;
32 struct side_event_description
;
33 struct side_arg_dynamic_struct
;
34 struct side_events_register_handle
;
36 enum side_type_label
{
37 /* Statically declared types */
51 SIDE_TYPE_FLOAT_BINARY16
,
52 SIDE_TYPE_FLOAT_BINARY32
,
53 SIDE_TYPE_FLOAT_BINARY64
,
54 SIDE_TYPE_FLOAT_BINARY128
,
57 /* Statically declared compound types */
61 SIDE_TYPE_VLA_VISITOR
,
72 SIDE_TYPE_ARRAY_POINTER32
,
73 SIDE_TYPE_ARRAY_POINTER64
,
84 SIDE_TYPE_VLA_POINTER32
,
85 SIDE_TYPE_VLA_POINTER64
,
87 /* Statically declared enumeration types */
89 SIDE_TYPE_ENUM_BITMAP
,
94 SIDE_TYPE_GATHER_UNSIGNED_INT
,
95 SIDE_TYPE_GATHER_SIGNED_INT
,
96 SIDE_TYPE_GATHER_FLOAT
,
97 SIDE_TYPE_GATHER_STRUCT
,
98 SIDE_TYPE_GATHER_ARRAY
,
102 SIDE_TYPE_DYNAMIC_NULL
,
103 SIDE_TYPE_DYNAMIC_BOOL
,
104 SIDE_TYPE_DYNAMIC_U8
,
105 SIDE_TYPE_DYNAMIC_U16
,
106 SIDE_TYPE_DYNAMIC_U32
,
107 SIDE_TYPE_DYNAMIC_U64
,
108 SIDE_TYPE_DYNAMIC_S8
,
109 SIDE_TYPE_DYNAMIC_S16
,
110 SIDE_TYPE_DYNAMIC_S32
,
111 SIDE_TYPE_DYNAMIC_S64
,
112 SIDE_TYPE_DYNAMIC_BYTE
,
113 SIDE_TYPE_DYNAMIC_POINTER32
,
114 SIDE_TYPE_DYNAMIC_POINTER64
,
115 SIDE_TYPE_DYNAMIC_FLOAT_BINARY16
,
116 SIDE_TYPE_DYNAMIC_FLOAT_BINARY32
,
117 SIDE_TYPE_DYNAMIC_FLOAT_BINARY64
,
118 SIDE_TYPE_DYNAMIC_FLOAT_BINARY128
,
119 SIDE_TYPE_DYNAMIC_STRING
,
121 /* Dynamic compound types */
122 SIDE_TYPE_DYNAMIC_STRUCT
,
123 SIDE_TYPE_DYNAMIC_STRUCT_VISITOR
,
124 SIDE_TYPE_DYNAMIC_VLA
,
125 SIDE_TYPE_DYNAMIC_VLA_VISITOR
,
128 enum side_attr_type
{
139 SIDE_ATTR_TYPE_POINTER32
,
140 SIDE_ATTR_TYPE_POINTER64
,
141 SIDE_ATTR_TYPE_FLOAT_BINARY16
,
142 SIDE_ATTR_TYPE_FLOAT_BINARY32
,
143 SIDE_ATTR_TYPE_FLOAT_BINARY64
,
144 SIDE_ATTR_TYPE_FLOAT_BINARY128
,
145 SIDE_ATTR_TYPE_STRING
,
149 SIDE_LOGLEVEL_EMERG
= 0,
150 SIDE_LOGLEVEL_ALERT
= 1,
151 SIDE_LOGLEVEL_CRIT
= 2,
152 SIDE_LOGLEVEL_ERR
= 3,
153 SIDE_LOGLEVEL_WARNING
= 4,
154 SIDE_LOGLEVEL_NOTICE
= 5,
155 SIDE_LOGLEVEL_INFO
= 6,
156 SIDE_LOGLEVEL_DEBUG
= 7,
159 enum side_visitor_status
{
160 SIDE_VISITOR_STATUS_OK
= 0,
161 SIDE_VISITOR_STATUS_ERROR
= -1,
166 SIDE_ERROR_INVAL
= 1,
167 SIDE_ERROR_EXIST
= 2,
168 SIDE_ERROR_NOMEM
= 3,
169 SIDE_ERROR_NOENT
= 4,
170 SIDE_ERROR_EXITING
= 5,
173 enum side_type_label_byte_order
{
174 SIDE_TYPE_BYTE_ORDER_LE
= 0,
175 SIDE_TYPE_BYTE_ORDER_BE
= 1,
178 #if (SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN)
179 # define SIDE_TYPE_BYTE_ORDER_HOST SIDE_TYPE_BYTE_ORDER_LE
181 # define SIDE_TYPE_BYTE_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE
184 #if (SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN)
185 # define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_LE
187 # define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE
190 typedef enum side_visitor_status (*side_visitor_func
)(
191 const struct side_tracer_visitor_ctx
*tracer_ctx
,
193 typedef enum side_visitor_status (*side_dynamic_struct_visitor_func
)(
194 const struct side_tracer_dynamic_struct_visitor_ctx
*tracer_ctx
,
197 union side_integer_value
{
208 union side_float_value
{
210 _Float16 side_float_binary16
;
213 _Float32 side_float_binary32
;
216 _Float64 side_float_binary64
;
219 _Float128 side_float_binary128
;
223 struct side_attr_value
{
224 uint32_t type
; /* enum side_attr_type */
227 uint64_t string_value
; /* const char * */
228 union side_integer_value integer_value
;
229 union side_float_value float_value
;
233 /* User attributes. */
236 const struct side_attr_value value
;
239 /* Type descriptions */
240 struct side_type_null
{
241 const struct side_attr
*attr
;
245 struct side_type_bool
{
246 const struct side_attr
*attr
;
250 struct side_type_byte
{
251 const struct side_attr
*attr
;
255 struct side_type_string
{
256 const struct side_attr
*attr
;
260 struct side_type_integer
{
261 const struct side_attr
*attr
;
263 uint16_t integer_size_bits
; /* bits */
264 uint16_t len_bits
; /* bits */
265 uint8_t signedness
; /* true/false */
266 uint8_t byte_order
; /* enum side_type_label_byte_order */
269 struct side_type_float
{
270 const struct side_attr
*attr
;
272 uint16_t float_size_bits
; /* bits */
273 uint8_t byte_order
; /* enum side_type_label_byte_order */
276 struct side_enum_mapping
{
282 struct side_enum_mappings
{
283 const struct side_enum_mapping
*mappings
;
284 const struct side_attr
*attr
;
285 uint32_t nr_mappings
;
289 struct side_enum_bitmap_mapping
{
290 uint64_t range_begin
;
295 struct side_enum_bitmap_mappings
{
296 const struct side_enum_bitmap_mapping
*mappings
;
297 const struct side_attr
*attr
;
298 uint32_t nr_mappings
;
302 struct side_type_struct
{
303 const struct side_event_field
*fields
;
304 const struct side_attr
*attr
;
309 struct side_type_array
{
310 const struct side_type
*elem_type
;
311 const struct side_attr
*attr
;
316 struct side_type_vla
{
317 const struct side_type
*elem_type
;
318 const struct side_attr
*attr
;
322 struct side_type_vla_visitor
{
323 const struct side_type
*elem_type
;
324 side_visitor_func visitor
;
325 const struct side_attr
*attr
;
329 struct side_type_enum
{
330 const struct side_enum_mappings
*mappings
;
331 const struct side_type
*elem_type
;
334 struct side_type_enum_bitmap
{
335 const struct side_enum_bitmap_mappings
*mappings
;
336 const struct side_type
*elem_type
;
339 struct side_type_gather_integer
{
340 uint64_t offset
; /* bytes */
341 uint8_t access_mode
; /* enum side_type_gather_access_mode */
342 struct side_type_integer type
;
343 uint16_t offset_bits
; /* bits */
346 struct side_type_gather_float
{
347 uint64_t offset
; /* bytes */
348 uint8_t access_mode
; /* enum side_type_gather_access_mode */
349 struct side_type_float type
;
352 struct side_type_gather_struct
{
353 uint64_t offset
; /* bytes */
354 uint8_t access_mode
; /* enum side_type_gather_access_mode */
355 const struct side_type_struct
*type
;
356 uint32_t size
; /* bytes */
359 struct side_type_gather_array
{
360 uint64_t offset
; /* bytes */
361 uint8_t access_mode
; /* enum side_type_gather_access_mode */
362 struct side_type_array type
;
365 struct side_type_gather_vla
{
366 const struct side_type
*length_type
; /* side_length() */
368 uint64_t offset
; /* bytes */
369 uint8_t access_mode
; /* enum side_type_gather_access_mode */
370 struct side_type_vla type
;
373 enum side_type_gather_access_mode
{
374 SIDE_TYPE_GATHER_ACCESS_ADDRESS
,
375 SIDE_TYPE_GATHER_ACCESS_POINTER
,
378 struct side_type_gather
{
380 struct side_type_gather_integer side_integer
;
381 struct side_type_gather_float side_float
;
382 struct side_type_gather_array side_array
;
383 struct side_type_gather_vla side_vla
;
384 struct side_type_gather_struct side_struct
;
388 /* Statically defined types. */
390 uint32_t type
; /* enum side_type_label */
393 struct side_type_null side_null
;
394 struct side_type_bool side_bool
;
395 struct side_type_byte side_byte
;
396 struct side_type_string side_string
;
397 struct side_type_integer side_integer
;
398 struct side_type_float side_float
;
401 struct side_type_array side_array
;
402 struct side_type_vla side_vla
;
403 struct side_type_vla_visitor side_vla_visitor
;
404 const struct side_type_struct
*side_struct
;
406 /* Enumeration types */
407 struct side_type_enum side_enum
;
408 struct side_type_enum_bitmap side_enum_bitmap
;
411 struct side_type_gather side_gather
;
415 struct side_event_field
{
416 const char *field_name
;
417 struct side_type side_type
;
420 enum side_event_flags
{
421 SIDE_EVENT_FLAG_VARIADIC
= (1 << 0),
424 struct side_callback
{
426 void (*call
)(const struct side_event_description
*desc
,
427 const struct side_arg_vec
*side_arg_vec
,
429 void (*call_variadic
)(const struct side_event_description
*desc
,
430 const struct side_arg_vec
*side_arg_vec
,
431 const struct side_arg_dynamic_struct
*var_struct
,
437 struct side_arg_static
{
441 uint64_t string_value
; /* const char * */
442 union side_integer_value integer_value
;
443 union side_float_value float_value
;
446 const struct side_arg_vec
*side_struct
;
447 const struct side_arg_vec
*side_array
;
448 const struct side_arg_vec
*side_vla
;
449 void *side_vla_app_visitor_ctx
;
450 void *side_array_fixint
;
454 } SIDE_PACKED side_vla_fixint
;
457 void *side_integer_gather_ptr
;
458 void *side_float_gather_ptr
;
459 void *side_array_gather_ptr
;
460 void *side_struct_gather_ptr
;
464 } SIDE_PACKED side_vla_gather
;
467 struct side_arg_dynamic_vla
{
468 const struct side_arg
*sav
;
469 const struct side_attr
*attr
;
474 struct side_arg_dynamic_struct
{
475 const struct side_arg_dynamic_field
*fields
;
476 const struct side_attr
*attr
;
481 struct side_dynamic_struct_visitor
{
483 side_dynamic_struct_visitor_func visitor
;
484 const struct side_attr
*attr
;
488 struct side_dynamic_vla_visitor
{
490 side_visitor_func visitor
;
491 const struct side_attr
*attr
;
495 struct side_arg_dynamic
{
497 struct side_type_null side_null
;
499 struct side_type_bool type
;
501 } SIDE_PACKED side_bool
;
504 struct side_type_byte type
;
506 } SIDE_PACKED side_byte
;
509 struct side_type_string type
;
510 uint64_t value
; /* const char * */
511 } SIDE_PACKED side_string
;
515 struct side_type_integer type
;
516 union side_integer_value value
;
517 } SIDE_PACKED side_integer
;
520 struct side_type_float type
;
521 union side_float_value value
;
522 } SIDE_PACKED side_float
;
525 const struct side_arg_dynamic_struct
*side_dynamic_struct
;
526 const struct side_arg_dynamic_vla
*side_dynamic_vla
;
528 struct side_dynamic_struct_visitor side_dynamic_struct_visitor
;
529 struct side_dynamic_vla_visitor side_dynamic_vla_visitor
;
533 enum side_type_label type
;
535 struct side_arg_static side_static
;
536 struct side_arg_dynamic side_dynamic
;
540 struct side_arg_vec
{
541 const struct side_arg
*sav
;
545 struct side_arg_dynamic_field
{
546 const char *field_name
;
547 const struct side_arg elem
;
550 /* The visitor pattern is a double-dispatch visitor. */
551 struct side_tracer_visitor_ctx
{
552 enum side_visitor_status (*write_elem
)(
553 const struct side_tracer_visitor_ctx
*tracer_ctx
,
554 const struct side_arg
*elem
);
555 void *priv
; /* Private tracer context. */
558 struct side_tracer_dynamic_struct_visitor_ctx
{
559 enum side_visitor_status (*write_field
)(
560 const struct side_tracer_dynamic_struct_visitor_ctx
*tracer_ctx
,
561 const struct side_arg_dynamic_field
*dynamic_field
);
562 void *priv
; /* Private tracer context. */
565 struct side_event_description
{
567 const char *provider_name
;
568 const char *event_name
;
569 const struct side_event_field
*fields
;
570 const struct side_attr
*attr
;
571 const struct side_callback
*callbacks
;
574 uint32_t loglevel
; /* enum side_loglevel */
577 uint32_t nr_callbacks
;
580 /* Event and type attributes */
582 #if SIDE_BITS_PER_LONG == 64
583 # define SIDE_TYPE_POINTER_HOST SIDE_TYPE_POINTER64
584 # define SIDE_TYPE_ARRAY_POINTER_HOST SIDE_TYPE_ARRAY_POINTER64
585 # define SIDE_TYPE_VLA_POINTER_HOST SIDE_TYPE_VLA_POINTER64
586 # define SIDE_TYPE_DYNAMIC_POINTER_HOST SIDE_TYPE_DYNAMIC_POINTER64
587 # define SIDE_ATTR_TYPE_POINTER_HOST SIDE_ATTR_TYPE_POINTER64
588 # define SIDE_PTR_HOST .side_u64
590 # define SIDE_TYPE_POINTER_HOST SIDE_TYPE_POINTER32
591 # define SIDE_TYPE_ARRAY_POINTER_HOST SIDE_TYPE_ARRAY_POINTER32
592 # define SIDE_TYPE_VLA_POINTER_HOST SIDE_TYPE_VLA_POINTER32
593 # define SIDE_TYPE_DYNAMIC_POINTER_HOST SIDE_TYPE_DYNAMIC_POINTER32
594 # define SIDE_ATTR_TYPE_POINTER_HOST SIDE_ATTR_TYPE_POINTER32
595 # define SIDE_PTR_HOST .side_u32
598 #define side_attr(_key, _value) \
601 .value = SIDE_PARAM(_value), \
604 #define side_attr_list(...) \
605 SIDE_COMPOUND_LITERAL(const struct side_attr, __VA_ARGS__)
607 #define side_attr_null(_val) { .type = SIDE_ATTR_TYPE_NULL }
608 #define side_attr_bool(_val) { .type = SIDE_ATTR_TYPE_BOOL, .u = { .bool_value = !!(_val) } }
609 #define side_attr_u8(_val) { .type = SIDE_ATTR_TYPE_U8, .u = { .integer_value = { .side_u8 = (_val) } } }
610 #define side_attr_u16(_val) { .type = SIDE_ATTR_TYPE_U16, .u = { .integer_value = { .side_u16 = (_val) } } }
611 #define side_attr_u32(_val) { .type = SIDE_ATTR_TYPE_U32, .u = { .integer_value = { .side_u32 = (_val) } } }
612 #define side_attr_u64(_val) { .type = SIDE_ATTR_TYPE_U64, .u = { .integer_value = { .side_u64 = (_val) } } }
613 #define side_attr_s8(_val) { .type = SIDE_ATTR_TYPE_S8, .u = { .integer_value = { .side_s8 = (_val) } } }
614 #define side_attr_s16(_val) { .type = SIDE_ATTR_TYPE_S16, .u = { .integer_value = { .side_s16 = (_val) } } }
615 #define side_attr_s32(_val) { .type = SIDE_ATTR_TYPE_S32, .u = { .integer_value = { .side_s32 = (_val) } } }
616 #define side_attr_s64(_val) { .type = SIDE_ATTR_TYPE_S64, .u = { .integer_value = { .side_s64 = (_val) } } }
617 #define side_attr_pointer(_val) { .type = SIDE_ATTR_TYPE_POINTER_HOST, .u = { .integer_value = { SIDE_PTR_HOST = (uintptr_t) (_val) } } }
618 #define side_attr_float_binary16(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY16, .u = { .float_value = { .side_float_binary16 = (_val) } } }
619 #define side_attr_float_binary32(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY32, .u = { .float_value = { .side_float_binary32 = (_val) } } }
620 #define side_attr_float_binary64(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY64, .u = { .float_value = { .side_float_binary64 = (_val) } } }
621 #define side_attr_float_binary128(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY128, .u = { .float_value = { .side_float_binary128 = (_val) } } }
622 #define side_attr_string(_val) { .type = SIDE_ATTR_TYPE_STRING, .u = { .string_value = (uintptr_t) (_val) } }
624 /* Static field definition */
626 #define side_type_null(_attr) \
628 .type = SIDE_TYPE_NULL, \
632 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
637 #define side_type_bool(_attr) \
639 .type = SIDE_TYPE_BOOL, \
643 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
648 #define side_type_byte(_attr) \
650 .type = SIDE_TYPE_BYTE, \
654 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
659 #define side_type_string(_attr) \
661 .type = SIDE_TYPE_STRING, \
665 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
670 #define side_type_dynamic() \
672 .type = SIDE_TYPE_DYNAMIC, \
675 #define _side_type_integer(_type, _signedness, _byte_order, _integer_size_bits, _len_bits, _attr) \
681 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
682 .integer_size_bits = _integer_size_bits, \
683 .len_bits = _len_bits, \
684 .signedness = _signedness, \
685 .byte_order = _byte_order, \
690 #define _side_type_float(_type, _byte_order, _float_size_bits, _attr) \
696 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
697 .float_size_bits = _float_size_bits, \
698 .byte_order = _byte_order, \
703 #define _side_field(_name, _type) \
705 .field_name = _name, \
706 .side_type = _type, \
710 #define side_type_u8(_attr) _side_type_integer(SIDE_TYPE_U8, false, SIDE_TYPE_BYTE_ORDER_HOST, 8, 8, SIDE_PARAM(_attr))
711 #define side_type_u16(_attr) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_HOST, 16, 16, SIDE_PARAM(_attr))
712 #define side_type_u32(_attr) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_HOST, 32, 32, SIDE_PARAM(_attr))
713 #define side_type_u64(_attr) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_HOST, 64, 64, SIDE_PARAM(_attr))
714 #define side_type_s8(_attr) _side_type_integer(SIDE_TYPE_S8, true, SIDE_TYPE_BYTE_ORDER_HOST, 8, 8, SIDE_PARAM(_attr))
715 #define side_type_s16(_attr) _side_type_integer(SIDE_TYPE_S16, true, SIDE_TYPE_BYTE_ORDER_HOST, 16, 16, SIDE_PARAM(_attr))
716 #define side_type_s32(_attr) _side_type_integer(SIDE_TYPE_S32, true, SIDE_TYPE_BYTE_ORDER_HOST, 32, 32, SIDE_PARAM(_attr))
717 #define side_type_s64(_attr) _side_type_integer(SIDE_TYPE_S64, true, SIDE_TYPE_BYTE_ORDER_HOST, 64, 64, SIDE_PARAM(_attr))
718 #define side_type_pointer(_attr) _side_type_integer(SIDE_TYPE_POINTER_HOST, false, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_BITS_PER_LONG, \
719 SIDE_BITS_PER_LONG, SIDE_PARAM(_attr))
720 #define side_type_float_binary16(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, 16, SIDE_PARAM(_attr))
721 #define side_type_float_binary32(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, 32, SIDE_PARAM(_attr))
722 #define side_type_float_binary64(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, 64, SIDE_PARAM(_attr))
723 #define side_type_float_binary128(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, 128, SIDE_PARAM(_attr))
725 #define side_field_null(_name, _attr) _side_field(_name, side_type_null(SIDE_PARAM(_attr)))
726 #define side_field_bool(_name, _attr) _side_field(_name, side_type_bool(SIDE_PARAM(_attr)))
727 #define side_field_u8(_name, _attr) _side_field(_name, side_type_u8(SIDE_PARAM(_attr)))
728 #define side_field_u16(_name, _attr) _side_field(_name, side_type_u16(SIDE_PARAM(_attr)))
729 #define side_field_u32(_name, _attr) _side_field(_name, side_type_u32(SIDE_PARAM(_attr)))
730 #define side_field_u64(_name, _attr) _side_field(_name, side_type_u64(SIDE_PARAM(_attr)))
731 #define side_field_s8(_name, _attr) _side_field(_name, side_type_s8(SIDE_PARAM(_attr)))
732 #define side_field_s16(_name, _attr) _side_field(_name, side_type_s16(SIDE_PARAM(_attr)))
733 #define side_field_s32(_name, _attr) _side_field(_name, side_type_s32(SIDE_PARAM(_attr)))
734 #define side_field_s64(_name, _attr) _side_field(_name, side_type_s64(SIDE_PARAM(_attr)))
735 #define side_field_byte(_name, _attr) _side_field(_name, side_type_byte(SIDE_PARAM(_attr)))
736 #define side_field_pointer(_name, _attr) _side_field(_name, side_type_pointer(SIDE_PARAM(_attr)))
737 #define side_field_float_binary16(_name, _attr) _side_field(_name, side_type_float_binary16(SIDE_PARAM(_attr)))
738 #define side_field_float_binary32(_name, _attr) _side_field(_name, side_type_float_binary32(SIDE_PARAM(_attr)))
739 #define side_field_float_binary64(_name, _attr) _side_field(_name, side_type_float_binary64(SIDE_PARAM(_attr)))
740 #define side_field_float_binary128(_name, _attr) _side_field(_name, side_type_float_binary128(SIDE_PARAM(_attr)))
741 #define side_field_string(_name, _attr) _side_field(_name, side_type_string(SIDE_PARAM(_attr)))
742 #define side_field_dynamic(_name) _side_field(_name, side_type_dynamic())
745 #define side_type_u16_le(_attr) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_LE, 16, 16, SIDE_PARAM(_attr))
746 #define side_type_u32_le(_attr) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_LE, 32, 32, SIDE_PARAM(_attr))
747 #define side_type_u64_le(_attr) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_LE, 64, 64, SIDE_PARAM(_attr))
748 #define side_type_s16_le(_attr) _side_type_integer(SIDE_TYPE_S16, true, SIDE_TYPE_BYTE_ORDER_LE, 16, 16, SIDE_PARAM(_attr))
749 #define side_type_s32_le(_attr) _side_type_integer(SIDE_TYPE_S32, true, SIDE_TYPE_BYTE_ORDER_LE, 32, 32, SIDE_PARAM(_attr))
750 #define side_type_s64_le(_attr) _side_type_integer(SIDE_TYPE_S64, true, SIDE_TYPE_BYTE_ORDER_LE, 64, 64, SIDE_PARAM(_attr))
751 #define side_type_pointer_le(_attr) _side_type_integer(SIDE_TYPE_POINTER_HOST, false, SIDE_TYPE_BYTE_ORDER_LE, SIDE_BITS_PER_LONG, \
752 SIDE_BITS_PER_LONG, SIDE_PARAM(_attr))
753 #define side_type_float_binary16_le(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_BYTE_ORDER_LE, 16, SIDE_PARAM(_attr))
754 #define side_type_float_binary32_le(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_BYTE_ORDER_LE, 32, SIDE_PARAM(_attr))
755 #define side_type_float_binary64_le(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_BYTE_ORDER_LE, 64, SIDE_PARAM(_attr))
756 #define side_type_float_binary128_le(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_BYTE_ORDER_LE, 128, SIDE_PARAM(_attr))
758 #define side_field_u16_le(_name, _attr) _side_field(_name, side_type_u16_le(SIDE_PARAM(_attr)))
759 #define side_field_u32_le(_name, _attr) _side_field(_name, side_type_u32_le(SIDE_PARAM(_attr)))
760 #define side_field_u64_le(_name, _attr) _side_field(_name, side_type_u64_le(SIDE_PARAM(_attr)))
761 #define side_field_s16_le(_name, _attr) _side_field(_name, side_type_s16_le(SIDE_PARAM(_attr)))
762 #define side_field_s32_le(_name, _attr) _side_field(_name, side_type_s32_le(SIDE_PARAM(_attr)))
763 #define side_field_s64_le(_name, _attr) _side_field(_name, side_type_s64_le(SIDE_PARAM(_attr)))
764 #define side_field_pointer_le(_name, _attr) _side_field(_name, side_type_pointer_le(SIDE_PARAM(_attr)))
765 #define side_field_float_binary16_le(_name, _attr) _side_field(_name, side_type_float_binary16_le(SIDE_PARAM(_attr)))
766 #define side_field_float_binary32_le(_name, _attr) _side_field(_name, side_type_float_binary32_le(SIDE_PARAM(_attr)))
767 #define side_field_float_binary64_le(_name, _attr) _side_field(_name, side_type_float_binary64_le(SIDE_PARAM(_attr)))
768 #define side_field_float_binary128_le(_name, _attr) _side_field(_name, side_type_float_binary128_le(SIDE_PARAM(_attr)))
771 #define side_type_u16_be(_attr) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_BE, 16, 16, SIDE_PARAM(_attr))
772 #define side_type_u32_be(_attr) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_BE, 32, 32, SIDE_PARAM(_attr))
773 #define side_type_u64_be(_attr) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_BE, 64, 64, SIDE_PARAM(_attr))
774 #define side_type_s16_be(_attr) _side_type_integer(SIDE_TYPE_S16, false, SIDE_TYPE_BYTE_ORDER_BE, 16, 16, SIDE_PARAM(_attr))
775 #define side_type_s32_be(_attr) _side_type_integer(SIDE_TYPE_S32, false, SIDE_TYPE_BYTE_ORDER_BE, 32, 32, SIDE_PARAM(_attr))
776 #define side_type_s64_be(_attr) _side_type_integer(SIDE_TYPE_S64, false, SIDE_TYPE_BYTE_ORDER_BE, 64, 64, SIDE_PARAM(_attr))
777 #define side_type_pointer_be(_attr) _side_type_integer(SIDE_TYPE_POINTER_HOST, false, SIDE_TYPE_BYTE_ORDER_BE, SIDE_BITS_PER_LONG, \
778 SIDE_BITS_PER_LONG, SIDE_PARAM(_attr))
779 #define side_type_float_binary16_be(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_BYTE_ORDER_BE, 16, SIDE_PARAM(_attr))
780 #define side_type_float_binary32_be(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_BYTE_ORDER_BE, 32, SIDE_PARAM(_attr))
781 #define side_type_float_binary64_be(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_BYTE_ORDER_BE, 64, SIDE_PARAM(_attr))
782 #define side_type_float_binary128_be(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_BYTE_ORDER_BE, 128, SIDE_PARAM(_attr))
784 #define side_field_u16_be(_name, _attr) _side_field(_name, side_type_u16_be(SIDE_PARAM(_attr)))
785 #define side_field_u32_be(_name, _attr) _side_field(_name, side_type_u32_be(SIDE_PARAM(_attr)))
786 #define side_field_u64_be(_name, _attr) _side_field(_name, side_type_u64_be(SIDE_PARAM(_attr)))
787 #define side_field_s16_be(_name, _attr) _side_field(_name, side_type_s16_be(SIDE_PARAM(_attr)))
788 #define side_field_s32_be(_name, _attr) _side_field(_name, side_type_s32_be(SIDE_PARAM(_attr)))
789 #define side_field_s64_be(_name, _attr) _side_field(_name, side_type_s64_be(SIDE_PARAM(_attr)))
790 #define side_field_pointer_be(_name, _attr) _side_field(_name, side_type_pointer_be(SIDE_PARAM(_attr)))
791 #define side_field_float_binary16_be(_name, _attr) _side_field(_name, side_type_float_binary16_be(SIDE_PARAM(_attr)))
792 #define side_field_float_binary32_be(_name, _attr) _side_field(_name, side_type_float_binary32_be(SIDE_PARAM(_attr)))
793 #define side_field_float_binary64_be(_name, _attr) _side_field(_name, side_type_float_binary64_be(SIDE_PARAM(_attr)))
794 #define side_field_float_binary128_be(_name, _attr) _side_field(_name, side_type_float_binary128_be(SIDE_PARAM(_attr)))
796 #define side_type_enum(_mappings, _elem_type) \
798 .type = SIDE_TYPE_ENUM, \
801 .mappings = _mappings, \
802 .elem_type = _elem_type, \
806 #define side_field_enum(_name, _mappings, _elem_type) \
807 _side_field(_name, side_type_enum(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type)))
809 #define side_type_enum_bitmap(_mappings, _elem_type) \
811 .type = SIDE_TYPE_ENUM_BITMAP, \
813 .side_enum_bitmap = { \
814 .mappings = _mappings, \
815 .elem_type = _elem_type, \
819 #define side_field_enum_bitmap(_name, _mappings, _elem_type) \
820 _side_field(_name, side_type_enum_bitmap(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type)))
822 #define side_type_struct(_struct) \
824 .type = SIDE_TYPE_STRUCT, \
826 .side_struct = _struct, \
829 #define side_field_struct(_name, _struct) \
830 _side_field(_name, side_type_struct(SIDE_PARAM(_struct)))
832 #define _side_type_struct_define(_fields, _attr) \
836 .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
837 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
840 #define side_define_struct(_identifier, _fields, _attr) \
841 const struct side_type_struct _identifier = _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM(_attr))
843 #define side_struct_literal(_fields, _attr) \
844 SIDE_COMPOUND_LITERAL(const struct side_type_struct, \
845 _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM(_attr)))
847 #define side_type_array(_elem_type, _length, _attr) \
849 .type = SIDE_TYPE_ARRAY, \
852 .elem_type = _elem_type, \
855 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
859 #define side_field_array(_name, _elem_type, _length, _attr) \
860 _side_field(_name, side_type_array(SIDE_PARAM(_elem_type), _length, SIDE_PARAM(_attr)))
862 #define side_type_vla(_elem_type, _attr) \
864 .type = SIDE_TYPE_VLA, \
867 .elem_type = _elem_type, \
869 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
873 #define side_field_vla(_name, _elem_type, _attr) \
874 _side_field(_name, side_type_vla(SIDE_PARAM(_elem_type), SIDE_PARAM(_attr)))
876 #define side_type_vla_visitor(_elem_type, _visitor, _attr) \
878 .type = SIDE_TYPE_VLA_VISITOR, \
880 .side_vla_visitor = { \
881 .elem_type = SIDE_PARAM(_elem_type), \
882 .visitor = _visitor, \
884 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
888 #define side_field_vla_visitor(_name, _elem_type, _visitor, _attr) \
889 _side_field(_name, side_type_vla_visitor(SIDE_PARAM(_elem_type), _visitor, SIDE_PARAM(_attr)))
893 #define _side_type_gather_integer(_type, _signedness, _byte_order, _offset, \
894 _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
902 .access_mode = _access_mode, \
905 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
906 .integer_size_bits = _integer_size_bits, \
907 .len_bits = _len_bits, \
908 .signedness = _signedness, \
909 .byte_order = _byte_order, \
911 .offset_bits = _offset_bits, \
918 #define side_type_gather_unsigned_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
919 _side_type_gather_integer(SIDE_TYPE_GATHER_UNSIGNED_INT, false, SIDE_TYPE_BYTE_ORDER_HOST, \
920 _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr))
921 #define side_type_gather_signed_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
922 _side_type_gather_integer(SIDE_TYPE_GATHER_SIGNED_INT, true, SIDE_TYPE_BYTE_ORDER_HOST, \
923 _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr))
925 #define side_type_gather_unsigned_integer_le(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
926 _side_type_gather_integer(SIDE_TYPE_GATHER_UNSIGNED_INT, false, SIDE_TYPE_BYTE_ORDER_LE, \
927 _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr))
928 #define side_type_gather_signed_integer_le(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
929 _side_type_gather_integer(SIDE_TYPE_GATHER_SIGNED_INT, true, SIDE_TYPE_BYTE_ORDER_LE, \
930 _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr))
932 #define side_type_gather_unsigned_integer_be(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
933 _side_type_gather_integer(SIDE_TYPE_GATHER_UNSIGNED_INT, false, SIDE_TYPE_BYTE_ORDER_BE, \
934 _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr))
935 #define side_type_gather_signed_integer_be(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
936 _side_type_gather_integer(SIDE_TYPE_GATHER_SIGNED_INT, true, SIDE_TYPE_BYTE_ORDER_BE, \
937 _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr))
939 #define side_field_gather_unsigned_integer(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
940 _side_field(_name, side_type_gather_unsigned_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
941 #define side_field_gather_signed_integer(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
942 _side_field(_name, side_type_gather_signed_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
944 #define side_field_gather_unsigned_integer_le(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
945 _side_field(_name, side_type_gather_unsigned_integer_le(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
946 #define side_field_gather_signed_integer_le(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
947 _side_field(_name, side_type_gather_signed_integer_le(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
949 #define side_field_gather_unsigned_integer_be(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
950 _side_field(_name, side_type_gather_unsigned_integer_be(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
951 #define side_field_gather_signed_integer_be(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
952 _side_field(_name, side_type_gather_signed_integer_be(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
954 #define _side_type_gather_float(_byte_order, _offset, _float_size_bits, _access_mode, _attr) \
956 .type = SIDE_TYPE_GATHER_FLOAT, \
962 .access_mode = _access_mode, \
965 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
966 .float_size_bits = _float_size_bits, \
967 .byte_order = _byte_order, \
975 #define side_type_gather_float(_offset, _float_size_bits, _access_mode, _attr) \
976 _side_type_gather_float(SIDE_TYPE_FLOAT_WORD_ORDER_HOST, _offset, _float_size_bits, _access_mode, _attr)
977 #define side_type_gather_float_le(_offset, _float_size_bits, _access_mode, _attr) \
978 _side_type_gather_float(SIDE_TYPE_BYTE_ORDER_LE, _offset, _float_size_bits, _access_mode, _attr)
979 #define side_type_gather_float_be(_offset, _float_size_bits, _access_mode, _attr) \
980 _side_type_gather_float(SIDE_TYPE_BYTE_ORDER_BE, _offset, _float_size_bits, _access_mode, _attr)
982 #define side_field_gather_float(_name, _offset, _float_size_bits, _access_mode, _attr) \
983 _side_field(_name, side_type_gather_float(_offset, _float_size_bits, _access_mode, _attr))
984 #define side_field_gather_float_le(_name, _offset, _float_size_bits, _access_mode, _attr) \
985 _side_field(_name, side_type_gather_float_le(_offset, _float_size_bits, _access_mode, _attr))
986 #define side_field_gather_float_be(_name, _offset, _float_size_bits, _access_mode, _attr) \
987 _side_field(_name, side_type_gather_float_be(_offset, _float_size_bits, _access_mode, _attr))
989 #define side_type_gather_struct(_struct_gather, _offset, _size, _access_mode) \
991 .type = SIDE_TYPE_GATHER_STRUCT, \
997 .access_mode = _access_mode, \
998 .type = _struct_gather, \
1005 #define side_field_gather_struct(_name, _struct_gather, _offset, _size, _access_mode) \
1006 _side_field(_name, side_type_gather_struct(SIDE_PARAM(_struct_gather), _offset, _size, _access_mode))
1008 #define side_type_gather_array(_elem_type_gather, _length, _offset, _access_mode, _attr) \
1010 .type = SIDE_TYPE_GATHER_ARRAY, \
1015 .offset = _offset, \
1016 .access_mode = _access_mode, \
1018 .elem_type = _elem_type_gather, \
1020 .length = _length, \
1021 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1028 #define side_field_gather_array(_name, _elem_type, _length, _offset, _access_mode, _attr) \
1029 _side_field(_name, side_type_gather_array(SIDE_PARAM(_elem_type), _length, _offset, _access_mode, SIDE_PARAM(_attr)))
1031 #define side_type_gather_vla(_elem_type_gather, _offset, _access_mode, _length_type_gather, _attr) \
1033 .type = SIDE_TYPE_GATHER_VLA, \
1038 .offset = _offset, \
1039 .access_mode = _access_mode, \
1041 .elem_type = _elem_type_gather, \
1043 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1045 .length_type = _length_type_gather, \
1051 #define side_field_gather_vla(_name, _elem_type_gather, _offset, _access_mode, _length_type_gather, _attr) \
1052 _side_field(_name, side_type_gather_vla(SIDE_PARAM(_elem_type_gather), _offset, _access_mode, SIDE_PARAM(_length_type_gather), SIDE_PARAM(_attr)))
1054 #define side_elem(...) \
1055 SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__)
1057 #define side_length(...) \
1058 SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__)
1060 #define side_field_list(...) \
1061 SIDE_COMPOUND_LITERAL(const struct side_event_field, __VA_ARGS__)
1063 /* Static field arguments */
1065 #define side_arg_null(_val) { .type = SIDE_TYPE_NULL }
1066 #define side_arg_bool(_val) { .type = SIDE_TYPE_BOOL, .u = { .side_static = { .bool_value = !!(_val) } } }
1067 #define side_arg_byte(_val) { .type = SIDE_TYPE_BYTE, .u = { .side_static = { .byte_value = (_val) } } }
1068 #define side_arg_string(_val) { .type = SIDE_TYPE_STRING, .u = { .side_static = { .string_value = (uintptr_t) (_val) } } }
1070 #define side_arg_u8(_val) { .type = SIDE_TYPE_U8, .u = { .side_static = { .integer_value = { .side_u8 = (_val) } } } }
1071 #define side_arg_u16(_val) { .type = SIDE_TYPE_U16, .u = { .side_static = { .integer_value = { .side_u16 = (_val) } } } }
1072 #define side_arg_u32(_val) { .type = SIDE_TYPE_U32, .u = { .side_static = { .integer_value = { .side_u32 = (_val) } } } }
1073 #define side_arg_u64(_val) { .type = SIDE_TYPE_U64, .u = { .side_static = { .integer_value = { .side_u64 = (_val) } } } }
1074 #define side_arg_s8(_val) { .type = SIDE_TYPE_S8, .u = { .side_static = { .integer_value = { .side_s8 = (_val) } } } }
1075 #define side_arg_s16(_val) { .type = SIDE_TYPE_S16, .u = { .side_static = { .integer_value = { .side_s16 = (_val) } } } }
1076 #define side_arg_s32(_val) { .type = SIDE_TYPE_S32, .u = { .side_static = { .integer_value = { .side_s32 = (_val) } } } }
1077 #define side_arg_s64(_val) { .type = SIDE_TYPE_S64, .u = { .side_static = { .integer_value = { .side_s64 = (_val) } } } }
1078 #define side_arg_pointer(_val) { .type = SIDE_TYPE_POINTER_HOST, .u = { .side_static = { .integer_value = { SIDE_PTR_HOST = (uintptr_t) (_val) } } } }
1079 #define side_arg_enum_bitmap8(_val) { .type = SIDE_TYPE_ENUM_BITMAP8, .u = { .side_static = { .integer_value = { .side_u8 = (_val) } } } }
1080 #define side_arg_enum_bitmap16(_val) { .type = SIDE_TYPE_ENUM_BITMAP16, .u = { .side_static = { .integer_value = { .side_u16 = (_val) } } } }
1081 #define side_arg_enum_bitmap32(_val) { .type = SIDE_TYPE_ENUM_BITMAP32, .u = { .side_static = { .integer_value = { .side_u32 = (_val) } } } }
1082 #define side_arg_enum_bitmap64(_val) { .type = SIDE_TYPE_ENUM_BITMAP64, .u = { .side_static = { .integer_value = { .side_u64 = (_val) } } } }
1083 #define side_arg_enum_bitmap_array(_side_type) { .type = SIDE_TYPE_ENUM_BITMAP_ARRAY, .u = { .side_static = { .side_array = (_side_type) } } }
1084 #define side_arg_enum_bitmap_vla(_side_type) { .type = SIDE_TYPE_ENUM_BITMAP_VLA, .u = { .side_static = { .side_vla = (_side_type) } } }
1085 #define side_arg_float_binary16(_val) { .type = SIDE_TYPE_FLOAT_BINARY16, .u = { .side_static = { .float_value = { .side_float_binary16 = (_val) } } } }
1086 #define side_arg_float_binary32(_val) { .type = SIDE_TYPE_FLOAT_BINARY32, .u = { .side_static = { .float_value = { .side_float_binary32 = (_val) } } } }
1087 #define side_arg_float_binary64(_val) { .type = SIDE_TYPE_FLOAT_BINARY64, .u = { .side_static = { .float_value = { .side_float_binary64 = (_val) } } } }
1088 #define side_arg_float_binary128(_val) { .type = SIDE_TYPE_FLOAT_BINARY128, .u = { .side_static = { .float_value = { .side_float_binary128 = (_val) } } } }
1090 #define side_arg_struct(_side_type) { .type = SIDE_TYPE_STRUCT, .u = { .side_static = { .side_struct = (_side_type) } } }
1091 #define side_arg_array(_side_type) { .type = SIDE_TYPE_ARRAY, .u = { .side_static = { .side_array = (_side_type) } } }
1092 #define side_arg_vla(_side_type) { .type = SIDE_TYPE_VLA, .u = { .side_static = { .side_vla = (_side_type) } } }
1093 #define side_arg_vla_visitor(_ctx) { .type = SIDE_TYPE_VLA_VISITOR, .u = { .side_static = { .side_vla_app_visitor_ctx = (_ctx) } } }
1095 #define side_arg_array_u8(_ptr) { .type = SIDE_TYPE_ARRAY_U8, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1096 #define side_arg_array_u16(_ptr) { .type = SIDE_TYPE_ARRAY_U16, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1097 #define side_arg_array_u32(_ptr) { .type = SIDE_TYPE_ARRAY_U32, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1098 #define side_arg_array_u64(_ptr) { .type = SIDE_TYPE_ARRAY_U64, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1099 #define side_arg_array_s8(_ptr) { .type = SIDE_TYPE_ARRAY_S8, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1100 #define side_arg_array_s16(_ptr) { .type = SIDE_TYPE_ARRAY_S16, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1101 #define side_arg_array_s32(_ptr) { .type = SIDE_TYPE_ARRAY_S32, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1102 #define side_arg_array_s64(_ptr) { .type = SIDE_TYPE_ARRAY_S64, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1103 #define side_arg_array_byte(_ptr) { .type = SIDE_TYPE_ARRAY_BYTE, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1104 #define side_arg_array_pointer(_ptr) { .type = SIDE_TYPE_ARRAY_POINTER_HOST, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1106 #define side_arg_vla_u8(_ptr, _length) { .type = SIDE_TYPE_VLA_U8, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
1107 #define side_arg_vla_u16(_ptr, _length) { .type = SIDE_TYPE_VLA_U16, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1108 #define side_arg_vla_u32(_ptr, _length) { .type = SIDE_TYPE_VLA_U32, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1109 #define side_arg_vla_u64(_ptr, _length) { .type = SIDE_TYPE_VLA_U64, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1110 #define side_arg_vla_s8(_ptr, _length) { .type = SIDE_TYPE_VLA_S8, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1111 #define side_arg_vla_s16(_ptr, _length) { .type = SIDE_TYPE_VLA_S16, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1112 #define side_arg_vla_s32(_ptr, _length) { .type = SIDE_TYPE_VLA_S32, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1113 #define side_arg_vla_s64(_ptr, _length) { .type = SIDE_TYPE_VLA_S64, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1114 #define side_arg_vla_byte(_ptr, _length) { .type = SIDE_TYPE_VLA_BYTE, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1115 #define side_arg_vla_pointer(_ptr, _length) { .type = SIDE_TYPE_VLA_POINTER_HOST, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1117 /* Gather field arguments */
1118 #define side_arg_gather_unsigned_integer(_ptr) { .type = SIDE_TYPE_GATHER_UNSIGNED_INT, .u = { .side_static = { .side_integer_gather_ptr = (_ptr) } } }
1119 #define side_arg_gather_signed_integer(_ptr) { .type = SIDE_TYPE_GATHER_SIGNED_INT, .u = { .side_static = { .side_integer_gather_ptr = (_ptr) } } }
1120 #define side_arg_gather_float(_ptr) { .type = SIDE_TYPE_GATHER_FLOAT, .u = { .side_static = { .side_float_gather_ptr = (_ptr) } } }
1121 #define side_arg_gather_struct(_ptr) { .type = SIDE_TYPE_GATHER_STRUCT, .u = { .side_static = { .side_struct_gather_ptr = (_ptr) } } }
1122 #define side_arg_gather_array(_ptr) { .type = SIDE_TYPE_GATHER_ARRAY, .u = { .side_static = { .side_array_gather_ptr = (_ptr) } } }
1123 #define side_arg_gather_vla(_ptr, _length_ptr) { .type = SIDE_TYPE_GATHER_VLA, .u = { .side_static = { .side_vla_gather = { .ptr = (_ptr), .length_ptr = (_length_ptr) } } } }
1125 /* Dynamic field arguments */
1127 #define side_arg_dynamic_null(_attr) \
1129 .type = SIDE_TYPE_DYNAMIC_NULL, \
1134 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1140 #define side_arg_dynamic_bool(_val, _attr) \
1142 .type = SIDE_TYPE_DYNAMIC_BOOL, \
1148 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1150 .value = !!(_val), \
1156 #define side_arg_dynamic_byte(_val, _attr) \
1158 .type = SIDE_TYPE_DYNAMIC_BYTE, \
1164 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1171 #define side_arg_dynamic_string(_val, _attr) \
1173 .type = SIDE_TYPE_DYNAMIC_STRING, \
1179 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1181 .value = (uintptr_t) (_val), \
1187 #define _side_arg_dynamic_integer(_field, _val, _type, _signedness, _byte_order, _integer_size_bits, _len_bits, _attr) \
1195 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1196 .integer_size_bits = _integer_size_bits, \
1197 .len_bits = _len_bits, \
1198 .signedness = _signedness, \
1199 .byte_order = _byte_order, \
1209 #define side_arg_dynamic_u8(_val, _attr) \
1210 _side_arg_dynamic_integer(.side_u8, _val, SIDE_TYPE_DYNAMIC_U8, false, SIDE_TYPE_BYTE_ORDER_HOST, 8, 8, SIDE_PARAM(_attr))
1211 #define side_arg_dynamic_s8(_val, _attr) \
1212 _side_arg_dynamic_integer(.side_s8, _val, SIDE_TYPE_DYNAMIC_S8, true, SIDE_TYPE_BYTE_ORDER_HOST, 8, 8, SIDE_PARAM(_attr))
1214 #define _side_arg_dynamic_u16(_val, _byte_order, _attr) \
1215 _side_arg_dynamic_integer(.side_u16, _val, SIDE_TYPE_DYNAMIC_U16, false, _byte_order, 16, 16, SIDE_PARAM(_attr))
1216 #define _side_arg_dynamic_u32(_val, _byte_order, _attr) \
1217 _side_arg_dynamic_integer(.side_u32, _val, SIDE_TYPE_DYNAMIC_U32, false, _byte_order, 32, 32, SIDE_PARAM(_attr))
1218 #define _side_arg_dynamic_u64(_val, _byte_order, _attr) \
1219 _side_arg_dynamic_integer(.side_u64, _val, SIDE_TYPE_DYNAMIC_U64, false, _byte_order, 64, 64, SIDE_PARAM(_attr))
1221 #define _side_arg_dynamic_s16(_val, _byte_order, _attr) \
1222 _side_arg_dynamic_integer(.side_s16, _val, SIDE_TYPE_DYNAMIC_S16, true, _byte_order, 16, 16, SIDE_PARAM(_attr))
1223 #define _side_arg_dynamic_s32(_val, _byte_order, _attr) \
1224 _side_arg_dynamic_integer(.side_s32, _val, SIDE_TYPE_DYNAMIC_S32, true, _byte_order, 32, 32, SIDE_PARAM(_attr))
1225 #define _side_arg_dynamic_s64(_val, _byte_order, _attr) \
1226 _side_arg_dynamic_integer(.side_s64, _val, SIDE_TYPE_DYNAMIC_S64, true, _byte_order, 64, 64, SIDE_PARAM(_attr))
1228 #define _side_arg_dynamic_pointer(_val, _byte_order, _attr) \
1229 _side_arg_dynamic_integer(SIDE_PTR_HOST, (uintptr_t) (_val), SIDE_TYPE_DYNAMIC_POINTER_HOST, false, _byte_order, \
1230 SIDE_BITS_PER_LONG, SIDE_BITS_PER_LONG, SIDE_PARAM(_attr))
1232 #define _side_arg_dynamic_float(_field, _val, _type, _byte_order, _float_size_bits, _attr) \
1240 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1241 .float_size_bits = _float_size_bits, \
1242 .byte_order = _byte_order, \
1252 #define _side_arg_dynamic_float_binary16(_val, _byte_order, _attr) \
1253 _side_arg_dynamic_float(.side_float_binary16, _val, SIDE_TYPE_DYNAMIC_FLOAT_BINARY16, _byte_order, 16, SIDE_PARAM(_attr))
1254 #define _side_arg_dynamic_float_binary32(_val, _byte_order, _attr) \
1255 _side_arg_dynamic_float(.side_float_binary32, _val, SIDE_TYPE_DYNAMIC_FLOAT_BINARY32, _byte_order, 32, SIDE_PARAM(_attr))
1256 #define _side_arg_dynamic_float_binary64(_val, _byte_order, _attr) \
1257 _side_arg_dynamic_float(.side_float_binary64, _val, SIDE_TYPE_DYNAMIC_FLOAT_BINARY64, _byte_order, 64, SIDE_PARAM(_attr))
1258 #define _side_arg_dynamic_float_binary128(_val, _byte_order, _attr) \
1259 _side_arg_dynamic_float(.side_float_binary128, _val, SIDE_TYPE_DYNAMIC_FLOAT_BINARY128, _byte_order, 128, SIDE_PARAM(_attr))
1262 #define side_arg_dynamic_u16(_val, _attr) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr))
1263 #define side_arg_dynamic_u32(_val, _attr) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr))
1264 #define side_arg_dynamic_u64(_val, _attr) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr))
1265 #define side_arg_dynamic_s16(_val, _attr) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr))
1266 #define side_arg_dynamic_s32(_val, _attr) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr))
1267 #define side_arg_dynamic_s64(_val, _attr) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr))
1268 #define side_arg_dynamic_pointer(_val, _attr) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr))
1269 #define side_arg_dynamic_float_binary16(_val, _attr) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM(_attr))
1270 #define side_arg_dynamic_float_binary32(_val, _attr) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM(_attr))
1271 #define side_arg_dynamic_float_binary64(_val, _attr) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM(_attr))
1272 #define side_arg_dynamic_float_binary128(_val, _attr) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM(_attr))
1275 #define side_arg_dynamic_u16_le(_val, _attr) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1276 #define side_arg_dynamic_u32_le(_val, _attr) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1277 #define side_arg_dynamic_u64_le(_val, _attr) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1278 #define side_arg_dynamic_s16_le(_val, _attr) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1279 #define side_arg_dynamic_s32_le(_val, _attr) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1280 #define side_arg_dynamic_s64_le(_val, _attr) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1281 #define side_arg_dynamic_pointer_le(_val, _attr) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1282 #define side_arg_dynamic_float_binary16_le(_val, _attr) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1283 #define side_arg_dynamic_float_binary32_le(_val, _attr) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1284 #define side_arg_dynamic_float_binary64_le(_val, _attr) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1285 #define side_arg_dynamic_float_binary128_le(_val, _attr) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1288 #define side_arg_dynamic_u16_be(_val, _attr) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1289 #define side_arg_dynamic_u32_be(_val, _attr) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1290 #define side_arg_dynamic_u64_be(_val, _attr) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1291 #define side_arg_dynamic_s16_be(_val, _attr) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1292 #define side_arg_dynamic_s32_be(_val, _attr) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1293 #define side_arg_dynamic_s64_be(_val, _attr) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1294 #define side_arg_dynamic_pointer_be(_val, _attr) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1295 #define side_arg_dynamic_float_binary16_be(_val, _attr) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1296 #define side_arg_dynamic_float_binary32_be(_val, _attr) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1297 #define side_arg_dynamic_float_binary64_be(_val, _attr) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1298 #define side_arg_dynamic_float_binary128_be(_val, _attr) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1300 #define side_arg_dynamic_vla(_vla) \
1302 .type = SIDE_TYPE_DYNAMIC_VLA, \
1305 .side_dynamic_vla = (_vla), \
1310 #define side_arg_dynamic_vla_visitor(_dynamic_vla_visitor, _ctx, _attr) \
1312 .type = SIDE_TYPE_DYNAMIC_VLA_VISITOR, \
1315 .side_dynamic_vla_visitor = { \
1317 .visitor = _dynamic_vla_visitor, \
1319 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1325 #define side_arg_dynamic_struct(_struct) \
1327 .type = SIDE_TYPE_DYNAMIC_STRUCT, \
1330 .side_dynamic_struct = (_struct), \
1335 #define side_arg_dynamic_struct_visitor(_dynamic_struct_visitor, _ctx, _attr) \
1337 .type = SIDE_TYPE_DYNAMIC_STRUCT_VISITOR, \
1340 .side_dynamic_struct_visitor = { \
1342 .visitor = _dynamic_struct_visitor, \
1344 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1350 #define side_arg_dynamic_define_vec(_identifier, _sav, _attr) \
1351 const struct side_arg _identifier##_vec[] = { _sav }; \
1352 const struct side_arg_dynamic_vla _identifier = { \
1353 .sav = _identifier##_vec, \
1355 .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
1356 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1359 #define side_arg_dynamic_define_struct(_identifier, _struct_fields, _attr) \
1360 const struct side_arg_dynamic_field _identifier##_fields[] = { _struct_fields }; \
1361 const struct side_arg_dynamic_struct _identifier = { \
1362 .fields = _identifier##_fields, \
1364 .len = SIDE_ARRAY_SIZE(_identifier##_fields), \
1365 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1368 #define side_arg_define_vec(_identifier, _sav) \
1369 const struct side_arg _identifier##_vec[] = { _sav }; \
1370 const struct side_arg_vec _identifier = { \
1371 .sav = _identifier##_vec, \
1372 .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
1375 #define side_arg_dynamic_field(_name, _elem) \
1377 .field_name = _name, \
1381 #define side_arg_list(...) __VA_ARGS__
1383 #define side_define_enum(_identifier, _mappings, _attr) \
1384 const struct side_enum_mappings _identifier = { \
1385 .mappings = _mappings, \
1387 .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \
1388 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1391 #define side_enum_mapping_list(...) \
1392 SIDE_COMPOUND_LITERAL(const struct side_enum_mapping, __VA_ARGS__)
1394 #define side_enum_mapping_range(_label, _begin, _end) \
1396 .range_begin = _begin, \
1397 .range_end = _end, \
1401 #define side_enum_mapping_value(_label, _value) \
1403 .range_begin = _value, \
1404 .range_end = _value, \
1408 #define side_define_enum_bitmap(_identifier, _mappings, _attr) \
1409 const struct side_enum_bitmap_mappings _identifier = { \
1410 .mappings = _mappings, \
1412 .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \
1413 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1416 #define side_enum_bitmap_mapping_list(...) \
1417 SIDE_COMPOUND_LITERAL(const struct side_enum_bitmap_mapping, __VA_ARGS__)
1419 #define side_enum_bitmap_mapping_range(_label, _begin, _end) \
1421 .range_begin = _begin, \
1422 .range_end = _end, \
1426 #define side_enum_bitmap_mapping_value(_label, _value) \
1428 .range_begin = _value, \
1429 .range_end = _value, \
1433 #define side_event_cond(_identifier) \
1434 if (side_unlikely(__atomic_load_n(&side_event_enable__##_identifier, \
1437 #define side_event_call(_identifier, _sav) \
1439 const struct side_arg side_sav[] = { _sav }; \
1440 const struct side_arg_vec side_arg_vec = { \
1442 .len = SIDE_ARRAY_SIZE(side_sav), \
1444 side_call(&(_identifier), &side_arg_vec); \
1447 #define side_event(_identifier, _sav) \
1448 side_event_cond(_identifier) \
1449 side_event_call(_identifier, SIDE_PARAM(_sav))
1451 #define side_event_call_variadic(_identifier, _sav, _var_fields, _attr) \
1453 const struct side_arg side_sav[] = { _sav }; \
1454 const struct side_arg_vec side_arg_vec = { \
1456 .len = SIDE_ARRAY_SIZE(side_sav), \
1458 const struct side_arg_dynamic_field side_fields[] = { _var_fields }; \
1459 const struct side_arg_dynamic_struct var_struct = { \
1460 .fields = side_fields, \
1462 .len = SIDE_ARRAY_SIZE(side_fields), \
1463 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1465 side_call_variadic(&(_identifier), &side_arg_vec, &var_struct); \
1468 #define side_event_variadic(_identifier, _sav, _var, _attr) \
1469 side_event_cond(_identifier) \
1470 side_event_call_variadic(_identifier, SIDE_PARAM(_sav), SIDE_PARAM(_var), SIDE_PARAM(_attr))
1472 #define _side_define_event(_linkage, _identifier, _provider, _event, _loglevel, _fields, _attr, _flags) \
1473 _linkage uintptr_t side_event_enable__##_identifier __attribute__((section("side_event_enable"))); \
1474 _linkage struct side_event_description __attribute__((section("side_event_description"))) \
1476 .enabled = &(side_event_enable__##_identifier), \
1477 .provider_name = _provider, \
1478 .event_name = _event, \
1479 .fields = _fields, \
1481 .callbacks = &side_empty_callback, \
1482 .flags = (_flags), \
1484 .loglevel = _loglevel, \
1485 .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
1486 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1487 .nr_callbacks = 0, \
1489 static const struct side_event_description *side_event_ptr__##_identifier \
1490 __attribute__((section("side_event_description_ptr"), used)) = &(_identifier);
1492 #define side_static_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \
1493 _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
1494 SIDE_PARAM(_attr), 0)
1496 #define side_static_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \
1497 _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
1498 SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC)
1500 #define side_hidden_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \
1501 _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \
1502 _loglevel, SIDE_PARAM(_fields), SIDE_PARAM(_attr), 0)
1504 #define side_hidden_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \
1505 _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \
1506 _loglevel, SIDE_PARAM(_fields), SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC)
1508 #define side_export_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \
1509 _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \
1510 _loglevel, SIDE_PARAM(_fields), SIDE_PARAM(_attr), 0)
1512 #define side_export_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \
1513 _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \
1514 _loglevel, SIDE_PARAM(_fields), SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC)
1516 #define side_declare_event(_identifier) \
1517 extern uintptr_t side_event_enable_##_identifier; \
1518 extern struct side_event_description _identifier
1520 extern const struct side_callback side_empty_callback
;
1522 void side_call(const struct side_event_description
*desc
,
1523 const struct side_arg_vec
*side_arg_vec
);
1524 void side_call_variadic(const struct side_event_description
*desc
,
1525 const struct side_arg_vec
*side_arg_vec
,
1526 const struct side_arg_dynamic_struct
*var_struct
);
1528 typedef void (*side_tracer_callback_func
)(const struct side_event_description
*desc
,
1529 const struct side_arg_vec
*side_arg_vec
,
1531 typedef void (*side_tracer_callback_variadic_func
)(const struct side_event_description
*desc
,
1532 const struct side_arg_vec
*side_arg_vec
,
1533 const struct side_arg_dynamic_struct
*var_struct
,
1536 int side_tracer_callback_register(struct side_event_description
*desc
,
1537 side_tracer_callback_func call
,
1539 int side_tracer_callback_variadic_register(struct side_event_description
*desc
,
1540 side_tracer_callback_variadic_func call_variadic
,
1542 int side_tracer_callback_unregister(struct side_event_description
*desc
,
1543 side_tracer_callback_func call
,
1545 int side_tracer_callback_variadic_unregister(struct side_event_description
*desc
,
1546 side_tracer_callback_variadic_func call_variadic
,
1549 struct side_events_register_handle
*side_events_register(struct side_event_description
**events
,
1550 uint32_t nr_events
);
1551 void side_events_unregister(struct side_events_register_handle
*handle
);
1553 enum side_tracer_notification
{
1554 SIDE_TRACER_NOTIFICATION_INSERT_EVENTS
,
1555 SIDE_TRACER_NOTIFICATION_REMOVE_EVENTS
,
1558 /* Callback is invoked with side library internal lock held. */
1559 struct side_tracer_handle
*side_tracer_event_notification_register(
1560 void (*cb
)(enum side_tracer_notification notif
,
1561 struct side_event_description
**events
, uint32_t nr_events
, void *priv
),
1563 void side_tracer_event_notification_unregister(struct side_tracer_handle
*handle
);
1565 void side_init(void);
1566 void side_exit(void);
1569 * These weak symbols, the constructor, and destructor take care of
1570 * registering only _one_ instance of the side instrumentation per
1571 * shared-ojbect (or for the whole main program).
1573 extern struct side_event_description
* __start_side_event_description_ptr
[]
1574 __attribute__((weak
, visibility("hidden")));
1575 extern struct side_event_description
* __stop_side_event_description_ptr
[]
1576 __attribute__((weak
, visibility("hidden")));
1577 int side_event_description_ptr_registered
1578 __attribute__((weak
, visibility("hidden")));
1579 struct side_events_register_handle
*side_events_handle
1580 __attribute__((weak
, visibility("hidden")));
1583 side_event_description_ptr_init(void)
1584 __attribute__((no_instrument_function
))
1585 __attribute__((constructor
));
1587 side_event_description_ptr_init(void)
1589 if (side_event_description_ptr_registered
++)
1591 side_events_handle
= side_events_register(__start_side_event_description_ptr
,
1592 __stop_side_event_description_ptr
- __start_side_event_description_ptr
);
1596 side_event_description_ptr_exit(void)
1597 __attribute__((no_instrument_function
))
1598 __attribute__((destructor
));
1600 side_event_description_ptr_exit(void)
1602 if (--side_event_description_ptr_registered
)
1604 side_events_unregister(side_events_handle
);
1605 side_events_handle
= NULL
;
1608 #endif /* _SIDE_TRACE_H */