Commit | Line | Data |
---|---|---|
d98421f2 PP |
1 | /* |
2 | * SPDX-License-Identifier: MIT | |
3 | * | |
4 | * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation | |
5 | * Copyright (c) 2018-2020 Philippe Proulx <pproulx@efficios.com> | |
6 | */ | |
7 | ||
8 | #ifndef BABELTRACE_ASSERT_COND_INTERNAL_H | |
9 | #define BABELTRACE_ASSERT_COND_INTERNAL_H | |
10 | ||
2bdc32f7 | 11 | #include "assert-cond-base.h" |
d98421f2 PP |
12 | |
13 | /* | |
14 | * Asserts that a given variable `_obj` named `_obj_name` (capitalized) | |
1778c2a4 PP |
15 | * and having the ID `_obj_id` (within the function's context) is not |
16 | * `NULL`. | |
d98421f2 | 17 | */ |
1778c2a4 PP |
18 | #define BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _obj_id, _obj, _obj_name) \ |
19 | BT_ASSERT_PRE_FROM_FUNC(_func, "not-null:" _obj_id, (_obj), \ | |
20 | "%s is NULL: ", _obj_name) | |
21 | ||
22 | #define BT_ASSERT_PRE_NON_NULL(_obj_id, _obj, _obj_name) \ | |
23 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(__func__, _obj_id, (_obj), _obj_name) | |
d98421f2 PP |
24 | |
25 | /* | |
26 | * Asserts that a given index `_index` is less than a given length | |
27 | * `_length`. | |
28 | */ | |
1778c2a4 PP |
29 | #define BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(_func, _index, _length) \ |
30 | BT_ASSERT_PRE_FROM_FUNC(_func, "valid-index", (_index) < (_length), \ | |
d98421f2 PP |
31 | "Index is out of bounds: index=%" PRIu64 ", " \ |
32 | "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_length)) | |
33 | ||
1778c2a4 PP |
34 | #define BT_ASSERT_PRE_VALID_INDEX(_index, _length) \ |
35 | BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(__func__, (_index), (_length)) | |
36 | ||
d98421f2 PP |
37 | /* |
38 | * Asserts that the current thread has no error set. | |
39 | */ | |
1778c2a4 PP |
40 | #define BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(_func) \ |
41 | do { \ | |
42 | const struct bt_error *err = bt_current_thread_take_error(); \ | |
43 | if (err) { \ | |
44 | bt_current_thread_move_error(err); \ | |
45 | } \ | |
46 | BT_ASSERT_PRE_FROM_FUNC(_func, "no-error", !err, \ | |
47 | "API function called while current thread has an " \ | |
48 | "error: function=%s", _func); \ | |
d98421f2 PP |
49 | } while (0) |
50 | ||
1778c2a4 PP |
51 | #define BT_ASSERT_PRE_NO_ERROR() \ |
52 | BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(__func__) | |
53 | ||
d98421f2 PP |
54 | /* |
55 | * Asserts that, if the current thread has an error, `_status` is an | |
56 | * error status code. | |
57 | * | |
1778c2a4 PP |
58 | * See _BT_ASSERT_COND() for details about the `_func` parameter. |
59 | * | |
d98421f2 PP |
60 | * Puts back the error in place (if there is one) such that if this |
61 | * macro aborts, it will be possible to inspect it with a debugger. | |
62 | */ | |
1778c2a4 | 63 | #define BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \ |
d98421f2 | 64 | do { \ |
1778c2a4 PP |
65 | const struct bt_error *_err = bt_current_thread_take_error(); \ |
66 | if (_err) { \ | |
67 | bt_current_thread_move_error(_err); \ | |
d98421f2 | 68 | } \ |
1778c2a4 PP |
69 | BT_ASSERT_POST(_func, "no-error-if-no-error-status", \ |
70 | (_status) < 0 || !_err, \ | |
d98421f2 PP |
71 | "Current thread has an error, but user function " \ |
72 | "returned a non-error status: status=%s", \ | |
73 | bt_common_func_status_string(_status)); \ | |
74 | } while (0) | |
75 | ||
76 | /* | |
77 | * Asserts that the current thread has no error. | |
1778c2a4 PP |
78 | * |
79 | * See _BT_ASSERT_COND() for details about the `_func` parameter. | |
d98421f2 | 80 | */ |
1778c2a4 PP |
81 | #define BT_ASSERT_POST_NO_ERROR(_func) \ |
82 | do { \ | |
83 | const struct bt_error *_err = bt_current_thread_take_error(); \ | |
84 | if (_err) { \ | |
85 | bt_current_thread_move_error(_err); \ | |
86 | } \ | |
87 | BT_ASSERT_POST(_func, "no-error", !_err, \ | |
88 | "Current thread has an error"); \ | |
89 | } while (0) | |
d98421f2 PP |
90 | |
91 | #ifdef BT_DEV_MODE | |
1778c2a4 PP |
92 | /* Developer mode version of BT_ASSERT_PRE_NON_NULL_FROM_FUNC() */ |
93 | # define BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, _obj_id, _obj, _obj_name) \ | |
94 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _obj_id, (_obj), (_obj_name)) | |
95 | ||
d98421f2 | 96 | /* Developer mode version of BT_ASSERT_PRE_NON_NULL() */ |
1778c2a4 PP |
97 | # define BT_ASSERT_PRE_DEV_NON_NULL(_obj_id, _obj, _obj_name) \ |
98 | BT_ASSERT_PRE_NON_NULL(_obj_id, (_obj), (_obj_name)) | |
d98421f2 PP |
99 | |
100 | /* | |
101 | * Developer mode: asserts that a given object `_obj` named `_obj_name` | |
1778c2a4 PP |
102 | * (capitalized) and having the ID `_obj_id` (within the function's |
103 | * context) is NOT frozen. | |
104 | * | |
105 | * This macro checks the `frozen` field of `_obj`. | |
d98421f2 PP |
106 | * |
107 | * This currently only exists in developer mode because some freezing | |
108 | * functions can be called on the fast path, so they too are only | |
109 | * enabled in developer mode. | |
110 | */ | |
1778c2a4 PP |
111 | # define BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(_func, _obj_id, _obj, _obj_name, _fmt, ...) \ |
112 | BT_ASSERT_PRE_FROM_FUNC(_func, "not-frozen:" _obj_id, \ | |
113 | !(_obj)->frozen, "%s is frozen" _fmt, _obj_name, ##__VA_ARGS__) | |
114 | ||
115 | # define BT_ASSERT_PRE_DEV_HOT(_obj_id, _obj, _obj_name, _fmt, ...) \ | |
116 | BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(__func__, _obj_id, (_obj), \ | |
117 | _obj_name, _fmt, ##__VA_ARGS__) | |
118 | ||
119 | /* Developer mode version of BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC() */ | |
120 | # define BT_ASSERT_PRE_DEV_VALID_INDEX_FROM_FUNC(_func, _index, _length) \ | |
121 | BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(_func, (_index), (_length)) | |
d98421f2 PP |
122 | |
123 | /* Developer mode version of BT_ASSERT_PRE_VALID_INDEX() */ | |
1778c2a4 | 124 | # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \ |
d98421f2 PP |
125 | BT_ASSERT_PRE_VALID_INDEX((_index), (_length)) |
126 | ||
1778c2a4 PP |
127 | /* Developer mode version of BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(). */ |
128 | # define BT_ASSERT_PRE_DEV_NO_ERROR_FROM_FUNC(_func) \ | |
129 | BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(_func) | |
130 | ||
d98421f2 | 131 | /* Developer mode version of BT_ASSERT_PRE_NO_ERROR(). */ |
1778c2a4 | 132 | # define BT_ASSERT_PRE_DEV_NO_ERROR() BT_ASSERT_PRE_NO_ERROR() |
d98421f2 | 133 | |
d98421f2 PP |
134 | /* |
135 | * Developer mode version of | |
136 | * BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(). | |
137 | */ | |
1778c2a4 PP |
138 | # define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \ |
139 | BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_func, (_status)) | |
d98421f2 PP |
140 | |
141 | /* Developer mode version of BT_ASSERT_POST_NO_ERROR(). */ | |
1778c2a4 PP |
142 | # define BT_ASSERT_POST_DEV_NO_ERROR(_func) \ |
143 | BT_ASSERT_POST_NO_ERROR(_func) | |
d98421f2 | 144 | |
d98421f2 PP |
145 | /* |
146 | * Marks a function as being only used within a BT_ASSERT_PRE_DEV() or | |
147 | * BT_ASSERT_POST_DEV() context. | |
148 | */ | |
149 | # define BT_ASSERT_COND_DEV_FUNC | |
150 | #else | |
1778c2a4 PP |
151 | # define BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, _obj_id, _obj, _obj_name) \ |
152 | BT_USE_EXPR4(_func, _obj_id, (_obj), _obj_name) | |
153 | ||
154 | # define BT_ASSERT_PRE_DEV_NON_NULL(_obj_id, _obj, _obj_name) \ | |
155 | BT_USE_EXPR3(_obj_id, (_obj), _obj_name) | |
156 | ||
157 | # define BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(_func, _obj_id, _obj, _obj_name, _fmt, ...) \ | |
158 | BT_USE_EXPR5(_func, _obj_id, (_obj), _obj_name, _fmt) | |
2bdc32f7 | 159 | |
1778c2a4 PP |
160 | # define BT_ASSERT_PRE_DEV_HOT(_obj_id, _obj, _obj_name, _fmt, ...) \ |
161 | BT_USE_EXPR4(_obj_id, (_obj), _obj_name, _fmt) | |
162 | ||
163 | # define BT_ASSERT_PRE_DEV_VALID_INDEX_FROM_FUNC(_func, _index, _length) \ | |
164 | BT_USE_EXPR3(_func, (_index), (_length)) | |
2bdc32f7 | 165 | |
d98421f2 | 166 | # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \ |
1778c2a4 PP |
167 | BT_USE_EXPR2((_index), (_length)) |
168 | ||
169 | # define BT_ASSERT_PRE_DEV_NO_ERROR_FROM_FUNC(_func) \ | |
170 | BT_USE_EXPR(_func) | |
2bdc32f7 | 171 | |
d98421f2 | 172 | # define BT_ASSERT_PRE_DEV_NO_ERROR() |
2bdc32f7 | 173 | |
1778c2a4 PP |
174 | # define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \ |
175 | BT_USE_EXPR2(_func, _status) | |
2bdc32f7 | 176 | |
1778c2a4 PP |
177 | # define BT_ASSERT_POST_DEV_NO_ERROR(_func) \ |
178 | BT_USE_EXPR(_func) | |
d98421f2 PP |
179 | #endif /* BT_DEV_MODE */ |
180 | ||
2bdc32f7 | 181 | #define _BT_ASSERT_PRE_CLK_CLS_NAME "Clock class" |
1778c2a4 | 182 | #define _BT_ASSERT_PRE_CLK_CLS_ID "clock-class" |
2bdc32f7 PP |
183 | |
184 | #define BT_ASSERT_PRE_CLK_CLS_NON_NULL(_cc) \ | |
1778c2a4 PP |
185 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CLK_CLS_ID, (_cc), \ |
186 | _BT_ASSERT_PRE_CLK_CLS_NAME) | |
2bdc32f7 PP |
187 | |
188 | #define BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(_cc) \ | |
1778c2a4 PP |
189 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CLK_CLS_ID, (_cc), \ |
190 | _BT_ASSERT_PRE_CLK_CLS_NAME) | |
2bdc32f7 PP |
191 | |
192 | #define _BT_ASSERT_PRE_DEF_CLK_CLS_NAME "Default clock class" | |
1778c2a4 | 193 | #define _BT_ASSERT_PRE_DEF_CLK_CLS_ID "default-clock-class" |
2bdc32f7 PP |
194 | |
195 | #define BT_ASSERT_PRE_DEF_CLK_CLS_NON_NULL(_cc) \ | |
1778c2a4 PP |
196 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_DEF_CLK_CLS_ID, (_cc), \ |
197 | _BT_ASSERT_PRE_DEF_CLK_CLS_NAME) | |
2bdc32f7 PP |
198 | |
199 | #define BT_ASSERT_PRE_DEV_DEF_CLK_CLS_NON_NULL(_cc) \ | |
1778c2a4 PP |
200 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_DEF_CLK_CLS_ID, \ |
201 | (_cc), _BT_ASSERT_PRE_DEF_CLK_CLS_NAME) | |
2bdc32f7 PP |
202 | |
203 | #define _BT_ASSERT_PRE_CS_NAME "Clock snapshot" | |
1778c2a4 | 204 | #define _BT_ASSERT_PRE_CS_ID "clock-snapshot" |
2bdc32f7 PP |
205 | |
206 | #define BT_ASSERT_PRE_CS_NON_NULL(_cs) \ | |
1778c2a4 PP |
207 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CS_ID, (_cs), \ |
208 | _BT_ASSERT_PRE_CS_NAME) | |
2bdc32f7 PP |
209 | |
210 | #define BT_ASSERT_PRE_DEV_CS_NON_NULL(_cs) \ | |
1778c2a4 PP |
211 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CS_ID, (_cs), \ |
212 | _BT_ASSERT_PRE_CS_NAME) | |
2bdc32f7 PP |
213 | |
214 | #define _BT_ASSERT_PRE_EVENT_NAME "Event" | |
1778c2a4 | 215 | #define _BT_ASSERT_PRE_EVENT_ID "event" |
2bdc32f7 | 216 | |
1778c2a4 PP |
217 | #define BT_ASSERT_PRE_EVENT_NON_NULL(_event) \ |
218 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_EVENT_ID, (_event), \ | |
219 | _BT_ASSERT_PRE_EVENT_NAME) | |
2bdc32f7 | 220 | |
1778c2a4 PP |
221 | #define BT_ASSERT_PRE_DEV_EVENT_NON_NULL(_event) \ |
222 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_EVENT_ID, (_event), \ | |
223 | _BT_ASSERT_PRE_EVENT_NAME) | |
2bdc32f7 PP |
224 | |
225 | #define _BT_ASSERT_PRE_EC_NAME "Event class" | |
1778c2a4 PP |
226 | #define _BT_ASSERT_PRE_EC_ID "event-class" |
227 | ||
228 | #define BT_ASSERT_PRE_EC_NON_NULL_FROM_FUNC(_func, _ec) \ | |
229 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_EC_ID, \ | |
230 | (_ec), _BT_ASSERT_PRE_EC_NAME) | |
2bdc32f7 PP |
231 | |
232 | #define BT_ASSERT_PRE_EC_NON_NULL(_ec) \ | |
1778c2a4 PP |
233 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_EC_ID, (_ec), \ |
234 | _BT_ASSERT_PRE_EC_NAME) | |
235 | ||
236 | #define BT_ASSERT_PRE_DEV_EC_NON_NULL_FROM_FUNC(_func, _ec) \ | |
237 | BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \ | |
238 | _BT_ASSERT_PRE_EC_ID, (_ec), _BT_ASSERT_PRE_EC_NAME) | |
2bdc32f7 PP |
239 | |
240 | #define BT_ASSERT_PRE_DEV_EC_NON_NULL(_ec) \ | |
1778c2a4 PP |
241 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_EC_ID, (_ec), \ |
242 | _BT_ASSERT_PRE_EC_NAME) | |
2bdc32f7 PP |
243 | |
244 | #define _BT_ASSERT_PRE_FC_IS_INT_COND(_fc) \ | |
245 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \ | |
246 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \ | |
247 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \ | |
248 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) | |
249 | ||
250 | #define _BT_ASSERT_PRE_FC_IS_INT_FMT(_name) \ | |
251 | _name " is not an integer field class: %![fc-]+F" | |
252 | ||
1778c2a4 PP |
253 | #define _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id) "is-int-field-class:" _fc_id |
254 | ||
2bdc32f7 PP |
255 | #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc) \ |
256 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \ | |
257 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION) | |
258 | ||
259 | #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name) \ | |
260 | _name " is not an unsigned integer field class: %![fc-]+F" | |
261 | ||
1778c2a4 PP |
262 | #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id) \ |
263 | "is-unsigned-integer-field-class:" _fc_id | |
2bdc32f7 PP |
264 | |
265 | #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc) \ | |
266 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \ | |
267 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) | |
268 | ||
269 | #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name) \ | |
270 | _name " is not a signed integer field class: %![fc-]+F" | |
271 | ||
1778c2a4 PP |
272 | #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id) \ |
273 | "is-signed-integer-field-class:" _fc_id | |
274 | ||
2bdc32f7 PP |
275 | #define _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc) \ |
276 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \ | |
277 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) | |
278 | ||
279 | #define _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name) \ | |
280 | _name " is not an enumeration field class: %![fc-]+F" | |
281 | ||
1778c2a4 PP |
282 | #define _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id) \ |
283 | "is-enumeration-field-class:" _fc_id | |
284 | ||
2bdc32f7 PP |
285 | #define _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc) \ |
286 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \ | |
287 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \ | |
288 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) | |
289 | ||
290 | #define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name) \ | |
291 | _name " is not an array field class: %![fc-]+F" | |
292 | ||
1778c2a4 PP |
293 | #define _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id) \ |
294 | "is-array-field-class:" _fc_id | |
295 | ||
2bdc32f7 PP |
296 | #define _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc) \ |
297 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \ | |
298 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \ | |
299 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ | |
300 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD) | |
301 | ||
302 | #define _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name) \ | |
303 | _name " is not an option field class: %![fc-]+F" | |
304 | ||
1778c2a4 PP |
305 | #define _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id) \ |
306 | "is-option-field-class:" _fc_id | |
307 | ||
2bdc32f7 PP |
308 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc) \ |
309 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \ | |
310 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ | |
311 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD) | |
312 | ||
313 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name) \ | |
314 | _name " is not an option field class with a selector: %![fc-]+F" | |
315 | ||
1778c2a4 PP |
316 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_ID(_fc_id) \ |
317 | "is-option-field-class-with-selector:" _fc_id | |
318 | ||
2bdc32f7 PP |
319 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc) \ |
320 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ | |
321 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD) | |
322 | ||
323 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name) \ | |
324 | _name " is not an option field class with an integer selector: %![fc-]+F" | |
325 | ||
1778c2a4 PP |
326 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_ID(_fc_id) \ |
327 | "is-option-field-class-with-integer-selector:" _fc_id | |
328 | ||
2bdc32f7 PP |
329 | #define _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name) \ |
330 | _name " is not a structure field class: %![fc-]+F" | |
331 | ||
332 | #define _BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc) \ | |
333 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STRUCTURE) | |
334 | ||
1778c2a4 PP |
335 | #define _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id) \ |
336 | "is-structure-field-class:" _fc_id | |
337 | ||
2bdc32f7 PP |
338 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc) \ |
339 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \ | |
340 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ | |
341 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD) | |
342 | ||
343 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name) \ | |
344 | _name " is not a variant field class: %![fc-]+F" | |
345 | ||
1778c2a4 PP |
346 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id) \ |
347 | "is-variant-field-class:" _fc_id | |
348 | ||
2bdc32f7 PP |
349 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc) \ |
350 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ | |
351 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD) | |
352 | ||
353 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name) \ | |
354 | _name " is not a variant field class with a selector: %![fc-]+F" | |
355 | ||
1778c2a4 PP |
356 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id) \ |
357 | "is-variant-field-class-with-selector:" _fc_id | |
358 | ||
0a83319b | 359 | #define _BT_ASSERT_PRE_FC_HAS_TYPE_COND(_fc, _type) \ |
2bdc32f7 PP |
360 | (((const struct bt_field_class *) (_fc))->type == (_type)) |
361 | ||
0a83319b | 362 | #define _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name) \ |
2bdc32f7 PP |
363 | _name " has the wrong type: expected-type=%s, %![fc-]+F" |
364 | ||
1778c2a4 PP |
365 | #define _BT_ASSERT_PRE_FC_HAS_TYPE_ID(_fc_id, _type_id) \ |
366 | "is-" _type_id ":" _fc_id | |
367 | ||
368 | #define BT_ASSERT_PRE_FC_IS_INT_FROM_FUNC(_func, _fc_id, _fc, _name) \ | |
369 | BT_ASSERT_PRE_FROM_FUNC(_func, \ | |
370 | _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id), \ | |
371 | _BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \ | |
2bdc32f7 PP |
372 | _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc)) |
373 | ||
1778c2a4 PP |
374 | #define BT_ASSERT_PRE_FC_IS_INT(_fc_id, _fc, _name) \ |
375 | BT_ASSERT_PRE_FC_IS_INT_FROM_FUNC(__func__, _fc_id, (_fc), _name) | |
376 | ||
377 | #define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc_id, _fc, _name) \ | |
378 | BT_ASSERT_PRE( \ | |
379 | _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id), \ | |
380 | _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \ | |
2bdc32f7 PP |
381 | _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc)) |
382 | ||
1778c2a4 PP |
383 | #define BT_ASSERT_PRE_FC_IS_SIGNED_INT(_fc_id, _fc, _name) \ |
384 | BT_ASSERT_PRE( \ | |
385 | _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id), \ | |
386 | _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc), \ | |
2bdc32f7 PP |
387 | _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc)) |
388 | ||
1778c2a4 PP |
389 | #define BT_ASSERT_PRE_FC_IS_ENUM(_fc_id, _fc, _name) \ |
390 | BT_ASSERT_PRE( \ | |
391 | _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id), \ | |
392 | _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \ | |
2bdc32f7 PP |
393 | _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc)) |
394 | ||
1778c2a4 PP |
395 | #define BT_ASSERT_PRE_FC_IS_ARRAY(_fc_id, _fc, _name) \ |
396 | BT_ASSERT_PRE( \ | |
397 | _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id), \ | |
398 | _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \ | |
2bdc32f7 PP |
399 | _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc)) |
400 | ||
1778c2a4 PP |
401 | #define BT_ASSERT_PRE_FC_IS_STRUCT(_fc_id, _fc, _name) \ |
402 | BT_ASSERT_PRE( \ | |
403 | _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id), \ | |
404 | _BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc), \ | |
2bdc32f7 PP |
405 | _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name), (_fc)) |
406 | ||
1778c2a4 PP |
407 | #define BT_ASSERT_PRE_FC_IS_OPTION(_fc_id, _fc, _name) \ |
408 | BT_ASSERT_PRE( \ | |
409 | _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id), \ | |
410 | _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc), \ | |
2bdc32f7 PP |
411 | _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc)) |
412 | ||
1778c2a4 PP |
413 | #define BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL(_fc_id, _fc, _name) \ |
414 | BT_ASSERT_PRE( \ | |
415 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_ID(_fc_id), \ | |
416 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \ | |
2bdc32f7 PP |
417 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc)) |
418 | ||
1778c2a4 PP |
419 | #define BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(_fc_id, _fc, _name) \ |
420 | BT_ASSERT_PRE( \ | |
421 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_ID(_fc_id), \ | |
422 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \ | |
2bdc32f7 PP |
423 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc)) |
424 | ||
1778c2a4 PP |
425 | #define BT_ASSERT_PRE_FC_IS_VARIANT(_fc_id, _fc, _name) \ |
426 | BT_ASSERT_PRE( \ | |
427 | _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id), \ | |
428 | _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc), \ | |
2bdc32f7 PP |
429 | _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc)) |
430 | ||
1778c2a4 PP |
431 | #define BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL(_fc_id, _fc, _name) \ |
432 | BT_ASSERT_PRE( \ | |
433 | _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id), \ | |
434 | _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \ | |
2bdc32f7 PP |
435 | _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc)) |
436 | ||
1778c2a4 PP |
437 | #define BT_ASSERT_PRE_FC_HAS_TYPE_FROM_FUNC(_func, _fc_id, _fc, _type_id, _type, _name) \ |
438 | BT_ASSERT_PRE_FROM_FUNC(_func, \ | |
439 | _BT_ASSERT_PRE_FC_HAS_TYPE_ID(_fc_id, _type_id), \ | |
440 | _BT_ASSERT_PRE_FC_HAS_TYPE_COND((_fc), (_type)), \ | |
0a83319b | 441 | _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name), \ |
2bdc32f7 PP |
442 | bt_common_field_class_type_string(_type), (_fc)) |
443 | ||
1778c2a4 PP |
444 | #define BT_ASSERT_PRE_FC_HAS_TYPE(_fc_id, _fc, _type_id, _type, _name) \ |
445 | BT_ASSERT_PRE_FC_HAS_TYPE_FROM_FUNC(__func__, _fc_id, (_fc), \ | |
446 | _type_id, (_type), _name) | |
447 | ||
448 | #define BT_ASSERT_PRE_DEV_FC_IS_INT(_fc_id, _fc, _name) \ | |
449 | BT_ASSERT_PRE_DEV( \ | |
450 | _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id), \ | |
451 | _BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \ | |
2bdc32f7 PP |
452 | _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc)) |
453 | ||
1778c2a4 PP |
454 | #define BT_ASSERT_PRE_DEV_FC_IS_UNSIGNED_INT(_fc_id, _fc, _name) \ |
455 | BT_ASSERT_PRE_DEV( \ | |
456 | _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id), \ | |
457 | _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \ | |
2bdc32f7 PP |
458 | _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc)) |
459 | ||
1778c2a4 PP |
460 | #define BT_ASSERT_PRE_DEV_FC_IS_SIGNED_INT(_fc_id, _fc, _name) \ |
461 | BT_ASSERT_PRE_DEV( \ | |
462 | _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id), \ | |
463 | _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc), \ | |
2bdc32f7 PP |
464 | _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc)) |
465 | ||
1778c2a4 PP |
466 | #define BT_ASSERT_PRE_DEV_FC_IS_ENUM(_fc_id, _fc, _name) \ |
467 | BT_ASSERT_PRE_DEV( \ | |
468 | _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id), \ | |
469 | _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \ | |
2bdc32f7 PP |
470 | _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc)) |
471 | ||
1778c2a4 PP |
472 | #define BT_ASSERT_PRE_DEV_FC_IS_ARRAY(_fc_id, _fc, _name) \ |
473 | BT_ASSERT_PRE_DEV( \ | |
474 | _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id), \ | |
475 | _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \ | |
2bdc32f7 PP |
476 | _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc)) |
477 | ||
1778c2a4 PP |
478 | #define BT_ASSERT_PRE_DEV_FC_IS_STRUCT(_fc_id, _fc, _name) \ |
479 | BT_ASSERT_PRE_DEV( \ | |
480 | _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id), \ | |
481 | _BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc), \ | |
2bdc32f7 PP |
482 | _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name), (_fc)) |
483 | ||
1778c2a4 PP |
484 | #define BT_ASSERT_PRE_DEV_FC_IS_OPTION(_fc_id, _fc, _name) \ |
485 | BT_ASSERT_PRE_DEV( \ | |
486 | _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id), \ | |
487 | _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc), \ | |
2bdc32f7 PP |
488 | _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc)) |
489 | ||
1778c2a4 PP |
490 | #define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_SEL(_fc_id, _fc, _name) \ |
491 | BT_ASSERT_PRE_DEV( \ | |
492 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \ | |
2bdc32f7 PP |
493 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc)) |
494 | ||
1778c2a4 PP |
495 | #define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_INT_SEL(_fc_id, _fc, _name) \ |
496 | BT_ASSERT_PRE_DEV( \ | |
497 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_ID(_fc_id), \ | |
498 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \ | |
2bdc32f7 PP |
499 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc)) |
500 | ||
1778c2a4 PP |
501 | #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT(_fc_id, _fc, _name) \ |
502 | BT_ASSERT_PRE_DEV( \ | |
503 | _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id), \ | |
504 | _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc), \ | |
2bdc32f7 PP |
505 | _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc)) |
506 | ||
1778c2a4 PP |
507 | #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL(_fc_id, _fc, _name) \ |
508 | BT_ASSERT_PRE_DEV( \ | |
509 | _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id), \ | |
510 | _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \ | |
2bdc32f7 PP |
511 | _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc)) |
512 | ||
1778c2a4 PP |
513 | #define BT_ASSERT_PRE_DEV_FC_HAS_TYPE(_fc_id, _fc, _type_id, _type, _name) \ |
514 | BT_ASSERT_PRE_DEV( \ | |
515 | _BT_ASSERT_PRE_FC_HAS_TYPE_ID(_fc_id, _type_id), \ | |
516 | _BT_ASSERT_PRE_FC_HAS_TYPE_COND((_fc), (_type)), \ | |
0a83319b | 517 | _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name), \ |
2bdc32f7 PP |
518 | bt_common_field_class_type_string(_type), (_fc)) |
519 | ||
1778c2a4 PP |
520 | #define BT_ASSERT_PRE_DEV_FC_HOT_FROM_FUNC(_func, _fc) \ |
521 | BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(_func, "field-class", \ | |
522 | (const struct bt_field_class *) (_fc), \ | |
523 | "Field class", ": %!+F", (_fc)) | |
524 | ||
525 | #define BT_ASSERT_PRE_DEV_FC_HOT(_fc) \ | |
526 | BT_ASSERT_PRE_DEV_FC_HOT_FROM_FUNC(__func__, (_fc)) | |
2bdc32f7 PP |
527 | |
528 | #define _BT_ASSERT_PRE_FC_NAME "Field class" | |
1778c2a4 | 529 | #define _BT_ASSERT_PRE_FC_ID "field-class" |
2bdc32f7 PP |
530 | |
531 | #define BT_ASSERT_PRE_FC_NON_NULL(_fc) \ | |
1778c2a4 PP |
532 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FC_ID, (_fc), \ |
533 | _BT_ASSERT_PRE_FC_NAME) | |
2bdc32f7 PP |
534 | |
535 | #define BT_ASSERT_PRE_DEV_FC_NON_NULL(_fc) \ | |
1778c2a4 PP |
536 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FC_ID, (_fc), \ |
537 | _BT_ASSERT_PRE_FC_NAME) | |
2bdc32f7 PP |
538 | |
539 | #define _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME "Structure field class member" | |
1778c2a4 | 540 | #define _BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID "structure-field-class-member" |
2bdc32f7 PP |
541 | |
542 | #define BT_ASSERT_PRE_STRUCT_FC_MEMBER_NON_NULL(_fc) \ | |
1778c2a4 PP |
543 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID, \ |
544 | (_fc), _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME) | |
2bdc32f7 PP |
545 | |
546 | #define BT_ASSERT_PRE_DEV_STRUCT_FC_MEMBER_NON_NULL(_fc) \ | |
1778c2a4 PP |
547 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID, \ |
548 | (_fc), _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME) | |
2bdc32f7 PP |
549 | |
550 | #define _BT_ASSERT_PRE_VAR_FC_OPT_NAME "Variant field class option" | |
1778c2a4 | 551 | #define _BT_ASSERT_PRE_VAR_FC_OPT_ID "variant-field-class-option-id" |
2bdc32f7 PP |
552 | |
553 | #define BT_ASSERT_PRE_VAR_FC_OPT_NON_NULL(_fc) \ | |
1778c2a4 PP |
554 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_VAR_FC_OPT_ID, (_fc), \ |
555 | _BT_ASSERT_PRE_VAR_FC_OPT_NAME) | |
2bdc32f7 PP |
556 | |
557 | #define BT_ASSERT_PRE_DEV_VAR_FC_OPT_NON_NULL(_fc) \ | |
1778c2a4 PP |
558 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_VAR_FC_OPT_ID, (_fc), \ |
559 | _BT_ASSERT_PRE_VAR_FC_OPT_NAME) | |
2bdc32f7 PP |
560 | |
561 | #define _BT_ASSERT_PRE_FP_NAME "Field path" | |
1778c2a4 | 562 | #define _BT_ASSERT_PRE_FP_ID "field-path" |
2bdc32f7 PP |
563 | |
564 | #define BT_ASSERT_PRE_FP_NON_NULL(_fp) \ | |
1778c2a4 PP |
565 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FP_ID, (_fp), \ |
566 | _BT_ASSERT_PRE_FP_NAME) | |
2bdc32f7 PP |
567 | |
568 | #define BT_ASSERT_PRE_DEV_FP_NON_NULL(_fp) \ | |
1778c2a4 PP |
569 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FP_ID, (_fp), \ |
570 | _BT_ASSERT_PRE_FP_NAME) | |
2bdc32f7 | 571 | |
1778c2a4 PP |
572 | #define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(_field_id, _field, _cls_type_id, _cls_type, _name) \ |
573 | BT_ASSERT_PRE_DEV("is-" _cls_type_id ":" _field_id, \ | |
574 | ((const struct bt_field *) (_field))->class->type == (_cls_type), \ | |
2bdc32f7 PP |
575 | _name " has the wrong class type: expected-class-type=%s, " \ |
576 | "%![field-]+f", \ | |
577 | bt_common_field_class_type_string(_cls_type), (_field)) | |
578 | ||
1778c2a4 | 579 | #define BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(_field_id, _field, _name) \ |
2bdc32f7 | 580 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 581 | "is-unsigned-integer-field:" _field_id, \ |
2bdc32f7 PP |
582 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \ |
583 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, \ | |
584 | _name " is not an unsigned integer field: %![field-]+f", \ | |
585 | (_field)) | |
586 | ||
1778c2a4 | 587 | #define BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(_field_id, _field, _name) \ |
2bdc32f7 | 588 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 589 | "is-signed-integer-field:" _field_id, \ |
2bdc32f7 PP |
590 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \ |
591 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, \ | |
592 | _name " is not a signed integer field: %![field-]+f", \ | |
593 | (_field)) | |
594 | ||
1778c2a4 | 595 | #define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(_field_id, _field, _name) \ |
2bdc32f7 | 596 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 597 | "is-array-field:" _field_id, \ |
2bdc32f7 PP |
598 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \ |
599 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \ | |
600 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \ | |
601 | _name " is not an array field: %![field-]+f", (_field)) | |
602 | ||
1778c2a4 | 603 | #define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(_field_id, _field, _name) \ |
2bdc32f7 | 604 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 605 | "is-dynamic-array-field:" _field_id, \ |
2bdc32f7 PP |
606 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \ |
607 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \ | |
608 | _name " is not a dynamic array field: %![field-]+f", (_field)) | |
609 | ||
1778c2a4 | 610 | #define BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(_field_id, _field, _name) \ |
2bdc32f7 | 611 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 612 | "is-option-field:" _field_id, \ |
2bdc32f7 PP |
613 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \ |
614 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \ | |
615 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ | |
616 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD, \ | |
617 | _name " is not an option field: %![field-]+f", (_field)) | |
618 | ||
1778c2a4 | 619 | #define BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(_field_id, _field, _name) \ |
2bdc32f7 | 620 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 621 | "is-variant-field:" _field_id, \ |
2bdc32f7 PP |
622 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \ |
623 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ | |
624 | ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD, \ | |
625 | _name " is not a variant field: %![field-]+f", (_field)) | |
626 | ||
1778c2a4 PP |
627 | #define BT_ASSERT_PRE_DEV_FIELD_IS_SET(_field_id, _field) \ |
628 | BT_ASSERT_PRE_DEV("is-field-set:" _field_id, \ | |
629 | bt_field_is_set(_field), \ | |
d5b13b9b | 630 | "Field is not set: %!+f", (_field)) |
2bdc32f7 PP |
631 | |
632 | #define _BT_ASSERT_PRE_FIELD_NAME "Field" | |
1778c2a4 | 633 | #define _BT_ASSERT_PRE_FIELD_ID "field" |
2bdc32f7 PP |
634 | |
635 | #define BT_ASSERT_PRE_FIELD_NON_NULL(_field) \ | |
1778c2a4 PP |
636 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field), \ |
637 | _BT_ASSERT_PRE_FIELD_NAME) | |
2bdc32f7 PP |
638 | |
639 | #define BT_ASSERT_PRE_DEV_FIELD_NON_NULL(_field) \ | |
1778c2a4 PP |
640 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field), \ |
641 | _BT_ASSERT_PRE_FIELD_NAME) | |
2bdc32f7 PP |
642 | |
643 | #define _BT_ASSERT_PRE_PACKET_NAME "Packet" | |
1778c2a4 PP |
644 | #define _BT_ASSERT_PRE_PACKET_ID "packet" |
645 | ||
646 | #define BT_ASSERT_PRE_PACKET_NON_NULL_FROM_FUNC(_func, _packet) \ | |
647 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \ | |
648 | _BT_ASSERT_PRE_PACKET_ID, (_packet), _BT_ASSERT_PRE_PACKET_NAME) | |
2bdc32f7 PP |
649 | |
650 | #define BT_ASSERT_PRE_PACKET_NON_NULL(_packet) \ | |
1778c2a4 PP |
651 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PACKET_ID, (_packet), \ |
652 | _BT_ASSERT_PRE_PACKET_NAME) | |
653 | ||
654 | #define BT_ASSERT_PRE_DEV_PACKET_NON_NULL_FROM_FUNC(_func, _packet) \ | |
655 | BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \ | |
656 | _BT_ASSERT_PRE_PACKET_ID, (_packet), _BT_ASSERT_PRE_PACKET_NAME) | |
2bdc32f7 PP |
657 | |
658 | #define BT_ASSERT_PRE_DEV_PACKET_NON_NULL(_packet) \ | |
1778c2a4 PP |
659 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PACKET_ID, (_packet), \ |
660 | _BT_ASSERT_PRE_PACKET_NAME) | |
2bdc32f7 PP |
661 | |
662 | #define _BT_ASSERT_PRE_SC_NAME "Stream class" | |
1778c2a4 | 663 | #define _BT_ASSERT_PRE_SC_ID "stream-class" |
2bdc32f7 PP |
664 | |
665 | #define BT_ASSERT_PRE_SC_NON_NULL(_sc) \ | |
1778c2a4 PP |
666 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_SC_ID, (_sc), \ |
667 | _BT_ASSERT_PRE_SC_NAME) | |
2bdc32f7 PP |
668 | |
669 | #define BT_ASSERT_PRE_DEV_SC_NON_NULL(_sc) \ | |
1778c2a4 PP |
670 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_SC_ID, (_sc), \ |
671 | _BT_ASSERT_PRE_SC_NAME) | |
2bdc32f7 PP |
672 | |
673 | #define _BT_ASSERT_PRE_STREAM_NAME "Stream" | |
1778c2a4 PP |
674 | #define _BT_ASSERT_PRE_STREAM_ID "stream" |
675 | ||
676 | #define BT_ASSERT_PRE_STREAM_NON_NULL_FROM_FUNC(_func, _stream) \ | |
677 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \ | |
678 | _BT_ASSERT_PRE_STREAM_ID, (_stream), \ | |
679 | _BT_ASSERT_PRE_STREAM_NAME) | |
2bdc32f7 PP |
680 | |
681 | #define BT_ASSERT_PRE_STREAM_NON_NULL(_stream) \ | |
1778c2a4 PP |
682 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_STREAM_ID, (_stream), \ |
683 | _BT_ASSERT_PRE_STREAM_NAME) | |
684 | ||
685 | #define BT_ASSERT_PRE_DEV_STREAM_NON_NULL_FROM_FUNC(_func, _stream) \ | |
686 | BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \ | |
687 | _BT_ASSERT_PRE_STREAM_ID, (_stream), \ | |
688 | _BT_ASSERT_PRE_STREAM_NAME) | |
2bdc32f7 PP |
689 | |
690 | #define BT_ASSERT_PRE_DEV_STREAM_NON_NULL(_stream) \ | |
1778c2a4 PP |
691 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_STREAM_ID, (_stream), \ |
692 | _BT_ASSERT_PRE_STREAM_NAME) | |
2bdc32f7 PP |
693 | |
694 | #define _BT_ASSERT_PRE_TC_NAME "Trace class" | |
1778c2a4 PP |
695 | #define _BT_ASSERT_PRE_TC_ID "trace-class" |
696 | ||
697 | #define BT_ASSERT_PRE_TC_NON_NULL_FROM_FUNC(_func, _tc) \ | |
698 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_TC_ID, \ | |
699 | (_tc), _BT_ASSERT_PRE_TC_NAME) | |
2bdc32f7 PP |
700 | |
701 | #define BT_ASSERT_PRE_TC_NON_NULL(_tc) \ | |
1778c2a4 PP |
702 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_TC_ID, (_tc), \ |
703 | _BT_ASSERT_PRE_TC_NAME) | |
2bdc32f7 PP |
704 | |
705 | #define BT_ASSERT_PRE_DEV_TC_NON_NULL(_tc) \ | |
1778c2a4 PP |
706 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_TC_ID, (_tc), \ |
707 | _BT_ASSERT_PRE_TC_NAME) | |
2bdc32f7 PP |
708 | |
709 | #define _BT_ASSERT_PRE_TRACE_NAME "Trace" | |
1778c2a4 | 710 | #define _BT_ASSERT_PRE_TRACE_ID "trace" |
2bdc32f7 PP |
711 | |
712 | #define BT_ASSERT_PRE_TRACE_NON_NULL(_trace) \ | |
1778c2a4 PP |
713 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_TRACE_ID, (_trace), \ |
714 | _BT_ASSERT_PRE_TRACE_NAME) | |
2bdc32f7 PP |
715 | |
716 | #define BT_ASSERT_PRE_DEV_TRACE_NON_NULL(_trace) \ | |
1778c2a4 PP |
717 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_TRACE_ID, (_trace), \ |
718 | _BT_ASSERT_PRE_TRACE_NAME) | |
2bdc32f7 | 719 | |
1778c2a4 PP |
720 | #define _BT_ASSERT_PRE_USER_ATTRS_NAME "User attributes value object" |
721 | #define _BT_ASSERT_PRE_USER_ATTRS_ID "user-attributes-value-object" | |
722 | ||
723 | #define BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(_func, _ua) \ | |
724 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \ | |
725 | _BT_ASSERT_PRE_USER_ATTRS_ID, (_ua), \ | |
726 | _BT_ASSERT_PRE_USER_ATTRS_NAME) | |
2bdc32f7 PP |
727 | |
728 | #define BT_ASSERT_PRE_USER_ATTRS_NON_NULL(_ua) \ | |
1778c2a4 | 729 | BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(__func__, (_ua)) |
2bdc32f7 PP |
730 | |
731 | #define BT_ASSERT_PRE_DEV_USER_ATTRS_NON_NULL(_ua) \ | |
1778c2a4 PP |
732 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_USER_ATTRS_ID, (_ua), \ |
733 | _BT_ASSERT_PRE_USER_ATTRS_NAME) | |
2bdc32f7 | 734 | |
1778c2a4 PP |
735 | #define BT_ASSERT_PRE_USER_ATTRS_IS_MAP_FROM_FUNC(_func, _ua) \ |
736 | BT_ASSERT_PRE_FROM_FUNC(_func, "is-map-value:user-attributes", \ | |
737 | (_ua)->type == BT_VALUE_TYPE_MAP, \ | |
2bdc32f7 PP |
738 | _BT_ASSERT_PRE_USER_ATTRS_NAME \ |
739 | " object is not a map value object.") | |
740 | ||
1778c2a4 PP |
741 | #define BT_ASSERT_PRE_USER_ATTRS_IS_MAP(_ua) \ |
742 | BT_ASSERT_PRE_USER_ATTRS_IS_MAP_FROM_FUNC(__func__, (_ua)) | |
743 | ||
2bdc32f7 | 744 | #define BT_ASSERT_COND_LISTENER_FUNC_NAME "Listener function" |
1778c2a4 | 745 | #define BT_ASSERT_COND_LISTENER_FUNC_ID "listener-function" |
2bdc32f7 | 746 | |
1778c2a4 PP |
747 | #define BT_ASSERT_PRE_LISTENER_FUNC_NON_NULL(_listener_func) \ |
748 | BT_ASSERT_PRE_NON_NULL(BT_ASSERT_COND_LISTENER_FUNC_ID, \ | |
749 | (_listener_func), BT_ASSERT_COND_LISTENER_FUNC_NAME) | |
2bdc32f7 | 750 | |
1778c2a4 PP |
751 | #define BT_ASSERT_PRE_DEV_LISTENER_FUNC_NON_NULL(_listener_func) \ |
752 | BT_ASSERT_PRE_DEV_NON_NULL(BT_ASSERT_COND_LISTENER_FUNC_ID, \ | |
753 | (_listener_func), BT_ASSERT_COND_LISTENER_FUNC_NAME) | |
2bdc32f7 PP |
754 | |
755 | #define _BT_ASSERT_PRE_MSG_ITER_NAME "Message iterator" | |
1778c2a4 PP |
756 | #define _BT_ASSERT_PRE_MSG_ITER_ID "message-iterator" |
757 | ||
758 | #define BT_ASSERT_PRE_MSG_ITER_NON_NULL_FROM_FUNC(_func, _msg_iter) \ | |
759 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \ | |
760 | _BT_ASSERT_PRE_MSG_ITER_ID, (_msg_iter), \ | |
761 | _BT_ASSERT_PRE_MSG_ITER_NAME) | |
2bdc32f7 PP |
762 | |
763 | #define BT_ASSERT_PRE_MSG_ITER_NON_NULL(_msg_iter) \ | |
1778c2a4 PP |
764 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_ID, (_msg_iter), \ |
765 | _BT_ASSERT_PRE_MSG_ITER_NAME) | |
766 | ||
767 | #define BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL_FROM_FUNC(_func, _msg_iter) \ | |
768 | BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \ | |
769 | _BT_ASSERT_PRE_MSG_ITER_ID, \ | |
770 | (_msg_iter), _BT_ASSERT_PRE_MSG_ITER_NAME) | |
2bdc32f7 PP |
771 | |
772 | #define BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL(_msg_iter) \ | |
1778c2a4 PP |
773 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_ID, \ |
774 | (_msg_iter), _BT_ASSERT_PRE_MSG_ITER_NAME) | |
775 | ||
776 | #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc) \ | |
777 | ((_sc)->default_clock_class) | |
778 | ||
779 | #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT \ | |
780 | "Message's stream's class has no default clock class: " \ | |
781 | "%![msg-]+n, %![sc-]+S" | |
782 | ||
783 | #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID \ | |
784 | "message-stream-class-has-default-clock-class" | |
785 | ||
786 | #define BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FROM_FUNC(_func, _msg, _sc) \ | |
787 | BT_ASSERT_PRE_FROM_FUNC(_func, \ | |
788 | _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID, \ | |
789 | _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc), \ | |
790 | _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT, \ | |
791 | (_msg), (_sc)); | |
792 | ||
793 | #define BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS(_msg, _sc) \ | |
794 | BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FROM_FUNC(__func__, (_msg), (_sc)) | |
795 | ||
796 | #define BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(_func, _msg, _sc) \ | |
797 | BT_ASSERT_PRE_DEV_FROM_FUNC(_func, \ | |
798 | _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID, \ | |
799 | _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc), \ | |
800 | _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT, \ | |
801 | (_msg), (_sc)); | |
2bdc32f7 PP |
802 | |
803 | #define BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS(_msg, _sc) \ | |
1778c2a4 | 804 | BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(__func__, (_msg), (_sc)) |
2bdc32f7 | 805 | |
0a83319b | 806 | #define _BT_ASSERT_PRE_MSG_HAS_TYPE_COND(_msg, _type) \ |
2bdc32f7 PP |
807 | (((struct bt_message *) (_msg))->type == (_type)) |
808 | ||
0a83319b | 809 | #define _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT \ |
2bdc32f7 PP |
810 | "Message has the wrong type: expected-type=%s, %![msg-]+n" |
811 | ||
1778c2a4 PP |
812 | #define _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id) \ |
813 | "is-" _type_id "-message:" _msg_id | |
814 | ||
815 | #define BT_ASSERT_PRE_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type) \ | |
2bdc32f7 | 816 | BT_ASSERT_PRE( \ |
1778c2a4 | 817 | _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id), \ |
0a83319b PP |
818 | _BT_ASSERT_PRE_MSG_HAS_TYPE_COND((_msg), (_type)), \ |
819 | _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT, \ | |
2bdc32f7 PP |
820 | bt_message_type_string(_type), (_msg)) |
821 | ||
1778c2a4 | 822 | #define BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type) \ |
2bdc32f7 | 823 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 824 | _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id), \ |
0a83319b PP |
825 | _BT_ASSERT_PRE_MSG_HAS_TYPE_COND((_msg), (_type)), \ |
826 | _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT, \ | |
2bdc32f7 PP |
827 | bt_message_type_string(_type), (_msg)) |
828 | ||
829 | #define _BT_ASSERT_PRE_MSG_NAME "Message" | |
1778c2a4 | 830 | #define _BT_ASSERT_PRE_MSG_ID "message" |
2bdc32f7 PP |
831 | |
832 | #define BT_ASSERT_PRE_MSG_NON_NULL(_msg_iter) \ | |
1778c2a4 PP |
833 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ID, (_msg_iter), \ |
834 | _BT_ASSERT_PRE_MSG_NAME) | |
2bdc32f7 PP |
835 | |
836 | #define BT_ASSERT_PRE_DEV_MSG_NON_NULL(_msg_iter) \ | |
1778c2a4 PP |
837 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ID, (_msg_iter), \ |
838 | _BT_ASSERT_PRE_MSG_NAME) | |
2bdc32f7 | 839 | |
4030a924 | 840 | #define BT_ASSERT_PRE_MSG_CS_BEGIN_LE_END(_msg_iter, _begin, _end) \ |
1778c2a4 PP |
841 | BT_ASSERT_PRE("beginning-default-clock-snapshot-lteq-end", \ |
842 | (_begin) <= (_end), \ | |
2bdc32f7 PP |
843 | "Beginning default clock snapshot value is greater " \ |
844 | "than end default clock snapshot value: " \ | |
845 | "cs-begin-val=%" PRIu64 ", cs-end-val=%" PRIu64 ", " \ | |
1778c2a4 | 846 | "%![msg-iter-]+i", (_begin), (_end), _msg_iter); |
2bdc32f7 PP |
847 | |
848 | #define BT_ASSERT_PRE_DEV_MSG_HOT(_msg) \ | |
1778c2a4 | 849 | BT_ASSERT_PRE_DEV_HOT("message", (_msg), "Message", ": %!+n", (_msg)); |
2bdc32f7 PP |
850 | |
851 | #define _BT_ASSERT_PRE_MSG_ITER_CLS_NAME "Message iterator class" | |
1778c2a4 | 852 | #define _BT_ASSERT_PRE_MSG_ITER_CLS_ID "message-iterator-class" |
2bdc32f7 PP |
853 | |
854 | #define BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(_msg_iter_cls) \ | |
1778c2a4 PP |
855 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_CLS_ID, \ |
856 | (_msg_iter_cls), _BT_ASSERT_PRE_MSG_ITER_CLS_NAME) | |
2bdc32f7 PP |
857 | |
858 | #define BT_ASSERT_PRE_DEV_MSG_ITER_CLS_NON_NULL(_msg_iter_cls) \ | |
1778c2a4 PP |
859 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_CLS_ID, \ |
860 | (_msg_iter_cls), _BT_ASSERT_PRE_MSG_ITER_CLS_NAME) | |
2bdc32f7 PP |
861 | |
862 | #define _BT_ASSERT_PRE_COMP_CLS_NAME "Component class" | |
1778c2a4 PP |
863 | #define _BT_ASSERT_PRE_COMP_CLS_ID "component-class" |
864 | ||
865 | #define BT_ASSERT_PRE_COMP_CLS_NON_NULL_FROM_FUNC(_func, _comp_cls) \ | |
866 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \ | |
867 | _BT_ASSERT_PRE_COMP_CLS_ID, (_comp_cls), \ | |
868 | _BT_ASSERT_PRE_COMP_CLS_NAME) | |
2bdc32f7 PP |
869 | |
870 | #define BT_ASSERT_PRE_COMP_CLS_NON_NULL(_comp_cls) \ | |
1778c2a4 PP |
871 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_CLS_ID, (_comp_cls), \ |
872 | _BT_ASSERT_PRE_COMP_CLS_NAME) | |
2bdc32f7 PP |
873 | |
874 | #define BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(_comp_cls) \ | |
1778c2a4 PP |
875 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_CLS_ID, \ |
876 | (_comp_cls), _BT_ASSERT_PRE_COMP_CLS_NAME) | |
2bdc32f7 PP |
877 | |
878 | #define _BT_ASSERT_PRE_COMP_DESCR_SET_NAME "Component descriptor set" | |
1778c2a4 | 879 | #define _BT_ASSERT_PRE_COMP_DESCR_SET_ID "component-descriptor-set" |
2bdc32f7 PP |
880 | |
881 | #define BT_ASSERT_PRE_COMP_DESCR_SET_NON_NULL(_comp_descr_set) \ | |
1778c2a4 PP |
882 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_DESCR_SET_ID, \ |
883 | (_comp_descr_set), _BT_ASSERT_PRE_COMP_DESCR_SET_NAME) | |
2bdc32f7 PP |
884 | |
885 | #define BT_ASSERT_PRE_DEV_COMP_DESCR_SET_NON_NULL(_comp_descr_set) \ | |
1778c2a4 PP |
886 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_DESCR_SET_ID, \ |
887 | (_comp_descr_set), _BT_ASSERT_PRE_COMP_DESCR_SET_NAME) | |
2bdc32f7 PP |
888 | |
889 | #define _BT_ASSERT_PRE_COMP_NAME "Component" | |
1778c2a4 PP |
890 | #define _BT_ASSERT_PRE_COMP_ID "component" |
891 | ||
892 | #define BT_ASSERT_PRE_COMP_NON_NULL_FROM_FUNC(_func, _comp) \ | |
893 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_COMP_ID, \ | |
894 | (_comp), _BT_ASSERT_PRE_COMP_NAME) | |
2bdc32f7 PP |
895 | |
896 | #define BT_ASSERT_PRE_COMP_NON_NULL(_comp) \ | |
1778c2a4 PP |
897 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_ID, (_comp), \ |
898 | _BT_ASSERT_PRE_COMP_NAME) | |
899 | ||
900 | #define BT_ASSERT_PRE_DEV_COMP_NON_NULL_FROM_FUNC(_func, _comp) \ | |
901 | BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \ | |
902 | _BT_ASSERT_PRE_COMP_ID, (_comp), _BT_ASSERT_PRE_COMP_NAME) | |
2bdc32f7 PP |
903 | |
904 | #define BT_ASSERT_PRE_DEV_COMP_NON_NULL(_comp) \ | |
1778c2a4 PP |
905 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_ID, (_comp), \ |
906 | _BT_ASSERT_PRE_COMP_NAME) | |
2bdc32f7 PP |
907 | |
908 | #define _BT_ASSERT_PRE_CONN_NAME "Connection" | |
1778c2a4 | 909 | #define _BT_ASSERT_PRE_CONN_ID "connection" |
2bdc32f7 PP |
910 | |
911 | #define BT_ASSERT_PRE_CONN_NON_NULL(_conn) \ | |
1778c2a4 PP |
912 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CONN_ID, (_conn), \ |
913 | _BT_ASSERT_PRE_CONN_NAME) | |
2bdc32f7 PP |
914 | |
915 | #define BT_ASSERT_PRE_DEV_CONN_NON_NULL(_conn) \ | |
1778c2a4 PP |
916 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CONN_ID, (_conn), \ |
917 | _BT_ASSERT_PRE_CONN_NAME) | |
2bdc32f7 PP |
918 | |
919 | #define _BT_ASSERT_PRE_GRAPH_NAME "Graph" | |
1778c2a4 PP |
920 | #define _BT_ASSERT_PRE_GRAPH_ID "graph" |
921 | ||
922 | #define BT_ASSERT_PRE_GRAPH_NON_NULL_FROM_FUNC(_func, _graph) \ | |
923 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \ | |
924 | _BT_ASSERT_PRE_GRAPH_ID, (_graph), _BT_ASSERT_PRE_GRAPH_NAME) | |
2bdc32f7 PP |
925 | |
926 | #define BT_ASSERT_PRE_GRAPH_NON_NULL(_graph) \ | |
1778c2a4 PP |
927 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_GRAPH_ID, (_graph), \ |
928 | _BT_ASSERT_PRE_GRAPH_NAME) | |
2bdc32f7 PP |
929 | |
930 | #define BT_ASSERT_PRE_DEV_GRAPH_NON_NULL(_graph) \ | |
1778c2a4 PP |
931 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_GRAPH_ID, (_graph), \ |
932 | _BT_ASSERT_PRE_GRAPH_NAME) | |
2bdc32f7 PP |
933 | |
934 | #define _BT_ASSERT_PRE_INTR_NAME "Interrupter" | |
1778c2a4 | 935 | #define _BT_ASSERT_PRE_INTR_ID "interrupter" |
2bdc32f7 PP |
936 | |
937 | #define BT_ASSERT_PRE_INTR_NON_NULL(_intr) \ | |
1778c2a4 PP |
938 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INTR_ID, (_intr), \ |
939 | _BT_ASSERT_PRE_INTR_NAME) | |
2bdc32f7 PP |
940 | |
941 | #define BT_ASSERT_PRE_DEV_INTR_NON_NULL(_intr) \ | |
1778c2a4 PP |
942 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INTR_ID, (_intr), \ |
943 | _BT_ASSERT_PRE_INTR_NAME) | |
2bdc32f7 PP |
944 | |
945 | #define _BT_ASSERT_PRE_PORT_NAME "Port" | |
1778c2a4 | 946 | #define _BT_ASSERT_PRE_PORT_ID "port" |
2bdc32f7 PP |
947 | |
948 | #define BT_ASSERT_PRE_PORT_NON_NULL(_port) \ | |
1778c2a4 PP |
949 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PORT_ID, (_port), \ |
950 | _BT_ASSERT_PRE_PORT_NAME) | |
2bdc32f7 PP |
951 | |
952 | #define BT_ASSERT_PRE_DEV_PORT_NON_NULL(_port) \ | |
1778c2a4 PP |
953 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PORT_ID, (_port), \ |
954 | _BT_ASSERT_PRE_PORT_NAME) | |
2bdc32f7 PP |
955 | |
956 | #define _BT_ASSERT_PRE_QUERY_EXEC_NAME "Query executor" | |
1778c2a4 | 957 | #define _BT_ASSERT_PRE_QUERY_EXEC_ID "query-executor" |
2bdc32f7 PP |
958 | |
959 | #define BT_ASSERT_PRE_QUERY_EXEC_NON_NULL(_query_exec) \ | |
1778c2a4 PP |
960 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_QUERY_EXEC_ID, \ |
961 | (_query_exec), _BT_ASSERT_PRE_QUERY_EXEC_NAME) | |
2bdc32f7 PP |
962 | |
963 | #define BT_ASSERT_PRE_DEV_QUERY_EXEC_NON_NULL(_query_exec) \ | |
1778c2a4 PP |
964 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_QUERY_EXEC_ID, \ |
965 | (_query_exec), _BT_ASSERT_PRE_QUERY_EXEC_NAME) | |
2bdc32f7 PP |
966 | |
967 | #define _BT_ASSERT_PRE_PLUGIN_SET_NAME "Plugin set" | |
1778c2a4 | 968 | #define _BT_ASSERT_PRE_PLUGIN_SET_ID "plugin-set" |
2bdc32f7 PP |
969 | |
970 | #define BT_ASSERT_PRE_PLUGIN_SET_NON_NULL(_plugin_set) \ | |
1778c2a4 PP |
971 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_ID, \ |
972 | (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_NAME) | |
2bdc32f7 PP |
973 | |
974 | #define BT_ASSERT_PRE_DEV_PLUGIN_SET_NON_NULL(_plugin_set) \ | |
1778c2a4 PP |
975 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_ID, \ |
976 | (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_NAME) | |
2bdc32f7 PP |
977 | |
978 | #define _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME \ | |
979 | _BT_ASSERT_PRE_PLUGIN_SET_NAME " (output)" | |
1778c2a4 PP |
980 | #define _BT_ASSERT_PRE_PLUGIN_SET_OUT_ID \ |
981 | _BT_ASSERT_PRE_PLUGIN_SET_ID "-output" | |
2bdc32f7 PP |
982 | |
983 | #define BT_ASSERT_PRE_PLUGIN_SET_OUT_NON_NULL(_plugin_set) \ | |
1778c2a4 PP |
984 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_OUT_ID, \ |
985 | (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME) | |
2bdc32f7 PP |
986 | |
987 | #define BT_ASSERT_PRE_DEV_PLUGIN_SET_OUT_NON_NULL(_plugin_set) \ | |
1778c2a4 PP |
988 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_OUT_ID, \ |
989 | (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME) | |
2bdc32f7 PP |
990 | |
991 | #define _BT_ASSERT_PRE_PLUGIN_NAME "Plugin" | |
1778c2a4 | 992 | #define _BT_ASSERT_PRE_PLUGIN_ID "plugin" |
2bdc32f7 PP |
993 | |
994 | #define BT_ASSERT_PRE_PLUGIN_NON_NULL(_plugin) \ | |
1778c2a4 PP |
995 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_ID, (_plugin), \ |
996 | _BT_ASSERT_PRE_PLUGIN_NAME) | |
2bdc32f7 PP |
997 | |
998 | #define BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(_plugin) \ | |
1778c2a4 PP |
999 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_ID, (_plugin), \ |
1000 | _BT_ASSERT_PRE_PLUGIN_NAME) | |
2bdc32f7 PP |
1001 | |
1002 | #define _BT_ASSERT_PRE_PLUGIN_OUT_NAME \ | |
1003 | _BT_ASSERT_PRE_PLUGIN_NAME " (output)" | |
1778c2a4 PP |
1004 | #define _BT_ASSERT_PRE_PLUGIN_OUT_ID \ |
1005 | _BT_ASSERT_PRE_PLUGIN_ID "-output" | |
2bdc32f7 PP |
1006 | |
1007 | #define BT_ASSERT_PRE_PLUGIN_OUT_NON_NULL(_plugin) \ | |
1778c2a4 PP |
1008 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_OUT_ID, (_plugin), \ |
1009 | _BT_ASSERT_PRE_PLUGIN_OUT_NAME) | |
2bdc32f7 PP |
1010 | |
1011 | #define BT_ASSERT_PRE_DEV_PLUGIN_OUT_NON_NULL(_plugin) \ | |
1778c2a4 PP |
1012 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_OUT_ID, \ |
1013 | (_plugin), _BT_ASSERT_PRE_PLUGIN_OUT_NAME) | |
2bdc32f7 PP |
1014 | |
1015 | #define _BT_ASSERT_PRE_ERROR_NAME "Error" | |
1778c2a4 | 1016 | #define _BT_ASSERT_PRE_ERROR_ID "error" |
2bdc32f7 PP |
1017 | |
1018 | #define BT_ASSERT_PRE_ERROR_NON_NULL(_error) \ | |
1778c2a4 PP |
1019 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_ERROR_ID, (_error), \ |
1020 | _BT_ASSERT_PRE_ERROR_NAME) | |
2bdc32f7 PP |
1021 | |
1022 | #define BT_ASSERT_PRE_DEV_ERROR_NON_NULL(_error) \ | |
1778c2a4 PP |
1023 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_ERROR_ID, (_error), \ |
1024 | _BT_ASSERT_PRE_ERROR_NAME) | |
2bdc32f7 PP |
1025 | |
1026 | #define _BT_ASSERT_PRE_ERROR_CAUSE_NAME "Error cause" | |
1778c2a4 | 1027 | #define _BT_ASSERT_PRE_ERROR_CAUSE_ID "error-cause" |
2bdc32f7 PP |
1028 | |
1029 | #define BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(_error_cause) \ | |
1778c2a4 PP |
1030 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_ERROR_CAUSE_ID, \ |
1031 | (_error_cause), _BT_ASSERT_PRE_ERROR_CAUSE_NAME) | |
2bdc32f7 PP |
1032 | |
1033 | #define BT_ASSERT_PRE_DEV_ERROR_CAUSE_NON_NULL(_error_cause) \ | |
1778c2a4 PP |
1034 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_ERROR_CAUSE_ID, \ |
1035 | (_error_cause), _BT_ASSERT_PRE_ERROR_CAUSE_NAME) | |
2bdc32f7 PP |
1036 | |
1037 | #define _BT_ASSERT_PRE_INT_RANGE_NAME "Integer range" | |
1778c2a4 | 1038 | #define _BT_ASSERT_PRE_INT_RANGE_ID "integer-range" |
2bdc32f7 PP |
1039 | |
1040 | #define BT_ASSERT_PRE_INT_RANGE_NON_NULL(_int_range) \ | |
1778c2a4 PP |
1041 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_ID, \ |
1042 | (_int_range), _BT_ASSERT_PRE_INT_RANGE_NAME) | |
2bdc32f7 PP |
1043 | |
1044 | #define BT_ASSERT_PRE_DEV_INT_RANGE_NON_NULL(_int_range) \ | |
1778c2a4 PP |
1045 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_ID, \ |
1046 | (_int_range), _BT_ASSERT_PRE_INT_RANGE_NAME) | |
1047 | ||
1048 | #define BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY_FROM_FUNC(_func, _range_set) \ | |
1049 | BT_ASSERT_PRE_FROM_FUNC(_func, "integer-range-set-is-not-empty", \ | |
1050 | (_range_set)->ranges->len > 0, \ | |
1051 | "Integer range set is empty: %!+R", (_range_set)) | |
1052 | ||
1053 | #define BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY(_range_set) \ | |
1054 | BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY_FROM_FUNC(__func__, \ | |
1055 | (_range_set)) | |
2bdc32f7 PP |
1056 | |
1057 | #define _BT_ASSERT_PRE_INT_RANGE_SET_NAME "Integer range set" | |
1778c2a4 | 1058 | #define _BT_ASSERT_PRE_INT_RANGE_SET_ID "integer-range-set" |
2bdc32f7 | 1059 | |
1778c2a4 PP |
1060 | #define BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL_FROM_FUNC(_func, _range_set) \ |
1061 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \ | |
1062 | _BT_ASSERT_PRE_INT_RANGE_SET_ID, (_range_set), \ | |
1063 | _BT_ASSERT_PRE_INT_RANGE_SET_NAME) | |
2bdc32f7 | 1064 | |
1778c2a4 PP |
1065 | #define BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(_range_set) \ |
1066 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_SET_ID, \ | |
1067 | (_range_set), _BT_ASSERT_PRE_INT_RANGE_SET_NAME) | |
1068 | ||
1069 | #define BT_ASSERT_PRE_DEV_INT_RANGE_SET_NON_NULL(_range_set) \ | |
1070 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_SET_ID, \ | |
1071 | (_range_set), _BT_ASSERT_PRE_INT_RANGE_SET_NAME) | |
2bdc32f7 | 1072 | |
0a83319b | 1073 | #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND(_value, _type) \ |
2bdc32f7 PP |
1074 | (((struct bt_value *) (_value))->type == (_type)) |
1075 | ||
0a83319b | 1076 | #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT \ |
2bdc32f7 PP |
1077 | "Value has the wrong type: expected-type=%s, %![value-]+v" |
1078 | ||
1778c2a4 PP |
1079 | #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id) \ |
1080 | "is-" _type_id "-value:" _value_id | |
1081 | ||
1082 | #define BT_ASSERT_PRE_VALUE_HAS_TYPE_FROM_FUNC(_func, _value_id, _value, _type_id, _type) \ | |
1083 | BT_ASSERT_PRE_FROM_FUNC(_func, \ | |
1084 | _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id), \ | |
0a83319b PP |
1085 | _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND((_value), (_type)), \ |
1086 | _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT, \ | |
2bdc32f7 PP |
1087 | bt_common_value_type_string(_type), (_value)) |
1088 | ||
1778c2a4 PP |
1089 | #define BT_ASSERT_PRE_VALUE_HAS_TYPE(_value_id, _value, _type_id, _type) \ |
1090 | BT_ASSERT_PRE_VALUE_HAS_TYPE_FROM_FUNC(__func__, _value_id, \ | |
1091 | (_value), _type_id, (_type)); | |
1092 | ||
1093 | #define BT_ASSERT_PRE_VALUE_IS_BOOL(_value) \ | |
1094 | BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \ | |
1095 | "boolean", BT_VALUE_TYPE_BOOL); | |
1096 | ||
1097 | #define BT_ASSERT_PRE_VALUE_IS_UNSIGNED_INT(_value) \ | |
1098 | BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \ | |
1099 | "unsigned-int", BT_VALUE_TYPE_UNSIGNED_INTEGER); | |
1100 | ||
1101 | #define BT_ASSERT_PRE_VALUE_IS_SIGNED_INT(_value) \ | |
1102 | BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \ | |
1103 | "signed-int", BT_VALUE_TYPE_SIGNED_INTEGER); | |
1104 | ||
1105 | #define BT_ASSERT_PRE_VALUE_IS_REAL(_value) \ | |
1106 | BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \ | |
1107 | "real", BT_VALUE_TYPE_REAL); | |
1108 | ||
1109 | #define BT_ASSERT_PRE_VALUE_IS_STRING(_value) \ | |
1110 | BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \ | |
1111 | "string", BT_VALUE_TYPE_STRING); | |
1112 | ||
1113 | #define BT_ASSERT_PRE_VALUE_IS_ARRAY(_value) \ | |
1114 | BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \ | |
1115 | "array", BT_VALUE_TYPE_ARRAY); | |
1116 | ||
1117 | #define BT_ASSERT_PRE_VALUE_IS_MAP_FROM_FUNC(_func, _value) \ | |
1118 | BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \ | |
1119 | "map", BT_VALUE_TYPE_MAP); | |
1120 | ||
1121 | #define BT_ASSERT_PRE_VALUE_IS_MAP(_value) \ | |
1122 | BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \ | |
1123 | "map", BT_VALUE_TYPE_MAP); | |
1124 | ||
1125 | #define BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(_value_id, _value, _type_id, _type) \ | |
2bdc32f7 | 1126 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 1127 | _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id), \ |
0a83319b PP |
1128 | _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND((_value), (_type)), \ |
1129 | _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT, \ | |
2bdc32f7 PP |
1130 | bt_common_value_type_string(_type), (_value)) |
1131 | ||
1778c2a4 PP |
1132 | #define BT_ASSERT_PRE_DEV_VALUE_IS_BOOL(_value) \ |
1133 | BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \ | |
1134 | "boolean", BT_VALUE_TYPE_BOOL); | |
1135 | ||
1136 | #define BT_ASSERT_PRE_DEV_VALUE_IS_UNSIGNED_INT(_value) \ | |
1137 | BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \ | |
1138 | "unsigned-int", BT_VALUE_TYPE_UNSIGNED_INTEGER); | |
1139 | ||
1140 | #define BT_ASSERT_PRE_DEV_VALUE_IS_SIGNED_INT(_value) \ | |
1141 | BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \ | |
1142 | "signed-int", BT_VALUE_TYPE_SIGNED_INTEGER); | |
1143 | ||
1144 | #define BT_ASSERT_PRE_DEV_VALUE_IS_REAL(_value) \ | |
1145 | BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \ | |
1146 | "real", BT_VALUE_TYPE_REAL); | |
1147 | ||
1148 | #define BT_ASSERT_PRE_DEV_VALUE_IS_STRING(_value) \ | |
1149 | BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \ | |
1150 | "string", BT_VALUE_TYPE_STRING); | |
1151 | ||
1152 | #define BT_ASSERT_PRE_DEV_VALUE_IS_ARRAY(_value) \ | |
1153 | BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \ | |
1154 | "array", BT_VALUE_TYPE_ARRAY); | |
1155 | ||
1156 | #define BT_ASSERT_PRE_DEV_VALUE_IS_MAP(_value) \ | |
1157 | BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \ | |
1158 | "map", BT_VALUE_TYPE_MAP); | |
1159 | ||
2bdc32f7 | 1160 | #define _BT_ASSERT_PRE_VALUE_NAME "Value object" |
1778c2a4 PP |
1161 | #define _BT_ASSERT_PRE_VALUE_ID "value-object" |
1162 | ||
1163 | #define BT_ASSERT_PRE_VALUE_NON_NULL_FROM_FUNC(_func, _value) \ | |
1164 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \ | |
1165 | _BT_ASSERT_PRE_VALUE_ID, (_value), _BT_ASSERT_PRE_VALUE_NAME) | |
2bdc32f7 PP |
1166 | |
1167 | #define BT_ASSERT_PRE_VALUE_NON_NULL(_value) \ | |
1778c2a4 PP |
1168 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_VALUE_ID, (_value), \ |
1169 | _BT_ASSERT_PRE_VALUE_NAME) | |
1170 | ||
1171 | #define BT_ASSERT_PRE_DEV_VALUE_NON_NULL_FROM_FUNC(_func, _value) \ | |
1172 | BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \ | |
1173 | _BT_ASSERT_PRE_VALUE_ID, (_value), _BT_ASSERT_PRE_VALUE_NAME) | |
2bdc32f7 PP |
1174 | |
1175 | #define BT_ASSERT_PRE_DEV_VALUE_NON_NULL(_value) \ | |
1778c2a4 PP |
1176 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_VALUE_ID, (_value), \ |
1177 | _BT_ASSERT_PRE_VALUE_NAME) | |
1178 | ||
1179 | #define BT_ASSERT_PRE_PARAM_VALUE_IS_MAP_FROM_FUNC(_func, _value) \ | |
1180 | BT_ASSERT_PRE_FROM_FUNC(_func, \ | |
1181 | "is-map-value:parameters-value-object", \ | |
1182 | !(_value) || bt_value_is_map(_value), \ | |
1183 | "Parameters value object is not a map value: %!+v", (_value)); | |
2bdc32f7 PP |
1184 | |
1185 | #define BT_ASSERT_PRE_PARAM_VALUE_IS_MAP(_value) \ | |
1778c2a4 | 1186 | BT_ASSERT_PRE_PARAM_VALUE_IS_MAP_FROM_FUNC(__func__, (_value)) |
2bdc32f7 PP |
1187 | |
1188 | #define _BT_ASSERT_PRE_RES_OUT_NAME "Result (output)" | |
1778c2a4 | 1189 | #define _BT_ASSERT_PRE_RES_OUT_ID "result-output" |
2bdc32f7 PP |
1190 | |
1191 | #define BT_ASSERT_PRE_RES_OUT_NON_NULL(_res) \ | |
1778c2a4 PP |
1192 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_RES_OUT_ID, (_res), \ |
1193 | _BT_ASSERT_PRE_RES_OUT_NAME) | |
2bdc32f7 PP |
1194 | |
1195 | #define BT_ASSERT_PRE_DEV_RES_OUT_NON_NULL(_res) \ | |
1778c2a4 PP |
1196 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_RES_OUT_ID, (_res), \ |
1197 | _BT_ASSERT_PRE_RES_OUT_NAME) | |
2bdc32f7 PP |
1198 | |
1199 | #define BT_ASSERT_PRE_METHOD_NON_NULL(_method) \ | |
1778c2a4 | 1200 | BT_ASSERT_PRE_NON_NULL("method", (_method), "Method"); |
2bdc32f7 PP |
1201 | |
1202 | #define _BT_ASSERT_PRE_NAME_NAME "Name" | |
1778c2a4 PP |
1203 | #define _BT_ASSERT_PRE_NAME_ID "name" |
1204 | ||
1205 | #define BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(_func, _name) \ | |
1206 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_NAME_ID, \ | |
1207 | (_name), _BT_ASSERT_PRE_NAME_NAME) | |
2bdc32f7 PP |
1208 | |
1209 | #define BT_ASSERT_PRE_NAME_NON_NULL(_name) \ | |
1778c2a4 PP |
1210 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_NAME_ID, (_name), \ |
1211 | _BT_ASSERT_PRE_NAME_NAME) | |
1212 | ||
1213 | #define BT_ASSERT_PRE_DEV_NAME_NON_NULL_FROM_FUNC(_func, _name) \ | |
1214 | BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \ | |
1215 | _BT_ASSERT_PRE_NAME_ID, (_name), _BT_ASSERT_PRE_NAME_NAME) | |
2bdc32f7 PP |
1216 | |
1217 | #define BT_ASSERT_PRE_DEV_NAME_NON_NULL(_name) \ | |
1778c2a4 PP |
1218 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_NAME_ID, (_name), \ |
1219 | _BT_ASSERT_PRE_NAME_NAME) | |
2bdc32f7 PP |
1220 | |
1221 | #define _BT_ASSERT_PRE_DESCR_NAME "Description" | |
1778c2a4 | 1222 | #define _BT_ASSERT_PRE_DESCR_ID "description" |
2bdc32f7 PP |
1223 | |
1224 | #define BT_ASSERT_PRE_DESCR_NON_NULL(_descr) \ | |
1778c2a4 PP |
1225 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_DESCR_ID, (_descr), \ |
1226 | _BT_ASSERT_PRE_DESCR_NAME) | |
2bdc32f7 PP |
1227 | |
1228 | #define BT_ASSERT_PRE_DEV_DESCR_NON_NULL(_descr) \ | |
1778c2a4 PP |
1229 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_DESCR_ID, (_descr), \ |
1230 | _BT_ASSERT_PRE_DESCR_NAME) | |
2bdc32f7 PP |
1231 | |
1232 | #define _BT_ASSERT_PRE_UUID_NAME "UUID" | |
1778c2a4 | 1233 | #define _BT_ASSERT_PRE_UUID_ID "uuid" |
2bdc32f7 PP |
1234 | |
1235 | #define BT_ASSERT_PRE_UUID_NON_NULL(_uuid) \ | |
1778c2a4 PP |
1236 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_UUID_ID, (_uuid), \ |
1237 | _BT_ASSERT_PRE_UUID_NAME) | |
2bdc32f7 PP |
1238 | |
1239 | #define BT_ASSERT_PRE_DEV_UUID_NON_NULL(_uuid) \ | |
1778c2a4 PP |
1240 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_UUID_ID, (_uuid), \ |
1241 | _BT_ASSERT_PRE_UUID_NAME) | |
2bdc32f7 PP |
1242 | |
1243 | #define _BT_ASSERT_PRE_KEY_NAME "Key" | |
1778c2a4 PP |
1244 | #define _BT_ASSERT_PRE_KEY_ID "key" |
1245 | ||
1246 | #define BT_ASSERT_PRE_KEY_NON_NULL_FROM_FUNC(_func, _key) \ | |
1247 | BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_KEY_ID, \ | |
1248 | (_key), _BT_ASSERT_PRE_KEY_NAME) | |
2bdc32f7 PP |
1249 | |
1250 | #define BT_ASSERT_PRE_KEY_NON_NULL(_key) \ | |
1778c2a4 PP |
1251 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_KEY_ID, (_key), \ |
1252 | _BT_ASSERT_PRE_KEY_NAME) | |
2bdc32f7 PP |
1253 | |
1254 | #define BT_ASSERT_PRE_DEV_KEY_NON_NULL(_key) \ | |
1778c2a4 PP |
1255 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_KEY_ID, (_key), \ |
1256 | _BT_ASSERT_PRE_KEY_NAME) | |
d98421f2 PP |
1257 | |
1258 | #endif /* BABELTRACE_ASSERT_COND_INTERNAL_H */ |