Move attributes into dynamic compound types
[libside.git] / include / side / trace.h
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>
14 #include <side/macros.h>
15
16 /* SIDE stands for "Static Instrumentation Dynamically Enabled" */
17
18 //TODO: as those structures will be ABI, we need to either consider them
19 //fixed forever, or think of a scheme that would allow their binary
20 //representation to be extended if need be.
21
22 struct side_arg_vec;
23 struct side_arg_vec_description;
24 struct side_arg_dynamic_vec;
25 struct side_arg_dynamic_vec_vla;
26 struct side_type_description;
27 struct side_event_field;
28 struct side_tracer_visitor_ctx;
29 struct side_tracer_dynamic_struct_visitor_ctx;
30 struct side_tracer_dynamic_vla_visitor_ctx;
31 struct side_event_description;
32 struct side_arg_dynamic_event_struct;
33
34 enum side_type {
35 SIDE_TYPE_BOOL,
36
37 SIDE_TYPE_U8,
38 SIDE_TYPE_U16,
39 SIDE_TYPE_U32,
40 SIDE_TYPE_U64,
41 SIDE_TYPE_S8,
42 SIDE_TYPE_S16,
43 SIDE_TYPE_S32,
44 SIDE_TYPE_S64,
45 SIDE_TYPE_BLOB,
46
47 SIDE_TYPE_ENUM_U8,
48 SIDE_TYPE_ENUM_U16,
49 SIDE_TYPE_ENUM_U32,
50 SIDE_TYPE_ENUM_U64,
51 SIDE_TYPE_ENUM_S8,
52 SIDE_TYPE_ENUM_S16,
53 SIDE_TYPE_ENUM_S32,
54 SIDE_TYPE_ENUM_S64,
55
56 SIDE_TYPE_ENUM_BITMAP8,
57 SIDE_TYPE_ENUM_BITMAP16,
58 SIDE_TYPE_ENUM_BITMAP32,
59 SIDE_TYPE_ENUM_BITMAP64,
60
61 SIDE_TYPE_FLOAT_BINARY16,
62 SIDE_TYPE_FLOAT_BINARY32,
63 SIDE_TYPE_FLOAT_BINARY64,
64 SIDE_TYPE_FLOAT_BINARY128,
65
66 SIDE_TYPE_STRING,
67
68 SIDE_TYPE_STRUCT,
69 SIDE_TYPE_ARRAY,
70 SIDE_TYPE_VLA,
71 SIDE_TYPE_VLA_VISITOR,
72
73 SIDE_TYPE_ARRAY_U8,
74 SIDE_TYPE_ARRAY_U16,
75 SIDE_TYPE_ARRAY_U32,
76 SIDE_TYPE_ARRAY_U64,
77 SIDE_TYPE_ARRAY_S8,
78 SIDE_TYPE_ARRAY_S16,
79 SIDE_TYPE_ARRAY_S32,
80 SIDE_TYPE_ARRAY_S64,
81 SIDE_TYPE_ARRAY_BLOB,
82
83 SIDE_TYPE_VLA_U8,
84 SIDE_TYPE_VLA_U16,
85 SIDE_TYPE_VLA_U32,
86 SIDE_TYPE_VLA_U64,
87 SIDE_TYPE_VLA_S8,
88 SIDE_TYPE_VLA_S16,
89 SIDE_TYPE_VLA_S32,
90 SIDE_TYPE_VLA_S64,
91 SIDE_TYPE_VLA_BLOB,
92
93 SIDE_TYPE_DYNAMIC,
94 };
95
96 enum side_dynamic_type {
97 SIDE_DYNAMIC_TYPE_NULL,
98
99 SIDE_DYNAMIC_TYPE_BOOL,
100
101 SIDE_DYNAMIC_TYPE_U8,
102 SIDE_DYNAMIC_TYPE_U16,
103 SIDE_DYNAMIC_TYPE_U32,
104 SIDE_DYNAMIC_TYPE_U64,
105 SIDE_DYNAMIC_TYPE_S8,
106 SIDE_DYNAMIC_TYPE_S16,
107 SIDE_DYNAMIC_TYPE_S32,
108 SIDE_DYNAMIC_TYPE_S64,
109 SIDE_DYNAMIC_TYPE_BLOB,
110
111 SIDE_DYNAMIC_TYPE_FLOAT_BINARY16,
112 SIDE_DYNAMIC_TYPE_FLOAT_BINARY32,
113 SIDE_DYNAMIC_TYPE_FLOAT_BINARY64,
114 SIDE_DYNAMIC_TYPE_FLOAT_BINARY128,
115
116 SIDE_DYNAMIC_TYPE_STRING,
117
118 SIDE_DYNAMIC_TYPE_STRUCT,
119 SIDE_DYNAMIC_TYPE_STRUCT_VISITOR,
120
121 SIDE_DYNAMIC_TYPE_VLA,
122 SIDE_DYNAMIC_TYPE_VLA_VISITOR,
123 };
124
125 enum side_attr_type {
126 SIDE_ATTR_TYPE_BOOL,
127
128 SIDE_ATTR_TYPE_U8,
129 SIDE_ATTR_TYPE_U16,
130 SIDE_ATTR_TYPE_U32,
131 SIDE_ATTR_TYPE_U64,
132 SIDE_ATTR_TYPE_S8,
133 SIDE_ATTR_TYPE_S16,
134 SIDE_ATTR_TYPE_S32,
135 SIDE_ATTR_TYPE_S64,
136
137 SIDE_ATTR_TYPE_FLOAT_BINARY16,
138 SIDE_ATTR_TYPE_FLOAT_BINARY32,
139 SIDE_ATTR_TYPE_FLOAT_BINARY64,
140 SIDE_ATTR_TYPE_FLOAT_BINARY128,
141
142 SIDE_ATTR_TYPE_STRING,
143 };
144
145 enum side_loglevel {
146 SIDE_LOGLEVEL_EMERG = 0,
147 SIDE_LOGLEVEL_ALERT = 1,
148 SIDE_LOGLEVEL_CRIT = 2,
149 SIDE_LOGLEVEL_ERR = 3,
150 SIDE_LOGLEVEL_WARNING = 4,
151 SIDE_LOGLEVEL_NOTICE = 5,
152 SIDE_LOGLEVEL_INFO = 6,
153 SIDE_LOGLEVEL_DEBUG = 7,
154 };
155
156 enum side_visitor_status {
157 SIDE_VISITOR_STATUS_OK = 0,
158 SIDE_VISITOR_STATUS_ERROR = -1,
159 };
160
161 typedef enum side_visitor_status (*side_visitor)(
162 const struct side_tracer_visitor_ctx *tracer_ctx,
163 void *app_ctx);
164 typedef enum side_visitor_status (*side_dynamic_struct_visitor)(
165 const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx,
166 void *app_ctx);
167 typedef enum side_visitor_status (*side_dynamic_vla_visitor)(
168 const struct side_tracer_dynamic_vla_visitor_ctx *tracer_ctx,
169 void *app_ctx);
170
171 struct side_attr_value {
172 uint32_t type; /* enum side_attr_type */
173 union {
174 uint8_t side_bool;
175
176 uint8_t side_u8;
177 uint16_t side_u16;
178 uint32_t side_u32;
179 uint64_t side_u64;
180 int8_t side_s8;
181 int16_t side_s16;
182 int32_t side_s32;
183 int64_t side_s64;
184
185 #if __HAVE_FLOAT16
186 _Float16 side_float_binary16;
187 #endif
188 #if __HAVE_FLOAT32
189 _Float32 side_float_binary32;
190 #endif
191 #if __HAVE_FLOAT64
192 _Float64 side_float_binary64;
193 #endif
194 #if __HAVE_FLOAT128
195 _Float128 side_float_binary128;
196 #endif
197
198 const char *string;
199 } u;
200 };
201
202 /* User attributes. */
203 struct side_attr {
204 const char *key;
205 const struct side_attr_value value;
206 };
207
208 struct side_enum_mapping {
209 int64_t range_begin;
210 int64_t range_end;
211 const char *label;
212 };
213
214 struct side_enum_mappings {
215 const struct side_enum_mapping *mappings;
216 const struct side_attr *attr;
217 uint32_t nr_mappings;
218 uint32_t nr_attr;
219 };
220
221 struct side_enum_bitmap_mapping {
222 int64_t range_begin;
223 int64_t range_end;
224 const char *label;
225 };
226
227 struct side_enum_bitmap_mappings {
228 const struct side_enum_bitmap_mapping *mappings;
229 const struct side_attr *attr;
230 uint32_t nr_mappings;
231 uint32_t nr_attr;
232 };
233
234 struct side_type_struct {
235 uint32_t nr_fields;
236 uint32_t nr_attr;
237 const struct side_event_field *fields;
238 const struct side_attr *attr;
239 };
240
241 struct side_type_description {
242 uint32_t type; /* enum side_type */
243 union {
244 struct {
245 const struct side_attr *attr;
246 uint32_t nr_attr;
247 } side_basic;
248 struct {
249 const struct side_type_description *elem_type;
250 const struct side_attr *attr;
251 uint32_t length;
252 uint32_t nr_attr;
253 } side_array;
254 struct {
255 const struct side_type_description *elem_type;
256 const struct side_attr *attr;
257 uint32_t nr_attr;
258 } side_vla;
259 struct {
260 const struct side_type_description *elem_type;
261 side_visitor visitor;
262 const struct side_attr *attr;
263 uint32_t nr_attr;
264 } side_vla_visitor;
265 const struct side_type_struct *side_struct;
266 const struct side_enum_mappings *side_enum_mappings;
267 const struct side_enum_bitmap_mappings *side_enum_bitmap_mappings;
268 } u;
269 };
270
271 struct side_event_field {
272 const char *field_name;
273 struct side_type_description side_type;
274 };
275
276 enum side_event_flags {
277 SIDE_EVENT_FLAG_VARIADIC = (1 << 0),
278 };
279
280 struct side_callback {
281 union {
282 void (*call)(const struct side_event_description *desc,
283 const struct side_arg_vec_description *sav_desc,
284 void *priv);
285 void (*call_variadic)(const struct side_event_description *desc,
286 const struct side_arg_vec_description *sav_desc,
287 const struct side_arg_dynamic_event_struct *var_struct,
288 void *priv);
289 } u;
290 void *priv;
291 };
292
293 struct side_callbacks {
294 struct side_callback *cb;
295 uint32_t nr_cb;
296 };
297
298 struct side_event_description {
299 uint32_t version;
300 uint32_t *enabled;
301 uint32_t loglevel; /* enum side_loglevel */
302 uint32_t nr_fields;
303 uint32_t nr_attr;
304 uint32_t _unused;
305 uint64_t flags;
306 const char *provider_name;
307 const char *event_name;
308 const struct side_event_field *fields;
309 const struct side_attr *attr;
310 struct side_callbacks *callbacks;
311 };
312
313 struct side_arg_dynamic_vec {
314 uint32_t dynamic_type; /* enum side_dynamic_type */
315 union {
316 struct {
317 const struct side_attr *attr;
318 uint32_t nr_attr;
319 union {
320 uint8_t side_bool;
321
322 uint8_t side_u8;
323 uint16_t side_u16;
324 uint32_t side_u32;
325 uint64_t side_u64;
326 int8_t side_s8;
327 int16_t side_s16;
328 int32_t side_s32;
329 int64_t side_s64;
330 uint8_t side_blob;
331
332 #if __HAVE_FLOAT16
333 _Float16 side_float_binary16;
334 #endif
335 #if __HAVE_FLOAT32
336 _Float32 side_float_binary32;
337 #endif
338 #if __HAVE_FLOAT64
339 _Float64 side_float_binary64;
340 #endif
341 #if __HAVE_FLOAT128
342 _Float128 side_float_binary128;
343 #endif
344
345 const char *string;
346 } u;
347 } side_basic;
348
349 const struct side_arg_dynamic_event_struct *side_dynamic_struct;
350 struct {
351 void *app_ctx;
352 side_dynamic_struct_visitor visitor;
353 const struct side_attr *attr;
354 uint32_t nr_attr;
355 } side_dynamic_struct_visitor;
356
357 const struct side_arg_dynamic_vec_vla *side_dynamic_vla;
358 struct {
359 void *app_ctx;
360 side_dynamic_vla_visitor visitor;
361 const struct side_attr *attr;
362 uint32_t nr_attr;
363 } side_dynamic_vla_visitor;
364 } u;
365 };
366
367 struct side_arg_dynamic_vec_vla {
368 const struct side_arg_dynamic_vec *sav;
369 const struct side_attr *attr;
370 uint32_t len;
371 uint32_t nr_attr;
372 };
373
374 struct side_arg_dynamic_event_field {
375 const char *field_name;
376 const struct side_arg_dynamic_vec elem;
377 };
378
379 struct side_arg_dynamic_event_struct {
380 const struct side_arg_dynamic_event_field *fields;
381 const struct side_attr *attr;
382 uint32_t len;
383 uint32_t nr_attr;
384 };
385
386 struct side_arg_vec {
387 enum side_type type;
388 union {
389 uint8_t side_bool;
390
391 uint8_t side_u8;
392 uint16_t side_u16;
393 uint32_t side_u32;
394 uint64_t side_u64;
395 int8_t side_s8;
396 int16_t side_s16;
397 int32_t side_s32;
398 int64_t side_s64;
399 uint8_t side_blob;
400
401 #if __HAVE_FLOAT16
402 _Float16 side_float_binary16;
403 #endif
404 #if __HAVE_FLOAT32
405 _Float32 side_float_binary32;
406 #endif
407 #if __HAVE_FLOAT64
408 _Float64 side_float_binary64;
409 #endif
410 #if __HAVE_FLOAT128
411 _Float128 side_float_binary128;
412 #endif
413
414 const char *string;
415 const struct side_arg_vec_description *side_struct;
416 const struct side_arg_vec_description *side_array;
417 const struct side_arg_vec_description *side_vla;
418 void *side_vla_app_visitor_ctx;
419
420 void *side_array_fixint;
421 struct {
422 void *p;
423 uint32_t length;
424 } side_vla_fixint;
425
426 struct side_arg_dynamic_vec dynamic;
427 } u;
428 };
429
430 struct side_arg_vec_description {
431 const struct side_arg_vec *sav;
432 uint32_t len;
433 };
434
435 /* The visitor pattern is a double-dispatch visitor. */
436 struct side_tracer_visitor_ctx {
437 enum side_visitor_status (*write_elem)(
438 const struct side_tracer_visitor_ctx *tracer_ctx,
439 const struct side_arg_vec *elem);
440 void *priv; /* Private tracer context. */
441 };
442
443 struct side_tracer_dynamic_struct_visitor_ctx {
444 enum side_visitor_status (*write_field)(
445 const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx,
446 const struct side_arg_dynamic_event_field *dynamic_field);
447 void *priv; /* Private tracer context. */
448 };
449
450 struct side_tracer_dynamic_vla_visitor_ctx {
451 enum side_visitor_status (*write_elem)(
452 const struct side_tracer_dynamic_vla_visitor_ctx *tracer_ctx,
453 const struct side_arg_dynamic_vec *elem);
454 void *priv; /* Private tracer context. */
455 };
456
457 #define side_attr(_key, _value) \
458 { \
459 .key = _key, \
460 .value = SIDE_PARAM(_value), \
461 }
462
463 #define side_attr_list(...) \
464 SIDE_COMPOUND_LITERAL(const struct side_attr, __VA_ARGS__)
465
466 #define _side_type_basic(_type, _attr) \
467 { \
468 .type = _type, \
469 .u = { \
470 .side_basic = { \
471 .attr = _attr, \
472 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
473 }, \
474 }, \
475 }
476
477 #define side_type_bool(_attr) _side_type_basic(SIDE_TYPE_BOOL, SIDE_PARAM(_attr))
478 #define side_type_u8(_attr) _side_type_basic(SIDE_TYPE_U8, SIDE_PARAM(_attr))
479 #define side_type_u16(_attr) _side_type_basic(SIDE_TYPE_U16, SIDE_PARAM(_attr))
480 #define side_type_u32(_attr) _side_type_basic(SIDE_TYPE_U32, SIDE_PARAM(_attr))
481 #define side_type_u64(_attr) _side_type_basic(SIDE_TYPE_U64, SIDE_PARAM(_attr))
482 #define side_type_s8(_attr) _side_type_basic(SIDE_TYPE_S8, SIDE_PARAM(_attr))
483 #define side_type_s16(_attr) _side_type_basic(SIDE_TYPE_S16, SIDE_PARAM(_attr))
484 #define side_type_s32(_attr) _side_type_basic(SIDE_TYPE_S32, SIDE_PARAM(_attr))
485 #define side_type_s64(_attr) _side_type_basic(SIDE_TYPE_S64, SIDE_PARAM(_attr))
486 #define side_type_blob(_attr) _side_type_basic(SIDE_TYPE_BLOB, SIDE_PARAM(_attr))
487 #define side_type_float_binary16(_attr) _side_type_basic(SIDE_TYPE_FLOAT_BINARY16, SIDE_PARAM(_attr))
488 #define side_type_float_binary32(_attr) _side_type_basic(SIDE_TYPE_FLOAT_BINARY32, SIDE_PARAM(_attr))
489 #define side_type_float_binary64(_attr) _side_type_basic(SIDE_TYPE_FLOAT_BINARY64, SIDE_PARAM(_attr))
490 #define side_type_float_binary128(_attr) _side_type_basic(SIDE_TYPE_FLOAT_BINARY128, SIDE_PARAM(_attr))
491 #define side_type_string(_attr) _side_type_basic(SIDE_TYPE_STRING, SIDE_PARAM(_attr))
492 #define side_type_dynamic(_attr) _side_type_basic(SIDE_TYPE_DYNAMIC, SIDE_PARAM(_attr))
493
494 #define _side_field(_name, _type) \
495 { \
496 .field_name = _name, \
497 .side_type = _type, \
498 }
499
500 #define side_field_bool(_name, _attr) _side_field(_name, side_type_bool(SIDE_PARAM(_attr)))
501 #define side_field_u8(_name, _attr) _side_field(_name, side_type_u8(SIDE_PARAM(_attr)))
502 #define side_field_u16(_name, _attr) _side_field(_name, side_type_u16(SIDE_PARAM(_attr)))
503 #define side_field_u32(_name, _attr) _side_field(_name, side_type_u32(SIDE_PARAM(_attr)))
504 #define side_field_u64(_name, _attr) _side_field(_name, side_type_u64(SIDE_PARAM(_attr)))
505 #define side_field_s8(_name, _attr) _side_field(_name, side_type_s8(SIDE_PARAM(_attr)))
506 #define side_field_s16(_name, _attr) _side_field(_name, side_type_s16(SIDE_PARAM(_attr)))
507 #define side_field_s32(_name, _attr) _side_field(_name, side_type_s32(SIDE_PARAM(_attr)))
508 #define side_field_s64(_name, _attr) _side_field(_name, side_type_s64(SIDE_PARAM(_attr)))
509 #define side_field_blob(_name, _attr) _side_field(_name, side_type_blob(SIDE_PARAM(_attr)))
510 #define side_field_float_binary16(_name, _attr) _side_field(_name, side_type_float_binary16(SIDE_PARAM(_attr)))
511 #define side_field_float_binary32(_name, _attr) _side_field(_name, side_type_float_binary32(SIDE_PARAM(_attr)))
512 #define side_field_float_binary64(_name, _attr) _side_field(_name, side_type_float_binary64(SIDE_PARAM(_attr)))
513 #define side_field_float_binary128(_name, _attr) _side_field(_name, side_type_float_binary128(SIDE_PARAM(_attr)))
514 #define side_field_string(_name, _attr) _side_field(_name, side_type_string(SIDE_PARAM(_attr)))
515 #define side_field_dynamic(_name, _attr) _side_field(_name, side_type_dynamic(SIDE_PARAM(_attr)))
516
517 #define side_type_enum(_type, _mappings) \
518 { \
519 .type = _type, \
520 .u = { \
521 .side_enum_mappings = _mappings, \
522 }, \
523 }
524 #define _side_field_enum(_name, _type, _mappings) \
525 _side_field(_name, side_type_enum(_type, SIDE_PARAM(_mappings)))
526
527 #define side_field_enum_u8(_name, _mappings) \
528 _side_field_enum(_name, SIDE_TYPE_ENUM_U8, SIDE_PARAM(_mappings))
529 #define side_field_enum_u16(_name, _mappings) \
530 _side_field_enum(_name, SIDE_TYPE_ENUM_U16, SIDE_PARAM(_mappings))
531 #define side_field_enum_u32(_name, _mappings) \
532 _side_field_enum(_name, SIDE_TYPE_ENUM_U32, SIDE_PARAM(_mappings))
533 #define side_field_enum_u64(_name, _mappings) \
534 _side_field_enum(_name, SIDE_TYPE_ENUM_U64, SIDE_PARAM(_mappings))
535 #define side_field_enum_s8(_name, _mappings) \
536 _side_field_enum(_name, SIDE_TYPE_ENUM_S8, SIDE_PARAM(_mappings))
537 #define side_field_enum_s16(_name, _mappings) \
538 _side_field_enum(_name, SIDE_TYPE_ENUM_S16, SIDE_PARAM(_mappings))
539 #define side_field_enum_s32(_name, _mappings) \
540 _side_field_enum(_name, SIDE_TYPE_ENUM_S32, SIDE_PARAM(_mappings))
541 #define side_field_enum_s64(_name, _mappings) \
542 _side_field_enum(_name, SIDE_TYPE_ENUM_S64, SIDE_PARAM(_mappings))
543
544 #define side_type_enum_bitmap(_type, _mappings) \
545 { \
546 .type = _type, \
547 .u = { \
548 .side_enum_bitmap_mappings = _mappings, \
549 }, \
550 }
551 #define _side_field_enum_bitmap(_name, _type, _mappings) \
552 _side_field(_name, side_type_enum_bitmap(_type, SIDE_PARAM(_mappings)))
553
554 #define side_field_enum_bitmap8(_name, _mappings) \
555 _side_field_enum_bitmap(_name, SIDE_TYPE_ENUM_BITMAP8, SIDE_PARAM(_mappings))
556 #define side_field_enum_bitmap16(_name, _mappings) \
557 _side_field_enum_bitmap(_name, SIDE_TYPE_ENUM_BITMAP16, SIDE_PARAM(_mappings))
558 #define side_field_enum_bitmap32(_name, _mappings) \
559 _side_field_enum_bitmap(_name, SIDE_TYPE_ENUM_BITMAP32, SIDE_PARAM(_mappings))
560 #define side_field_enum_bitmap64(_name, _mappings) \
561 _side_field_enum_bitmap(_name, SIDE_TYPE_ENUM_BITMAP64, SIDE_PARAM(_mappings))
562
563 #define side_type_struct(_struct) \
564 { \
565 .type = SIDE_TYPE_STRUCT, \
566 .u = { \
567 .side_struct = _struct, \
568 }, \
569 }
570 #define side_field_struct(_name, _struct) \
571 _side_field(_name, side_type_struct(SIDE_PARAM(_struct)))
572
573 #define _side_type_struct_define(_fields, _attr) \
574 { \
575 .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
576 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
577 .fields = _fields, \
578 .attr = _attr, \
579 }
580
581 #define side_define_struct(_identifier, _fields, _attr) \
582 const struct side_type_struct _identifier = _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM(_attr))
583
584 #define side_struct_literal(_fields, _attr) \
585 SIDE_COMPOUND_LITERAL(const struct side_type_struct, \
586 _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM(_attr)))
587
588 #define side_type_array(_elem_type, _length, _attr) \
589 { \
590 .type = SIDE_TYPE_ARRAY, \
591 .u = { \
592 .side_array = { \
593 .elem_type = _elem_type, \
594 .attr = _attr, \
595 .length = _length, \
596 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
597 }, \
598 }, \
599 }
600 #define side_field_array(_name, _elem_type, _length, _attr) \
601 _side_field(_name, side_type_array(SIDE_PARAM(_elem_type), _length, SIDE_PARAM(_attr)))
602
603 #define side_type_vla(_elem_type, _attr) \
604 { \
605 .type = SIDE_TYPE_VLA, \
606 .u = { \
607 .side_vla = { \
608 .elem_type = _elem_type, \
609 .attr = _attr, \
610 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
611 }, \
612 }, \
613 }
614 #define side_field_vla(_name, _elem_type, _attr) \
615 _side_field(_name, side_type_vla(SIDE_PARAM(_elem_type), SIDE_PARAM(_attr)))
616
617 #define side_type_vla_visitor(_elem_type, _visitor, _attr) \
618 { \
619 .type = SIDE_TYPE_VLA_VISITOR, \
620 .u = { \
621 .side_vla_visitor = { \
622 .elem_type = SIDE_PARAM(_elem_type), \
623 .visitor = _visitor, \
624 .attr = _attr, \
625 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
626 }, \
627 }, \
628 }
629 #define side_field_vla_visitor(_name, _elem_type, _visitor, _attr) \
630 _side_field(_name, side_type_vla_visitor(SIDE_PARAM(_elem_type), _visitor, SIDE_PARAM(_attr)))
631
632 #define side_elem(...) \
633 SIDE_COMPOUND_LITERAL(const struct side_type_description, __VA_ARGS__)
634
635 #define side_field_list(...) \
636 SIDE_COMPOUND_LITERAL(const struct side_event_field, __VA_ARGS__)
637
638 #define side_arg_bool(val) { .type = SIDE_TYPE_BOOL, .u = { .side_bool = !!(val) } }
639 #define side_arg_u8(val) { .type = SIDE_TYPE_U8, .u = { .side_u8 = (val) } }
640 #define side_arg_u16(val) { .type = SIDE_TYPE_U16, .u = { .side_u16 = (val) } }
641 #define side_arg_u32(val) { .type = SIDE_TYPE_U32, .u = { .side_u32 = (val) } }
642 #define side_arg_u64(val) { .type = SIDE_TYPE_U64, .u = { .side_u64 = (val) } }
643 #define side_arg_s8(val) { .type = SIDE_TYPE_S8, .u = { .side_s8 = (val) } }
644 #define side_arg_s16(val) { .type = SIDE_TYPE_S16, .u = { .side_s16 = (val) } }
645 #define side_arg_s32(val) { .type = SIDE_TYPE_S32, .u = { .side_s32 = (val) } }
646 #define side_arg_s64(val) { .type = SIDE_TYPE_S64, .u = { .side_s64 = (val) } }
647 #define side_arg_blob(val) { .type = SIDE_TYPE_BLOB, .u = { .side_blob = (val) } }
648 #define side_arg_enum_u8(val) { .type = SIDE_TYPE_ENUM_U8, .u = { .side_u8 = (val) } }
649 #define side_arg_enum_u16(val) { .type = SIDE_TYPE_ENUM_U16, .u = { .side_u16 = (val) } }
650 #define side_arg_enum_u32(val) { .type = SIDE_TYPE_ENUM_U32, .u = { .side_u32 = (val) } }
651 #define side_arg_enum_u64(val) { .type = SIDE_TYPE_ENUM_U64, .u = { .side_u64 = (val) } }
652 #define side_arg_enum_s8(val) { .type = SIDE_TYPE_ENUM_S8, .u = { .side_s8 = (val) } }
653 #define side_arg_enum_s16(val) { .type = SIDE_TYPE_ENUM_S16, .u = { .side_s16 = (val) } }
654 #define side_arg_enum_s32(val) { .type = SIDE_TYPE_ENUM_S32, .u = { .side_s32 = (val) } }
655 #define side_arg_enum_s64(val) { .type = SIDE_TYPE_ENUM_S64, .u = { .side_s64 = (val) } }
656 #define side_arg_enum_bitmap8(val) { .type = SIDE_TYPE_ENUM_BITMAP8, .u = { .side_u8 = (val) } }
657 #define side_arg_enum_bitmap16(val) { .type = SIDE_TYPE_ENUM_BITMAP16, .u = { .side_u16 = (val) } }
658 #define side_arg_enum_bitmap32(val) { .type = SIDE_TYPE_ENUM_BITMAP32, .u = { .side_u32 = (val) } }
659 #define side_arg_enum_bitmap64(val) { .type = SIDE_TYPE_ENUM_BITMAP64, .u = { .side_u64 = (val) } }
660 #define side_arg_float_binary16(val) { .type = SIDE_TYPE_FLOAT_BINARY16, .u = { .side_float_binary16 = (val) } }
661 #define side_arg_float_binary32(val) { .type = SIDE_TYPE_FLOAT_BINARY32, .u = { .side_float_binary32 = (val) } }
662 #define side_arg_float_binary64(val) { .type = SIDE_TYPE_FLOAT_BINARY64, .u = { .side_float_binary64 = (val) } }
663 #define side_arg_float_binary128(val) { .type = SIDE_TYPE_FLOAT_BINARY128, .u = { .side_float_binary128 = (val) } }
664
665 #define side_arg_string(val) { .type = SIDE_TYPE_STRING, .u = { .string = (val) } }
666 #define side_arg_struct(_side_type) { .type = SIDE_TYPE_STRUCT, .u = { .side_struct = (_side_type) } }
667 #define side_arg_array(_side_type) { .type = SIDE_TYPE_ARRAY, .u = { .side_array = (_side_type) } }
668 #define side_arg_vla(_side_type) { .type = SIDE_TYPE_VLA, .u = { .side_vla = (_side_type) } }
669 #define side_arg_vla_visitor(_ctx) { .type = SIDE_TYPE_VLA_VISITOR, .u = { .side_vla_app_visitor_ctx = (_ctx) } }
670
671 #define side_arg_array_u8(_ptr) { .type = SIDE_TYPE_ARRAY_U8, .u = { .side_array_fixint = (_ptr) } }
672 #define side_arg_array_u16(_ptr) { .type = SIDE_TYPE_ARRAY_U16, .u = { .side_array_fixint = (_ptr) } }
673 #define side_arg_array_u32(_ptr) { .type = SIDE_TYPE_ARRAY_U32, .u = { .side_array_fixint = (_ptr) } }
674 #define side_arg_array_u64(_ptr) { .type = SIDE_TYPE_ARRAY_U64, .u = { .side_array_fixint = (_ptr) } }
675 #define side_arg_array_s8(_ptr) { .type = SIDE_TYPE_ARRAY_S8, .u = { .side_array_fixint = (_ptr) } }
676 #define side_arg_array_s16(_ptr) { .type = SIDE_TYPE_ARRAY_S16, .u = { .side_array_fixint = (_ptr) } }
677 #define side_arg_array_s32(_ptr) { .type = SIDE_TYPE_ARRAY_S32, .u = { .side_array_fixint = (_ptr) } }
678 #define side_arg_array_s64(_ptr) { .type = SIDE_TYPE_ARRAY_S64, .u = { .side_array_fixint = (_ptr) } }
679 #define side_arg_array_blob(_ptr) { .type = SIDE_TYPE_ARRAY_BLOB, .u = { .side_array_fixint = (_ptr) } }
680
681 #define side_arg_vla_u8(_ptr, _length) { .type = SIDE_TYPE_VLA_U8, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } }
682 #define side_arg_vla_u16(_ptr, _length) { .type = SIDE_TYPE_VLA_U16, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
683 #define side_arg_vla_u32(_ptr, _length) { .type = SIDE_TYPE_VLA_U32, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
684 #define side_arg_vla_u64(_ptr, _length) { .type = SIDE_TYPE_VLA_U64, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
685 #define side_arg_vla_s8(_ptr, _length) { .type = SIDE_TYPE_VLA_S8, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
686 #define side_arg_vla_s16(_ptr, _length) { .type = SIDE_TYPE_VLA_S16, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
687 #define side_arg_vla_s32(_ptr, _length) { .type = SIDE_TYPE_VLA_S32, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
688 #define side_arg_vla_s64(_ptr, _length) { .type = SIDE_TYPE_VLA_S64, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
689 #define side_arg_vla_blob(_ptr, _length) { .type = SIDE_TYPE_VLA_BLOB, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } }
690
691 #define side_arg_dynamic(dynamic_arg_type) \
692 { \
693 .type = SIDE_TYPE_DYNAMIC, \
694 .u = { \
695 .dynamic = dynamic_arg_type, \
696 }, \
697 }
698
699 #define side_arg_dynamic_null(_attr) \
700 { \
701 .dynamic_type = SIDE_DYNAMIC_TYPE_NULL, \
702 .u = { \
703 .side_basic = { \
704 .attr = _attr, \
705 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
706 }, \
707 }, \
708 }
709
710 #define side_arg_dynamic_bool(_val, _attr) \
711 { \
712 .dynamic_type = SIDE_DYNAMIC_TYPE_BOOL, \
713 .u = { \
714 .side_basic = { \
715 .attr = _attr, \
716 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
717 .u = { \
718 .side_bool = !!(_val), \
719 }, \
720 }, \
721 }, \
722 }
723
724 #define side_arg_dynamic_u8(_val, _attr) \
725 { \
726 .dynamic_type = SIDE_DYNAMIC_TYPE_U8, \
727 .u = { \
728 .side_basic = { \
729 .attr = _attr, \
730 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
731 .u = { \
732 .side_u8 = (_val), \
733 }, \
734 }, \
735 }, \
736 }
737 #define side_arg_dynamic_u16(_val, _attr) \
738 { \
739 .dynamic_type = SIDE_DYNAMIC_TYPE_U16, \
740 .u = { \
741 .side_basic = { \
742 .attr = _attr, \
743 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
744 .u = { \
745 .side_u16 = (_val), \
746 }, \
747 }, \
748 }, \
749 }
750 #define side_arg_dynamic_u32(_val, _attr) \
751 { \
752 .dynamic_type = SIDE_DYNAMIC_TYPE_U32, \
753 .u = { \
754 .side_basic = { \
755 .attr = _attr, \
756 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
757 .u = { \
758 .side_u32 = (_val), \
759 }, \
760 }, \
761 }, \
762 }
763 #define side_arg_dynamic_u64(_val, _attr) \
764 { \
765 .dynamic_type = SIDE_DYNAMIC_TYPE_U64, \
766 .u = { \
767 .side_basic = { \
768 .attr = _attr, \
769 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
770 .u = { \
771 .side_u64 = (_val), \
772 }, \
773 }, \
774 }, \
775 }
776
777 #define side_arg_dynamic_s8(_val, _attr) \
778 { \
779 .dynamic_type = SIDE_DYNAMIC_TYPE_S8, \
780 .u = { \
781 .side_basic = { \
782 .attr = _attr, \
783 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
784 .u = { \
785 .side_s8 = (_val), \
786 }, \
787 }, \
788 }, \
789 }
790 #define side_arg_dynamic_s16(_val, _attr) \
791 { \
792 .dynamic_type = SIDE_DYNAMIC_TYPE_S16, \
793 .u = { \
794 .side_basic = { \
795 .attr = _attr, \
796 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
797 .u = { \
798 .side_s16 = (_val), \
799 }, \
800 }, \
801 }, \
802 }
803 #define side_arg_dynamic_s32(_val, _attr) \
804 { \
805 .dynamic_type = SIDE_DYNAMIC_TYPE_S32, \
806 .u = { \
807 .side_basic = { \
808 .attr = _attr, \
809 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
810 .u = { \
811 .side_s32 = (_val), \
812 }, \
813 }, \
814 }, \
815 }
816 #define side_arg_dynamic_s64(_val, _attr) \
817 { \
818 .dynamic_type = SIDE_DYNAMIC_TYPE_S64, \
819 .u = { \
820 .side_basic = { \
821 .attr = _attr, \
822 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
823 .u = { \
824 .side_s64 = (_val), \
825 }, \
826 }, \
827 }, \
828 }
829 #define side_arg_dynamic_blob(_val, _attr) \
830 { \
831 .dynamic_type = SIDE_DYNAMIC_TYPE_BLOB, \
832 .u = { \
833 .side_basic = { \
834 .attr = _attr, \
835 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
836 .u = { \
837 .side_blob = (_val), \
838 }, \
839 }, \
840 }, \
841 }
842
843 #define side_arg_dynamic_float_binary16(_val, _attr) \
844 { \
845 .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY16, \
846 .u = { \
847 .side_basic = { \
848 .attr = _attr, \
849 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
850 .u = { \
851 .side_float_binary16 = (_val), \
852 }, \
853 }, \
854 }, \
855 }
856 #define side_arg_dynamic_float_binary32(_val, _attr) \
857 { \
858 .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY32, \
859 .u = { \
860 .side_basic = { \
861 .attr = _attr, \
862 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
863 .u = { \
864 .side_float_binary32 = (_val), \
865 }, \
866 }, \
867 }, \
868 }
869 #define side_arg_dynamic_float_binary64(_val, _attr) \
870 { \
871 .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY64, \
872 .u = { \
873 .side_basic = { \
874 .attr = _attr, \
875 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
876 .u = { \
877 .side_float_binary64 = (_val), \
878 }, \
879 }, \
880 }, \
881 }
882 #define side_arg_dynamic_float_binary128(_val, _attr) \
883 { \
884 .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY128, \
885 .u = { \
886 .side_basic = { \
887 .attr = _attr, \
888 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
889 .u = { \
890 .side_float_binary128 = (_val), \
891 }, \
892 }, \
893 }, \
894 }
895
896 #define side_arg_dynamic_string(_val, _attr) \
897 { \
898 .dynamic_type = SIDE_DYNAMIC_TYPE_STRING, \
899 .u = { \
900 .side_basic = { \
901 .attr = _attr, \
902 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
903 .u = { \
904 .string = (_val), \
905 }, \
906 }, \
907 }, \
908 }
909
910 #define side_arg_dynamic_vla(_vla) \
911 { \
912 .dynamic_type = SIDE_DYNAMIC_TYPE_VLA, \
913 .u = { \
914 .side_dynamic_vla = (_vla), \
915 }, \
916 }
917
918 #define side_arg_dynamic_vla_visitor(_dynamic_vla_visitor, _ctx, _attr) \
919 { \
920 .dynamic_type = SIDE_DYNAMIC_TYPE_VLA_VISITOR, \
921 .u = { \
922 .side_dynamic_vla_visitor = { \
923 .app_ctx = _ctx, \
924 .visitor = _dynamic_vla_visitor, \
925 .attr = _attr, \
926 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
927 }, \
928 }, \
929 }
930
931 #define side_arg_dynamic_struct(_struct) \
932 { \
933 .dynamic_type = SIDE_DYNAMIC_TYPE_STRUCT, \
934 .u = { \
935 .side_dynamic_struct = (_struct), \
936 }, \
937 }
938
939 #define side_arg_dynamic_struct_visitor(_dynamic_struct_visitor, _ctx, _attr) \
940 { \
941 .dynamic_type = SIDE_DYNAMIC_TYPE_STRUCT_VISITOR, \
942 .u = { \
943 .side_dynamic_struct_visitor = { \
944 .app_ctx = _ctx, \
945 .visitor = _dynamic_struct_visitor, \
946 .attr = _attr, \
947 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
948 }, \
949 }, \
950 }
951
952 #define side_arg_dynamic_define_vec(_identifier, _sav, _attr) \
953 const struct side_arg_dynamic_vec _identifier##_vec[] = { _sav }; \
954 const struct side_arg_dynamic_vec_vla _identifier = { \
955 .sav = _identifier##_vec, \
956 .attr = _attr, \
957 .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
958 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
959 }
960
961 #define side_arg_dynamic_define_struct(_identifier, _struct_fields, _attr) \
962 const struct side_arg_dynamic_event_field _identifier##_fields[] = { _struct_fields }; \
963 const struct side_arg_dynamic_event_struct _identifier = { \
964 .fields = _identifier##_fields, \
965 .attr = _attr, \
966 .len = SIDE_ARRAY_SIZE(_identifier##_fields), \
967 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
968 }
969
970 #define side_arg_define_vec(_identifier, _sav) \
971 const struct side_arg_vec _identifier##_vec[] = { _sav }; \
972 const struct side_arg_vec_description _identifier = { \
973 .sav = _identifier##_vec, \
974 .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
975 }
976
977 #define side_arg_dynamic_field(_name, _elem) \
978 { \
979 .field_name = _name, \
980 .elem = _elem, \
981 }
982
983 #define side_arg_list(...) __VA_ARGS__
984
985 #define side_attr_bool(val) { .type = SIDE_ATTR_TYPE_BOOL, .u = { .side_bool = !!(val) } }
986 #define side_attr_u8(val) { .type = SIDE_ATTR_TYPE_U8, .u = { .side_u8 = (val) } }
987 #define side_attr_u16(val) { .type = SIDE_ATTR_TYPE_U16, .u = { .side_u16 = (val) } }
988 #define side_attr_u32(val) { .type = SIDE_ATTR_TYPE_U32, .u = { .side_u32 = (val) } }
989 #define side_attr_u64(val) { .type = SIDE_ATTR_TYPE_U64, .u = { .side_u64 = (val) } }
990 #define side_attr_s8(val) { .type = SIDE_ATTR_TYPE_S8, .u = { .side_s8 = (val) } }
991 #define side_attr_s16(val) { .type = SIDE_ATTR_TYPE_S16, .u = { .side_s16 = (val) } }
992 #define side_attr_s32(val) { .type = SIDE_ATTR_TYPE_S32, .u = { .side_s32 = (val) } }
993 #define side_attr_s64(val) { .type = SIDE_ATTR_TYPE_S64, .u = { .side_s64 = (val) } }
994 #define side_attr_float_binary16(val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY16, .u = { .side_float_binary16 = (val) } }
995 #define side_attr_float_binary32(val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY32, .u = { .side_float_binary32 = (val) } }
996 #define side_attr_float_binary64(val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY64, .u = { .side_float_binary64 = (val) } }
997 #define side_attr_float_binary128(val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY128, .u = { .side_float_binary128 = (val) } }
998 #define side_attr_string(val) { .type = SIDE_ATTR_TYPE_STRING, .u = { .string = (val) } }
999
1000 #define side_event_cond(_desc) if (side_unlikely(_desc##_enabled))
1001
1002 #define side_event_call(_desc, _sav) \
1003 { \
1004 const struct side_arg_vec side_sav[] = { _sav }; \
1005 const struct side_arg_vec_description sav_desc = { \
1006 .sav = side_sav, \
1007 .len = SIDE_ARRAY_SIZE(side_sav), \
1008 }; \
1009 side_call(&(_desc), &sav_desc); \
1010 }
1011
1012 #define side_event(_desc, _sav) \
1013 side_event_cond(_desc) \
1014 side_event_call(_desc, SIDE_PARAM(_sav))
1015
1016 #define side_event_call_variadic(_desc, _sav, _var_fields, _attr) \
1017 { \
1018 const struct side_arg_vec side_sav[] = { _sav }; \
1019 const struct side_arg_vec_description sav_desc = { \
1020 .sav = side_sav, \
1021 .len = SIDE_ARRAY_SIZE(side_sav), \
1022 }; \
1023 const struct side_arg_dynamic_event_field side_fields[] = { _var_fields }; \
1024 const struct side_arg_dynamic_event_struct var_struct = { \
1025 .fields = side_fields, \
1026 .attr = _attr, \
1027 .len = SIDE_ARRAY_SIZE(side_fields), \
1028 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1029 }; \
1030 side_call_variadic(&(_desc), &sav_desc, &var_struct); \
1031 }
1032
1033 #define side_event_variadic(_desc, _sav, _var, _attr) \
1034 side_event_cond(_desc) \
1035 side_event_call_variadic(_desc, SIDE_PARAM(_sav), SIDE_PARAM(_var), SIDE_PARAM(_attr))
1036
1037 #define side_define_enum(_identifier, _mappings, _attr) \
1038 const struct side_enum_mappings _identifier = { \
1039 .mappings = _mappings, \
1040 .attr = _attr, \
1041 .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \
1042 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1043 }
1044
1045 #define side_enum_mapping_list(...) \
1046 SIDE_COMPOUND_LITERAL(const struct side_enum_mapping, __VA_ARGS__)
1047
1048 #define side_enum_mapping_range(_label, _begin, _end) \
1049 { \
1050 .range_begin = _begin, \
1051 .range_end = _end, \
1052 .label = _label, \
1053 }
1054
1055 #define side_enum_mapping_value(_label, _value) \
1056 { \
1057 .range_begin = _value, \
1058 .range_end = _value, \
1059 .label = _label, \
1060 }
1061
1062 #define side_define_enum_bitmap(_identifier, _mappings, _attr) \
1063 const struct side_enum_bitmap_mappings _identifier = { \
1064 .mappings = _mappings, \
1065 .attr = _attr, \
1066 .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \
1067 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1068 }
1069
1070 #define side_enum_bitmap_mapping_list(...) \
1071 SIDE_COMPOUND_LITERAL(const struct side_enum_bitmap_mapping, __VA_ARGS__)
1072
1073 #define side_enum_bitmap_mapping_range(_label, _begin, _end) \
1074 { \
1075 .range_begin = _begin, \
1076 .range_end = _end, \
1077 .label = _label, \
1078 }
1079
1080 #define side_enum_bitmap_mapping_value(_label, _value) \
1081 { \
1082 .range_begin = _value, \
1083 .range_end = _value, \
1084 .label = _label, \
1085 }
1086
1087 #define _side_define_event(_identifier, _provider, _event, _loglevel, _fields, _attr, _flags) \
1088 uint32_t _identifier##_enabled __attribute__((section("side_event_enable"))); \
1089 struct side_callbacks _identifier##_callbacks __attribute__((section("side_event_callbacks"))); \
1090 const struct side_event_description _identifier = { \
1091 .version = 0, \
1092 .enabled = &(_identifier##_enabled), \
1093 .loglevel = _loglevel, \
1094 .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
1095 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
1096 .flags = (_flags), \
1097 .provider_name = _provider, \
1098 .event_name = _event, \
1099 .fields = _fields, \
1100 .attr = _attr, \
1101 .callbacks = &(_identifier##_callbacks), \
1102 }; \
1103 const struct side_event_description *_identifier##_ptr \
1104 __attribute__((section("side_event_description"), used)) = &(_identifier);
1105
1106 #define side_define_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \
1107 _side_define_event(_identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
1108 SIDE_PARAM(_attr), 0)
1109
1110 #define side_define_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \
1111 _side_define_event(_identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
1112 SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC)
1113
1114 #define side_declare_event(_identifier) \
1115 struct side_event_description _identifier
1116
1117 void side_call(const struct side_event_description *desc,
1118 const struct side_arg_vec_description *sav_desc);
1119 void side_call_variadic(const struct side_event_description *desc,
1120 const struct side_arg_vec_description *sav_desc,
1121 const struct side_arg_dynamic_event_struct *var_struct);
1122
1123 #endif /* _SIDE_TRACE_H */
This page took 0.057525 seconds and 5 git commands to generate.