Move ABI headers under side/abi/
[libside.git] / include / side / instrumentation-c-api.h
CommitLineData
57553dfd
MD
1// SPDX-License-Identifier: MIT
2/*
3 * Copyright 2022-2023 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 */
5
6#ifndef SIDE_INSTRUMENTATION_C_API_H
7#define SIDE_INSTRUMENTATION_C_API_H
8
9#include <stdint.h>
10#include <side/macros.h>
11#include <side/endian.h>
12
b8dfb348
MD
13#include <side/abi/type-value.h>
14#include <side/abi/attribute.h>
15#include <side/abi/type-description.h>
57553dfd
MD
16
17#if (SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN)
18# define SIDE_TYPE_BYTE_ORDER_HOST SIDE_TYPE_BYTE_ORDER_LE
19#else
20# define SIDE_TYPE_BYTE_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE
21#endif
22
23#if (SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN)
24# define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_LE
25#else
26# define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE
27#endif
28
29/* Event and type attributes */
30
31#define side_attr(_key, _value) \
32 { \
33 .key = { \
34 .p = SIDE_PTR_INIT(_key), \
35 .unit_size = sizeof(uint8_t), \
36 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
37 }, \
38 .value = SIDE_PARAM(_value), \
39 }
40
41#define side_attr_list(...) \
42 SIDE_COMPOUND_LITERAL(const struct side_attr, __VA_ARGS__)
43
44#define side_attr_null(_val) { .type = SIDE_ATTR_TYPE_NULL }
45#define side_attr_bool(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_BOOL), .u = { .bool_value = !!(_val) } }
46#define side_attr_u8(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U8), .u = { .integer_value = { .side_u8 = (_val) } } }
47#define side_attr_u16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U16), .u = { .integer_value = { .side_u16 = (_val) } } }
48#define side_attr_u32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U32), .u = { .integer_value = { .side_u32 = (_val) } } }
49#define side_attr_u64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U64), .u = { .integer_value = { .side_u64 = (_val) } } }
50#define side_attr_s8(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S8), .u = { .integer_value = { .side_s8 = (_val) } } }
51#define side_attr_s16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S16), .u = { .integer_value = { .side_s16 = (_val) } } }
52#define side_attr_s32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S32), .u = { .integer_value = { .side_s32 = (_val) } } }
53#define side_attr_s64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S64), .u = { .integer_value = { .side_s64 = (_val) } } }
54#define side_attr_float_binary16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY16), .u = { .float_value = { .side_float_binary16 = (_val) } } }
55#define side_attr_float_binary32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY32), .u = { .float_value = { .side_float_binary32 = (_val) } } }
56#define side_attr_float_binary64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY64), .u = { .float_value = { .side_float_binary64 = (_val) } } }
57#define side_attr_float_binary128(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY128), .u = { .float_value = { .side_float_binary128 = (_val) } } }
58
59#define _side_attr_string(_val, _byte_order, _unit_size) \
60 { \
61 .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_STRING), \
62 .u = { \
63 .string_value = { \
64 .p = SIDE_PTR_INIT(_val), \
65 .unit_size = _unit_size, \
66 .byte_order = SIDE_ENUM_INIT(_byte_order), \
67 }, \
68 }, \
69 }
70
71#define side_attr_string(_val) _side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t))
72#define side_attr_string16(_val) _side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t))
73#define side_attr_string32(_val) _side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t))
74
75/* Stack-copy enumeration type definitions */
76
77#define side_define_enum(_identifier, _mappings, _attr...) \
78 const struct side_enum_mappings _identifier = { \
79 .mappings = SIDE_PTR_INIT(_mappings), \
80 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
81 .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \
82 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
83 }
84
85#define side_enum_mapping_list(...) \
86 SIDE_COMPOUND_LITERAL(const struct side_enum_mapping, __VA_ARGS__)
87
88#define side_enum_mapping_range(_label, _begin, _end) \
89 { \
90 .range_begin = _begin, \
91 .range_end = _end, \
92 .label = { \
93 .p = SIDE_PTR_INIT(_label), \
94 .unit_size = sizeof(uint8_t), \
95 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
96 }, \
97 }
98
99#define side_enum_mapping_value(_label, _value) \
100 { \
101 .range_begin = _value, \
102 .range_end = _value, \
103 .label = { \
104 .p = SIDE_PTR_INIT(_label), \
105 .unit_size = sizeof(uint8_t), \
106 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
107 }, \
108 }
109
110#define side_define_enum_bitmap(_identifier, _mappings, _attr...) \
111 const struct side_enum_bitmap_mappings _identifier = { \
112 .mappings = SIDE_PTR_INIT(_mappings), \
113 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
114 .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \
115 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
116 }
117
118#define side_enum_bitmap_mapping_list(...) \
119 SIDE_COMPOUND_LITERAL(const struct side_enum_bitmap_mapping, __VA_ARGS__)
120
121#define side_enum_bitmap_mapping_range(_label, _begin, _end) \
122 { \
123 .range_begin = _begin, \
124 .range_end = _end, \
125 .label = { \
126 .p = SIDE_PTR_INIT(_label), \
127 .unit_size = sizeof(uint8_t), \
128 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
129 }, \
130 }
131
132#define side_enum_bitmap_mapping_value(_label, _value) \
133 { \
134 .range_begin = _value, \
135 .range_end = _value, \
136 .label = { \
137 .p = SIDE_PTR_INIT(_label), \
138 .unit_size = sizeof(uint8_t), \
139 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
140 }, \
141 }
142
143/* Stack-copy field and type definitions */
144
145#define side_type_null(_attr...) \
146 { \
147 .type = SIDE_ENUM_INIT(SIDE_TYPE_NULL), \
148 .u = { \
149 .side_null = { \
150 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
151 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
152 }, \
153 }, \
154 }
155
156#define side_type_bool(_attr...) \
157 { \
158 .type = SIDE_ENUM_INIT(SIDE_TYPE_BOOL), \
159 .u = { \
160 .side_bool = { \
161 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
162 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
163 .bool_size = sizeof(uint8_t), \
164 .len_bits = 0, \
165 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
166 }, \
167 }, \
168 }
169
170#define side_type_byte(_attr...) \
171 { \
172 .type = SIDE_ENUM_INIT(SIDE_TYPE_BYTE), \
173 .u = { \
174 .side_byte = { \
175 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
176 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
177 }, \
178 }, \
179 }
180
181#define _side_type_string(_type, _byte_order, _unit_size, _attr) \
182 { \
183 .type = SIDE_ENUM_INIT(_type), \
184 .u = { \
185 .side_string = { \
186 .attr = SIDE_PTR_INIT(_attr), \
187 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
188 .unit_size = _unit_size, \
189 .byte_order = SIDE_ENUM_INIT(_byte_order), \
190 }, \
191 }, \
192 }
193
194#define side_type_dynamic() \
195 { \
196 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC), \
197 }
198
199#define _side_type_integer(_type, _signedness, _byte_order, _integer_size, _len_bits, _attr) \
200 { \
201 .type = SIDE_ENUM_INIT(_type), \
202 .u = { \
203 .side_integer = { \
204 .attr = SIDE_PTR_INIT(_attr), \
205 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
206 .integer_size = _integer_size, \
207 .len_bits = _len_bits, \
208 .signedness = _signedness, \
209 .byte_order = SIDE_ENUM_INIT(_byte_order), \
210 }, \
211 }, \
212 }
213
214#define _side_type_float(_type, _byte_order, _float_size, _attr) \
215 { \
216 .type = SIDE_ENUM_INIT(_type), \
217 .u = { \
218 .side_float = { \
219 .attr = SIDE_PTR_INIT(_attr), \
220 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
221 .float_size = _float_size, \
222 .byte_order = SIDE_ENUM_INIT(_byte_order), \
223 }, \
224 }, \
225 }
226
227#define _side_field(_name, _type) \
228 { \
229 .field_name = SIDE_PTR_INIT(_name), \
230 .side_type = _type, \
231 }
232
233#define side_option_range(_range_begin, _range_end, _type) \
234 { \
235 .range_begin = _range_begin, \
236 .range_end = _range_end, \
237 .side_type = _type, \
238 }
239
240#define side_option(_value, _type) \
241 side_option_range(_value, _value, SIDE_PARAM(_type))
242
243/* Host endian */
244#define side_type_u8(_attr...) _side_type_integer(SIDE_TYPE_U8, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
245#define side_type_u16(_attr...) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
246#define side_type_u32(_attr...) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
247#define side_type_u64(_attr...) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
248#define side_type_s8(_attr...) _side_type_integer(SIDE_TYPE_S8, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int8_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
249#define side_type_s16(_attr...) _side_type_integer(SIDE_TYPE_S16, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
250#define side_type_s32(_attr...) _side_type_integer(SIDE_TYPE_S32, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
251#define side_type_s64(_attr...) _side_type_integer(SIDE_TYPE_S64, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
252#define side_type_pointer(_attr...) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
253#define side_type_float_binary16(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
254#define side_type_float_binary32(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
255#define side_type_float_binary64(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
256#define side_type_float_binary128(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
257#define side_type_string(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF8, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
258#define side_type_string16(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
259#define side_type_string32(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
260
261#define side_field_null(_name, _attr...) _side_field(_name, side_type_null(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
262#define side_field_bool(_name, _attr...) _side_field(_name, side_type_bool(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
263#define side_field_u8(_name, _attr...) _side_field(_name, side_type_u8(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
264#define side_field_u16(_name, _attr...) _side_field(_name, side_type_u16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
265#define side_field_u32(_name, _attr...) _side_field(_name, side_type_u32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
266#define side_field_u64(_name, _attr...) _side_field(_name, side_type_u64(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
267#define side_field_s8(_name, _attr...) _side_field(_name, side_type_s8(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
268#define side_field_s16(_name, _attr...) _side_field(_name, side_type_s16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
269#define side_field_s32(_name, _attr...) _side_field(_name, side_type_s32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
270#define side_field_s64(_name, _attr...) _side_field(_name, side_type_s64(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
271#define side_field_byte(_name, _attr...) _side_field(_name, side_type_byte(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
272#define side_field_pointer(_name, _attr...) _side_field(_name, side_type_pointer(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
273#define side_field_float_binary16(_name, _attr...) _side_field(_name, side_type_float_binary16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
274#define side_field_float_binary32(_name, _attr...) _side_field(_name, side_type_float_binary32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
275#define side_field_float_binary64(_name, _attr...) _side_field(_name, side_type_float_binary64(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
276#define side_field_float_binary128(_name, _attr...) _side_field(_name, side_type_float_binary128(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
277#define side_field_string(_name, _attr...) _side_field(_name, side_type_string(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
278#define side_field_string16(_name, _attr...) _side_field(_name, side_type_string16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
279#define side_field_string32(_name, _attr...) _side_field(_name, side_type_string32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
280#define side_field_dynamic(_name) _side_field(_name, side_type_dynamic())
281
282/* Little endian */
283#define side_type_u16_le(_attr...) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
284#define side_type_u32_le(_attr...) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
285#define side_type_u64_le(_attr...) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
286#define side_type_s16_le(_attr...) _side_type_integer(SIDE_TYPE_S16, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
287#define side_type_s32_le(_attr...) _side_type_integer(SIDE_TYPE_S32, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
288#define side_type_s64_le(_attr...) _side_type_integer(SIDE_TYPE_S64, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
289#define side_type_pointer_le(_attr...) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
290#define side_type_float_binary16_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
291#define side_type_float_binary32_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
292#define side_type_float_binary64_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
293#define side_type_float_binary128_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
294#define side_type_string16_le(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
295#define side_type_string32_le(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
296
297#define side_field_u16_le(_name, _attr...) _side_field(_name, side_type_u16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
298#define side_field_u32_le(_name, _attr...) _side_field(_name, side_type_u32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
299#define side_field_u64_le(_name, _attr...) _side_field(_name, side_type_u64_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
300#define side_field_s16_le(_name, _attr...) _side_field(_name, side_type_s16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
301#define side_field_s32_le(_name, _attr...) _side_field(_name, side_type_s32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
302#define side_field_s64_le(_name, _attr...) _side_field(_name, side_type_s64_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
303#define side_field_pointer_le(_name, _attr...) _side_field(_name, side_type_pointer_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
304#define side_field_float_binary16_le(_name, _attr...) _side_field(_name, side_type_float_binary16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
305#define side_field_float_binary32_le(_name, _attr...) _side_field(_name, side_type_float_binary32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
306#define side_field_float_binary64_le(_name, _attr...) _side_field(_name, side_type_float_binary64_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
307#define side_field_float_binary128_le(_name, _attr...) _side_field(_name, side_type_float_binary128_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
308#define side_field_string16_le(_name, _attr...) _side_field(_name, side_type_string16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
309#define side_field_string32_le(_name, _attr...) _side_field(_name, side_type_string32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
310
311/* Big endian */
312#define side_type_u16_be(_attr...) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
313#define side_type_u32_be(_attr...) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
314#define side_type_u64_be(_attr...) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
315#define side_type_s16_be(_attr...) _side_type_integer(SIDE_TYPE_S16, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
316#define side_type_s32_be(_attr...) _side_type_integer(SIDE_TYPE_S32, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
317#define side_type_s64_be(_attr...) _side_type_integer(SIDE_TYPE_S64, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
318#define side_type_pointer_be(_attr...) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
319#define side_type_float_binary16_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
320#define side_type_float_binary32_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
321#define side_type_float_binary64_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
322#define side_type_float_binary128_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
323#define side_type_string16_be(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
324#define side_type_string32_be(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
325
326#define side_field_u16_be(_name, _attr...) _side_field(_name, side_type_u16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
327#define side_field_u32_be(_name, _attr...) _side_field(_name, side_type_u32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
328#define side_field_u64_be(_name, _attr...) _side_field(_name, side_type_u64_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
329#define side_field_s16_be(_name, _attr...) _side_field(_name, side_type_s16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
330#define side_field_s32_be(_name, _attr...) _side_field(_name, side_type_s32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
331#define side_field_s64_be(_name, _attr...) _side_field(_name, side_type_s64_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
332#define side_field_pointer_be(_name, _attr...) _side_field(_name, side_type_pointer_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
333#define side_field_float_binary16_be(_name, _attr...) _side_field(_name, side_type_float_binary16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
334#define side_field_float_binary32_be(_name, _attr...) _side_field(_name, side_type_float_binary32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
335#define side_field_float_binary64_be(_name, _attr...) _side_field(_name, side_type_float_binary64_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
336#define side_field_float_binary128_be(_name, _attr...) _side_field(_name, side_type_float_binary128_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
337#define side_field_string16_be(_name, _attr...) _side_field(_name, side_type_string16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
338#define side_field_string32_be(_name, _attr...) _side_field(_name, side_type_string32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
339
340#define side_type_enum(_mappings, _elem_type) \
341 { \
342 .type = SIDE_ENUM_INIT(SIDE_TYPE_ENUM), \
343 .u = { \
344 .side_enum = { \
345 .mappings = SIDE_PTR_INIT(_mappings), \
346 .elem_type = SIDE_PTR_INIT(_elem_type), \
347 }, \
348 }, \
349 }
350#define side_field_enum(_name, _mappings, _elem_type) \
351 _side_field(_name, side_type_enum(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type)))
352
353#define side_type_enum_bitmap(_mappings, _elem_type) \
354 { \
355 .type = SIDE_ENUM_INIT(SIDE_TYPE_ENUM_BITMAP), \
356 .u = { \
357 .side_enum_bitmap = { \
358 .mappings = SIDE_PTR_INIT(_mappings), \
359 .elem_type = SIDE_PTR_INIT(_elem_type), \
360 }, \
361 }, \
362 }
363#define side_field_enum_bitmap(_name, _mappings, _elem_type) \
364 _side_field(_name, side_type_enum_bitmap(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type)))
365
366#define side_type_struct(_struct) \
367 { \
368 .type = SIDE_ENUM_INIT(SIDE_TYPE_STRUCT), \
369 .u = { \
370 .side_struct = SIDE_PTR_INIT(_struct), \
371 }, \
372 }
373#define side_field_struct(_name, _struct) \
374 _side_field(_name, side_type_struct(SIDE_PARAM(_struct)))
375
376#define _side_type_struct_define(_fields, _attr) \
377 { \
378 .fields = SIDE_PTR_INIT(_fields), \
379 .attr = SIDE_PTR_INIT(_attr), \
380 .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
381 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
382 }
383
384#define side_define_struct(_identifier, _fields, _attr...) \
385 const struct side_type_struct _identifier = _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
386
387#define side_struct_literal(_fields, _attr...) \
388 SIDE_COMPOUND_LITERAL(const struct side_type_struct, \
389 _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
390
391#define side_type_variant(_variant) \
392 { \
393 .type = SIDE_ENUM_INIT(SIDE_TYPE_VARIANT), \
394 .u = { \
395 .side_variant = SIDE_PTR_INIT(_variant), \
396 }, \
397 }
398#define side_field_variant(_name, _variant) \
399 _side_field(_name, side_type_variant(SIDE_PARAM(_variant)))
400
401#define _side_type_variant_define(_selector, _options, _attr) \
402 { \
403 .selector = _selector, \
404 .options = SIDE_PTR_INIT(_options), \
405 .attr = SIDE_PTR_INIT(_attr), \
406 .nr_options = SIDE_ARRAY_SIZE(SIDE_PARAM(_options)), \
407 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
408 }
409
410#define side_define_variant(_identifier, _selector, _options, _attr...) \
411 const struct side_type_variant _identifier = \
412 _side_type_variant_define(SIDE_PARAM(_selector), SIDE_PARAM(_options), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
413
414#define side_variant_literal(_selector, _options, _attr...) \
415 SIDE_COMPOUND_LITERAL(const struct side_type_variant, \
416 _side_type_variant_define(SIDE_PARAM(_selector), SIDE_PARAM(_options), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
417
418#define side_type_array(_elem_type, _length, _attr...) \
419 { \
420 .type = SIDE_ENUM_INIT(SIDE_TYPE_ARRAY), \
421 .u = { \
422 .side_array = { \
423 .elem_type = SIDE_PTR_INIT(_elem_type), \
424 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
425 .length = _length, \
426 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
427 }, \
428 }, \
429 }
430#define side_field_array(_name, _elem_type, _length, _attr...) \
431 _side_field(_name, side_type_array(SIDE_PARAM(_elem_type), _length, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
432
433#define side_type_vla(_elem_type, _attr...) \
434 { \
435 .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA), \
436 .u = { \
437 .side_vla = { \
438 .elem_type = SIDE_PTR_INIT(_elem_type), \
439 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
440 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
441 }, \
442 }, \
443 }
444#define side_field_vla(_name, _elem_type, _attr...) \
445 _side_field(_name, side_type_vla(SIDE_PARAM(_elem_type), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
446
447#define side_type_vla_visitor(_elem_type, _visitor, _attr...) \
448 { \
449 .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA_VISITOR), \
450 .u = { \
451 .side_vla_visitor = { \
452 .elem_type = SIDE_PTR_INIT(_elem_type), \
453 .visitor = SIDE_PTR_INIT(_visitor), \
454 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
455 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
456 }, \
457 }, \
458 }
459#define side_field_vla_visitor(_name, _elem_type, _visitor, _attr...) \
460 _side_field(_name, side_type_vla_visitor(SIDE_PARAM(_elem_type), _visitor, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
461
462/* Gather field and type definitions */
463
464#define side_type_gather_byte(_offset, _access_mode, _attr...) \
465 { \
466 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BYTE), \
467 .u = { \
468 .side_gather = { \
469 .u = { \
470 .side_byte = { \
471 .offset = _offset, \
472 .access_mode = _access_mode, \
473 .type = { \
474 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
475 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
476 }, \
477 }, \
478 }, \
479 }, \
480 }, \
481 }
482#define side_field_gather_byte(_name, _offset, _access_mode, _attr...) \
483 _side_field(_name, side_type_gather_byte(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
484
485#define _side_type_gather_bool(_byte_order, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
486 { \
487 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BOOL), \
488 .u = { \
489 .side_gather = { \
490 .u = { \
491 .side_bool = { \
492 .offset = _offset, \
493 .access_mode = _access_mode, \
494 .type = { \
495 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
496 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
497 .bool_size = _bool_size, \
498 .len_bits = _len_bits, \
499 .byte_order = SIDE_ENUM_INIT(_byte_order), \
500 }, \
501 .offset_bits = _offset_bits, \
502 }, \
503 }, \
504 }, \
505 }, \
506 }
507#define side_type_gather_bool(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
508 _side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_HOST, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
509#define side_type_gather_bool_le(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
510 _side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_LE, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
511#define side_type_gather_bool_be(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
512 _side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_BE, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
513
514#define side_field_gather_bool(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
515 _side_field(_name, side_type_gather_bool(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))))
516#define side_field_gather_bool_le(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
517 _side_field(_name, side_type_gather_bool_le(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))))
518#define side_field_gather_bool_be(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \
519 _side_field(_name, side_type_gather_bool_be(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))))
520
521#define _side_type_gather_integer(_type, _signedness, _byte_order, _offset, \
522 _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
523 { \
524 .type = SIDE_ENUM_INIT(_type), \
525 .u = { \
526 .side_gather = { \
527 .u = { \
528 .side_integer = { \
529 .offset = _offset, \
530 .access_mode = _access_mode, \
531 .type = { \
532 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
533 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
534 .integer_size = _integer_size, \
535 .len_bits = _len_bits, \
536 .signedness = _signedness, \
537 .byte_order = SIDE_ENUM_INIT(_byte_order), \
538 }, \
539 .offset_bits = _offset_bits, \
540 }, \
541 }, \
542 }, \
543 }, \
544 }
545
546#define side_type_gather_unsigned_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
547 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_HOST, \
548 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
549#define side_type_gather_signed_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
550 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_HOST, \
551 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
552
553#define side_type_gather_unsigned_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
554 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_LE, \
555 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
556#define side_type_gather_signed_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
557 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_LE, \
558 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
559
560#define side_type_gather_unsigned_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
561 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_BE, \
562 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
563#define side_type_gather_signed_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
564 _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_BE, \
565 _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
566
567#define side_field_gather_unsigned_integer(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
568 _side_field(_name, side_type_gather_unsigned_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
569#define side_field_gather_signed_integer(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
570 _side_field(_name, side_type_gather_signed_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
571
572#define side_field_gather_unsigned_integer_le(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
573 _side_field(_name, side_type_gather_unsigned_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
574#define side_field_gather_signed_integer_le(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
575 _side_field(_name, side_type_gather_signed_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
576
577#define side_field_gather_unsigned_integer_be(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
578 _side_field(_name, side_type_gather_unsigned_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
579#define side_field_gather_signed_integer_be(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \
580 _side_field(_name, side_type_gather_signed_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
581
582#define side_type_gather_pointer(_offset, _access_mode, _attr...) \
583 _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_HOST, \
584 _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
585#define side_field_gather_pointer(_name, _offset, _access_mode, _attr...) \
586 _side_field(_name, side_type_gather_pointer(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
587
588#define side_type_gather_pointer_le(_offset, _access_mode, _attr...) \
589 _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_LE, \
590 _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
591#define side_field_gather_pointer_le(_name, _offset, _access_mode, _attr...) \
592 _side_field(_name, side_type_gather_pointer_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
593
594#define side_type_gather_pointer_be(_offset, _access_mode, _attr...) \
595 _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_BE, \
596 _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
597#define side_field_gather_pointer_be(_name, _offset, _access_mode, _attr...) \
598 _side_field(_name, side_type_gather_pointer_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
599
600#define _side_type_gather_float(_byte_order, _offset, _float_size, _access_mode, _attr...) \
601 { \
602 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_FLOAT), \
603 .u = { \
604 .side_gather = { \
605 .u = { \
606 .side_float = { \
607 .offset = _offset, \
608 .access_mode = _access_mode, \
609 .type = { \
610 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
611 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
612 .float_size = _float_size, \
613 .byte_order = SIDE_ENUM_INIT(_byte_order), \
614 }, \
615 }, \
616 }, \
617 }, \
618 }, \
619 }
620
621#define side_type_gather_float(_offset, _float_size, _access_mode, _attr...) \
622 _side_type_gather_float(SIDE_TYPE_FLOAT_WORD_ORDER_HOST, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
623#define side_type_gather_float_le(_offset, _float_size, _access_mode, _attr...) \
624 _side_type_gather_float(SIDE_TYPE_BYTE_ORDER_LE, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
625#define side_type_gather_float_be(_offset, _float_size, _access_mode, _attr...) \
626 _side_type_gather_float(SIDE_TYPE_BYTE_ORDER_BE, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
627
628#define side_field_gather_float(_name, _offset, _float_size, _access_mode, _attr...) \
629 _side_field(_name, side_type_gather_float(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
630#define side_field_gather_float_le(_name, _offset, _float_size, _access_mode, _attr...) \
631 _side_field(_name, side_type_gather_float_le(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
632#define side_field_gather_float_be(_name, _offset, _float_size, _access_mode, _attr...) \
633 _side_field(_name, side_type_gather_float_be(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
634
635#define _side_type_gather_string(_offset, _byte_order, _unit_size, _access_mode, _attr...) \
636 { \
637 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRING), \
638 .u = { \
639 .side_gather = { \
640 .u = { \
641 .side_string = { \
642 .offset = _offset, \
643 .access_mode = _access_mode, \
644 .type = { \
645 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
646 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
647 .unit_size = _unit_size, \
648 .byte_order = SIDE_ENUM_INIT(_byte_order), \
649 }, \
650 }, \
651 }, \
652 }, \
653 }, \
654 }
655#define side_type_gather_string(_offset, _access_mode, _attr...) \
656 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
657#define side_field_gather_string(_name, _offset, _access_mode, _attr...) \
658 _side_field(_name, side_type_gather_string(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
659
660#define side_type_gather_string16(_offset, _access_mode, _attr...) \
661 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
662#define side_type_gather_string16_le(_offset, _access_mode, _attr...) \
663 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
664#define side_type_gather_string16_be(_offset, _access_mode, _attr...) \
665 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
666
667#define side_field_gather_string16(_name, _offset, _access_mode, _attr...) \
668 _side_field(_name, side_type_gather_string16(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
669#define side_field_gather_string16_le(_name, _offset, _access_mode, _attr...) \
670 _side_field(_name, side_type_gather_string16_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
671#define side_field_gather_string16_be(_name, _offset, _access_mode, _attr...) \
672 _side_field(_name, side_type_gather_string16_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
673
674#define side_type_gather_string32(_offset, _access_mode, _attr...) \
675 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
676#define side_type_gather_string32_le(_offset, _access_mode, _attr...) \
677 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
678#define side_type_gather_string32_be(_offset, _access_mode, _attr...) \
679 _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
680
681#define side_field_gather_string32(_name, _offset, _access_mode, _attr...) \
682 _side_field(_name, side_type_gather_string32(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
683#define side_field_gather_string32_le(_name, _offset, _access_mode, _attr...) \
684 _side_field(_name, side_type_gather_string32_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
685#define side_field_gather_string32_be(_name, _offset, _access_mode, _attr...) \
686 _side_field(_name, side_type_gather_string32_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
687
688#define side_type_gather_enum(_mappings, _elem_type) \
689 { \
690 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_ENUM), \
691 .u = { \
692 .side_enum = { \
693 .mappings = SIDE_PTR_INIT(_mappings), \
694 .elem_type = SIDE_PTR_INIT(_elem_type), \
695 }, \
696 }, \
697 }
698#define side_field_gather_enum(_name, _mappings, _elem_type) \
699 _side_field(_name, side_type_gather_enum(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type)))
700
701#define side_type_gather_struct(_struct_gather, _offset, _size, _access_mode) \
702 { \
703 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRUCT), \
704 .u = { \
705 .side_gather = { \
706 .u = { \
707 .side_struct = { \
708 .offset = _offset, \
709 .access_mode = _access_mode, \
710 .type = SIDE_PTR_INIT(_struct_gather), \
711 .size = _size, \
712 }, \
713 }, \
714 }, \
715 }, \
716 }
717#define side_field_gather_struct(_name, _struct_gather, _offset, _size, _access_mode) \
718 _side_field(_name, side_type_gather_struct(SIDE_PARAM(_struct_gather), _offset, _size, _access_mode))
719
720#define side_type_gather_array(_elem_type_gather, _length, _offset, _access_mode, _attr...) \
721 { \
722 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_ARRAY), \
723 .u = { \
724 .side_gather = { \
725 .u = { \
726 .side_array = { \
727 .offset = _offset, \
728 .access_mode = _access_mode, \
729 .type = { \
730 .elem_type = SIDE_PTR_INIT(_elem_type_gather), \
731 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
732 .length = _length, \
733 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
734 }, \
735 }, \
736 }, \
737 }, \
738 }, \
739 }
740#define side_field_gather_array(_name, _elem_type, _length, _offset, _access_mode, _attr...) \
741 _side_field(_name, side_type_gather_array(SIDE_PARAM(_elem_type), _length, _offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
742
743#define side_type_gather_vla(_elem_type_gather, _offset, _access_mode, _length_type_gather, _attr...) \
744 { \
745 .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_VLA), \
746 .u = { \
747 .side_gather = { \
748 .u = { \
749 .side_vla = { \
750 .length_type = SIDE_PTR_INIT(_length_type_gather), \
751 .offset = _offset, \
752 .access_mode = _access_mode, \
753 .type = { \
754 .elem_type = SIDE_PTR_INIT(_elem_type_gather), \
755 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
756 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
757 }, \
758 }, \
759 }, \
760 }, \
761 }, \
762 }
763#define side_field_gather_vla(_name, _elem_type_gather, _offset, _access_mode, _length_type_gather, _attr...) \
764 _side_field(_name, side_type_gather_vla(SIDE_PARAM(_elem_type_gather), _offset, _access_mode, SIDE_PARAM(_length_type_gather), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))
765
766#define side_elem(...) \
767 SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__)
768
769#define side_length(...) \
770 SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__)
771
772#define side_field_list(...) \
773 SIDE_COMPOUND_LITERAL(const struct side_event_field, __VA_ARGS__)
774
775#define side_option_list(...) \
776 SIDE_COMPOUND_LITERAL(const struct side_variant_option, __VA_ARGS__)
777
778/* Stack-copy field arguments */
779
780#define side_arg_null(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_NULL) }
781#define side_arg_bool(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_BOOL), .u = { .side_static = { .bool_value = { .side_bool8 = !!(_val) } } } }
782#define side_arg_byte(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_BYTE), .u = { .side_static = { .byte_value = (_val) } } }
783#define side_arg_string(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF8), .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } }
784#define side_arg_string16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF16), .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } }
785#define side_arg_string32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF32), .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } }
786
787#define side_arg_u8(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U8), .u = { .side_static = { .integer_value = { .side_u8 = (_val) } } } }
788#define side_arg_u16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U16), .u = { .side_static = { .integer_value = { .side_u16 = (_val) } } } }
789#define side_arg_u32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U32), .u = { .side_static = { .integer_value = { .side_u32 = (_val) } } } }
790#define side_arg_u64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U64), .u = { .side_static = { .integer_value = { .side_u64 = (_val) } } } }
791#define side_arg_s8(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S8), .u = { .side_static = { .integer_value = { .side_s8 = (_val) } } } }
792#define side_arg_s16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S16), .u = { .side_static = { .integer_value = { .side_s16 = (_val) } } } }
793#define side_arg_s32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S32), .u = { .side_static = { .integer_value = { .side_s32 = (_val) } } } }
794#define side_arg_s64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S64), .u = { .side_static = { .integer_value = { .side_s64 = (_val) } } } }
795#define side_arg_pointer(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_POINTER), .u = { .side_static = { .integer_value = { .side_uptr = (uintptr_t) (_val) } } } }
796#define side_arg_float_binary16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY16), .u = { .side_static = { .float_value = { .side_float_binary16 = (_val) } } } }
797#define side_arg_float_binary32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY32), .u = { .side_static = { .float_value = { .side_float_binary32 = (_val) } } } }
798#define side_arg_float_binary64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY64), .u = { .side_static = { .float_value = { .side_float_binary64 = (_val) } } } }
799#define side_arg_float_binary128(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY128), .u = { .side_static = { .float_value = { .side_float_binary128 = (_val) } } } }
800
801#define side_arg_struct(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRUCT), .u = { .side_static = { .side_struct = SIDE_PTR_INIT(_side_type) } } }
802
803#define side_arg_define_variant(_identifier, _selector_val, _option) \
804 const struct side_arg_variant _identifier = { \
805 .selector = _selector_val, \
806 .option = _option, \
807 }
808#define side_arg_variant(_side_variant) \
809 { \
810 .type = SIDE_ENUM_INIT(SIDE_TYPE_VARIANT), \
811 .u = { \
812 .side_static = { \
813 .side_variant = SIDE_PTR_INIT(_side_variant), \
814 }, \
815 }, \
816 }
817
818#define side_arg_array(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_ARRAY), .u = { .side_static = { .side_array = SIDE_PTR_INIT(_side_type) } } }
819#define side_arg_vla(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA), .u = { .side_static = { .side_vla = SIDE_PTR_INIT(_side_type) } } }
820#define side_arg_vla_visitor(_ctx) { .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA_VISITOR), .u = { .side_static = { .side_vla_app_visitor_ctx = (_ctx) } } }
821
822/* Gather field arguments */
823
824#define side_arg_gather_bool(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BOOL), .u = { .side_static = { .side_bool_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
825#define side_arg_gather_byte(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BYTE), .u = { .side_static = { .side_byte_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
826#define side_arg_gather_pointer(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_POINTER), .u = { .side_static = { .side_integer_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
827#define side_arg_gather_integer(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_INTEGER), .u = { .side_static = { .side_integer_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
828#define side_arg_gather_float(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_FLOAT), .u = { .side_static = { .side_float_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
829#define side_arg_gather_string(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRING), .u = { .side_static = { .side_string_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
830#define side_arg_gather_struct(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRUCT), .u = { .side_static = { .side_struct_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
831#define side_arg_gather_array(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_ARRAY), .u = { .side_static = { .side_array_gather_ptr = SIDE_PTR_INIT(_ptr) } } }
832#define side_arg_gather_vla(_ptr, _length_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_VLA), .u = { .side_static = { .side_vla_gather = { .ptr = SIDE_PTR_INIT(_ptr), .length_ptr = SIDE_PTR_INIT(_length_ptr) } } } }
833
834/* Dynamic field arguments */
835
836#define side_arg_dynamic_null(_attr...) \
837 { \
838 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_NULL), \
839 .u = { \
840 .side_dynamic = { \
841 .side_null = { \
842 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
843 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
844 }, \
845 }, \
846 }, \
847 }
848
849#define side_arg_dynamic_bool(_val, _attr...) \
850 { \
851 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_BOOL), \
852 .u = { \
853 .side_dynamic = { \
854 .side_bool = { \
855 .type = { \
856 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
857 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
858 .bool_size = sizeof(uint8_t), \
859 .len_bits = 0, \
860 .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \
861 }, \
862 .value = { \
863 .side_bool8 = !!(_val), \
864 }, \
865 }, \
866 }, \
867 }, \
868 }
869
870#define side_arg_dynamic_byte(_val, _attr...) \
871 { \
872 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_BYTE), \
873 .u = { \
874 .side_dynamic = { \
875 .side_byte = { \
876 .type = { \
877 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
878 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
879 }, \
880 .value = (_val), \
881 }, \
882 }, \
883 }, \
884 }
885
886#define _side_arg_dynamic_string(_val, _byte_order, _unit_size, _attr...) \
887 { \
888 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRING), \
889 .u = { \
890 .side_dynamic = { \
891 .side_string = { \
892 .type = { \
893 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
894 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
895 .unit_size = _unit_size, \
896 .byte_order = SIDE_ENUM_INIT(_byte_order), \
897 }, \
898 .value = (uintptr_t) (_val), \
899 }, \
900 }, \
901 }, \
902 }
903#define side_arg_dynamic_string(_val, _attr...) \
904 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
905#define side_arg_dynamic_string16(_val, _attr...) \
906 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
907#define side_arg_dynamic_string16_le(_val, _attr...) \
908 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
909#define side_arg_dynamic_string16_be(_val, _attr...) \
910 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
911#define side_arg_dynamic_string32(_val, _attr...) \
912 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
913#define side_arg_dynamic_string32_le(_val, _attr...) \
914 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
915#define side_arg_dynamic_string32_be(_val, _attr...) \
916 _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
917
918#define _side_arg_dynamic_integer(_field, _val, _type, _signedness, _byte_order, _integer_size, _len_bits, _attr...) \
919 { \
920 .type = SIDE_ENUM_INIT(_type), \
921 .u = { \
922 .side_dynamic = { \
923 .side_integer = { \
924 .type = { \
925 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
926 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
927 .integer_size = _integer_size, \
928 .len_bits = _len_bits, \
929 .signedness = _signedness, \
930 .byte_order = SIDE_ENUM_INIT(_byte_order), \
931 }, \
932 .value = { \
933 _field = (_val), \
934 }, \
935 }, \
936 }, \
937 }, \
938 }
939
940#define side_arg_dynamic_u8(_val, _attr...) \
941 _side_arg_dynamic_integer(.side_u8, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
942#define side_arg_dynamic_s8(_val, _attr...) \
943 _side_arg_dynamic_integer(.side_s8, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int8_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
944
945#define _side_arg_dynamic_u16(_val, _byte_order, _attr...) \
946 _side_arg_dynamic_integer(.side_u16, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
947#define _side_arg_dynamic_u32(_val, _byte_order, _attr...) \
948 _side_arg_dynamic_integer(.side_u32, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
949#define _side_arg_dynamic_u64(_val, _byte_order, _attr...) \
950 _side_arg_dynamic_integer(.side_u64, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
951
952#define _side_arg_dynamic_s16(_val, _byte_order, _attr...) \
953 _side_arg_dynamic_integer(.side_s16, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
954#define _side_arg_dynamic_s32(_val, _byte_order, _attr...) \
955 _side_arg_dynamic_integer(.side_s32, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
956#define _side_arg_dynamic_s64(_val, _byte_order, _attr...) \
957 _side_arg_dynamic_integer(.side_s64, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
958
959#define _side_arg_dynamic_pointer(_val, _byte_order, _attr...) \
960 _side_arg_dynamic_integer(.side_uptr, (uintptr_t) (_val), SIDE_TYPE_DYNAMIC_POINTER, false, _byte_order, \
961 sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
962
963#define _side_arg_dynamic_float(_field, _val, _type, _byte_order, _float_size, _attr...) \
964 { \
965 .type = SIDE_ENUM_INIT(_type), \
966 .u = { \
967 .side_dynamic = { \
968 .side_float = { \
969 .type = { \
970 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
971 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
972 .float_size = _float_size, \
973 .byte_order = SIDE_ENUM_INIT(_byte_order), \
974 }, \
975 .value = { \
976 _field = (_val), \
977 }, \
978 }, \
979 }, \
980 }, \
981 }
982
983#define _side_arg_dynamic_float_binary16(_val, _byte_order, _attr...) \
984 _side_arg_dynamic_float(.side_float_binary16, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
985#define _side_arg_dynamic_float_binary32(_val, _byte_order, _attr...) \
986 _side_arg_dynamic_float(.side_float_binary32, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
987#define _side_arg_dynamic_float_binary64(_val, _byte_order, _attr...) \
988 _side_arg_dynamic_float(.side_float_binary64, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
989#define _side_arg_dynamic_float_binary128(_val, _byte_order, _attr...) \
990 _side_arg_dynamic_float(.side_float_binary128, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
991
992/* Host endian */
993#define side_arg_dynamic_u16(_val, _attr...) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
994#define side_arg_dynamic_u32(_val, _attr...) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
995#define side_arg_dynamic_u64(_val, _attr...) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
996#define side_arg_dynamic_s16(_val, _attr...) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
997#define side_arg_dynamic_s32(_val, _attr...) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
998#define side_arg_dynamic_s64(_val, _attr...) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
999#define side_arg_dynamic_pointer(_val, _attr...) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1000#define side_arg_dynamic_float_binary16(_val, _attr...) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1001#define side_arg_dynamic_float_binary32(_val, _attr...) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1002#define side_arg_dynamic_float_binary64(_val, _attr...) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1003#define side_arg_dynamic_float_binary128(_val, _attr...) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1004
1005/* Little endian */
1006#define side_arg_dynamic_u16_le(_val, _attr...) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1007#define side_arg_dynamic_u32_le(_val, _attr...) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1008#define side_arg_dynamic_u64_le(_val, _attr...) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1009#define side_arg_dynamic_s16_le(_val, _attr...) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1010#define side_arg_dynamic_s32_le(_val, _attr...) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1011#define side_arg_dynamic_s64_le(_val, _attr...) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1012#define side_arg_dynamic_pointer_le(_val, _attr...) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1013#define side_arg_dynamic_float_binary16_le(_val, _attr...) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1014#define side_arg_dynamic_float_binary32_le(_val, _attr...) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1015#define side_arg_dynamic_float_binary64_le(_val, _attr...) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1016#define side_arg_dynamic_float_binary128_le(_val, _attr...) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1017
1018/* Big endian */
1019#define side_arg_dynamic_u16_be(_val, _attr...) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1020#define side_arg_dynamic_u32_be(_val, _attr...) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1021#define side_arg_dynamic_u64_be(_val, _attr...) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1022#define side_arg_dynamic_s16_be(_val, _attr...) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1023#define side_arg_dynamic_s32_be(_val, _attr...) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1024#define side_arg_dynamic_s64_be(_val, _attr...) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1025#define side_arg_dynamic_pointer_be(_val, _attr...) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1026#define side_arg_dynamic_float_binary16_be(_val, _attr...) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1027#define side_arg_dynamic_float_binary32_be(_val, _attr...) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1028#define side_arg_dynamic_float_binary64_be(_val, _attr...) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1029#define side_arg_dynamic_float_binary128_be(_val, _attr...) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1030
1031#define side_arg_dynamic_vla(_vla) \
1032 { \
1033 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_VLA), \
1034 .u = { \
1035 .side_dynamic = { \
1036 .side_dynamic_vla = SIDE_PTR_INIT(_vla), \
1037 }, \
1038 }, \
1039 }
1040
1041#define side_arg_dynamic_vla_visitor(_dynamic_vla_visitor, _ctx, _attr...) \
1042 { \
1043 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_VLA_VISITOR), \
1044 .u = { \
1045 .side_dynamic = { \
1046 .side_dynamic_vla_visitor = { \
1047 .app_ctx = SIDE_PTR_INIT(_ctx), \
1048 .visitor = SIDE_PTR_INIT(_dynamic_vla_visitor), \
1049 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1050 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1051 }, \
1052 }, \
1053 }, \
1054 }
1055
1056#define side_arg_dynamic_struct(_struct) \
1057 { \
1058 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRUCT), \
1059 .u = { \
1060 .side_dynamic = { \
1061 .side_dynamic_struct = SIDE_PTR_INIT(_struct), \
1062 }, \
1063 }, \
1064 }
1065
1066#define side_arg_dynamic_struct_visitor(_dynamic_struct_visitor, _ctx, _attr...) \
1067 { \
1068 .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRUCT_VISITOR), \
1069 .u = { \
1070 .side_dynamic = { \
1071 .side_dynamic_struct_visitor = { \
1072 .app_ctx = SIDE_PTR_INIT(_ctx), \
1073 .visitor = SIDE_PTR_INIT(_dynamic_struct_visitor), \
1074 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1075 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1076 }, \
1077 }, \
1078 }, \
1079 }
1080
1081#define side_arg_dynamic_define_vec(_identifier, _sav, _attr...) \
1082 const struct side_arg _identifier##_vec[] = { _sav }; \
1083 const struct side_arg_dynamic_vla _identifier = { \
1084 .sav = SIDE_PTR_INIT(_identifier##_vec), \
1085 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1086 .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
1087 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1088 }
1089
1090#define side_arg_dynamic_define_struct(_identifier, _struct_fields, _attr...) \
1091 const struct side_arg_dynamic_field _identifier##_fields[] = { _struct_fields }; \
1092 const struct side_arg_dynamic_struct _identifier = { \
1093 .fields = SIDE_PTR_INIT(_identifier##_fields), \
1094 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1095 .len = SIDE_ARRAY_SIZE(_identifier##_fields), \
1096 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1097 }
1098
1099#define side_arg_define_vec(_identifier, _sav) \
1100 const struct side_arg _identifier##_vec[] = { _sav }; \
1101 const struct side_arg_vec _identifier = { \
1102 .sav = SIDE_PTR_INIT(_identifier##_vec), \
1103 .len = SIDE_ARRAY_SIZE(_identifier##_vec), \
1104 }
1105
1106#define side_arg_dynamic_field(_name, _elem) \
1107 { \
1108 .field_name = SIDE_PTR_INIT(_name), \
1109 .elem = _elem, \
1110 }
1111
1112/*
1113 * Event instrumentation description registration, runtime enabled state
1114 * check, and instrumentation invocation.
1115 */
1116
1117#define side_arg_list(...) __VA_ARGS__
1118
1119#define side_event_cond(_identifier) \
1120 if (side_unlikely(__atomic_load_n(&side_event_state__##_identifier.enabled, \
1121 __ATOMIC_RELAXED)))
1122
1123#define side_event_call(_identifier, _sav) \
1124 { \
1125 const struct side_arg side_sav[] = { _sav }; \
1126 const struct side_arg_vec side_arg_vec = { \
1127 .sav = SIDE_PTR_INIT(side_sav), \
1128 .len = SIDE_ARRAY_SIZE(side_sav), \
1129 }; \
1130 side_call(&(side_event_state__##_identifier).p, &side_arg_vec); \
1131 }
1132
1133#define side_event(_identifier, _sav) \
1134 side_event_cond(_identifier) \
1135 side_event_call(_identifier, SIDE_PARAM(_sav))
1136
1137#define side_event_call_variadic(_identifier, _sav, _var_fields, _attr...) \
1138 { \
1139 const struct side_arg side_sav[] = { _sav }; \
1140 const struct side_arg_vec side_arg_vec = { \
1141 .sav = SIDE_PTR_INIT(side_sav), \
1142 .len = SIDE_ARRAY_SIZE(side_sav), \
1143 }; \
1144 const struct side_arg_dynamic_field side_fields[] = { _var_fields }; \
1145 const struct side_arg_dynamic_struct var_struct = { \
1146 .fields = SIDE_PTR_INIT(side_fields), \
1147 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1148 .len = SIDE_ARRAY_SIZE(side_fields), \
1149 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1150 }; \
1151 side_call_variadic(&(side_event_state__##_identifier.p), &side_arg_vec, &var_struct); \
1152 }
1153
1154#define side_event_variadic(_identifier, _sav, _var, _attr...) \
1155 side_event_cond(_identifier) \
1156 side_event_call_variadic(_identifier, SIDE_PARAM(_sav), SIDE_PARAM(_var), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1157
1158#define _side_define_event(_linkage, _identifier, _provider, _event, _loglevel, _fields, _flags, _attr...) \
1159 _linkage struct side_event_description __attribute__((section("side_event_description"))) \
1160 _identifier; \
1161 _linkage struct side_event_state_0 __attribute__((section("side_event_state"))) \
1162 side_event_state__##_identifier = { \
1163 .p = { \
1164 .version = SIDE_EVENT_STATE_ABI_VERSION, \
1165 }, \
1166 .enabled = 0, \
1167 .callbacks = SIDE_PTR_INIT(&side_empty_callback), \
1168 .desc = SIDE_PTR_INIT(&(_identifier)), \
1169 }; \
1170 _linkage struct side_event_description __attribute__((section("side_event_description"))) \
1171 _identifier = { \
1172 .struct_size = offsetof(struct side_event_description, end), \
1173 .version = SIDE_EVENT_DESCRIPTION_ABI_VERSION, \
1174 .state = SIDE_PTR_INIT(&(side_event_state__##_identifier.p)), \
1175 .provider_name = SIDE_PTR_INIT(_provider), \
1176 .event_name = SIDE_PTR_INIT(_event), \
1177 .fields = SIDE_PTR_INIT(_fields), \
1178 .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1179 .flags = (_flags), \
1180 .nr_side_type_label = _NR_SIDE_TYPE_LABEL, \
1181 .nr_side_attr_type = _NR_SIDE_ATTR_TYPE, \
1182 .loglevel = SIDE_ENUM_INIT(_loglevel), \
1183 .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
1184 .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
1185 .nr_callbacks = 0, \
1186 }; \
1187 static const struct side_event_description *side_event_ptr__##_identifier \
1188 __attribute__((section("side_event_description_ptr"), used)) = &(_identifier);
1189
1190#define side_static_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
1191 _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
1192 0, ##_attr)
1193
1194#define side_static_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
1195 _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
1196 SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1197
1198#define side_hidden_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
1199 _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \
1200 _loglevel, SIDE_PARAM(_fields), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1201
1202#define side_hidden_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
1203 _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \
1204 _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1205
1206#define side_export_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
1207 _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \
1208 _loglevel, SIDE_PARAM(_fields), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1209
1210#define side_export_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \
1211 _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \
1212 _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))
1213
1214#define side_declare_event(_identifier) \
1215 extern struct side_event_state_0 side_event_state_##_identifier; \
1216 extern struct side_event_description _identifier
1217
1218#endif /* SIDE_INSTRUMENTATION_C_API_H */
This page took 0.0677 seconds and 4 git commands to generate.