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 | ||
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 | ||
66d7c96a MD |
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) } } } } | |
b1d9577a | 805 | #define side_arg_u128(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U128), .flags = 0, .u = { .side_static = { .integer_value = { .side_u128 = (_val) } } } } |
66d7c96a MD |
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) } } } } | |
b1d9577a | 810 | #define side_arg_s128(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S128), .flags = 0, .u = { .side_static = { .integer_value = { .side_s128 = (_val) } } } } |
66d7c96a MD |
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) } } } | |
57553dfd MD |
818 | |
819 | #define side_arg_define_variant(_identifier, _selector_val, _option) \ | |
e14987e0 | 820 | const struct side_arg_variant _identifier = { \ |
57553dfd MD |
821 | .selector = _selector_val, \ |
822 | .option = _option, \ | |
823 | } | |
824 | #define side_arg_variant(_side_variant) \ | |
825 | { \ | |
826 | .type = SIDE_ENUM_INIT(SIDE_TYPE_VARIANT), \ | |
66d7c96a | 827 | .flags = 0, \ |
57553dfd MD |
828 | .u = { \ |
829 | .side_static = { \ | |
830 | .side_variant = SIDE_PTR_INIT(_side_variant), \ | |
831 | }, \ | |
832 | }, \ | |
833 | } | |
834 | ||
66d7c96a MD |
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) } } } | |
c6af61dc MD |
837 | #define side_arg_vla_visitor(_side_vla_visitor) \ |
838 | { \ | |
839 | .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA_VISITOR), \ | |
840 | .flags = 0, \ | |
841 | .u = { \ | |
842 | .side_static = { \ | |
843 | .side_vla_visitor = SIDE_PTR_INIT(_side_vla_visitor), \ | |
844 | } \ | |
845 | } \ | |
846 | } | |
847 | ||
848 | #define side_arg_define_vla_visitor(_identifier, _ctx) \ | |
849 | struct side_arg_vla_visitor _identifier = { \ | |
850 | .app_ctx = SIDE_PTR_INIT(_ctx), \ | |
851 | .cached_arg = SIDE_PTR_INIT(NULL), \ | |
852 | } | |
57553dfd MD |
853 | |
854 | /* Gather field arguments */ | |
855 | ||
66d7c96a MD |
856 | #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) } } } |
857 | #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) } } } | |
858 | #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) } } } | |
859 | #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) } } } | |
860 | #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) } } } | |
861 | #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) } } } | |
862 | #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) } } } | |
863 | #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) } } } | |
864 | #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 |
865 | |
866 | /* Dynamic field arguments */ | |
867 | ||
868 | #define side_arg_dynamic_null(_attr...) \ | |
869 | { \ | |
870 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_NULL), \ | |
66d7c96a | 871 | .flags = 0, \ |
57553dfd MD |
872 | .u = { \ |
873 | .side_dynamic = { \ | |
874 | .side_null = { \ | |
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 | }, \ | |
878 | }, \ | |
879 | }, \ | |
880 | } | |
881 | ||
882 | #define side_arg_dynamic_bool(_val, _attr...) \ | |
883 | { \ | |
884 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_BOOL), \ | |
66d7c96a | 885 | .flags = 0, \ |
57553dfd MD |
886 | .u = { \ |
887 | .side_dynamic = { \ | |
888 | .side_bool = { \ | |
889 | .type = { \ | |
890 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
891 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
892 | .bool_size = sizeof(uint8_t), \ | |
893 | .len_bits = 0, \ | |
894 | .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \ | |
895 | }, \ | |
896 | .value = { \ | |
897 | .side_bool8 = !!(_val), \ | |
898 | }, \ | |
899 | }, \ | |
900 | }, \ | |
901 | }, \ | |
902 | } | |
903 | ||
904 | #define side_arg_dynamic_byte(_val, _attr...) \ | |
905 | { \ | |
906 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_BYTE), \ | |
66d7c96a | 907 | .flags = 0, \ |
57553dfd MD |
908 | .u = { \ |
909 | .side_dynamic = { \ | |
910 | .side_byte = { \ | |
911 | .type = { \ | |
912 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
913 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
914 | }, \ | |
915 | .value = (_val), \ | |
916 | }, \ | |
917 | }, \ | |
918 | }, \ | |
919 | } | |
920 | ||
921 | #define _side_arg_dynamic_string(_val, _byte_order, _unit_size, _attr...) \ | |
922 | { \ | |
923 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRING), \ | |
66d7c96a | 924 | .flags = 0, \ |
57553dfd MD |
925 | .u = { \ |
926 | .side_dynamic = { \ | |
927 | .side_string = { \ | |
928 | .type = { \ | |
929 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
930 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
931 | .unit_size = _unit_size, \ | |
932 | .byte_order = SIDE_ENUM_INIT(_byte_order), \ | |
933 | }, \ | |
934 | .value = (uintptr_t) (_val), \ | |
935 | }, \ | |
936 | }, \ | |
937 | }, \ | |
938 | } | |
939 | #define side_arg_dynamic_string(_val, _attr...) \ | |
940 | _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
941 | #define side_arg_dynamic_string16(_val, _attr...) \ | |
942 | _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
943 | #define side_arg_dynamic_string16_le(_val, _attr...) \ | |
944 | _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
945 | #define side_arg_dynamic_string16_be(_val, _attr...) \ | |
946 | _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
947 | #define side_arg_dynamic_string32(_val, _attr...) \ | |
948 | _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
949 | #define side_arg_dynamic_string32_le(_val, _attr...) \ | |
950 | _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
951 | #define side_arg_dynamic_string32_be(_val, _attr...) \ | |
952 | _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
953 | ||
954 | #define _side_arg_dynamic_integer(_field, _val, _type, _signedness, _byte_order, _integer_size, _len_bits, _attr...) \ | |
955 | { \ | |
956 | .type = SIDE_ENUM_INIT(_type), \ | |
66d7c96a | 957 | .flags = 0, \ |
57553dfd MD |
958 | .u = { \ |
959 | .side_dynamic = { \ | |
960 | .side_integer = { \ | |
961 | .type = { \ | |
962 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
963 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
964 | .integer_size = _integer_size, \ | |
965 | .len_bits = _len_bits, \ | |
966 | .signedness = _signedness, \ | |
967 | .byte_order = SIDE_ENUM_INIT(_byte_order), \ | |
968 | }, \ | |
969 | .value = { \ | |
970 | _field = (_val), \ | |
971 | }, \ | |
972 | }, \ | |
973 | }, \ | |
974 | }, \ | |
975 | } | |
976 | ||
977 | #define side_arg_dynamic_u8(_val, _attr...) \ | |
978 | _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())) | |
979 | #define side_arg_dynamic_s8(_val, _attr...) \ | |
980 | _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())) | |
981 | ||
982 | #define _side_arg_dynamic_u16(_val, _byte_order, _attr...) \ | |
983 | _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())) | |
984 | #define _side_arg_dynamic_u32(_val, _byte_order, _attr...) \ | |
985 | _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())) | |
986 | #define _side_arg_dynamic_u64(_val, _byte_order, _attr...) \ | |
987 | _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 |
988 | #define _side_arg_dynamic_u128(_val, _byte_order, _attr...) \ |
989 | _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 |
990 | |
991 | #define _side_arg_dynamic_s16(_val, _byte_order, _attr...) \ | |
992 | _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())) | |
993 | #define _side_arg_dynamic_s32(_val, _byte_order, _attr...) \ | |
994 | _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())) | |
995 | #define _side_arg_dynamic_s64(_val, _byte_order, _attr...) \ | |
996 | _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 |
997 | #define _side_arg_dynamic_s128(_val, _byte_order, _attr...) \ |
998 | _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 |
999 | |
1000 | #define _side_arg_dynamic_pointer(_val, _byte_order, _attr...) \ | |
1001 | _side_arg_dynamic_integer(.side_uptr, (uintptr_t) (_val), SIDE_TYPE_DYNAMIC_POINTER, false, _byte_order, \ | |
1002 | sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1003 | ||
1004 | #define _side_arg_dynamic_float(_field, _val, _type, _byte_order, _float_size, _attr...) \ | |
1005 | { \ | |
1006 | .type = SIDE_ENUM_INIT(_type), \ | |
66d7c96a | 1007 | .flags = 0, \ |
57553dfd MD |
1008 | .u = { \ |
1009 | .side_dynamic = { \ | |
1010 | .side_float = { \ | |
1011 | .type = { \ | |
1012 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1013 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1014 | .float_size = _float_size, \ | |
1015 | .byte_order = SIDE_ENUM_INIT(_byte_order), \ | |
1016 | }, \ | |
1017 | .value = { \ | |
1018 | _field = (_val), \ | |
1019 | }, \ | |
1020 | }, \ | |
1021 | }, \ | |
1022 | }, \ | |
1023 | } | |
1024 | ||
1025 | #define _side_arg_dynamic_float_binary16(_val, _byte_order, _attr...) \ | |
1026 | _side_arg_dynamic_float(.side_float_binary16, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1027 | #define _side_arg_dynamic_float_binary32(_val, _byte_order, _attr...) \ | |
1028 | _side_arg_dynamic_float(.side_float_binary32, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1029 | #define _side_arg_dynamic_float_binary64(_val, _byte_order, _attr...) \ | |
1030 | _side_arg_dynamic_float(.side_float_binary64, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1031 | #define _side_arg_dynamic_float_binary128(_val, _byte_order, _attr...) \ | |
1032 | _side_arg_dynamic_float(.side_float_binary128, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1033 | ||
1034 | /* Host endian */ | |
1035 | #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())) | |
1036 | #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())) | |
1037 | #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 | 1038 | #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 |
1039 | #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())) |
1040 | #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())) | |
1041 | #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 | 1042 | #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 |
1043 | #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())) |
1044 | #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())) | |
1045 | #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())) | |
1046 | #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())) | |
1047 | #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())) | |
1048 | ||
1049 | /* Little endian */ | |
1050 | #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())) | |
1051 | #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())) | |
1052 | #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 | 1053 | #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 |
1054 | #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())) |
1055 | #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())) | |
1056 | #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 | 1057 | #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 |
1058 | #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())) |
1059 | #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())) | |
1060 | #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())) | |
1061 | #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())) | |
1062 | #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())) | |
1063 | ||
1064 | /* Big endian */ | |
1065 | #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())) | |
1066 | #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())) | |
1067 | #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 | 1068 | #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 |
1069 | #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())) |
1070 | #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())) | |
1071 | #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 | 1072 | #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 |
1073 | #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())) |
1074 | #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())) | |
1075 | #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())) | |
1076 | #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())) | |
1077 | #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())) | |
1078 | ||
1079 | #define side_arg_dynamic_vla(_vla) \ | |
1080 | { \ | |
1081 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_VLA), \ | |
66d7c96a | 1082 | .flags = 0, \ |
57553dfd MD |
1083 | .u = { \ |
1084 | .side_dynamic = { \ | |
1085 | .side_dynamic_vla = SIDE_PTR_INIT(_vla), \ | |
1086 | }, \ | |
1087 | }, \ | |
1088 | } | |
1089 | ||
c6af61dc | 1090 | #define side_arg_dynamic_vla_visitor(_dynamic_vla_visitor) \ |
57553dfd MD |
1091 | { \ |
1092 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_VLA_VISITOR), \ | |
66d7c96a | 1093 | .flags = 0, \ |
57553dfd MD |
1094 | .u = { \ |
1095 | .side_dynamic = { \ | |
c6af61dc | 1096 | .side_dynamic_vla_visitor = SIDE_PTR_INIT(_dynamic_vla_visitor), \ |
57553dfd MD |
1097 | }, \ |
1098 | }, \ | |
1099 | } | |
1100 | ||
1101 | #define side_arg_dynamic_struct(_struct) \ | |
1102 | { \ | |
1103 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRUCT), \ | |
66d7c96a | 1104 | .flags = 0, \ |
57553dfd MD |
1105 | .u = { \ |
1106 | .side_dynamic = { \ | |
1107 | .side_dynamic_struct = SIDE_PTR_INIT(_struct), \ | |
1108 | }, \ | |
1109 | }, \ | |
1110 | } | |
1111 | ||
c6af61dc | 1112 | #define side_arg_dynamic_struct_visitor(_dynamic_struct_visitor) \ |
57553dfd MD |
1113 | { \ |
1114 | .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRUCT_VISITOR), \ | |
66d7c96a | 1115 | .flags = 0, \ |
57553dfd MD |
1116 | .u = { \ |
1117 | .side_dynamic = { \ | |
c6af61dc | 1118 | .side_dynamic_struct_visitor = SIDE_PTR_INIT(_dynamic_struct_visitor), \ |
57553dfd MD |
1119 | }, \ |
1120 | }, \ | |
1121 | } | |
1122 | ||
1123 | #define side_arg_dynamic_define_vec(_identifier, _sav, _attr...) \ | |
e14987e0 | 1124 | const struct side_arg _identifier##_vec[] = { _sav }; \ |
57553dfd MD |
1125 | const struct side_arg_dynamic_vla _identifier = { \ |
1126 | .sav = SIDE_PTR_INIT(_identifier##_vec), \ | |
1127 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1128 | .len = SIDE_ARRAY_SIZE(_identifier##_vec), \ | |
1129 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1130 | } | |
1131 | ||
1132 | #define side_arg_dynamic_define_struct(_identifier, _struct_fields, _attr...) \ | |
e14987e0 | 1133 | const struct side_arg_dynamic_field _identifier##_fields[] = { _struct_fields }; \ |
57553dfd MD |
1134 | const struct side_arg_dynamic_struct _identifier = { \ |
1135 | .fields = SIDE_PTR_INIT(_identifier##_fields), \ | |
1136 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1137 | .len = SIDE_ARRAY_SIZE(_identifier##_fields), \ | |
1138 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1139 | } | |
1140 | ||
c6af61dc MD |
1141 | #define side_arg_dynamic_define_struct_visitor(_identifier, _dynamic_struct_visitor, _ctx, _attr...) \ |
1142 | struct side_arg_dynamic_struct_visitor _identifier = { \ | |
1143 | .visitor = SIDE_PTR_INIT(_dynamic_struct_visitor), \ | |
1144 | .app_ctx = SIDE_PTR_INIT(_ctx), \ | |
1145 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1146 | .cached_arg = SIDE_PTR_INIT(NULL), \ | |
1147 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1148 | } | |
1149 | ||
1150 | #define side_arg_dynamic_define_vla_visitor(_identifier, _dynamic_vla_visitor, _ctx, _attr...) \ | |
1151 | struct side_arg_dynamic_vla_visitor _identifier = { \ | |
1152 | .visitor = SIDE_PTR_INIT(_dynamic_vla_visitor), \ | |
1153 | .app_ctx = SIDE_PTR_INIT(_ctx), \ | |
1154 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1155 | .cached_arg = SIDE_PTR_INIT(NULL), \ | |
1156 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1157 | } | |
1158 | ||
57553dfd | 1159 | #define side_arg_define_vec(_identifier, _sav) \ |
e14987e0 | 1160 | const struct side_arg _identifier##_vec[] = { _sav }; \ |
57553dfd MD |
1161 | const struct side_arg_vec _identifier = { \ |
1162 | .sav = SIDE_PTR_INIT(_identifier##_vec), \ | |
1163 | .len = SIDE_ARRAY_SIZE(_identifier##_vec), \ | |
1164 | } | |
1165 | ||
1166 | #define side_arg_dynamic_field(_name, _elem) \ | |
1167 | { \ | |
1168 | .field_name = SIDE_PTR_INIT(_name), \ | |
1169 | .elem = _elem, \ | |
1170 | } | |
1171 | ||
1172 | /* | |
1173 | * Event instrumentation description registration, runtime enabled state | |
1174 | * check, and instrumentation invocation. | |
1175 | */ | |
1176 | ||
1177 | #define side_arg_list(...) __VA_ARGS__ | |
1178 | ||
1179 | #define side_event_cond(_identifier) \ | |
1180 | if (side_unlikely(__atomic_load_n(&side_event_state__##_identifier.enabled, \ | |
1181 | __ATOMIC_RELAXED))) | |
1182 | ||
f0b01832 | 1183 | #define _side_event_call(_call, _identifier, _sav) \ |
57553dfd | 1184 | { \ |
e14987e0 | 1185 | const struct side_arg side_sav[] = { _sav }; \ |
57553dfd MD |
1186 | const struct side_arg_vec side_arg_vec = { \ |
1187 | .sav = SIDE_PTR_INIT(side_sav), \ | |
1188 | .len = SIDE_ARRAY_SIZE(side_sav), \ | |
1189 | }; \ | |
f0b01832 | 1190 | _call(&(side_event_state__##_identifier).parent, &side_arg_vec); \ |
57553dfd MD |
1191 | } |
1192 | ||
f0b01832 MD |
1193 | #define side_event_call(_identifier, _sav) \ |
1194 | _side_event_call(side_call, _identifier, SIDE_PARAM(_sav)) | |
1195 | ||
57553dfd MD |
1196 | #define side_event(_identifier, _sav) \ |
1197 | side_event_cond(_identifier) \ | |
1198 | side_event_call(_identifier, SIDE_PARAM(_sav)) | |
1199 | ||
f0b01832 | 1200 | #define _side_event_call_variadic(_call, _identifier, _sav, _var_fields, _attr...) \ |
57553dfd | 1201 | { \ |
e14987e0 | 1202 | const struct side_arg side_sav[] = { _sav }; \ |
57553dfd MD |
1203 | const struct side_arg_vec side_arg_vec = { \ |
1204 | .sav = SIDE_PTR_INIT(side_sav), \ | |
1205 | .len = SIDE_ARRAY_SIZE(side_sav), \ | |
1206 | }; \ | |
e14987e0 | 1207 | const struct side_arg_dynamic_field side_fields[] = { _var_fields }; \ |
57553dfd MD |
1208 | const struct side_arg_dynamic_struct var_struct = { \ |
1209 | .fields = SIDE_PTR_INIT(side_fields), \ | |
f0b01832 | 1210 | .attr = SIDE_PTR_INIT(_attr), \ |
57553dfd | 1211 | .len = SIDE_ARRAY_SIZE(side_fields), \ |
f0b01832 | 1212 | .nr_attr = SIDE_ARRAY_SIZE(_attr), \ |
57553dfd | 1213 | }; \ |
f0b01832 | 1214 | _call(&(side_event_state__##_identifier.parent), &side_arg_vec, &var_struct); \ |
57553dfd MD |
1215 | } |
1216 | ||
f0b01832 MD |
1217 | #define side_event_call_variadic(_identifier, _sav, _var_fields, _attr...) \ |
1218 | _side_event_call_variadic(side_call_variadic, _identifier, SIDE_PARAM(_sav), SIDE_PARAM(_var_fields), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1219 | ||
57553dfd MD |
1220 | #define side_event_variadic(_identifier, _sav, _var, _attr...) \ |
1221 | side_event_cond(_identifier) \ | |
1222 | side_event_call_variadic(_identifier, SIDE_PARAM(_sav), SIDE_PARAM(_var), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1223 | ||
f0b01832 MD |
1224 | #define side_statedump_event_call(_identifier, _sav) \ |
1225 | _side_event_call(side_statedump_call, _identifier, SIDE_PARAM(_sav)) | |
1226 | ||
1227 | #define side_statedump_event_call_variadic(_identifier, _sav, _var_fields, _attr...) \ | |
1228 | _side_event_call_variadic(side_statedump_call_variadic, _identifier, SIDE_PARAM(_sav), SIDE_PARAM(_var_fields), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1229 | ||
57553dfd MD |
1230 | #define _side_define_event(_linkage, _identifier, _provider, _event, _loglevel, _fields, _flags, _attr...) \ |
1231 | _linkage struct side_event_description __attribute__((section("side_event_description"))) \ | |
1232 | _identifier; \ | |
1233 | _linkage struct side_event_state_0 __attribute__((section("side_event_state"))) \ | |
1234 | side_event_state__##_identifier = { \ | |
49aea3ef | 1235 | .parent = { \ |
57553dfd MD |
1236 | .version = SIDE_EVENT_STATE_ABI_VERSION, \ |
1237 | }, \ | |
3cac1780 | 1238 | .nr_callbacks = 0, \ |
57553dfd | 1239 | .enabled = 0, \ |
867b4725 | 1240 | .callbacks = (const struct side_callback *) &side_empty_callback[0], \ |
7269a8a3 | 1241 | .desc = &(_identifier), \ |
57553dfd MD |
1242 | }; \ |
1243 | _linkage struct side_event_description __attribute__((section("side_event_description"))) \ | |
1244 | _identifier = { \ | |
1245 | .struct_size = offsetof(struct side_event_description, end), \ | |
1246 | .version = SIDE_EVENT_DESCRIPTION_ABI_VERSION, \ | |
49aea3ef | 1247 | .state = SIDE_PTR_INIT(&(side_event_state__##_identifier.parent)), \ |
57553dfd MD |
1248 | .provider_name = SIDE_PTR_INIT(_provider), \ |
1249 | .event_name = SIDE_PTR_INIT(_event), \ | |
1250 | .fields = SIDE_PTR_INIT(_fields), \ | |
1251 | .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
1252 | .flags = (_flags), \ | |
1253 | .nr_side_type_label = _NR_SIDE_TYPE_LABEL, \ | |
1254 | .nr_side_attr_type = _NR_SIDE_ATTR_TYPE, \ | |
1255 | .loglevel = SIDE_ENUM_INIT(_loglevel), \ | |
1256 | .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \ | |
1257 | .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ | |
57553dfd MD |
1258 | }; \ |
1259 | static const struct side_event_description *side_event_ptr__##_identifier \ | |
1260 | __attribute__((section("side_event_description_ptr"), used)) = &(_identifier); | |
1261 | ||
1262 | #define side_static_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ | |
1263 | _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \ | |
1264 | 0, ##_attr) | |
1265 | ||
1266 | #define side_static_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ | |
1267 | _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \ | |
1268 | SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1269 | ||
1270 | #define side_hidden_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ | |
1271 | _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \ | |
1272 | _loglevel, SIDE_PARAM(_fields), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1273 | ||
1274 | #define side_hidden_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ | |
1275 | _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \ | |
1276 | _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1277 | ||
1278 | #define side_export_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ | |
1279 | _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \ | |
1280 | _loglevel, SIDE_PARAM(_fields), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1281 | ||
1282 | #define side_export_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ | |
1283 | _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \ | |
1284 | _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) | |
1285 | ||
1286 | #define side_declare_event(_identifier) \ | |
1287 | extern struct side_event_state_0 side_event_state_##_identifier; \ | |
1288 | extern struct side_event_description _identifier | |
1289 | ||
1290 | #endif /* SIDE_INSTRUMENTATION_C_API_H */ |