Fix: lib: pass down API function name to some helpers
[babeltrace.git] / src / lib / assert-cond.h
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
11 #include "assert-cond-base.h"
12
13 /*
14 * Asserts that a given variable `_obj` named `_obj_name` (capitalized)
15 * and having the ID `_obj_id` (within the function's context) is not
16 * `NULL`.
17 */
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)
24
25 /*
26 * Asserts that a given index `_index` is less than a given length
27 * `_length`.
28 */
29 #define BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(_func, _index, _length) \
30 BT_ASSERT_PRE_FROM_FUNC(_func, "valid-index", (_index) < (_length), \
31 "Index is out of bounds: index=%" PRIu64 ", " \
32 "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_length))
33
34 #define BT_ASSERT_PRE_VALID_INDEX(_index, _length) \
35 BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(__func__, (_index), (_length))
36
37 /*
38 * Asserts that the current thread has no error set.
39 */
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); \
49 } while (0)
50
51 #define BT_ASSERT_PRE_NO_ERROR() \
52 BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(__func__)
53
54 /*
55 * Asserts that, if the current thread has an error, `_status` is an
56 * error status code.
57 *
58 * See _BT_ASSERT_COND() for details about the `_func` parameter.
59 *
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 */
63 #define BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \
64 do { \
65 const struct bt_error *_err = bt_current_thread_take_error(); \
66 if (_err) { \
67 bt_current_thread_move_error(_err); \
68 } \
69 BT_ASSERT_POST(_func, "no-error-if-no-error-status", \
70 (_status) < 0 || !_err, \
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.
78 *
79 * See _BT_ASSERT_COND() for details about the `_func` parameter.
80 */
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)
90
91 #ifdef BT_DEV_MODE
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
96 /* Developer mode version of BT_ASSERT_PRE_NON_NULL() */
97 # define BT_ASSERT_PRE_DEV_NON_NULL(_obj_id, _obj, _obj_name) \
98 BT_ASSERT_PRE_NON_NULL(_obj_id, (_obj), (_obj_name))
99
100 /*
101 * Developer mode: asserts that a given object `_obj` named `_obj_name`
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`.
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 */
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))
122
123 /* Developer mode version of BT_ASSERT_PRE_VALID_INDEX() */
124 # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \
125 BT_ASSERT_PRE_VALID_INDEX((_index), (_length))
126
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
131 /* Developer mode version of BT_ASSERT_PRE_NO_ERROR(). */
132 # define BT_ASSERT_PRE_DEV_NO_ERROR() BT_ASSERT_PRE_NO_ERROR()
133
134 /*
135 * Developer mode version of
136 * BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS().
137 */
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))
140
141 /* Developer mode version of BT_ASSERT_POST_NO_ERROR(). */
142 # define BT_ASSERT_POST_DEV_NO_ERROR(_func) \
143 BT_ASSERT_POST_NO_ERROR(_func)
144
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
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)
159
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))
165
166 # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \
167 BT_USE_EXPR2((_index), (_length))
168
169 # define BT_ASSERT_PRE_DEV_NO_ERROR_FROM_FUNC(_func) \
170 BT_USE_EXPR(_func)
171
172 # define BT_ASSERT_PRE_DEV_NO_ERROR()
173
174 # define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \
175 BT_USE_EXPR2(_func, _status)
176
177 # define BT_ASSERT_POST_DEV_NO_ERROR(_func) \
178 BT_USE_EXPR(_func)
179 #endif /* BT_DEV_MODE */
180
181 #define _BT_ASSERT_PRE_CLK_CLS_NAME "Clock class"
182 #define _BT_ASSERT_PRE_CLK_CLS_ID "clock-class"
183
184 #define BT_ASSERT_PRE_CLK_CLS_NON_NULL(_cc) \
185 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CLK_CLS_ID, (_cc), \
186 _BT_ASSERT_PRE_CLK_CLS_NAME)
187
188 #define BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(_cc) \
189 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CLK_CLS_ID, (_cc), \
190 _BT_ASSERT_PRE_CLK_CLS_NAME)
191
192 #define _BT_ASSERT_PRE_DEF_CLK_CLS_NAME "Default clock class"
193 #define _BT_ASSERT_PRE_DEF_CLK_CLS_ID "default-clock-class"
194
195 #define BT_ASSERT_PRE_DEF_CLK_CLS_NON_NULL(_cc) \
196 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_DEF_CLK_CLS_ID, (_cc), \
197 _BT_ASSERT_PRE_DEF_CLK_CLS_NAME)
198
199 #define BT_ASSERT_PRE_DEV_DEF_CLK_CLS_NON_NULL(_cc) \
200 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_DEF_CLK_CLS_ID, \
201 (_cc), _BT_ASSERT_PRE_DEF_CLK_CLS_NAME)
202
203 #define _BT_ASSERT_PRE_CS_NAME "Clock snapshot"
204 #define _BT_ASSERT_PRE_CS_ID "clock-snapshot"
205
206 #define BT_ASSERT_PRE_CS_NON_NULL(_cs) \
207 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CS_ID, (_cs), \
208 _BT_ASSERT_PRE_CS_NAME)
209
210 #define BT_ASSERT_PRE_DEV_CS_NON_NULL(_cs) \
211 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CS_ID, (_cs), \
212 _BT_ASSERT_PRE_CS_NAME)
213
214 #define _BT_ASSERT_PRE_EVENT_NAME "Event"
215 #define _BT_ASSERT_PRE_EVENT_ID "event"
216
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)
220
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)
224
225 #define _BT_ASSERT_PRE_EC_NAME "Event class"
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)
231
232 #define BT_ASSERT_PRE_EC_NON_NULL(_ec) \
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)
239
240 #define BT_ASSERT_PRE_DEV_EC_NON_NULL(_ec) \
241 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_EC_ID, (_ec), \
242 _BT_ASSERT_PRE_EC_NAME)
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
253 #define _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id) "is-int-field-class:" _fc_id
254
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
262 #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id) \
263 "is-unsigned-integer-field-class:" _fc_id
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
272 #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id) \
273 "is-signed-integer-field-class:" _fc_id
274
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
282 #define _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id) \
283 "is-enumeration-field-class:" _fc_id
284
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
293 #define _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id) \
294 "is-array-field-class:" _fc_id
295
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
305 #define _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id) \
306 "is-option-field-class:" _fc_id
307
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
316 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_ID(_fc_id) \
317 "is-option-field-class-with-selector:" _fc_id
318
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
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
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
335 #define _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id) \
336 "is-structure-field-class:" _fc_id
337
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
346 #define _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id) \
347 "is-variant-field-class:" _fc_id
348
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
356 #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id) \
357 "is-variant-field-class-with-selector:" _fc_id
358
359 #define _BT_ASSERT_PRE_FC_HAS_TYPE_COND(_fc, _type) \
360 (((const struct bt_field_class *) (_fc))->type == (_type))
361
362 #define _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name) \
363 _name " has the wrong type: expected-type=%s, %![fc-]+F"
364
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), \
372 _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc))
373
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), \
381 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc))
382
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), \
387 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc))
388
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), \
393 _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc))
394
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), \
399 _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc))
400
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), \
405 _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name), (_fc))
406
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), \
411 _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc))
412
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), \
417 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
418
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), \
423 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc))
424
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), \
429 _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc))
430
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), \
435 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc))
436
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)), \
441 _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name), \
442 bt_common_field_class_type_string(_type), (_fc))
443
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), \
452 _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc))
453
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), \
458 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc))
459
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), \
464 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc))
465
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), \
470 _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc))
471
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), \
476 _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc))
477
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), \
482 _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name), (_fc))
483
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), \
488 _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc))
489
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), \
493 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
494
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), \
499 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc))
500
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), \
505 _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc))
506
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), \
511 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc))
512
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)), \
517 _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name), \
518 bt_common_field_class_type_string(_type), (_fc))
519
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))
527
528 #define _BT_ASSERT_PRE_FC_NAME "Field class"
529 #define _BT_ASSERT_PRE_FC_ID "field-class"
530
531 #define BT_ASSERT_PRE_FC_NON_NULL(_fc) \
532 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FC_ID, (_fc), \
533 _BT_ASSERT_PRE_FC_NAME)
534
535 #define BT_ASSERT_PRE_DEV_FC_NON_NULL(_fc) \
536 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FC_ID, (_fc), \
537 _BT_ASSERT_PRE_FC_NAME)
538
539 #define _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME "Structure field class member"
540 #define _BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID "structure-field-class-member"
541
542 #define BT_ASSERT_PRE_STRUCT_FC_MEMBER_NON_NULL(_fc) \
543 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID, \
544 (_fc), _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME)
545
546 #define BT_ASSERT_PRE_DEV_STRUCT_FC_MEMBER_NON_NULL(_fc) \
547 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID, \
548 (_fc), _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME)
549
550 #define _BT_ASSERT_PRE_VAR_FC_OPT_NAME "Variant field class option"
551 #define _BT_ASSERT_PRE_VAR_FC_OPT_ID "variant-field-class-option-id"
552
553 #define BT_ASSERT_PRE_VAR_FC_OPT_NON_NULL(_fc) \
554 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_VAR_FC_OPT_ID, (_fc), \
555 _BT_ASSERT_PRE_VAR_FC_OPT_NAME)
556
557 #define BT_ASSERT_PRE_DEV_VAR_FC_OPT_NON_NULL(_fc) \
558 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_VAR_FC_OPT_ID, (_fc), \
559 _BT_ASSERT_PRE_VAR_FC_OPT_NAME)
560
561 #define _BT_ASSERT_PRE_FP_NAME "Field path"
562 #define _BT_ASSERT_PRE_FP_ID "field-path"
563
564 #define BT_ASSERT_PRE_FP_NON_NULL(_fp) \
565 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FP_ID, (_fp), \
566 _BT_ASSERT_PRE_FP_NAME)
567
568 #define BT_ASSERT_PRE_DEV_FP_NON_NULL(_fp) \
569 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FP_ID, (_fp), \
570 _BT_ASSERT_PRE_FP_NAME)
571
572 #define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE_FROM_FUNC(_func, _field_id, _field, _cls_type_id, _cls_type, _name) \
573 BT_ASSERT_PRE_DEV_FROM_FUNC(_func, "is-" _cls_type_id ":" _field_id, \
574 ((const struct bt_field *) (_field))->class->type == (_cls_type), \
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
579 #define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(_field_id, _field, _cls_type_id, _cls_type, _name) \
580 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE_FROM_FUNC(__func__, \
581 _field_id, (_field), _cls_type_id, _cls_type, _name)
582
583 #define BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(_field_id, _field, _name) \
584 BT_ASSERT_PRE_DEV( \
585 "is-unsigned-integer-field:" _field_id, \
586 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
587 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, \
588 _name " is not an unsigned integer field: %![field-]+f", \
589 (_field))
590
591 #define BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(_field_id, _field, _name) \
592 BT_ASSERT_PRE_DEV( \
593 "is-signed-integer-field:" _field_id, \
594 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
595 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, \
596 _name " is not a signed integer field: %![field-]+f", \
597 (_field))
598
599 #define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY_FROM_FUNC(_func, _field_id, _field, _name) \
600 BT_ASSERT_PRE_DEV_FROM_FUNC(_func, \
601 "is-array-field:" _field_id, \
602 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
603 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
604 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
605 _name " is not an array field: %![field-]+f", (_field))
606
607 #define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(_field_id, _field, _name) \
608 BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY_FROM_FUNC(__func__, _field_id, \
609 (_field), _name)
610
611 #define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(_field_id, _field, _name) \
612 BT_ASSERT_PRE_DEV( \
613 "is-dynamic-array-field:" _field_id, \
614 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
615 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
616 _name " is not a dynamic array field: %![field-]+f", (_field))
617
618 #define BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(_field_id, _field, _name) \
619 BT_ASSERT_PRE_DEV( \
620 "is-option-field:" _field_id, \
621 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \
622 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
623 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
624 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD, \
625 _name " is not an option field: %![field-]+f", (_field))
626
627 #define BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(_field_id, _field, _name) \
628 BT_ASSERT_PRE_DEV( \
629 "is-variant-field:" _field_id, \
630 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \
631 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
632 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD, \
633 _name " is not a variant field: %![field-]+f", (_field))
634
635 #define BT_ASSERT_PRE_DEV_FIELD_IS_SET(_field_id, _field) \
636 BT_ASSERT_PRE_DEV("is-field-set:" _field_id, \
637 bt_field_is_set(_field), \
638 "Field is not set: %!+f", (_field))
639
640 #define _BT_ASSERT_PRE_FIELD_NAME "Field"
641 #define _BT_ASSERT_PRE_FIELD_ID "field"
642
643 #define BT_ASSERT_PRE_FIELD_NON_NULL(_field) \
644 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field), \
645 _BT_ASSERT_PRE_FIELD_NAME)
646
647 #define BT_ASSERT_PRE_DEV_FIELD_NON_NULL_FROM_FUNC(_func, _field) \
648 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
649 _BT_ASSERT_PRE_FIELD_ID, (_field), \
650 _BT_ASSERT_PRE_FIELD_NAME)
651
652 #define BT_ASSERT_PRE_DEV_FIELD_NON_NULL(_field) \
653 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field), \
654 _BT_ASSERT_PRE_FIELD_NAME)
655
656 #define _BT_ASSERT_PRE_PACKET_NAME "Packet"
657 #define _BT_ASSERT_PRE_PACKET_ID "packet"
658
659 #define BT_ASSERT_PRE_PACKET_NON_NULL_FROM_FUNC(_func, _packet) \
660 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
661 _BT_ASSERT_PRE_PACKET_ID, (_packet), _BT_ASSERT_PRE_PACKET_NAME)
662
663 #define BT_ASSERT_PRE_PACKET_NON_NULL(_packet) \
664 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PACKET_ID, (_packet), \
665 _BT_ASSERT_PRE_PACKET_NAME)
666
667 #define BT_ASSERT_PRE_DEV_PACKET_NON_NULL_FROM_FUNC(_func, _packet) \
668 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
669 _BT_ASSERT_PRE_PACKET_ID, (_packet), _BT_ASSERT_PRE_PACKET_NAME)
670
671 #define BT_ASSERT_PRE_DEV_PACKET_NON_NULL(_packet) \
672 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PACKET_ID, (_packet), \
673 _BT_ASSERT_PRE_PACKET_NAME)
674
675 #define _BT_ASSERT_PRE_SC_NAME "Stream class"
676 #define _BT_ASSERT_PRE_SC_ID "stream-class"
677
678 #define BT_ASSERT_PRE_SC_NON_NULL(_sc) \
679 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_SC_ID, (_sc), \
680 _BT_ASSERT_PRE_SC_NAME)
681
682 #define BT_ASSERT_PRE_DEV_SC_NON_NULL(_sc) \
683 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_SC_ID, (_sc), \
684 _BT_ASSERT_PRE_SC_NAME)
685
686 #define _BT_ASSERT_PRE_STREAM_NAME "Stream"
687 #define _BT_ASSERT_PRE_STREAM_ID "stream"
688
689 #define BT_ASSERT_PRE_STREAM_NON_NULL_FROM_FUNC(_func, _stream) \
690 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
691 _BT_ASSERT_PRE_STREAM_ID, (_stream), \
692 _BT_ASSERT_PRE_STREAM_NAME)
693
694 #define BT_ASSERT_PRE_STREAM_NON_NULL(_stream) \
695 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_STREAM_ID, (_stream), \
696 _BT_ASSERT_PRE_STREAM_NAME)
697
698 #define BT_ASSERT_PRE_DEV_STREAM_NON_NULL_FROM_FUNC(_func, _stream) \
699 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
700 _BT_ASSERT_PRE_STREAM_ID, (_stream), \
701 _BT_ASSERT_PRE_STREAM_NAME)
702
703 #define BT_ASSERT_PRE_DEV_STREAM_NON_NULL(_stream) \
704 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_STREAM_ID, (_stream), \
705 _BT_ASSERT_PRE_STREAM_NAME)
706
707 #define _BT_ASSERT_PRE_TC_NAME "Trace class"
708 #define _BT_ASSERT_PRE_TC_ID "trace-class"
709
710 #define BT_ASSERT_PRE_TC_NON_NULL_FROM_FUNC(_func, _tc) \
711 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_TC_ID, \
712 (_tc), _BT_ASSERT_PRE_TC_NAME)
713
714 #define BT_ASSERT_PRE_TC_NON_NULL(_tc) \
715 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_TC_ID, (_tc), \
716 _BT_ASSERT_PRE_TC_NAME)
717
718 #define BT_ASSERT_PRE_DEV_TC_NON_NULL(_tc) \
719 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_TC_ID, (_tc), \
720 _BT_ASSERT_PRE_TC_NAME)
721
722 #define _BT_ASSERT_PRE_TRACE_NAME "Trace"
723 #define _BT_ASSERT_PRE_TRACE_ID "trace"
724
725 #define BT_ASSERT_PRE_TRACE_NON_NULL(_trace) \
726 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_TRACE_ID, (_trace), \
727 _BT_ASSERT_PRE_TRACE_NAME)
728
729 #define BT_ASSERT_PRE_DEV_TRACE_NON_NULL(_trace) \
730 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_TRACE_ID, (_trace), \
731 _BT_ASSERT_PRE_TRACE_NAME)
732
733 #define _BT_ASSERT_PRE_USER_ATTRS_NAME "User attributes value object"
734 #define _BT_ASSERT_PRE_USER_ATTRS_ID "user-attributes-value-object"
735
736 #define BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(_func, _ua) \
737 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
738 _BT_ASSERT_PRE_USER_ATTRS_ID, (_ua), \
739 _BT_ASSERT_PRE_USER_ATTRS_NAME)
740
741 #define BT_ASSERT_PRE_USER_ATTRS_NON_NULL(_ua) \
742 BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(__func__, (_ua))
743
744 #define BT_ASSERT_PRE_DEV_USER_ATTRS_NON_NULL(_ua) \
745 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_USER_ATTRS_ID, (_ua), \
746 _BT_ASSERT_PRE_USER_ATTRS_NAME)
747
748 #define BT_ASSERT_PRE_USER_ATTRS_IS_MAP_FROM_FUNC(_func, _ua) \
749 BT_ASSERT_PRE_FROM_FUNC(_func, "is-map-value:user-attributes", \
750 (_ua)->type == BT_VALUE_TYPE_MAP, \
751 _BT_ASSERT_PRE_USER_ATTRS_NAME \
752 " object is not a map value object.")
753
754 #define BT_ASSERT_PRE_USER_ATTRS_IS_MAP(_ua) \
755 BT_ASSERT_PRE_USER_ATTRS_IS_MAP_FROM_FUNC(__func__, (_ua))
756
757 #define BT_ASSERT_COND_LISTENER_FUNC_NAME "Listener function"
758 #define BT_ASSERT_COND_LISTENER_FUNC_ID "listener-function"
759
760 #define BT_ASSERT_PRE_LISTENER_FUNC_NON_NULL(_listener_func) \
761 BT_ASSERT_PRE_NON_NULL(BT_ASSERT_COND_LISTENER_FUNC_ID, \
762 (_listener_func), BT_ASSERT_COND_LISTENER_FUNC_NAME)
763
764 #define BT_ASSERT_PRE_DEV_LISTENER_FUNC_NON_NULL(_listener_func) \
765 BT_ASSERT_PRE_DEV_NON_NULL(BT_ASSERT_COND_LISTENER_FUNC_ID, \
766 (_listener_func), BT_ASSERT_COND_LISTENER_FUNC_NAME)
767
768 #define _BT_ASSERT_PRE_MSG_ITER_NAME "Message iterator"
769 #define _BT_ASSERT_PRE_MSG_ITER_ID "message-iterator"
770
771 #define BT_ASSERT_PRE_MSG_ITER_NON_NULL_FROM_FUNC(_func, _msg_iter) \
772 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
773 _BT_ASSERT_PRE_MSG_ITER_ID, (_msg_iter), \
774 _BT_ASSERT_PRE_MSG_ITER_NAME)
775
776 #define BT_ASSERT_PRE_MSG_ITER_NON_NULL(_msg_iter) \
777 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_ID, (_msg_iter), \
778 _BT_ASSERT_PRE_MSG_ITER_NAME)
779
780 #define BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL_FROM_FUNC(_func, _msg_iter) \
781 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
782 _BT_ASSERT_PRE_MSG_ITER_ID, \
783 (_msg_iter), _BT_ASSERT_PRE_MSG_ITER_NAME)
784
785 #define BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL(_msg_iter) \
786 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_ID, \
787 (_msg_iter), _BT_ASSERT_PRE_MSG_ITER_NAME)
788
789 #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc) \
790 ((_sc)->default_clock_class)
791
792 #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT \
793 "Message's stream's class has no default clock class: " \
794 "%![msg-]+n, %![sc-]+S"
795
796 #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID \
797 "message-stream-class-has-default-clock-class"
798
799 #define BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FROM_FUNC(_func, _msg, _sc) \
800 BT_ASSERT_PRE_FROM_FUNC(_func, \
801 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID, \
802 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc), \
803 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT, \
804 (_msg), (_sc));
805
806 #define BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS(_msg, _sc) \
807 BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FROM_FUNC(__func__, (_msg), (_sc))
808
809 #define BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(_func, _msg, _sc) \
810 BT_ASSERT_PRE_DEV_FROM_FUNC(_func, \
811 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID, \
812 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc), \
813 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT, \
814 (_msg), (_sc));
815
816 #define BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS(_msg, _sc) \
817 BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(__func__, (_msg), (_sc))
818
819 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_COND(_msg, _type) \
820 (((struct bt_message *) (_msg))->type == (_type))
821
822 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT \
823 "Message has the wrong type: expected-type=%s, %![msg-]+n"
824
825 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id) \
826 "is-" _type_id "-message:" _msg_id
827
828 #define BT_ASSERT_PRE_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type) \
829 BT_ASSERT_PRE( \
830 _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id), \
831 _BT_ASSERT_PRE_MSG_HAS_TYPE_COND((_msg), (_type)), \
832 _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT, \
833 bt_common_message_type_string(_type), (_msg))
834
835 #define BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type) \
836 BT_ASSERT_PRE_DEV( \
837 _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id), \
838 _BT_ASSERT_PRE_MSG_HAS_TYPE_COND((_msg), (_type)), \
839 _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT, \
840 bt_common_message_type_string(_type), (_msg))
841
842 #define _BT_ASSERT_PRE_MSG_NAME "Message"
843 #define _BT_ASSERT_PRE_MSG_ID "message"
844
845 #define BT_ASSERT_PRE_MSG_NON_NULL(_msg_iter) \
846 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ID, (_msg_iter), \
847 _BT_ASSERT_PRE_MSG_NAME)
848
849 #define BT_ASSERT_PRE_DEV_MSG_NON_NULL(_msg_iter) \
850 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ID, (_msg_iter), \
851 _BT_ASSERT_PRE_MSG_NAME)
852
853 #define BT_ASSERT_PRE_MSG_CS_BEGIN_LE_END(_msg_iter, _begin, _end) \
854 BT_ASSERT_PRE("beginning-default-clock-snapshot-lteq-end", \
855 (_begin) <= (_end), \
856 "Beginning default clock snapshot value is greater " \
857 "than end default clock snapshot value: " \
858 "cs-begin-val=%" PRIu64 ", cs-end-val=%" PRIu64 ", " \
859 "%![msg-iter-]+i", (_begin), (_end), _msg_iter);
860
861 #define BT_ASSERT_PRE_DEV_MSG_HOT(_msg) \
862 BT_ASSERT_PRE_DEV_HOT("message", (_msg), "Message", ": %!+n", (_msg));
863
864 #define _BT_ASSERT_PRE_MSG_ITER_CLS_NAME "Message iterator class"
865 #define _BT_ASSERT_PRE_MSG_ITER_CLS_ID "message-iterator-class"
866
867 #define BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(_msg_iter_cls) \
868 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_CLS_ID, \
869 (_msg_iter_cls), _BT_ASSERT_PRE_MSG_ITER_CLS_NAME)
870
871 #define BT_ASSERT_PRE_DEV_MSG_ITER_CLS_NON_NULL(_msg_iter_cls) \
872 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_CLS_ID, \
873 (_msg_iter_cls), _BT_ASSERT_PRE_MSG_ITER_CLS_NAME)
874
875 #define _BT_ASSERT_PRE_COMP_CLS_NAME "Component class"
876 #define _BT_ASSERT_PRE_COMP_CLS_ID "component-class"
877
878 #define BT_ASSERT_PRE_COMP_CLS_NON_NULL_FROM_FUNC(_func, _comp_cls) \
879 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
880 _BT_ASSERT_PRE_COMP_CLS_ID, (_comp_cls), \
881 _BT_ASSERT_PRE_COMP_CLS_NAME)
882
883 #define BT_ASSERT_PRE_COMP_CLS_NON_NULL(_comp_cls) \
884 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_CLS_ID, (_comp_cls), \
885 _BT_ASSERT_PRE_COMP_CLS_NAME)
886
887 #define BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(_comp_cls) \
888 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_CLS_ID, \
889 (_comp_cls), _BT_ASSERT_PRE_COMP_CLS_NAME)
890
891 #define _BT_ASSERT_PRE_COMP_DESCR_SET_NAME "Component descriptor set"
892 #define _BT_ASSERT_PRE_COMP_DESCR_SET_ID "component-descriptor-set"
893
894 #define BT_ASSERT_PRE_COMP_DESCR_SET_NON_NULL(_comp_descr_set) \
895 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_DESCR_SET_ID, \
896 (_comp_descr_set), _BT_ASSERT_PRE_COMP_DESCR_SET_NAME)
897
898 #define BT_ASSERT_PRE_DEV_COMP_DESCR_SET_NON_NULL(_comp_descr_set) \
899 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_DESCR_SET_ID, \
900 (_comp_descr_set), _BT_ASSERT_PRE_COMP_DESCR_SET_NAME)
901
902 #define _BT_ASSERT_PRE_COMP_NAME "Component"
903 #define _BT_ASSERT_PRE_COMP_ID "component"
904
905 #define BT_ASSERT_PRE_COMP_NON_NULL_FROM_FUNC(_func, _comp) \
906 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_COMP_ID, \
907 (_comp), _BT_ASSERT_PRE_COMP_NAME)
908
909 #define BT_ASSERT_PRE_COMP_NON_NULL(_comp) \
910 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_ID, (_comp), \
911 _BT_ASSERT_PRE_COMP_NAME)
912
913 #define BT_ASSERT_PRE_DEV_COMP_NON_NULL_FROM_FUNC(_func, _comp) \
914 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
915 _BT_ASSERT_PRE_COMP_ID, (_comp), _BT_ASSERT_PRE_COMP_NAME)
916
917 #define BT_ASSERT_PRE_DEV_COMP_NON_NULL(_comp) \
918 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_ID, (_comp), \
919 _BT_ASSERT_PRE_COMP_NAME)
920
921 #define _BT_ASSERT_PRE_CONN_NAME "Connection"
922 #define _BT_ASSERT_PRE_CONN_ID "connection"
923
924 #define BT_ASSERT_PRE_CONN_NON_NULL(_conn) \
925 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CONN_ID, (_conn), \
926 _BT_ASSERT_PRE_CONN_NAME)
927
928 #define BT_ASSERT_PRE_DEV_CONN_NON_NULL(_conn) \
929 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CONN_ID, (_conn), \
930 _BT_ASSERT_PRE_CONN_NAME)
931
932 #define _BT_ASSERT_PRE_GRAPH_NAME "Graph"
933 #define _BT_ASSERT_PRE_GRAPH_ID "graph"
934
935 #define BT_ASSERT_PRE_GRAPH_NON_NULL_FROM_FUNC(_func, _graph) \
936 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
937 _BT_ASSERT_PRE_GRAPH_ID, (_graph), _BT_ASSERT_PRE_GRAPH_NAME)
938
939 #define BT_ASSERT_PRE_GRAPH_NON_NULL(_graph) \
940 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_GRAPH_ID, (_graph), \
941 _BT_ASSERT_PRE_GRAPH_NAME)
942
943 #define BT_ASSERT_PRE_DEV_GRAPH_NON_NULL(_graph) \
944 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_GRAPH_ID, (_graph), \
945 _BT_ASSERT_PRE_GRAPH_NAME)
946
947 #define _BT_ASSERT_PRE_INTR_NAME "Interrupter"
948 #define _BT_ASSERT_PRE_INTR_ID "interrupter"
949
950 #define BT_ASSERT_PRE_INTR_NON_NULL(_intr) \
951 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INTR_ID, (_intr), \
952 _BT_ASSERT_PRE_INTR_NAME)
953
954 #define BT_ASSERT_PRE_DEV_INTR_NON_NULL(_intr) \
955 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INTR_ID, (_intr), \
956 _BT_ASSERT_PRE_INTR_NAME)
957
958 #define _BT_ASSERT_PRE_PORT_NAME "Port"
959 #define _BT_ASSERT_PRE_PORT_ID "port"
960
961 #define BT_ASSERT_PRE_PORT_NON_NULL(_port) \
962 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PORT_ID, (_port), \
963 _BT_ASSERT_PRE_PORT_NAME)
964
965 #define BT_ASSERT_PRE_DEV_PORT_NON_NULL(_port) \
966 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PORT_ID, (_port), \
967 _BT_ASSERT_PRE_PORT_NAME)
968
969 #define _BT_ASSERT_PRE_QUERY_EXEC_NAME "Query executor"
970 #define _BT_ASSERT_PRE_QUERY_EXEC_ID "query-executor"
971
972 #define BT_ASSERT_PRE_QUERY_EXEC_NON_NULL(_query_exec) \
973 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_QUERY_EXEC_ID, \
974 (_query_exec), _BT_ASSERT_PRE_QUERY_EXEC_NAME)
975
976 #define BT_ASSERT_PRE_DEV_QUERY_EXEC_NON_NULL(_query_exec) \
977 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_QUERY_EXEC_ID, \
978 (_query_exec), _BT_ASSERT_PRE_QUERY_EXEC_NAME)
979
980 #define _BT_ASSERT_PRE_PLUGIN_SET_NAME "Plugin set"
981 #define _BT_ASSERT_PRE_PLUGIN_SET_ID "plugin-set"
982
983 #define BT_ASSERT_PRE_PLUGIN_SET_NON_NULL(_plugin_set) \
984 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_ID, \
985 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_NAME)
986
987 #define BT_ASSERT_PRE_DEV_PLUGIN_SET_NON_NULL(_plugin_set) \
988 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_ID, \
989 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_NAME)
990
991 #define _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME \
992 _BT_ASSERT_PRE_PLUGIN_SET_NAME " (output)"
993 #define _BT_ASSERT_PRE_PLUGIN_SET_OUT_ID \
994 _BT_ASSERT_PRE_PLUGIN_SET_ID "-output"
995
996 #define BT_ASSERT_PRE_PLUGIN_SET_OUT_NON_NULL(_plugin_set) \
997 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_OUT_ID, \
998 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME)
999
1000 #define BT_ASSERT_PRE_DEV_PLUGIN_SET_OUT_NON_NULL(_plugin_set) \
1001 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_OUT_ID, \
1002 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME)
1003
1004 #define _BT_ASSERT_PRE_PLUGIN_NAME "Plugin"
1005 #define _BT_ASSERT_PRE_PLUGIN_ID "plugin"
1006
1007 #define BT_ASSERT_PRE_PLUGIN_NON_NULL(_plugin) \
1008 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_ID, (_plugin), \
1009 _BT_ASSERT_PRE_PLUGIN_NAME)
1010
1011 #define BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(_plugin) \
1012 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_ID, (_plugin), \
1013 _BT_ASSERT_PRE_PLUGIN_NAME)
1014
1015 #define _BT_ASSERT_PRE_PLUGIN_OUT_NAME \
1016 _BT_ASSERT_PRE_PLUGIN_NAME " (output)"
1017 #define _BT_ASSERT_PRE_PLUGIN_OUT_ID \
1018 _BT_ASSERT_PRE_PLUGIN_ID "-output"
1019
1020 #define BT_ASSERT_PRE_PLUGIN_OUT_NON_NULL(_plugin) \
1021 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_OUT_ID, (_plugin), \
1022 _BT_ASSERT_PRE_PLUGIN_OUT_NAME)
1023
1024 #define BT_ASSERT_PRE_DEV_PLUGIN_OUT_NON_NULL(_plugin) \
1025 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_OUT_ID, \
1026 (_plugin), _BT_ASSERT_PRE_PLUGIN_OUT_NAME)
1027
1028 #define _BT_ASSERT_PRE_ERROR_NAME "Error"
1029 #define _BT_ASSERT_PRE_ERROR_ID "error"
1030
1031 #define BT_ASSERT_PRE_ERROR_NON_NULL(_error) \
1032 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_ERROR_ID, (_error), \
1033 _BT_ASSERT_PRE_ERROR_NAME)
1034
1035 #define BT_ASSERT_PRE_DEV_ERROR_NON_NULL(_error) \
1036 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_ERROR_ID, (_error), \
1037 _BT_ASSERT_PRE_ERROR_NAME)
1038
1039 #define _BT_ASSERT_PRE_ERROR_CAUSE_NAME "Error cause"
1040 #define _BT_ASSERT_PRE_ERROR_CAUSE_ID "error-cause"
1041
1042 #define BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(_error_cause) \
1043 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_ERROR_CAUSE_ID, \
1044 (_error_cause), _BT_ASSERT_PRE_ERROR_CAUSE_NAME)
1045
1046 #define BT_ASSERT_PRE_DEV_ERROR_CAUSE_NON_NULL(_error_cause) \
1047 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_ERROR_CAUSE_ID, \
1048 (_error_cause), _BT_ASSERT_PRE_ERROR_CAUSE_NAME)
1049
1050 #define _BT_ASSERT_PRE_INT_RANGE_NAME "Integer range"
1051 #define _BT_ASSERT_PRE_INT_RANGE_ID "integer-range"
1052
1053 #define BT_ASSERT_PRE_INT_RANGE_NON_NULL(_int_range) \
1054 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_ID, \
1055 (_int_range), _BT_ASSERT_PRE_INT_RANGE_NAME)
1056
1057 #define BT_ASSERT_PRE_DEV_INT_RANGE_NON_NULL(_int_range) \
1058 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_ID, \
1059 (_int_range), _BT_ASSERT_PRE_INT_RANGE_NAME)
1060
1061 #define BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY_FROM_FUNC(_func, _range_set) \
1062 BT_ASSERT_PRE_FROM_FUNC(_func, "integer-range-set-is-not-empty", \
1063 (_range_set)->ranges->len > 0, \
1064 "Integer range set is empty: %!+R", (_range_set))
1065
1066 #define BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY(_range_set) \
1067 BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY_FROM_FUNC(__func__, \
1068 (_range_set))
1069
1070 #define _BT_ASSERT_PRE_INT_RANGE_SET_NAME "Integer range set"
1071 #define _BT_ASSERT_PRE_INT_RANGE_SET_ID "integer-range-set"
1072
1073 #define BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL_FROM_FUNC(_func, _range_set) \
1074 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
1075 _BT_ASSERT_PRE_INT_RANGE_SET_ID, (_range_set), \
1076 _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
1077
1078 #define BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(_range_set) \
1079 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_SET_ID, \
1080 (_range_set), _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
1081
1082 #define BT_ASSERT_PRE_DEV_INT_RANGE_SET_NON_NULL(_range_set) \
1083 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_SET_ID, \
1084 (_range_set), _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
1085
1086 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND(_value, _type) \
1087 (((struct bt_value *) (_value))->type == (_type))
1088
1089 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT \
1090 "Value has the wrong type: expected-type=%s, %![value-]+v"
1091
1092 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id) \
1093 "is-" _type_id "-value:" _value_id
1094
1095 #define BT_ASSERT_PRE_VALUE_HAS_TYPE_FROM_FUNC(_func, _value_id, _value, _type_id, _type) \
1096 BT_ASSERT_PRE_FROM_FUNC(_func, \
1097 _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id), \
1098 _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND((_value), (_type)), \
1099 _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT, \
1100 bt_common_value_type_string(_type), (_value))
1101
1102 #define BT_ASSERT_PRE_VALUE_HAS_TYPE(_value_id, _value, _type_id, _type) \
1103 BT_ASSERT_PRE_VALUE_HAS_TYPE_FROM_FUNC(__func__, _value_id, \
1104 (_value), _type_id, (_type));
1105
1106 #define BT_ASSERT_PRE_VALUE_IS_BOOL(_value) \
1107 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1108 "boolean", BT_VALUE_TYPE_BOOL);
1109
1110 #define BT_ASSERT_PRE_VALUE_IS_UNSIGNED_INT(_value) \
1111 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1112 "unsigned-int", BT_VALUE_TYPE_UNSIGNED_INTEGER);
1113
1114 #define BT_ASSERT_PRE_VALUE_IS_SIGNED_INT(_value) \
1115 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1116 "signed-int", BT_VALUE_TYPE_SIGNED_INTEGER);
1117
1118 #define BT_ASSERT_PRE_VALUE_IS_REAL(_value) \
1119 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1120 "real", BT_VALUE_TYPE_REAL);
1121
1122 #define BT_ASSERT_PRE_VALUE_IS_STRING(_value) \
1123 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1124 "string", BT_VALUE_TYPE_STRING);
1125
1126 #define BT_ASSERT_PRE_VALUE_IS_ARRAY(_value) \
1127 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1128 "array", BT_VALUE_TYPE_ARRAY);
1129
1130 #define BT_ASSERT_PRE_VALUE_IS_MAP_FROM_FUNC(_func, _value) \
1131 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1132 "map", BT_VALUE_TYPE_MAP);
1133
1134 #define BT_ASSERT_PRE_VALUE_IS_MAP(_value) \
1135 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1136 "map", BT_VALUE_TYPE_MAP);
1137
1138 #define BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(_value_id, _value, _type_id, _type) \
1139 BT_ASSERT_PRE_DEV( \
1140 _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id), \
1141 _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND((_value), (_type)), \
1142 _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT, \
1143 bt_common_value_type_string(_type), (_value))
1144
1145 #define BT_ASSERT_PRE_DEV_VALUE_IS_BOOL(_value) \
1146 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1147 "boolean", BT_VALUE_TYPE_BOOL);
1148
1149 #define BT_ASSERT_PRE_DEV_VALUE_IS_UNSIGNED_INT(_value) \
1150 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1151 "unsigned-int", BT_VALUE_TYPE_UNSIGNED_INTEGER);
1152
1153 #define BT_ASSERT_PRE_DEV_VALUE_IS_SIGNED_INT(_value) \
1154 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1155 "signed-int", BT_VALUE_TYPE_SIGNED_INTEGER);
1156
1157 #define BT_ASSERT_PRE_DEV_VALUE_IS_REAL(_value) \
1158 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1159 "real", BT_VALUE_TYPE_REAL);
1160
1161 #define BT_ASSERT_PRE_DEV_VALUE_IS_STRING(_value) \
1162 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1163 "string", BT_VALUE_TYPE_STRING);
1164
1165 #define BT_ASSERT_PRE_DEV_VALUE_IS_ARRAY(_value) \
1166 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1167 "array", BT_VALUE_TYPE_ARRAY);
1168
1169 #define BT_ASSERT_PRE_DEV_VALUE_IS_MAP(_value) \
1170 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1171 "map", BT_VALUE_TYPE_MAP);
1172
1173 #define _BT_ASSERT_PRE_VALUE_NAME "Value object"
1174 #define _BT_ASSERT_PRE_VALUE_ID "value-object"
1175
1176 #define BT_ASSERT_PRE_VALUE_NON_NULL_FROM_FUNC(_func, _value) \
1177 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
1178 _BT_ASSERT_PRE_VALUE_ID, (_value), _BT_ASSERT_PRE_VALUE_NAME)
1179
1180 #define BT_ASSERT_PRE_VALUE_NON_NULL(_value) \
1181 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_VALUE_ID, (_value), \
1182 _BT_ASSERT_PRE_VALUE_NAME)
1183
1184 #define BT_ASSERT_PRE_DEV_VALUE_NON_NULL_FROM_FUNC(_func, _value) \
1185 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
1186 _BT_ASSERT_PRE_VALUE_ID, (_value), _BT_ASSERT_PRE_VALUE_NAME)
1187
1188 #define BT_ASSERT_PRE_DEV_VALUE_NON_NULL(_value) \
1189 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_VALUE_ID, (_value), \
1190 _BT_ASSERT_PRE_VALUE_NAME)
1191
1192 #define BT_ASSERT_PRE_PARAM_VALUE_IS_MAP_FROM_FUNC(_func, _value) \
1193 BT_ASSERT_PRE_FROM_FUNC(_func, \
1194 "is-map-value:parameters-value-object", \
1195 !(_value) || bt_value_is_map(_value), \
1196 "Parameters value object is not a map value: %!+v", (_value));
1197
1198 #define BT_ASSERT_PRE_PARAM_VALUE_IS_MAP(_value) \
1199 BT_ASSERT_PRE_PARAM_VALUE_IS_MAP_FROM_FUNC(__func__, (_value))
1200
1201 #define _BT_ASSERT_PRE_RES_OUT_NAME "Result (output)"
1202 #define _BT_ASSERT_PRE_RES_OUT_ID "result-output"
1203
1204 #define BT_ASSERT_PRE_RES_OUT_NON_NULL(_res) \
1205 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_RES_OUT_ID, (_res), \
1206 _BT_ASSERT_PRE_RES_OUT_NAME)
1207
1208 #define BT_ASSERT_PRE_DEV_RES_OUT_NON_NULL(_res) \
1209 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_RES_OUT_ID, (_res), \
1210 _BT_ASSERT_PRE_RES_OUT_NAME)
1211
1212 #define BT_ASSERT_PRE_METHOD_NON_NULL(_method) \
1213 BT_ASSERT_PRE_NON_NULL("method", (_method), "Method");
1214
1215 #define _BT_ASSERT_PRE_NAME_NAME "Name"
1216 #define _BT_ASSERT_PRE_NAME_ID "name"
1217
1218 #define BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(_func, _name) \
1219 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_NAME_ID, \
1220 (_name), _BT_ASSERT_PRE_NAME_NAME)
1221
1222 #define BT_ASSERT_PRE_NAME_NON_NULL(_name) \
1223 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_NAME_ID, (_name), \
1224 _BT_ASSERT_PRE_NAME_NAME)
1225
1226 #define BT_ASSERT_PRE_DEV_NAME_NON_NULL_FROM_FUNC(_func, _name) \
1227 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
1228 _BT_ASSERT_PRE_NAME_ID, (_name), _BT_ASSERT_PRE_NAME_NAME)
1229
1230 #define BT_ASSERT_PRE_DEV_NAME_NON_NULL(_name) \
1231 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_NAME_ID, (_name), \
1232 _BT_ASSERT_PRE_NAME_NAME)
1233
1234 #define _BT_ASSERT_PRE_DESCR_NAME "Description"
1235 #define _BT_ASSERT_PRE_DESCR_ID "description"
1236
1237 #define BT_ASSERT_PRE_DESCR_NON_NULL(_descr) \
1238 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_DESCR_ID, (_descr), \
1239 _BT_ASSERT_PRE_DESCR_NAME)
1240
1241 #define BT_ASSERT_PRE_DEV_DESCR_NON_NULL(_descr) \
1242 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_DESCR_ID, (_descr), \
1243 _BT_ASSERT_PRE_DESCR_NAME)
1244
1245 #define _BT_ASSERT_PRE_UUID_NAME "UUID"
1246 #define _BT_ASSERT_PRE_UUID_ID "uuid"
1247
1248 #define BT_ASSERT_PRE_UUID_NON_NULL(_uuid) \
1249 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_UUID_ID, (_uuid), \
1250 _BT_ASSERT_PRE_UUID_NAME)
1251
1252 #define BT_ASSERT_PRE_DEV_UUID_NON_NULL(_uuid) \
1253 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_UUID_ID, (_uuid), \
1254 _BT_ASSERT_PRE_UUID_NAME)
1255
1256 #define _BT_ASSERT_PRE_KEY_NAME "Key"
1257 #define _BT_ASSERT_PRE_KEY_ID "key"
1258
1259 #define BT_ASSERT_PRE_KEY_NON_NULL_FROM_FUNC(_func, _key) \
1260 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_KEY_ID, \
1261 (_key), _BT_ASSERT_PRE_KEY_NAME)
1262
1263 #define BT_ASSERT_PRE_KEY_NON_NULL(_key) \
1264 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_KEY_ID, (_key), \
1265 _BT_ASSERT_PRE_KEY_NAME)
1266
1267 #define BT_ASSERT_PRE_DEV_KEY_NON_NULL(_key) \
1268 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_KEY_ID, (_key), \
1269 _BT_ASSERT_PRE_KEY_NAME)
1270
1271 #endif /* BABELTRACE_ASSERT_COND_INTERNAL_H */
This page took 0.057934 seconds and 4 git commands to generate.