Use structure size and version for event description extensibility
[libside.git] / include / side / trace.h
CommitLineData
67337c4a
MD
1// SPDX-License-Identifier: MIT
2/*
3 * Copyright 2022 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 */
5
6#ifndef _SIDE_TRACE_H
7#define _SIDE_TRACE_H
8
9#include <stdint.h>
10#include <inttypes.h>
11#include <stdlib.h>
12#include <stdio.h>
13#include <math.h>
25ea4c79 14#include <stdbool.h>
441235e7 15#include <stddef.h>
67337c4a
MD
16#include <side/macros.h>
17#include <side/endian.h>
18
19/*
551d8244 20 * SIDE stands for "Software Instrumentation Dynamically Enabled"
67337c4a 21 *
2e197497 22 * This is an instrumentation ABI for Linux user-space, which exposes an
67337c4a
MD
23 * instrumentation type system and facilities allowing a kernel or
24 * user-space tracer to consume user-space instrumentation.
25 *
2e197497 26 * This instrumentation ABI exposes 3 type systems:
67337c4a
MD
27 *
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.
36 *
37 * This is the most expressive of the 3 type systems, althrough not the
38 * fastest due to the extra copy of the arguments.
39 *
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.
47 *
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.
51 *
52 * This type system is has the least overhead of the 3 type systems.
53 *
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.
61 *
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.
65 *
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.
2e197497
MD
69 *
70 * The extensibility scheme for the SIDE ABI is as follows:
71 *
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 side defined by a
79 * side_padding() member. Each structure and union have a static
80 * assert validating its size.
81 *
82 * Handling of unknown types by the tracers:
83 *
84 * * A tracer may choose to support only a subset of the types supported
85 * by libside. When encountering an unknown or unsupported type, the
86 * tracer has the option to either disallow the entire event or skip
87 * over the unknown type, both at event registration and when
88 * receiving the side_call arguments.
89 *
441235e7
MD
90 * * Event descriptions can be extended by adding fields at the end of
91 * the structure. The "struct side_event_description" is therefore a
92 * structure with flexible size and must not be used within arrays.
67337c4a
MD
93 */
94
441235e7 95#define SIDE_ABI_VERSION 0
67337c4a
MD
96
97struct side_arg;
98struct side_arg_vec;
09515e04 99union side_arg_dynamic;
67337c4a
MD
100struct side_arg_dynamic_field;
101struct side_arg_dynamic_vla;
102struct side_type;
103struct side_event_field;
104struct side_tracer_visitor_ctx;
105struct side_tracer_dynamic_struct_visitor_ctx;
106struct side_event_description;
107struct side_arg_dynamic_struct;
108struct side_events_register_handle;
5530345d 109struct side_arg_variant;
0d747f98 110struct side_event_state;
2e197497 111struct side_callback;
67337c4a
MD
112
113enum side_type_label {
114 /* Stack-copy basic types */
115 SIDE_TYPE_NULL,
116 SIDE_TYPE_BOOL,
117 SIDE_TYPE_U8,
118 SIDE_TYPE_U16,
119 SIDE_TYPE_U32,
120 SIDE_TYPE_U64,
121 SIDE_TYPE_S8,
122 SIDE_TYPE_S16,
123 SIDE_TYPE_S32,
124 SIDE_TYPE_S64,
125 SIDE_TYPE_BYTE,
126 SIDE_TYPE_POINTER,
127 SIDE_TYPE_FLOAT_BINARY16,
128 SIDE_TYPE_FLOAT_BINARY32,
129 SIDE_TYPE_FLOAT_BINARY64,
130 SIDE_TYPE_FLOAT_BINARY128,
131 SIDE_TYPE_STRING_UTF8,
132 SIDE_TYPE_STRING_UTF16,
133 SIDE_TYPE_STRING_UTF32,
134
135 /* Stack-copy compound types */
136 SIDE_TYPE_STRUCT,
5530345d 137 SIDE_TYPE_VARIANT,
67337c4a
MD
138 SIDE_TYPE_ARRAY,
139 SIDE_TYPE_VLA,
140 SIDE_TYPE_VLA_VISITOR,
141
142 /* Stack-copy enumeration types */
143 SIDE_TYPE_ENUM,
144 SIDE_TYPE_ENUM_BITMAP,
145
146 /* Stack-copy place holder for dynamic types */
147 SIDE_TYPE_DYNAMIC,
148
149 /* Gather basic types */
150 SIDE_TYPE_GATHER_BOOL,
151 SIDE_TYPE_GATHER_INTEGER,
152 SIDE_TYPE_GATHER_BYTE,
153 SIDE_TYPE_GATHER_POINTER,
154 SIDE_TYPE_GATHER_FLOAT,
155 SIDE_TYPE_GATHER_STRING,
156
157 /* Gather compound types */
158 SIDE_TYPE_GATHER_STRUCT,
159 SIDE_TYPE_GATHER_ARRAY,
160 SIDE_TYPE_GATHER_VLA,
161
162 /* Gather enumeration types */
163 SIDE_TYPE_GATHER_ENUM,
164
165 /* Dynamic basic types */
166 SIDE_TYPE_DYNAMIC_NULL,
167 SIDE_TYPE_DYNAMIC_BOOL,
168 SIDE_TYPE_DYNAMIC_INTEGER,
169 SIDE_TYPE_DYNAMIC_BYTE,
170 SIDE_TYPE_DYNAMIC_POINTER,
171 SIDE_TYPE_DYNAMIC_FLOAT,
172 SIDE_TYPE_DYNAMIC_STRING,
173
174 /* Dynamic compound types */
175 SIDE_TYPE_DYNAMIC_STRUCT,
176 SIDE_TYPE_DYNAMIC_STRUCT_VISITOR,
177 SIDE_TYPE_DYNAMIC_VLA,
178 SIDE_TYPE_DYNAMIC_VLA_VISITOR,
1e5997be
MD
179
180 _NR_SIDE_TYPE_LABEL, /* Last entry. */
67337c4a
MD
181};
182
183enum side_attr_type {
184 SIDE_ATTR_TYPE_NULL,
185 SIDE_ATTR_TYPE_BOOL,
186 SIDE_ATTR_TYPE_U8,
187 SIDE_ATTR_TYPE_U16,
188 SIDE_ATTR_TYPE_U32,
189 SIDE_ATTR_TYPE_U64,
190 SIDE_ATTR_TYPE_S8,
191 SIDE_ATTR_TYPE_S16,
192 SIDE_ATTR_TYPE_S32,
193 SIDE_ATTR_TYPE_S64,
194 SIDE_ATTR_TYPE_FLOAT_BINARY16,
195 SIDE_ATTR_TYPE_FLOAT_BINARY32,
196 SIDE_ATTR_TYPE_FLOAT_BINARY64,
197 SIDE_ATTR_TYPE_FLOAT_BINARY128,
198 SIDE_ATTR_TYPE_STRING,
1e5997be
MD
199
200 _NR_SIDE_ATTR_TYPE, /* Last entry. */
67337c4a
MD
201};
202
203enum side_loglevel {
204 SIDE_LOGLEVEL_EMERG = 0,
205 SIDE_LOGLEVEL_ALERT = 1,
206 SIDE_LOGLEVEL_CRIT = 2,
207 SIDE_LOGLEVEL_ERR = 3,
208 SIDE_LOGLEVEL_WARNING = 4,
209 SIDE_LOGLEVEL_NOTICE = 5,
210 SIDE_LOGLEVEL_INFO = 6,
211 SIDE_LOGLEVEL_DEBUG = 7,
212};
213
214enum side_visitor_status {
215 SIDE_VISITOR_STATUS_OK = 0,
216 SIDE_VISITOR_STATUS_ERROR = -1,
217};
218
219enum side_error {
220 SIDE_ERROR_OK = 0,
221 SIDE_ERROR_INVAL = 1,
222 SIDE_ERROR_EXIST = 2,
223 SIDE_ERROR_NOMEM = 3,
224 SIDE_ERROR_NOENT = 4,
225 SIDE_ERROR_EXITING = 5,
226};
227
228enum side_type_label_byte_order {
229 SIDE_TYPE_BYTE_ORDER_LE = 0,
230 SIDE_TYPE_BYTE_ORDER_BE = 1,
231};
232
233#if (SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN)
234# define SIDE_TYPE_BYTE_ORDER_HOST SIDE_TYPE_BYTE_ORDER_LE
235#else
236# define SIDE_TYPE_BYTE_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE
237#endif
238
239#if (SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN)
240# define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_LE
241#else
242# define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE
243#endif
244
245enum side_type_gather_access_mode {
246 SIDE_TYPE_GATHER_ACCESS_DIRECT,
247 SIDE_TYPE_GATHER_ACCESS_POINTER, /* Pointer dereference */
248};
249
250typedef enum side_visitor_status (*side_visitor_func)(
251 const struct side_tracer_visitor_ctx *tracer_ctx,
252 void *app_ctx);
253typedef enum side_visitor_status (*side_dynamic_struct_visitor_func)(
254 const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx,
255 void *app_ctx);
2e197497
MD
256typedef enum side_visitor_status (*side_write_elem_func)(
257 const struct side_tracer_visitor_ctx *tracer_ctx,
258 const struct side_arg *elem);
259typedef enum side_visitor_status (*side_write_field_func)(
260 const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx,
261 const struct side_arg_dynamic_field *dynamic_field);
67337c4a
MD
262
263union side_integer_value {
264 uint8_t side_u8;
265 uint16_t side_u16;
266 uint32_t side_u32;
267 uint64_t side_u64;
268 int8_t side_s8;
269 int16_t side_s16;
270 int32_t side_s32;
271 int64_t side_s64;
272 uintptr_t side_uptr;
2e197497 273 side_padding(32);
67337c4a 274} SIDE_PACKED;
2e197497 275side_check_size(union side_integer_value, 32);
67337c4a
MD
276
277union side_bool_value {
278 uint8_t side_bool8;
279 uint16_t side_bool16;
280 uint32_t side_bool32;
281 uint64_t side_bool64;
2e197497 282 side_padding(32);
67337c4a 283} SIDE_PACKED;
2e197497 284side_check_size(union side_bool_value, 32);
67337c4a
MD
285
286union side_float_value {
287#if __HAVE_FLOAT16
288 _Float16 side_float_binary16;
289#endif
290#if __HAVE_FLOAT32
291 _Float32 side_float_binary32;
292#endif
293#if __HAVE_FLOAT64
294 _Float64 side_float_binary64;
295#endif
296#if __HAVE_FLOAT128
297 _Float128 side_float_binary128;
298#endif
2e197497 299 side_padding(32);
67337c4a 300} SIDE_PACKED;
2e197497 301side_check_size(union side_float_value, 32);
67337c4a
MD
302
303struct side_type_raw_string {
3db2d8a1 304 side_ptr_t(const void) p; /* pointer to string */
67337c4a 305 uint8_t unit_size; /* 1, 2, or 4 bytes */
3bc9ba43 306 side_enum_t(enum side_type_label_byte_order, uint8_t) byte_order;
67337c4a 307} SIDE_PACKED;
2e197497 308side_check_size(struct side_type_raw_string, 18);
67337c4a
MD
309
310struct side_attr_value {
15f17024 311 side_enum_t(enum side_attr_type, uint32_t) type;
67337c4a
MD
312 union {
313 uint8_t bool_value;
314 struct side_type_raw_string string_value;
315 union side_integer_value integer_value;
316 union side_float_value float_value;
2e197497 317 side_padding(32);
67337c4a
MD
318 } SIDE_PACKED u;
319};
2e197497 320side_check_size(struct side_attr_value, 36);
67337c4a
MD
321
322/* User attributes. */
323struct side_attr {
324 const struct side_type_raw_string key;
325 const struct side_attr_value value;
326} SIDE_PACKED;
2e197497 327side_check_size(struct side_attr, 54);
67337c4a
MD
328
329/* Type descriptions */
330struct side_type_null {
b313067b 331 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
332 uint32_t nr_attr;
333} SIDE_PACKED;
2e197497 334side_check_size(struct side_type_null, 20);
67337c4a
MD
335
336struct side_type_bool {
db8df9b5 337 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
338 uint32_t nr_attr;
339 uint16_t bool_size; /* bytes */
340 uint16_t len_bits; /* bits. 0 for (bool_size * CHAR_BITS) */
3bc9ba43 341 side_enum_t(enum side_type_label_byte_order, uint8_t) byte_order;
67337c4a 342} SIDE_PACKED;
2e197497 343side_check_size(struct side_type_bool, 25);
67337c4a
MD
344
345struct side_type_byte {
12d787db 346 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
347 uint32_t nr_attr;
348} SIDE_PACKED;
2e197497 349side_check_size(struct side_type_byte, 20);
67337c4a
MD
350
351struct side_type_string {
12d787db 352 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
353 uint32_t nr_attr;
354 uint8_t unit_size; /* 1, 2, or 4 bytes */
3bc9ba43 355 side_enum_t(enum side_type_label_byte_order, uint8_t) byte_order;
67337c4a 356} SIDE_PACKED;
2e197497 357side_check_size(struct side_type_string, 22);
67337c4a
MD
358
359struct side_type_integer {
12d787db 360 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
361 uint32_t nr_attr;
362 uint16_t integer_size; /* bytes */
363 uint16_t len_bits; /* bits. 0 for (integer_size * CHAR_BITS) */
364 uint8_t signedness; /* true/false */
3bc9ba43 365 side_enum_t(enum side_type_label_byte_order, uint8_t) byte_order;
67337c4a 366} SIDE_PACKED;
2e197497 367side_check_size(struct side_type_integer, 26);
67337c4a
MD
368
369struct side_type_float {
12d787db 370 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
371 uint32_t nr_attr;
372 uint16_t float_size; /* bytes */
3bc9ba43 373 side_enum_t(enum side_type_label_byte_order, uint8_t) byte_order;
67337c4a 374} SIDE_PACKED;
2e197497 375side_check_size(struct side_type_float, 23);
67337c4a
MD
376
377struct side_enum_mapping {
378 int64_t range_begin;
379 int64_t range_end;
380 struct side_type_raw_string label;
381} SIDE_PACKED;
2e197497 382side_check_size(struct side_enum_mapping, 16 + sizeof(struct side_type_raw_string));
67337c4a
MD
383
384struct side_enum_mappings {
64037418 385 side_ptr_t(const struct side_enum_mapping) mappings;
12d787db 386 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
387 uint32_t nr_mappings;
388 uint32_t nr_attr;
389} SIDE_PACKED;
2e197497 390side_check_size(struct side_enum_mappings, 40);
67337c4a
MD
391
392struct side_enum_bitmap_mapping {
393 uint64_t range_begin;
394 uint64_t range_end;
395 struct side_type_raw_string label;
396} SIDE_PACKED;
2e197497 397side_check_size(struct side_enum_bitmap_mapping, 16 + sizeof(struct side_type_raw_string));
67337c4a
MD
398
399struct side_enum_bitmap_mappings {
64037418 400 side_ptr_t(const struct side_enum_bitmap_mapping) mappings;
12d787db 401 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
402 uint32_t nr_mappings;
403 uint32_t nr_attr;
404} SIDE_PACKED;
2e197497 405side_check_size(struct side_enum_bitmap_mappings, 40);
67337c4a
MD
406
407struct side_type_struct {
c5789285 408 side_ptr_t(const struct side_event_field) fields;
12d787db 409 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
410 uint32_t nr_fields;
411 uint32_t nr_attr;
412} SIDE_PACKED;
2e197497 413side_check_size(struct side_type_struct, 40);
67337c4a
MD
414
415struct side_type_array {
c5789285 416 side_ptr_t(const struct side_type) elem_type;
12d787db 417 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
418 uint32_t length;
419 uint32_t nr_attr;
420} SIDE_PACKED;
2e197497 421side_check_size(struct side_type_array, 40);
67337c4a
MD
422
423struct side_type_vla {
c5789285 424 side_ptr_t(const struct side_type) elem_type;
12d787db 425 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
426 uint32_t nr_attr;
427} SIDE_PACKED;
2e197497 428side_check_size(struct side_type_vla, 36);
67337c4a
MD
429
430struct side_type_vla_visitor {
c5789285 431 side_ptr_t(const struct side_type) elem_type;
2e197497 432 side_func_ptr_t(side_visitor_func) visitor;
12d787db 433 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
434 uint32_t nr_attr;
435} SIDE_PACKED;
2e197497 436side_check_size(struct side_type_vla_visitor, 52);
67337c4a
MD
437
438struct side_type_enum {
64037418 439 side_ptr_t(const struct side_enum_mappings) mappings;
c5789285 440 side_ptr_t(const struct side_type) elem_type;
67337c4a 441} SIDE_PACKED;
2e197497 442side_check_size(struct side_type_enum, 32);
67337c4a
MD
443
444struct side_type_enum_bitmap {
64037418 445 side_ptr_t(const struct side_enum_bitmap_mappings) mappings;
c5789285 446 side_ptr_t(const struct side_type) elem_type;
67337c4a 447} SIDE_PACKED;
2e197497 448side_check_size(struct side_type_enum_bitmap, 32);
67337c4a
MD
449
450struct side_type_gather_bool {
451 uint64_t offset; /* bytes */
2e197497 452 uint16_t offset_bits; /* bits */
67337c4a
MD
453 uint8_t access_mode; /* enum side_type_gather_access_mode */
454 struct side_type_bool type;
67337c4a 455} SIDE_PACKED;
2e197497 456side_check_size(struct side_type_gather_bool, 11 + sizeof(struct side_type_bool));
67337c4a
MD
457
458struct side_type_gather_byte {
459 uint64_t offset; /* bytes */
460 uint8_t access_mode; /* enum side_type_gather_access_mode */
461 struct side_type_byte type;
462} SIDE_PACKED;
2e197497 463side_check_size(struct side_type_gather_byte, 9 + sizeof(struct side_type_byte));
67337c4a
MD
464
465struct side_type_gather_integer {
466 uint64_t offset; /* bytes */
2e197497 467 uint16_t offset_bits; /* bits */
67337c4a
MD
468 uint8_t access_mode; /* enum side_type_gather_access_mode */
469 struct side_type_integer type;
67337c4a 470} SIDE_PACKED;
2e197497 471side_check_size(struct side_type_gather_integer, 11 + sizeof(struct side_type_integer));
67337c4a
MD
472
473struct side_type_gather_float {
474 uint64_t offset; /* bytes */
475 uint8_t access_mode; /* enum side_type_gather_access_mode */
476 struct side_type_float type;
477} SIDE_PACKED;
2e197497 478side_check_size(struct side_type_gather_float, 9 + sizeof(struct side_type_float));
67337c4a
MD
479
480struct side_type_gather_string {
481 uint64_t offset; /* bytes */
482 uint8_t access_mode; /* enum side_type_gather_access_mode */
483 struct side_type_string type;
484} SIDE_PACKED;
2e197497 485side_check_size(struct side_type_gather_string, 9 + sizeof(struct side_type_string));
67337c4a
MD
486
487struct side_type_gather_enum {
64037418 488 side_ptr_t(const struct side_enum_mappings) mappings;
c5789285 489 side_ptr_t(const struct side_type) elem_type;
67337c4a 490} SIDE_PACKED;
2e197497 491side_check_size(struct side_type_gather_enum, 32);
67337c4a
MD
492
493struct side_type_gather_struct {
2e197497 494 side_ptr_t(const struct side_type_struct) type;
67337c4a
MD
495 uint64_t offset; /* bytes */
496 uint8_t access_mode; /* enum side_type_gather_access_mode */
67337c4a
MD
497 uint32_t size; /* bytes */
498} SIDE_PACKED;
2e197497 499side_check_size(struct side_type_gather_struct, 29);
67337c4a
MD
500
501struct side_type_gather_array {
502 uint64_t offset; /* bytes */
503 uint8_t access_mode; /* enum side_type_gather_access_mode */
504 struct side_type_array type;
505} SIDE_PACKED;
2e197497 506side_check_size(struct side_type_gather_array, 9 + sizeof(struct side_type_array));
67337c4a
MD
507
508struct side_type_gather_vla {
c5789285 509 side_ptr_t(const struct side_type) length_type; /* side_length() */
67337c4a
MD
510 uint64_t offset; /* bytes */
511 uint8_t access_mode; /* enum side_type_gather_access_mode */
512 struct side_type_vla type;
513} SIDE_PACKED;
2e197497 514side_check_size(struct side_type_gather_vla, 25 + sizeof(struct side_type_vla));
67337c4a
MD
515
516struct side_type_gather {
517 union {
518 struct side_type_gather_bool side_bool;
519 struct side_type_gather_byte side_byte;
520 struct side_type_gather_integer side_integer;
521 struct side_type_gather_float side_float;
522 struct side_type_gather_string side_string;
523 struct side_type_gather_enum side_enum;
524 struct side_type_gather_array side_array;
525 struct side_type_gather_vla side_vla;
526 struct side_type_gather_struct side_struct;
2e197497 527 side_padding(61);
67337c4a
MD
528 } SIDE_PACKED u;
529} SIDE_PACKED;
2e197497 530side_check_size(struct side_type_gather, 61);
67337c4a
MD
531
532struct side_type {
2e197497 533 side_enum_t(enum side_type_label, uint16_t) type;
67337c4a
MD
534 union {
535 /* Stack-copy basic types */
536 struct side_type_null side_null;
537 struct side_type_bool side_bool;
538 struct side_type_byte side_byte;
539 struct side_type_string side_string;
540 struct side_type_integer side_integer;
541 struct side_type_float side_float;
542
543 /* Stack-copy compound types */
544 struct side_type_array side_array;
545 struct side_type_vla side_vla;
546 struct side_type_vla_visitor side_vla_visitor;
c5789285
MD
547 side_ptr_t(const struct side_type_struct) side_struct;
548 side_ptr_t(const struct side_type_variant) side_variant;
67337c4a
MD
549
550 /* Stack-copy enumeration types */
551 struct side_type_enum side_enum;
552 struct side_type_enum_bitmap side_enum_bitmap;
553
554 /* Gather types */
555 struct side_type_gather side_gather;
2e197497 556 side_padding(62);
67337c4a
MD
557 } SIDE_PACKED u;
558} SIDE_PACKED;
2e197497 559side_check_size(struct side_type, 64);
67337c4a 560
5530345d
MD
561struct side_variant_option {
562 int64_t range_begin;
563 int64_t range_end;
564 const struct side_type side_type;
565} SIDE_PACKED;
2e197497 566side_check_size(struct side_variant_option, 16 + sizeof(const struct side_type));
5530345d
MD
567
568struct side_type_variant {
c5789285 569 side_ptr_t(const struct side_variant_option) options;
12d787db 570 side_ptr_t(const struct side_attr) attr;
5530345d
MD
571 uint32_t nr_options;
572 uint32_t nr_attr;
2e197497 573 const struct side_type selector;
5530345d 574} SIDE_PACKED;
2e197497 575side_check_size(struct side_type_variant, 40 + sizeof(const struct side_type));
5530345d 576
67337c4a 577struct side_event_field {
c5789285 578 side_ptr_t(const char) field_name;
67337c4a
MD
579 struct side_type side_type;
580} SIDE_PACKED;
2e197497 581side_check_size(struct side_event_field, 16 + sizeof(struct side_type));
67337c4a
MD
582
583enum side_event_flags {
584 SIDE_EVENT_FLAG_VARIADIC = (1 << 0),
585};
586
09515e04 587union side_arg_static {
67337c4a
MD
588 /* Stack-copy basic types */
589 union side_bool_value bool_value;
590 uint8_t byte_value;
6910c28c 591 side_ptr_t(const void) string_value; /* const {uint8_t, uint16_t, uint32_t} * */
67337c4a
MD
592 union side_integer_value integer_value;
593 union side_float_value float_value;
594
595 /* Stack-copy compound types */
bac71609
MD
596 side_ptr_t(const struct side_arg_vec) side_struct;
597 side_ptr_t(const struct side_arg_variant) side_variant;
598 side_ptr_t(const struct side_arg_vec) side_array;
599 side_ptr_t(const struct side_arg_vec) side_vla;
67337c4a
MD
600 void *side_vla_app_visitor_ctx;
601
602 /* Gather basic types */
155b1756
MD
603 side_ptr_t(const void) side_bool_gather_ptr;
604 side_ptr_t(const void) side_byte_gather_ptr;
605 side_ptr_t(const void) side_integer_gather_ptr;
606 side_ptr_t(const void) side_float_gather_ptr;
607 side_ptr_t(const void) side_string_gather_ptr;
67337c4a
MD
608
609 /* Gather compound types */
155b1756
MD
610 side_ptr_t(const void) side_array_gather_ptr;
611 side_ptr_t(const void) side_struct_gather_ptr;
67337c4a 612 struct {
155b1756
MD
613 side_ptr_t(const void) ptr;
614 side_ptr_t(const void) length_ptr;
67337c4a 615 } SIDE_PACKED side_vla_gather;
2e197497 616 side_padding(32);
67337c4a 617} SIDE_PACKED;
2e197497 618side_check_size(union side_arg_static, 32);
67337c4a
MD
619
620struct side_arg_dynamic_vla {
f13253cb 621 side_ptr_t(const struct side_arg) sav;
12d787db 622 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
623 uint32_t len;
624 uint32_t nr_attr;
625} SIDE_PACKED;
2e197497 626side_check_size(struct side_arg_dynamic_vla, 40);
67337c4a
MD
627
628struct side_arg_dynamic_struct {
f13253cb 629 side_ptr_t(const struct side_arg_dynamic_field) fields;
12d787db 630 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
631 uint32_t len;
632 uint32_t nr_attr;
633} SIDE_PACKED;
2e197497 634side_check_size(struct side_arg_dynamic_struct, 40);
67337c4a
MD
635
636struct side_dynamic_struct_visitor {
2e197497
MD
637 side_func_ptr_t(side_dynamic_struct_visitor_func) visitor;
638 side_ptr_t(void) app_ctx;
12d787db 639 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
640 uint32_t nr_attr;
641} SIDE_PACKED;
2e197497 642side_check_size(struct side_dynamic_struct_visitor, 52);
67337c4a
MD
643
644struct side_dynamic_vla_visitor {
2e197497
MD
645 side_func_ptr_t(side_visitor_func) visitor;
646 side_ptr_t(void) app_ctx;
12d787db 647 side_ptr_t(const struct side_attr) attr;
67337c4a
MD
648 uint32_t nr_attr;
649} SIDE_PACKED;
2e197497 650side_check_size(struct side_dynamic_vla_visitor, 52);
67337c4a 651
09515e04 652union side_arg_dynamic {
67337c4a
MD
653 /* Dynamic basic types */
654 struct side_type_null side_null;
655 struct {
656 struct side_type_bool type;
657 union side_bool_value value;
658 } SIDE_PACKED side_bool;
659 struct {
660 struct side_type_byte type;
661 uint8_t value;
662 } SIDE_PACKED side_byte;
663 struct {
664 struct side_type_string type;
665 uint64_t value; /* const char * */
666 } SIDE_PACKED side_string;
667 struct {
668 struct side_type_integer type;
669 union side_integer_value value;
670 } SIDE_PACKED side_integer;
671 struct {
672 struct side_type_float type;
673 union side_float_value value;
674 } SIDE_PACKED side_float;
675
676 /* Dynamic compound types */
f13253cb
MD
677 side_ptr_t(const struct side_arg_dynamic_struct) side_dynamic_struct;
678 side_ptr_t(const struct side_arg_dynamic_vla) side_dynamic_vla;
67337c4a
MD
679
680 struct side_dynamic_struct_visitor side_dynamic_struct_visitor;
681 struct side_dynamic_vla_visitor side_dynamic_vla_visitor;
2e197497
MD
682
683 side_padding(58);
67337c4a 684} SIDE_PACKED;
2e197497 685side_check_size(union side_arg_dynamic, 58);
67337c4a
MD
686
687struct side_arg {
2e197497 688 side_enum_t(enum side_type_label, uint16_t) type;
67337c4a 689 union {
09515e04
MD
690 union side_arg_static side_static;
691 union side_arg_dynamic side_dynamic;
2e197497 692 side_padding(62);
67337c4a
MD
693 } SIDE_PACKED u;
694} SIDE_PACKED;
2e197497 695side_check_size(struct side_arg, 64);
67337c4a 696
5530345d
MD
697struct side_arg_variant {
698 struct side_arg selector;
699 struct side_arg option;
700} SIDE_PACKED;
2e197497 701side_check_size(struct side_arg_variant, 128);
5530345d 702
67337c4a 703struct side_arg_vec {
f13253cb 704 side_ptr_t(const struct side_arg) sav;
67337c4a
MD
705 uint32_t len;
706} SIDE_PACKED;
2e197497 707side_check_size(struct side_arg_vec, 20);
67337c4a
MD
708
709struct side_arg_dynamic_field {
f13253cb 710 side_ptr_t(const char) field_name;
67337c4a
MD
711 const struct side_arg elem;
712} SIDE_PACKED;
2e197497 713side_check_size(struct side_arg_dynamic_field, 16 + sizeof(const struct side_arg));
67337c4a
MD
714
715struct side_event_description {
441235e7
MD
716 uint32_t struct_size; /* Size of this structure. */
717 uint32_t version; /* ABI version. */
718
0b9e59d6
MD
719 side_ptr_t(struct side_event_state) state;
720 side_ptr_t(const char) provider_name;
721 side_ptr_t(const char) event_name;
722 side_ptr_t(const struct side_event_field) fields;
12d787db 723 side_ptr_t(const struct side_attr) attr;
67337c4a 724 uint64_t flags;
1e5997be
MD
725 uint16_t nr_side_type_label;
726 uint16_t nr_side_attr_type;
1f7aaefb 727 side_enum_t(enum side_loglevel, uint32_t) loglevel;
67337c4a
MD
728 uint32_t nr_fields;
729 uint32_t nr_attr;
f8188f94 730 uint32_t nr_callbacks;
441235e7
MD
731#define side_event_description_orig_abi_last nr_callbacks
732 /* End of fields supported in the original ABI. */
733
734 char end[]; /* End with a flexible array to account for extensibility. */
67337c4a
MD
735} SIDE_PACKED;
736
0d747f98
MD
737/*
738 * This structure is _not_ packed to allow atomic operations on its
739 * fields.
740 */
741struct side_event_state {
742 uintptr_t enabled;
743 const struct side_callback *callbacks;
744 struct side_event_description *desc;
745};
746
67337c4a
MD
747/* Event and type attributes */
748
749#define side_attr(_key, _value) \
750 { \
751 .key = { \
d1251f44 752 .p = SIDE_PTR_INIT(_key), \
67337c4a 753 .unit_size = sizeof(uint8_t), \
3bc9ba43 754 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
67337c4a
MD
755 }, \
756 .value = SIDE_PARAM(_value), \
757 }
758
759#define side_attr_list(...) \
760 SIDE_COMPOUND_LITERAL(const struct side_attr, __VA_ARGS__)
761
762#define side_attr_null(_val) { .type = SIDE_ATTR_TYPE_NULL }
15f17024
MD
763#define side_attr_bool(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_BOOL), .u = { .bool_value = !!(_val) } }
764#define side_attr_u8(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U8), .u = { .integer_value = { .side_u8 = (_val) } } }
765#define side_attr_u16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U16), .u = { .integer_value = { .side_u16 = (_val) } } }
766#define side_attr_u32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U32), .u = { .integer_value = { .side_u32 = (_val) } } }
767#define side_attr_u64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U64), .u = { .integer_value = { .side_u64 = (_val) } } }
768#define side_attr_s8(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S8), .u = { .integer_value = { .side_s8 = (_val) } } }
769#define side_attr_s16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S16), .u = { .integer_value = { .side_s16 = (_val) } } }
770#define side_attr_s32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S32), .u = { .integer_value = { .side_s32 = (_val) } } }
771#define side_attr_s64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S64), .u = { .integer_value = { .side_s64 = (_val) } } }
772#define side_attr_float_binary16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY16), .u = { .float_value = { .side_float_binary16 = (_val) } } }
773#define side_attr_float_binary32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY32), .u = { .float_value = { .side_float_binary32 = (_val) } } }
774#define side_attr_float_binary64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY64), .u = { .float_value = { .side_float_binary64 = (_val) } } }
775#define side_attr_float_binary128(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY128), .u = { .float_value = { .side_float_binary128 = (_val) } } }
67337c4a
MD
776
777#define _side_attr_string(_val, _byte_order, _unit_size) \
778 { \
15f17024 779 .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_STRING), \
67337c4a
MD
780 .u = { \
781 .string_value = { \
d1251f44 782 .p = SIDE_PTR_INIT(_val), \
67337c4a 783 .unit_size = _unit_size, \
3bc9ba43 784 .byte_order = SIDE_ENUM_INIT(_byte_order), \
67337c4a
MD
785 }, \
786 }, \
787 }
788
789#define side_attr_string(_val) _side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t))
790#define side_attr_string16(_val) _side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t))
791#define side_attr_string32(_val) _side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t))
792
793/* Stack-copy enumeration type definitions */
794
d5a4e361 795#define side_define_enum(_identifier, _mappings, _attr...) \
67337c4a 796 const struct side_enum_mappings _identifier = { \
64037418 797 .mappings = SIDE_PTR_INIT(_mappings), \
12d787db 798 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a 799 .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \
d5a4e361 800 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
801 }
802
803#define side_enum_mapping_list(...) \
804 SIDE_COMPOUND_LITERAL(const struct side_enum_mapping, __VA_ARGS__)
805
806#define side_enum_mapping_range(_label, _begin, _end) \
807 { \
808 .range_begin = _begin, \
809 .range_end = _end, \
810 .label = { \
d1251f44 811 .p = SIDE_PTR_INIT(_label), \
67337c4a 812 .unit_size = sizeof(uint8_t), \
3bc9ba43 813 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
67337c4a
MD
814 }, \
815 }
816
817#define side_enum_mapping_value(_label, _value) \
818 { \
819 .range_begin = _value, \
820 .range_end = _value, \
821 .label = { \
d1251f44 822 .p = SIDE_PTR_INIT(_label), \
67337c4a 823 .unit_size = sizeof(uint8_t), \
3bc9ba43 824 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
67337c4a
MD
825 }, \
826 }
827
d5a4e361 828#define side_define_enum_bitmap(_identifier, _mappings, _attr...) \
67337c4a 829 const struct side_enum_bitmap_mappings _identifier = { \
64037418 830 .mappings = SIDE_PTR_INIT(_mappings), \
12d787db 831 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a 832 .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \
d5a4e361 833 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
834 }
835
836#define side_enum_bitmap_mapping_list(...) \
837 SIDE_COMPOUND_LITERAL(const struct side_enum_bitmap_mapping, __VA_ARGS__)
838
839#define side_enum_bitmap_mapping_range(_label, _begin, _end) \
840 { \
841 .range_begin = _begin, \
842 .range_end = _end, \
843 .label = { \
d1251f44 844 .p = SIDE_PTR_INIT(_label), \
67337c4a 845 .unit_size = sizeof(uint8_t), \
3bc9ba43 846 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
67337c4a
MD
847 }, \
848 }
849
850#define side_enum_bitmap_mapping_value(_label, _value) \
851 { \
852 .range_begin = _value, \
853 .range_end = _value, \
854 .label = { \
d1251f44 855 .p = SIDE_PTR_INIT(_label), \
67337c4a 856 .unit_size = sizeof(uint8_t), \
3bc9ba43 857 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
67337c4a
MD
858 }, \
859 }
860
861/* Stack-copy field and type definitions */
862
d5a4e361 863#define side_type_null(_attr...) \
67337c4a 864 { \
3ce69bfa 865 .type = SIDE_ENUM_INIT(SIDE_TYPE_NULL), \
67337c4a
MD
866 .u = { \
867 .side_null = { \
b313067b 868 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 869 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
870 }, \
871 }, \
872 }
873
d5a4e361 874#define side_type_bool(_attr...) \
67337c4a 875 { \
3ce69bfa 876 .type = SIDE_ENUM_INIT(SIDE_TYPE_BOOL), \
67337c4a
MD
877 .u = { \
878 .side_bool = { \
db8df9b5 879 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 880 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
881 .bool_size = sizeof(uint8_t), \
882 .len_bits = 0, \
3bc9ba43 883 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
67337c4a
MD
884 }, \
885 }, \
886 }
887
d5a4e361 888#define side_type_byte(_attr...) \
67337c4a 889 { \
3ce69bfa 890 .type = SIDE_ENUM_INIT(SIDE_TYPE_BYTE), \
67337c4a
MD
891 .u = { \
892 .side_byte = { \
12d787db 893 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 894 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
895 }, \
896 }, \
897 }
898
899#define _side_type_string(_type, _byte_order, _unit_size, _attr) \
900 { \
3ce69bfa 901 .type = SIDE_ENUM_INIT(_type), \
67337c4a
MD
902 .u = { \
903 .side_string = { \
12d787db 904 .attr = SIDE_PTR_INIT(_attr), \
67337c4a
MD
905 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
906 .unit_size = _unit_size, \
3bc9ba43 907 .byte_order = SIDE_ENUM_INIT(_byte_order), \
67337c4a
MD
908 }, \
909 }, \
910 }
911
912#define side_type_dynamic() \
913 { \
3ce69bfa 914 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC), \
67337c4a
MD
915 }
916
917#define _side_type_integer(_type, _signedness, _byte_order, _integer_size, _len_bits, _attr) \
918 { \
3ce69bfa 919 .type = SIDE_ENUM_INIT(_type), \
67337c4a
MD
920 .u = { \
921 .side_integer = { \
12d787db 922 .attr = SIDE_PTR_INIT(_attr), \
67337c4a
MD
923 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
924 .integer_size = _integer_size, \
925 .len_bits = _len_bits, \
926 .signedness = _signedness, \
3bc9ba43 927 .byte_order = SIDE_ENUM_INIT(_byte_order), \
67337c4a
MD
928 }, \
929 }, \
930 }
931
932#define _side_type_float(_type, _byte_order, _float_size, _attr) \
933 { \
3ce69bfa 934 .type = SIDE_ENUM_INIT(_type), \
67337c4a
MD
935 .u = { \
936 .side_float = { \
12d787db 937 .attr = SIDE_PTR_INIT(_attr), \
67337c4a
MD
938 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
939 .float_size = _float_size, \
3bc9ba43 940 .byte_order = SIDE_ENUM_INIT(_byte_order), \
67337c4a
MD
941 }, \
942 }, \
943 }
944
945#define _side_field(_name, _type) \
946 { \
c5789285 947 .field_name = SIDE_PTR_INIT(_name), \
67337c4a
MD
948 .side_type = _type, \
949 }
950
5530345d
MD
951#define side_option_range(_range_begin, _range_end, _type) \
952 { \
953 .range_begin = _range_begin, \
954 .range_end = _range_end, \
955 .side_type = _type, \
956 }
957
958#define side_option(_value, _type) \
959 side_option_range(_value, _value, SIDE_PARAM(_type))
960
67337c4a 961/* Host endian */
d5a4e361
MD
962#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()))
963#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()))
964#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()))
965#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()))
966#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()))
967#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()))
968#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()))
969#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()))
970#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()))
971#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()))
972#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()))
973#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()))
974#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()))
975#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()))
976#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()))
977#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()))
978
979#define side_field_null(_name, _attr...) _side_field(_name, side_type_null(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
980#define side_field_bool(_name, _attr...) _side_field(_name, side_type_bool(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
981#define side_field_u8(_name, _attr...) _side_field(_name, side_type_u8(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
982#define side_field_u16(_name, _attr...) _side_field(_name, side_type_u16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
983#define side_field_u32(_name, _attr...) _side_field(_name, side_type_u32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
984#define side_field_u64(_name, _attr...) _side_field(_name, side_type_u64(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
985#define side_field_s8(_name, _attr...) _side_field(_name, side_type_s8(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
986#define side_field_s16(_name, _attr...) _side_field(_name, side_type_s16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
987#define side_field_s32(_name, _attr...) _side_field(_name, side_type_s32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
988#define side_field_s64(_name, _attr...) _side_field(_name, side_type_s64(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
989#define side_field_byte(_name, _attr...) _side_field(_name, side_type_byte(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
990#define side_field_pointer(_name, _attr...) _side_field(_name, side_type_pointer(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
991#define side_field_float_binary16(_name, _attr...) _side_field(_name, side_type_float_binary16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
992#define side_field_float_binary32(_name, _attr...) _side_field(_name, side_type_float_binary32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
993#define side_field_float_binary64(_name, _attr...) _side_field(_name, side_type_float_binary64(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
994#define side_field_float_binary128(_name, _attr...) _side_field(_name, side_type_float_binary128(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
995#define side_field_string(_name, _attr...) _side_field(_name, side_type_string(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
996#define side_field_string16(_name, _attr...) _side_field(_name, side_type_string16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
997#define side_field_string32(_name, _attr...) _side_field(_name, side_type_string32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
67337c4a
MD
998#define side_field_dynamic(_name) _side_field(_name, side_type_dynamic())
999
1000/* Little endian */
d5a4e361
MD
1001#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()))
1002#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()))
1003#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()))
1004#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()))
1005#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()))
1006#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()))
1007#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()))
1008#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()))
1009#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()))
1010#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()))
1011#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()))
1012#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()))
1013#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()))
1014
1015#define side_field_u16_le(_name, _attr...) _side_field(_name, side_type_u16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1016#define side_field_u32_le(_name, _attr...) _side_field(_name, side_type_u32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1017#define side_field_u64_le(_name, _attr...) _side_field(_name, side_type_u64_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1018#define side_field_s16_le(_name, _attr...) _side_field(_name, side_type_s16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1019#define side_field_s32_le(_name, _attr...) _side_field(_name, side_type_s32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1020#define side_field_s64_le(_name, _attr...) _side_field(_name, side_type_s64_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1021#define side_field_pointer_le(_name, _attr...) _side_field(_name, side_type_pointer_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1022#define side_field_float_binary16_le(_name, _attr...) _side_field(_name, side_type_float_binary16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1023#define side_field_float_binary32_le(_name, _attr...) _side_field(_name, side_type_float_binary32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1024#define side_field_float_binary64_le(_name, _attr...) _side_field(_name, side_type_float_binary64_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1025#define side_field_float_binary128_le(_name, _attr...) _side_field(_name, side_type_float_binary128_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1026#define side_field_string16_le(_name, _attr...) _side_field(_name, side_type_string16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1027#define side_field_string32_le(_name, _attr...) _side_field(_name, side_type_string32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
67337c4a
MD
1028
1029/* Big endian */
d5a4e361
MD
1030#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()))
1031#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()))
1032#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()))
1033#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()))
1034#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()))
1035#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()))
1036#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()))
1037#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()))
1038#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()))
1039#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()))
1040#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()))
1041#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()))
1042#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()))
1043
1044#define side_field_u16_be(_name, _attr...) _side_field(_name, side_type_u16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1045#define side_field_u32_be(_name, _attr...) _side_field(_name, side_type_u32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1046#define side_field_u64_be(_name, _attr...) _side_field(_name, side_type_u64_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1047#define side_field_s16_be(_name, _attr...) _side_field(_name, side_type_s16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1048#define side_field_s32_be(_name, _attr...) _side_field(_name, side_type_s32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1049#define side_field_s64_be(_name, _attr...) _side_field(_name, side_type_s64_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1050#define side_field_pointer_be(_name, _attr...) _side_field(_name, side_type_pointer_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1051#define side_field_float_binary16_be(_name, _attr...) _side_field(_name, side_type_float_binary16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1052#define side_field_float_binary32_be(_name, _attr...) _side_field(_name, side_type_float_binary32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1053#define side_field_float_binary64_be(_name, _attr...) _side_field(_name, side_type_float_binary64_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1054#define side_field_float_binary128_be(_name, _attr...) _side_field(_name, side_type_float_binary128_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1055#define side_field_string16_be(_name, _attr...) _side_field(_name, side_type_string16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1056#define side_field_string32_be(_name, _attr...) _side_field(_name, side_type_string32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
67337c4a
MD
1057
1058#define side_type_enum(_mappings, _elem_type) \
1059 { \
3ce69bfa 1060 .type = SIDE_ENUM_INIT(SIDE_TYPE_ENUM), \
67337c4a
MD
1061 .u = { \
1062 .side_enum = { \
64037418 1063 .mappings = SIDE_PTR_INIT(_mappings), \
c5789285 1064 .elem_type = SIDE_PTR_INIT(_elem_type), \
67337c4a
MD
1065 }, \
1066 }, \
1067 }
1068#define side_field_enum(_name, _mappings, _elem_type) \
1069 _side_field(_name, side_type_enum(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type)))
1070
1071#define side_type_enum_bitmap(_mappings, _elem_type) \
1072 { \
3ce69bfa 1073 .type = SIDE_ENUM_INIT(SIDE_TYPE_ENUM_BITMAP), \
67337c4a
MD
1074 .u = { \
1075 .side_enum_bitmap = { \
64037418 1076 .mappings = SIDE_PTR_INIT(_mappings), \
c5789285 1077 .elem_type = SIDE_PTR_INIT(_elem_type), \
67337c4a
MD
1078 }, \
1079 }, \
1080 }
1081#define side_field_enum_bitmap(_name, _mappings, _elem_type) \
1082 _side_field(_name, side_type_enum_bitmap(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type)))
1083
1084#define side_type_struct(_struct) \
1085 { \
3ce69bfa 1086 .type = SIDE_ENUM_INIT(SIDE_TYPE_STRUCT), \
67337c4a 1087 .u = { \
c5789285 1088 .side_struct = SIDE_PTR_INIT(_struct), \
67337c4a
MD
1089 }, \
1090 }
1091#define side_field_struct(_name, _struct) \
1092 _side_field(_name, side_type_struct(SIDE_PARAM(_struct)))
1093
1094#define _side_type_struct_define(_fields, _attr) \
1095 { \
c5789285 1096 .fields = SIDE_PTR_INIT(_fields), \
12d787db 1097 .attr = SIDE_PTR_INIT(_attr), \
67337c4a
MD
1098 .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
1099 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1100 }
1101
d5a4e361
MD
1102#define side_define_struct(_identifier, _fields, _attr...) \
1103 const struct side_type_struct _identifier = _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
67337c4a 1104
d5a4e361 1105#define side_struct_literal(_fields, _attr...) \
67337c4a 1106 SIDE_COMPOUND_LITERAL(const struct side_type_struct, \
d5a4e361 1107 _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
67337c4a 1108
5530345d
MD
1109#define side_type_variant(_variant) \
1110 { \
3ce69bfa 1111 .type = SIDE_ENUM_INIT(SIDE_TYPE_VARIANT), \
5530345d 1112 .u = { \
c5789285 1113 .side_variant = SIDE_PTR_INIT(_variant), \
5530345d
MD
1114 }, \
1115 }
1116#define side_field_variant(_name, _variant) \
1117 _side_field(_name, side_type_variant(SIDE_PARAM(_variant)))
1118
1119#define _side_type_variant_define(_selector, _options, _attr) \
1120 { \
1121 .selector = _selector, \
c5789285 1122 .options = SIDE_PTR_INIT(_options), \
12d787db 1123 .attr = SIDE_PTR_INIT(_attr), \
5530345d
MD
1124 .nr_options = SIDE_ARRAY_SIZE(SIDE_PARAM(_options)), \
1125 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1126 }
1127
d5a4e361 1128#define side_define_variant(_identifier, _selector, _options, _attr...) \
5530345d 1129 const struct side_type_variant _identifier = \
d5a4e361 1130 _side_type_variant_define(SIDE_PARAM(_selector), SIDE_PARAM(_options), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
5530345d 1131
d5a4e361 1132#define side_variant_literal(_selector, _options, _attr...) \
5530345d 1133 SIDE_COMPOUND_LITERAL(const struct side_type_variant, \
d5a4e361 1134 _side_type_variant_define(SIDE_PARAM(_selector), SIDE_PARAM(_options), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
5530345d 1135
d5a4e361 1136#define side_type_array(_elem_type, _length, _attr...) \
67337c4a 1137 { \
3ce69bfa 1138 .type = SIDE_ENUM_INIT(SIDE_TYPE_ARRAY), \
67337c4a
MD
1139 .u = { \
1140 .side_array = { \
c5789285 1141 .elem_type = SIDE_PTR_INIT(_elem_type), \
12d787db 1142 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a 1143 .length = _length, \
d5a4e361 1144 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1145 }, \
1146 }, \
1147 }
d5a4e361
MD
1148#define side_field_array(_name, _elem_type, _length, _attr...) \
1149 _side_field(_name, side_type_array(SIDE_PARAM(_elem_type), _length, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
67337c4a 1150
d5a4e361 1151#define side_type_vla(_elem_type, _attr...) \
67337c4a 1152 { \
3ce69bfa 1153 .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA), \
67337c4a
MD
1154 .u = { \
1155 .side_vla = { \
c5789285 1156 .elem_type = SIDE_PTR_INIT(_elem_type), \
12d787db 1157 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1158 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1159 }, \
1160 }, \
1161 }
d5a4e361
MD
1162#define side_field_vla(_name, _elem_type, _attr...) \
1163 _side_field(_name, side_type_vla(SIDE_PARAM(_elem_type), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
67337c4a 1164
d5a4e361 1165#define side_type_vla_visitor(_elem_type, _visitor, _attr...) \
67337c4a 1166 { \
3ce69bfa 1167 .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA_VISITOR), \
67337c4a
MD
1168 .u = { \
1169 .side_vla_visitor = { \
c5789285 1170 .elem_type = SIDE_PTR_INIT(_elem_type), \
2e197497 1171 .visitor = SIDE_PTR_INIT(_visitor), \
12d787db 1172 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1173 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1174 }, \
1175 }, \
1176 }
d5a4e361
MD
1177#define side_field_vla_visitor(_name, _elem_type, _visitor, _attr...) \
1178 _side_field(_name, side_type_vla_visitor(SIDE_PARAM(_elem_type), _visitor, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
67337c4a
MD
1179
1180/* Gather field and type definitions */
1181
d5a4e361 1182#define side_type_gather_byte(_offset, _access_mode, _attr...) \
67337c4a 1183 { \
3ce69bfa 1184 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BYTE), \
67337c4a
MD
1185 .u = { \
1186 .side_gather = { \
1187 .u = { \
1188 .side_byte = { \
1189 .offset = _offset, \
1190 .access_mode = _access_mode, \
1191 .type = { \
12d787db 1192 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1193 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1194 }, \
1195 }, \
1196 }, \
1197 }, \
1198 }, \
1199 }
d5a4e361
MD
1200#define side_field_gather_byte(_name, _offset, _access_mode, _attr...) \
1201 _side_field(_name, side_type_gather_byte(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
67337c4a 1202
d5a4e361 1203#define _side_type_gather_bool(_byte_order, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
67337c4a 1204 { \
3ce69bfa 1205 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BOOL), \
67337c4a
MD
1206 .u = { \
1207 .side_gather = { \
1208 .u = { \
1209 .side_bool = { \
1210 .offset = _offset, \
1211 .access_mode = _access_mode, \
1212 .type = { \
db8df9b5 1213 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1214 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1215 .bool_size = _bool_size, \
1216 .len_bits = _len_bits, \
3bc9ba43 1217 .byte_order = SIDE_ENUM_INIT(_byte_order), \
67337c4a
MD
1218 }, \
1219 .offset_bits = _offset_bits, \
1220 }, \
1221 }, \
1222 }, \
1223 }, \
1224 }
d5a4e361
MD
1225#define side_type_gather_bool(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1226 _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()))
1227#define side_type_gather_bool_le(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1228 _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()))
1229#define side_type_gather_bool_be(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1230 _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()))
1231
1232#define side_field_gather_bool(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1233 _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()))))
1234#define side_field_gather_bool_le(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1235 _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()))))
1236#define side_field_gather_bool_be(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1237 _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()))))
67337c4a
MD
1238
1239#define _side_type_gather_integer(_type, _signedness, _byte_order, _offset, \
d5a4e361 1240 _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
67337c4a 1241 { \
3ce69bfa 1242 .type = SIDE_ENUM_INIT(_type), \
67337c4a
MD
1243 .u = { \
1244 .side_gather = { \
1245 .u = { \
1246 .side_integer = { \
1247 .offset = _offset, \
1248 .access_mode = _access_mode, \
1249 .type = { \
12d787db 1250 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1251 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1252 .integer_size = _integer_size, \
1253 .len_bits = _len_bits, \
1254 .signedness = _signedness, \
3bc9ba43 1255 .byte_order = SIDE_ENUM_INIT(_byte_order), \
67337c4a
MD
1256 }, \
1257 .offset_bits = _offset_bits, \
1258 }, \
1259 }, \
1260 }, \
1261 }, \
1262 }
1263
d5a4e361 1264#define side_type_gather_unsigned_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
67337c4a 1265 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_HOST, \
d5a4e361
MD
1266 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1267#define side_type_gather_signed_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
67337c4a 1268 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_HOST, \
d5a4e361 1269 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
67337c4a 1270
d5a4e361 1271#define side_type_gather_unsigned_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
67337c4a 1272 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_LE, \
d5a4e361
MD
1273 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1274#define side_type_gather_signed_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
67337c4a 1275 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_LE, \
d5a4e361 1276 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
67337c4a 1277
d5a4e361 1278#define side_type_gather_unsigned_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
67337c4a 1279 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_BE, \
d5a4e361
MD
1280 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1281#define side_type_gather_signed_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
67337c4a 1282 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_BE, \
d5a4e361 1283 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
67337c4a 1284
d5a4e361
MD
1285#define side_field_gather_unsigned_integer(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1286 _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())))
1287#define side_field_gather_signed_integer(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1288 _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())))
67337c4a 1289
d5a4e361
MD
1290#define side_field_gather_unsigned_integer_le(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1291 _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())))
1292#define side_field_gather_signed_integer_le(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1293 _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())))
67337c4a 1294
d5a4e361
MD
1295#define side_field_gather_unsigned_integer_be(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1296 _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())))
1297#define side_field_gather_signed_integer_be(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
1298 _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())))
67337c4a 1299
d5a4e361 1300#define side_type_gather_pointer(_offset, _access_mode, _attr...) \
67337c4a 1301 _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_HOST, \
d5a4e361
MD
1302 _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1303#define side_field_gather_pointer(_name, _offset, _access_mode, _attr...) \
1304 _side_field(_name, side_type_gather_pointer(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
67337c4a 1305
d5a4e361 1306#define side_type_gather_pointer_le(_offset, _access_mode, _attr...) \
67337c4a 1307 _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_LE, \
d5a4e361
MD
1308 _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1309#define side_field_gather_pointer_le(_name, _offset, _access_mode, _attr...) \
1310 _side_field(_name, side_type_gather_pointer_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
67337c4a 1311
d5a4e361 1312#define side_type_gather_pointer_be(_offset, _access_mode, _attr...) \
67337c4a 1313 _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_BE, \
d5a4e361
MD
1314 _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1315#define side_field_gather_pointer_be(_name, _offset, _access_mode, _attr...) \
1316 _side_field(_name, side_type_gather_pointer_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
67337c4a 1317
d5a4e361 1318#define _side_type_gather_float(_byte_order, _offset, _float_size, _access_mode, _attr...) \
67337c4a 1319 { \
3ce69bfa 1320 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_FLOAT), \
67337c4a
MD
1321 .u = { \
1322 .side_gather = { \
1323 .u = { \
1324 .side_float = { \
1325 .offset = _offset, \
1326 .access_mode = _access_mode, \
1327 .type = { \
12d787db 1328 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1329 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a 1330 .float_size = _float_size, \
3bc9ba43 1331 .byte_order = SIDE_ENUM_INIT(_byte_order), \
67337c4a
MD
1332 }, \
1333 }, \
1334 }, \
1335 }, \
1336 }, \
1337 }
1338
d5a4e361
MD
1339#define side_type_gather_float(_offset, _float_size, _access_mode, _attr...) \
1340 _side_type_gather_float(SIDE_TYPE_FLOAT_WORD_ORDER_HOST, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1341#define side_type_gather_float_le(_offset, _float_size, _access_mode, _attr...) \
1342 _side_type_gather_float(SIDE_TYPE_BYTE_ORDER_LE, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1343#define side_type_gather_float_be(_offset, _float_size, _access_mode, _attr...) \
1344 _side_type_gather_float(SIDE_TYPE_BYTE_ORDER_BE, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1345
1346#define side_field_gather_float(_name, _offset, _float_size, _access_mode, _attr...) \
1347 _side_field(_name, side_type_gather_float(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1348#define side_field_gather_float_le(_name, _offset, _float_size, _access_mode, _attr...) \
1349 _side_field(_name, side_type_gather_float_le(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1350#define side_field_gather_float_be(_name, _offset, _float_size, _access_mode, _attr...) \
1351 _side_field(_name, side_type_gather_float_be(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1352
1353#define _side_type_gather_string(_offset, _byte_order, _unit_size, _access_mode, _attr...) \
67337c4a 1354 { \
3ce69bfa 1355 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRING), \
67337c4a
MD
1356 .u = { \
1357 .side_gather = { \
1358 .u = { \
1359 .side_string = { \
1360 .offset = _offset, \
1361 .access_mode = _access_mode, \
1362 .type = { \
12d787db 1363 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1364 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a 1365 .unit_size = _unit_size, \
3bc9ba43 1366 .byte_order = SIDE_ENUM_INIT(_byte_order), \
67337c4a
MD
1367 }, \
1368 }, \
1369 }, \
1370 }, \
1371 }, \
1372 }
d5a4e361
MD
1373#define side_type_gather_string(_offset, _access_mode, _attr...) \
1374 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1375#define side_field_gather_string(_name, _offset, _access_mode, _attr...) \
1376 _side_field(_name, side_type_gather_string(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1377
1378#define side_type_gather_string16(_offset, _access_mode, _attr...) \
1379 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1380#define side_type_gather_string16_le(_offset, _access_mode, _attr...) \
1381 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1382#define side_type_gather_string16_be(_offset, _access_mode, _attr...) \
1383 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1384
1385#define side_field_gather_string16(_name, _offset, _access_mode, _attr...) \
1386 _side_field(_name, side_type_gather_string16(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1387#define side_field_gather_string16_le(_name, _offset, _access_mode, _attr...) \
1388 _side_field(_name, side_type_gather_string16_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1389#define side_field_gather_string16_be(_name, _offset, _access_mode, _attr...) \
1390 _side_field(_name, side_type_gather_string16_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1391
1392#define side_type_gather_string32(_offset, _access_mode, _attr...) \
1393 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1394#define side_type_gather_string32_le(_offset, _access_mode, _attr...) \
1395 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1396#define side_type_gather_string32_be(_offset, _access_mode, _attr...) \
1397 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1398
1399#define side_field_gather_string32(_name, _offset, _access_mode, _attr...) \
1400 _side_field(_name, side_type_gather_string32(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1401#define side_field_gather_string32_le(_name, _offset, _access_mode, _attr...) \
1402 _side_field(_name, side_type_gather_string32_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
1403#define side_field_gather_string32_be(_name, _offset, _access_mode, _attr...) \
1404 _side_field(_name, side_type_gather_string32_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
67337c4a
MD
1405
1406#define side_type_gather_enum(_mappings, _elem_type) \
1407 { \
3ce69bfa 1408 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_ENUM), \
67337c4a
MD
1409 .u = { \
1410 .side_enum = { \
64037418 1411 .mappings = SIDE_PTR_INIT(_mappings), \
c5789285 1412 .elem_type = SIDE_PTR_INIT(_elem_type), \
67337c4a
MD
1413 }, \
1414 }, \
1415 }
1416#define side_field_gather_enum(_name, _mappings, _elem_type) \
1417 _side_field(_name, side_type_gather_enum(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type)))
1418
1419#define side_type_gather_struct(_struct_gather, _offset, _size, _access_mode) \
1420 { \
3ce69bfa 1421 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRUCT), \
67337c4a
MD
1422 .u = { \
1423 .side_gather = { \
1424 .u = { \
1425 .side_struct = { \
1426 .offset = _offset, \
1427 .access_mode = _access_mode, \
c5789285 1428 .type = SIDE_PTR_INIT(_struct_gather), \
67337c4a
MD
1429 .size = _size, \
1430 }, \
1431 }, \
1432 }, \
1433 }, \
1434 }
1435#define side_field_gather_struct(_name, _struct_gather, _offset, _size, _access_mode) \
1436 _side_field(_name, side_type_gather_struct(SIDE_PARAM(_struct_gather), _offset, _size, _access_mode))
1437
d5a4e361 1438#define side_type_gather_array(_elem_type_gather, _length, _offset, _access_mode, _attr...) \
67337c4a 1439 { \
3ce69bfa 1440 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_ARRAY), \
67337c4a
MD
1441 .u = { \
1442 .side_gather = { \
1443 .u = { \
1444 .side_array = { \
1445 .offset = _offset, \
1446 .access_mode = _access_mode, \
1447 .type = { \
c5789285 1448 .elem_type = SIDE_PTR_INIT(_elem_type_gather), \
12d787db 1449 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a 1450 .length = _length, \
d5a4e361 1451 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1452 }, \
1453 }, \
1454 }, \
1455 }, \
1456 }, \
1457 }
d5a4e361
MD
1458#define side_field_gather_array(_name, _elem_type, _length, _offset, _access_mode, _attr...) \
1459 _side_field(_name, side_type_gather_array(SIDE_PARAM(_elem_type), _length, _offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
67337c4a 1460
d5a4e361 1461#define side_type_gather_vla(_elem_type_gather, _offset, _access_mode, _length_type_gather, _attr...) \
67337c4a 1462 { \
3ce69bfa 1463 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_VLA), \
67337c4a
MD
1464 .u = { \
1465 .side_gather = { \
1466 .u = { \
1467 .side_vla = { \
c5789285 1468 .length_type = SIDE_PTR_INIT(_length_type_gather), \
67337c4a
MD
1469 .offset = _offset, \
1470 .access_mode = _access_mode, \
1471 .type = { \
c5789285 1472 .elem_type = SIDE_PTR_INIT(_elem_type_gather), \
12d787db 1473 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1474 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1475 }, \
1476 }, \
1477 }, \
1478 }, \
1479 }, \
1480 }
d5a4e361
MD
1481#define side_field_gather_vla(_name, _elem_type_gather, _offset, _access_mode, _length_type_gather, _attr...) \
1482 _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())))
67337c4a
MD
1483
1484#define side_elem(...) \
1485 SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__)
1486
1487#define side_length(...) \
1488 SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__)
1489
1490#define side_field_list(...) \
1491 SIDE_COMPOUND_LITERAL(const struct side_event_field, __VA_ARGS__)
1492
5530345d
MD
1493#define side_option_list(...) \
1494 SIDE_COMPOUND_LITERAL(const struct side_variant_option, __VA_ARGS__)
1495
67337c4a
MD
1496/* Stack-copy field arguments */
1497
3ce69bfa
MD
1498#define side_arg_null(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_NULL) }
1499#define side_arg_bool(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_BOOL), .u = { .side_static = { .bool_value = { .side_bool8 = !!(_val) } } } }
1500#define side_arg_byte(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_BYTE), .u = { .side_static = { .byte_value = (_val) } } }
1501#define side_arg_string(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF8), .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } }
1502#define side_arg_string16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF16), .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } }
1503#define side_arg_string32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF32), .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } }
1504
1505#define side_arg_u8(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U8), .u = { .side_static = { .integer_value = { .side_u8 = (_val) } } } }
1506#define side_arg_u16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U16), .u = { .side_static = { .integer_value = { .side_u16 = (_val) } } } }
1507#define side_arg_u32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U32), .u = { .side_static = { .integer_value = { .side_u32 = (_val) } } } }
1508#define side_arg_u64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U64), .u = { .side_static = { .integer_value = { .side_u64 = (_val) } } } }
1509#define side_arg_s8(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S8), .u = { .side_static = { .integer_value = { .side_s8 = (_val) } } } }
1510#define side_arg_s16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S16), .u = { .side_static = { .integer_value = { .side_s16 = (_val) } } } }
1511#define side_arg_s32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S32), .u = { .side_static = { .integer_value = { .side_s32 = (_val) } } } }
1512#define side_arg_s64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S64), .u = { .side_static = { .integer_value = { .side_s64 = (_val) } } } }
1513#define side_arg_pointer(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_POINTER), .u = { .side_static = { .integer_value = { .side_uptr = (uintptr_t) (_val) } } } }
1514#define side_arg_float_binary16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY16), .u = { .side_static = { .float_value = { .side_float_binary16 = (_val) } } } }
1515#define side_arg_float_binary32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY32), .u = { .side_static = { .float_value = { .side_float_binary32 = (_val) } } } }
1516#define side_arg_float_binary64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY64), .u = { .side_static = { .float_value = { .side_float_binary64 = (_val) } } } }
1517#define side_arg_float_binary128(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY128), .u = { .side_static = { .float_value = { .side_float_binary128 = (_val) } } } }
1518
1519#define side_arg_struct(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRUCT), .u = { .side_static = { .side_struct = SIDE_PTR_INIT(_side_type) } } }
5530345d
MD
1520
1521#define side_arg_define_variant(_identifier, _selector_val, _option) \
1522 const struct side_arg_variant _identifier = { \
1523 .selector = _selector_val, \
1524 .option = _option, \
1525 }
1526#define side_arg_variant(_side_variant) \
1527 { \
3ce69bfa 1528 .type = SIDE_ENUM_INIT(SIDE_TYPE_VARIANT), \
5530345d
MD
1529 .u = { \
1530 .side_static = { \
bac71609 1531 .side_variant = SIDE_PTR_INIT(_side_variant), \
5530345d
MD
1532 }, \
1533 }, \
1534 }
1535
3ce69bfa
MD
1536#define side_arg_array(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_ARRAY), .u = { .side_static = { .side_array = SIDE_PTR_INIT(_side_type) } } }
1537#define side_arg_vla(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA), .u = { .side_static = { .side_vla = SIDE_PTR_INIT(_side_type) } } }
1538#define side_arg_vla_visitor(_ctx) { .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA_VISITOR), .u = { .side_static = { .side_vla_app_visitor_ctx = (_ctx) } } }
67337c4a
MD
1539
1540/* Gather field arguments */
1541
3ce69bfa
MD
1542#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) } } }
1543#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) } } }
1544#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) } } }
1545#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) } } }
1546#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) } } }
1547#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) } } }
1548#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) } } }
1549#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) } } }
1550#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) } } } }
67337c4a
MD
1551
1552/* Dynamic field arguments */
1553
d5a4e361 1554#define side_arg_dynamic_null(_attr...) \
67337c4a 1555 { \
3ce69bfa 1556 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_NULL), \
67337c4a
MD
1557 .u = { \
1558 .side_dynamic = { \
1559 .side_null = { \
b313067b 1560 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1561 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1562 }, \
1563 }, \
1564 }, \
1565 }
1566
d5a4e361 1567#define side_arg_dynamic_bool(_val, _attr...) \
67337c4a 1568 { \
3ce69bfa 1569 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_BOOL), \
67337c4a
MD
1570 .u = { \
1571 .side_dynamic = { \
1572 .side_bool = { \
1573 .type = { \
db8df9b5 1574 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1575 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1576 .bool_size = sizeof(uint8_t), \
1577 .len_bits = 0, \
3bc9ba43 1578 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
67337c4a
MD
1579 }, \
1580 .value = { \
1581 .side_bool8 = !!(_val), \
1582 }, \
1583 }, \
1584 }, \
1585 }, \
1586 }
1587
d5a4e361 1588#define side_arg_dynamic_byte(_val, _attr...) \
67337c4a 1589 { \
3ce69bfa 1590 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_BYTE), \
67337c4a
MD
1591 .u = { \
1592 .side_dynamic = { \
1593 .side_byte = { \
1594 .type = { \
12d787db 1595 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1596 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1597 }, \
1598 .value = (_val), \
1599 }, \
1600 }, \
1601 }, \
1602 }
d5a4e361
MD
1603
1604#define _side_arg_dynamic_string(_val, _byte_order, _unit_size, _attr...) \
67337c4a 1605 { \
3ce69bfa 1606 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRING), \
67337c4a
MD
1607 .u = { \
1608 .side_dynamic = { \
1609 .side_string = { \
1610 .type = { \
12d787db 1611 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1612 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a 1613 .unit_size = _unit_size, \
3bc9ba43 1614 .byte_order = SIDE_ENUM_INIT(_byte_order), \
67337c4a
MD
1615 }, \
1616 .value = (uintptr_t) (_val), \
1617 }, \
1618 }, \
1619 }, \
1620 }
d5a4e361
MD
1621#define side_arg_dynamic_string(_val, _attr...) \
1622 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1623#define side_arg_dynamic_string16(_val, _attr...) \
1624 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1625#define side_arg_dynamic_string16_le(_val, _attr...) \
1626 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1627#define side_arg_dynamic_string16_be(_val, _attr...) \
1628 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1629#define side_arg_dynamic_string32(_val, _attr...) \
1630 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1631#define side_arg_dynamic_string32_le(_val, _attr...) \
1632 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1633#define side_arg_dynamic_string32_be(_val, _attr...) \
1634 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1635
1636#define _side_arg_dynamic_integer(_field, _val, _type, _signedness, _byte_order, _integer_size, _len_bits, _attr...) \
67337c4a 1637 { \
3ce69bfa 1638 .type = SIDE_ENUM_INIT(_type), \
67337c4a
MD
1639 .u = { \
1640 .side_dynamic = { \
1641 .side_integer = { \
1642 .type = { \
12d787db 1643 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1644 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1645 .integer_size = _integer_size, \
1646 .len_bits = _len_bits, \
1647 .signedness = _signedness, \
3bc9ba43 1648 .byte_order = SIDE_ENUM_INIT(_byte_order), \
67337c4a
MD
1649 }, \
1650 .value = { \
1651 _field = (_val), \
1652 }, \
1653 }, \
1654 }, \
1655 }, \
1656 }
1657
d5a4e361
MD
1658#define side_arg_dynamic_u8(_val, _attr...) \
1659 _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()))
1660#define side_arg_dynamic_s8(_val, _attr...) \
1661 _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()))
1662
1663#define _side_arg_dynamic_u16(_val, _byte_order, _attr...) \
1664 _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()))
1665#define _side_arg_dynamic_u32(_val, _byte_order, _attr...) \
1666 _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()))
1667#define _side_arg_dynamic_u64(_val, _byte_order, _attr...) \
1668 _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()))
1669
1670#define _side_arg_dynamic_s16(_val, _byte_order, _attr...) \
1671 _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()))
1672#define _side_arg_dynamic_s32(_val, _byte_order, _attr...) \
1673 _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()))
1674#define _side_arg_dynamic_s64(_val, _byte_order, _attr...) \
1675 _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()))
1676
1677#define _side_arg_dynamic_pointer(_val, _byte_order, _attr...) \
67337c4a 1678 _side_arg_dynamic_integer(.side_uptr, (uintptr_t) (_val), SIDE_TYPE_DYNAMIC_POINTER, false, _byte_order, \
d5a4e361 1679 sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
67337c4a 1680
d5a4e361 1681#define _side_arg_dynamic_float(_field, _val, _type, _byte_order, _float_size, _attr...) \
67337c4a 1682 { \
3ce69bfa 1683 .type = SIDE_ENUM_INIT(_type), \
67337c4a
MD
1684 .u = { \
1685 .side_dynamic = { \
1686 .side_float = { \
1687 .type = { \
12d787db 1688 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1689 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a 1690 .float_size = _float_size, \
3bc9ba43 1691 .byte_order = SIDE_ENUM_INIT(_byte_order), \
67337c4a
MD
1692 }, \
1693 .value = { \
1694 _field = (_val), \
1695 }, \
1696 }, \
1697 }, \
1698 }, \
1699 }
1700
d5a4e361
MD
1701#define _side_arg_dynamic_float_binary16(_val, _byte_order, _attr...) \
1702 _side_arg_dynamic_float(.side_float_binary16, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1703#define _side_arg_dynamic_float_binary32(_val, _byte_order, _attr...) \
1704 _side_arg_dynamic_float(.side_float_binary32, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1705#define _side_arg_dynamic_float_binary64(_val, _byte_order, _attr...) \
1706 _side_arg_dynamic_float(.side_float_binary64, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1707#define _side_arg_dynamic_float_binary128(_val, _byte_order, _attr...) \
1708 _side_arg_dynamic_float(.side_float_binary128, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
67337c4a
MD
1709
1710/* Host endian */
d5a4e361
MD
1711#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()))
1712#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()))
1713#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()))
1714#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()))
1715#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()))
1716#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()))
1717#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()))
1718#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()))
1719#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()))
1720#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()))
1721#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()))
67337c4a
MD
1722
1723/* Little endian */
d5a4e361
MD
1724#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()))
1725#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()))
1726#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()))
1727#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()))
1728#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()))
1729#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()))
1730#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()))
1731#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()))
1732#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()))
1733#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()))
1734#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()))
67337c4a
MD
1735
1736/* Big endian */
d5a4e361
MD
1737#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()))
1738#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()))
1739#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()))
1740#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()))
1741#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()))
1742#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()))
1743#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()))
1744#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()))
1745#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()))
1746#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()))
1747#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()))
67337c4a
MD
1748
1749#define side_arg_dynamic_vla(_vla) \
1750 { \
3ce69bfa 1751 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_VLA), \
67337c4a
MD
1752 .u = { \
1753 .side_dynamic = { \
f13253cb 1754 .side_dynamic_vla = SIDE_PTR_INIT(_vla), \
67337c4a
MD
1755 }, \
1756 }, \
1757 }
1758
d5a4e361 1759#define side_arg_dynamic_vla_visitor(_dynamic_vla_visitor, _ctx, _attr...) \
67337c4a 1760 { \
3ce69bfa 1761 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_VLA_VISITOR), \
67337c4a
MD
1762 .u = { \
1763 .side_dynamic = { \
1764 .side_dynamic_vla_visitor = { \
2e197497
MD
1765 .app_ctx = SIDE_PTR_INIT(_ctx), \
1766 .visitor = SIDE_PTR_INIT(_dynamic_vla_visitor), \
12d787db 1767 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1768 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1769 }, \
1770 }, \
1771 }, \
1772 }
1773
1774#define side_arg_dynamic_struct(_struct) \
1775 { \
3ce69bfa 1776 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRUCT), \
67337c4a
MD
1777 .u = { \
1778 .side_dynamic = { \
f13253cb 1779 .side_dynamic_struct = SIDE_PTR_INIT(_struct), \
67337c4a
MD
1780 }, \
1781 }, \
1782 }
1783
d5a4e361 1784#define side_arg_dynamic_struct_visitor(_dynamic_struct_visitor, _ctx, _attr...) \
67337c4a 1785 { \
3ce69bfa 1786 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRUCT_VISITOR), \
67337c4a
MD
1787 .u = { \
1788 .side_dynamic = { \
1789 .side_dynamic_struct_visitor = { \
2e197497
MD
1790 .app_ctx = SIDE_PTR_INIT(_ctx), \
1791 .visitor = SIDE_PTR_INIT(_dynamic_struct_visitor), \
12d787db 1792 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
d5a4e361 1793 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1794 }, \
1795 }, \
1796 }, \
1797 }
1798
d5a4e361 1799#define side_arg_dynamic_define_vec(_identifier, _sav, _attr...) \
67337c4a
MD
1800 const struct side_arg _identifier##_vec[] = { _sav }; \
1801 const struct side_arg_dynamic_vla _identifier = { \
f13253cb 1802 .sav = SIDE_PTR_INIT(_identifier##_vec), \
12d787db 1803 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a 1804 .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
d5a4e361 1805 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1806 }
1807
d5a4e361 1808#define side_arg_dynamic_define_struct(_identifier, _struct_fields, _attr...) \
67337c4a
MD
1809 const struct side_arg_dynamic_field _identifier##_fields[] = { _struct_fields }; \
1810 const struct side_arg_dynamic_struct _identifier = { \
f13253cb 1811 .fields = SIDE_PTR_INIT(_identifier##_fields), \
12d787db 1812 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a 1813 .len = SIDE_ARRAY_SIZE(_identifier##_fields), \
d5a4e361 1814 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a
MD
1815 }
1816
1817#define side_arg_define_vec(_identifier, _sav) \
1818 const struct side_arg _identifier##_vec[] = { _sav }; \
1819 const struct side_arg_vec _identifier = { \
f13253cb 1820 .sav = SIDE_PTR_INIT(_identifier##_vec), \
67337c4a
MD
1821 .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
1822 }
1823
1824#define side_arg_dynamic_field(_name, _elem) \
1825 { \
f13253cb 1826 .field_name = SIDE_PTR_INIT(_name), \
67337c4a
MD
1827 .elem = _elem, \
1828 }
1829
1830/*
1831 * Event instrumentation description registration, runtime enabled state
1832 * check, and instrumentation invocation.
1833 */
1834
1835#define side_arg_list(...) __VA_ARGS__
1836
1837#define side_event_cond(_identifier) \
6c12af2c 1838 if (side_unlikely(__atomic_load_n(&side_event_state__##_identifier.enabled, \
67337c4a
MD
1839 __ATOMIC_RELAXED)))
1840
1841#define side_event_call(_identifier, _sav) \
1842 { \
1843 const struct side_arg side_sav[] = { _sav }; \
1844 const struct side_arg_vec side_arg_vec = { \
f13253cb 1845 .sav = SIDE_PTR_INIT(side_sav), \
67337c4a
MD
1846 .len = SIDE_ARRAY_SIZE(side_sav), \
1847 }; \
0d747f98 1848 side_call(&(side_event_state__##_identifier), &side_arg_vec); \
67337c4a
MD
1849 }
1850
1851#define side_event(_identifier, _sav) \
1852 side_event_cond(_identifier) \
1853 side_event_call(_identifier, SIDE_PARAM(_sav))
1854
d5a4e361 1855#define side_event_call_variadic(_identifier, _sav, _var_fields, _attr...) \
67337c4a
MD
1856 { \
1857 const struct side_arg side_sav[] = { _sav }; \
1858 const struct side_arg_vec side_arg_vec = { \
f13253cb 1859 .sav = SIDE_PTR_INIT(side_sav), \
67337c4a
MD
1860 .len = SIDE_ARRAY_SIZE(side_sav), \
1861 }; \
1862 const struct side_arg_dynamic_field side_fields[] = { _var_fields }; \
1863 const struct side_arg_dynamic_struct var_struct = { \
f13253cb 1864 .fields = SIDE_PTR_INIT(side_fields), \
12d787db 1865 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a 1866 .len = SIDE_ARRAY_SIZE(side_fields), \
d5a4e361 1867 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a 1868 }; \
0d747f98 1869 side_call_variadic(&(side_event_state__##_identifier), &side_arg_vec, &var_struct); \
67337c4a
MD
1870 }
1871
d5a4e361 1872#define side_event_variadic(_identifier, _sav, _var, _attr...) \
67337c4a 1873 side_event_cond(_identifier) \
d5a4e361 1874 side_event_call_variadic(_identifier, SIDE_PARAM(_sav), SIDE_PARAM(_var), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
67337c4a 1875
d5a4e361 1876#define _side_define_event(_linkage, _identifier, _provider, _event, _loglevel, _fields, _flags, _attr...) \
0d747f98
MD
1877 _linkage struct side_event_description __attribute__((section("side_event_description"))) \
1878 _identifier; \
6c12af2c
MD
1879 _linkage struct side_event_state __attribute__((section("side_event_state"))) \
1880 side_event_state__##_identifier = { \
1881 .enabled = 0, \
1882 .callbacks = &side_empty_callback, \
39fe9c03 1883 .desc = &(_identifier), \
6c12af2c 1884 }; \
67337c4a
MD
1885 _linkage struct side_event_description __attribute__((section("side_event_description"))) \
1886 _identifier = { \
441235e7
MD
1887 .struct_size = offsetof(struct side_event_description, end), \
1888 .version = SIDE_ABI_VERSION, \
0b9e59d6
MD
1889 .state = SIDE_PTR_INIT(&(side_event_state__##_identifier)), \
1890 .provider_name = SIDE_PTR_INIT(_provider), \
1891 .event_name = SIDE_PTR_INIT(_event), \
1892 .fields = SIDE_PTR_INIT(_fields), \
12d787db 1893 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
67337c4a 1894 .flags = (_flags), \
1e5997be
MD
1895 .nr_side_type_label = _NR_SIDE_TYPE_LABEL, \
1896 .nr_side_attr_type = _NR_SIDE_ATTR_TYPE, \
1f7aaefb 1897 .loglevel = SIDE_ENUM_INIT(_loglevel), \
67337c4a 1898 .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
d5a4e361 1899 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
f8188f94 1900 .nr_callbacks = 0, \
67337c4a
MD
1901 }; \
1902 static const struct side_event_description *side_event_ptr__##_identifier \
1903 __attribute__((section("side_event_description_ptr"), used)) = &(_identifier);
1904
d5a4e361 1905#define side_static_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
67337c4a 1906 _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
d5a4e361 1907 0, ##_attr)
67337c4a 1908
d5a4e361 1909#define side_static_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
67337c4a 1910 _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
d5a4e361 1911 SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
67337c4a 1912
d5a4e361 1913#define side_hidden_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
67337c4a 1914 _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \
d5a4e361 1915 _loglevel, SIDE_PARAM(_fields), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
67337c4a 1916
d5a4e361 1917#define side_hidden_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
67337c4a 1918 _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \
d5a4e361 1919 _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
67337c4a 1920
d5a4e361 1921#define side_export_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
67337c4a 1922 _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \
d5a4e361 1923 _loglevel, SIDE_PARAM(_fields), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
67337c4a 1924
d5a4e361 1925#define side_export_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
67337c4a 1926 _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \
d5a4e361 1927 _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
67337c4a
MD
1928
1929#define side_declare_event(_identifier) \
6c12af2c 1930 extern struct side_event_state side_event_state_##_identifier; \
67337c4a
MD
1931 extern struct side_event_description _identifier
1932
1933#ifdef __cplusplus
1934extern "C" {
1935#endif
1936
2e197497
MD
1937struct side_callback {
1938 union {
1939 void (*call)(const struct side_event_description *desc,
1940 const struct side_arg_vec *side_arg_vec,
1941 void *priv);
1942 void (*call_variadic)(const struct side_event_description *desc,
1943 const struct side_arg_vec *side_arg_vec,
1944 const struct side_arg_dynamic_struct *var_struct,
1945 void *priv);
1946 } SIDE_PACKED u;
1947 void *priv;
1948} SIDE_PACKED;
1949
1950/* The visitor pattern is a double-dispatch visitor. */
1951struct side_tracer_visitor_ctx {
1952 side_write_elem_func write_elem;
1953 void *priv; /* Private tracer context. */
1954} SIDE_PACKED;
1955
1956struct side_tracer_dynamic_struct_visitor_ctx {
1957 side_write_field_func write_field;
1958 void *priv; /* Private tracer context. */
1959} SIDE_PACKED;
1960
67337c4a
MD
1961extern const struct side_callback side_empty_callback;
1962
0d747f98 1963void side_call(const struct side_event_state *state,
67337c4a 1964 const struct side_arg_vec *side_arg_vec);
0d747f98 1965void side_call_variadic(const struct side_event_state *state,
67337c4a
MD
1966 const struct side_arg_vec *side_arg_vec,
1967 const struct side_arg_dynamic_struct *var_struct);
1968
1969struct side_events_register_handle *side_events_register(struct side_event_description **events,
1970 uint32_t nr_events);
1971void side_events_unregister(struct side_events_register_handle *handle);
1972
1973/*
1974 * Userspace tracer registration API. This allows userspace tracers to
1975 * register event notification callbacks to be notified of the currently
1976 * registered instrumentation, and to register their callbacks to
1977 * specific events.
1978 */
1979typedef void (*side_tracer_callback_func)(const struct side_event_description *desc,
1980 const struct side_arg_vec *side_arg_vec,
1981 void *priv);
1982typedef void (*side_tracer_callback_variadic_func)(const struct side_event_description *desc,
1983 const struct side_arg_vec *side_arg_vec,
1984 const struct side_arg_dynamic_struct *var_struct,
1985 void *priv);
1986
1987int side_tracer_callback_register(struct side_event_description *desc,
1988 side_tracer_callback_func call,
1989 void *priv);
1990int side_tracer_callback_variadic_register(struct side_event_description *desc,
1991 side_tracer_callback_variadic_func call_variadic,
1992 void *priv);
1993int side_tracer_callback_unregister(struct side_event_description *desc,
1994 side_tracer_callback_func call,
1995 void *priv);
1996int side_tracer_callback_variadic_unregister(struct side_event_description *desc,
1997 side_tracer_callback_variadic_func call_variadic,
1998 void *priv);
1999
2000enum side_tracer_notification {
2001 SIDE_TRACER_NOTIFICATION_INSERT_EVENTS,
2002 SIDE_TRACER_NOTIFICATION_REMOVE_EVENTS,
2003};
2004
2005/* Callback is invoked with side library internal lock held. */
2006struct side_tracer_handle *side_tracer_event_notification_register(
2007 void (*cb)(enum side_tracer_notification notif,
2008 struct side_event_description **events, uint32_t nr_events, void *priv),
2009 void *priv);
2010void side_tracer_event_notification_unregister(struct side_tracer_handle *handle);
2011
2012/*
2013 * Explicit hooks to initialize/finalize the side instrumentation
2014 * library. Those are also library constructor/destructor.
2015 */
2016void side_init(void) __attribute__((constructor));
2017void side_exit(void) __attribute__((destructor));
2018
2019/*
2020 * The following constructors/destructors perform automatic registration
2021 * of the declared side events. Those may have to be called explicitly
2022 * in a statically linked library.
2023 */
2024
2025/*
2026 * These weak symbols, the constructor, and destructor take care of
2027 * registering only _one_ instance of the side instrumentation per
2028 * shared-ojbect (or for the whole main program).
2029 */
2030extern struct side_event_description * __start_side_event_description_ptr[]
2031 __attribute__((weak, visibility("hidden")));
2032extern struct side_event_description * __stop_side_event_description_ptr[]
2033 __attribute__((weak, visibility("hidden")));
2034int side_event_description_ptr_registered
2035 __attribute__((weak, visibility("hidden")));
2036struct side_events_register_handle *side_events_handle
2037 __attribute__((weak, visibility("hidden")));
2038
2039static void
2040side_event_description_ptr_init(void)
2041 __attribute__((no_instrument_function))
2042 __attribute__((constructor));
2043static void
2044side_event_description_ptr_init(void)
2045{
2046 if (side_event_description_ptr_registered++)
2047 return;
2048 side_events_handle = side_events_register(__start_side_event_description_ptr,
2049 __stop_side_event_description_ptr - __start_side_event_description_ptr);
2050}
2051
2052static void
2053side_event_description_ptr_exit(void)
2054 __attribute__((no_instrument_function))
2055 __attribute__((destructor));
2056static void
2057side_event_description_ptr_exit(void)
2058{
2059 if (--side_event_description_ptr_registered)
2060 return;
2061 side_events_unregister(side_events_handle);
2062 side_events_handle = NULL;
2063}
2064
2065#ifdef __cplusplus
2066}
2067#endif
2068
2069#endif /* _SIDE_TRACE_H */
This page took 0.133974 seconds and 4 git commands to generate.