Commit | Line | Data |
---|---|---|
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) } } } | |
b1d9577a | 50 | #define side_attr_u128(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U128), .u = { .integer_value = { .side_u128 = (_val) } } } |
57553dfd MD |
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) } } } | |
b1d9577a | 55 | #define side_attr_s128(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S128), .u = { .integer_value = { .side_s128 = (_val) } } } |
57553dfd MD |
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())) | |
0cbdadb5 | 250 | #define side_type_u128(_attr...) _side_type_integer(SIDE_TYPE_U128, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(unsigned __int128), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) |
57553dfd MD |
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())) | |
0cbdadb5 | 255 | #define side_type_s128(_attr...) _side_type_integer(SIDE_TYPE_S128, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(__int128), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) |
57553dfd MD |
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()))) | |
b1d9577a | 271 | #define side_field_u128(_name, _attr...) _side_field(_name, side_type_u128(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) |
57553dfd MD |
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()))) | |
b1d9577a | 276 | #define side_field_s128(_name, _attr...) _side_field(_name, side_type_s128(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) |
57553dfd MD |
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())) | |
b1d9577a | 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())) |
57553dfd MD |
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())) | |
b1d9577a | 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())) |
57553dfd MD |
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()))) | |
b1d9577a | 308 | #define side_field_u128_le(_name, _attr...) _side_field(_name, side_type_u128_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) |
57553dfd MD |
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()))) | |
b1d9577a | 312 | #define side_field_s128_le(_name, _attr...) _side_field(_name, side_type_s128_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) |
57553dfd MD |
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())) | |
b1d9577a | 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())) |
57553dfd MD |
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())) | |
b1d9577a | 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())) |
57553dfd MD |
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()))) | |
b1d9577a | 341 | #define side_field_u128_be(_name, _attr...) _side_field(_name, side_type_u128_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) |
57553dfd MD |
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()))) | |
b1d9577a | 345 | #define side_field_s128_be(_name, _attr...) _side_field(_name, side_type_s128_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) |
57553dfd MD |
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 | ||
f0619c77 | 447 | #define side_type_vla(_elem_type, _length_type, _attr...) \ |
57553dfd MD |
448 | { \ |
449 | .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA), \ | |
450 | .u = { \ | |
451 | .side_vla = { \ | |
452 | .elem_type = SIDE_PTR_INIT(_elem_type), \ | |
f0619c77 | 453 | .length_type = SIDE_PTR_INIT(_length_type), \ |
57553dfd MD |
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 | } | |
f0619c77 MD |
459 | #define side_field_vla(_name, _elem_type, _length_type, _attr...) \ |
460 | _side_field(_name, side_type_vla(SIDE_PARAM(_elem_type), SIDE_PARAM(_length_type), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
57553dfd | 461 | |
f0619c77 MD |
462 | #define _side_type_vla_visitor_define(_elem_type, _length_type, _visitor, _attr...) \ |
463 | { \ | |
464 | .elem_type = SIDE_PTR_INIT(_elem_type), \ | |
465 | .length_type = SIDE_PTR_INIT(_length_type), \ | |
466 | .visitor = SIDE_PTR_INIT(_visitor), \ | |
467 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
468 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
469 | } | |
470 | ||
471 | #define side_define_vla_visitor(_identifier, _elem_type, _length_type, _visitor, _attr...) \ | |
472 | const struct side_type_struct _identifier = _side_type_struct_define(SIDE_PARAM(_elem_type), SIDE_PARAM(_length_type), SIDE_PARAM(_visitor), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
473 | ||
474 | #define side_vla_visitor_literal(_elem_type, _length_type, _visitor, _attr...) \ | |
475 | SIDE_COMPOUND_LITERAL(const struct side_type_vla_visitor, \ | |
476 | _side_type_vla_visitor_define(SIDE_PARAM(_elem_type), SIDE_PARAM(_length_type), SIDE_PARAM(_visitor), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
477 | ||
478 | #define side_type_vla_visitor(_vla_visitor) \ | |
57553dfd MD |
479 | { \ |
480 | .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA_VISITOR), \ | |
481 | .u = { \ | |
f0619c77 | 482 | .side_vla_visitor = SIDE_PTR_INIT(_vla_visitor), \ |
57553dfd MD |
483 | }, \ |
484 | } | |
f0619c77 MD |
485 | #define side_field_vla_visitor(_name, _vla_visitor) \ |
486 | _side_field(_name, side_type_vla_visitor(SIDE_PARAM(_vla_visitor))) | |
57553dfd MD |
487 | |
488 | /* Gather field and type definitions */ | |
489 | ||
490 | #define side_type_gather_byte(_offset, _access_mode, _attr...) \ | |
491 | { \ | |
492 | .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BYTE), \ | |
493 | .u = { \ | |
494 | .side_gather = { \ | |
495 | .u = { \ | |
496 | .side_byte = { \ | |
497 | .offset = _offset, \ | |
f0619c77 | 498 | .access_mode = SIDE_ENUM_INIT(_access_mode), \ |
57553dfd MD |
499 | .type = { \ |
500 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
501 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
502 | }, \ | |
503 | }, \ | |
504 | }, \ | |
505 | }, \ | |
506 | }, \ | |
507 | } | |
508 | #define side_field_gather_byte(_name, _offset, _access_mode, _attr...) \ | |
509 | _side_field(_name, side_type_gather_byte(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
510 | ||
511 | #define _side_type_gather_bool(_byte_order, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
512 | { \ | |
513 | .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BOOL), \ | |
514 | .u = { \ | |
515 | .side_gather = { \ | |
516 | .u = { \ | |
517 | .side_bool = { \ | |
518 | .offset = _offset, \ | |
f0619c77 | 519 | .access_mode = SIDE_ENUM_INIT(_access_mode), \ |
57553dfd MD |
520 | .type = { \ |
521 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
522 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
523 | .bool_size = _bool_size, \ | |
524 | .len_bits = _len_bits, \ | |
525 | .byte_order = SIDE_ENUM_INIT(_byte_order), \ | |
526 | }, \ | |
527 | .offset_bits = _offset_bits, \ | |
528 | }, \ | |
529 | }, \ | |
530 | }, \ | |
531 | }, \ | |
532 | } | |
533 | #define side_type_gather_bool(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
534 | _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())) | |
535 | #define side_type_gather_bool_le(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
536 | _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())) | |
537 | #define side_type_gather_bool_be(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
538 | _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())) | |
539 | ||
540 | #define side_field_gather_bool(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
541 | _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())))) | |
542 | #define side_field_gather_bool_le(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
543 | _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())))) | |
544 | #define side_field_gather_bool_be(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
545 | _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())))) | |
546 | ||
547 | #define _side_type_gather_integer(_type, _signedness, _byte_order, _offset, \ | |
548 | _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
549 | { \ | |
550 | .type = SIDE_ENUM_INIT(_type), \ | |
551 | .u = { \ | |
552 | .side_gather = { \ | |
553 | .u = { \ | |
554 | .side_integer = { \ | |
555 | .offset = _offset, \ | |
f0619c77 | 556 | .access_mode = SIDE_ENUM_INIT(_access_mode), \ |
57553dfd MD |
557 | .type = { \ |
558 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
559 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
560 | .integer_size = _integer_size, \ | |
561 | .len_bits = _len_bits, \ | |
562 | .signedness = _signedness, \ | |
563 | .byte_order = SIDE_ENUM_INIT(_byte_order), \ | |
564 | }, \ | |
565 | .offset_bits = _offset_bits, \ | |
566 | }, \ | |
567 | }, \ | |
568 | }, \ | |
569 | }, \ | |
570 | } | |
571 | ||
572 | #define side_type_gather_unsigned_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
573 | _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_HOST, \ | |
574 | _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
575 | #define side_type_gather_signed_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
576 | _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_HOST, \ | |
577 | _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
578 | ||
579 | #define side_type_gather_unsigned_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
580 | _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_LE, \ | |
581 | _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
582 | #define side_type_gather_signed_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
583 | _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_LE, \ | |
584 | _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
585 | ||
586 | #define side_type_gather_unsigned_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
587 | _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_BE, \ | |
588 | _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
589 | #define side_type_gather_signed_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
590 | _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_BE, \ | |
591 | _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
592 | ||
593 | #define side_field_gather_unsigned_integer(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
594 | _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()))) | |
595 | #define side_field_gather_signed_integer(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
596 | _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()))) | |
597 | ||
598 | #define side_field_gather_unsigned_integer_le(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
599 | _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()))) | |
600 | #define side_field_gather_signed_integer_le(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
601 | _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()))) | |
602 | ||
603 | #define side_field_gather_unsigned_integer_be(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
604 | _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()))) | |
605 | #define side_field_gather_signed_integer_be(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ | |
606 | _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()))) | |
607 | ||
608 | #define side_type_gather_pointer(_offset, _access_mode, _attr...) \ | |
609 | _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_HOST, \ | |
610 | _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
611 | #define side_field_gather_pointer(_name, _offset, _access_mode, _attr...) \ | |
612 | _side_field(_name, side_type_gather_pointer(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
613 | ||
614 | #define side_type_gather_pointer_le(_offset, _access_mode, _attr...) \ | |
615 | _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_LE, \ | |
616 | _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
617 | #define side_field_gather_pointer_le(_name, _offset, _access_mode, _attr...) \ | |
618 | _side_field(_name, side_type_gather_pointer_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
619 | ||
620 | #define side_type_gather_pointer_be(_offset, _access_mode, _attr...) \ | |
621 | _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_BE, \ | |
622 | _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
623 | #define side_field_gather_pointer_be(_name, _offset, _access_mode, _attr...) \ | |
624 | _side_field(_name, side_type_gather_pointer_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
625 | ||
626 | #define _side_type_gather_float(_byte_order, _offset, _float_size, _access_mode, _attr...) \ | |
627 | { \ | |
628 | .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_FLOAT), \ | |
629 | .u = { \ | |
630 | .side_gather = { \ | |
631 | .u = { \ | |
632 | .side_float = { \ | |
633 | .offset = _offset, \ | |
f0619c77 | 634 | .access_mode = SIDE_ENUM_INIT(_access_mode), \ |
57553dfd MD |
635 | .type = { \ |
636 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
637 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
638 | .float_size = _float_size, \ | |
639 | .byte_order = SIDE_ENUM_INIT(_byte_order), \ | |
640 | }, \ | |
641 | }, \ | |
642 | }, \ | |
643 | }, \ | |
644 | }, \ | |
645 | } | |
646 | ||
647 | #define side_type_gather_float(_offset, _float_size, _access_mode, _attr...) \ | |
648 | _side_type_gather_float(SIDE_TYPE_FLOAT_WORD_ORDER_HOST, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
649 | #define side_type_gather_float_le(_offset, _float_size, _access_mode, _attr...) \ | |
650 | _side_type_gather_float(SIDE_TYPE_BYTE_ORDER_LE, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
651 | #define side_type_gather_float_be(_offset, _float_size, _access_mode, _attr...) \ | |
652 | _side_type_gather_float(SIDE_TYPE_BYTE_ORDER_BE, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
653 | ||
654 | #define side_field_gather_float(_name, _offset, _float_size, _access_mode, _attr...) \ | |
655 | _side_field(_name, side_type_gather_float(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
656 | #define side_field_gather_float_le(_name, _offset, _float_size, _access_mode, _attr...) \ | |
657 | _side_field(_name, side_type_gather_float_le(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
658 | #define side_field_gather_float_be(_name, _offset, _float_size, _access_mode, _attr...) \ | |
659 | _side_field(_name, side_type_gather_float_be(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
660 | ||
661 | #define _side_type_gather_string(_offset, _byte_order, _unit_size, _access_mode, _attr...) \ | |
662 | { \ | |
663 | .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRING), \ | |
664 | .u = { \ | |
665 | .side_gather = { \ | |
666 | .u = { \ | |
667 | .side_string = { \ | |
668 | .offset = _offset, \ | |
f0619c77 | 669 | .access_mode = SIDE_ENUM_INIT(_access_mode), \ |
57553dfd MD |
670 | .type = { \ |
671 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
672 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
673 | .unit_size = _unit_size, \ | |
674 | .byte_order = SIDE_ENUM_INIT(_byte_order), \ | |
675 | }, \ | |
676 | }, \ | |
677 | }, \ | |
678 | }, \ | |
679 | }, \ | |
680 | } | |
681 | #define side_type_gather_string(_offset, _access_mode, _attr...) \ | |
682 | _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
683 | #define side_field_gather_string(_name, _offset, _access_mode, _attr...) \ | |
684 | _side_field(_name, side_type_gather_string(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
685 | ||
686 | #define side_type_gather_string16(_offset, _access_mode, _attr...) \ | |
687 | _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
688 | #define side_type_gather_string16_le(_offset, _access_mode, _attr...) \ | |
689 | _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
690 | #define side_type_gather_string16_be(_offset, _access_mode, _attr...) \ | |
691 | _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
692 | ||
693 | #define side_field_gather_string16(_name, _offset, _access_mode, _attr...) \ | |
694 | _side_field(_name, side_type_gather_string16(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
695 | #define side_field_gather_string16_le(_name, _offset, _access_mode, _attr...) \ | |
696 | _side_field(_name, side_type_gather_string16_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
697 | #define side_field_gather_string16_be(_name, _offset, _access_mode, _attr...) \ | |
698 | _side_field(_name, side_type_gather_string16_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
699 | ||
700 | #define side_type_gather_string32(_offset, _access_mode, _attr...) \ | |
701 | _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
702 | #define side_type_gather_string32_le(_offset, _access_mode, _attr...) \ | |
703 | _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
704 | #define side_type_gather_string32_be(_offset, _access_mode, _attr...) \ | |
705 | _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
706 | ||
707 | #define side_field_gather_string32(_name, _offset, _access_mode, _attr...) \ | |
708 | _side_field(_name, side_type_gather_string32(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
709 | #define side_field_gather_string32_le(_name, _offset, _access_mode, _attr...) \ | |
710 | _side_field(_name, side_type_gather_string32_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
711 | #define side_field_gather_string32_be(_name, _offset, _access_mode, _attr...) \ | |
712 | _side_field(_name, side_type_gather_string32_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
713 | ||
714 | #define side_type_gather_enum(_mappings, _elem_type) \ | |
715 | { \ | |
716 | .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_ENUM), \ | |
717 | .u = { \ | |
718 | .side_enum = { \ | |
719 | .mappings = SIDE_PTR_INIT(_mappings), \ | |
720 | .elem_type = SIDE_PTR_INIT(_elem_type), \ | |
721 | }, \ | |
722 | }, \ | |
723 | } | |
724 | #define side_field_gather_enum(_name, _mappings, _elem_type) \ | |
725 | _side_field(_name, side_type_gather_enum(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type))) | |
726 | ||
727 | #define side_type_gather_struct(_struct_gather, _offset, _size, _access_mode) \ | |
728 | { \ | |
729 | .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRUCT), \ | |
730 | .u = { \ | |
731 | .side_gather = { \ | |
732 | .u = { \ | |
733 | .side_struct = { \ | |
734 | .offset = _offset, \ | |
f0619c77 | 735 | .access_mode = SIDE_ENUM_INIT(_access_mode), \ |
57553dfd MD |
736 | .type = SIDE_PTR_INIT(_struct_gather), \ |
737 | .size = _size, \ | |
738 | }, \ | |
739 | }, \ | |
740 | }, \ | |
741 | }, \ | |
742 | } | |
743 | #define side_field_gather_struct(_name, _struct_gather, _offset, _size, _access_mode) \ | |
744 | _side_field(_name, side_type_gather_struct(SIDE_PARAM(_struct_gather), _offset, _size, _access_mode)) | |
745 | ||
746 | #define side_type_gather_array(_elem_type_gather, _length, _offset, _access_mode, _attr...) \ | |
747 | { \ | |
748 | .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_ARRAY), \ | |
749 | .u = { \ | |
750 | .side_gather = { \ | |
751 | .u = { \ | |
752 | .side_array = { \ | |
753 | .offset = _offset, \ | |
f0619c77 | 754 | .access_mode = SIDE_ENUM_INIT(_access_mode), \ |
57553dfd MD |
755 | .type = { \ |
756 | .elem_type = SIDE_PTR_INIT(_elem_type_gather), \ | |
757 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
758 | .length = _length, \ | |
759 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
760 | }, \ | |
761 | }, \ | |
762 | }, \ | |
763 | }, \ | |
764 | }, \ | |
765 | } | |
766 | #define side_field_gather_array(_name, _elem_type, _length, _offset, _access_mode, _attr...) \ | |
767 | _side_field(_name, side_type_gather_array(SIDE_PARAM(_elem_type), _length, _offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) | |
768 | ||
769 | #define side_type_gather_vla(_elem_type_gather, _offset, _access_mode, _length_type_gather, _attr...) \ | |
770 | { \ | |
771 | .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_VLA), \ | |
772 | .u = { \ | |
773 | .side_gather = { \ | |
774 | .u = { \ | |
775 | .side_vla = { \ | |
57553dfd | 776 | .offset = _offset, \ |
f0619c77 | 777 | .access_mode = SIDE_ENUM_INIT(_access_mode), \ |
57553dfd MD |
778 | .type = { \ |
779 | .elem_type = SIDE_PTR_INIT(_elem_type_gather), \ | |
f0619c77 | 780 | .length_type = SIDE_PTR_INIT(_length_type_gather), \ |
57553dfd MD |
781 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ |
782 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
783 | }, \ | |
784 | }, \ | |
785 | }, \ | |
786 | }, \ | |
787 | }, \ | |
788 | } | |
789 | #define side_field_gather_vla(_name, _elem_type_gather, _offset, _access_mode, _length_type_gather, _attr...) \ | |
790 | _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()))) | |
791 | ||
792 | #define side_elem(...) \ | |
793 | SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__) | |
794 | ||
795 | #define side_length(...) \ | |
796 | SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__) | |
797 | ||
798 | #define side_field_list(...) \ | |
799 | SIDE_COMPOUND_LITERAL(const struct side_event_field, __VA_ARGS__) | |
800 | ||
801 | #define side_option_list(...) \ | |
802 | SIDE_COMPOUND_LITERAL(const struct side_variant_option, __VA_ARGS__) | |
803 | ||
804 | /* Stack-copy field arguments */ | |
805 | ||
66d7c96a MD |
806 | #define side_arg_null(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_NULL), .flags = 0, } |
807 | #define side_arg_bool(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_BOOL), .flags = 0, .u = { .side_static = { .bool_value = { .side_bool8 = !!(_val) } } } } | |
808 | #define side_arg_byte(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_BYTE), .flags = 0, .u = { .side_static = { .byte_value = (_val) } } } | |
809 | #define side_arg_string(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF8), .flags = 0, .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } } | |
810 | #define side_arg_string16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF16), .flags = 0, .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } } | |
811 | #define side_arg_string32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF32), .flags = 0, .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } } | |
812 | ||
813 | #define side_arg_u8(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U8), .flags = 0, .u = { .side_static = { .integer_value = { .side_u8 = (_val) } } } } | |
814 | #define side_arg_u16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U16), .flags = 0, .u = { .side_static = { .integer_value = { .side_u16 = (_val) } } } } | |
815 | #define side_arg_u32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U32), .flags = 0, .u = { .side_static = { .integer_value = { .side_u32 = (_val) } } } } | |
816 | #define side_arg_u64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U64), .flags = 0, .u = { .side_static = { .integer_value = { .side_u64 = (_val) } } } } | |
b1d9577a | 817 | #define side_arg_u128(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U128), .flags = 0, .u = { .side_static = { .integer_value = { .side_u128 = (_val) } } } } |
66d7c96a MD |
818 | #define side_arg_s8(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S8), .flags = 0, .u = { .side_static = { .integer_value = { .side_s8 = (_val) } } } } |
819 | #define side_arg_s16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S16), .flags = 0, .u = { .side_static = { .integer_value = { .side_s16 = (_val) } } } } | |
820 | #define side_arg_s32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S32), .flags = 0, .u = { .side_static = { .integer_value = { .side_s32 = (_val) } } } } | |
821 | #define side_arg_s64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S64), .flags = 0, .u = { .side_static = { .integer_value = { .side_s64 = (_val) } } } } | |
b1d9577a | 822 | #define side_arg_s128(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S128), .flags = 0, .u = { .side_static = { .integer_value = { .side_s128 = (_val) } } } } |
66d7c96a MD |
823 | #define side_arg_pointer(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_POINTER), .flags = 0, .u = { .side_static = { .integer_value = { .side_uptr = (uintptr_t) (_val) } } } } |
824 | #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) } } } } | |
825 | #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) } } } } | |
826 | #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) } } } } | |
827 | #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) } } } } | |
828 | ||
829 | #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) } } } | |
57553dfd MD |
830 | |
831 | #define side_arg_define_variant(_identifier, _selector_val, _option) \ | |
e14987e0 | 832 | const struct side_arg_variant _identifier = { \ |
57553dfd MD |
833 | .selector = _selector_val, \ |
834 | .option = _option, \ | |
835 | } | |
836 | #define side_arg_variant(_side_variant) \ | |
837 | { \ | |
838 | .type = SIDE_ENUM_INIT(SIDE_TYPE_VARIANT), \ | |
66d7c96a | 839 | .flags = 0, \ |
57553dfd MD |
840 | .u = { \ |
841 | .side_static = { \ | |
842 | .side_variant = SIDE_PTR_INIT(_side_variant), \ | |
843 | }, \ | |
844 | }, \ | |
845 | } | |
846 | ||
66d7c96a MD |
847 | #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) } } } |
848 | #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) } } } | |
c6af61dc MD |
849 | #define side_arg_vla_visitor(_side_vla_visitor) \ |
850 | { \ | |
851 | .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA_VISITOR), \ | |
852 | .flags = 0, \ | |
853 | .u = { \ | |
854 | .side_static = { \ | |
855 | .side_vla_visitor = SIDE_PTR_INIT(_side_vla_visitor), \ | |
856 | } \ | |
857 | } \ | |
858 | } | |
859 | ||
860 | #define side_arg_define_vla_visitor(_identifier, _ctx) \ | |
861 | struct side_arg_vla_visitor _identifier = { \ | |
862 | .app_ctx = SIDE_PTR_INIT(_ctx), \ | |
863 | .cached_arg = SIDE_PTR_INIT(NULL), \ | |
864 | } | |
57553dfd MD |
865 | |
866 | /* Gather field arguments */ | |
867 | ||
66d7c96a MD |
868 | #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) } } } |
869 | #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) } } } | |
870 | #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) } } } | |
871 | #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) } } } | |
872 | #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) } } } | |
873 | #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) } } } | |
874 | #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) } } } | |
875 | #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) } } } | |
876 | #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) } } } } | |
57553dfd MD |
877 | |
878 | /* Dynamic field arguments */ | |
879 | ||
880 | #define side_arg_dynamic_null(_attr...) \ | |
881 | { \ | |
882 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_NULL), \ | |
66d7c96a | 883 | .flags = 0, \ |
57553dfd MD |
884 | .u = { \ |
885 | .side_dynamic = { \ | |
886 | .side_null = { \ | |
887 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
888 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
889 | }, \ | |
890 | }, \ | |
891 | }, \ | |
892 | } | |
893 | ||
894 | #define side_arg_dynamic_bool(_val, _attr...) \ | |
895 | { \ | |
896 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_BOOL), \ | |
66d7c96a | 897 | .flags = 0, \ |
57553dfd MD |
898 | .u = { \ |
899 | .side_dynamic = { \ | |
900 | .side_bool = { \ | |
901 | .type = { \ | |
902 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
903 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
904 | .bool_size = sizeof(uint8_t), \ | |
905 | .len_bits = 0, \ | |
906 | .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \ | |
907 | }, \ | |
908 | .value = { \ | |
909 | .side_bool8 = !!(_val), \ | |
910 | }, \ | |
911 | }, \ | |
912 | }, \ | |
913 | }, \ | |
914 | } | |
915 | ||
916 | #define side_arg_dynamic_byte(_val, _attr...) \ | |
917 | { \ | |
918 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_BYTE), \ | |
66d7c96a | 919 | .flags = 0, \ |
57553dfd MD |
920 | .u = { \ |
921 | .side_dynamic = { \ | |
922 | .side_byte = { \ | |
923 | .type = { \ | |
924 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
925 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
926 | }, \ | |
927 | .value = (_val), \ | |
928 | }, \ | |
929 | }, \ | |
930 | }, \ | |
931 | } | |
932 | ||
933 | #define _side_arg_dynamic_string(_val, _byte_order, _unit_size, _attr...) \ | |
934 | { \ | |
935 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRING), \ | |
66d7c96a | 936 | .flags = 0, \ |
57553dfd MD |
937 | .u = { \ |
938 | .side_dynamic = { \ | |
939 | .side_string = { \ | |
940 | .type = { \ | |
941 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
942 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
943 | .unit_size = _unit_size, \ | |
944 | .byte_order = SIDE_ENUM_INIT(_byte_order), \ | |
945 | }, \ | |
946 | .value = (uintptr_t) (_val), \ | |
947 | }, \ | |
948 | }, \ | |
949 | }, \ | |
950 | } | |
951 | #define side_arg_dynamic_string(_val, _attr...) \ | |
952 | _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
953 | #define side_arg_dynamic_string16(_val, _attr...) \ | |
954 | _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
955 | #define side_arg_dynamic_string16_le(_val, _attr...) \ | |
956 | _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
957 | #define side_arg_dynamic_string16_be(_val, _attr...) \ | |
958 | _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
959 | #define side_arg_dynamic_string32(_val, _attr...) \ | |
960 | _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
961 | #define side_arg_dynamic_string32_le(_val, _attr...) \ | |
962 | _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
963 | #define side_arg_dynamic_string32_be(_val, _attr...) \ | |
964 | _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
965 | ||
966 | #define _side_arg_dynamic_integer(_field, _val, _type, _signedness, _byte_order, _integer_size, _len_bits, _attr...) \ | |
967 | { \ | |
968 | .type = SIDE_ENUM_INIT(_type), \ | |
66d7c96a | 969 | .flags = 0, \ |
57553dfd MD |
970 | .u = { \ |
971 | .side_dynamic = { \ | |
972 | .side_integer = { \ | |
973 | .type = { \ | |
974 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
975 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
976 | .integer_size = _integer_size, \ | |
977 | .len_bits = _len_bits, \ | |
978 | .signedness = _signedness, \ | |
979 | .byte_order = SIDE_ENUM_INIT(_byte_order), \ | |
980 | }, \ | |
981 | .value = { \ | |
982 | _field = (_val), \ | |
983 | }, \ | |
984 | }, \ | |
985 | }, \ | |
986 | }, \ | |
987 | } | |
988 | ||
989 | #define side_arg_dynamic_u8(_val, _attr...) \ | |
990 | _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())) | |
991 | #define side_arg_dynamic_s8(_val, _attr...) \ | |
992 | _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())) | |
993 | ||
994 | #define _side_arg_dynamic_u16(_val, _byte_order, _attr...) \ | |
995 | _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())) | |
996 | #define _side_arg_dynamic_u32(_val, _byte_order, _attr...) \ | |
997 | _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())) | |
998 | #define _side_arg_dynamic_u64(_val, _byte_order, _attr...) \ | |
999 | _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())) | |
b1d9577a MD |
1000 | #define _side_arg_dynamic_u128(_val, _byte_order, _attr...) \ |
1001 | _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())) | |
57553dfd MD |
1002 | |
1003 | #define _side_arg_dynamic_s16(_val, _byte_order, _attr...) \ | |
1004 | _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())) | |
1005 | #define _side_arg_dynamic_s32(_val, _byte_order, _attr...) \ | |
1006 | _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())) | |
1007 | #define _side_arg_dynamic_s64(_val, _byte_order, _attr...) \ | |
1008 | _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())) | |
b1d9577a MD |
1009 | #define _side_arg_dynamic_s128(_val, _byte_order, _attr...) \ |
1010 | _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())) | |
57553dfd MD |
1011 | |
1012 | #define _side_arg_dynamic_pointer(_val, _byte_order, _attr...) \ | |
1013 | _side_arg_dynamic_integer(.side_uptr, (uintptr_t) (_val), SIDE_TYPE_DYNAMIC_POINTER, false, _byte_order, \ | |
1014 | sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1015 | ||
1016 | #define _side_arg_dynamic_float(_field, _val, _type, _byte_order, _float_size, _attr...) \ | |
1017 | { \ | |
1018 | .type = SIDE_ENUM_INIT(_type), \ | |
66d7c96a | 1019 | .flags = 0, \ |
57553dfd MD |
1020 | .u = { \ |
1021 | .side_dynamic = { \ | |
1022 | .side_float = { \ | |
1023 | .type = { \ | |
1024 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1025 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1026 | .float_size = _float_size, \ | |
1027 | .byte_order = SIDE_ENUM_INIT(_byte_order), \ | |
1028 | }, \ | |
1029 | .value = { \ | |
1030 | _field = (_val), \ | |
1031 | }, \ | |
1032 | }, \ | |
1033 | }, \ | |
1034 | }, \ | |
1035 | } | |
1036 | ||
1037 | #define _side_arg_dynamic_float_binary16(_val, _byte_order, _attr...) \ | |
1038 | _side_arg_dynamic_float(.side_float_binary16, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1039 | #define _side_arg_dynamic_float_binary32(_val, _byte_order, _attr...) \ | |
1040 | _side_arg_dynamic_float(.side_float_binary32, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1041 | #define _side_arg_dynamic_float_binary64(_val, _byte_order, _attr...) \ | |
1042 | _side_arg_dynamic_float(.side_float_binary64, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1043 | #define _side_arg_dynamic_float_binary128(_val, _byte_order, _attr...) \ | |
1044 | _side_arg_dynamic_float(.side_float_binary128, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1045 | ||
1046 | /* Host endian */ | |
1047 | #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())) | |
1048 | #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())) | |
1049 | #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())) | |
b1d9577a | 1050 | #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())) |
57553dfd MD |
1051 | #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())) |
1052 | #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())) | |
1053 | #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())) | |
b1d9577a | 1054 | #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())) |
57553dfd MD |
1055 | #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())) |
1056 | #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())) | |
1057 | #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())) | |
1058 | #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())) | |
1059 | #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())) | |
1060 | ||
1061 | /* Little endian */ | |
1062 | #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())) | |
1063 | #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())) | |
1064 | #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())) | |
b1d9577a | 1065 | #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())) |
57553dfd MD |
1066 | #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())) |
1067 | #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())) | |
1068 | #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())) | |
b1d9577a | 1069 | #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())) |
57553dfd MD |
1070 | #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())) |
1071 | #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())) | |
1072 | #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())) | |
1073 | #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())) | |
1074 | #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())) | |
1075 | ||
1076 | /* Big endian */ | |
1077 | #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())) | |
1078 | #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())) | |
1079 | #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())) | |
b1d9577a | 1080 | #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())) |
57553dfd MD |
1081 | #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())) |
1082 | #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())) | |
1083 | #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())) | |
b1d9577a | 1084 | #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())) |
57553dfd MD |
1085 | #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())) |
1086 | #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())) | |
1087 | #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())) | |
1088 | #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())) | |
1089 | #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())) | |
1090 | ||
1091 | #define side_arg_dynamic_vla(_vla) \ | |
1092 | { \ | |
1093 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_VLA), \ | |
66d7c96a | 1094 | .flags = 0, \ |
57553dfd MD |
1095 | .u = { \ |
1096 | .side_dynamic = { \ | |
1097 | .side_dynamic_vla = SIDE_PTR_INIT(_vla), \ | |
1098 | }, \ | |
1099 | }, \ | |
1100 | } | |
1101 | ||
c6af61dc | 1102 | #define side_arg_dynamic_vla_visitor(_dynamic_vla_visitor) \ |
57553dfd MD |
1103 | { \ |
1104 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_VLA_VISITOR), \ | |
66d7c96a | 1105 | .flags = 0, \ |
57553dfd MD |
1106 | .u = { \ |
1107 | .side_dynamic = { \ | |
c6af61dc | 1108 | .side_dynamic_vla_visitor = SIDE_PTR_INIT(_dynamic_vla_visitor), \ |
57553dfd MD |
1109 | }, \ |
1110 | }, \ | |
1111 | } | |
1112 | ||
1113 | #define side_arg_dynamic_struct(_struct) \ | |
1114 | { \ | |
1115 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRUCT), \ | |
66d7c96a | 1116 | .flags = 0, \ |
57553dfd MD |
1117 | .u = { \ |
1118 | .side_dynamic = { \ | |
1119 | .side_dynamic_struct = SIDE_PTR_INIT(_struct), \ | |
1120 | }, \ | |
1121 | }, \ | |
1122 | } | |
1123 | ||
c6af61dc | 1124 | #define side_arg_dynamic_struct_visitor(_dynamic_struct_visitor) \ |
57553dfd MD |
1125 | { \ |
1126 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRUCT_VISITOR), \ | |
66d7c96a | 1127 | .flags = 0, \ |
57553dfd MD |
1128 | .u = { \ |
1129 | .side_dynamic = { \ | |
c6af61dc | 1130 | .side_dynamic_struct_visitor = SIDE_PTR_INIT(_dynamic_struct_visitor), \ |
57553dfd MD |
1131 | }, \ |
1132 | }, \ | |
1133 | } | |
1134 | ||
1135 | #define side_arg_dynamic_define_vec(_identifier, _sav, _attr...) \ | |
e14987e0 | 1136 | const struct side_arg _identifier##_vec[] = { _sav }; \ |
57553dfd MD |
1137 | const struct side_arg_dynamic_vla _identifier = { \ |
1138 | .sav = SIDE_PTR_INIT(_identifier##_vec), \ | |
1139 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1140 | .len = SIDE_ARRAY_SIZE(_identifier##_vec), \ | |
1141 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1142 | } | |
1143 | ||
1144 | #define side_arg_dynamic_define_struct(_identifier, _struct_fields, _attr...) \ | |
e14987e0 | 1145 | const struct side_arg_dynamic_field _identifier##_fields[] = { _struct_fields }; \ |
57553dfd MD |
1146 | const struct side_arg_dynamic_struct _identifier = { \ |
1147 | .fields = SIDE_PTR_INIT(_identifier##_fields), \ | |
1148 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1149 | .len = SIDE_ARRAY_SIZE(_identifier##_fields), \ | |
1150 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1151 | } | |
1152 | ||
c6af61dc MD |
1153 | #define side_arg_dynamic_define_struct_visitor(_identifier, _dynamic_struct_visitor, _ctx, _attr...) \ |
1154 | struct side_arg_dynamic_struct_visitor _identifier = { \ | |
1155 | .visitor = SIDE_PTR_INIT(_dynamic_struct_visitor), \ | |
1156 | .app_ctx = SIDE_PTR_INIT(_ctx), \ | |
1157 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1158 | .cached_arg = SIDE_PTR_INIT(NULL), \ | |
1159 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1160 | } | |
1161 | ||
1162 | #define side_arg_dynamic_define_vla_visitor(_identifier, _dynamic_vla_visitor, _ctx, _attr...) \ | |
1163 | struct side_arg_dynamic_vla_visitor _identifier = { \ | |
1164 | .visitor = SIDE_PTR_INIT(_dynamic_vla_visitor), \ | |
1165 | .app_ctx = SIDE_PTR_INIT(_ctx), \ | |
1166 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1167 | .cached_arg = SIDE_PTR_INIT(NULL), \ | |
1168 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1169 | } | |
1170 | ||
57553dfd | 1171 | #define side_arg_define_vec(_identifier, _sav) \ |
e14987e0 | 1172 | const struct side_arg _identifier##_vec[] = { _sav }; \ |
57553dfd MD |
1173 | const struct side_arg_vec _identifier = { \ |
1174 | .sav = SIDE_PTR_INIT(_identifier##_vec), \ | |
1175 | .len = SIDE_ARRAY_SIZE(_identifier##_vec), \ | |
1176 | } | |
1177 | ||
1178 | #define side_arg_dynamic_field(_name, _elem) \ | |
1179 | { \ | |
1180 | .field_name = SIDE_PTR_INIT(_name), \ | |
1181 | .elem = _elem, \ | |
1182 | } | |
1183 | ||
1184 | /* | |
1185 | * Event instrumentation description registration, runtime enabled state | |
1186 | * check, and instrumentation invocation. | |
1187 | */ | |
1188 | ||
1189 | #define side_arg_list(...) __VA_ARGS__ | |
1190 | ||
1191 | #define side_event_cond(_identifier) \ | |
1192 | if (side_unlikely(__atomic_load_n(&side_event_state__##_identifier.enabled, \ | |
1193 | __ATOMIC_RELAXED))) | |
1194 | ||
f0b01832 | 1195 | #define _side_event_call(_call, _identifier, _sav) \ |
57553dfd | 1196 | { \ |
e14987e0 | 1197 | const struct side_arg side_sav[] = { _sav }; \ |
57553dfd MD |
1198 | const struct side_arg_vec side_arg_vec = { \ |
1199 | .sav = SIDE_PTR_INIT(side_sav), \ | |
1200 | .len = SIDE_ARRAY_SIZE(side_sav), \ | |
1201 | }; \ | |
f0b01832 | 1202 | _call(&(side_event_state__##_identifier).parent, &side_arg_vec); \ |
57553dfd MD |
1203 | } |
1204 | ||
f0b01832 MD |
1205 | #define side_event_call(_identifier, _sav) \ |
1206 | _side_event_call(side_call, _identifier, SIDE_PARAM(_sav)) | |
1207 | ||
57553dfd MD |
1208 | #define side_event(_identifier, _sav) \ |
1209 | side_event_cond(_identifier) \ | |
1210 | side_event_call(_identifier, SIDE_PARAM(_sav)) | |
1211 | ||
f0b01832 | 1212 | #define _side_event_call_variadic(_call, _identifier, _sav, _var_fields, _attr...) \ |
57553dfd | 1213 | { \ |
e14987e0 | 1214 | const struct side_arg side_sav[] = { _sav }; \ |
57553dfd MD |
1215 | const struct side_arg_vec side_arg_vec = { \ |
1216 | .sav = SIDE_PTR_INIT(side_sav), \ | |
1217 | .len = SIDE_ARRAY_SIZE(side_sav), \ | |
1218 | }; \ | |
e14987e0 | 1219 | const struct side_arg_dynamic_field side_fields[] = { _var_fields }; \ |
57553dfd MD |
1220 | const struct side_arg_dynamic_struct var_struct = { \ |
1221 | .fields = SIDE_PTR_INIT(side_fields), \ | |
f0b01832 | 1222 | .attr = SIDE_PTR_INIT(_attr), \ |
57553dfd | 1223 | .len = SIDE_ARRAY_SIZE(side_fields), \ |
f0b01832 | 1224 | .nr_attr = SIDE_ARRAY_SIZE(_attr), \ |
57553dfd | 1225 | }; \ |
f0b01832 | 1226 | _call(&(side_event_state__##_identifier.parent), &side_arg_vec, &var_struct); \ |
57553dfd MD |
1227 | } |
1228 | ||
f0b01832 MD |
1229 | #define side_event_call_variadic(_identifier, _sav, _var_fields, _attr...) \ |
1230 | _side_event_call_variadic(side_call_variadic, _identifier, SIDE_PARAM(_sav), SIDE_PARAM(_var_fields), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1231 | ||
57553dfd MD |
1232 | #define side_event_variadic(_identifier, _sav, _var, _attr...) \ |
1233 | side_event_cond(_identifier) \ | |
1234 | side_event_call_variadic(_identifier, SIDE_PARAM(_sav), SIDE_PARAM(_var), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1235 | ||
3da13b2c MD |
1236 | #define _side_statedump_event_call(_call, _identifier, _key, _sav) \ |
1237 | { \ | |
1238 | const struct side_arg side_sav[] = { _sav }; \ | |
1239 | const struct side_arg_vec side_arg_vec = { \ | |
1240 | .sav = SIDE_PTR_INIT(side_sav), \ | |
1241 | .len = SIDE_ARRAY_SIZE(side_sav), \ | |
1242 | }; \ | |
1243 | _call(&(side_event_state__##_identifier).parent, &side_arg_vec, _key); \ | |
1244 | } | |
1245 | ||
1246 | #define side_statedump_event_call(_identifier, _key, _sav) \ | |
1247 | _side_statedump_event_call(side_statedump_call, _identifier, _key, SIDE_PARAM(_sav)) | |
1248 | ||
1249 | #define _side_statedump_event_call_variadic(_call, _identifier, _key, _sav, _var_fields, _attr...) \ | |
1250 | { \ | |
1251 | const struct side_arg side_sav[] = { _sav }; \ | |
1252 | const struct side_arg_vec side_arg_vec = { \ | |
1253 | .sav = side_ptr_init(side_sav), \ | |
1254 | .len = side_array_size(side_sav), \ | |
1255 | }; \ | |
1256 | const struct side_arg_dynamic_field side_fields[] = { _var_fields }; \ | |
1257 | const struct side_arg_dynamic_struct var_struct = { \ | |
1258 | .fields = side_ptr_init(side_fields), \ | |
1259 | .attr = side_ptr_init(_attr), \ | |
1260 | .len = side_array_size(side_fields), \ | |
1261 | .nr_attr = side_array_size(_attr), \ | |
1262 | }; \ | |
1263 | _call(&(side_event_state__##_identifier.parent), &side_arg_vec, &var_struct, _key); \ | |
1264 | } | |
f0b01832 | 1265 | |
3da13b2c MD |
1266 | #define side_statedump_event_call_variadic(_identifier, _key, _sav, _var_fields, _attr...) \ |
1267 | _side_statedump_event_call_variadic(side_statedump_call_variadic, _identifier, _key, SIDE_PARAM(_sav), SIDE_PARAM(_var_fields), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
f0b01832 | 1268 | |
57553dfd MD |
1269 | #define _side_define_event(_linkage, _identifier, _provider, _event, _loglevel, _fields, _flags, _attr...) \ |
1270 | _linkage struct side_event_description __attribute__((section("side_event_description"))) \ | |
1271 | _identifier; \ | |
1272 | _linkage struct side_event_state_0 __attribute__((section("side_event_state"))) \ | |
1273 | side_event_state__##_identifier = { \ | |
49aea3ef | 1274 | .parent = { \ |
57553dfd MD |
1275 | .version = SIDE_EVENT_STATE_ABI_VERSION, \ |
1276 | }, \ | |
3cac1780 | 1277 | .nr_callbacks = 0, \ |
57553dfd | 1278 | .enabled = 0, \ |
867b4725 | 1279 | .callbacks = (const struct side_callback *) &side_empty_callback[0], \ |
7269a8a3 | 1280 | .desc = &(_identifier), \ |
57553dfd MD |
1281 | }; \ |
1282 | _linkage struct side_event_description __attribute__((section("side_event_description"))) \ | |
1283 | _identifier = { \ | |
1284 | .struct_size = offsetof(struct side_event_description, end), \ | |
1285 | .version = SIDE_EVENT_DESCRIPTION_ABI_VERSION, \ | |
49aea3ef | 1286 | .state = SIDE_PTR_INIT(&(side_event_state__##_identifier.parent)), \ |
57553dfd MD |
1287 | .provider_name = SIDE_PTR_INIT(_provider), \ |
1288 | .event_name = SIDE_PTR_INIT(_event), \ | |
1289 | .fields = SIDE_PTR_INIT(_fields), \ | |
1290 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1291 | .flags = (_flags), \ | |
1292 | .nr_side_type_label = _NR_SIDE_TYPE_LABEL, \ | |
1293 | .nr_side_attr_type = _NR_SIDE_ATTR_TYPE, \ | |
1294 | .loglevel = SIDE_ENUM_INIT(_loglevel), \ | |
1295 | .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \ | |
1296 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
57553dfd MD |
1297 | }; \ |
1298 | static const struct side_event_description *side_event_ptr__##_identifier \ | |
1299 | __attribute__((section("side_event_description_ptr"), used)) = &(_identifier); | |
1300 | ||
1301 | #define side_static_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ | |
1302 | _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \ | |
1303 | 0, ##_attr) | |
1304 | ||
1305 | #define side_static_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ | |
1306 | _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \ | |
1307 | SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1308 | ||
1309 | #define side_hidden_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ | |
1310 | _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \ | |
1311 | _loglevel, SIDE_PARAM(_fields), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1312 | ||
1313 | #define side_hidden_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ | |
1314 | _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \ | |
1315 | _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1316 | ||
1317 | #define side_export_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ | |
1318 | _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \ | |
1319 | _loglevel, SIDE_PARAM(_fields), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1320 | ||
1321 | #define side_export_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ | |
1322 | _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \ | |
1323 | _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1324 | ||
1325 | #define side_declare_event(_identifier) \ | |
1326 | extern struct side_event_state_0 side_event_state_##_identifier; \ | |
1327 | extern struct side_event_description _identifier | |
1328 | ||
1329 | #endif /* SIDE_INSTRUMENTATION_C_API_H */ |