Commit | Line | Data |
---|---|---|
f611d0c3 MD |
1 | // SPDX-License-Identifier: MIT |
2 | /* | |
3 | * Copyright 2022 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
4 | */ | |
5 | ||
6 | #include <stdint.h> | |
7 | #include <inttypes.h> | |
8 | #include <stdlib.h> | |
9 | #include <stdio.h> | |
4f40d951 | 10 | #include <stdbool.h> |
7a1cb105 | 11 | #include <stddef.h> |
f611d0c3 | 12 | |
67337c4a | 13 | #include <side/trace.h> |
f611d0c3 MD |
14 | |
15 | /* User code example */ | |
16 | ||
67337c4a MD |
17 | side_static_event(my_provider_event, "myprovider", "myevent", SIDE_LOGLEVEL_DEBUG, |
18 | side_field_list( | |
a82ffcff MD |
19 | side_field_u32("abc"), |
20 | side_field_s64("def"), | |
21 | side_field_pointer("ptr"), | |
67337c4a MD |
22 | side_field_dynamic("dynamic"), |
23 | side_field_dynamic("dynamic_pointer"), | |
a82ffcff MD |
24 | side_field_null("null"), |
25 | ) | |
f611d0c3 MD |
26 | ); |
27 | ||
28 | static | |
29 | void test_fields(void) | |
30 | { | |
31 | uint32_t uw = 42; | |
32 | int64_t sdw = -500; | |
33 | ||
67337c4a MD |
34 | side_event(my_provider_event, |
35 | side_arg_list( | |
36 | side_arg_u32(uw), | |
37 | side_arg_s64(sdw), | |
38 | side_arg_pointer((void *) 0x1), | |
a82ffcff MD |
39 | side_arg_dynamic_string("zzz"), |
40 | side_arg_dynamic_pointer((void *) 0x1), | |
67337c4a | 41 | side_arg_null(), |
f5e650d7 MD |
42 | ) |
43 | ); | |
f611d0c3 MD |
44 | } |
45 | ||
67337c4a MD |
46 | side_hidden_event(my_provider_event_hidden, "myprovider", "myeventhidden", SIDE_LOGLEVEL_DEBUG, |
47 | side_field_list( | |
a82ffcff MD |
48 | side_field_u32("abc"), |
49 | ) | |
89747802 MD |
50 | ); |
51 | ||
52 | static | |
53 | void test_event_hidden(void) | |
54 | { | |
67337c4a | 55 | side_event(my_provider_event_hidden, side_arg_list(side_arg_u32(2))); |
89747802 MD |
56 | } |
57 | ||
67337c4a | 58 | side_declare_event(my_provider_event_export); |
89747802 | 59 | |
67337c4a MD |
60 | side_export_event(my_provider_event_export, "myprovider", "myeventexport", SIDE_LOGLEVEL_DEBUG, |
61 | side_field_list( | |
a82ffcff MD |
62 | side_field_u32("abc"), |
63 | ) | |
89747802 MD |
64 | ); |
65 | ||
66 | static | |
67 | void test_event_export(void) | |
68 | { | |
67337c4a | 69 | side_event(my_provider_event_export, side_arg_list(side_arg_u32(2))); |
89747802 MD |
70 | } |
71 | ||
67337c4a MD |
72 | side_static_event(my_provider_event_struct_literal, "myprovider", "myeventstructliteral", SIDE_LOGLEVEL_DEBUG, |
73 | side_field_list( | |
74 | side_field_struct("structliteral", | |
75 | side_struct_literal( | |
76 | side_field_list( | |
a82ffcff MD |
77 | side_field_u32("x"), |
78 | side_field_s64("y"), | |
79 | ) | |
c7a14585 | 80 | ) |
f611d0c3 | 81 | ), |
a82ffcff MD |
82 | side_field_u8("z"), |
83 | ) | |
f611d0c3 MD |
84 | ); |
85 | ||
c7a14585 MD |
86 | static |
87 | void test_struct_literal(void) | |
88 | { | |
67337c4a MD |
89 | side_event_cond(my_provider_event_struct_literal) { |
90 | side_arg_define_vec(mystruct, side_arg_list(side_arg_u32(21), side_arg_s64(22))); | |
91 | side_event_call(my_provider_event_struct_literal, side_arg_list(side_arg_struct(&mystruct), side_arg_u8(55))); | |
c7a14585 MD |
92 | } |
93 | } | |
94 | ||
67337c4a MD |
95 | static side_define_struct(mystructdef, |
96 | side_field_list( | |
a82ffcff MD |
97 | side_field_u32("x"), |
98 | side_field_s64("y"), | |
99 | ) | |
c7a14585 MD |
100 | ); |
101 | ||
67337c4a MD |
102 | side_static_event(my_provider_event_struct, "myprovider", "myeventstruct", SIDE_LOGLEVEL_DEBUG, |
103 | side_field_list( | |
104 | side_field_struct("struct", &mystructdef), | |
a82ffcff MD |
105 | side_field_u8("z"), |
106 | ) | |
c7a14585 MD |
107 | ); |
108 | ||
f611d0c3 MD |
109 | static |
110 | void test_struct(void) | |
111 | { | |
67337c4a MD |
112 | side_event_cond(my_provider_event_struct) { |
113 | side_arg_define_vec(mystruct, side_arg_list(side_arg_u32(21), side_arg_s64(22))); | |
114 | side_event_call(my_provider_event_struct, side_arg_list(side_arg_struct(&mystruct), side_arg_u8(55))); | |
f611d0c3 MD |
115 | } |
116 | } | |
117 | ||
67337c4a MD |
118 | side_static_event(my_provider_event_array, "myprovider", "myarray", SIDE_LOGLEVEL_DEBUG, |
119 | side_field_list( | |
a82ffcff MD |
120 | side_field_array("arr", side_elem(side_type_u32()), 3), |
121 | side_field_s64("v"), | |
122 | ) | |
f611d0c3 MD |
123 | ); |
124 | ||
125 | static | |
126 | void test_array(void) | |
127 | { | |
67337c4a MD |
128 | side_event_cond(my_provider_event_array) { |
129 | side_arg_define_vec(myarray, side_arg_list(side_arg_u32(1), side_arg_u32(2), side_arg_u32(3))); | |
130 | side_event_call(my_provider_event_array, side_arg_list(side_arg_array(&myarray), side_arg_s64(42))); | |
f611d0c3 MD |
131 | } |
132 | } | |
133 | ||
67337c4a MD |
134 | side_static_event(my_provider_event_vla, "myprovider", "myvla", SIDE_LOGLEVEL_DEBUG, |
135 | side_field_list( | |
f0619c77 | 136 | side_field_vla("vla", side_elem(side_type_u32()), side_elem(side_type_u32())), |
a82ffcff MD |
137 | side_field_s64("v"), |
138 | ) | |
f611d0c3 MD |
139 | ); |
140 | ||
141 | static | |
142 | void test_vla(void) | |
143 | { | |
67337c4a MD |
144 | side_event_cond(my_provider_event_vla) { |
145 | side_arg_define_vec(myvla, side_arg_list(side_arg_u32(1), side_arg_u32(2), side_arg_u32(3))); | |
146 | side_event_call(my_provider_event_vla, side_arg_list(side_arg_vla(&myvla), side_arg_s64(42))); | |
f611d0c3 MD |
147 | } |
148 | } | |
149 | ||
cdd6e858 MD |
150 | /* 1D array visitor */ |
151 | ||
f611d0c3 MD |
152 | struct app_visitor_ctx { |
153 | const uint32_t *ptr; | |
352a4b77 | 154 | uint32_t length; |
f611d0c3 MD |
155 | }; |
156 | ||
352a4b77 | 157 | static |
67337c4a | 158 | enum side_visitor_status test_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) |
f611d0c3 MD |
159 | { |
160 | struct app_visitor_ctx *ctx = (struct app_visitor_ctx *) _ctx; | |
352a4b77 MD |
161 | uint32_t length = ctx->length, i; |
162 | ||
163 | for (i = 0; i < length; i++) { | |
67337c4a | 164 | const struct side_arg elem = side_arg_u32(ctx->ptr[i]); |
ffb5c809 | 165 | |
67337c4a MD |
166 | if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) |
167 | return SIDE_VISITOR_STATUS_ERROR; | |
352a4b77 | 168 | } |
67337c4a | 169 | return SIDE_VISITOR_STATUS_OK; |
f611d0c3 MD |
170 | } |
171 | ||
172 | static uint32_t testarray[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; | |
173 | ||
67337c4a MD |
174 | side_static_event(my_provider_event_vla_visitor, "myprovider", "myvlavisit", SIDE_LOGLEVEL_DEBUG, |
175 | side_field_list( | |
f0619c77 MD |
176 | side_field_vla_visitor("vlavisit", |
177 | side_vla_visitor_literal( | |
178 | side_elem(side_type_u32()), | |
179 | side_elem(side_type_u32()), | |
180 | test_visitor | |
181 | ) | |
182 | ), | |
a82ffcff MD |
183 | side_field_s64("v"), |
184 | ) | |
f611d0c3 MD |
185 | ); |
186 | ||
187 | static | |
188 | void test_vla_visitor(void) | |
189 | { | |
67337c4a | 190 | side_event_cond(my_provider_event_vla_visitor) { |
f611d0c3 MD |
191 | struct app_visitor_ctx ctx = { |
192 | .ptr = testarray, | |
67337c4a | 193 | .length = SIDE_ARRAY_SIZE(testarray), |
f611d0c3 | 194 | }; |
c6af61dc MD |
195 | side_arg_define_vla_visitor(side_visitor, &ctx); |
196 | side_event_call(my_provider_event_vla_visitor, | |
197 | side_arg_list(side_arg_vla_visitor(&side_visitor), side_arg_s64(42))); | |
f611d0c3 MD |
198 | } |
199 | } | |
200 | ||
cdd6e858 MD |
201 | /* 2D array visitor */ |
202 | ||
203 | struct app_visitor_2d_inner_ctx { | |
204 | const uint32_t *ptr; | |
205 | uint32_t length; | |
206 | }; | |
207 | ||
208 | static | |
67337c4a | 209 | enum side_visitor_status test_inner_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) |
cdd6e858 MD |
210 | { |
211 | struct app_visitor_2d_inner_ctx *ctx = (struct app_visitor_2d_inner_ctx *) _ctx; | |
212 | uint32_t length = ctx->length, i; | |
213 | ||
214 | for (i = 0; i < length; i++) { | |
67337c4a | 215 | const struct side_arg elem = side_arg_u32(ctx->ptr[i]); |
ffb5c809 | 216 | |
67337c4a MD |
217 | if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) |
218 | return SIDE_VISITOR_STATUS_ERROR; | |
cdd6e858 | 219 | } |
67337c4a | 220 | return SIDE_VISITOR_STATUS_OK; |
cdd6e858 MD |
221 | } |
222 | ||
223 | struct app_visitor_2d_outer_ctx { | |
224 | const uint32_t (*ptr)[2]; | |
225 | uint32_t length; | |
226 | }; | |
227 | ||
228 | static | |
67337c4a | 229 | enum side_visitor_status test_outer_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) |
cdd6e858 MD |
230 | { |
231 | struct app_visitor_2d_outer_ctx *ctx = (struct app_visitor_2d_outer_ctx *) _ctx; | |
232 | uint32_t length = ctx->length, i; | |
233 | ||
234 | for (i = 0; i < length; i++) { | |
235 | struct app_visitor_2d_inner_ctx inner_ctx = { | |
236 | .ptr = ctx->ptr[i], | |
237 | .length = 2, | |
238 | }; | |
c6af61dc MD |
239 | side_arg_define_vla_visitor(side_inner_visitor, &inner_ctx); |
240 | const struct side_arg elem = side_arg_vla_visitor(&side_inner_visitor); | |
67337c4a MD |
241 | if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) |
242 | return SIDE_VISITOR_STATUS_ERROR; | |
cdd6e858 | 243 | } |
67337c4a | 244 | return SIDE_VISITOR_STATUS_OK; |
cdd6e858 MD |
245 | } |
246 | ||
247 | static uint32_t testarray2d[][2] = { | |
248 | { 1, 2 }, | |
249 | { 33, 44 }, | |
250 | { 55, 66 }, | |
251 | }; | |
252 | ||
67337c4a MD |
253 | side_static_event(my_provider_event_vla_visitor2d, "myprovider", "myvlavisit2d", SIDE_LOGLEVEL_DEBUG, |
254 | side_field_list( | |
255 | side_field_vla_visitor("vlavisit2d", | |
f0619c77 MD |
256 | side_vla_visitor_literal( |
257 | side_elem( | |
258 | side_type_vla_visitor( | |
259 | side_vla_visitor_literal( | |
260 | side_elem(side_type_u32()), | |
261 | side_elem(side_type_u32()), | |
262 | test_inner_visitor | |
263 | ) | |
264 | ) | |
265 | ), | |
266 | side_elem(side_type_u32()), | |
267 | test_outer_visitor | |
268 | ) | |
269 | ), | |
a82ffcff MD |
270 | side_field_s64("v"), |
271 | ) | |
cdd6e858 MD |
272 | ); |
273 | ||
274 | static | |
275 | void test_vla_visitor_2d(void) | |
276 | { | |
67337c4a | 277 | side_event_cond(my_provider_event_vla_visitor2d) { |
cdd6e858 MD |
278 | struct app_visitor_2d_outer_ctx ctx = { |
279 | .ptr = testarray2d, | |
67337c4a | 280 | .length = SIDE_ARRAY_SIZE(testarray2d), |
cdd6e858 | 281 | }; |
c6af61dc MD |
282 | side_arg_define_vla_visitor(side_outer_visitor, &ctx); |
283 | side_event_call(my_provider_event_vla_visitor2d, | |
284 | side_arg_list(side_arg_vla_visitor(&side_outer_visitor), side_arg_s64(42))); | |
cdd6e858 MD |
285 | } |
286 | } | |
287 | ||
67337c4a MD |
288 | side_static_event(my_provider_event_dynamic_basic, |
289 | "myprovider", "mydynamicbasic", SIDE_LOGLEVEL_DEBUG, | |
290 | side_field_list( | |
291 | side_field_dynamic("dynamic"), | |
a82ffcff | 292 | ) |
a2e2357e MD |
293 | ); |
294 | ||
295 | static | |
296 | void test_dynamic_basic_type(void) | |
297 | { | |
67337c4a | 298 | side_event(my_provider_event_dynamic_basic, |
a82ffcff | 299 | side_arg_list(side_arg_dynamic_s16(-33))); |
a2e2357e MD |
300 | } |
301 | ||
67337c4a MD |
302 | side_static_event(my_provider_event_dynamic_vla, |
303 | "myprovider", "mydynamicvla", SIDE_LOGLEVEL_DEBUG, | |
304 | side_field_list( | |
305 | side_field_dynamic("dynamic"), | |
a82ffcff | 306 | ) |
a2e2357e MD |
307 | ); |
308 | ||
309 | static | |
310 | void test_dynamic_vla(void) | |
311 | { | |
67337c4a MD |
312 | side_arg_dynamic_define_vec(myvla, |
313 | side_arg_list( | |
a82ffcff MD |
314 | side_arg_dynamic_u32(1), |
315 | side_arg_dynamic_u32(2), | |
316 | side_arg_dynamic_u32(3), | |
317 | ) | |
df075fa5 | 318 | ); |
67337c4a MD |
319 | side_event(my_provider_event_dynamic_vla, |
320 | side_arg_list(side_arg_dynamic_vla(&myvla))); | |
a2e2357e MD |
321 | } |
322 | ||
67337c4a MD |
323 | side_static_event(my_provider_event_dynamic_null, |
324 | "myprovider", "mydynamicnull", SIDE_LOGLEVEL_DEBUG, | |
325 | side_field_list( | |
326 | side_field_dynamic("dynamic"), | |
a82ffcff | 327 | ) |
465e5e7e MD |
328 | ); |
329 | ||
330 | static | |
331 | void test_dynamic_null(void) | |
332 | { | |
67337c4a | 333 | side_event(my_provider_event_dynamic_null, |
a82ffcff | 334 | side_arg_list(side_arg_dynamic_null())); |
465e5e7e MD |
335 | } |
336 | ||
67337c4a MD |
337 | side_static_event(my_provider_event_dynamic_struct, |
338 | "myprovider", "mydynamicstruct", SIDE_LOGLEVEL_DEBUG, | |
339 | side_field_list( | |
340 | side_field_dynamic("dynamic"), | |
a82ffcff | 341 | ) |
465e5e7e MD |
342 | ); |
343 | ||
344 | static | |
c208889e | 345 | void test_dynamic_struct(void) |
465e5e7e | 346 | { |
67337c4a MD |
347 | side_arg_dynamic_define_struct(mystruct, |
348 | side_arg_list( | |
a82ffcff MD |
349 | side_arg_dynamic_field("a", side_arg_dynamic_u32(43)), |
350 | side_arg_dynamic_field("b", side_arg_dynamic_string("zzz")), | |
351 | side_arg_dynamic_field("c", side_arg_dynamic_null()), | |
352 | ) | |
465e5e7e MD |
353 | ); |
354 | ||
67337c4a MD |
355 | side_event(my_provider_event_dynamic_struct, |
356 | side_arg_list(side_arg_dynamic_struct(&mystruct))); | |
465e5e7e MD |
357 | } |
358 | ||
67337c4a MD |
359 | side_static_event(my_provider_event_dynamic_nested_struct, |
360 | "myprovider", "mydynamicnestedstruct", SIDE_LOGLEVEL_DEBUG, | |
361 | side_field_list( | |
362 | side_field_dynamic("dynamic"), | |
a82ffcff | 363 | ) |
3222d397 MD |
364 | ); |
365 | ||
366 | static | |
c208889e | 367 | void test_dynamic_nested_struct(void) |
3222d397 | 368 | { |
67337c4a MD |
369 | side_arg_dynamic_define_struct(nested, |
370 | side_arg_list( | |
a82ffcff MD |
371 | side_arg_dynamic_field("a", side_arg_dynamic_u32(43)), |
372 | side_arg_dynamic_field("b", side_arg_dynamic_u8(55)), | |
373 | ) | |
3222d397 | 374 | ); |
67337c4a MD |
375 | side_arg_dynamic_define_struct(nested2, |
376 | side_arg_list( | |
a82ffcff MD |
377 | side_arg_dynamic_field("aa", side_arg_dynamic_u64(128)), |
378 | side_arg_dynamic_field("bb", side_arg_dynamic_u16(1)), | |
379 | ) | |
3222d397 | 380 | ); |
67337c4a MD |
381 | side_arg_dynamic_define_struct(mystruct, |
382 | side_arg_list( | |
383 | side_arg_dynamic_field("nested", side_arg_dynamic_struct(&nested)), | |
384 | side_arg_dynamic_field("nested2", side_arg_dynamic_struct(&nested2)), | |
a82ffcff | 385 | ) |
3222d397 | 386 | ); |
67337c4a MD |
387 | side_event(my_provider_event_dynamic_nested_struct, |
388 | side_arg_list(side_arg_dynamic_struct(&mystruct))); | |
3222d397 MD |
389 | } |
390 | ||
67337c4a MD |
391 | side_static_event(my_provider_event_dynamic_vla_struct, |
392 | "myprovider", "mydynamicvlastruct", SIDE_LOGLEVEL_DEBUG, | |
393 | side_field_list( | |
394 | side_field_dynamic("dynamic"), | |
a82ffcff | 395 | ) |
7ce1b78f MD |
396 | ); |
397 | ||
398 | static | |
c208889e | 399 | void test_dynamic_vla_struct(void) |
7ce1b78f | 400 | { |
67337c4a MD |
401 | side_arg_dynamic_define_struct(nested, |
402 | side_arg_list( | |
a82ffcff MD |
403 | side_arg_dynamic_field("a", side_arg_dynamic_u32(43)), |
404 | side_arg_dynamic_field("b", side_arg_dynamic_u8(55)), | |
405 | ) | |
7ce1b78f | 406 | ); |
67337c4a MD |
407 | side_arg_dynamic_define_vec(myvla, |
408 | side_arg_list( | |
409 | side_arg_dynamic_struct(&nested), | |
410 | side_arg_dynamic_struct(&nested), | |
411 | side_arg_dynamic_struct(&nested), | |
412 | side_arg_dynamic_struct(&nested), | |
a82ffcff | 413 | ) |
7ce1b78f | 414 | ); |
67337c4a MD |
415 | side_event(my_provider_event_dynamic_vla_struct, |
416 | side_arg_list(side_arg_dynamic_vla(&myvla))); | |
7ce1b78f MD |
417 | } |
418 | ||
67337c4a MD |
419 | side_static_event(my_provider_event_dynamic_struct_vla, |
420 | "myprovider", "mydynamicstructvla", SIDE_LOGLEVEL_DEBUG, | |
421 | side_field_list( | |
422 | side_field_dynamic("dynamic"), | |
a82ffcff | 423 | ) |
980bfdc4 MD |
424 | ); |
425 | ||
426 | static | |
c208889e | 427 | void test_dynamic_struct_vla(void) |
980bfdc4 | 428 | { |
67337c4a MD |
429 | side_arg_dynamic_define_vec(myvla, |
430 | side_arg_list( | |
a82ffcff MD |
431 | side_arg_dynamic_u32(1), |
432 | side_arg_dynamic_u32(2), | |
433 | side_arg_dynamic_u32(3), | |
434 | ) | |
df075fa5 | 435 | ); |
67337c4a MD |
436 | side_arg_dynamic_define_vec(myvla2, |
437 | side_arg_list( | |
a82ffcff MD |
438 | side_arg_dynamic_u32(4), |
439 | side_arg_dynamic_u64(5), | |
440 | side_arg_dynamic_u32(6), | |
441 | ) | |
df075fa5 | 442 | ); |
67337c4a MD |
443 | side_arg_dynamic_define_struct(mystruct, |
444 | side_arg_list( | |
445 | side_arg_dynamic_field("a", side_arg_dynamic_vla(&myvla)), | |
446 | side_arg_dynamic_field("b", side_arg_dynamic_vla(&myvla2)), | |
a82ffcff | 447 | ) |
980bfdc4 | 448 | ); |
67337c4a MD |
449 | side_event(my_provider_event_dynamic_struct_vla, |
450 | side_arg_list(side_arg_dynamic_struct(&mystruct))); | |
980bfdc4 MD |
451 | } |
452 | ||
67337c4a MD |
453 | side_static_event(my_provider_event_dynamic_nested_vla, |
454 | "myprovider", "mydynamicnestedvla", SIDE_LOGLEVEL_DEBUG, | |
455 | side_field_list( | |
456 | side_field_dynamic("dynamic"), | |
a82ffcff | 457 | ) |
948e3e72 MD |
458 | ); |
459 | ||
460 | static | |
461 | void test_dynamic_nested_vla(void) | |
462 | { | |
67337c4a MD |
463 | side_arg_dynamic_define_vec(nestedvla, |
464 | side_arg_list( | |
a82ffcff MD |
465 | side_arg_dynamic_u32(1), |
466 | side_arg_dynamic_u16(2), | |
467 | side_arg_dynamic_u32(3), | |
468 | ) | |
948e3e72 | 469 | ); |
67337c4a MD |
470 | side_arg_dynamic_define_vec(nestedvla2, |
471 | side_arg_list( | |
a82ffcff MD |
472 | side_arg_dynamic_u8(4), |
473 | side_arg_dynamic_u32(5), | |
474 | side_arg_dynamic_u32(6), | |
475 | ) | |
948e3e72 | 476 | ); |
67337c4a MD |
477 | side_arg_dynamic_define_vec(myvla, |
478 | side_arg_list( | |
479 | side_arg_dynamic_vla(&nestedvla), | |
480 | side_arg_dynamic_vla(&nestedvla2), | |
a82ffcff | 481 | ) |
948e3e72 | 482 | ); |
67337c4a MD |
483 | side_event(my_provider_event_dynamic_nested_vla, |
484 | side_arg_list(side_arg_dynamic_vla(&myvla))); | |
948e3e72 MD |
485 | } |
486 | ||
67337c4a MD |
487 | side_static_event_variadic(my_provider_event_variadic, |
488 | "myprovider", "myvariadicevent", SIDE_LOGLEVEL_DEBUG, | |
a82ffcff | 489 | side_field_list() |
19fa6aa2 MD |
490 | ); |
491 | ||
492 | static | |
493 | void test_variadic(void) | |
494 | { | |
67337c4a MD |
495 | side_event_variadic(my_provider_event_variadic, |
496 | side_arg_list(), | |
497 | side_arg_list( | |
a82ffcff MD |
498 | side_arg_dynamic_field("a", side_arg_dynamic_u32(55)), |
499 | side_arg_dynamic_field("b", side_arg_dynamic_s8(-4)), | |
500 | ) | |
19fa6aa2 MD |
501 | ); |
502 | } | |
503 | ||
67337c4a MD |
504 | side_static_event_variadic(my_provider_event_static_variadic, |
505 | "myprovider", "mystaticvariadicevent", SIDE_LOGLEVEL_DEBUG, | |
506 | side_field_list( | |
a82ffcff MD |
507 | side_field_u32("abc"), |
508 | side_field_u16("def"), | |
509 | ) | |
41c4d119 MD |
510 | ); |
511 | ||
512 | static | |
513 | void test_static_variadic(void) | |
514 | { | |
67337c4a MD |
515 | side_event_variadic(my_provider_event_static_variadic, |
516 | side_arg_list( | |
517 | side_arg_u32(1), | |
518 | side_arg_u16(2), | |
41c4d119 | 519 | ), |
67337c4a | 520 | side_arg_list( |
a82ffcff MD |
521 | side_arg_dynamic_field("a", side_arg_dynamic_u32(55)), |
522 | side_arg_dynamic_field("b", side_arg_dynamic_s8(-4)), | |
523 | ) | |
41c4d119 MD |
524 | ); |
525 | } | |
526 | ||
67337c4a MD |
527 | side_static_event(my_provider_event_bool, "myprovider", "myeventbool", SIDE_LOGLEVEL_DEBUG, |
528 | side_field_list( | |
a82ffcff MD |
529 | side_field_bool("a_false"), |
530 | side_field_bool("b_true"), | |
531 | side_field_bool("c_true"), | |
532 | side_field_bool("d_true"), | |
533 | side_field_bool("e_true"), | |
534 | side_field_bool("f_false"), | |
535 | side_field_bool("g_true"), | |
536 | ) | |
4f40d951 MD |
537 | ); |
538 | ||
539 | static | |
540 | void test_bool(void) | |
541 | { | |
542 | uint32_t a = 0; | |
543 | uint32_t b = 1; | |
544 | uint64_t c = 0x12345678; | |
545 | int16_t d = -32768; | |
546 | bool e = true; | |
547 | bool f = false; | |
548 | uint32_t g = 256; | |
549 | ||
67337c4a MD |
550 | side_event(my_provider_event_bool, |
551 | side_arg_list( | |
552 | side_arg_bool(a), | |
553 | side_arg_bool(b), | |
554 | side_arg_bool(c), | |
555 | side_arg_bool(d), | |
556 | side_arg_bool(e), | |
557 | side_arg_bool(f), | |
558 | side_arg_bool(g), | |
4f40d951 MD |
559 | ) |
560 | ); | |
561 | } | |
562 | ||
67337c4a MD |
563 | side_static_event_variadic(my_provider_event_dynamic_bool, |
564 | "myprovider", "mydynamicbool", SIDE_LOGLEVEL_DEBUG, | |
a82ffcff | 565 | side_field_list() |
4f40d951 MD |
566 | ); |
567 | ||
568 | static | |
569 | void test_dynamic_bool(void) | |
570 | { | |
67337c4a MD |
571 | side_event_variadic(my_provider_event_dynamic_bool, |
572 | side_arg_list(), | |
573 | side_arg_list( | |
a82ffcff MD |
574 | side_arg_dynamic_field("a_true", side_arg_dynamic_bool(55)), |
575 | side_arg_dynamic_field("b_true", side_arg_dynamic_bool(-4)), | |
576 | side_arg_dynamic_field("c_false", side_arg_dynamic_bool(0)), | |
577 | side_arg_dynamic_field("d_true", side_arg_dynamic_bool(256)), | |
578 | ) | |
4f40d951 MD |
579 | ); |
580 | } | |
581 | ||
67337c4a MD |
582 | side_static_event(my_provider_event_dynamic_vla_visitor, |
583 | "myprovider", "mydynamicvlavisitor", SIDE_LOGLEVEL_DEBUG, | |
584 | side_field_list( | |
585 | side_field_dynamic("dynamic"), | |
a82ffcff | 586 | ) |
8ceca0cd MD |
587 | ); |
588 | ||
589 | struct app_dynamic_vla_visitor_ctx { | |
590 | const uint32_t *ptr; | |
591 | uint32_t length; | |
592 | }; | |
593 | ||
594 | static | |
67337c4a | 595 | enum side_visitor_status test_dynamic_vla_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) |
8ceca0cd MD |
596 | { |
597 | struct app_dynamic_vla_visitor_ctx *ctx = (struct app_dynamic_vla_visitor_ctx *) _ctx; | |
598 | uint32_t length = ctx->length, i; | |
599 | ||
600 | for (i = 0; i < length; i++) { | |
a82ffcff | 601 | const struct side_arg elem = side_arg_dynamic_u32(ctx->ptr[i]); |
67337c4a MD |
602 | if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) |
603 | return SIDE_VISITOR_STATUS_ERROR; | |
8ceca0cd | 604 | } |
67337c4a | 605 | return SIDE_VISITOR_STATUS_OK; |
8ceca0cd MD |
606 | } |
607 | ||
608 | static uint32_t testarray_dynamic_vla[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; | |
609 | ||
610 | static | |
611 | void test_dynamic_vla_with_visitor(void) | |
612 | { | |
67337c4a | 613 | side_event_cond(my_provider_event_dynamic_vla_visitor) { |
8ceca0cd MD |
614 | struct app_dynamic_vla_visitor_ctx ctx = { |
615 | .ptr = testarray_dynamic_vla, | |
67337c4a | 616 | .length = SIDE_ARRAY_SIZE(testarray_dynamic_vla), |
8ceca0cd | 617 | }; |
c6af61dc | 618 | side_arg_dynamic_define_vla_visitor(myvlavisitor, test_dynamic_vla_visitor, &ctx); |
67337c4a MD |
619 | side_event_call(my_provider_event_dynamic_vla_visitor, |
620 | side_arg_list( | |
c6af61dc | 621 | side_arg_dynamic_vla_visitor(&myvlavisitor) |
8ceca0cd MD |
622 | ) |
623 | ); | |
624 | } | |
625 | } | |
626 | ||
67337c4a MD |
627 | side_static_event(my_provider_event_dynamic_struct_visitor, |
628 | "myprovider", "mydynamicstructvisitor", SIDE_LOGLEVEL_DEBUG, | |
629 | side_field_list( | |
630 | side_field_dynamic("dynamic"), | |
a82ffcff | 631 | ) |
2b359235 MD |
632 | ); |
633 | ||
634 | struct struct_visitor_pair { | |
635 | const char *name; | |
636 | uint32_t value; | |
637 | }; | |
638 | ||
639 | struct app_dynamic_struct_visitor_ctx { | |
640 | const struct struct_visitor_pair *ptr; | |
641 | uint32_t length; | |
642 | }; | |
643 | ||
644 | static | |
67337c4a | 645 | enum side_visitor_status test_dynamic_struct_visitor(const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx, void *_ctx) |
2b359235 MD |
646 | { |
647 | struct app_dynamic_struct_visitor_ctx *ctx = (struct app_dynamic_struct_visitor_ctx *) _ctx; | |
648 | uint32_t length = ctx->length, i; | |
649 | ||
650 | for (i = 0; i < length; i++) { | |
f13253cb MD |
651 | struct side_arg_dynamic_field dynamic_field = |
652 | side_arg_dynamic_field(ctx->ptr[i].name, | |
653 | side_arg_dynamic_u32(ctx->ptr[i].value)); | |
67337c4a MD |
654 | if (tracer_ctx->write_field(tracer_ctx, &dynamic_field) != SIDE_VISITOR_STATUS_OK) |
655 | return SIDE_VISITOR_STATUS_ERROR; | |
2b359235 | 656 | } |
67337c4a | 657 | return SIDE_VISITOR_STATUS_OK; |
2b359235 MD |
658 | } |
659 | ||
660 | static struct struct_visitor_pair testarray_dynamic_struct[] = { | |
661 | { "a", 1, }, | |
662 | { "b", 2, }, | |
663 | { "c", 3, }, | |
664 | { "d", 4, }, | |
665 | }; | |
666 | ||
667 | static | |
668 | void test_dynamic_struct_with_visitor(void) | |
669 | { | |
67337c4a | 670 | side_event_cond(my_provider_event_dynamic_struct_visitor) { |
2b359235 MD |
671 | struct app_dynamic_struct_visitor_ctx ctx = { |
672 | .ptr = testarray_dynamic_struct, | |
67337c4a | 673 | .length = SIDE_ARRAY_SIZE(testarray_dynamic_struct), |
2b359235 | 674 | }; |
c6af61dc | 675 | side_arg_dynamic_define_struct_visitor(mystructvisitor, test_dynamic_struct_visitor, &ctx); |
67337c4a MD |
676 | side_event_call(my_provider_event_dynamic_struct_visitor, |
677 | side_arg_list( | |
c6af61dc | 678 | side_arg_dynamic_struct_visitor(&mystructvisitor) |
2b359235 MD |
679 | ) |
680 | ); | |
681 | } | |
682 | } | |
683 | ||
67337c4a MD |
684 | side_static_event(my_provider_event_user_attribute, "myprovider", "myevent_user_attribute", SIDE_LOGLEVEL_DEBUG, |
685 | side_field_list( | |
a82ffcff MD |
686 | side_field_u32("abc"), |
687 | side_field_s64("def"), | |
399c836b | 688 | ), |
67337c4a MD |
689 | side_attr_list( |
690 | side_attr("user_attribute_a", side_attr_string("val1")), | |
691 | side_attr("user_attribute_b", side_attr_string("val2")), | |
65010f43 MD |
692 | ) |
693 | ); | |
694 | ||
695 | static | |
696 | void test_event_user_attribute(void) | |
697 | { | |
67337c4a | 698 | side_event(my_provider_event_user_attribute, side_arg_list(side_arg_u32(1), side_arg_s64(2))); |
65010f43 MD |
699 | } |
700 | ||
67337c4a MD |
701 | side_static_event(my_provider_field_user_attribute, "myprovider", "myevent_field_attribute", SIDE_LOGLEVEL_DEBUG, |
702 | side_field_list( | |
703 | side_field_u32("abc", | |
704 | side_attr_list( | |
705 | side_attr("user_attribute_a", side_attr_string("val1")), | |
706 | side_attr("user_attribute_b", side_attr_u32(2)), | |
a848763d MD |
707 | ) |
708 | ), | |
67337c4a MD |
709 | side_field_s64("def", |
710 | side_attr_list( | |
711 | side_attr("user_attribute_c", side_attr_string("val3")), | |
712 | side_attr("user_attribute_d", side_attr_s64(-5)), | |
a848763d MD |
713 | ) |
714 | ), | |
a82ffcff | 715 | ) |
a848763d MD |
716 | ); |
717 | ||
718 | static | |
719 | void test_field_user_attribute(void) | |
720 | { | |
67337c4a | 721 | side_event(my_provider_field_user_attribute, side_arg_list(side_arg_u32(1), side_arg_s64(2))); |
a848763d MD |
722 | } |
723 | ||
67337c4a MD |
724 | side_static_event_variadic(my_provider_event_variadic_attr, |
725 | "myprovider", "myvariadiceventattr", SIDE_LOGLEVEL_DEBUG, | |
a82ffcff | 726 | side_field_list() |
808bd9bf MD |
727 | ); |
728 | ||
729 | static | |
730 | void test_variadic_attr(void) | |
731 | { | |
67337c4a MD |
732 | side_event_variadic(my_provider_event_variadic_attr, |
733 | side_arg_list(), | |
734 | side_arg_list( | |
735 | side_arg_dynamic_field("a", | |
736 | side_arg_dynamic_u32(55, | |
737 | side_attr_list( | |
738 | side_attr("user_attribute_c", side_attr_string("valX")), | |
739 | side_attr("user_attribute_d", side_attr_u8(55)), | |
808bd9bf MD |
740 | ) |
741 | ) | |
742 | ), | |
67337c4a MD |
743 | side_arg_dynamic_field("b", |
744 | side_arg_dynamic_s8(-4, | |
745 | side_attr_list( | |
746 | side_attr("X", side_attr_u8(1)), | |
747 | side_attr("Y", side_attr_s8(2)), | |
808bd9bf MD |
748 | ) |
749 | ) | |
750 | ), | |
a82ffcff | 751 | ) |
808bd9bf MD |
752 | ); |
753 | } | |
754 | ||
67337c4a MD |
755 | side_static_event_variadic(my_provider_event_variadic_vla_attr, |
756 | "myprovider", "myvariadiceventvlaattr", SIDE_LOGLEVEL_DEBUG, | |
a82ffcff | 757 | side_field_list() |
808bd9bf MD |
758 | ); |
759 | ||
760 | static | |
761 | void test_variadic_vla_attr(void) | |
762 | { | |
67337c4a MD |
763 | side_arg_dynamic_define_vec(myvla, |
764 | side_arg_list( | |
765 | side_arg_dynamic_u32(1, | |
766 | side_attr_list( | |
767 | side_attr("Z", side_attr_u8(0)), | |
768 | side_attr("A", side_attr_u8(123)), | |
808bd9bf MD |
769 | ) |
770 | ), | |
a82ffcff MD |
771 | side_arg_dynamic_u32(2), |
772 | side_arg_dynamic_u32(3), | |
8d20e708 | 773 | ), |
67337c4a MD |
774 | side_attr_list( |
775 | side_attr("X", side_attr_u8(1)), | |
776 | side_attr("Y", side_attr_u8(2)), | |
808bd9bf MD |
777 | ) |
778 | ); | |
67337c4a MD |
779 | side_event_variadic(my_provider_event_variadic_vla_attr, |
780 | side_arg_list(), | |
781 | side_arg_list( | |
782 | side_arg_dynamic_field("a", side_arg_dynamic_vla(&myvla)), | |
a82ffcff | 783 | ) |
808bd9bf MD |
784 | ); |
785 | } | |
786 | ||
67337c4a MD |
787 | side_static_event_variadic(my_provider_event_variadic_struct_attr, |
788 | "myprovider", "myvariadiceventstructattr", SIDE_LOGLEVEL_DEBUG, | |
a82ffcff | 789 | side_field_list() |
808bd9bf MD |
790 | ); |
791 | ||
792 | static | |
793 | void test_variadic_struct_attr(void) | |
794 | { | |
67337c4a MD |
795 | side_event_cond(my_provider_event_variadic_struct_attr) { |
796 | side_arg_dynamic_define_struct(mystruct, | |
797 | side_arg_list( | |
798 | side_arg_dynamic_field("a", | |
799 | side_arg_dynamic_u32(43, | |
800 | side_attr_list( | |
801 | side_attr("A", side_attr_bool(true)), | |
808bd9bf MD |
802 | ) |
803 | ) | |
804 | ), | |
a82ffcff | 805 | side_arg_dynamic_field("b", side_arg_dynamic_u8(55)), |
8d20e708 | 806 | ), |
67337c4a MD |
807 | side_attr_list( |
808 | side_attr("X", side_attr_u8(1)), | |
809 | side_attr("Y", side_attr_u8(2)), | |
808bd9bf MD |
810 | ) |
811 | ); | |
67337c4a MD |
812 | side_event_call_variadic(my_provider_event_variadic_struct_attr, |
813 | side_arg_list(), | |
814 | side_arg_list( | |
815 | side_arg_dynamic_field("a", side_arg_dynamic_struct(&mystruct)), | |
a82ffcff | 816 | ) |
808bd9bf MD |
817 | ); |
818 | } | |
819 | } | |
820 | ||
67337c4a MD |
821 | side_static_event(my_provider_event_float, "myprovider", "myeventfloat", SIDE_LOGLEVEL_DEBUG, |
822 | side_field_list( | |
fb25b355 | 823 | #if __HAVE_FLOAT16 |
a82ffcff MD |
824 | side_field_float_binary16("binary16"), |
825 | side_field_float_binary16_le("binary16_le"), | |
826 | side_field_float_binary16_be("binary16_be"), | |
fb25b355 MD |
827 | #endif |
828 | #if __HAVE_FLOAT32 | |
a82ffcff MD |
829 | side_field_float_binary32("binary32"), |
830 | side_field_float_binary32_le("binary32_le"), | |
831 | side_field_float_binary32_be("binary32_be"), | |
fb25b355 MD |
832 | #endif |
833 | #if __HAVE_FLOAT64 | |
a82ffcff MD |
834 | side_field_float_binary64("binary64"), |
835 | side_field_float_binary64_le("binary64_le"), | |
836 | side_field_float_binary64_be("binary64_be"), | |
fb25b355 MD |
837 | #endif |
838 | #if __HAVE_FLOAT128 | |
a82ffcff MD |
839 | side_field_float_binary128("binary128"), |
840 | side_field_float_binary128_le("binary128_le"), | |
841 | side_field_float_binary128_be("binary128_be"), | |
fb25b355 | 842 | #endif |
a82ffcff | 843 | ) |
fb25b355 MD |
844 | ); |
845 | ||
846 | static | |
847 | void test_float(void) | |
848 | { | |
8bdd5c12 MD |
849 | #if __HAVE_FLOAT16 |
850 | union { | |
851 | _Float16 f; | |
852 | uint16_t u; | |
853 | } float16 = { | |
854 | .f = 1.1, | |
855 | }; | |
856 | #endif | |
857 | #if __HAVE_FLOAT32 | |
858 | union { | |
859 | _Float32 f; | |
860 | uint32_t u; | |
861 | } float32 = { | |
862 | .f = 2.2, | |
863 | }; | |
864 | #endif | |
865 | #if __HAVE_FLOAT64 | |
866 | union { | |
867 | _Float64 f; | |
868 | uint64_t u; | |
869 | } float64 = { | |
870 | .f = 3.3, | |
871 | }; | |
872 | #endif | |
873 | #if __HAVE_FLOAT128 | |
874 | union { | |
875 | _Float128 f; | |
876 | char arr[16]; | |
877 | } float128 = { | |
878 | .f = 4.4, | |
879 | }; | |
880 | #endif | |
881 | ||
882 | #if __HAVE_FLOAT16 | |
67337c4a | 883 | float16.u = side_bswap_16(float16.u); |
8bdd5c12 MD |
884 | #endif |
885 | #if __HAVE_FLOAT32 | |
67337c4a | 886 | float32.u = side_bswap_32(float32.u); |
8bdd5c12 MD |
887 | #endif |
888 | #if __HAVE_FLOAT64 | |
67337c4a | 889 | float64.u = side_bswap_64(float64.u); |
8bdd5c12 MD |
890 | #endif |
891 | #if __HAVE_FLOAT128 | |
67337c4a | 892 | side_bswap_128p(float128.arr); |
8bdd5c12 MD |
893 | #endif |
894 | ||
67337c4a MD |
895 | side_event(my_provider_event_float, |
896 | side_arg_list( | |
fb25b355 | 897 | #if __HAVE_FLOAT16 |
67337c4a MD |
898 | side_arg_float_binary16(1.1), |
899 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN | |
900 | side_arg_float_binary16(1.1), | |
901 | side_arg_float_binary16(float16.f), | |
8bdd5c12 | 902 | # else |
67337c4a MD |
903 | side_arg_float_binary16(float16.f), |
904 | side_arg_float_binary16(1.1), | |
8bdd5c12 | 905 | # endif |
fb25b355 MD |
906 | #endif |
907 | #if __HAVE_FLOAT32 | |
67337c4a MD |
908 | side_arg_float_binary32(2.2), |
909 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN | |
910 | side_arg_float_binary32(2.2), | |
911 | side_arg_float_binary32(float32.f), | |
8bdd5c12 | 912 | # else |
67337c4a MD |
913 | side_arg_float_binary32(float32.f), |
914 | side_arg_float_binary32(2.2), | |
8bdd5c12 | 915 | # endif |
fb25b355 MD |
916 | #endif |
917 | #if __HAVE_FLOAT64 | |
67337c4a MD |
918 | side_arg_float_binary64(3.3), |
919 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN | |
920 | side_arg_float_binary64(3.3), | |
921 | side_arg_float_binary64(float64.f), | |
8bdd5c12 | 922 | # else |
67337c4a MD |
923 | side_arg_float_binary64(float64.f), |
924 | side_arg_float_binary64(3.3), | |
8bdd5c12 | 925 | # endif |
fb25b355 MD |
926 | #endif |
927 | #if __HAVE_FLOAT128 | |
67337c4a MD |
928 | side_arg_float_binary128(4.4), |
929 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN | |
930 | side_arg_float_binary128(4.4), | |
931 | side_arg_float_binary128(float128.f), | |
8bdd5c12 | 932 | # else |
67337c4a MD |
933 | side_arg_float_binary128(float128.f), |
934 | side_arg_float_binary128(4.4), | |
8bdd5c12 | 935 | # endif |
fb25b355 MD |
936 | #endif |
937 | ) | |
938 | ); | |
939 | } | |
940 | ||
67337c4a MD |
941 | side_static_event_variadic(my_provider_event_variadic_float, |
942 | "myprovider", "myvariadicfloat", SIDE_LOGLEVEL_DEBUG, | |
a82ffcff | 943 | side_field_list() |
fb25b355 MD |
944 | ); |
945 | ||
946 | static | |
947 | void test_variadic_float(void) | |
948 | { | |
8bdd5c12 MD |
949 | #if __HAVE_FLOAT16 |
950 | union { | |
951 | _Float16 f; | |
952 | uint16_t u; | |
953 | } float16 = { | |
954 | .f = 1.1, | |
955 | }; | |
956 | #endif | |
957 | #if __HAVE_FLOAT32 | |
958 | union { | |
959 | _Float32 f; | |
960 | uint32_t u; | |
961 | } float32 = { | |
962 | .f = 2.2, | |
963 | }; | |
964 | #endif | |
965 | #if __HAVE_FLOAT64 | |
966 | union { | |
967 | _Float64 f; | |
968 | uint64_t u; | |
969 | } float64 = { | |
970 | .f = 3.3, | |
971 | }; | |
972 | #endif | |
973 | #if __HAVE_FLOAT128 | |
974 | union { | |
975 | _Float128 f; | |
976 | char arr[16]; | |
977 | } float128 = { | |
978 | .f = 4.4, | |
979 | }; | |
980 | #endif | |
981 | ||
982 | #if __HAVE_FLOAT16 | |
67337c4a | 983 | float16.u = side_bswap_16(float16.u); |
8bdd5c12 MD |
984 | #endif |
985 | #if __HAVE_FLOAT32 | |
67337c4a | 986 | float32.u = side_bswap_32(float32.u); |
8bdd5c12 MD |
987 | #endif |
988 | #if __HAVE_FLOAT64 | |
67337c4a | 989 | float64.u = side_bswap_64(float64.u); |
8bdd5c12 MD |
990 | #endif |
991 | #if __HAVE_FLOAT128 | |
67337c4a | 992 | side_bswap_128p(float128.arr); |
8bdd5c12 MD |
993 | #endif |
994 | ||
67337c4a MD |
995 | side_event_variadic(my_provider_event_variadic_float, |
996 | side_arg_list(), | |
997 | side_arg_list( | |
fb25b355 | 998 | #if __HAVE_FLOAT16 |
a82ffcff | 999 | side_arg_dynamic_field("binary16", side_arg_dynamic_float_binary16(1.1)), |
67337c4a | 1000 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN |
a82ffcff MD |
1001 | side_arg_dynamic_field("binary16_le", side_arg_dynamic_float_binary16_le(1.1)), |
1002 | side_arg_dynamic_field("binary16_be", side_arg_dynamic_float_binary16_be(float16.f)), | |
8bdd5c12 | 1003 | # else |
a82ffcff MD |
1004 | side_arg_dynamic_field("binary16_le", side_arg_dynamic_float_binary16_le(float16.f)), |
1005 | side_arg_dynamic_field("binary16_be", side_arg_dynamic_float_binary16_be(1.1)), | |
8bdd5c12 | 1006 | # endif |
fb25b355 MD |
1007 | #endif |
1008 | #if __HAVE_FLOAT32 | |
a82ffcff | 1009 | side_arg_dynamic_field("binary32", side_arg_dynamic_float_binary32(2.2)), |
67337c4a | 1010 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN |
a82ffcff MD |
1011 | side_arg_dynamic_field("binary32_le", side_arg_dynamic_float_binary32_le(2.2)), |
1012 | side_arg_dynamic_field("binary32_be", side_arg_dynamic_float_binary32_be(float32.f)), | |
8bdd5c12 | 1013 | # else |
a82ffcff MD |
1014 | side_arg_dynamic_field("binary32_le", side_arg_dynamic_float_binary32_le(float32.f)), |
1015 | side_arg_dynamic_field("binary32_be", side_arg_dynamic_float_binary32_be(2.2)), | |
8bdd5c12 | 1016 | # endif |
fb25b355 MD |
1017 | #endif |
1018 | #if __HAVE_FLOAT64 | |
a82ffcff | 1019 | side_arg_dynamic_field("binary64", side_arg_dynamic_float_binary64(3.3)), |
67337c4a | 1020 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN |
a82ffcff MD |
1021 | side_arg_dynamic_field("binary64_le", side_arg_dynamic_float_binary64_le(3.3)), |
1022 | side_arg_dynamic_field("binary64_be", side_arg_dynamic_float_binary64_be(float64.f)), | |
8bdd5c12 | 1023 | # else |
a82ffcff MD |
1024 | side_arg_dynamic_field("binary64_le", side_arg_dynamic_float_binary64_le(float64.f)), |
1025 | side_arg_dynamic_field("binary64_be", side_arg_dynamic_float_binary64_be(3.3)), | |
8bdd5c12 | 1026 | # endif |
fb25b355 MD |
1027 | #endif |
1028 | #if __HAVE_FLOAT128 | |
a82ffcff | 1029 | side_arg_dynamic_field("binary128", side_arg_dynamic_float_binary128(4.4)), |
67337c4a | 1030 | # if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN |
a82ffcff MD |
1031 | side_arg_dynamic_field("binary128_le", side_arg_dynamic_float_binary128_le(4.4)), |
1032 | side_arg_dynamic_field("binary128_be", side_arg_dynamic_float_binary128_be(float128.f)), | |
8bdd5c12 | 1033 | # else |
a82ffcff MD |
1034 | side_arg_dynamic_field("binary128_le", side_arg_dynamic_float_binary128_le(float128.f)), |
1035 | side_arg_dynamic_field("binary128_be", side_arg_dynamic_float_binary128_be(4.4)), | |
8bdd5c12 | 1036 | # endif |
fb25b355 | 1037 | #endif |
a82ffcff | 1038 | ) |
fb25b355 MD |
1039 | ); |
1040 | } | |
1041 | ||
67337c4a MD |
1042 | static side_define_enum(myenum, |
1043 | side_enum_mapping_list( | |
1044 | side_enum_mapping_range("one-ten", 1, 10), | |
1045 | side_enum_mapping_range("100-200", 100, 200), | |
1046 | side_enum_mapping_value("200", 200), | |
1047 | side_enum_mapping_value("300", 300), | |
a82ffcff | 1048 | ) |
79f677ba MD |
1049 | ); |
1050 | ||
67337c4a MD |
1051 | side_static_event(my_provider_event_enum, "myprovider", "myeventenum", SIDE_LOGLEVEL_DEBUG, |
1052 | side_field_list( | |
a82ffcff MD |
1053 | side_field_enum("5", &myenum, side_elem(side_type_u32())), |
1054 | side_field_enum("400", &myenum, side_elem(side_type_u64())), | |
1055 | side_field_enum("200", &myenum, side_elem(side_type_u8())), | |
1056 | side_field_enum("-100", &myenum, side_elem(side_type_s8())), | |
1057 | side_field_enum("6_be", &myenum, side_elem(side_type_u32_be())), | |
1058 | side_field_enum("6_le", &myenum, side_elem(side_type_u32_le())), | |
1059 | ) | |
79f677ba MD |
1060 | ); |
1061 | ||
1062 | static | |
1063 | void test_enum(void) | |
1064 | { | |
67337c4a MD |
1065 | side_event(my_provider_event_enum, |
1066 | side_arg_list( | |
1067 | side_arg_u32(5), | |
1068 | side_arg_u64(400), | |
1069 | side_arg_u8(200), | |
1070 | side_arg_s8(-100), | |
1071 | #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN | |
1072 | side_arg_u32(side_bswap_32(6)), | |
1073 | side_arg_u32(6), | |
8bdd5c12 | 1074 | #else |
67337c4a MD |
1075 | side_arg_u32(6), |
1076 | side_arg_u32(side_bswap_32(6)), | |
8bdd5c12 | 1077 | #endif |
79f677ba MD |
1078 | ) |
1079 | ); | |
1080 | } | |
1081 | ||
ea32e5fc | 1082 | /* A bitmap enum maps bits to labels. */ |
67337c4a MD |
1083 | static side_define_enum_bitmap(myenum_bitmap, |
1084 | side_enum_bitmap_mapping_list( | |
1085 | side_enum_bitmap_mapping_value("0", 0), | |
1086 | side_enum_bitmap_mapping_range("1-2", 1, 2), | |
1087 | side_enum_bitmap_mapping_range("2-4", 2, 4), | |
1088 | side_enum_bitmap_mapping_value("3", 3), | |
1089 | side_enum_bitmap_mapping_value("30", 30), | |
1090 | side_enum_bitmap_mapping_value("63", 63), | |
1091 | side_enum_bitmap_mapping_range("158-160", 158, 160), | |
1092 | side_enum_bitmap_mapping_value("159", 159), | |
1093 | side_enum_bitmap_mapping_range("500-700", 500, 700), | |
a82ffcff | 1094 | ) |
ea32e5fc MD |
1095 | ); |
1096 | ||
67337c4a MD |
1097 | side_static_event(my_provider_event_enum_bitmap, "myprovider", "myeventenumbitmap", SIDE_LOGLEVEL_DEBUG, |
1098 | side_field_list( | |
a82ffcff MD |
1099 | side_field_enum_bitmap("bit_0", &myenum_bitmap, side_elem(side_type_u32())), |
1100 | side_field_enum_bitmap("bit_1", &myenum_bitmap, side_elem(side_type_u32())), | |
1101 | side_field_enum_bitmap("bit_2", &myenum_bitmap, side_elem(side_type_u8())), | |
1102 | side_field_enum_bitmap("bit_3", &myenum_bitmap, side_elem(side_type_u8())), | |
1103 | side_field_enum_bitmap("bit_30", &myenum_bitmap, side_elem(side_type_u32())), | |
1104 | side_field_enum_bitmap("bit_31", &myenum_bitmap, side_elem(side_type_u32())), | |
1105 | side_field_enum_bitmap("bit_63", &myenum_bitmap, side_elem(side_type_u64())), | |
1106 | side_field_enum_bitmap("bits_1+63", &myenum_bitmap, side_elem(side_type_u64())), | |
1107 | side_field_enum_bitmap("byte_bit_2", &myenum_bitmap, side_elem(side_type_byte())), | |
67337c4a | 1108 | side_field_enum_bitmap("bit_159", &myenum_bitmap, |
a82ffcff | 1109 | side_elem(side_type_array(side_elem(side_type_u32()), 5))), |
67337c4a | 1110 | side_field_enum_bitmap("bit_159", &myenum_bitmap, |
f0619c77 | 1111 | side_elem(side_type_vla(side_elem(side_type_u32()), side_elem(side_type_u32())))), |
a82ffcff MD |
1112 | side_field_enum_bitmap("bit_2_be", &myenum_bitmap, side_elem(side_type_u32_be())), |
1113 | side_field_enum_bitmap("bit_2_le", &myenum_bitmap, side_elem(side_type_u32_le())), | |
1114 | ) | |
ea32e5fc MD |
1115 | ); |
1116 | ||
1117 | static | |
1118 | void test_enum_bitmap(void) | |
1119 | { | |
67337c4a MD |
1120 | side_event_cond(my_provider_event_enum_bitmap) { |
1121 | side_arg_define_vec(myarray, | |
1122 | side_arg_list( | |
1123 | side_arg_u32(0), | |
1124 | side_arg_u32(0), | |
1125 | side_arg_u32(0), | |
1126 | side_arg_u32(0), | |
1127 | side_arg_u32(0x80000000), /* bit 159 */ | |
af6aa6e1 MD |
1128 | ) |
1129 | ); | |
67337c4a MD |
1130 | side_event_call(my_provider_event_enum_bitmap, |
1131 | side_arg_list( | |
1132 | side_arg_u32(1U << 0), | |
1133 | side_arg_u32(1U << 1), | |
1134 | side_arg_u8(1U << 2), | |
1135 | side_arg_u8(1U << 3), | |
1136 | side_arg_u32(1U << 30), | |
1137 | side_arg_u32(1U << 31), | |
1138 | side_arg_u64(1ULL << 63), | |
1139 | side_arg_u64((1ULL << 1) | (1ULL << 63)), | |
1140 | side_arg_byte(1U << 2), | |
1141 | side_arg_array(&myarray), | |
1142 | side_arg_vla(&myarray), | |
1143 | #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN | |
1144 | side_arg_u32(side_bswap_32(1U << 2)), | |
1145 | side_arg_u32(1U << 2), | |
8bdd5c12 | 1146 | #else |
67337c4a MD |
1147 | side_arg_u32(1U << 2), |
1148 | side_arg_u32(side_bswap_32(1U << 2)), | |
8bdd5c12 | 1149 | #endif |
af6aa6e1 MD |
1150 | ) |
1151 | ); | |
1152 | } | |
ea32e5fc MD |
1153 | } |
1154 | ||
67337c4a MD |
1155 | side_static_event_variadic(my_provider_event_blob, "myprovider", "myeventblob", SIDE_LOGLEVEL_DEBUG, |
1156 | side_field_list( | |
a82ffcff MD |
1157 | side_field_byte("blobfield"), |
1158 | side_field_array("arrayblob", side_elem(side_type_byte()), 3), | |
1159 | ) | |
7aec0d09 MD |
1160 | ); |
1161 | ||
1162 | static | |
1163 | void test_blob(void) | |
1164 | { | |
67337c4a MD |
1165 | side_event_cond(my_provider_event_blob) { |
1166 | side_arg_define_vec(myarray, side_arg_list(side_arg_byte(1), side_arg_byte(2), side_arg_byte(3))); | |
1167 | side_arg_dynamic_define_vec(myvla, | |
1168 | side_arg_list( | |
a82ffcff MD |
1169 | side_arg_dynamic_byte(0x22), |
1170 | side_arg_dynamic_byte(0x33), | |
1171 | ) | |
199e7aa9 | 1172 | ); |
67337c4a MD |
1173 | side_event_call_variadic(my_provider_event_blob, |
1174 | side_arg_list( | |
1175 | side_arg_byte(0x55), | |
1176 | side_arg_array(&myarray), | |
199e7aa9 | 1177 | ), |
67337c4a MD |
1178 | side_arg_list( |
1179 | side_arg_dynamic_field("varblobfield", | |
a82ffcff | 1180 | side_arg_dynamic_byte(0x55) |
199e7aa9 | 1181 | ), |
67337c4a | 1182 | side_arg_dynamic_field("varblobvla", side_arg_dynamic_vla(&myvla)), |
a82ffcff | 1183 | ) |
7aec0d09 MD |
1184 | ); |
1185 | } | |
1186 | } | |
ea32e5fc | 1187 | |
67337c4a MD |
1188 | side_static_event_variadic(my_provider_event_format_string, |
1189 | "myprovider", "myeventformatstring", SIDE_LOGLEVEL_DEBUG, | |
1190 | side_field_list( | |
a82ffcff | 1191 | side_field_string("fmt"), |
71aa8975 | 1192 | ), |
67337c4a MD |
1193 | side_attr_list( |
1194 | side_attr("lang.c.format_string", side_attr_bool(true)), | |
71aa8975 MD |
1195 | ) |
1196 | ); | |
1197 | ||
1198 | static | |
1199 | void test_fmt_string(void) | |
1200 | { | |
67337c4a MD |
1201 | side_event_cond(my_provider_event_format_string) { |
1202 | side_arg_dynamic_define_vec(args, | |
1203 | side_arg_list( | |
a82ffcff MD |
1204 | side_arg_dynamic_string("blah"), |
1205 | side_arg_dynamic_s32(123), | |
1206 | ) | |
71aa8975 | 1207 | ); |
67337c4a MD |
1208 | side_event_call_variadic(my_provider_event_format_string, |
1209 | side_arg_list( | |
1210 | side_arg_string("This is a formatted string with str: %s int: %d"), | |
71aa8975 | 1211 | ), |
67337c4a MD |
1212 | side_arg_list( |
1213 | side_arg_dynamic_field("arguments", side_arg_dynamic_vla(&args)), | |
a82ffcff | 1214 | ) |
71aa8975 MD |
1215 | ); |
1216 | } | |
1217 | } | |
1218 | ||
67337c4a MD |
1219 | side_static_event_variadic(my_provider_event_endian, "myprovider", "myevent_endian", SIDE_LOGLEVEL_DEBUG, |
1220 | side_field_list( | |
a82ffcff MD |
1221 | side_field_u16_le("u16_le"), |
1222 | side_field_u32_le("u32_le"), | |
1223 | side_field_u64_le("u64_le"), | |
1224 | side_field_s16_le("s16_le"), | |
1225 | side_field_s32_le("s32_le"), | |
1226 | side_field_s64_le("s64_le"), | |
1227 | side_field_u16_be("u16_be"), | |
1228 | side_field_u32_be("u32_be"), | |
1229 | side_field_u64_be("u64_be"), | |
1230 | side_field_s16_be("s16_be"), | |
1231 | side_field_s32_be("s32_be"), | |
1232 | side_field_s64_be("s64_be"), | |
1233 | ) | |
8bdd5c12 MD |
1234 | ); |
1235 | ||
1236 | static | |
1237 | void test_endian(void) | |
1238 | { | |
67337c4a MD |
1239 | side_event_variadic(my_provider_event_endian, |
1240 | side_arg_list( | |
1241 | #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN | |
1242 | side_arg_u16(1), | |
1243 | side_arg_u32(1), | |
1244 | side_arg_u64(1), | |
1245 | side_arg_s16(1), | |
1246 | side_arg_s32(1), | |
1247 | side_arg_s64(1), | |
1248 | side_arg_u16(side_bswap_16(1)), | |
1249 | side_arg_u32(side_bswap_32(1)), | |
1250 | side_arg_u64(side_bswap_64(1)), | |
1251 | side_arg_s16(side_bswap_16(1)), | |
1252 | side_arg_s32(side_bswap_32(1)), | |
1253 | side_arg_s64(side_bswap_64(1)), | |
8bdd5c12 | 1254 | #else |
67337c4a MD |
1255 | side_arg_u16(side_bswap_16(1)), |
1256 | side_arg_u32(side_bswap_32(1)), | |
1257 | side_arg_u64(side_bswap_64(1)), | |
1258 | side_arg_s16(side_bswap_16(1)), | |
1259 | side_arg_s32(side_bswap_32(1)), | |
1260 | side_arg_s64(side_bswap_64(1)), | |
1261 | side_arg_u16(1), | |
1262 | side_arg_u32(1), | |
1263 | side_arg_u64(1), | |
1264 | side_arg_s16(1), | |
1265 | side_arg_s32(1), | |
1266 | side_arg_s64(1), | |
8bdd5c12 MD |
1267 | #endif |
1268 | ), | |
67337c4a MD |
1269 | side_arg_list( |
1270 | #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN | |
a82ffcff MD |
1271 | side_arg_dynamic_field("u16_le", side_arg_dynamic_u16_le(1)), |
1272 | side_arg_dynamic_field("u32_le", side_arg_dynamic_u32_le(1)), | |
1273 | side_arg_dynamic_field("u64_le", side_arg_dynamic_u64_le(1)), | |
1274 | side_arg_dynamic_field("s16_le", side_arg_dynamic_s16_le(1)), | |
1275 | side_arg_dynamic_field("s32_le", side_arg_dynamic_s32_le(1)), | |
1276 | side_arg_dynamic_field("s64_le", side_arg_dynamic_s64_le(1)), | |
1277 | side_arg_dynamic_field("u16_be", side_arg_dynamic_u16_be(side_bswap_16(1))), | |
1278 | side_arg_dynamic_field("u32_be", side_arg_dynamic_u32_be(side_bswap_32(1))), | |
1279 | side_arg_dynamic_field("u64_be", side_arg_dynamic_u64_be(side_bswap_64(1))), | |
1280 | side_arg_dynamic_field("s16_be", side_arg_dynamic_s16_be(side_bswap_16(1))), | |
1281 | side_arg_dynamic_field("s32_be", side_arg_dynamic_s32_be(side_bswap_32(1))), | |
1282 | side_arg_dynamic_field("s64_be", side_arg_dynamic_s64_be(side_bswap_64(1))), | |
8bdd5c12 | 1283 | #else |
a82ffcff MD |
1284 | side_arg_dynamic_field("u16_le", side_arg_dynamic_u16_le(side_bswap_16(1))), |
1285 | side_arg_dynamic_field("u32_le", side_arg_dynamic_u32_le(side_bswap_32(1))), | |
1286 | side_arg_dynamic_field("u64_le", side_arg_dynamic_u64_le(side_bswap_64(1))), | |
1287 | side_arg_dynamic_field("s16_le", side_arg_dynamic_s16_le(side_bswap_16(1))), | |
1288 | side_arg_dynamic_field("s32_le", side_arg_dynamic_s32_le(side_bswap_32(1))), | |
1289 | side_arg_dynamic_field("s64_le", side_arg_dynamic_s64_le(side_bswap_64(1))), | |
1290 | side_arg_dynamic_field("u16_be", side_arg_dynamic_u16_be(1)), | |
1291 | side_arg_dynamic_field("u32_be", side_arg_dynamic_u32_be(1)), | |
1292 | side_arg_dynamic_field("u64_be", side_arg_dynamic_u64_be(1)), | |
1293 | side_arg_dynamic_field("s16_be", side_arg_dynamic_s16_be(1)), | |
1294 | side_arg_dynamic_field("s32_be", side_arg_dynamic_s32_be(1)), | |
1295 | side_arg_dynamic_field("s64_be", side_arg_dynamic_s64_be(1)), | |
8bdd5c12 | 1296 | #endif |
a82ffcff | 1297 | ) |
8bdd5c12 MD |
1298 | ); |
1299 | } | |
1300 | ||
67337c4a MD |
1301 | side_static_event(my_provider_event_base, "myprovider", "myevent_base", SIDE_LOGLEVEL_DEBUG, |
1302 | side_field_list( | |
1303 | side_field_u8("u8base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1304 | side_field_u8("u8base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1305 | side_field_u8("u8base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1306 | side_field_u8("u8base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1307 | side_field_u16("u16base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1308 | side_field_u16("u16base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1309 | side_field_u16("u16base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1310 | side_field_u16("u16base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1311 | side_field_u32("u32base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1312 | side_field_u32("u32base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1313 | side_field_u32("u32base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1314 | side_field_u32("u32base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1315 | side_field_u64("u64base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1316 | side_field_u64("u64base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1317 | side_field_u64("u64base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1318 | side_field_u64("u64base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1319 | side_field_s8("s8base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1320 | side_field_s8("s8base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1321 | side_field_s8("s8base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1322 | side_field_s8("s8base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1323 | side_field_s16("s16base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1324 | side_field_s16("s16base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1325 | side_field_s16("s16base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1326 | side_field_s16("s16base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1327 | side_field_s32("s32base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1328 | side_field_s32("s32base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1329 | side_field_s32("s32base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1330 | side_field_s32("s32base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1331 | side_field_s64("s64base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
1332 | side_field_s64("s64base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
1333 | side_field_s64("s64base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1334 | side_field_s64("s64base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
a82ffcff | 1335 | ) |
1d9c515c MD |
1336 | ); |
1337 | ||
1338 | static | |
1339 | void test_base(void) | |
1340 | { | |
67337c4a MD |
1341 | side_event(my_provider_event_base, |
1342 | side_arg_list( | |
1343 | side_arg_u8(55), | |
1344 | side_arg_u8(55), | |
1345 | side_arg_u8(55), | |
1346 | side_arg_u8(55), | |
1347 | side_arg_u16(55), | |
1348 | side_arg_u16(55), | |
1349 | side_arg_u16(55), | |
1350 | side_arg_u16(55), | |
1351 | side_arg_u32(55), | |
1352 | side_arg_u32(55), | |
1353 | side_arg_u32(55), | |
1354 | side_arg_u32(55), | |
1355 | side_arg_u64(55), | |
1356 | side_arg_u64(55), | |
1357 | side_arg_u64(55), | |
1358 | side_arg_u64(55), | |
1359 | side_arg_s8(-55), | |
1360 | side_arg_s8(-55), | |
1361 | side_arg_s8(-55), | |
1362 | side_arg_s8(-55), | |
1363 | side_arg_s16(-55), | |
1364 | side_arg_s16(-55), | |
1365 | side_arg_s16(-55), | |
1366 | side_arg_s16(-55), | |
1367 | side_arg_s32(-55), | |
1368 | side_arg_s32(-55), | |
1369 | side_arg_s32(-55), | |
1370 | side_arg_s32(-55), | |
1371 | side_arg_s64(-55), | |
1372 | side_arg_s64(-55), | |
1373 | side_arg_s64(-55), | |
1374 | side_arg_s64(-55), | |
1d9c515c MD |
1375 | ) |
1376 | ); | |
1377 | } | |
1378 | ||
7a1cb105 MD |
1379 | struct test { |
1380 | uint32_t a; | |
1381 | uint64_t b; | |
1382 | uint8_t c; | |
1383 | int32_t d; | |
1384 | uint16_t e; | |
bc0b21eb MD |
1385 | int8_t f; |
1386 | int16_t g; | |
1387 | int32_t h; | |
1388 | int64_t i; | |
1389 | int64_t j; | |
1390 | int64_t k; | |
c1723f3c | 1391 | uint64_t test; |
7a1cb105 MD |
1392 | }; |
1393 | ||
67337c4a MD |
1394 | static side_define_struct(mystructgatherdef, |
1395 | side_field_list( | |
1396 | side_field_gather_unsigned_integer("a", offsetof(struct test, a), | |
1397 | side_struct_field_sizeof(struct test, a), 0, 0, | |
a82ffcff | 1398 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
67337c4a MD |
1399 | side_field_gather_signed_integer("d", offsetof(struct test, d), |
1400 | side_struct_field_sizeof(struct test, d), 0, 0, | |
a82ffcff | 1401 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
67337c4a MD |
1402 | side_field_gather_unsigned_integer("e", offsetof(struct test, e), |
1403 | side_struct_field_sizeof(struct test, e), 8, 4, | |
1404 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1405 | side_field_gather_signed_integer("f", offsetof(struct test, f), | |
1406 | side_struct_field_sizeof(struct test, f), 1, 4, | |
1407 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1408 | side_field_gather_signed_integer("g", offsetof(struct test, g), | |
1409 | side_struct_field_sizeof(struct test, g), 11, 4, | |
1410 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1411 | side_field_gather_signed_integer("h", offsetof(struct test, h), | |
1412 | side_struct_field_sizeof(struct test, h), 1, 31, | |
1413 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1414 | side_field_gather_signed_integer("i", offsetof(struct test, i), | |
1415 | side_struct_field_sizeof(struct test, i), 33, 20, | |
1416 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1417 | side_field_gather_signed_integer("j", offsetof(struct test, j), | |
1418 | side_struct_field_sizeof(struct test, j), 63, 1, | |
1419 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1420 | side_field_gather_signed_integer("k", offsetof(struct test, k), | |
1421 | side_struct_field_sizeof(struct test, k), 1, 63, | |
1422 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
1423 | side_field_gather_unsigned_integer_le("test", offsetof(struct test, test), | |
1424 | side_struct_field_sizeof(struct test, test), 0, 64, | |
1425 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1426 | side_field_gather_unsigned_integer_le("test_le", offsetof(struct test, test), | |
1427 | side_struct_field_sizeof(struct test, test), 0, 64, | |
1428 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
1429 | side_field_gather_unsigned_integer_be("test_be", offsetof(struct test, test), | |
1430 | side_struct_field_sizeof(struct test, test), 0, 64, | |
1431 | SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
a82ffcff | 1432 | ) |
7a1cb105 MD |
1433 | ); |
1434 | ||
67337c4a MD |
1435 | side_static_event(my_provider_event_structgather, "myprovider", "myeventstructgather", SIDE_LOGLEVEL_DEBUG, |
1436 | side_field_list( | |
1437 | side_field_gather_struct("structgather", &mystructgatherdef, 0, sizeof(struct test), | |
1438 | SIDE_TYPE_GATHER_ACCESS_DIRECT), | |
1439 | side_field_gather_signed_integer("intgather", 0, sizeof(int32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, | |
1440 | side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
13d97eca | 1441 | #if __HAVE_FLOAT32 |
a82ffcff | 1442 | side_field_gather_float("f32", 0, sizeof(_Float32), SIDE_TYPE_GATHER_ACCESS_DIRECT), |
13d97eca | 1443 | #endif |
a82ffcff | 1444 | ) |
7a1cb105 MD |
1445 | ); |
1446 | ||
1447 | static | |
d41cb7ee | 1448 | void test_struct_gather(void) |
7a1cb105 | 1449 | { |
67337c4a | 1450 | side_event_cond(my_provider_event_structgather) { |
7a1cb105 MD |
1451 | struct test mystruct = { |
1452 | .a = 55, | |
1453 | .b = 123, | |
1454 | .c = 2, | |
1455 | .d = -55, | |
1456 | .e = 0xABCD, | |
bc0b21eb MD |
1457 | .f = -1, |
1458 | .g = -1, | |
1459 | .h = -1, | |
1460 | .i = -1, | |
1461 | .j = -1, | |
1462 | .k = -1, | |
c1723f3c | 1463 | .test = 0xFF, |
7a1cb105 | 1464 | }; |
33956c71 | 1465 | int32_t val = -66; |
13d97eca MD |
1466 | #if __HAVE_FLOAT32 |
1467 | _Float32 f32 = 1.1; | |
1468 | #endif | |
67337c4a MD |
1469 | side_event_call(my_provider_event_structgather, |
1470 | side_arg_list( | |
1471 | side_arg_gather_struct(&mystruct), | |
1472 | side_arg_gather_integer(&val), | |
13d97eca | 1473 | #if __HAVE_FLOAT32 |
67337c4a | 1474 | side_arg_gather_float(&f32), |
13d97eca | 1475 | #endif |
33956c71 MD |
1476 | ) |
1477 | ); | |
7a1cb105 MD |
1478 | } |
1479 | } | |
1480 | ||
7394a8b8 MD |
1481 | struct testnest2 { |
1482 | uint8_t c; | |
1483 | }; | |
1484 | ||
1485 | struct testnest1 { | |
1486 | uint64_t b; | |
1487 | struct testnest2 *nest; | |
1488 | }; | |
1489 | ||
1490 | struct testnest0 { | |
1491 | uint32_t a; | |
1492 | struct testnest1 *nest; | |
1493 | }; | |
1494 | ||
67337c4a MD |
1495 | static side_define_struct(mystructgathernest2, |
1496 | side_field_list( | |
1497 | side_field_gather_unsigned_integer("c", offsetof(struct testnest2, c), | |
1498 | side_struct_field_sizeof(struct testnest2, c), 0, 0, | |
a82ffcff MD |
1499 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
1500 | ) | |
7394a8b8 MD |
1501 | ); |
1502 | ||
67337c4a MD |
1503 | static side_define_struct(mystructgathernest1, |
1504 | side_field_list( | |
1505 | side_field_gather_unsigned_integer("b", offsetof(struct testnest1, b), | |
1506 | side_struct_field_sizeof(struct testnest1, b), 0, 0, | |
a82ffcff | 1507 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
67337c4a | 1508 | side_field_gather_struct("nest2", &mystructgathernest2, |
dd7947bf | 1509 | offsetof(struct testnest1, nest), sizeof(struct testnest2), |
67337c4a | 1510 | SIDE_TYPE_GATHER_ACCESS_POINTER), |
a82ffcff | 1511 | ) |
7394a8b8 MD |
1512 | ); |
1513 | ||
67337c4a MD |
1514 | static side_define_struct(mystructgathernest0, |
1515 | side_field_list( | |
1516 | side_field_gather_unsigned_integer("a", offsetof(struct testnest0, a), | |
1517 | side_struct_field_sizeof(struct testnest0, a), 0, 0, | |
a82ffcff | 1518 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
67337c4a | 1519 | side_field_gather_struct("nest1", &mystructgathernest1, |
dd7947bf | 1520 | offsetof(struct testnest0, nest), sizeof(struct testnest1), |
67337c4a | 1521 | SIDE_TYPE_GATHER_ACCESS_POINTER), |
a82ffcff | 1522 | ) |
7394a8b8 MD |
1523 | ); |
1524 | ||
67337c4a MD |
1525 | side_static_event(my_provider_event_structgather_nest, |
1526 | "myprovider", "myeventstructgathernest", SIDE_LOGLEVEL_DEBUG, | |
1527 | side_field_list( | |
1528 | side_field_gather_struct("nest0", &mystructgathernest0, 0, | |
1529 | sizeof(struct testnest0), SIDE_TYPE_GATHER_ACCESS_DIRECT), | |
a82ffcff | 1530 | ) |
7394a8b8 MD |
1531 | ); |
1532 | ||
1533 | static | |
d41cb7ee | 1534 | void test_struct_gather_nest_ptr(void) |
7394a8b8 | 1535 | { |
67337c4a | 1536 | side_event_cond(my_provider_event_structgather_nest) { |
7394a8b8 MD |
1537 | struct testnest2 mystruct2 = { |
1538 | .c = 77, | |
1539 | }; | |
1540 | struct testnest1 mystruct1 = { | |
1541 | .b = 66, | |
1542 | .nest = &mystruct2, | |
1543 | }; | |
1544 | struct testnest0 mystruct = { | |
1545 | .a = 55, | |
1546 | .nest = &mystruct1, | |
1547 | }; | |
67337c4a MD |
1548 | side_event_call(my_provider_event_structgather_nest, |
1549 | side_arg_list( | |
1550 | side_arg_gather_struct(&mystruct), | |
7394a8b8 MD |
1551 | ) |
1552 | ); | |
1553 | } | |
1554 | } | |
1555 | ||
905f68e3 MD |
1556 | struct testfloat { |
1557 | #if __HAVE_FLOAT16 | |
1558 | _Float16 f16; | |
1559 | #endif | |
1560 | #if __HAVE_FLOAT32 | |
1561 | _Float32 f32; | |
1562 | #endif | |
1563 | #if __HAVE_FLOAT64 | |
1564 | _Float64 f64; | |
1565 | #endif | |
1566 | #if __HAVE_FLOAT128 | |
1567 | _Float128 f128; | |
1568 | #endif | |
1569 | }; | |
1570 | ||
67337c4a MD |
1571 | static side_define_struct(mystructgatherfloat, |
1572 | side_field_list( | |
905f68e3 | 1573 | #if __HAVE_FLOAT16 |
67337c4a | 1574 | side_field_gather_float("f16", offsetof(struct testfloat, f16), side_struct_field_sizeof(struct testfloat, f16), |
a82ffcff | 1575 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
905f68e3 MD |
1576 | #endif |
1577 | #if __HAVE_FLOAT32 | |
67337c4a | 1578 | side_field_gather_float("f32", offsetof(struct testfloat, f32), side_struct_field_sizeof(struct testfloat, f32), |
a82ffcff | 1579 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
905f68e3 MD |
1580 | #endif |
1581 | #if __HAVE_FLOAT64 | |
67337c4a | 1582 | side_field_gather_float("f64", offsetof(struct testfloat, f64), side_struct_field_sizeof(struct testfloat, f64), |
a82ffcff | 1583 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
905f68e3 MD |
1584 | #endif |
1585 | #if __HAVE_FLOAT128 | |
67337c4a | 1586 | side_field_gather_float("f128", offsetof(struct testfloat, f128), side_struct_field_sizeof(struct testfloat, f128), |
a82ffcff | 1587 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
905f68e3 | 1588 | #endif |
a82ffcff | 1589 | ) |
905f68e3 MD |
1590 | ); |
1591 | ||
67337c4a MD |
1592 | side_static_event(my_provider_event_structgatherfloat, |
1593 | "myprovider", "myeventstructgatherfloat", SIDE_LOGLEVEL_DEBUG, | |
1594 | side_field_list( | |
1595 | side_field_gather_struct("structgatherfloat", &mystructgatherfloat, 0, | |
1596 | sizeof(struct testfloat), SIDE_TYPE_GATHER_ACCESS_DIRECT), | |
a82ffcff | 1597 | ) |
905f68e3 MD |
1598 | ); |
1599 | ||
1600 | static | |
d41cb7ee | 1601 | void test_struct_gather_float(void) |
905f68e3 | 1602 | { |
67337c4a | 1603 | side_event_cond(my_provider_event_structgatherfloat) { |
905f68e3 MD |
1604 | struct testfloat mystruct = { |
1605 | #if __HAVE_FLOAT16 | |
1606 | .f16 = 1.1, | |
1607 | #endif | |
1608 | #if __HAVE_FLOAT32 | |
1609 | .f32 = 2.2, | |
1610 | #endif | |
1611 | #if __HAVE_FLOAT64 | |
1612 | .f64 = 3.3, | |
1613 | #endif | |
1614 | #if __HAVE_FLOAT128 | |
1615 | .f128 = 4.4, | |
1616 | #endif | |
1617 | }; | |
67337c4a MD |
1618 | side_event_call(my_provider_event_structgatherfloat, |
1619 | side_arg_list( | |
1620 | side_arg_gather_struct(&mystruct), | |
905f68e3 MD |
1621 | ) |
1622 | ); | |
1623 | } | |
1624 | } | |
1625 | ||
d41cb7ee | 1626 | uint32_t mygatherarray[] = { 1, 2, 3, 4, 5 }; |
d9359cfa | 1627 | |
d41cb7ee | 1628 | uint16_t mygatherarray2[] = { 6, 7, 8, 9 }; |
d9359cfa MD |
1629 | |
1630 | struct testarray { | |
1631 | int a; | |
1632 | uint32_t *ptr; | |
1633 | }; | |
1634 | ||
67337c4a MD |
1635 | static side_define_struct(mystructgatherarray, |
1636 | side_field_list( | |
1637 | side_field_gather_array("array", | |
a82ffcff | 1638 | side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT)), |
67337c4a | 1639 | SIDE_ARRAY_SIZE(mygatherarray), |
d9359cfa | 1640 | offsetof(struct testarray, ptr), |
a82ffcff MD |
1641 | SIDE_TYPE_GATHER_ACCESS_POINTER |
1642 | ), | |
1643 | ) | |
d9359cfa MD |
1644 | ); |
1645 | ||
67337c4a MD |
1646 | side_static_event(my_provider_event_structgatherarray, |
1647 | "myprovider", "myeventstructgatherarray", SIDE_LOGLEVEL_DEBUG, | |
1648 | side_field_list( | |
1649 | side_field_gather_struct("structgatherarray", &mystructgatherarray, 0, | |
1650 | sizeof(struct testarray), SIDE_TYPE_GATHER_ACCESS_DIRECT), | |
1651 | side_field_gather_array("array2", | |
a82ffcff | 1652 | side_elem(side_type_gather_unsigned_integer(0, sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT)), |
67337c4a | 1653 | SIDE_ARRAY_SIZE(mygatherarray2), 0, |
a82ffcff | 1654 | SIDE_TYPE_GATHER_ACCESS_DIRECT |
d9359cfa | 1655 | ), |
a82ffcff | 1656 | ) |
d9359cfa MD |
1657 | ); |
1658 | ||
1659 | static | |
d41cb7ee | 1660 | void test_array_gather(void) |
d9359cfa | 1661 | { |
67337c4a | 1662 | side_event_cond(my_provider_event_structgatherarray) { |
d9359cfa MD |
1663 | struct testarray mystruct = { |
1664 | .a = 55, | |
d41cb7ee | 1665 | .ptr = mygatherarray, |
d9359cfa | 1666 | }; |
67337c4a MD |
1667 | side_event_call(my_provider_event_structgatherarray, |
1668 | side_arg_list( | |
1669 | side_arg_gather_struct(&mystruct), | |
1670 | side_arg_gather_array(&mygatherarray2), | |
d9359cfa MD |
1671 | ) |
1672 | ); | |
1673 | } | |
1674 | } | |
1675 | ||
dd7947bf | 1676 | #define TESTSGNESTARRAY_LEN 4 |
d41cb7ee | 1677 | struct testgatherstructnest1 { |
dd7947bf MD |
1678 | int b; |
1679 | int c[TESTSGNESTARRAY_LEN]; | |
1680 | }; | |
1681 | ||
d41cb7ee MD |
1682 | struct testgatherstructnest0 { |
1683 | struct testgatherstructnest1 nest; | |
1684 | struct testgatherstructnest1 nestarray[2]; | |
dd7947bf MD |
1685 | int a; |
1686 | }; | |
1687 | ||
67337c4a MD |
1688 | static side_define_struct(mystructgatherstructnest1, |
1689 | side_field_list( | |
1690 | side_field_gather_signed_integer("b", offsetof(struct testgatherstructnest1, b), | |
1691 | side_struct_field_sizeof(struct testgatherstructnest1, b), 0, 0, | |
a82ffcff | 1692 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
67337c4a MD |
1693 | side_field_gather_array("c", |
1694 | side_elem( | |
1695 | side_type_gather_signed_integer(0, sizeof(uint32_t), 0, 0, | |
a82ffcff | 1696 | SIDE_TYPE_GATHER_ACCESS_DIRECT) |
dd7947bf MD |
1697 | ), |
1698 | TESTSGNESTARRAY_LEN, | |
d41cb7ee | 1699 | offsetof(struct testgatherstructnest1, c), |
a82ffcff MD |
1700 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
1701 | ) | |
dd7947bf MD |
1702 | ); |
1703 | ||
67337c4a MD |
1704 | static side_define_struct(mystructgatherstructnest0, |
1705 | side_field_list( | |
1706 | side_field_gather_signed_integer("a", offsetof(struct testgatherstructnest0, a), | |
1707 | side_struct_field_sizeof(struct testgatherstructnest0, a), 0, 0, | |
a82ffcff | 1708 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
67337c4a | 1709 | side_field_gather_struct("structnest0", &mystructgatherstructnest1, |
d41cb7ee MD |
1710 | offsetof(struct testgatherstructnest0, nest), |
1711 | sizeof(struct testgatherstructnest1), | |
67337c4a MD |
1712 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
1713 | side_field_gather_array("nestarray", | |
1714 | side_elem( | |
1715 | side_type_gather_struct(&mystructgatherstructnest1, | |
dd7947bf | 1716 | 0, |
d41cb7ee | 1717 | sizeof(struct testgatherstructnest1), |
a82ffcff | 1718 | SIDE_TYPE_GATHER_ACCESS_DIRECT) |
dd7947bf MD |
1719 | ), |
1720 | 2, | |
d41cb7ee | 1721 | offsetof(struct testgatherstructnest0, nestarray), |
a82ffcff MD |
1722 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
1723 | ) | |
dd7947bf MD |
1724 | ); |
1725 | ||
67337c4a MD |
1726 | side_static_event(my_provider_event_gatherstructnest, |
1727 | "myprovider", "myeventgatherstructnest", SIDE_LOGLEVEL_DEBUG, | |
1728 | side_field_list( | |
1729 | side_field_gather_struct("structgather", &mystructgatherstructnest0, 0, | |
1730 | sizeof(struct testgatherstructnest0), SIDE_TYPE_GATHER_ACCESS_DIRECT), | |
a82ffcff | 1731 | ) |
dd7947bf MD |
1732 | ); |
1733 | ||
1734 | static | |
d41cb7ee | 1735 | void test_gather_structnest(void) |
dd7947bf | 1736 | { |
67337c4a | 1737 | side_event_cond(my_provider_event_gatherstructnest) { |
d41cb7ee | 1738 | struct testgatherstructnest0 mystruct = { |
dd7947bf MD |
1739 | .nest = { |
1740 | .b = 66, | |
1741 | .c = { 0, 1, 2, 3 }, | |
1742 | }, | |
1743 | .nestarray = { | |
1744 | [0] = { | |
1745 | .b = 77, | |
1746 | .c = { 11, 12, 13, 14 }, | |
1747 | }, | |
1748 | [1] = { | |
1749 | .b = 88, | |
1750 | .c = { 15, 16, 17, 18 }, | |
1751 | }, | |
1752 | }, | |
1753 | .a = 55, | |
1754 | }; | |
67337c4a MD |
1755 | side_event_call(my_provider_event_gatherstructnest, |
1756 | side_arg_list( | |
1757 | side_arg_gather_struct(&mystruct), | |
dd7947bf MD |
1758 | ) |
1759 | ); | |
1760 | } | |
1761 | } | |
1762 | ||
d41cb7ee | 1763 | uint32_t gathervla[] = { 1, 2, 3, 4 }; |
80429681 | 1764 | uint32_t gathervla2[] = { 5, 6, 7, 8, 9 }; |
65b8734a | 1765 | |
d41cb7ee | 1766 | struct testgathervla { |
65b8734a MD |
1767 | int a; |
1768 | uint16_t len; | |
1769 | uint32_t *p; | |
1770 | }; | |
1771 | ||
67337c4a MD |
1772 | static side_define_struct(mystructgathervla, |
1773 | side_field_list( | |
1774 | side_field_gather_signed_integer("a", offsetof(struct testgathervla, a), | |
1775 | side_struct_field_sizeof(struct testgathervla, a), 0, 0, | |
a82ffcff | 1776 | SIDE_TYPE_GATHER_ACCESS_DIRECT |
65b8734a | 1777 | ), |
67337c4a | 1778 | side_field_gather_vla("nestvla", |
a82ffcff | 1779 | side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT)), |
d41cb7ee | 1780 | offsetof(struct testgathervla, p), |
67337c4a MD |
1781 | SIDE_TYPE_GATHER_ACCESS_POINTER, |
1782 | side_length(side_type_gather_unsigned_integer(offsetof(struct testgathervla, len), | |
a82ffcff | 1783 | sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT)) |
65b8734a | 1784 | ), |
a82ffcff | 1785 | ) |
65b8734a MD |
1786 | ); |
1787 | ||
67337c4a MD |
1788 | side_static_event(my_provider_event_gathervla, |
1789 | "myprovider", "myeventgathervla", SIDE_LOGLEVEL_DEBUG, | |
1790 | side_field_list( | |
1791 | side_field_gather_struct("structgathervla", &mystructgathervla, 0, | |
1792 | sizeof(struct testgathervla), SIDE_TYPE_GATHER_ACCESS_DIRECT), | |
1793 | side_field_gather_vla("vla", | |
a82ffcff | 1794 | side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT)), |
67337c4a | 1795 | 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, |
a82ffcff | 1796 | side_length(side_type_gather_unsigned_integer(0, sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT)) |
80429681 | 1797 | ), |
a82ffcff | 1798 | ) |
65b8734a MD |
1799 | ); |
1800 | ||
1801 | static | |
d41cb7ee | 1802 | void test_gather_vla(void) |
65b8734a | 1803 | { |
67337c4a | 1804 | side_event_cond(my_provider_event_gathervla) { |
d41cb7ee | 1805 | struct testgathervla mystruct = { |
65b8734a | 1806 | .a = 55, |
67337c4a | 1807 | .len = SIDE_ARRAY_SIZE(gathervla), |
d41cb7ee | 1808 | .p = gathervla, |
65b8734a | 1809 | }; |
80429681 | 1810 | uint16_t vla2_len = 5; |
67337c4a MD |
1811 | side_event_call(my_provider_event_gathervla, |
1812 | side_arg_list( | |
1813 | side_arg_gather_struct(&mystruct), | |
1814 | side_arg_gather_vla(gathervla2, &vla2_len), | |
65b8734a MD |
1815 | ) |
1816 | ); | |
1817 | } | |
1818 | } | |
1819 | ||
d41cb7ee | 1820 | struct testgathervlaflex { |
65b8734a MD |
1821 | uint8_t len; |
1822 | uint32_t otherfield; | |
1823 | uint64_t array[]; | |
1824 | }; | |
1825 | ||
67337c4a MD |
1826 | static side_define_struct(mystructgathervlaflex, |
1827 | side_field_list( | |
1828 | side_field_gather_vla("vlaflex", | |
a82ffcff | 1829 | side_elem(side_type_gather_unsigned_integer(0, sizeof(uint64_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT)), |
d41cb7ee | 1830 | offsetof(struct testgathervlaflex, array), |
67337c4a MD |
1831 | SIDE_TYPE_GATHER_ACCESS_DIRECT, |
1832 | side_length(side_type_gather_unsigned_integer(offsetof(struct testgathervlaflex, len), | |
a82ffcff | 1833 | side_struct_field_sizeof(struct testgathervlaflex, len), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT)) |
65b8734a | 1834 | ), |
a82ffcff | 1835 | ) |
65b8734a MD |
1836 | ); |
1837 | ||
67337c4a MD |
1838 | side_static_event(my_provider_event_gathervlaflex, |
1839 | "myprovider", "myeventgathervlaflex", SIDE_LOGLEVEL_DEBUG, | |
1840 | side_field_list( | |
1841 | side_field_gather_struct("structgathervlaflex", &mystructgathervlaflex, 0, | |
a82ffcff MD |
1842 | sizeof(struct testgathervlaflex), SIDE_TYPE_GATHER_ACCESS_DIRECT) |
1843 | ) | |
65b8734a MD |
1844 | ); |
1845 | ||
1846 | #define VLAFLEXLEN 6 | |
1847 | static | |
d41cb7ee | 1848 | void test_gather_vla_flex(void) |
65b8734a | 1849 | { |
67337c4a | 1850 | side_event_cond(my_provider_event_gathervlaflex) { |
358281a1 | 1851 | struct testgathervlaflex *mystruct = |
150b5c1d | 1852 | (struct testgathervlaflex *) malloc(sizeof(*mystruct) + VLAFLEXLEN * sizeof(uint64_t)); |
65b8734a MD |
1853 | |
1854 | mystruct->len = VLAFLEXLEN; | |
1855 | mystruct->otherfield = 0; | |
1856 | mystruct->array[0] = 1; | |
1857 | mystruct->array[1] = 2; | |
1858 | mystruct->array[2] = 3; | |
1859 | mystruct->array[3] = 4; | |
1860 | mystruct->array[4] = 5; | |
1861 | mystruct->array[5] = 6; | |
67337c4a MD |
1862 | side_event_call(my_provider_event_gathervlaflex, |
1863 | side_arg_list( | |
1864 | side_arg_gather_struct(mystruct), | |
65b8734a MD |
1865 | ) |
1866 | ); | |
1867 | free(mystruct); | |
1868 | } | |
1869 | } | |
1870 | ||
67337c4a MD |
1871 | side_static_event(my_provider_event_gatherbyte, |
1872 | "myprovider", "myeventgatherbyte", SIDE_LOGLEVEL_DEBUG, | |
1873 | side_field_list( | |
a82ffcff | 1874 | side_field_gather_byte("byte", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT), |
67337c4a | 1875 | side_field_gather_array("array", |
a82ffcff MD |
1876 | side_elem(side_type_gather_byte(0, SIDE_TYPE_GATHER_ACCESS_DIRECT)), |
1877 | 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT | |
d69918cc | 1878 | ), |
a82ffcff | 1879 | ) |
d69918cc MD |
1880 | ); |
1881 | ||
1882 | static | |
1883 | void test_gather_byte(void) | |
1884 | { | |
67337c4a | 1885 | side_event_cond(my_provider_event_gatherbyte) { |
d69918cc MD |
1886 | uint8_t v = 0x44; |
1887 | uint8_t array[3] = { 0x1, 0x2, 0x3 }; | |
1888 | ||
67337c4a MD |
1889 | side_event_call(my_provider_event_gatherbyte, |
1890 | side_arg_list( | |
1891 | side_arg_gather_byte(&v), | |
1892 | side_arg_gather_array(array), | |
d69918cc MD |
1893 | ) |
1894 | ); | |
1895 | } | |
1896 | } | |
1897 | ||
8ad2f385 MD |
1898 | #define ARRAYBOOLLEN 4 |
1899 | static bool arraybool[ARRAYBOOLLEN] = { false, true, false, true }; | |
1900 | ||
67337c4a MD |
1901 | side_static_event(my_provider_event_gatherbool, |
1902 | "myprovider", "myeventgatherbool", SIDE_LOGLEVEL_DEBUG, | |
1903 | side_field_list( | |
1904 | side_field_gather_bool("v1_true", 0, sizeof(bool), 0, 0, | |
a82ffcff | 1905 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
67337c4a | 1906 | side_field_gather_bool("v2_false", 0, sizeof(bool), 0, 0, |
a82ffcff | 1907 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
67337c4a | 1908 | side_field_gather_bool("v3_true", 0, sizeof(uint16_t), 1, 1, |
a82ffcff | 1909 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
67337c4a | 1910 | side_field_gather_bool("v4_false", 0, sizeof(uint16_t), 1, 1, |
a82ffcff | 1911 | SIDE_TYPE_GATHER_ACCESS_DIRECT), |
67337c4a MD |
1912 | side_field_gather_array("arraybool", |
1913 | side_elem(side_type_gather_bool(0, sizeof(bool), 0, 0, | |
a82ffcff MD |
1914 | SIDE_TYPE_GATHER_ACCESS_DIRECT)), |
1915 | ARRAYBOOLLEN, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT | |
8ad2f385 | 1916 | ), |
a82ffcff | 1917 | ) |
8ad2f385 MD |
1918 | ); |
1919 | ||
1920 | static | |
1921 | void test_gather_bool(void) | |
1922 | { | |
67337c4a | 1923 | side_event_cond(my_provider_event_structgatherarray) { |
8ad2f385 MD |
1924 | bool v1 = true; |
1925 | bool v2 = false; | |
1926 | uint16_t v3 = 1U << 1; | |
1927 | uint16_t v4 = 1U << 2; | |
1928 | ||
67337c4a MD |
1929 | side_event_call(my_provider_event_gatherbool, |
1930 | side_arg_list( | |
1931 | side_arg_gather_bool(&v1), | |
1932 | side_arg_gather_bool(&v2), | |
1933 | side_arg_gather_bool(&v3), | |
1934 | side_arg_gather_bool(&v4), | |
1935 | side_arg_gather_array(arraybool), | |
8ad2f385 MD |
1936 | ) |
1937 | ); | |
1938 | } | |
1939 | } | |
1940 | ||
67337c4a MD |
1941 | side_static_event(my_provider_event_gatherpointer, |
1942 | "myprovider", "myeventgatherpointer", SIDE_LOGLEVEL_DEBUG, | |
1943 | side_field_list( | |
a82ffcff | 1944 | side_field_gather_pointer("ptr", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT), |
67337c4a | 1945 | side_field_gather_array("array", |
a82ffcff MD |
1946 | side_elem(side_type_gather_pointer(0, SIDE_TYPE_GATHER_ACCESS_DIRECT)), |
1947 | 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT | |
4e1b0e0e | 1948 | ), |
a82ffcff | 1949 | ) |
4e1b0e0e MD |
1950 | ); |
1951 | ||
1952 | static | |
1953 | void test_gather_pointer(void) | |
1954 | { | |
67337c4a | 1955 | side_event_cond(my_provider_event_structgatherarray) { |
4e1b0e0e MD |
1956 | void *v = (void *)0x44; |
1957 | void *array[3] = { (void *)0x1, (void *)0x2, (void *)0x3 }; | |
1958 | ||
67337c4a MD |
1959 | side_event_call(my_provider_event_gatherpointer, |
1960 | side_arg_list( | |
1961 | side_arg_gather_pointer(&v), | |
1962 | side_arg_gather_array(array), | |
4e1b0e0e MD |
1963 | ) |
1964 | ); | |
1965 | } | |
1966 | } | |
0519cb86 | 1967 | |
67337c4a MD |
1968 | static side_define_enum(myenumgather, |
1969 | side_enum_mapping_list( | |
1970 | side_enum_mapping_range("one-ten", 1, 10), | |
1971 | side_enum_mapping_range("100-200", 100, 200), | |
1972 | side_enum_mapping_value("200", 200), | |
1973 | side_enum_mapping_value("300", 300), | |
a82ffcff | 1974 | ) |
0519cb86 MD |
1975 | ); |
1976 | ||
67337c4a MD |
1977 | side_static_event(my_provider_event_enum_gather, "myprovider", "myeventenumgather", SIDE_LOGLEVEL_DEBUG, |
1978 | side_field_list( | |
1979 | side_field_gather_enum("5", &myenumgather, | |
1980 | side_elem( | |
1981 | side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, | |
a82ffcff | 1982 | SIDE_TYPE_GATHER_ACCESS_DIRECT) |
0519cb86 MD |
1983 | ) |
1984 | ), | |
67337c4a MD |
1985 | side_field_gather_enum("400", &myenumgather, |
1986 | side_elem( | |
1987 | side_type_gather_unsigned_integer(0, sizeof(uint64_t), 0, 0, | |
a82ffcff | 1988 | SIDE_TYPE_GATHER_ACCESS_DIRECT) |
0519cb86 MD |
1989 | ) |
1990 | ), | |
67337c4a MD |
1991 | side_field_gather_enum("200", &myenumgather, |
1992 | side_elem( | |
1993 | side_type_gather_unsigned_integer(0, sizeof(uint8_t), 0, 0, | |
a82ffcff | 1994 | SIDE_TYPE_GATHER_ACCESS_DIRECT) |
0519cb86 MD |
1995 | ) |
1996 | ), | |
67337c4a MD |
1997 | side_field_gather_enum("-100", &myenumgather, |
1998 | side_elem( | |
1999 | side_type_gather_signed_integer(0, sizeof(int8_t), 0, 0, | |
a82ffcff | 2000 | SIDE_TYPE_GATHER_ACCESS_DIRECT) |
0519cb86 MD |
2001 | ) |
2002 | ), | |
67337c4a MD |
2003 | side_field_gather_enum("6_be", &myenumgather, |
2004 | side_elem( | |
2005 | side_type_gather_unsigned_integer_be(0, sizeof(uint32_t), 0, 0, | |
a82ffcff | 2006 | SIDE_TYPE_GATHER_ACCESS_DIRECT) |
0519cb86 MD |
2007 | ) |
2008 | ), | |
67337c4a MD |
2009 | side_field_gather_enum("6_le", &myenumgather, |
2010 | side_elem( | |
2011 | side_type_gather_unsigned_integer_le(0, sizeof(uint32_t), 0, 0, | |
a82ffcff | 2012 | SIDE_TYPE_GATHER_ACCESS_DIRECT) |
0519cb86 MD |
2013 | ) |
2014 | ), | |
a82ffcff | 2015 | ) |
0519cb86 MD |
2016 | ); |
2017 | ||
2018 | static | |
2019 | void test_gather_enum(void) | |
2020 | { | |
2021 | uint32_t v1 = 5; | |
2022 | uint64_t v2 = 400; | |
2023 | uint8_t v3 = 200; | |
2024 | int8_t v4 = -100; | |
67337c4a MD |
2025 | #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN |
2026 | uint32_t v5 = side_bswap_32(6); | |
0519cb86 MD |
2027 | uint32_t v6 = 6; |
2028 | #else | |
2029 | uint32_t v5 = 6; | |
67337c4a | 2030 | uint32_t v6 = side_bswap_32(6); |
0519cb86 MD |
2031 | #endif |
2032 | ||
67337c4a MD |
2033 | side_event(my_provider_event_enum_gather, |
2034 | side_arg_list( | |
2035 | side_arg_gather_integer(&v1), | |
2036 | side_arg_gather_integer(&v2), | |
2037 | side_arg_gather_integer(&v3), | |
2038 | side_arg_gather_integer(&v4), | |
2039 | side_arg_gather_integer(&v5), | |
2040 | side_arg_gather_integer(&v6), | |
0519cb86 MD |
2041 | ) |
2042 | ); | |
2043 | } | |
2044 | ||
67337c4a MD |
2045 | side_static_event(my_provider_event_gatherstring, |
2046 | "myprovider", "myeventgatherstring", SIDE_LOGLEVEL_DEBUG, | |
2047 | side_field_list( | |
a82ffcff | 2048 | side_field_gather_string("string", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT), |
67337c4a | 2049 | side_field_gather_array("arrayptr", |
a82ffcff MD |
2050 | side_elem(side_type_gather_string(0, SIDE_TYPE_GATHER_ACCESS_POINTER)), |
2051 | 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT | |
7d34edfc | 2052 | ), |
67337c4a | 2053 | side_field_gather_array("array", |
a82ffcff MD |
2054 | side_elem(side_type_gather_string(0, SIDE_TYPE_GATHER_ACCESS_DIRECT)), |
2055 | 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT | |
7d34edfc | 2056 | ), |
a82ffcff | 2057 | ) |
7d34edfc MD |
2058 | ); |
2059 | ||
2060 | static | |
2061 | void test_gather_string(void) | |
2062 | { | |
67337c4a | 2063 | side_event_cond(my_provider_event_gatherstring) { |
9365e936 MJ |
2064 | const char *str1 = "abcdef"; |
2065 | const char *ptrarray[3] = { | |
7d34edfc MD |
2066 | "abc", |
2067 | "def", | |
2068 | "ghi", | |
2069 | }; | |
2070 | char flatarray[] = { 'a', 'b', '\0', 'c', 'd', '\0', 'e', 'f', '\0' }; | |
2071 | ||
67337c4a MD |
2072 | side_event_call(my_provider_event_gatherstring, |
2073 | side_arg_list( | |
2074 | side_arg_gather_string(str1), | |
2075 | side_arg_gather_array(ptrarray), | |
2076 | side_arg_gather_array(flatarray), | |
7d34edfc MD |
2077 | ) |
2078 | ); | |
2079 | } | |
2080 | } | |
2081 | ||
67337c4a MD |
2082 | side_static_event(my_provider_event_str_utf, "myprovider", "myevent_str_utf", SIDE_LOGLEVEL_DEBUG, |
2083 | side_field_list( | |
a82ffcff MD |
2084 | side_field_string("utf8"), |
2085 | side_field_string32("utf32"), | |
2086 | side_field_string16("utf16"), | |
2087 | side_field_string32_le("utf32_le"), | |
2088 | side_field_string16_le("utf16_le"), | |
2089 | side_field_string32_be("utf32_be"), | |
2090 | side_field_string16_be("utf16_be"), | |
67337c4a | 2091 | side_field_dynamic("dynamic_utf32"), |
a82ffcff MD |
2092 | side_field_gather_string32("gather_utf32", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT), |
2093 | ) | |
52990f65 MD |
2094 | ); |
2095 | ||
2096 | static | |
2097 | void test_string_utf(void) | |
2098 | { | |
2099 | /* | |
2100 | * Character '®' is: | |
2101 | * UTF-8: \c2 \ae | |
2102 | * UTF-16: U+00ae | |
2103 | * UTF-32: U+000000ae | |
2104 | */ | |
2105 | uint8_t str8[] = { 0xc2, 0xae, 'a', 'b', 'c', 0 }; | |
2106 | uint32_t str32[] = { 0x000000ae, 'a', 'b', 'c', 0 }; | |
2107 | uint16_t str16[] = { 0x00ae, 'a', 'b', 'c', 0 }; | |
67337c4a | 2108 | #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN |
52990f65 MD |
2109 | uint32_t str32_le[] = { 0x000000ae, 'a', 'b', 'c', 0 }; |
2110 | uint16_t str16_le[] = { 0x00ae, 'a', 'b', 'c', 0 }; | |
67337c4a MD |
2111 | uint32_t str32_be[] = { side_bswap_32(0x000000ae), side_bswap_32('a'), side_bswap_32('b'), side_bswap_32('c'), 0 }; |
2112 | uint16_t str16_be[] = { side_bswap_16(0x00ae), side_bswap_16('a'), side_bswap_16('b'), side_bswap_16('c'), 0 }; | |
52990f65 | 2113 | #else |
67337c4a MD |
2114 | uint32_t str32_le[] = { side_bswap_32(0x000000ae), side_bswap_32('a'), side_bswap_32('b'), side_bswap_32('c'), 0 }; |
2115 | uint16_t str16_le[] = { side_bswap_16(0x00ae), side_bswap_16('a'), side_bswap_16('b'), side_bswap_16('c'), 0 }; | |
52990f65 MD |
2116 | uint32_t str32_be[] = { 0x000000ae, 'a', 'b', 'c', 0 }; |
2117 | uint16_t str16_be[] = { 0x00ae, 'a', 'b', 'c', 0 }; | |
2118 | #endif | |
2119 | ||
67337c4a MD |
2120 | side_event(my_provider_event_str_utf, |
2121 | side_arg_list( | |
2122 | side_arg_string(str8), | |
2123 | side_arg_string32(str32), | |
2124 | side_arg_string16(str16), | |
2125 | side_arg_string32(str32_le), | |
2126 | side_arg_string16(str16_le), | |
2127 | side_arg_string32(str32_be), | |
2128 | side_arg_string16(str16_be), | |
a82ffcff | 2129 | side_arg_dynamic_string32(str32), |
67337c4a | 2130 | side_arg_gather_string(str32), |
52990f65 MD |
2131 | ) |
2132 | ); | |
2133 | } | |
2134 | ||
5530345d | 2135 | static side_define_variant(myvariantdef, |
a82ffcff | 2136 | side_type_u32(), |
5530345d | 2137 | side_option_list( |
a82ffcff MD |
2138 | side_option_range(1, 3, side_type_u16()), |
2139 | side_option(5, side_type_string()), | |
2140 | ) | |
5530345d MD |
2141 | ); |
2142 | ||
2143 | side_static_event(my_provider_event_variant, "myprovider", "myeventvariant", SIDE_LOGLEVEL_DEBUG, | |
2144 | side_field_list( | |
2145 | side_field_variant("variant1", &myvariantdef), | |
2146 | side_field_variant("variant2", &myvariantdef), | |
a82ffcff MD |
2147 | side_field_u8("z"), |
2148 | ) | |
5530345d MD |
2149 | ); |
2150 | ||
2151 | static | |
2152 | void test_variant(void) | |
2153 | { | |
2154 | side_event_cond(my_provider_event_variant) { | |
2155 | side_arg_define_variant(myvariant1, side_arg_u32(2), side_arg_u16(4)); | |
2156 | side_arg_define_variant(myvariant2, side_arg_u32(5), side_arg_string("abc")); | |
2157 | ||
2158 | side_event_call(my_provider_event_variant, | |
2159 | side_arg_list( | |
2160 | side_arg_variant(&myvariant1), | |
2161 | side_arg_variant(&myvariant2), | |
2162 | side_arg_u8(55), | |
2163 | ) | |
2164 | ); | |
2165 | } | |
2166 | } | |
2167 | ||
0cbdadb5 MD |
2168 | #ifdef __SIZEOF_INT128__ |
2169 | side_static_event(my_provider_event_integer128, "myprovider", "myevent_integer128", SIDE_LOGLEVEL_DEBUG, | |
2170 | side_field_list( | |
2171 | side_field_s128("signed128_base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
2172 | side_field_u128("unsigned128_base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), | |
2173 | side_field_s128("signed128_base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
2174 | side_field_u128("unsigned128_base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), | |
2175 | side_field_s128("signed128_base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
2176 | side_field_u128("unsigned128_base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), | |
2177 | side_field_s128("signed128_base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
2178 | side_field_u128("unsigned128_base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), | |
2179 | ) | |
2180 | ); | |
2181 | ||
2182 | static | |
2183 | void test_integer128(void) | |
2184 | { | |
2185 | side_event_cond(my_provider_event_integer128) { | |
2186 | __int128 s_v128 = 0; | |
2187 | unsigned __int128 u_v128; | |
2188 | ||
2189 | /* -2^63 - 1 */ | |
2190 | s_v128 = INT64_MIN; | |
2191 | s_v128--; | |
2192 | /* Maximum unsigned 128-bit value: 340282366920938463463374607431768211455. */ | |
2193 | u_v128 = 0; | |
2194 | u_v128--; | |
2195 | side_event_call(my_provider_event_integer128, | |
2196 | side_arg_list( | |
2197 | side_arg_s128(s_v128), | |
2198 | side_arg_u128(u_v128), | |
2199 | side_arg_s128(s_v128), | |
2200 | side_arg_u128(u_v128), | |
2201 | side_arg_s128(s_v128), | |
2202 | side_arg_u128(u_v128), | |
2203 | side_arg_s128(s_v128), | |
2204 | side_arg_u128(u_v128), | |
2205 | ) | |
2206 | ); | |
2207 | } | |
2208 | side_event_cond(my_provider_event_integer128) { | |
2209 | __int128 s_v128 = 0; | |
2210 | unsigned __int128 u_v128; | |
2211 | ||
2212 | /* Minimum signed 128-bit value: -170141183460469231731687303715884105728 */ | |
2213 | s_v128 = 1; | |
2214 | s_v128 <<= 64; | |
2215 | s_v128 <<= 63; | |
2216 | /* Zero. */ | |
2217 | u_v128 = 0; | |
2218 | side_event_call(my_provider_event_integer128, | |
2219 | side_arg_list( | |
2220 | side_arg_s128(s_v128), | |
2221 | side_arg_u128(u_v128), | |
2222 | side_arg_s128(s_v128), | |
2223 | side_arg_u128(u_v128), | |
2224 | side_arg_s128(s_v128), | |
2225 | side_arg_u128(u_v128), | |
2226 | side_arg_s128(s_v128), | |
2227 | side_arg_u128(u_v128), | |
2228 | ) | |
2229 | ); | |
2230 | } | |
2231 | side_event_cond(my_provider_event_integer128) { | |
2232 | __int128 s_v128 = 0; | |
2233 | unsigned __int128 u_v128; | |
2234 | ||
2235 | /* Minimum signed 128-bit value + 1: -170141183460469231731687303715884105727 */ | |
2236 | s_v128 = 1; | |
2237 | s_v128 <<= 64; | |
2238 | s_v128 <<= 63; | |
2239 | s_v128++; | |
2240 | /* INT64_MAX + 1. */ | |
2241 | u_v128 = INT64_MAX; /* 9223372036854775807LL */ | |
2242 | u_v128++; | |
2243 | side_event_call(my_provider_event_integer128, | |
2244 | side_arg_list( | |
2245 | side_arg_s128(s_v128), | |
2246 | side_arg_u128(u_v128), | |
2247 | side_arg_s128(s_v128), | |
2248 | side_arg_u128(u_v128), | |
2249 | side_arg_s128(s_v128), | |
2250 | side_arg_u128(u_v128), | |
2251 | side_arg_s128(s_v128), | |
2252 | side_arg_u128(u_v128), | |
2253 | ) | |
2254 | ); | |
2255 | } | |
2256 | } | |
2257 | #else | |
2258 | static | |
2259 | void test_integer128(void) | |
2260 | { | |
2261 | } | |
2262 | #endif | |
2263 | ||
2264 | ||
f611d0c3 MD |
2265 | int main() |
2266 | { | |
2267 | test_fields(); | |
89747802 MD |
2268 | test_event_hidden(); |
2269 | test_event_export(); | |
c7a14585 | 2270 | test_struct_literal(); |
f611d0c3 MD |
2271 | test_struct(); |
2272 | test_array(); | |
2273 | test_vla(); | |
2274 | test_vla_visitor(); | |
cdd6e858 | 2275 | test_vla_visitor_2d(); |
a2e2357e MD |
2276 | test_dynamic_basic_type(); |
2277 | test_dynamic_vla(); | |
465e5e7e | 2278 | test_dynamic_null(); |
c208889e MD |
2279 | test_dynamic_struct(); |
2280 | test_dynamic_nested_struct(); | |
2281 | test_dynamic_vla_struct(); | |
2282 | test_dynamic_struct_vla(); | |
948e3e72 | 2283 | test_dynamic_nested_vla(); |
19fa6aa2 | 2284 | test_variadic(); |
41c4d119 | 2285 | test_static_variadic(); |
4f40d951 MD |
2286 | test_bool(); |
2287 | test_dynamic_bool(); | |
8ceca0cd | 2288 | test_dynamic_vla_with_visitor(); |
2b359235 | 2289 | test_dynamic_struct_with_visitor(); |
65010f43 | 2290 | test_event_user_attribute(); |
a848763d | 2291 | test_field_user_attribute(); |
808bd9bf MD |
2292 | test_variadic_attr(); |
2293 | test_variadic_vla_attr(); | |
2294 | test_variadic_struct_attr(); | |
fb25b355 MD |
2295 | test_float(); |
2296 | test_variadic_float(); | |
79f677ba | 2297 | test_enum(); |
ea32e5fc | 2298 | test_enum_bitmap(); |
7aec0d09 | 2299 | test_blob(); |
71aa8975 | 2300 | test_fmt_string(); |
8bdd5c12 | 2301 | test_endian(); |
1d9c515c | 2302 | test_base(); |
d41cb7ee MD |
2303 | test_struct_gather(); |
2304 | test_struct_gather_nest_ptr(); | |
2305 | test_struct_gather_float(); | |
2306 | test_array_gather(); | |
2307 | test_gather_structnest(); | |
2308 | test_gather_vla(); | |
2309 | test_gather_vla_flex(); | |
d69918cc | 2310 | test_gather_byte(); |
8ad2f385 | 2311 | test_gather_bool(); |
4e1b0e0e | 2312 | test_gather_pointer(); |
0519cb86 | 2313 | test_gather_enum(); |
7d34edfc | 2314 | test_gather_string(); |
52990f65 | 2315 | test_string_utf(); |
5530345d | 2316 | test_variant(); |
0cbdadb5 | 2317 | test_integer128(); |
f611d0c3 MD |
2318 | return 0; |
2319 | } |