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