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_vla
;
28 struct side_event_field
;
29 struct side_tracer_visitor_ctx
;
30 struct side_tracer_dynamic_struct_visitor_ctx
;
31 struct side_tracer_dynamic_vla_visitor_ctx
;
32 struct side_event_description
;
33 struct side_arg_dynamic_event_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
,
93 /* Scatter-gather types */
94 SIDE_TYPE_SG_UNSIGNED_INT
,
95 SIDE_TYPE_SG_SIGNED_INT
,
100 SIDE_TYPE_DYNAMIC_NULL
,
101 SIDE_TYPE_DYNAMIC_BOOL
,
102 SIDE_TYPE_DYNAMIC_U8
,
103 SIDE_TYPE_DYNAMIC_U16
,
104 SIDE_TYPE_DYNAMIC_U32
,
105 SIDE_TYPE_DYNAMIC_U64
,
106 SIDE_TYPE_DYNAMIC_S8
,
107 SIDE_TYPE_DYNAMIC_S16
,
108 SIDE_TYPE_DYNAMIC_S32
,
109 SIDE_TYPE_DYNAMIC_S64
,
110 SIDE_TYPE_DYNAMIC_BYTE
,
111 SIDE_TYPE_DYNAMIC_POINTER32
,
112 SIDE_TYPE_DYNAMIC_POINTER64
,
113 SIDE_TYPE_DYNAMIC_FLOAT_BINARY16
,
114 SIDE_TYPE_DYNAMIC_FLOAT_BINARY32
,
115 SIDE_TYPE_DYNAMIC_FLOAT_BINARY64
,
116 SIDE_TYPE_DYNAMIC_FLOAT_BINARY128
,
117 SIDE_TYPE_DYNAMIC_STRING
,
119 /* Dynamic compound types */
120 SIDE_TYPE_DYNAMIC_STRUCT
,
121 SIDE_TYPE_DYNAMIC_STRUCT_VISITOR
,
122 SIDE_TYPE_DYNAMIC_VLA
,
123 SIDE_TYPE_DYNAMIC_VLA_VISITOR
,
126 enum side_attr_type
{
137 SIDE_ATTR_TYPE_POINTER32
,
138 SIDE_ATTR_TYPE_POINTER64
,
139 SIDE_ATTR_TYPE_FLOAT_BINARY16
,
140 SIDE_ATTR_TYPE_FLOAT_BINARY32
,
141 SIDE_ATTR_TYPE_FLOAT_BINARY64
,
142 SIDE_ATTR_TYPE_FLOAT_BINARY128
,
143 SIDE_ATTR_TYPE_STRING
,
147 SIDE_LOGLEVEL_EMERG
= 0,
148 SIDE_LOGLEVEL_ALERT
= 1,
149 SIDE_LOGLEVEL_CRIT
= 2,
150 SIDE_LOGLEVEL_ERR
= 3,
151 SIDE_LOGLEVEL_WARNING
= 4,
152 SIDE_LOGLEVEL_NOTICE
= 5,
153 SIDE_LOGLEVEL_INFO
= 6,
154 SIDE_LOGLEVEL_DEBUG
= 7,
157 enum side_visitor_status
{
158 SIDE_VISITOR_STATUS_OK
= 0,
159 SIDE_VISITOR_STATUS_ERROR
= -1,
164 SIDE_ERROR_INVAL
= 1,
165 SIDE_ERROR_EXIST
= 2,
166 SIDE_ERROR_NOMEM
= 3,
167 SIDE_ERROR_NOENT
= 4,
168 SIDE_ERROR_EXITING
= 5,
171 enum side_type_label_byte_order
{
172 SIDE_TYPE_BYTE_ORDER_LE
= 0,
173 SIDE_TYPE_BYTE_ORDER_BE
= 1,
176 #if (SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN)
177 # define SIDE_TYPE_BYTE_ORDER_HOST SIDE_TYPE_BYTE_ORDER_LE
179 # define SIDE_TYPE_BYTE_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE
182 #if (SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN)
183 # define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_LE
185 # define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE
188 typedef enum side_visitor_status (*side_visitor
)(
189 const struct side_tracer_visitor_ctx
*tracer_ctx
,
191 typedef enum side_visitor_status (*side_dynamic_struct_visitor
)(
192 const struct side_tracer_dynamic_struct_visitor_ctx
*tracer_ctx
,
194 typedef enum side_visitor_status (*side_dynamic_vla_visitor
)(
195 const struct side_tracer_dynamic_vla_visitor_ctx
*tracer_ctx
,
198 union side_integer_value
{
209 union side_float_value
{
211 _Float16 side_float_binary16
;
214 _Float32 side_float_binary32
;
217 _Float64 side_float_binary64
;
220 _Float128 side_float_binary128
;
224 struct side_attr_value
{
225 uint32_t type
; /* enum side_attr_type */
228 uint64_t string_value
; /* const char * */
229 union side_integer_value integer_value
;
230 union side_float_value float_value
;
234 /* User attributes. */
237 const struct side_attr_value value
;
240 /* Type descriptions */
241 struct side_type_null
{
242 const struct side_attr
*attr
;
246 struct side_type_bool
{
247 const struct side_attr
*attr
;
251 struct side_type_byte
{
252 const struct side_attr
*attr
;
256 struct side_type_string
{
257 const struct side_attr
*attr
;
261 struct side_type_integer
{
262 const struct side_attr
*attr
;
264 uint16_t integer_size_bits
; /* bits */
265 uint16_t len_bits
; /* bits */
266 uint8_t signedness
; /* true/false */
267 uint8_t byte_order
; /* enum side_type_label_byte_order */
270 struct side_type_float
{
271 const struct side_attr
*attr
;
273 uint32_t byte_order
; /* enum side_type_label_byte_order */
274 uint16_t float_size_bits
; /* bits */
277 struct side_enum_mapping
{
283 struct side_enum_mappings
{
284 const struct side_enum_mapping
*mappings
;
285 const struct side_attr
*attr
;
286 uint32_t nr_mappings
;
290 struct side_enum_bitmap_mapping
{
291 uint64_t range_begin
;
296 struct side_enum_bitmap_mappings
{
297 const struct side_enum_bitmap_mapping
*mappings
;
298 const struct side_attr
*attr
;
299 uint32_t nr_mappings
;
303 struct side_type_struct
{
306 const struct side_event_field
*fields
;
307 const struct side_attr
*attr
;
310 struct side_type_array
{
311 const struct side_type
*elem_type
;
312 const struct side_attr
*attr
;
317 struct side_type_vla
{
318 const struct side_type
*elem_type
;
319 const struct side_attr
*attr
;
323 struct side_type_vla_visitor
{
324 side_visitor visitor
;
325 const struct side_type
*elem_type
;
326 const struct side_attr
*attr
;
330 struct side_type_enum
{
331 const struct side_enum_mappings
*mappings
;
332 const struct side_type
*elem_type
;
335 struct side_type_enum_bitmap
{
336 const struct side_enum_bitmap_mappings
*mappings
;
337 const struct side_type
*elem_type
;
340 struct side_type_sg
{
341 uint64_t offset
; /* bytes */
344 struct side_type_integer type
;
345 uint16_t offset_bits
; /* bits */
346 } SIDE_PACKED side_integer
;
347 struct side_type_float side_float
;
348 const struct side_type_struct
*side_struct
;
352 /* Statically defined types. */
354 uint32_t type
; /* enum side_type_label */
357 struct side_type_null side_null
;
358 struct side_type_bool side_bool
;
359 struct side_type_byte side_byte
;
360 struct side_type_string side_string
;
361 struct side_type_integer side_integer
;
362 struct side_type_float side_float
;
365 struct side_type_array side_array
;
366 struct side_type_vla side_vla
;
367 struct side_type_vla_visitor side_vla_visitor
;
368 const struct side_type_struct
*side_struct
;
370 /* Enumeration types */
371 struct side_type_enum side_enum
;
372 struct side_type_enum_bitmap side_enum_bitmap
;
374 /* Scatter-gather types */
375 struct side_type_sg side_sg
;
379 struct side_event_field
{
380 const char *field_name
;
381 struct side_type side_type
;
384 enum side_event_flags
{
385 SIDE_EVENT_FLAG_VARIADIC
= (1 << 0),
388 struct side_callback
{
390 void (*call
)(const struct side_event_description
*desc
,
391 const struct side_arg_vec
*side_arg_vec
,
393 void (*call_variadic
)(const struct side_event_description
*desc
,
394 const struct side_arg_vec
*side_arg_vec
,
395 const struct side_arg_dynamic_event_struct
*var_struct
,
401 struct side_arg_static
{
405 uint64_t string_value
; /* const char * */
406 union side_integer_value integer_value
;
407 union side_float_value float_value
;
410 const struct side_arg_vec
*side_struct
;
411 const struct side_arg_vec
*side_array
;
412 const struct side_arg_vec
*side_vla
;
413 void *side_vla_app_visitor_ctx
;
414 void *side_array_fixint
;
418 } SIDE_PACKED side_vla_fixint
;
421 void *side_integer_sg_ptr
;
422 void *side_float_sg_ptr
;
423 void *side_struct_sg_ptr
;
426 struct side_arg_dynamic
{
428 struct side_type_null side_null
;
430 struct side_type_bool type
;
432 } SIDE_PACKED side_bool
;
435 struct side_type_byte type
;
437 } SIDE_PACKED side_byte
;
440 struct side_type_string type
;
441 uint64_t value
; /* const char * */
442 } SIDE_PACKED side_string
;
446 struct side_type_integer type
;
447 union side_integer_value value
;
448 } SIDE_PACKED side_integer
;
451 struct side_type_float type
;
452 union side_float_value value
;
453 } SIDE_PACKED side_float
;
456 const struct side_arg_dynamic_event_struct
*side_dynamic_struct
;
459 side_dynamic_struct_visitor visitor
;
460 const struct side_attr
*attr
;
462 } SIDE_PACKED side_dynamic_struct_visitor
;
463 const struct side_arg_dynamic_vla
*side_dynamic_vla
;
466 side_dynamic_vla_visitor visitor
;
467 const struct side_attr
*attr
;
469 } SIDE_PACKED side_dynamic_vla_visitor
;
473 enum side_type_label type
;
475 struct side_arg_static side_static
;
476 struct side_arg_dynamic side_dynamic
;
480 struct side_arg_vec
{
481 const struct side_arg
*sav
;
485 struct side_event_description
{
487 const char *provider_name
;
488 const char *event_name
;
489 const struct side_event_field
*fields
;
490 const struct side_attr
*attr
;
491 const struct side_callback
*callbacks
;
494 uint32_t loglevel
; /* enum side_loglevel */
497 uint32_t nr_callbacks
;
500 struct side_arg_dynamic_vla
{
501 const struct side_arg
*sav
;
502 const struct side_attr
*attr
;
507 struct side_arg_dynamic_event_field
{
508 const char *field_name
;
509 const struct side_arg elem
;
512 struct side_arg_dynamic_event_struct
{
513 const struct side_arg_dynamic_event_field
*fields
;
514 const struct side_attr
*attr
;
519 /* The visitor pattern is a double-dispatch visitor. */
520 struct side_tracer_visitor_ctx
{
521 enum side_visitor_status (*write_elem
)(
522 const struct side_tracer_visitor_ctx
*tracer_ctx
,
523 const struct side_arg
*elem
);
524 void *priv
; /* Private tracer context. */
527 struct side_tracer_dynamic_struct_visitor_ctx
{
528 enum side_visitor_status (*write_field
)(
529 const struct side_tracer_dynamic_struct_visitor_ctx
*tracer_ctx
,
530 const struct side_arg_dynamic_event_field
*dynamic_field
);
531 void *priv
; /* Private tracer context. */
534 struct side_tracer_dynamic_vla_visitor_ctx
{
535 enum side_visitor_status (*write_elem
)(
536 const struct side_tracer_dynamic_vla_visitor_ctx
*tracer_ctx
,
537 const struct side_arg
*elem
);
538 void *priv
; /* Private tracer context. */
541 /* Event and type attributes */
543 #if SIDE_BITS_PER_LONG == 64
544 # define SIDE_TYPE_POINTER_HOST SIDE_TYPE_POINTER64
545 # define SIDE_TYPE_ARRAY_POINTER_HOST SIDE_TYPE_ARRAY_POINTER64
546 # define SIDE_TYPE_VLA_POINTER_HOST SIDE_TYPE_VLA_POINTER64
547 # define SIDE_TYPE_DYNAMIC_POINTER_HOST SIDE_TYPE_DYNAMIC_POINTER64
548 # define SIDE_ATTR_TYPE_POINTER_HOST SIDE_ATTR_TYPE_POINTER64
549 # define SIDE_PTR_HOST .side_u64
551 # define SIDE_TYPE_POINTER_HOST SIDE_TYPE_POINTER32
552 # define SIDE_TYPE_ARRAY_POINTER_HOST SIDE_TYPE_ARRAY_POINTER32
553 # define SIDE_TYPE_VLA_POINTER_HOST SIDE_TYPE_VLA_POINTER32
554 # define SIDE_TYPE_DYNAMIC_POINTER_HOST SIDE_TYPE_DYNAMIC_POINTER32
555 # define SIDE_ATTR_TYPE_POINTER_HOST SIDE_ATTR_TYPE_POINTER32
556 # define SIDE_PTR_HOST .side_u32
559 #define side_attr(_key, _value) \
562 .value = SIDE_PARAM(_value), \
565 #define side_attr_list(...) \
566 SIDE_COMPOUND_LITERAL(const struct side_attr, __VA_ARGS__)
568 #define side_attr_null(_val) { .type = SIDE_ATTR_TYPE_NULL }
569 #define side_attr_bool(_val) { .type = SIDE_ATTR_TYPE_BOOL, .u = { .bool_value = !!(_val) } }
570 #define side_attr_u8(_val) { .type = SIDE_ATTR_TYPE_U8, .u = { .integer_value = { .side_u8 = (_val) } } }
571 #define side_attr_u16(_val) { .type = SIDE_ATTR_TYPE_U16, .u = { .integer_value = { .side_u16 = (_val) } } }
572 #define side_attr_u32(_val) { .type = SIDE_ATTR_TYPE_U32, .u = { .integer_value = { .side_u32 = (_val) } } }
573 #define side_attr_u64(_val) { .type = SIDE_ATTR_TYPE_U64, .u = { .integer_value = { .side_u64 = (_val) } } }
574 #define side_attr_s8(_val) { .type = SIDE_ATTR_TYPE_S8, .u = { .integer_value = { .side_s8 = (_val) } } }
575 #define side_attr_s16(_val) { .type = SIDE_ATTR_TYPE_S16, .u = { .integer_value = { .side_s16 = (_val) } } }
576 #define side_attr_s32(_val) { .type = SIDE_ATTR_TYPE_S32, .u = { .integer_value = { .side_s32 = (_val) } } }
577 #define side_attr_s64(_val) { .type = SIDE_ATTR_TYPE_S64, .u = { .integer_value = { .side_s64 = (_val) } } }
578 #define side_attr_pointer(_val) { .type = SIDE_ATTR_TYPE_POINTER_HOST, .u = { .integer_value = { SIDE_PTR_HOST = (uintptr_t) (_val) } } }
579 #define side_attr_float_binary16(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY16, .u = { .float_value = { .side_float_binary16 = (_val) } } }
580 #define side_attr_float_binary32(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY32, .u = { .float_value = { .side_float_binary32 = (_val) } } }
581 #define side_attr_float_binary64(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY64, .u = { .float_value = { .side_float_binary64 = (_val) } } }
582 #define side_attr_float_binary128(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY128, .u = { .float_value = { .side_float_binary128 = (_val) } } }
583 #define side_attr_string(_val) { .type = SIDE_ATTR_TYPE_STRING, .u = { .string_value = (uintptr_t) (_val) } }
585 /* Static field definition */
587 #define side_type_null(_attr) \
589 .type = SIDE_TYPE_NULL, \
593 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
598 #define side_type_bool(_attr) \
600 .type = SIDE_TYPE_BOOL, \
604 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
609 #define side_type_byte(_attr) \
611 .type = SIDE_TYPE_BYTE, \
615 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
620 #define side_type_string(_attr) \
622 .type = SIDE_TYPE_STRING, \
626 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
631 #define side_type_dynamic() \
633 .type = SIDE_TYPE_DYNAMIC, \
636 #define _side_type_integer(_type, _signedness, _byte_order, _integer_size_bits, _len_bits, _attr) \
642 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
643 .integer_size_bits = _integer_size_bits, \
644 .len_bits = _len_bits, \
645 .signedness = _signedness, \
646 .byte_order = _byte_order, \
651 #define _side_type_float(_type, _byte_order, _float_size_bits, _attr) \
657 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
658 .byte_order = _byte_order, \
659 .float_size_bits = _float_size_bits, \
664 #define _side_field(_name, _type) \
666 .field_name = _name, \
667 .side_type = _type, \
671 #define side_type_u8(_attr) _side_type_integer(SIDE_TYPE_U8, false, SIDE_TYPE_BYTE_ORDER_HOST, 8, 8, SIDE_PARAM(_attr))
672 #define side_type_u16(_attr) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_HOST, 16, 16, SIDE_PARAM(_attr))
673 #define side_type_u32(_attr) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_HOST, 32, 32, SIDE_PARAM(_attr))
674 #define side_type_u64(_attr) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_HOST, 64, 64, SIDE_PARAM(_attr))
675 #define side_type_s8(_attr) _side_type_integer(SIDE_TYPE_S8, true, SIDE_TYPE_BYTE_ORDER_HOST, 8, 8, SIDE_PARAM(_attr))
676 #define side_type_s16(_attr) _side_type_integer(SIDE_TYPE_S16, true, SIDE_TYPE_BYTE_ORDER_HOST, 16, 16, SIDE_PARAM(_attr))
677 #define side_type_s32(_attr) _side_type_integer(SIDE_TYPE_S32, true, SIDE_TYPE_BYTE_ORDER_HOST, 32, 32, SIDE_PARAM(_attr))
678 #define side_type_s64(_attr) _side_type_integer(SIDE_TYPE_S64, true, SIDE_TYPE_BYTE_ORDER_HOST, 64, 64, SIDE_PARAM(_attr))
679 #define side_type_pointer(_attr) _side_type_integer(SIDE_TYPE_POINTER_HOST, false, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_BITS_PER_LONG, \
680 SIDE_BITS_PER_LONG, SIDE_PARAM(_attr))
681 #define side_type_float_binary16(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, 16, SIDE_PARAM(_attr))
682 #define side_type_float_binary32(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, 32, SIDE_PARAM(_attr))
683 #define side_type_float_binary64(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, 64, SIDE_PARAM(_attr))
684 #define side_type_float_binary128(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, 128, SIDE_PARAM(_attr))
686 #define side_field_null(_name, _attr) _side_field(_name, side_type_null(SIDE_PARAM(_attr)))
687 #define side_field_bool(_name, _attr) _side_field(_name, side_type_bool(SIDE_PARAM(_attr)))
688 #define side_field_u8(_name, _attr) _side_field(_name, side_type_u8(SIDE_PARAM(_attr)))
689 #define side_field_u16(_name, _attr) _side_field(_name, side_type_u16(SIDE_PARAM(_attr)))
690 #define side_field_u32(_name, _attr) _side_field(_name, side_type_u32(SIDE_PARAM(_attr)))
691 #define side_field_u64(_name, _attr) _side_field(_name, side_type_u64(SIDE_PARAM(_attr)))
692 #define side_field_s8(_name, _attr) _side_field(_name, side_type_s8(SIDE_PARAM(_attr)))
693 #define side_field_s16(_name, _attr) _side_field(_name, side_type_s16(SIDE_PARAM(_attr)))
694 #define side_field_s32(_name, _attr) _side_field(_name, side_type_s32(SIDE_PARAM(_attr)))
695 #define side_field_s64(_name, _attr) _side_field(_name, side_type_s64(SIDE_PARAM(_attr)))
696 #define side_field_byte(_name, _attr) _side_field(_name, side_type_byte(SIDE_PARAM(_attr)))
697 #define side_field_pointer(_name, _attr) _side_field(_name, side_type_pointer(SIDE_PARAM(_attr)))
698 #define side_field_float_binary16(_name, _attr) _side_field(_name, side_type_float_binary16(SIDE_PARAM(_attr)))
699 #define side_field_float_binary32(_name, _attr) _side_field(_name, side_type_float_binary32(SIDE_PARAM(_attr)))
700 #define side_field_float_binary64(_name, _attr) _side_field(_name, side_type_float_binary64(SIDE_PARAM(_attr)))
701 #define side_field_float_binary128(_name, _attr) _side_field(_name, side_type_float_binary128(SIDE_PARAM(_attr)))
702 #define side_field_string(_name, _attr) _side_field(_name, side_type_string(SIDE_PARAM(_attr)))
703 #define side_field_dynamic(_name) _side_field(_name, side_type_dynamic())
706 #define side_type_u16_le(_attr) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_LE, 16, 16, SIDE_PARAM(_attr))
707 #define side_type_u32_le(_attr) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_LE, 32, 32, SIDE_PARAM(_attr))
708 #define side_type_u64_le(_attr) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_LE, 64, 64, SIDE_PARAM(_attr))
709 #define side_type_s16_le(_attr) _side_type_integer(SIDE_TYPE_S16, true, SIDE_TYPE_BYTE_ORDER_LE, 16, 16, SIDE_PARAM(_attr))
710 #define side_type_s32_le(_attr) _side_type_integer(SIDE_TYPE_S32, true, SIDE_TYPE_BYTE_ORDER_LE, 32, 32, SIDE_PARAM(_attr))
711 #define side_type_s64_le(_attr) _side_type_integer(SIDE_TYPE_S64, true, SIDE_TYPE_BYTE_ORDER_LE, 64, 64, SIDE_PARAM(_attr))
712 #define side_type_pointer_le(_attr) _side_type_integer(SIDE_TYPE_POINTER_HOST, false, SIDE_TYPE_BYTE_ORDER_LE, SIDE_BITS_PER_LONG, \
713 SIDE_BITS_PER_LONG, SIDE_PARAM(_attr))
714 #define side_type_float_binary16_le(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_BYTE_ORDER_LE, 16, SIDE_PARAM(_attr))
715 #define side_type_float_binary32_le(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_BYTE_ORDER_LE, 32, SIDE_PARAM(_attr))
716 #define side_type_float_binary64_le(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_BYTE_ORDER_LE, 64, SIDE_PARAM(_attr))
717 #define side_type_float_binary128_le(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_BYTE_ORDER_LE, 128, SIDE_PARAM(_attr))
719 #define side_field_u16_le(_name, _attr) _side_field(_name, side_type_u16_le(SIDE_PARAM(_attr)))
720 #define side_field_u32_le(_name, _attr) _side_field(_name, side_type_u32_le(SIDE_PARAM(_attr)))
721 #define side_field_u64_le(_name, _attr) _side_field(_name, side_type_u64_le(SIDE_PARAM(_attr)))
722 #define side_field_s16_le(_name, _attr) _side_field(_name, side_type_s16_le(SIDE_PARAM(_attr)))
723 #define side_field_s32_le(_name, _attr) _side_field(_name, side_type_s32_le(SIDE_PARAM(_attr)))
724 #define side_field_s64_le(_name, _attr) _side_field(_name, side_type_s64_le(SIDE_PARAM(_attr)))
725 #define side_field_pointer_le(_name, _attr) _side_field(_name, side_type_pointer_le(SIDE_PARAM(_attr)))
726 #define side_field_float_binary16_le(_name, _attr) _side_field(_name, side_type_float_binary16_le(SIDE_PARAM(_attr)))
727 #define side_field_float_binary32_le(_name, _attr) _side_field(_name, side_type_float_binary32_le(SIDE_PARAM(_attr)))
728 #define side_field_float_binary64_le(_name, _attr) _side_field(_name, side_type_float_binary64_le(SIDE_PARAM(_attr)))
729 #define side_field_float_binary128_le(_name, _attr) _side_field(_name, side_type_float_binary128_le(SIDE_PARAM(_attr)))
732 #define side_type_u16_be(_attr) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_BE, 16, 16, SIDE_PARAM(_attr))
733 #define side_type_u32_be(_attr) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_BE, 32, 32, SIDE_PARAM(_attr))
734 #define side_type_u64_be(_attr) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_BE, 64, 64, SIDE_PARAM(_attr))
735 #define side_type_s16_be(_attr) _side_type_integer(SIDE_TYPE_S16, false, SIDE_TYPE_BYTE_ORDER_BE, 16, 16, SIDE_PARAM(_attr))
736 #define side_type_s32_be(_attr) _side_type_integer(SIDE_TYPE_S32, false, SIDE_TYPE_BYTE_ORDER_BE, 32, 32, SIDE_PARAM(_attr))
737 #define side_type_s64_be(_attr) _side_type_integer(SIDE_TYPE_S64, false, SIDE_TYPE_BYTE_ORDER_BE, 64, 64, SIDE_PARAM(_attr))
738 #define side_type_pointer_be(_attr) _side_type_integer(SIDE_TYPE_POINTER_HOST, false, SIDE_TYPE_BYTE_ORDER_BE, SIDE_BITS_PER_LONG, \
739 SIDE_BITS_PER_LONG, SIDE_PARAM(_attr))
740 #define side_type_float_binary16_be(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_BYTE_ORDER_BE, 16, SIDE_PARAM(_attr))
741 #define side_type_float_binary32_be(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_BYTE_ORDER_BE, 32, SIDE_PARAM(_attr))
742 #define side_type_float_binary64_be(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_BYTE_ORDER_BE, 64, SIDE_PARAM(_attr))
743 #define side_type_float_binary128_be(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_BYTE_ORDER_BE, 128, SIDE_PARAM(_attr))
745 #define side_field_u16_be(_name, _attr) _side_field(_name, side_type_u16_be(SIDE_PARAM(_attr)))
746 #define side_field_u32_be(_name, _attr) _side_field(_name, side_type_u32_be(SIDE_PARAM(_attr)))
747 #define side_field_u64_be(_name, _attr) _side_field(_name, side_type_u64_be(SIDE_PARAM(_attr)))
748 #define side_field_s16_be(_name, _attr) _side_field(_name, side_type_s16_be(SIDE_PARAM(_attr)))
749 #define side_field_s32_be(_name, _attr) _side_field(_name, side_type_s32_be(SIDE_PARAM(_attr)))
750 #define side_field_s64_be(_name, _attr) _side_field(_name, side_type_s64_be(SIDE_PARAM(_attr)))
751 #define side_field_pointer_be(_name, _attr) _side_field(_name, side_type_pointer_be(SIDE_PARAM(_attr)))
752 #define side_field_float_binary16_be(_name, _attr) _side_field(_name, side_type_float_binary16_be(SIDE_PARAM(_attr)))
753 #define side_field_float_binary32_be(_name, _attr) _side_field(_name, side_type_float_binary32_be(SIDE_PARAM(_attr)))
754 #define side_field_float_binary64_be(_name, _attr) _side_field(_name, side_type_float_binary64_be(SIDE_PARAM(_attr)))
755 #define side_field_float_binary128_be(_name, _attr) _side_field(_name, side_type_float_binary128_be(SIDE_PARAM(_attr)))
757 #define side_type_enum(_mappings, _elem_type) \
759 .type = SIDE_TYPE_ENUM, \
762 .mappings = _mappings, \
763 .elem_type = _elem_type, \
767 #define side_field_enum(_name, _mappings, _elem_type) \
768 _side_field(_name, side_type_enum(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type)))
770 #define side_type_enum_bitmap(_mappings, _elem_type) \
772 .type = SIDE_TYPE_ENUM_BITMAP, \
774 .side_enum_bitmap = { \
775 .mappings = _mappings, \
776 .elem_type = _elem_type, \
780 #define side_field_enum_bitmap(_name, _mappings, _elem_type) \
781 _side_field(_name, side_type_enum_bitmap(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type)))
783 #define side_type_struct(_struct) \
785 .type = SIDE_TYPE_STRUCT, \
787 .side_struct = _struct, \
790 #define side_field_struct(_name, _struct) \
791 _side_field(_name, side_type_struct(SIDE_PARAM(_struct)))
793 #define _side_type_struct_define(_fields, _attr) \
795 .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
796 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
801 #define side_define_struct(_identifier, _fields, _attr) \
802 const struct side_type_struct _identifier = _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM(_attr))
804 #define side_struct_literal(_fields, _attr) \
805 SIDE_COMPOUND_LITERAL(const struct side_type_struct, \
806 _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM(_attr)))
808 /* Scatter-gather fields */
810 #define _side_type_sg_integer(_type, _signedness, _byte_order, _offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
820 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
821 .integer_size_bits = _integer_size_bits, \
822 .len_bits = _len_bits, \
823 .signedness = _signedness, \
824 .byte_order = _byte_order, \
826 .offset_bits = _offset_bits, \
833 #define side_type_sg_unsigned_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
834 _side_type_sg_integer(SIDE_TYPE_SG_UNSIGNED_INT, false, SIDE_TYPE_BYTE_ORDER_HOST, \
835 _integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr))
836 #define side_type_sg_signed_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
837 _side_type_sg_integer(SIDE_TYPE_SG_SIGNED_INT, true, SIDE_TYPE_BYTE_ORDER_HOST, \
838 _integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr))
840 #define side_type_sg_unsigned_integer_le(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
841 _side_type_sg_integer(SIDE_TYPE_SG_UNSIGNED_INT, false, SIDE_TYPE_BYTE_ORDER_LE, \
842 _integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr))
843 #define side_type_sg_signed_integer_le(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
844 _side_type_sg_integer(SIDE_TYPE_SG_SIGNED_INT, true, SIDE_TYPE_BYTE_ORDER_LE, \
845 _integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr))
847 #define side_type_sg_unsigned_integer_be(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
848 _side_type_sg_integer(SIDE_TYPE_SG_UNSIGNED_INT, false, SIDE_TYPE_BYTE_ORDER_BE, \
849 _integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr))
850 #define side_type_sg_signed_integer_be(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
851 _side_type_sg_integer(SIDE_TYPE_SG_SIGNED_INT, true, SIDE_TYPE_BYTE_ORDER_BE, \
852 _integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr))
854 #define side_field_sg_unsigned_integer(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
855 _side_field(_name, side_type_sg_unsigned_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr)))
856 #define side_field_sg_signed_integer(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
857 _side_field(_name, side_type_sg_signed_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr)))
859 #define side_field_sg_unsigned_integer_le(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
860 _side_field(_name, side_type_sg_unsigned_integer_le(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr)))
861 #define side_field_sg_signed_integer_le(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
862 _side_field(_name, side_type_sg_signed_integer_le(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr)))
864 #define side_field_sg_unsigned_integer_be(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
865 _side_field(_name, side_type_sg_unsigned_integer_be(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr)))
866 #define side_field_sg_signed_integer_be(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
867 _side_field(_name, side_type_sg_signed_integer_be(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr)))
869 #define _side_type_sg_float(_byte_order, _offset, _float_size_bits, _attr) \
871 .type = SIDE_TYPE_SG_FLOAT, \
878 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
879 .float_size_bits = _float_size_bits, \
880 .byte_order = _byte_order, \
887 #define side_type_sg_float(_offset, _float_size_bits, _attr) \
888 _side_type_sg_float(SIDE_TYPE_FLOAT_WORD_ORDER_HOST, _offset, _float_size_bits, _attr)
889 #define side_type_sg_float_le(_offset, _float_size_bits, _attr) \
890 _side_type_sg_float(SIDE_TYPE_BYTE_ORDER_LE, _offset, _float_size_bits, _attr)
891 #define side_type_sg_float_be(_offset, _float_size_bits, _attr) \
892 _side_type_sg_float(SIDE_TYPE_BYTE_ORDER_BE, _offset, _float_size_bits, _attr)
894 #define side_field_sg_float(_name, _offset, _float_size_bits, _attr) \
895 _side_field(_name, side_type_sg_float(_offset, _float_size_bits, _attr))
896 #define side_field_sg_float_le(_name, _offset, _float_size_bits, _attr) \
897 _side_field(_name, side_type_sg_float_le(_offset, _float_size_bits, _attr))
898 #define side_field_sg_float_be(_name, _offset, _float_size_bits, _attr) \
899 _side_field(_name, side_type_sg_float_be(_offset, _float_size_bits, _attr))
901 #define side_type_sg_struct(_struct_sg, _offset) \
903 .type = SIDE_TYPE_SG_STRUCT, \
908 .side_struct = _struct_sg, \
913 #define side_field_sg_struct(_name, _struct_sg, _offset) \
914 _side_field(_name, side_type_sg_struct(SIDE_PARAM(_struct_sg), _offset))
916 #define side_type_array(_elem_type, _length, _attr) \
918 .type = SIDE_TYPE_ARRAY, \
921 .elem_type = _elem_type, \
924 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
928 #define side_field_array(_name, _elem_type, _length, _attr) \
929 _side_field(_name, side_type_array(SIDE_PARAM(_elem_type), _length, SIDE_PARAM(_attr)))
931 #define side_type_vla(_elem_type, _attr) \
933 .type = SIDE_TYPE_VLA, \
936 .elem_type = _elem_type, \
938 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
942 #define side_field_vla(_name, _elem_type, _attr) \
943 _side_field(_name, side_type_vla(SIDE_PARAM(_elem_type), SIDE_PARAM(_attr)))
945 #define side_type_vla_visitor(_elem_type, _visitor, _attr) \
947 .type = SIDE_TYPE_VLA_VISITOR, \
949 .side_vla_visitor = { \
950 .elem_type = SIDE_PARAM(_elem_type), \
951 .visitor = _visitor, \
953 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
957 #define side_field_vla_visitor(_name, _elem_type, _visitor, _attr) \
958 _side_field(_name, side_type_vla_visitor(SIDE_PARAM(_elem_type), _visitor, SIDE_PARAM(_attr)))
960 #define side_elem(...) \
961 SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__)
963 #define side_field_list(...) \
964 SIDE_COMPOUND_LITERAL(const struct side_event_field, __VA_ARGS__)
966 /* Static field arguments */
968 #define side_arg_null(_val) { .type = SIDE_TYPE_NULL }
969 #define side_arg_bool(_val) { .type = SIDE_TYPE_BOOL, .u = { .side_static = { .bool_value = !!(_val) } } }
970 #define side_arg_byte(_val) { .type = SIDE_TYPE_BYTE, .u = { .side_static = { .byte_value = (_val) } } }
971 #define side_arg_string(_val) { .type = SIDE_TYPE_STRING, .u = { .side_static = { .string_value = (uintptr_t) (_val) } } }
973 #define side_arg_u8(_val) { .type = SIDE_TYPE_U8, .u = { .side_static = { .integer_value = { .side_u8 = (_val) } } } }
974 #define side_arg_u16(_val) { .type = SIDE_TYPE_U16, .u = { .side_static = { .integer_value = { .side_u16 = (_val) } } } }
975 #define side_arg_u32(_val) { .type = SIDE_TYPE_U32, .u = { .side_static = { .integer_value = { .side_u32 = (_val) } } } }
976 #define side_arg_u64(_val) { .type = SIDE_TYPE_U64, .u = { .side_static = { .integer_value = { .side_u64 = (_val) } } } }
977 #define side_arg_s8(_val) { .type = SIDE_TYPE_S8, .u = { .side_static = { .integer_value = { .side_s8 = (_val) } } } }
978 #define side_arg_s16(_val) { .type = SIDE_TYPE_S16, .u = { .side_static = { .integer_value = { .side_s16 = (_val) } } } }
979 #define side_arg_s32(_val) { .type = SIDE_TYPE_S32, .u = { .side_static = { .integer_value = { .side_s32 = (_val) } } } }
980 #define side_arg_s64(_val) { .type = SIDE_TYPE_S64, .u = { .side_static = { .integer_value = { .side_s64 = (_val) } } } }
981 #define side_arg_pointer(_val) { .type = SIDE_TYPE_POINTER_HOST, .u = { .side_static = { .integer_value = { SIDE_PTR_HOST = (uintptr_t) (_val) } } } }
982 #define side_arg_enum_bitmap8(_val) { .type = SIDE_TYPE_ENUM_BITMAP8, .u = { .side_static = { .integer_value = { .side_u8 = (_val) } } } }
983 #define side_arg_enum_bitmap16(_val) { .type = SIDE_TYPE_ENUM_BITMAP16, .u = { .side_static = { .integer_value = { .side_u16 = (_val) } } } }
984 #define side_arg_enum_bitmap32(_val) { .type = SIDE_TYPE_ENUM_BITMAP32, .u = { .side_static = { .integer_value = { .side_u32 = (_val) } } } }
985 #define side_arg_enum_bitmap64(_val) { .type = SIDE_TYPE_ENUM_BITMAP64, .u = { .side_static = { .integer_value = { .side_u64 = (_val) } } } }
986 #define side_arg_enum_bitmap_array(_side_type) { .type = SIDE_TYPE_ENUM_BITMAP_ARRAY, .u = { .side_static = { .side_array = (_side_type) } } }
987 #define side_arg_enum_bitmap_vla(_side_type) { .type = SIDE_TYPE_ENUM_BITMAP_VLA, .u = { .side_static = { .side_vla = (_side_type) } } }
988 #define side_arg_float_binary16(_val) { .type = SIDE_TYPE_FLOAT_BINARY16, .u = { .side_static = { .float_value = { .side_float_binary16 = (_val) } } } }
989 #define side_arg_float_binary32(_val) { .type = SIDE_TYPE_FLOAT_BINARY32, .u = { .side_static = { .float_value = { .side_float_binary32 = (_val) } } } }
990 #define side_arg_float_binary64(_val) { .type = SIDE_TYPE_FLOAT_BINARY64, .u = { .side_static = { .float_value = { .side_float_binary64 = (_val) } } } }
991 #define side_arg_float_binary128(_val) { .type = SIDE_TYPE_FLOAT_BINARY128, .u = { .side_static = { .float_value = { .side_float_binary128 = (_val) } } } }
993 #define side_arg_struct(_side_type) { .type = SIDE_TYPE_STRUCT, .u = { .side_static = { .side_struct = (_side_type) } } }
994 #define side_arg_sg_struct(_ptr) { .type = SIDE_TYPE_SG_STRUCT, .u = { .side_static = { .side_struct_sg_ptr = (_ptr) } } }
995 #define side_arg_sg_unsigned_integer(_ptr) { .type = SIDE_TYPE_SG_UNSIGNED_INT, .u = { .side_static = { .side_integer_sg_ptr = (_ptr) } } }
996 #define side_arg_sg_signed_integer(_ptr) { .type = SIDE_TYPE_SG_SIGNED_INT, .u = { .side_static = { .side_integer_sg_ptr = (_ptr) } } }
997 #define side_arg_sg_float(_ptr) { .type = SIDE_TYPE_SG_FLOAT, .u = { .side_static = { .side_float_sg_ptr = (_ptr) } } }
998 #define side_arg_array(_side_type) { .type = SIDE_TYPE_ARRAY, .u = { .side_static = { .side_array = (_side_type) } } }
999 #define side_arg_vla(_side_type) { .type = SIDE_TYPE_VLA, .u = { .side_static = { .side_vla = (_side_type) } } }
1000 #define side_arg_vla_visitor(_ctx) { .type = SIDE_TYPE_VLA_VISITOR, .u = { .side_static = { .side_vla_app_visitor_ctx = (_ctx) } } }
1002 #define side_arg_array_u8(_ptr) { .type = SIDE_TYPE_ARRAY_U8, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1003 #define side_arg_array_u16(_ptr) { .type = SIDE_TYPE_ARRAY_U16, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1004 #define side_arg_array_u32(_ptr) { .type = SIDE_TYPE_ARRAY_U32, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1005 #define side_arg_array_u64(_ptr) { .type = SIDE_TYPE_ARRAY_U64, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1006 #define side_arg_array_s8(_ptr) { .type = SIDE_TYPE_ARRAY_S8, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1007 #define side_arg_array_s16(_ptr) { .type = SIDE_TYPE_ARRAY_S16, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1008 #define side_arg_array_s32(_ptr) { .type = SIDE_TYPE_ARRAY_S32, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1009 #define side_arg_array_s64(_ptr) { .type = SIDE_TYPE_ARRAY_S64, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1010 #define side_arg_array_byte(_ptr) { .type = SIDE_TYPE_ARRAY_BYTE, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1011 #define side_arg_array_pointer(_ptr) { .type = SIDE_TYPE_ARRAY_POINTER_HOST, .u = { .side_static = { .side_array_fixint = (_ptr) } } }
1013 #define side_arg_vla_u8(_ptr, _length) { .type = SIDE_TYPE_VLA_U8, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
1014 #define side_arg_vla_u16(_ptr, _length) { .type = SIDE_TYPE_VLA_U16, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1015 #define side_arg_vla_u32(_ptr, _length) { .type = SIDE_TYPE_VLA_U32, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1016 #define side_arg_vla_u64(_ptr, _length) { .type = SIDE_TYPE_VLA_U64, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1017 #define side_arg_vla_s8(_ptr, _length) { .type = SIDE_TYPE_VLA_S8, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1018 #define side_arg_vla_s16(_ptr, _length) { .type = SIDE_TYPE_VLA_S16, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1019 #define side_arg_vla_s32(_ptr, _length) { .type = SIDE_TYPE_VLA_S32, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1020 #define side_arg_vla_s64(_ptr, _length) { .type = SIDE_TYPE_VLA_S64, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1021 #define side_arg_vla_byte(_ptr, _length) { .type = SIDE_TYPE_VLA_BYTE, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1022 #define side_arg_vla_pointer(_ptr, _length) { .type = SIDE_TYPE_VLA_POINTER_HOST, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
1024 /* Dynamic field arguments */
1026 #define side_arg_dynamic_null(_attr) \
1028 .type = SIDE_TYPE_DYNAMIC_NULL, \
1033 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1039 #define side_arg_dynamic_bool(_val, _attr) \
1041 .type = SIDE_TYPE_DYNAMIC_BOOL, \
1047 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1049 .value = !!(_val), \
1055 #define side_arg_dynamic_byte(_val, _attr) \
1057 .type = SIDE_TYPE_DYNAMIC_BYTE, \
1063 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1070 #define side_arg_dynamic_string(_val, _attr) \
1072 .type = SIDE_TYPE_DYNAMIC_STRING, \
1078 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1080 .value = (uintptr_t) (_val), \
1086 #define _side_arg_dynamic_integer(_field, _val, _type, _signedness, _byte_order, _integer_size_bits, _len_bits, _attr) \
1094 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1095 .integer_size_bits = _integer_size_bits, \
1096 .len_bits = _len_bits, \
1097 .signedness = _signedness, \
1098 .byte_order = _byte_order, \
1108 #define side_arg_dynamic_u8(_val, _attr) \
1109 _side_arg_dynamic_integer(.side_u8, _val, SIDE_TYPE_DYNAMIC_U8, false, SIDE_TYPE_BYTE_ORDER_HOST, 8, 8, SIDE_PARAM(_attr))
1110 #define side_arg_dynamic_s8(_val, _attr) \
1111 _side_arg_dynamic_integer(.side_s8, _val, SIDE_TYPE_DYNAMIC_S8, true, SIDE_TYPE_BYTE_ORDER_HOST, 8, 8, SIDE_PARAM(_attr))
1113 #define _side_arg_dynamic_u16(_val, _byte_order, _attr) \
1114 _side_arg_dynamic_integer(.side_u16, _val, SIDE_TYPE_DYNAMIC_U16, false, _byte_order, 16, 16, SIDE_PARAM(_attr))
1115 #define _side_arg_dynamic_u32(_val, _byte_order, _attr) \
1116 _side_arg_dynamic_integer(.side_u32, _val, SIDE_TYPE_DYNAMIC_U32, false, _byte_order, 32, 32, SIDE_PARAM(_attr))
1117 #define _side_arg_dynamic_u64(_val, _byte_order, _attr) \
1118 _side_arg_dynamic_integer(.side_u64, _val, SIDE_TYPE_DYNAMIC_U64, false, _byte_order, 64, 64, SIDE_PARAM(_attr))
1120 #define _side_arg_dynamic_s16(_val, _byte_order, _attr) \
1121 _side_arg_dynamic_integer(.side_s16, _val, SIDE_TYPE_DYNAMIC_S16, true, _byte_order, 16, 16, SIDE_PARAM(_attr))
1122 #define _side_arg_dynamic_s32(_val, _byte_order, _attr) \
1123 _side_arg_dynamic_integer(.side_s32, _val, SIDE_TYPE_DYNAMIC_S32, true, _byte_order, 32, 32, SIDE_PARAM(_attr))
1124 #define _side_arg_dynamic_s64(_val, _byte_order, _attr) \
1125 _side_arg_dynamic_integer(.side_s64, _val, SIDE_TYPE_DYNAMIC_S64, true, _byte_order, 64, 64, SIDE_PARAM(_attr))
1127 #define _side_arg_dynamic_pointer(_val, _byte_order, _attr) \
1128 _side_arg_dynamic_integer(SIDE_PTR_HOST, (uintptr_t) (_val), SIDE_TYPE_DYNAMIC_POINTER_HOST, false, _byte_order, \
1129 SIDE_BITS_PER_LONG, SIDE_BITS_PER_LONG, SIDE_PARAM(_attr))
1131 #define _side_arg_dynamic_float(_field, _val, _type, _byte_order, _float_size_bits, _attr) \
1139 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1140 .byte_order = _byte_order, \
1141 .float_size_bits = _float_size_bits, \
1151 #define _side_arg_dynamic_float_binary16(_val, _byte_order, _attr) \
1152 _side_arg_dynamic_float(.side_float_binary16, _val, SIDE_TYPE_DYNAMIC_FLOAT_BINARY16, _byte_order, 16, SIDE_PARAM(_attr))
1153 #define _side_arg_dynamic_float_binary32(_val, _byte_order, _attr) \
1154 _side_arg_dynamic_float(.side_float_binary32, _val, SIDE_TYPE_DYNAMIC_FLOAT_BINARY32, _byte_order, 32, SIDE_PARAM(_attr))
1155 #define _side_arg_dynamic_float_binary64(_val, _byte_order, _attr) \
1156 _side_arg_dynamic_float(.side_float_binary64, _val, SIDE_TYPE_DYNAMIC_FLOAT_BINARY64, _byte_order, 64, SIDE_PARAM(_attr))
1157 #define _side_arg_dynamic_float_binary128(_val, _byte_order, _attr) \
1158 _side_arg_dynamic_float(.side_float_binary128, _val, SIDE_TYPE_DYNAMIC_FLOAT_BINARY128, _byte_order, 128, SIDE_PARAM(_attr))
1161 #define side_arg_dynamic_u16(_val, _attr) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr))
1162 #define side_arg_dynamic_u32(_val, _attr) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr))
1163 #define side_arg_dynamic_u64(_val, _attr) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr))
1164 #define side_arg_dynamic_s16(_val, _attr) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr))
1165 #define side_arg_dynamic_s32(_val, _attr) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr))
1166 #define side_arg_dynamic_s64(_val, _attr) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr))
1167 #define side_arg_dynamic_pointer(_val, _attr) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr))
1168 #define side_arg_dynamic_float_binary16(_val, _attr) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM(_attr))
1169 #define side_arg_dynamic_float_binary32(_val, _attr) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM(_attr))
1170 #define side_arg_dynamic_float_binary64(_val, _attr) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM(_attr))
1171 #define side_arg_dynamic_float_binary128(_val, _attr) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM(_attr))
1174 #define side_arg_dynamic_u16_le(_val, _attr) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1175 #define side_arg_dynamic_u32_le(_val, _attr) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1176 #define side_arg_dynamic_u64_le(_val, _attr) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1177 #define side_arg_dynamic_s16_le(_val, _attr) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1178 #define side_arg_dynamic_s32_le(_val, _attr) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1179 #define side_arg_dynamic_s64_le(_val, _attr) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1180 #define side_arg_dynamic_pointer_le(_val, _attr) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1181 #define side_arg_dynamic_float_binary16_le(_val, _attr) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1182 #define side_arg_dynamic_float_binary32_le(_val, _attr) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1183 #define side_arg_dynamic_float_binary64_le(_val, _attr) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1184 #define side_arg_dynamic_float_binary128_le(_val, _attr) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr))
1187 #define side_arg_dynamic_u16_be(_val, _attr) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1188 #define side_arg_dynamic_u32_be(_val, _attr) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1189 #define side_arg_dynamic_u64_be(_val, _attr) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1190 #define side_arg_dynamic_s16_be(_val, _attr) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1191 #define side_arg_dynamic_s32_be(_val, _attr) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1192 #define side_arg_dynamic_s64_be(_val, _attr) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1193 #define side_arg_dynamic_pointer_be(_val, _attr) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1194 #define side_arg_dynamic_float_binary16_be(_val, _attr) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1195 #define side_arg_dynamic_float_binary32_be(_val, _attr) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1196 #define side_arg_dynamic_float_binary64_be(_val, _attr) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1197 #define side_arg_dynamic_float_binary128_be(_val, _attr) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr))
1199 #define side_arg_dynamic_vla(_vla) \
1201 .type = SIDE_TYPE_DYNAMIC_VLA, \
1204 .side_dynamic_vla = (_vla), \
1209 #define side_arg_dynamic_vla_visitor(_dynamic_vla_visitor, _ctx, _attr) \
1211 .type = SIDE_TYPE_DYNAMIC_VLA_VISITOR, \
1214 .side_dynamic_vla_visitor = { \
1216 .visitor = _dynamic_vla_visitor, \
1218 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1224 #define side_arg_dynamic_struct(_struct) \
1226 .type = SIDE_TYPE_DYNAMIC_STRUCT, \
1229 .side_dynamic_struct = (_struct), \
1234 #define side_arg_dynamic_struct_visitor(_dynamic_struct_visitor, _ctx, _attr) \
1236 .type = SIDE_TYPE_DYNAMIC_STRUCT_VISITOR, \
1239 .side_dynamic_struct_visitor = { \
1241 .visitor = _dynamic_struct_visitor, \
1243 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1249 #define side_arg_dynamic_define_vec(_identifier, _sav, _attr) \
1250 const struct side_arg _identifier##_vec[] = { _sav }; \
1251 const struct side_arg_dynamic_vla _identifier = { \
1252 .sav = _identifier##_vec, \
1254 .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
1255 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1258 #define side_arg_dynamic_define_struct(_identifier, _struct_fields, _attr) \
1259 const struct side_arg_dynamic_event_field _identifier##_fields[] = { _struct_fields }; \
1260 const struct side_arg_dynamic_event_struct _identifier = { \
1261 .fields = _identifier##_fields, \
1263 .len = SIDE_ARRAY_SIZE(_identifier##_fields), \
1264 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1267 #define side_arg_define_vec(_identifier, _sav) \
1268 const struct side_arg _identifier##_vec[] = { _sav }; \
1269 const struct side_arg_vec _identifier = { \
1270 .sav = _identifier##_vec, \
1271 .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
1274 #define side_arg_dynamic_field(_name, _elem) \
1276 .field_name = _name, \
1280 #define side_arg_list(...) __VA_ARGS__
1282 #define side_define_enum(_identifier, _mappings, _attr) \
1283 const struct side_enum_mappings _identifier = { \
1284 .mappings = _mappings, \
1286 .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \
1287 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1290 #define side_enum_mapping_list(...) \
1291 SIDE_COMPOUND_LITERAL(const struct side_enum_mapping, __VA_ARGS__)
1293 #define side_enum_mapping_range(_label, _begin, _end) \
1295 .range_begin = _begin, \
1296 .range_end = _end, \
1300 #define side_enum_mapping_value(_label, _value) \
1302 .range_begin = _value, \
1303 .range_end = _value, \
1307 #define side_define_enum_bitmap(_identifier, _mappings, _attr) \
1308 const struct side_enum_bitmap_mappings _identifier = { \
1309 .mappings = _mappings, \
1311 .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \
1312 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1315 #define side_enum_bitmap_mapping_list(...) \
1316 SIDE_COMPOUND_LITERAL(const struct side_enum_bitmap_mapping, __VA_ARGS__)
1318 #define side_enum_bitmap_mapping_range(_label, _begin, _end) \
1320 .range_begin = _begin, \
1321 .range_end = _end, \
1325 #define side_enum_bitmap_mapping_value(_label, _value) \
1327 .range_begin = _value, \
1328 .range_end = _value, \
1332 #define side_event_cond(_identifier) \
1333 if (side_unlikely(__atomic_load_n(&side_event_enable__##_identifier, \
1336 #define side_event_call(_identifier, _sav) \
1338 const struct side_arg side_sav[] = { _sav }; \
1339 const struct side_arg_vec side_arg_vec = { \
1341 .len = SIDE_ARRAY_SIZE(side_sav), \
1343 side_call(&(_identifier), &side_arg_vec); \
1346 #define side_event(_identifier, _sav) \
1347 side_event_cond(_identifier) \
1348 side_event_call(_identifier, SIDE_PARAM(_sav))
1350 #define side_event_call_variadic(_identifier, _sav, _var_fields, _attr) \
1352 const struct side_arg side_sav[] = { _sav }; \
1353 const struct side_arg_vec side_arg_vec = { \
1355 .len = SIDE_ARRAY_SIZE(side_sav), \
1357 const struct side_arg_dynamic_event_field side_fields[] = { _var_fields }; \
1358 const struct side_arg_dynamic_event_struct var_struct = { \
1359 .fields = side_fields, \
1361 .len = SIDE_ARRAY_SIZE(side_fields), \
1362 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1364 side_call_variadic(&(_identifier), &side_arg_vec, &var_struct); \
1367 #define side_event_variadic(_identifier, _sav, _var, _attr) \
1368 side_event_cond(_identifier) \
1369 side_event_call_variadic(_identifier, SIDE_PARAM(_sav), SIDE_PARAM(_var), SIDE_PARAM(_attr))
1371 #define _side_define_event(_linkage, _identifier, _provider, _event, _loglevel, _fields, _attr, _flags) \
1372 _linkage uintptr_t side_event_enable__##_identifier __attribute__((section("side_event_enable"))); \
1373 _linkage struct side_event_description __attribute__((section("side_event_description"))) \
1375 .enabled = &(side_event_enable__##_identifier), \
1376 .provider_name = _provider, \
1377 .event_name = _event, \
1378 .fields = _fields, \
1380 .callbacks = &side_empty_callback, \
1381 .flags = (_flags), \
1383 .loglevel = _loglevel, \
1384 .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
1385 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1386 .nr_callbacks = 0, \
1388 static const struct side_event_description *side_event_ptr__##_identifier \
1389 __attribute__((section("side_event_description_ptr"), used)) = &(_identifier);
1391 #define side_static_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \
1392 _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
1393 SIDE_PARAM(_attr), 0)
1395 #define side_static_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \
1396 _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
1397 SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC)
1399 #define side_hidden_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \
1400 _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
1401 SIDE_PARAM(_attr), 0)
1403 #define side_hidden_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \
1404 _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
1405 SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC)
1407 #define side_export_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \
1408 _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
1409 SIDE_PARAM(_attr), 0)
1411 #define side_export_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \
1412 _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
1413 SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC)
1415 #define side_declare_event(_identifier) \
1416 extern uintptr_t side_event_enable_##_identifier; \
1417 extern struct side_event_description _identifier
1419 extern const struct side_callback side_empty_callback
;
1421 void side_call(const struct side_event_description
*desc
,
1422 const struct side_arg_vec
*side_arg_vec
);
1423 void side_call_variadic(const struct side_event_description
*desc
,
1424 const struct side_arg_vec
*side_arg_vec
,
1425 const struct side_arg_dynamic_event_struct
*var_struct
);
1427 int side_tracer_callback_register(struct side_event_description
*desc
,
1428 void (*call
)(const struct side_event_description
*desc
,
1429 const struct side_arg_vec
*side_arg_vec
,
1432 int side_tracer_callback_variadic_register(struct side_event_description
*desc
,
1433 void (*call_variadic
)(const struct side_event_description
*desc
,
1434 const struct side_arg_vec
*side_arg_vec
,
1435 const struct side_arg_dynamic_event_struct
*var_struct
,
1438 int side_tracer_callback_unregister(struct side_event_description
*desc
,
1439 void (*call
)(const struct side_event_description
*desc
,
1440 const struct side_arg_vec
*side_arg_vec
,
1443 int side_tracer_callback_variadic_unregister(struct side_event_description
*desc
,
1444 void (*call_variadic
)(const struct side_event_description
*desc
,
1445 const struct side_arg_vec
*side_arg_vec
,
1446 const struct side_arg_dynamic_event_struct
*var_struct
,
1450 struct side_events_register_handle
*side_events_register(struct side_event_description
**events
, uint32_t nr_events
);
1451 void side_events_unregister(struct side_events_register_handle
*handle
);
1453 enum side_tracer_notification
{
1454 SIDE_TRACER_NOTIFICATION_INSERT_EVENTS
,
1455 SIDE_TRACER_NOTIFICATION_REMOVE_EVENTS
,
1458 /* Callback is invoked with side library internal lock held. */
1459 struct side_tracer_handle
*side_tracer_event_notification_register(
1460 void (*cb
)(enum side_tracer_notification notif
,
1461 struct side_event_description
**events
, uint32_t nr_events
, void *priv
),
1463 void side_tracer_event_notification_unregister(struct side_tracer_handle
*handle
);
1465 void side_init(void);
1466 void side_exit(void);
1469 * These weak symbols, the constructor, and destructor take care of
1470 * registering only _one_ instance of the side instrumentation per
1471 * shared-ojbect (or for the whole main program).
1473 extern struct side_event_description
* __start_side_event_description_ptr
[]
1474 __attribute__((weak
, visibility("hidden")));
1475 extern struct side_event_description
* __stop_side_event_description_ptr
[]
1476 __attribute__((weak
, visibility("hidden")));
1477 int side_event_description_ptr_registered
1478 __attribute__((weak
, visibility("hidden")));
1479 struct side_events_register_handle
*side_events_handle
1480 __attribute__((weak
, visibility("hidden")));
1483 side_event_description_ptr_init(void)
1484 __attribute__((no_instrument_function
))
1485 __attribute__((constructor
));
1487 side_event_description_ptr_init(void)
1489 if (side_event_description_ptr_registered
++)
1491 side_events_handle
= side_events_register(__start_side_event_description_ptr
,
1492 __stop_side_event_description_ptr
- __start_side_event_description_ptr
);
1496 side_event_description_ptr_exit(void)
1497 __attribute__((no_instrument_function
))
1498 __attribute__((destructor
));
1500 side_event_description_ptr_exit(void)
1502 if (--side_event_description_ptr_registered
)
1504 side_events_unregister(side_events_handle
);
1505 side_events_handle
= NULL
;
1508 #endif /* _SIDE_TRACE_H */