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