1 // SPDX-License-Identifier: MIT
3 * Copyright 2022 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
16 #include <side/macros.h>
17 #include <side/endian.h>
20 * SIDE stands for "Software Instrumentation Dynamically Enabled"
22 * This is an instrumentation ABI for Linux user-space, which exposes an
23 * instrumentation type system and facilities allowing a kernel or
24 * user-space tracer to consume user-space instrumentation.
26 * This instrumentation ABI exposes 3 type systems:
28 * * Stack-copy type system: This is the core type system which can
29 * represent all supported types and into which all other type systems
30 * can be nested. This type system requires that every type is
31 * statically or dynamically declared and then registered, thus giving
32 * tracers a complete description of the events and their associated
33 * fields before the associated instrumentation is invoked. The
34 * application needs to copy each argument (side_arg_...()) onto the
35 * stack when calling the instrumentation.
37 * This is the most expressive of the 3 type systems, althrough not the
38 * fastest due to the extra copy of the arguments.
40 * * Data-gathering type system: This type system requires every type to
41 * be statically or dynamically declared and registered, but does not
42 * require the application to copy its arguments onto the stack.
43 * Instead, the type description contains all the required information
44 * to fetch the data from the application memory. The only argument
45 * required from the instrumentation is the base pointer from which
46 * the data should be fetched.
48 * This type system can be used as an event field, or nested within
49 * the stack-copy type system. Nesting of gather-vla within
50 * gather-array and gather-vla types is not allowed.
52 * This type system is has the least overhead of the 3 type systems.
54 * * Dynamic type system: This type system receives both type
55 * description and actual data onto the stack at runtime. It has more
56 * overhead that the 2 other type systems, but does not require a
57 * prior registration of event field description. This makes it useful
58 * for seldom used types which are not performance critical, but for
59 * which registering each individual events would needlessly grow the
60 * number of events to declare and register.
62 * Another use-case for this type system is for use by dynamically
63 * typed language runtimes, where the field type is only known when
64 * the instrumentation is called.
66 * Those dynamic types can be either used as arguments to a variadic
67 * field list, or as on-stack instrumentation argument for a static
68 * type SIDE_TYPE_DYNAMIC place holder in the stack-copy type system.
70 * The extensibility scheme for the SIDE ABI is as follows:
72 * * Existing field types are never changed nor extended. Field types
73 * can be added to the ABI by reserving a label within
74 * enum side_type_label.
75 * * Existing attribute types are never changed nor extended. Attribute
76 * types can be added to the ABI by reserving a label within
77 * enum side_attr_type.
78 * * Each union part of the ABI has an explicit size defined by a
79 * side_padding() member. Each structure and union have a static
80 * assert validating its size.
81 * * If the semantic of the existing event description or type fields
82 * change, the SIDE_EVENT_DESCRIPTION_ABI_VERSION should be increased.
83 * * If the semantic of the "struct side_event_state_N" fields change,
84 * the SIDE_EVENT_STATE_ABI_VERSION should be increased. The
85 * "struct side_event_state_N" is not extensible and must have its
86 * ABI version increased whenever it is changed. Note that increasing
87 * the version of SIDE_EVENT_DESCRIPTION_ABI_VERSION is not necessary
88 * when changing the layout of "struct side_event_state_N".
90 * Handling of unknown types by the tracers:
92 * * A tracer may choose to support only a subset of the types supported
93 * by libside. When encountering an unknown or unsupported type, the
94 * tracer has the option to either disallow the entire event or skip
95 * over the unknown type, both at event registration and when
96 * receiving the side_call arguments.
98 * * Event descriptions can be extended by adding fields at the end of
99 * the structure. The "struct side_event_description" is a structure
100 * with flexible size which must not be used within arrays.
103 #define SIDE_EVENT_DESCRIPTION_ABI_VERSION 0
104 #define SIDE_EVENT_STATE_ABI_VERSION 0
108 union side_arg_dynamic
;
109 struct side_arg_dynamic_field
;
110 struct side_arg_dynamic_vla
;
112 struct side_event_field
;
113 struct side_tracer_visitor_ctx
;
114 struct side_tracer_dynamic_struct_visitor_ctx
;
115 struct side_event_description
;
116 struct side_arg_dynamic_struct
;
117 struct side_events_register_handle
;
118 struct side_arg_variant
;
119 struct side_event_state_0
;
120 struct side_callback
;
122 enum side_type_label
{
123 /* Stack-copy basic types */
136 SIDE_TYPE_FLOAT_BINARY16
,
137 SIDE_TYPE_FLOAT_BINARY32
,
138 SIDE_TYPE_FLOAT_BINARY64
,
139 SIDE_TYPE_FLOAT_BINARY128
,
140 SIDE_TYPE_STRING_UTF8
,
141 SIDE_TYPE_STRING_UTF16
,
142 SIDE_TYPE_STRING_UTF32
,
144 /* Stack-copy compound types */
149 SIDE_TYPE_VLA_VISITOR
,
151 /* Stack-copy enumeration types */
153 SIDE_TYPE_ENUM_BITMAP
,
155 /* Stack-copy place holder for dynamic types */
158 /* Gather basic types */
159 SIDE_TYPE_GATHER_BOOL
,
160 SIDE_TYPE_GATHER_INTEGER
,
161 SIDE_TYPE_GATHER_BYTE
,
162 SIDE_TYPE_GATHER_POINTER
,
163 SIDE_TYPE_GATHER_FLOAT
,
164 SIDE_TYPE_GATHER_STRING
,
166 /* Gather compound types */
167 SIDE_TYPE_GATHER_STRUCT
,
168 SIDE_TYPE_GATHER_ARRAY
,
169 SIDE_TYPE_GATHER_VLA
,
171 /* Gather enumeration types */
172 SIDE_TYPE_GATHER_ENUM
,
174 /* Dynamic basic types */
175 SIDE_TYPE_DYNAMIC_NULL
,
176 SIDE_TYPE_DYNAMIC_BOOL
,
177 SIDE_TYPE_DYNAMIC_INTEGER
,
178 SIDE_TYPE_DYNAMIC_BYTE
,
179 SIDE_TYPE_DYNAMIC_POINTER
,
180 SIDE_TYPE_DYNAMIC_FLOAT
,
181 SIDE_TYPE_DYNAMIC_STRING
,
183 /* Dynamic compound types */
184 SIDE_TYPE_DYNAMIC_STRUCT
,
185 SIDE_TYPE_DYNAMIC_STRUCT_VISITOR
,
186 SIDE_TYPE_DYNAMIC_VLA
,
187 SIDE_TYPE_DYNAMIC_VLA_VISITOR
,
189 _NR_SIDE_TYPE_LABEL
, /* Last entry. */
192 enum side_attr_type
{
203 SIDE_ATTR_TYPE_FLOAT_BINARY16
,
204 SIDE_ATTR_TYPE_FLOAT_BINARY32
,
205 SIDE_ATTR_TYPE_FLOAT_BINARY64
,
206 SIDE_ATTR_TYPE_FLOAT_BINARY128
,
207 SIDE_ATTR_TYPE_STRING
,
209 _NR_SIDE_ATTR_TYPE
, /* Last entry. */
213 SIDE_LOGLEVEL_EMERG
= 0,
214 SIDE_LOGLEVEL_ALERT
= 1,
215 SIDE_LOGLEVEL_CRIT
= 2,
216 SIDE_LOGLEVEL_ERR
= 3,
217 SIDE_LOGLEVEL_WARNING
= 4,
218 SIDE_LOGLEVEL_NOTICE
= 5,
219 SIDE_LOGLEVEL_INFO
= 6,
220 SIDE_LOGLEVEL_DEBUG
= 7,
223 enum side_visitor_status
{
224 SIDE_VISITOR_STATUS_OK
= 0,
225 SIDE_VISITOR_STATUS_ERROR
= -1,
230 SIDE_ERROR_INVAL
= 1,
231 SIDE_ERROR_EXIST
= 2,
232 SIDE_ERROR_NOMEM
= 3,
233 SIDE_ERROR_NOENT
= 4,
234 SIDE_ERROR_EXITING
= 5,
237 enum side_type_label_byte_order
{
238 SIDE_TYPE_BYTE_ORDER_LE
= 0,
239 SIDE_TYPE_BYTE_ORDER_BE
= 1,
242 #if (SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN)
243 # define SIDE_TYPE_BYTE_ORDER_HOST SIDE_TYPE_BYTE_ORDER_LE
245 # define SIDE_TYPE_BYTE_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE
248 #if (SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN)
249 # define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_LE
251 # define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE
254 enum side_type_gather_access_mode
{
255 SIDE_TYPE_GATHER_ACCESS_DIRECT
,
256 SIDE_TYPE_GATHER_ACCESS_POINTER
, /* Pointer dereference */
259 typedef enum side_visitor_status (*side_visitor_func
)(
260 const struct side_tracer_visitor_ctx
*tracer_ctx
,
262 typedef enum side_visitor_status (*side_dynamic_struct_visitor_func
)(
263 const struct side_tracer_dynamic_struct_visitor_ctx
*tracer_ctx
,
265 typedef enum side_visitor_status (*side_write_elem_func
)(
266 const struct side_tracer_visitor_ctx
*tracer_ctx
,
267 const struct side_arg
*elem
);
268 typedef enum side_visitor_status (*side_write_field_func
)(
269 const struct side_tracer_dynamic_struct_visitor_ctx
*tracer_ctx
,
270 const struct side_arg_dynamic_field
*dynamic_field
);
272 union side_integer_value
{
284 side_check_size(union side_integer_value
, 32);
286 union side_bool_value
{
288 uint16_t side_bool16
;
289 uint32_t side_bool32
;
290 uint64_t side_bool64
;
293 side_check_size(union side_bool_value
, 32);
295 union side_float_value
{
297 _Float16 side_float_binary16
;
300 _Float32 side_float_binary32
;
303 _Float64 side_float_binary64
;
306 _Float128 side_float_binary128
;
310 side_check_size(union side_float_value
, 32);
312 struct side_type_raw_string
{
313 side_ptr_t(const void) p
; /* pointer to string */
314 uint8_t unit_size
; /* 1, 2, or 4 bytes */
315 side_enum_t(enum side_type_label_byte_order
, uint8_t) byte_order
;
317 side_check_size(struct side_type_raw_string
, 18);
319 struct side_attr_value
{
320 side_enum_t(enum side_attr_type
, uint32_t) type
;
323 struct side_type_raw_string string_value
;
324 union side_integer_value integer_value
;
325 union side_float_value float_value
;
329 side_check_size(struct side_attr_value
, 36);
331 /* User attributes. */
333 const struct side_type_raw_string key
;
334 const struct side_attr_value value
;
336 side_check_size(struct side_attr
, 54);
338 /* Type descriptions */
339 struct side_type_null
{
340 side_ptr_t(const struct side_attr
) attr
;
343 side_check_size(struct side_type_null
, 20);
345 struct side_type_bool
{
346 side_ptr_t(const struct side_attr
) attr
;
348 uint16_t bool_size
; /* bytes */
349 uint16_t len_bits
; /* bits. 0 for (bool_size * CHAR_BITS) */
350 side_enum_t(enum side_type_label_byte_order
, uint8_t) byte_order
;
352 side_check_size(struct side_type_bool
, 25);
354 struct side_type_byte
{
355 side_ptr_t(const struct side_attr
) attr
;
358 side_check_size(struct side_type_byte
, 20);
360 struct side_type_string
{
361 side_ptr_t(const struct side_attr
) attr
;
363 uint8_t unit_size
; /* 1, 2, or 4 bytes */
364 side_enum_t(enum side_type_label_byte_order
, uint8_t) byte_order
;
366 side_check_size(struct side_type_string
, 22);
368 struct side_type_integer
{
369 side_ptr_t(const struct side_attr
) attr
;
371 uint16_t integer_size
; /* bytes */
372 uint16_t len_bits
; /* bits. 0 for (integer_size * CHAR_BITS) */
373 uint8_t signedness
; /* true/false */
374 side_enum_t(enum side_type_label_byte_order
, uint8_t) byte_order
;
376 side_check_size(struct side_type_integer
, 26);
378 struct side_type_float
{
379 side_ptr_t(const struct side_attr
) attr
;
381 uint16_t float_size
; /* bytes */
382 side_enum_t(enum side_type_label_byte_order
, uint8_t) byte_order
;
384 side_check_size(struct side_type_float
, 23);
386 struct side_enum_mapping
{
389 struct side_type_raw_string label
;
391 side_check_size(struct side_enum_mapping
, 16 + sizeof(struct side_type_raw_string
));
393 struct side_enum_mappings
{
394 side_ptr_t(const struct side_enum_mapping
) mappings
;
395 side_ptr_t(const struct side_attr
) attr
;
396 uint32_t nr_mappings
;
399 side_check_size(struct side_enum_mappings
, 40);
401 struct side_enum_bitmap_mapping
{
402 uint64_t range_begin
;
404 struct side_type_raw_string label
;
406 side_check_size(struct side_enum_bitmap_mapping
, 16 + sizeof(struct side_type_raw_string
));
408 struct side_enum_bitmap_mappings
{
409 side_ptr_t(const struct side_enum_bitmap_mapping
) mappings
;
410 side_ptr_t(const struct side_attr
) attr
;
411 uint32_t nr_mappings
;
414 side_check_size(struct side_enum_bitmap_mappings
, 40);
416 struct side_type_struct
{
417 side_ptr_t(const struct side_event_field
) fields
;
418 side_ptr_t(const struct side_attr
) attr
;
422 side_check_size(struct side_type_struct
, 40);
424 struct side_type_array
{
425 side_ptr_t(const struct side_type
) elem_type
;
426 side_ptr_t(const struct side_attr
) attr
;
430 side_check_size(struct side_type_array
, 40);
432 struct side_type_vla
{
433 side_ptr_t(const struct side_type
) elem_type
;
434 side_ptr_t(const struct side_attr
) attr
;
437 side_check_size(struct side_type_vla
, 36);
439 struct side_type_vla_visitor
{
440 side_ptr_t(const struct side_type
) elem_type
;
441 side_func_ptr_t(side_visitor_func
) visitor
;
442 side_ptr_t(const struct side_attr
) attr
;
445 side_check_size(struct side_type_vla_visitor
, 52);
447 struct side_type_enum
{
448 side_ptr_t(const struct side_enum_mappings
) mappings
;
449 side_ptr_t(const struct side_type
) elem_type
;
451 side_check_size(struct side_type_enum
, 32);
453 struct side_type_enum_bitmap
{
454 side_ptr_t(const struct side_enum_bitmap_mappings
) mappings
;
455 side_ptr_t(const struct side_type
) elem_type
;
457 side_check_size(struct side_type_enum_bitmap
, 32);
459 struct side_type_gather_bool
{
460 uint64_t offset
; /* bytes */
461 uint16_t offset_bits
; /* bits */
462 uint8_t access_mode
; /* enum side_type_gather_access_mode */
463 struct side_type_bool type
;
465 side_check_size(struct side_type_gather_bool
, 11 + sizeof(struct side_type_bool
));
467 struct side_type_gather_byte
{
468 uint64_t offset
; /* bytes */
469 uint8_t access_mode
; /* enum side_type_gather_access_mode */
470 struct side_type_byte type
;
472 side_check_size(struct side_type_gather_byte
, 9 + sizeof(struct side_type_byte
));
474 struct side_type_gather_integer
{
475 uint64_t offset
; /* bytes */
476 uint16_t offset_bits
; /* bits */
477 uint8_t access_mode
; /* enum side_type_gather_access_mode */
478 struct side_type_integer type
;
480 side_check_size(struct side_type_gather_integer
, 11 + sizeof(struct side_type_integer
));
482 struct side_type_gather_float
{
483 uint64_t offset
; /* bytes */
484 uint8_t access_mode
; /* enum side_type_gather_access_mode */
485 struct side_type_float type
;
487 side_check_size(struct side_type_gather_float
, 9 + sizeof(struct side_type_float
));
489 struct side_type_gather_string
{
490 uint64_t offset
; /* bytes */
491 uint8_t access_mode
; /* enum side_type_gather_access_mode */
492 struct side_type_string type
;
494 side_check_size(struct side_type_gather_string
, 9 + sizeof(struct side_type_string
));
496 struct side_type_gather_enum
{
497 side_ptr_t(const struct side_enum_mappings
) mappings
;
498 side_ptr_t(const struct side_type
) elem_type
;
500 side_check_size(struct side_type_gather_enum
, 32);
502 struct side_type_gather_struct
{
503 side_ptr_t(const struct side_type_struct
) type
;
504 uint64_t offset
; /* bytes */
505 uint8_t access_mode
; /* enum side_type_gather_access_mode */
506 uint32_t size
; /* bytes */
508 side_check_size(struct side_type_gather_struct
, 29);
510 struct side_type_gather_array
{
511 uint64_t offset
; /* bytes */
512 uint8_t access_mode
; /* enum side_type_gather_access_mode */
513 struct side_type_array type
;
515 side_check_size(struct side_type_gather_array
, 9 + sizeof(struct side_type_array
));
517 struct side_type_gather_vla
{
518 side_ptr_t(const struct side_type
) length_type
; /* side_length() */
519 uint64_t offset
; /* bytes */
520 uint8_t access_mode
; /* enum side_type_gather_access_mode */
521 struct side_type_vla type
;
523 side_check_size(struct side_type_gather_vla
, 25 + sizeof(struct side_type_vla
));
525 struct side_type_gather
{
527 struct side_type_gather_bool side_bool
;
528 struct side_type_gather_byte side_byte
;
529 struct side_type_gather_integer side_integer
;
530 struct side_type_gather_float side_float
;
531 struct side_type_gather_string side_string
;
532 struct side_type_gather_enum side_enum
;
533 struct side_type_gather_array side_array
;
534 struct side_type_gather_vla side_vla
;
535 struct side_type_gather_struct side_struct
;
539 side_check_size(struct side_type_gather
, 61);
542 side_enum_t(enum side_type_label
, uint16_t) type
;
544 /* Stack-copy basic types */
545 struct side_type_null side_null
;
546 struct side_type_bool side_bool
;
547 struct side_type_byte side_byte
;
548 struct side_type_string side_string
;
549 struct side_type_integer side_integer
;
550 struct side_type_float side_float
;
552 /* Stack-copy compound types */
553 struct side_type_array side_array
;
554 struct side_type_vla side_vla
;
555 struct side_type_vla_visitor side_vla_visitor
;
556 side_ptr_t(const struct side_type_struct
) side_struct
;
557 side_ptr_t(const struct side_type_variant
) side_variant
;
559 /* Stack-copy enumeration types */
560 struct side_type_enum side_enum
;
561 struct side_type_enum_bitmap side_enum_bitmap
;
564 struct side_type_gather side_gather
;
568 side_check_size(struct side_type
, 64);
570 struct side_variant_option
{
573 const struct side_type side_type
;
575 side_check_size(struct side_variant_option
, 16 + sizeof(const struct side_type
));
577 struct side_type_variant
{
578 side_ptr_t(const struct side_variant_option
) options
;
579 side_ptr_t(const struct side_attr
) attr
;
582 const struct side_type selector
;
584 side_check_size(struct side_type_variant
, 40 + sizeof(const struct side_type
));
586 struct side_event_field
{
587 side_ptr_t(const char) field_name
;
588 struct side_type side_type
;
590 side_check_size(struct side_event_field
, 16 + sizeof(struct side_type
));
592 enum side_event_flags
{
593 SIDE_EVENT_FLAG_VARIADIC
= (1 << 0),
596 union side_arg_static
{
597 /* Stack-copy basic types */
598 union side_bool_value bool_value
;
600 side_ptr_t(const void) string_value
; /* const {uint8_t, uint16_t, uint32_t} * */
601 union side_integer_value integer_value
;
602 union side_float_value float_value
;
604 /* Stack-copy compound types */
605 side_ptr_t(const struct side_arg_vec
) side_struct
;
606 side_ptr_t(const struct side_arg_variant
) side_variant
;
607 side_ptr_t(const struct side_arg_vec
) side_array
;
608 side_ptr_t(const struct side_arg_vec
) side_vla
;
609 void *side_vla_app_visitor_ctx
;
611 /* Gather basic types */
612 side_ptr_t(const void) side_bool_gather_ptr
;
613 side_ptr_t(const void) side_byte_gather_ptr
;
614 side_ptr_t(const void) side_integer_gather_ptr
;
615 side_ptr_t(const void) side_float_gather_ptr
;
616 side_ptr_t(const void) side_string_gather_ptr
;
618 /* Gather compound types */
619 side_ptr_t(const void) side_array_gather_ptr
;
620 side_ptr_t(const void) side_struct_gather_ptr
;
622 side_ptr_t(const void) ptr
;
623 side_ptr_t(const void) length_ptr
;
624 } SIDE_PACKED side_vla_gather
;
627 side_check_size(union side_arg_static
, 32);
629 struct side_arg_dynamic_vla
{
630 side_ptr_t(const struct side_arg
) sav
;
631 side_ptr_t(const struct side_attr
) attr
;
635 side_check_size(struct side_arg_dynamic_vla
, 40);
637 struct side_arg_dynamic_struct
{
638 side_ptr_t(const struct side_arg_dynamic_field
) fields
;
639 side_ptr_t(const struct side_attr
) attr
;
643 side_check_size(struct side_arg_dynamic_struct
, 40);
645 struct side_dynamic_struct_visitor
{
646 side_func_ptr_t(side_dynamic_struct_visitor_func
) visitor
;
647 side_ptr_t(void) app_ctx
;
648 side_ptr_t(const struct side_attr
) attr
;
651 side_check_size(struct side_dynamic_struct_visitor
, 52);
653 struct side_dynamic_vla_visitor
{
654 side_func_ptr_t(side_visitor_func
) visitor
;
655 side_ptr_t(void) app_ctx
;
656 side_ptr_t(const struct side_attr
) attr
;
659 side_check_size(struct side_dynamic_vla_visitor
, 52);
661 union side_arg_dynamic
{
662 /* Dynamic basic types */
663 struct side_type_null side_null
;
665 struct side_type_bool type
;
666 union side_bool_value value
;
667 } SIDE_PACKED side_bool
;
669 struct side_type_byte type
;
671 } SIDE_PACKED side_byte
;
673 struct side_type_string type
;
674 uint64_t value
; /* const char * */
675 } SIDE_PACKED side_string
;
677 struct side_type_integer type
;
678 union side_integer_value value
;
679 } SIDE_PACKED side_integer
;
681 struct side_type_float type
;
682 union side_float_value value
;
683 } SIDE_PACKED side_float
;
685 /* Dynamic compound types */
686 side_ptr_t(const struct side_arg_dynamic_struct
) side_dynamic_struct
;
687 side_ptr_t(const struct side_arg_dynamic_vla
) side_dynamic_vla
;
689 struct side_dynamic_struct_visitor side_dynamic_struct_visitor
;
690 struct side_dynamic_vla_visitor side_dynamic_vla_visitor
;
694 side_check_size(union side_arg_dynamic
, 58);
697 side_enum_t(enum side_type_label
, uint16_t) type
;
699 union side_arg_static side_static
;
700 union side_arg_dynamic side_dynamic
;
704 side_check_size(struct side_arg
, 64);
706 struct side_arg_variant
{
707 struct side_arg selector
;
708 struct side_arg option
;
710 side_check_size(struct side_arg_variant
, 128);
712 struct side_arg_vec
{
713 side_ptr_t(const struct side_arg
) sav
;
716 side_check_size(struct side_arg_vec
, 20);
718 struct side_arg_dynamic_field
{
719 side_ptr_t(const char) field_name
;
720 const struct side_arg elem
;
722 side_check_size(struct side_arg_dynamic_field
, 16 + sizeof(const struct side_arg
));
724 struct side_event_description
{
725 uint32_t struct_size
; /* Size of this structure. */
726 uint32_t version
; /* Event description ABI version. */
728 side_ptr_t(struct side_event_state
) state
;
729 side_ptr_t(const char) provider_name
;
730 side_ptr_t(const char) event_name
;
731 side_ptr_t(const struct side_event_field
) fields
;
732 side_ptr_t(const struct side_attr
) attr
;
734 uint16_t nr_side_type_label
;
735 uint16_t nr_side_attr_type
;
736 side_enum_t(enum side_loglevel
, uint32_t) loglevel
;
739 uint32_t nr_callbacks
;
740 #define side_event_description_orig_abi_last nr_callbacks
741 /* End of fields supported in the original ABI. */
743 char end
[]; /* End with a flexible array to account for extensibility. */
747 * This structure is _not_ packed to allow atomic operations on its
748 * fields. Changes to this structure must bump the "Event state ABI
749 * version" and tracers _must_ learn how to deal with this ABI,
750 * otherwise they should reject the event.
753 struct side_event_state
{
754 uint32_t version
; /* Event state ABI version. */
757 struct side_event_state_0
{
758 struct side_event_state p
; /* Required first field. */
760 side_ptr_t(const struct side_callback
) callbacks
;
761 side_ptr_t(struct side_event_description
) desc
;
764 /* Event and type attributes */
766 #define side_attr(_key, _value) \
769 .p = SIDE_PTR_INIT(_key), \
770 .unit_size = sizeof(uint8_t), \
771 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
773 .value = SIDE_PARAM(_value), \
776 #define side_attr_list(...) \
777 SIDE_COMPOUND_LITERAL(const struct side_attr, __VA_ARGS__)
779 #define side_attr_null(_val) { .type = SIDE_ATTR_TYPE_NULL }
780 #define side_attr_bool(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_BOOL), .u = { .bool_value = !!(_val) } }
781 #define side_attr_u8(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U8), .u = { .integer_value = { .side_u8 = (_val) } } }
782 #define side_attr_u16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U16), .u = { .integer_value = { .side_u16 = (_val) } } }
783 #define side_attr_u32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U32), .u = { .integer_value = { .side_u32 = (_val) } } }
784 #define side_attr_u64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U64), .u = { .integer_value = { .side_u64 = (_val) } } }
785 #define side_attr_s8(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S8), .u = { .integer_value = { .side_s8 = (_val) } } }
786 #define side_attr_s16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S16), .u = { .integer_value = { .side_s16 = (_val) } } }
787 #define side_attr_s32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S32), .u = { .integer_value = { .side_s32 = (_val) } } }
788 #define side_attr_s64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S64), .u = { .integer_value = { .side_s64 = (_val) } } }
789 #define side_attr_float_binary16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY16), .u = { .float_value = { .side_float_binary16 = (_val) } } }
790 #define side_attr_float_binary32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY32), .u = { .float_value = { .side_float_binary32 = (_val) } } }
791 #define side_attr_float_binary64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY64), .u = { .float_value = { .side_float_binary64 = (_val) } } }
792 #define side_attr_float_binary128(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY128), .u = { .float_value = { .side_float_binary128 = (_val) } } }
794 #define _side_attr_string(_val, _byte_order, _unit_size) \
796 .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_STRING), \
799 .p = SIDE_PTR_INIT(_val), \
800 .unit_size = _unit_size, \
801 .byte_order = SIDE_ENUM_INIT(_byte_order), \
806 #define side_attr_string(_val) _side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t))
807 #define side_attr_string16(_val) _side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t))
808 #define side_attr_string32(_val) _side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t))
810 /* Stack-copy enumeration type definitions */
812 #define side_define_enum(_identifier, _mappings, _attr...) \
813 const struct side_enum_mappings _identifier = { \
814 .mappings = SIDE_PTR_INIT(_mappings), \
815 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
816 .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \
817 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
820 #define side_enum_mapping_list(...) \
821 SIDE_COMPOUND_LITERAL(const struct side_enum_mapping, __VA_ARGS__)
823 #define side_enum_mapping_range(_label, _begin, _end) \
825 .range_begin = _begin, \
828 .p = SIDE_PTR_INIT(_label), \
829 .unit_size = sizeof(uint8_t), \
830 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
834 #define side_enum_mapping_value(_label, _value) \
836 .range_begin = _value, \
837 .range_end = _value, \
839 .p = SIDE_PTR_INIT(_label), \
840 .unit_size = sizeof(uint8_t), \
841 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
845 #define side_define_enum_bitmap(_identifier, _mappings, _attr...) \
846 const struct side_enum_bitmap_mappings _identifier = { \
847 .mappings = SIDE_PTR_INIT(_mappings), \
848 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
849 .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \
850 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
853 #define side_enum_bitmap_mapping_list(...) \
854 SIDE_COMPOUND_LITERAL(const struct side_enum_bitmap_mapping, __VA_ARGS__)
856 #define side_enum_bitmap_mapping_range(_label, _begin, _end) \
858 .range_begin = _begin, \
861 .p = SIDE_PTR_INIT(_label), \
862 .unit_size = sizeof(uint8_t), \
863 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
867 #define side_enum_bitmap_mapping_value(_label, _value) \
869 .range_begin = _value, \
870 .range_end = _value, \
872 .p = SIDE_PTR_INIT(_label), \
873 .unit_size = sizeof(uint8_t), \
874 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
878 /* Stack-copy field and type definitions */
880 #define side_type_null(_attr...) \
882 .type = SIDE_ENUM_INIT(SIDE_TYPE_NULL), \
885 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
886 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
891 #define side_type_bool(_attr...) \
893 .type = SIDE_ENUM_INIT(SIDE_TYPE_BOOL), \
896 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
897 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
898 .bool_size = sizeof(uint8_t), \
900 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
905 #define side_type_byte(_attr...) \
907 .type = SIDE_ENUM_INIT(SIDE_TYPE_BYTE), \
910 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
911 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
916 #define _side_type_string(_type, _byte_order, _unit_size, _attr) \
918 .type = SIDE_ENUM_INIT(_type), \
921 .attr = SIDE_PTR_INIT(_attr), \
922 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
923 .unit_size = _unit_size, \
924 .byte_order = SIDE_ENUM_INIT(_byte_order), \
929 #define side_type_dynamic() \
931 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC), \
934 #define _side_type_integer(_type, _signedness, _byte_order, _integer_size, _len_bits, _attr) \
936 .type = SIDE_ENUM_INIT(_type), \
939 .attr = SIDE_PTR_INIT(_attr), \
940 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
941 .integer_size = _integer_size, \
942 .len_bits = _len_bits, \
943 .signedness = _signedness, \
944 .byte_order = SIDE_ENUM_INIT(_byte_order), \
949 #define _side_type_float(_type, _byte_order, _float_size, _attr) \
951 .type = SIDE_ENUM_INIT(_type), \
954 .attr = SIDE_PTR_INIT(_attr), \
955 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
956 .float_size = _float_size, \
957 .byte_order = SIDE_ENUM_INIT(_byte_order), \
962 #define _side_field(_name, _type) \
964 .field_name = SIDE_PTR_INIT(_name), \
965 .side_type = _type, \
968 #define side_option_range(_range_begin, _range_end, _type) \
970 .range_begin = _range_begin, \
971 .range_end = _range_end, \
972 .side_type = _type, \
975 #define side_option(_value, _type) \
976 side_option_range(_value, _value, SIDE_PARAM(_type))
979 #define side_type_u8(_attr...) _side_type_integer(SIDE_TYPE_U8, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
980 #define side_type_u16(_attr...) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
981 #define side_type_u32(_attr...) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
982 #define side_type_u64(_attr...) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
983 #define side_type_s8(_attr...) _side_type_integer(SIDE_TYPE_S8, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int8_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
984 #define side_type_s16(_attr...) _side_type_integer(SIDE_TYPE_S16, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
985 #define side_type_s32(_attr...) _side_type_integer(SIDE_TYPE_S32, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
986 #define side_type_s64(_attr...) _side_type_integer(SIDE_TYPE_S64, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
987 #define side_type_pointer(_attr...) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
988 #define side_type_float_binary16(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
989 #define side_type_float_binary32(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
990 #define side_type_float_binary64(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
991 #define side_type_float_binary128(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
992 #define side_type_string(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF8, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
993 #define side_type_string16(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
994 #define side_type_string32(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
996 #define side_field_null(_name, _attr...) _side_field(_name, side_type_null(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
997 #define side_field_bool(_name, _attr...) _side_field(_name, side_type_bool(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
998 #define side_field_u8(_name, _attr...) _side_field(_name, side_type_u8(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
999 #define side_field_u16(_name, _attr...) _side_field(_name, side_type_u16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1000 #define side_field_u32(_name, _attr...) _side_field(_name, side_type_u32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1001 #define side_field_u64(_name, _attr...) _side_field(_name, side_type_u64(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1002 #define side_field_s8(_name, _attr...) _side_field(_name, side_type_s8(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1003 #define side_field_s16(_name, _attr...) _side_field(_name, side_type_s16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1004 #define side_field_s32(_name, _attr...) _side_field(_name, side_type_s32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1005 #define side_field_s64(_name, _attr...) _side_field(_name, side_type_s64(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1006 #define side_field_byte(_name, _attr...) _side_field(_name, side_type_byte(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1007 #define side_field_pointer(_name, _attr...) _side_field(_name, side_type_pointer(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1008 #define side_field_float_binary16(_name, _attr...) _side_field(_name, side_type_float_binary16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1009 #define side_field_float_binary32(_name, _attr...) _side_field(_name, side_type_float_binary32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1010 #define side_field_float_binary64(_name, _attr...) _side_field(_name, side_type_float_binary64(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1011 #define side_field_float_binary128(_name, _attr...) _side_field(_name, side_type_float_binary128(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1012 #define side_field_string(_name, _attr...) _side_field(_name, side_type_string(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1013 #define side_field_string16(_name, _attr...) _side_field(_name, side_type_string16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1014 #define side_field_string32(_name, _attr...) _side_field(_name, side_type_string32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1015 #define side_field_dynamic(_name) _side_field(_name, side_type_dynamic())
1018 #define side_type_u16_le(_attr...) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1019 #define side_type_u32_le(_attr...) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1020 #define side_type_u64_le(_attr...) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1021 #define side_type_s16_le(_attr...) _side_type_integer(SIDE_TYPE_S16, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1022 #define side_type_s32_le(_attr...) _side_type_integer(SIDE_TYPE_S32, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1023 #define side_type_s64_le(_attr...) _side_type_integer(SIDE_TYPE_S64, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1024 #define side_type_pointer_le(_attr...) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1025 #define side_type_float_binary16_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1026 #define side_type_float_binary32_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1027 #define side_type_float_binary64_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1028 #define side_type_float_binary128_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1029 #define side_type_string16_le(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1030 #define side_type_string32_le(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1032 #define side_field_u16_le(_name, _attr...) _side_field(_name, side_type_u16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1033 #define side_field_u32_le(_name, _attr...) _side_field(_name, side_type_u32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1034 #define side_field_u64_le(_name, _attr...) _side_field(_name, side_type_u64_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1035 #define side_field_s16_le(_name, _attr...) _side_field(_name, side_type_s16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1036 #define side_field_s32_le(_name, _attr...) _side_field(_name, side_type_s32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1037 #define side_field_s64_le(_name, _attr...) _side_field(_name, side_type_s64_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1038 #define side_field_pointer_le(_name, _attr...) _side_field(_name, side_type_pointer_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1039 #define side_field_float_binary16_le(_name, _attr...) _side_field(_name, side_type_float_binary16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1040 #define side_field_float_binary32_le(_name, _attr...) _side_field(_name, side_type_float_binary32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1041 #define side_field_float_binary64_le(_name, _attr...) _side_field(_name, side_type_float_binary64_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1042 #define side_field_float_binary128_le(_name, _attr...) _side_field(_name, side_type_float_binary128_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1043 #define side_field_string16_le(_name, _attr...) _side_field(_name, side_type_string16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1044 #define side_field_string32_le(_name, _attr...) _side_field(_name, side_type_string32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1047 #define side_type_u16_be(_attr...) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1048 #define side_type_u32_be(_attr...) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1049 #define side_type_u64_be(_attr...) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1050 #define side_type_s16_be(_attr...) _side_type_integer(SIDE_TYPE_S16, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1051 #define side_type_s32_be(_attr...) _side_type_integer(SIDE_TYPE_S32, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1052 #define side_type_s64_be(_attr...) _side_type_integer(SIDE_TYPE_S64, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1053 #define side_type_pointer_be(_attr...) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1054 #define side_type_float_binary16_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1055 #define side_type_float_binary32_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1056 #define side_type_float_binary64_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1057 #define side_type_float_binary128_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1058 #define side_type_string16_be(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1059 #define side_type_string32_be(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1061 #define side_field_u16_be(_name, _attr...) _side_field(_name, side_type_u16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1062 #define side_field_u32_be(_name, _attr...) _side_field(_name, side_type_u32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1063 #define side_field_u64_be(_name, _attr...) _side_field(_name, side_type_u64_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1064 #define side_field_s16_be(_name, _attr...) _side_field(_name, side_type_s16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1065 #define side_field_s32_be(_name, _attr...) _side_field(_name, side_type_s32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1066 #define side_field_s64_be(_name, _attr...) _side_field(_name, side_type_s64_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1067 #define side_field_pointer_be(_name, _attr...) _side_field(_name, side_type_pointer_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1068 #define side_field_float_binary16_be(_name, _attr...) _side_field(_name, side_type_float_binary16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1069 #define side_field_float_binary32_be(_name, _attr...) _side_field(_name, side_type_float_binary32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1070 #define side_field_float_binary64_be(_name, _attr...) _side_field(_name, side_type_float_binary64_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1071 #define side_field_float_binary128_be(_name, _attr...) _side_field(_name, side_type_float_binary128_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1072 #define side_field_string16_be(_name, _attr...) _side_field(_name, side_type_string16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1073 #define side_field_string32_be(_name, _attr...) _side_field(_name, side_type_string32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1075 #define side_type_enum(_mappings, _elem_type) \
1077 .type = SIDE_ENUM_INIT(SIDE_TYPE_ENUM), \
1080 .mappings = SIDE_PTR_INIT(_mappings), \
1081 .elem_type = SIDE_PTR_INIT(_elem_type), \
1085 #define side_field_enum(_name, _mappings, _elem_type) \
1086 _side_field(_name, side_type_enum(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type)))
1088 #define side_type_enum_bitmap(_mappings, _elem_type) \
1090 .type = SIDE_ENUM_INIT(SIDE_TYPE_ENUM_BITMAP), \
1092 .side_enum_bitmap = { \
1093 .mappings = SIDE_PTR_INIT(_mappings), \
1094 .elem_type = SIDE_PTR_INIT(_elem_type), \
1098 #define side_field_enum_bitmap(_name, _mappings, _elem_type) \
1099 _side_field(_name, side_type_enum_bitmap(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type)))
1101 #define side_type_struct(_struct) \
1103 .type = SIDE_ENUM_INIT(SIDE_TYPE_STRUCT), \
1105 .side_struct = SIDE_PTR_INIT(_struct), \
1108 #define side_field_struct(_name, _struct) \
1109 _side_field(_name, side_type_struct(SIDE_PARAM(_struct)))
1111 #define _side_type_struct_define(_fields, _attr) \
1113 .fields = SIDE_PTR_INIT(_fields), \
1114 .attr = SIDE_PTR_INIT(_attr), \
1115 .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
1116 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1119 #define side_define_struct(_identifier, _fields, _attr...) \
1120 const struct side_type_struct _identifier = _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1122 #define side_struct_literal(_fields, _attr...) \
1123 SIDE_COMPOUND_LITERAL(const struct side_type_struct, \
1124 _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1126 #define side_type_variant(_variant) \
1128 .type = SIDE_ENUM_INIT(SIDE_TYPE_VARIANT), \
1130 .side_variant = SIDE_PTR_INIT(_variant), \
1133 #define side_field_variant(_name, _variant) \
1134 _side_field(_name, side_type_variant(SIDE_PARAM(_variant)))
1136 #define _side_type_variant_define(_selector, _options, _attr) \
1138 .selector = _selector, \
1139 .options = SIDE_PTR_INIT(_options), \
1140 .attr = SIDE_PTR_INIT(_attr), \
1141 .nr_options = SIDE_ARRAY_SIZE(SIDE_PARAM(_options)), \
1142 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1145 #define side_define_variant(_identifier, _selector, _options, _attr...) \
1146 const struct side_type_variant _identifier = \
1147 _side_type_variant_define(SIDE_PARAM(_selector), SIDE_PARAM(_options), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1149 #define side_variant_literal(_selector, _options, _attr...) \
1150 SIDE_COMPOUND_LITERAL(const struct side_type_variant, \
1151 _side_type_variant_define(SIDE_PARAM(_selector), SIDE_PARAM(_options), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1153 #define side_type_array(_elem_type, _length, _attr...) \
1155 .type = SIDE_ENUM_INIT(SIDE_TYPE_ARRAY), \
1158 .elem_type = SIDE_PTR_INIT(_elem_type), \
1159 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1160 .length = _length, \
1161 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1165 #define side_field_array(_name, _elem_type, _length, _attr...) \
1166 _side_field(_name, side_type_array(SIDE_PARAM(_elem_type), _length, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1168 #define side_type_vla(_elem_type, _attr...) \
1170 .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA), \
1173 .elem_type = SIDE_PTR_INIT(_elem_type), \
1174 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1175 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1179 #define side_field_vla(_name, _elem_type, _attr...) \
1180 _side_field(_name, side_type_vla(SIDE_PARAM(_elem_type), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1182 #define side_type_vla_visitor(_elem_type, _visitor, _attr...) \
1184 .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA_VISITOR), \
1186 .side_vla_visitor = { \
1187 .elem_type = SIDE_PTR_INIT(_elem_type), \
1188 .visitor = SIDE_PTR_INIT(_visitor), \
1189 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1190 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1194 #define side_field_vla_visitor(_name, _elem_type, _visitor, _attr...) \
1195 _side_field(_name, side_type_vla_visitor(SIDE_PARAM(_elem_type), _visitor, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1197 /* Gather field and type definitions */
1199 #define side_type_gather_byte(_offset, _access_mode, _attr...) \
1201 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BYTE), \
1206 .offset = _offset, \
1207 .access_mode = _access_mode, \
1209 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1210 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1217 #define side_field_gather_byte(_name, _offset, _access_mode, _attr...) \
1218 _side_field(_name, side_type_gather_byte(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1220 #define _side_type_gather_bool(_byte_order, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1222 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BOOL), \
1227 .offset = _offset, \
1228 .access_mode = _access_mode, \
1230 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1231 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1232 .bool_size = _bool_size, \
1233 .len_bits = _len_bits, \
1234 .byte_order = SIDE_ENUM_INIT(_byte_order), \
1236 .offset_bits = _offset_bits, \
1242 #define side_type_gather_bool(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1243 _side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_HOST, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1244 #define side_type_gather_bool_le(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1245 _side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_LE, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1246 #define side_type_gather_bool_be(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1247 _side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_BE, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1249 #define side_field_gather_bool(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1250 _side_field(_name, side_type_gather_bool(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))))
1251 #define side_field_gather_bool_le(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1252 _side_field(_name, side_type_gather_bool_le(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))))
1253 #define side_field_gather_bool_be(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1254 _side_field(_name, side_type_gather_bool_be(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))))
1256 #define _side_type_gather_integer(_type, _signedness, _byte_order, _offset, \
1257 _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1259 .type = SIDE_ENUM_INIT(_type), \
1264 .offset = _offset, \
1265 .access_mode = _access_mode, \
1267 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1268 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1269 .integer_size = _integer_size, \
1270 .len_bits = _len_bits, \
1271 .signedness = _signedness, \
1272 .byte_order = SIDE_ENUM_INIT(_byte_order), \
1274 .offset_bits = _offset_bits, \
1281 #define side_type_gather_unsigned_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1282 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_HOST, \
1283 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1284 #define side_type_gather_signed_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1285 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_HOST, \
1286 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1288 #define side_type_gather_unsigned_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1289 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_LE, \
1290 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1291 #define side_type_gather_signed_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1292 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_LE, \
1293 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1295 #define side_type_gather_unsigned_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1296 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_BE, \
1297 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1298 #define side_type_gather_signed_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1299 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_BE, \
1300 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1302 #define side_field_gather_unsigned_integer(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1303 _side_field(_name, side_type_gather_unsigned_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1304 #define side_field_gather_signed_integer(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1305 _side_field(_name, side_type_gather_signed_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1307 #define side_field_gather_unsigned_integer_le(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1308 _side_field(_name, side_type_gather_unsigned_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1309 #define side_field_gather_signed_integer_le(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1310 _side_field(_name, side_type_gather_signed_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1312 #define side_field_gather_unsigned_integer_be(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1313 _side_field(_name, side_type_gather_unsigned_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1314 #define side_field_gather_signed_integer_be(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1315 _side_field(_name, side_type_gather_signed_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1317 #define side_type_gather_pointer(_offset, _access_mode, _attr...) \
1318 _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_HOST, \
1319 _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1320 #define side_field_gather_pointer(_name, _offset, _access_mode, _attr...) \
1321 _side_field(_name, side_type_gather_pointer(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1323 #define side_type_gather_pointer_le(_offset, _access_mode, _attr...) \
1324 _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_LE, \
1325 _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1326 #define side_field_gather_pointer_le(_name, _offset, _access_mode, _attr...) \
1327 _side_field(_name, side_type_gather_pointer_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1329 #define side_type_gather_pointer_be(_offset, _access_mode, _attr...) \
1330 _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_BE, \
1331 _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1332 #define side_field_gather_pointer_be(_name, _offset, _access_mode, _attr...) \
1333 _side_field(_name, side_type_gather_pointer_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1335 #define _side_type_gather_float(_byte_order, _offset, _float_size, _access_mode, _attr...) \
1337 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_FLOAT), \
1342 .offset = _offset, \
1343 .access_mode = _access_mode, \
1345 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1346 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1347 .float_size = _float_size, \
1348 .byte_order = SIDE_ENUM_INIT(_byte_order), \
1356 #define side_type_gather_float(_offset, _float_size, _access_mode, _attr...) \
1357 _side_type_gather_float(SIDE_TYPE_FLOAT_WORD_ORDER_HOST, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1358 #define side_type_gather_float_le(_offset, _float_size, _access_mode, _attr...) \
1359 _side_type_gather_float(SIDE_TYPE_BYTE_ORDER_LE, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1360 #define side_type_gather_float_be(_offset, _float_size, _access_mode, _attr...) \
1361 _side_type_gather_float(SIDE_TYPE_BYTE_ORDER_BE, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1363 #define side_field_gather_float(_name, _offset, _float_size, _access_mode, _attr...) \
1364 _side_field(_name, side_type_gather_float(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1365 #define side_field_gather_float_le(_name, _offset, _float_size, _access_mode, _attr...) \
1366 _side_field(_name, side_type_gather_float_le(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1367 #define side_field_gather_float_be(_name, _offset, _float_size, _access_mode, _attr...) \
1368 _side_field(_name, side_type_gather_float_be(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1370 #define _side_type_gather_string(_offset, _byte_order, _unit_size, _access_mode, _attr...) \
1372 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRING), \
1377 .offset = _offset, \
1378 .access_mode = _access_mode, \
1380 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1381 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1382 .unit_size = _unit_size, \
1383 .byte_order = SIDE_ENUM_INIT(_byte_order), \
1390 #define side_type_gather_string(_offset, _access_mode, _attr...) \
1391 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1392 #define side_field_gather_string(_name, _offset, _access_mode, _attr...) \
1393 _side_field(_name, side_type_gather_string(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1395 #define side_type_gather_string16(_offset, _access_mode, _attr...) \
1396 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1397 #define side_type_gather_string16_le(_offset, _access_mode, _attr...) \
1398 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1399 #define side_type_gather_string16_be(_offset, _access_mode, _attr...) \
1400 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1402 #define side_field_gather_string16(_name, _offset, _access_mode, _attr...) \
1403 _side_field(_name, side_type_gather_string16(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1404 #define side_field_gather_string16_le(_name, _offset, _access_mode, _attr...) \
1405 _side_field(_name, side_type_gather_string16_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1406 #define side_field_gather_string16_be(_name, _offset, _access_mode, _attr...) \
1407 _side_field(_name, side_type_gather_string16_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1409 #define side_type_gather_string32(_offset, _access_mode, _attr...) \
1410 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1411 #define side_type_gather_string32_le(_offset, _access_mode, _attr...) \
1412 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1413 #define side_type_gather_string32_be(_offset, _access_mode, _attr...) \
1414 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1416 #define side_field_gather_string32(_name, _offset, _access_mode, _attr...) \
1417 _side_field(_name, side_type_gather_string32(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1418 #define side_field_gather_string32_le(_name, _offset, _access_mode, _attr...) \
1419 _side_field(_name, side_type_gather_string32_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1420 #define side_field_gather_string32_be(_name, _offset, _access_mode, _attr...) \
1421 _side_field(_name, side_type_gather_string32_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1423 #define side_type_gather_enum(_mappings, _elem_type) \
1425 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_ENUM), \
1428 .mappings = SIDE_PTR_INIT(_mappings), \
1429 .elem_type = SIDE_PTR_INIT(_elem_type), \
1433 #define side_field_gather_enum(_name, _mappings, _elem_type) \
1434 _side_field(_name, side_type_gather_enum(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type)))
1436 #define side_type_gather_struct(_struct_gather, _offset, _size, _access_mode) \
1438 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRUCT), \
1443 .offset = _offset, \
1444 .access_mode = _access_mode, \
1445 .type = SIDE_PTR_INIT(_struct_gather), \
1452 #define side_field_gather_struct(_name, _struct_gather, _offset, _size, _access_mode) \
1453 _side_field(_name, side_type_gather_struct(SIDE_PARAM(_struct_gather), _offset, _size, _access_mode))
1455 #define side_type_gather_array(_elem_type_gather, _length, _offset, _access_mode, _attr...) \
1457 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_ARRAY), \
1462 .offset = _offset, \
1463 .access_mode = _access_mode, \
1465 .elem_type = SIDE_PTR_INIT(_elem_type_gather), \
1466 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1467 .length = _length, \
1468 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1475 #define side_field_gather_array(_name, _elem_type, _length, _offset, _access_mode, _attr...) \
1476 _side_field(_name, side_type_gather_array(SIDE_PARAM(_elem_type), _length, _offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1478 #define side_type_gather_vla(_elem_type_gather, _offset, _access_mode, _length_type_gather, _attr...) \
1480 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_VLA), \
1485 .length_type = SIDE_PTR_INIT(_length_type_gather), \
1486 .offset = _offset, \
1487 .access_mode = _access_mode, \
1489 .elem_type = SIDE_PTR_INIT(_elem_type_gather), \
1490 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1491 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1498 #define side_field_gather_vla(_name, _elem_type_gather, _offset, _access_mode, _length_type_gather, _attr...) \
1499 _side_field(_name, side_type_gather_vla(SIDE_PARAM(_elem_type_gather), _offset, _access_mode, SIDE_PARAM(_length_type_gather), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1501 #define side_elem(...) \
1502 SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__)
1504 #define side_length(...) \
1505 SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__)
1507 #define side_field_list(...) \
1508 SIDE_COMPOUND_LITERAL(const struct side_event_field, __VA_ARGS__)
1510 #define side_option_list(...) \
1511 SIDE_COMPOUND_LITERAL(const struct side_variant_option, __VA_ARGS__)
1513 /* Stack-copy field arguments */
1515 #define side_arg_null(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_NULL) }
1516 #define side_arg_bool(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_BOOL), .u = { .side_static = { .bool_value = { .side_bool8 = !!(_val) } } } }
1517 #define side_arg_byte(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_BYTE), .u = { .side_static = { .byte_value = (_val) } } }
1518 #define side_arg_string(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF8), .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } }
1519 #define side_arg_string16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF16), .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } }
1520 #define side_arg_string32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF32), .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } }
1522 #define side_arg_u8(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U8), .u = { .side_static = { .integer_value = { .side_u8 = (_val) } } } }
1523 #define side_arg_u16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U16), .u = { .side_static = { .integer_value = { .side_u16 = (_val) } } } }
1524 #define side_arg_u32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U32), .u = { .side_static = { .integer_value = { .side_u32 = (_val) } } } }
1525 #define side_arg_u64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U64), .u = { .side_static = { .integer_value = { .side_u64 = (_val) } } } }
1526 #define side_arg_s8(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S8), .u = { .side_static = { .integer_value = { .side_s8 = (_val) } } } }
1527 #define side_arg_s16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S16), .u = { .side_static = { .integer_value = { .side_s16 = (_val) } } } }
1528 #define side_arg_s32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S32), .u = { .side_static = { .integer_value = { .side_s32 = (_val) } } } }
1529 #define side_arg_s64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S64), .u = { .side_static = { .integer_value = { .side_s64 = (_val) } } } }
1530 #define side_arg_pointer(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_POINTER), .u = { .side_static = { .integer_value = { .side_uptr = (uintptr_t) (_val) } } } }
1531 #define side_arg_float_binary16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY16), .u = { .side_static = { .float_value = { .side_float_binary16 = (_val) } } } }
1532 #define side_arg_float_binary32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY32), .u = { .side_static = { .float_value = { .side_float_binary32 = (_val) } } } }
1533 #define side_arg_float_binary64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY64), .u = { .side_static = { .float_value = { .side_float_binary64 = (_val) } } } }
1534 #define side_arg_float_binary128(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY128), .u = { .side_static = { .float_value = { .side_float_binary128 = (_val) } } } }
1536 #define side_arg_struct(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRUCT), .u = { .side_static = { .side_struct = SIDE_PTR_INIT(_side_type) } } }
1538 #define side_arg_define_variant(_identifier, _selector_val, _option) \
1539 const struct side_arg_variant _identifier = { \
1540 .selector = _selector_val, \
1541 .option = _option, \
1543 #define side_arg_variant(_side_variant) \
1545 .type = SIDE_ENUM_INIT(SIDE_TYPE_VARIANT), \
1548 .side_variant = SIDE_PTR_INIT(_side_variant), \
1553 #define side_arg_array(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_ARRAY), .u = { .side_static = { .side_array = SIDE_PTR_INIT(_side_type) } } }
1554 #define side_arg_vla(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA), .u = { .side_static = { .side_vla = SIDE_PTR_INIT(_side_type) } } }
1555 #define side_arg_vla_visitor(_ctx) { .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA_VISITOR), .u = { .side_static = { .side_vla_app_visitor_ctx = (_ctx) } } }
1557 /* Gather field arguments */
1559 #define side_arg_gather_bool(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BOOL), .u = { .side_static = { .side_bool_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
1560 #define side_arg_gather_byte(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BYTE), .u = { .side_static = { .side_byte_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
1561 #define side_arg_gather_pointer(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_POINTER), .u = { .side_static = { .side_integer_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
1562 #define side_arg_gather_integer(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_INTEGER), .u = { .side_static = { .side_integer_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
1563 #define side_arg_gather_float(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_FLOAT), .u = { .side_static = { .side_float_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
1564 #define side_arg_gather_string(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRING), .u = { .side_static = { .side_string_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
1565 #define side_arg_gather_struct(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRUCT), .u = { .side_static = { .side_struct_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
1566 #define side_arg_gather_array(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_ARRAY), .u = { .side_static = { .side_array_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
1567 #define side_arg_gather_vla(_ptr, _length_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_VLA), .u = { .side_static = { .side_vla_gather = { .ptr = SIDE_PTR_INIT(_ptr), .length_ptr = SIDE_PTR_INIT(_length_ptr) } } } }
1569 /* Dynamic field arguments */
1571 #define side_arg_dynamic_null(_attr...) \
1573 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_NULL), \
1577 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1578 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1584 #define side_arg_dynamic_bool(_val, _attr...) \
1586 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_BOOL), \
1591 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1592 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1593 .bool_size = sizeof(uint8_t), \
1595 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
1598 .side_bool8 = !!(_val), \
1605 #define side_arg_dynamic_byte(_val, _attr...) \
1607 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_BYTE), \
1612 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1613 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1621 #define _side_arg_dynamic_string(_val, _byte_order, _unit_size, _attr...) \
1623 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRING), \
1628 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1629 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1630 .unit_size = _unit_size, \
1631 .byte_order = SIDE_ENUM_INIT(_byte_order), \
1633 .value = (uintptr_t) (_val), \
1638 #define side_arg_dynamic_string(_val, _attr...) \
1639 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1640 #define side_arg_dynamic_string16(_val, _attr...) \
1641 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1642 #define side_arg_dynamic_string16_le(_val, _attr...) \
1643 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1644 #define side_arg_dynamic_string16_be(_val, _attr...) \
1645 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1646 #define side_arg_dynamic_string32(_val, _attr...) \
1647 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1648 #define side_arg_dynamic_string32_le(_val, _attr...) \
1649 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1650 #define side_arg_dynamic_string32_be(_val, _attr...) \
1651 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1653 #define _side_arg_dynamic_integer(_field, _val, _type, _signedness, _byte_order, _integer_size, _len_bits, _attr...) \
1655 .type = SIDE_ENUM_INIT(_type), \
1660 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1661 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1662 .integer_size = _integer_size, \
1663 .len_bits = _len_bits, \
1664 .signedness = _signedness, \
1665 .byte_order = SIDE_ENUM_INIT(_byte_order), \
1675 #define side_arg_dynamic_u8(_val, _attr...) \
1676 _side_arg_dynamic_integer(.side_u8, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1677 #define side_arg_dynamic_s8(_val, _attr...) \
1678 _side_arg_dynamic_integer(.side_s8, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int8_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1680 #define _side_arg_dynamic_u16(_val, _byte_order, _attr...) \
1681 _side_arg_dynamic_integer(.side_u16, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1682 #define _side_arg_dynamic_u32(_val, _byte_order, _attr...) \
1683 _side_arg_dynamic_integer(.side_u32, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1684 #define _side_arg_dynamic_u64(_val, _byte_order, _attr...) \
1685 _side_arg_dynamic_integer(.side_u64, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1687 #define _side_arg_dynamic_s16(_val, _byte_order, _attr...) \
1688 _side_arg_dynamic_integer(.side_s16, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1689 #define _side_arg_dynamic_s32(_val, _byte_order, _attr...) \
1690 _side_arg_dynamic_integer(.side_s32, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1691 #define _side_arg_dynamic_s64(_val, _byte_order, _attr...) \
1692 _side_arg_dynamic_integer(.side_s64, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1694 #define _side_arg_dynamic_pointer(_val, _byte_order, _attr...) \
1695 _side_arg_dynamic_integer(.side_uptr, (uintptr_t) (_val), SIDE_TYPE_DYNAMIC_POINTER, false, _byte_order, \
1696 sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1698 #define _side_arg_dynamic_float(_field, _val, _type, _byte_order, _float_size, _attr...) \
1700 .type = SIDE_ENUM_INIT(_type), \
1705 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1706 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1707 .float_size = _float_size, \
1708 .byte_order = SIDE_ENUM_INIT(_byte_order), \
1718 #define _side_arg_dynamic_float_binary16(_val, _byte_order, _attr...) \
1719 _side_arg_dynamic_float(.side_float_binary16, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1720 #define _side_arg_dynamic_float_binary32(_val, _byte_order, _attr...) \
1721 _side_arg_dynamic_float(.side_float_binary32, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1722 #define _side_arg_dynamic_float_binary64(_val, _byte_order, _attr...) \
1723 _side_arg_dynamic_float(.side_float_binary64, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1724 #define _side_arg_dynamic_float_binary128(_val, _byte_order, _attr...) \
1725 _side_arg_dynamic_float(.side_float_binary128, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1728 #define side_arg_dynamic_u16(_val, _attr...) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1729 #define side_arg_dynamic_u32(_val, _attr...) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1730 #define side_arg_dynamic_u64(_val, _attr...) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1731 #define side_arg_dynamic_s16(_val, _attr...) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1732 #define side_arg_dynamic_s32(_val, _attr...) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1733 #define side_arg_dynamic_s64(_val, _attr...) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1734 #define side_arg_dynamic_pointer(_val, _attr...) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1735 #define side_arg_dynamic_float_binary16(_val, _attr...) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1736 #define side_arg_dynamic_float_binary32(_val, _attr...) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1737 #define side_arg_dynamic_float_binary64(_val, _attr...) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1738 #define side_arg_dynamic_float_binary128(_val, _attr...) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1741 #define side_arg_dynamic_u16_le(_val, _attr...) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1742 #define side_arg_dynamic_u32_le(_val, _attr...) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1743 #define side_arg_dynamic_u64_le(_val, _attr...) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1744 #define side_arg_dynamic_s16_le(_val, _attr...) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1745 #define side_arg_dynamic_s32_le(_val, _attr...) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1746 #define side_arg_dynamic_s64_le(_val, _attr...) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1747 #define side_arg_dynamic_pointer_le(_val, _attr...) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1748 #define side_arg_dynamic_float_binary16_le(_val, _attr...) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1749 #define side_arg_dynamic_float_binary32_le(_val, _attr...) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1750 #define side_arg_dynamic_float_binary64_le(_val, _attr...) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1751 #define side_arg_dynamic_float_binary128_le(_val, _attr...) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1754 #define side_arg_dynamic_u16_be(_val, _attr...) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1755 #define side_arg_dynamic_u32_be(_val, _attr...) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1756 #define side_arg_dynamic_u64_be(_val, _attr...) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1757 #define side_arg_dynamic_s16_be(_val, _attr...) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1758 #define side_arg_dynamic_s32_be(_val, _attr...) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1759 #define side_arg_dynamic_s64_be(_val, _attr...) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1760 #define side_arg_dynamic_pointer_be(_val, _attr...) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1761 #define side_arg_dynamic_float_binary16_be(_val, _attr...) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1762 #define side_arg_dynamic_float_binary32_be(_val, _attr...) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1763 #define side_arg_dynamic_float_binary64_be(_val, _attr...) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1764 #define side_arg_dynamic_float_binary128_be(_val, _attr...) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1766 #define side_arg_dynamic_vla(_vla) \
1768 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_VLA), \
1771 .side_dynamic_vla = SIDE_PTR_INIT(_vla), \
1776 #define side_arg_dynamic_vla_visitor(_dynamic_vla_visitor, _ctx, _attr...) \
1778 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_VLA_VISITOR), \
1781 .side_dynamic_vla_visitor = { \
1782 .app_ctx = SIDE_PTR_INIT(_ctx), \
1783 .visitor = SIDE_PTR_INIT(_dynamic_vla_visitor), \
1784 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1785 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1791 #define side_arg_dynamic_struct(_struct) \
1793 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRUCT), \
1796 .side_dynamic_struct = SIDE_PTR_INIT(_struct), \
1801 #define side_arg_dynamic_struct_visitor(_dynamic_struct_visitor, _ctx, _attr...) \
1803 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRUCT_VISITOR), \
1806 .side_dynamic_struct_visitor = { \
1807 .app_ctx = SIDE_PTR_INIT(_ctx), \
1808 .visitor = SIDE_PTR_INIT(_dynamic_struct_visitor), \
1809 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1810 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1816 #define side_arg_dynamic_define_vec(_identifier, _sav, _attr...) \
1817 const struct side_arg _identifier##_vec[] = { _sav }; \
1818 const struct side_arg_dynamic_vla _identifier = { \
1819 .sav = SIDE_PTR_INIT(_identifier##_vec), \
1820 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1821 .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
1822 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1825 #define side_arg_dynamic_define_struct(_identifier, _struct_fields, _attr...) \
1826 const struct side_arg_dynamic_field _identifier##_fields[] = { _struct_fields }; \
1827 const struct side_arg_dynamic_struct _identifier = { \
1828 .fields = SIDE_PTR_INIT(_identifier##_fields), \
1829 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1830 .len = SIDE_ARRAY_SIZE(_identifier##_fields), \
1831 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1834 #define side_arg_define_vec(_identifier, _sav) \
1835 const struct side_arg _identifier##_vec[] = { _sav }; \
1836 const struct side_arg_vec _identifier = { \
1837 .sav = SIDE_PTR_INIT(_identifier##_vec), \
1838 .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
1841 #define side_arg_dynamic_field(_name, _elem) \
1843 .field_name = SIDE_PTR_INIT(_name), \
1848 * Event instrumentation description registration, runtime enabled state
1849 * check, and instrumentation invocation.
1852 #define side_arg_list(...) __VA_ARGS__
1854 #define side_event_cond(_identifier) \
1855 if (side_unlikely(__atomic_load_n(&side_event_state__##_identifier.enabled, \
1858 #define side_event_call(_identifier, _sav) \
1860 const struct side_arg side_sav[] = { _sav }; \
1861 const struct side_arg_vec side_arg_vec = { \
1862 .sav = SIDE_PTR_INIT(side_sav), \
1863 .len = SIDE_ARRAY_SIZE(side_sav), \
1865 side_call(&(side_event_state__##_identifier).p, &side_arg_vec); \
1868 #define side_event(_identifier, _sav) \
1869 side_event_cond(_identifier) \
1870 side_event_call(_identifier, SIDE_PARAM(_sav))
1872 #define side_event_call_variadic(_identifier, _sav, _var_fields, _attr...) \
1874 const struct side_arg side_sav[] = { _sav }; \
1875 const struct side_arg_vec side_arg_vec = { \
1876 .sav = SIDE_PTR_INIT(side_sav), \
1877 .len = SIDE_ARRAY_SIZE(side_sav), \
1879 const struct side_arg_dynamic_field side_fields[] = { _var_fields }; \
1880 const struct side_arg_dynamic_struct var_struct = { \
1881 .fields = SIDE_PTR_INIT(side_fields), \
1882 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1883 .len = SIDE_ARRAY_SIZE(side_fields), \
1884 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1886 side_call_variadic(&(side_event_state__##_identifier.p), &side_arg_vec, &var_struct); \
1889 #define side_event_variadic(_identifier, _sav, _var, _attr...) \
1890 side_event_cond(_identifier) \
1891 side_event_call_variadic(_identifier, SIDE_PARAM(_sav), SIDE_PARAM(_var), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1893 #define _side_define_event(_linkage, _identifier, _provider, _event, _loglevel, _fields, _flags, _attr...) \
1894 _linkage struct side_event_description __attribute__((section("side_event_description"))) \
1896 _linkage struct side_event_state_0 __attribute__((section("side_event_state"))) \
1897 side_event_state__##_identifier = { \
1899 .version = SIDE_EVENT_STATE_ABI_VERSION, \
1902 .callbacks = SIDE_PTR_INIT(&side_empty_callback), \
1903 .desc = SIDE_PTR_INIT(&(_identifier)), \
1905 _linkage struct side_event_description __attribute__((section("side_event_description"))) \
1907 .struct_size = offsetof(struct side_event_description, end), \
1908 .version = SIDE_EVENT_DESCRIPTION_ABI_VERSION, \
1909 .state = SIDE_PTR_INIT(&(side_event_state__##_identifier.p)), \
1910 .provider_name = SIDE_PTR_INIT(_provider), \
1911 .event_name = SIDE_PTR_INIT(_event), \
1912 .fields = SIDE_PTR_INIT(_fields), \
1913 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1914 .flags = (_flags), \
1915 .nr_side_type_label = _NR_SIDE_TYPE_LABEL, \
1916 .nr_side_attr_type = _NR_SIDE_ATTR_TYPE, \
1917 .loglevel = SIDE_ENUM_INIT(_loglevel), \
1918 .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
1919 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1920 .nr_callbacks = 0, \
1922 static const struct side_event_description *side_event_ptr__##_identifier \
1923 __attribute__((section("side_event_description_ptr"), used)) = &(_identifier);
1925 #define side_static_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
1926 _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
1929 #define side_static_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
1930 _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
1931 SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1933 #define side_hidden_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
1934 _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \
1935 _loglevel, SIDE_PARAM(_fields), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1937 #define side_hidden_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
1938 _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \
1939 _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1941 #define side_export_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
1942 _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \
1943 _loglevel, SIDE_PARAM(_fields), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1945 #define side_export_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
1946 _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \
1947 _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1949 #define side_declare_event(_identifier) \
1950 extern struct side_event_state_0 side_event_state_##_identifier; \
1951 extern struct side_event_description _identifier
1957 struct side_callback
{
1959 void (*call
)(const struct side_event_description
*desc
,
1960 const struct side_arg_vec
*side_arg_vec
,
1962 void (*call_variadic
)(const struct side_event_description
*desc
,
1963 const struct side_arg_vec
*side_arg_vec
,
1964 const struct side_arg_dynamic_struct
*var_struct
,
1970 /* The visitor pattern is a double-dispatch visitor. */
1971 struct side_tracer_visitor_ctx
{
1972 side_write_elem_func write_elem
;
1973 void *priv
; /* Private tracer context. */
1976 struct side_tracer_dynamic_struct_visitor_ctx
{
1977 side_write_field_func write_field
;
1978 void *priv
; /* Private tracer context. */
1981 extern const struct side_callback side_empty_callback
;
1983 void side_call(const struct side_event_state
*state
,
1984 const struct side_arg_vec
*side_arg_vec
);
1985 void side_call_variadic(const struct side_event_state
*state
,
1986 const struct side_arg_vec
*side_arg_vec
,
1987 const struct side_arg_dynamic_struct
*var_struct
);
1989 struct side_events_register_handle
*side_events_register(struct side_event_description
**events
,
1990 uint32_t nr_events
);
1991 void side_events_unregister(struct side_events_register_handle
*handle
);
1994 * Userspace tracer registration API. This allows userspace tracers to
1995 * register event notification callbacks to be notified of the currently
1996 * registered instrumentation, and to register their callbacks to
1999 typedef void (*side_tracer_callback_func
)(const struct side_event_description
*desc
,
2000 const struct side_arg_vec
*side_arg_vec
,
2002 typedef void (*side_tracer_callback_variadic_func
)(const struct side_event_description
*desc
,
2003 const struct side_arg_vec
*side_arg_vec
,
2004 const struct side_arg_dynamic_struct
*var_struct
,
2007 int side_tracer_callback_register(struct side_event_description
*desc
,
2008 side_tracer_callback_func call
,
2010 int side_tracer_callback_variadic_register(struct side_event_description
*desc
,
2011 side_tracer_callback_variadic_func call_variadic
,
2013 int side_tracer_callback_unregister(struct side_event_description
*desc
,
2014 side_tracer_callback_func call
,
2016 int side_tracer_callback_variadic_unregister(struct side_event_description
*desc
,
2017 side_tracer_callback_variadic_func call_variadic
,
2020 enum side_tracer_notification
{
2021 SIDE_TRACER_NOTIFICATION_INSERT_EVENTS
,
2022 SIDE_TRACER_NOTIFICATION_REMOVE_EVENTS
,
2025 /* Callback is invoked with side library internal lock held. */
2026 struct side_tracer_handle
*side_tracer_event_notification_register(
2027 void (*cb
)(enum side_tracer_notification notif
,
2028 struct side_event_description
**events
, uint32_t nr_events
, void *priv
),
2030 void side_tracer_event_notification_unregister(struct side_tracer_handle
*handle
);
2033 * Explicit hooks to initialize/finalize the side instrumentation
2034 * library. Those are also library constructor/destructor.
2036 void side_init(void) __attribute__((constructor
));
2037 void side_exit(void) __attribute__((destructor
));
2040 * The following constructors/destructors perform automatic registration
2041 * of the declared side events. Those may have to be called explicitly
2042 * in a statically linked library.
2046 * These weak symbols, the constructor, and destructor take care of
2047 * registering only _one_ instance of the side instrumentation per
2048 * shared-ojbect (or for the whole main program).
2050 extern struct side_event_description
* __start_side_event_description_ptr
[]
2051 __attribute__((weak
, visibility("hidden")));
2052 extern struct side_event_description
* __stop_side_event_description_ptr
[]
2053 __attribute__((weak
, visibility("hidden")));
2054 int side_event_description_ptr_registered
2055 __attribute__((weak
, visibility("hidden")));
2056 struct side_events_register_handle
*side_events_handle
2057 __attribute__((weak
, visibility("hidden")));
2060 side_event_description_ptr_init(void)
2061 __attribute__((no_instrument_function
))
2062 __attribute__((constructor
));
2064 side_event_description_ptr_init(void)
2066 if (side_event_description_ptr_registered
++)
2068 side_events_handle
= side_events_register(__start_side_event_description_ptr
,
2069 __stop_side_event_description_ptr
- __start_side_event_description_ptr
);
2073 side_event_description_ptr_exit(void)
2074 __attribute__((no_instrument_function
))
2075 __attribute__((destructor
));
2077 side_event_description_ptr_exit(void)
2079 if (--side_event_description_ptr_registered
)
2081 side_events_unregister(side_events_handle
);
2082 side_events_handle
= NULL
;
2089 #endif /* _SIDE_TRACE_H */