2 * SPDX-License-Identifier: MIT
4 * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
5 * Copyright (c) 2018-2020 Philippe Proulx <pproulx@efficios.com>
8 #ifndef BABELTRACE_ASSERT_COND_INTERNAL_H
9 #define BABELTRACE_ASSERT_COND_INTERNAL_H
11 #include "assert-cond-base.h"
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
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)
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)
26 * Asserts that a given index `_index` is less than a given length
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))
34 #define BT_ASSERT_PRE_VALID_INDEX(_index, _length) \
35 BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(__func__, (_index), (_length))
38 * Asserts that the current thread has no error set.
40 #define BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(_func) \
42 const struct bt_error *err = bt_current_thread_take_error(); \
44 bt_current_thread_move_error(err); \
46 BT_ASSERT_PRE_FROM_FUNC(_func, "no-error", !err, \
47 "API function called while current thread has an " \
48 "error: function=%s", _func); \
51 #define BT_ASSERT_PRE_NO_ERROR() \
52 BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(__func__)
55 * Asserts that, if the current thread has an error, `_status` is an
58 * See _BT_ASSERT_COND() for details about the `_func` parameter.
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.
63 #define BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \
65 const struct bt_error *_err = bt_current_thread_take_error(); \
67 bt_current_thread_move_error(_err); \
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)); \
77 * Asserts that the current thread has no error.
79 * See _BT_ASSERT_COND() for details about the `_func` parameter.
81 #define BT_ASSERT_POST_NO_ERROR(_func) \
83 const struct bt_error *_err = bt_current_thread_take_error(); \
85 bt_current_thread_move_error(_err); \
87 BT_ASSERT_POST(_func, "no-error", !_err, \
88 "Current thread has an error"); \
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))
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))
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.
105 * This macro checks the `frozen` field of `_obj`.
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.
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__)
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__)
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))
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))
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)
131 /* Developer mode version of BT_ASSERT_PRE_NO_ERROR(). */
132 # define BT_ASSERT_PRE_DEV_NO_ERROR() BT_ASSERT_PRE_NO_ERROR()
135 * Developer mode version of
136 * BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS().
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))
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)
146 * Marks a function as being only used within a BT_ASSERT_PRE_DEV() or
147 * BT_ASSERT_POST_DEV() context.
149 # define BT_ASSERT_COND_DEV_FUNC
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)
154 # define BT_ASSERT_PRE_DEV_NON_NULL(_obj_id, _obj, _obj_name) \
155 BT_USE_EXPR3(_obj_id, (_obj), _obj_name)
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)
160 # define BT_ASSERT_PRE_DEV_HOT(_obj_id, _obj, _obj_name, _fmt, ...) \
161 BT_USE_EXPR4(_obj_id, (_obj), _obj_name, _fmt)
163 # define BT_ASSERT_PRE_DEV_VALID_INDEX_FROM_FUNC(_func, _index, _length) \
164 BT_USE_EXPR3(_func, (_index), (_length))
166 # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \
167 BT_USE_EXPR2((_index), (_length))
169 # define BT_ASSERT_PRE_DEV_NO_ERROR_FROM_FUNC(_func) \
172 # define BT_ASSERT_PRE_DEV_NO_ERROR()
174 # define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \
175 BT_USE_EXPR2(_func, _status)
177 # define BT_ASSERT_POST_DEV_NO_ERROR(_func) \
179 #endif /* BT_DEV_MODE */
181 #define _BT_ASSERT_PRE_CLK_CLS_NAME "Clock class"
182 #define _BT_ASSERT_PRE_CLK_CLS_ID "clock-class"
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)
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)
192 #define _BT_ASSERT_PRE_DEF_CLK_CLS_NAME "Default clock class"
193 #define _BT_ASSERT_PRE_DEF_CLK_CLS_ID "default-clock-class"
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)
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)
203 #define _BT_ASSERT_PRE_CS_NAME "Clock snapshot"
204 #define _BT_ASSERT_PRE_CS_ID "clock-snapshot"
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)
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)
214 #define _BT_ASSERT_PRE_EVENT_NAME "Event"
215 #define _BT_ASSERT_PRE_EVENT_ID "event"
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)
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)
225 #define _BT_ASSERT_PRE_EC_NAME "Event class"
226 #define _BT_ASSERT_PRE_EC_ID "event-class"
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)
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)
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)
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)
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)
250 #define _BT_ASSERT_PRE_FC_IS_INT_FMT(_name) \
251 _name " is not an integer field class: %![fc-]+F"
253 #define _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id) "is-int-field-class:" _fc_id
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)
259 #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name) \
260 _name " is not an unsigned integer field class: %![fc-]+F"
262 #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id) \
263 "is-unsigned-integer-field-class:" _fc_id
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)
269 #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name) \
270 _name " is not a signed integer field class: %![fc-]+F"
272 #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id) \
273 "is-signed-integer-field-class:" _fc_id
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)
279 #define _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name) \
280 _name " is not an enumeration field class: %![fc-]+F"
282 #define _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id) \
283 "is-enumeration-field-class:" _fc_id
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)
290 #define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name) \
291 _name " is not an array field class: %![fc-]+F"
293 #define _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id) \
294 "is-array-field-class:" _fc_id
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)
302 #define _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name) \
303 _name " is not an option field class: %![fc-]+F"
305 #define _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id) \
306 "is-option-field-class:" _fc_id
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)
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"
316 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_ID(_fc_id) \
317 "is-option-field-class-with-selector:" _fc_id
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)
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"
326 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_ID(_fc_id) \
327 "is-option-field-class-with-integer-selector:" _fc_id
329 #define _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name) \
330 _name " is not a structure field class: %![fc-]+F"
332 #define _BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc) \
333 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STRUCTURE)
335 #define _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id) \
336 "is-structure-field-class:" _fc_id
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)
343 #define _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name) \
344 _name " is not a variant field class: %![fc-]+F"
346 #define _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id) \
347 "is-variant-field-class:" _fc_id
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)
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"
356 #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id) \
357 "is-variant-field-class-with-selector:" _fc_id
359 #define _BT_ASSERT_PRE_FC_HAS_TYPE_COND(_fc, _type) \
360 (((const struct bt_field_class *) (_fc))->type == (_type))
362 #define _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name) \
363 _name " has the wrong type: expected-type=%s, %![fc-]+F"
365 #define _BT_ASSERT_PRE_FC_HAS_TYPE_ID(_fc_id, _type_id) \
366 "is-" _type_id ":" _fc_id
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))
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)
377 #define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc_id, _fc, _name) \
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))
383 #define BT_ASSERT_PRE_FC_IS_SIGNED_INT(_fc_id, _fc, _name) \
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))
389 #define BT_ASSERT_PRE_FC_IS_ENUM(_fc_id, _fc, _name) \
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))
395 #define BT_ASSERT_PRE_FC_IS_ARRAY(_fc_id, _fc, _name) \
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))
401 #define BT_ASSERT_PRE_FC_IS_STRUCT(_fc_id, _fc, _name) \
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))
407 #define BT_ASSERT_PRE_FC_IS_OPTION(_fc_id, _fc, _name) \
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))
413 #define BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL(_fc_id, _fc, _name) \
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))
419 #define BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(_fc_id, _fc, _name) \
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))
425 #define BT_ASSERT_PRE_FC_IS_VARIANT(_fc_id, _fc, _name) \
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))
431 #define BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL(_fc_id, _fc, _name) \
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))
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))
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)
448 #define BT_ASSERT_PRE_DEV_FC_IS_INT(_fc_id, _fc, _name) \
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))
454 #define BT_ASSERT_PRE_DEV_FC_IS_UNSIGNED_INT(_fc_id, _fc, _name) \
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))
460 #define BT_ASSERT_PRE_DEV_FC_IS_SIGNED_INT(_fc_id, _fc, _name) \
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))
466 #define BT_ASSERT_PRE_DEV_FC_IS_ENUM(_fc_id, _fc, _name) \
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))
472 #define BT_ASSERT_PRE_DEV_FC_IS_ARRAY(_fc_id, _fc, _name) \
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))
478 #define BT_ASSERT_PRE_DEV_FC_IS_STRUCT(_fc_id, _fc, _name) \
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))
484 #define BT_ASSERT_PRE_DEV_FC_IS_OPTION(_fc_id, _fc, _name) \
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))
490 #define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_SEL(_fc_id, _fc, _name) \
492 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \
493 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
495 #define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_INT_SEL(_fc_id, _fc, _name) \
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))
501 #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT(_fc_id, _fc, _name) \
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))
507 #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL(_fc_id, _fc, _name) \
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))
513 #define BT_ASSERT_PRE_DEV_FC_HAS_TYPE(_fc_id, _fc, _type_id, _type, _name) \
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))
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))
525 #define BT_ASSERT_PRE_DEV_FC_HOT(_fc) \
526 BT_ASSERT_PRE_DEV_FC_HOT_FROM_FUNC(__func__, (_fc))
528 #define _BT_ASSERT_PRE_FC_NAME "Field class"
529 #define _BT_ASSERT_PRE_FC_ID "field-class"
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)
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)
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"
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)
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)
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"
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)
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)
561 #define _BT_ASSERT_PRE_FP_NAME "Field path"
562 #define _BT_ASSERT_PRE_FP_ID "field-path"
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)
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)
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), \
575 _name " has the wrong class type: expected-class-type=%s, " \
577 bt_common_field_class_type_string(_cls_type), (_field))
579 #define BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(_field_id, _field, _name) \
581 "is-unsigned-integer-field:" _field_id, \
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", \
587 #define BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(_field_id, _field, _name) \
589 "is-signed-integer-field:" _field_id, \
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", \
595 #define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(_field_id, _field, _name) \
597 "is-array-field:" _field_id, \
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))
603 #define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(_field_id, _field, _name) \
605 "is-dynamic-array-field:" _field_id, \
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))
610 #define BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(_field_id, _field, _name) \
612 "is-option-field:" _field_id, \
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))
619 #define BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(_field_id, _field, _name) \
621 "is-variant-field:" _field_id, \
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))
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), \
630 "Field is not set: %!+f", (_field))
632 #define _BT_ASSERT_PRE_FIELD_NAME "Field"
633 #define _BT_ASSERT_PRE_FIELD_ID "field"
635 #define BT_ASSERT_PRE_FIELD_NON_NULL(_field) \
636 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field), \
637 _BT_ASSERT_PRE_FIELD_NAME)
639 #define BT_ASSERT_PRE_DEV_FIELD_NON_NULL(_field) \
640 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field), \
641 _BT_ASSERT_PRE_FIELD_NAME)
643 #define _BT_ASSERT_PRE_PACKET_NAME "Packet"
644 #define _BT_ASSERT_PRE_PACKET_ID "packet"
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)
650 #define BT_ASSERT_PRE_PACKET_NON_NULL(_packet) \
651 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PACKET_ID, (_packet), \
652 _BT_ASSERT_PRE_PACKET_NAME)
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)
658 #define BT_ASSERT_PRE_DEV_PACKET_NON_NULL(_packet) \
659 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PACKET_ID, (_packet), \
660 _BT_ASSERT_PRE_PACKET_NAME)
662 #define _BT_ASSERT_PRE_SC_NAME "Stream class"
663 #define _BT_ASSERT_PRE_SC_ID "stream-class"
665 #define BT_ASSERT_PRE_SC_NON_NULL(_sc) \
666 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_SC_ID, (_sc), \
667 _BT_ASSERT_PRE_SC_NAME)
669 #define BT_ASSERT_PRE_DEV_SC_NON_NULL(_sc) \
670 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_SC_ID, (_sc), \
671 _BT_ASSERT_PRE_SC_NAME)
673 #define _BT_ASSERT_PRE_STREAM_NAME "Stream"
674 #define _BT_ASSERT_PRE_STREAM_ID "stream"
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)
681 #define BT_ASSERT_PRE_STREAM_NON_NULL(_stream) \
682 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_STREAM_ID, (_stream), \
683 _BT_ASSERT_PRE_STREAM_NAME)
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)
690 #define BT_ASSERT_PRE_DEV_STREAM_NON_NULL(_stream) \
691 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_STREAM_ID, (_stream), \
692 _BT_ASSERT_PRE_STREAM_NAME)
694 #define _BT_ASSERT_PRE_TC_NAME "Trace class"
695 #define _BT_ASSERT_PRE_TC_ID "trace-class"
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)
701 #define BT_ASSERT_PRE_TC_NON_NULL(_tc) \
702 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_TC_ID, (_tc), \
703 _BT_ASSERT_PRE_TC_NAME)
705 #define BT_ASSERT_PRE_DEV_TC_NON_NULL(_tc) \
706 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_TC_ID, (_tc), \
707 _BT_ASSERT_PRE_TC_NAME)
709 #define _BT_ASSERT_PRE_TRACE_NAME "Trace"
710 #define _BT_ASSERT_PRE_TRACE_ID "trace"
712 #define BT_ASSERT_PRE_TRACE_NON_NULL(_trace) \
713 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_TRACE_ID, (_trace), \
714 _BT_ASSERT_PRE_TRACE_NAME)
716 #define BT_ASSERT_PRE_DEV_TRACE_NON_NULL(_trace) \
717 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_TRACE_ID, (_trace), \
718 _BT_ASSERT_PRE_TRACE_NAME)
720 #define _BT_ASSERT_PRE_USER_ATTRS_NAME "User attributes value object"
721 #define _BT_ASSERT_PRE_USER_ATTRS_ID "user-attributes-value-object"
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)
728 #define BT_ASSERT_PRE_USER_ATTRS_NON_NULL(_ua) \
729 BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(__func__, (_ua))
731 #define BT_ASSERT_PRE_DEV_USER_ATTRS_NON_NULL(_ua) \
732 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_USER_ATTRS_ID, (_ua), \
733 _BT_ASSERT_PRE_USER_ATTRS_NAME)
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, \
738 _BT_ASSERT_PRE_USER_ATTRS_NAME \
739 " object is not a map value object.")
741 #define BT_ASSERT_PRE_USER_ATTRS_IS_MAP(_ua) \
742 BT_ASSERT_PRE_USER_ATTRS_IS_MAP_FROM_FUNC(__func__, (_ua))
744 #define BT_ASSERT_COND_LISTENER_FUNC_NAME "Listener function"
745 #define BT_ASSERT_COND_LISTENER_FUNC_ID "listener-function"
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)
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)
755 #define _BT_ASSERT_PRE_MSG_ITER_NAME "Message iterator"
756 #define _BT_ASSERT_PRE_MSG_ITER_ID "message-iterator"
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)
763 #define BT_ASSERT_PRE_MSG_ITER_NON_NULL(_msg_iter) \
764 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_ID, (_msg_iter), \
765 _BT_ASSERT_PRE_MSG_ITER_NAME)
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)
772 #define BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL(_msg_iter) \
773 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_ID, \
774 (_msg_iter), _BT_ASSERT_PRE_MSG_ITER_NAME)
776 #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc) \
777 ((_sc)->default_clock_class)
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"
783 #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID \
784 "message-stream-class-has-default-clock-class"
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, \
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))
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, \
803 #define BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS(_msg, _sc) \
804 BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(__func__, (_msg), (_sc))
806 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_COND(_msg, _type) \
807 (((struct bt_message *) (_msg))->type == (_type))
809 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT \
810 "Message has the wrong type: expected-type=%s, %![msg-]+n"
812 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id) \
813 "is-" _type_id "-message:" _msg_id
815 #define BT_ASSERT_PRE_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type) \
817 _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id), \
818 _BT_ASSERT_PRE_MSG_HAS_TYPE_COND((_msg), (_type)), \
819 _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT, \
820 bt_common_message_type_string(_type), (_msg))
822 #define BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type) \
824 _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id), \
825 _BT_ASSERT_PRE_MSG_HAS_TYPE_COND((_msg), (_type)), \
826 _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT, \
827 bt_common_message_type_string(_type), (_msg))
829 #define _BT_ASSERT_PRE_MSG_NAME "Message"
830 #define _BT_ASSERT_PRE_MSG_ID "message"
832 #define BT_ASSERT_PRE_MSG_NON_NULL(_msg_iter) \
833 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ID, (_msg_iter), \
834 _BT_ASSERT_PRE_MSG_NAME)
836 #define BT_ASSERT_PRE_DEV_MSG_NON_NULL(_msg_iter) \
837 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ID, (_msg_iter), \
838 _BT_ASSERT_PRE_MSG_NAME)
840 #define BT_ASSERT_PRE_MSG_CS_BEGIN_LE_END(_msg_iter, _begin, _end) \
841 BT_ASSERT_PRE("beginning-default-clock-snapshot-lteq-end", \
842 (_begin) <= (_end), \
843 "Beginning default clock snapshot value is greater " \
844 "than end default clock snapshot value: " \
845 "cs-begin-val=%" PRIu64 ", cs-end-val=%" PRIu64 ", " \
846 "%![msg-iter-]+i", (_begin), (_end), _msg_iter);
848 #define BT_ASSERT_PRE_DEV_MSG_HOT(_msg) \
849 BT_ASSERT_PRE_DEV_HOT("message", (_msg), "Message", ": %!+n", (_msg));
851 #define _BT_ASSERT_PRE_MSG_ITER_CLS_NAME "Message iterator class"
852 #define _BT_ASSERT_PRE_MSG_ITER_CLS_ID "message-iterator-class"
854 #define BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(_msg_iter_cls) \
855 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_CLS_ID, \
856 (_msg_iter_cls), _BT_ASSERT_PRE_MSG_ITER_CLS_NAME)
858 #define BT_ASSERT_PRE_DEV_MSG_ITER_CLS_NON_NULL(_msg_iter_cls) \
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)
862 #define _BT_ASSERT_PRE_COMP_CLS_NAME "Component class"
863 #define _BT_ASSERT_PRE_COMP_CLS_ID "component-class"
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)
870 #define BT_ASSERT_PRE_COMP_CLS_NON_NULL(_comp_cls) \
871 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_CLS_ID, (_comp_cls), \
872 _BT_ASSERT_PRE_COMP_CLS_NAME)
874 #define BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(_comp_cls) \
875 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_CLS_ID, \
876 (_comp_cls), _BT_ASSERT_PRE_COMP_CLS_NAME)
878 #define _BT_ASSERT_PRE_COMP_DESCR_SET_NAME "Component descriptor set"
879 #define _BT_ASSERT_PRE_COMP_DESCR_SET_ID "component-descriptor-set"
881 #define BT_ASSERT_PRE_COMP_DESCR_SET_NON_NULL(_comp_descr_set) \
882 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_DESCR_SET_ID, \
883 (_comp_descr_set), _BT_ASSERT_PRE_COMP_DESCR_SET_NAME)
885 #define BT_ASSERT_PRE_DEV_COMP_DESCR_SET_NON_NULL(_comp_descr_set) \
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)
889 #define _BT_ASSERT_PRE_COMP_NAME "Component"
890 #define _BT_ASSERT_PRE_COMP_ID "component"
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)
896 #define BT_ASSERT_PRE_COMP_NON_NULL(_comp) \
897 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_ID, (_comp), \
898 _BT_ASSERT_PRE_COMP_NAME)
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)
904 #define BT_ASSERT_PRE_DEV_COMP_NON_NULL(_comp) \
905 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_ID, (_comp), \
906 _BT_ASSERT_PRE_COMP_NAME)
908 #define _BT_ASSERT_PRE_CONN_NAME "Connection"
909 #define _BT_ASSERT_PRE_CONN_ID "connection"
911 #define BT_ASSERT_PRE_CONN_NON_NULL(_conn) \
912 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CONN_ID, (_conn), \
913 _BT_ASSERT_PRE_CONN_NAME)
915 #define BT_ASSERT_PRE_DEV_CONN_NON_NULL(_conn) \
916 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CONN_ID, (_conn), \
917 _BT_ASSERT_PRE_CONN_NAME)
919 #define _BT_ASSERT_PRE_GRAPH_NAME "Graph"
920 #define _BT_ASSERT_PRE_GRAPH_ID "graph"
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)
926 #define BT_ASSERT_PRE_GRAPH_NON_NULL(_graph) \
927 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_GRAPH_ID, (_graph), \
928 _BT_ASSERT_PRE_GRAPH_NAME)
930 #define BT_ASSERT_PRE_DEV_GRAPH_NON_NULL(_graph) \
931 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_GRAPH_ID, (_graph), \
932 _BT_ASSERT_PRE_GRAPH_NAME)
934 #define _BT_ASSERT_PRE_INTR_NAME "Interrupter"
935 #define _BT_ASSERT_PRE_INTR_ID "interrupter"
937 #define BT_ASSERT_PRE_INTR_NON_NULL(_intr) \
938 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INTR_ID, (_intr), \
939 _BT_ASSERT_PRE_INTR_NAME)
941 #define BT_ASSERT_PRE_DEV_INTR_NON_NULL(_intr) \
942 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INTR_ID, (_intr), \
943 _BT_ASSERT_PRE_INTR_NAME)
945 #define _BT_ASSERT_PRE_PORT_NAME "Port"
946 #define _BT_ASSERT_PRE_PORT_ID "port"
948 #define BT_ASSERT_PRE_PORT_NON_NULL(_port) \
949 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PORT_ID, (_port), \
950 _BT_ASSERT_PRE_PORT_NAME)
952 #define BT_ASSERT_PRE_DEV_PORT_NON_NULL(_port) \
953 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PORT_ID, (_port), \
954 _BT_ASSERT_PRE_PORT_NAME)
956 #define _BT_ASSERT_PRE_QUERY_EXEC_NAME "Query executor"
957 #define _BT_ASSERT_PRE_QUERY_EXEC_ID "query-executor"
959 #define BT_ASSERT_PRE_QUERY_EXEC_NON_NULL(_query_exec) \
960 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_QUERY_EXEC_ID, \
961 (_query_exec), _BT_ASSERT_PRE_QUERY_EXEC_NAME)
963 #define BT_ASSERT_PRE_DEV_QUERY_EXEC_NON_NULL(_query_exec) \
964 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_QUERY_EXEC_ID, \
965 (_query_exec), _BT_ASSERT_PRE_QUERY_EXEC_NAME)
967 #define _BT_ASSERT_PRE_PLUGIN_SET_NAME "Plugin set"
968 #define _BT_ASSERT_PRE_PLUGIN_SET_ID "plugin-set"
970 #define BT_ASSERT_PRE_PLUGIN_SET_NON_NULL(_plugin_set) \
971 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_ID, \
972 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_NAME)
974 #define BT_ASSERT_PRE_DEV_PLUGIN_SET_NON_NULL(_plugin_set) \
975 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_ID, \
976 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_NAME)
978 #define _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME \
979 _BT_ASSERT_PRE_PLUGIN_SET_NAME " (output)"
980 #define _BT_ASSERT_PRE_PLUGIN_SET_OUT_ID \
981 _BT_ASSERT_PRE_PLUGIN_SET_ID "-output"
983 #define BT_ASSERT_PRE_PLUGIN_SET_OUT_NON_NULL(_plugin_set) \
984 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_OUT_ID, \
985 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME)
987 #define BT_ASSERT_PRE_DEV_PLUGIN_SET_OUT_NON_NULL(_plugin_set) \
988 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_OUT_ID, \
989 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME)
991 #define _BT_ASSERT_PRE_PLUGIN_NAME "Plugin"
992 #define _BT_ASSERT_PRE_PLUGIN_ID "plugin"
994 #define BT_ASSERT_PRE_PLUGIN_NON_NULL(_plugin) \
995 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_ID, (_plugin), \
996 _BT_ASSERT_PRE_PLUGIN_NAME)
998 #define BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(_plugin) \
999 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_ID, (_plugin), \
1000 _BT_ASSERT_PRE_PLUGIN_NAME)
1002 #define _BT_ASSERT_PRE_PLUGIN_OUT_NAME \
1003 _BT_ASSERT_PRE_PLUGIN_NAME " (output)"
1004 #define _BT_ASSERT_PRE_PLUGIN_OUT_ID \
1005 _BT_ASSERT_PRE_PLUGIN_ID "-output"
1007 #define BT_ASSERT_PRE_PLUGIN_OUT_NON_NULL(_plugin) \
1008 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_OUT_ID, (_plugin), \
1009 _BT_ASSERT_PRE_PLUGIN_OUT_NAME)
1011 #define BT_ASSERT_PRE_DEV_PLUGIN_OUT_NON_NULL(_plugin) \
1012 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_OUT_ID, \
1013 (_plugin), _BT_ASSERT_PRE_PLUGIN_OUT_NAME)
1015 #define _BT_ASSERT_PRE_ERROR_NAME "Error"
1016 #define _BT_ASSERT_PRE_ERROR_ID "error"
1018 #define BT_ASSERT_PRE_ERROR_NON_NULL(_error) \
1019 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_ERROR_ID, (_error), \
1020 _BT_ASSERT_PRE_ERROR_NAME)
1022 #define BT_ASSERT_PRE_DEV_ERROR_NON_NULL(_error) \
1023 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_ERROR_ID, (_error), \
1024 _BT_ASSERT_PRE_ERROR_NAME)
1026 #define _BT_ASSERT_PRE_ERROR_CAUSE_NAME "Error cause"
1027 #define _BT_ASSERT_PRE_ERROR_CAUSE_ID "error-cause"
1029 #define BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(_error_cause) \
1030 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_ERROR_CAUSE_ID, \
1031 (_error_cause), _BT_ASSERT_PRE_ERROR_CAUSE_NAME)
1033 #define BT_ASSERT_PRE_DEV_ERROR_CAUSE_NON_NULL(_error_cause) \
1034 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_ERROR_CAUSE_ID, \
1035 (_error_cause), _BT_ASSERT_PRE_ERROR_CAUSE_NAME)
1037 #define _BT_ASSERT_PRE_INT_RANGE_NAME "Integer range"
1038 #define _BT_ASSERT_PRE_INT_RANGE_ID "integer-range"
1040 #define BT_ASSERT_PRE_INT_RANGE_NON_NULL(_int_range) \
1041 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_ID, \
1042 (_int_range), _BT_ASSERT_PRE_INT_RANGE_NAME)
1044 #define BT_ASSERT_PRE_DEV_INT_RANGE_NON_NULL(_int_range) \
1045 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_ID, \
1046 (_int_range), _BT_ASSERT_PRE_INT_RANGE_NAME)
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))
1053 #define BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY(_range_set) \
1054 BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY_FROM_FUNC(__func__, \
1057 #define _BT_ASSERT_PRE_INT_RANGE_SET_NAME "Integer range set"
1058 #define _BT_ASSERT_PRE_INT_RANGE_SET_ID "integer-range-set"
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)
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)
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)
1073 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND(_value, _type) \
1074 (((struct bt_value *) (_value))->type == (_type))
1076 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT \
1077 "Value has the wrong type: expected-type=%s, %![value-]+v"
1079 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id) \
1080 "is-" _type_id "-value:" _value_id
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), \
1085 _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND((_value), (_type)), \
1086 _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT, \
1087 bt_common_value_type_string(_type), (_value))
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));
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);
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);
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);
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);
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);
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);
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);
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);
1125 #define BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(_value_id, _value, _type_id, _type) \
1126 BT_ASSERT_PRE_DEV( \
1127 _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id), \
1128 _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND((_value), (_type)), \
1129 _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT, \
1130 bt_common_value_type_string(_type), (_value))
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);
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);
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);
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);
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);
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);
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);
1160 #define _BT_ASSERT_PRE_VALUE_NAME "Value object"
1161 #define _BT_ASSERT_PRE_VALUE_ID "value-object"
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)
1167 #define BT_ASSERT_PRE_VALUE_NON_NULL(_value) \
1168 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_VALUE_ID, (_value), \
1169 _BT_ASSERT_PRE_VALUE_NAME)
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)
1175 #define BT_ASSERT_PRE_DEV_VALUE_NON_NULL(_value) \
1176 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_VALUE_ID, (_value), \
1177 _BT_ASSERT_PRE_VALUE_NAME)
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));
1185 #define BT_ASSERT_PRE_PARAM_VALUE_IS_MAP(_value) \
1186 BT_ASSERT_PRE_PARAM_VALUE_IS_MAP_FROM_FUNC(__func__, (_value))
1188 #define _BT_ASSERT_PRE_RES_OUT_NAME "Result (output)"
1189 #define _BT_ASSERT_PRE_RES_OUT_ID "result-output"
1191 #define BT_ASSERT_PRE_RES_OUT_NON_NULL(_res) \
1192 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_RES_OUT_ID, (_res), \
1193 _BT_ASSERT_PRE_RES_OUT_NAME)
1195 #define BT_ASSERT_PRE_DEV_RES_OUT_NON_NULL(_res) \
1196 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_RES_OUT_ID, (_res), \
1197 _BT_ASSERT_PRE_RES_OUT_NAME)
1199 #define BT_ASSERT_PRE_METHOD_NON_NULL(_method) \
1200 BT_ASSERT_PRE_NON_NULL("method", (_method), "Method");
1202 #define _BT_ASSERT_PRE_NAME_NAME "Name"
1203 #define _BT_ASSERT_PRE_NAME_ID "name"
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)
1209 #define BT_ASSERT_PRE_NAME_NON_NULL(_name) \
1210 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_NAME_ID, (_name), \
1211 _BT_ASSERT_PRE_NAME_NAME)
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)
1217 #define BT_ASSERT_PRE_DEV_NAME_NON_NULL(_name) \
1218 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_NAME_ID, (_name), \
1219 _BT_ASSERT_PRE_NAME_NAME)
1221 #define _BT_ASSERT_PRE_DESCR_NAME "Description"
1222 #define _BT_ASSERT_PRE_DESCR_ID "description"
1224 #define BT_ASSERT_PRE_DESCR_NON_NULL(_descr) \
1225 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_DESCR_ID, (_descr), \
1226 _BT_ASSERT_PRE_DESCR_NAME)
1228 #define BT_ASSERT_PRE_DEV_DESCR_NON_NULL(_descr) \
1229 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_DESCR_ID, (_descr), \
1230 _BT_ASSERT_PRE_DESCR_NAME)
1232 #define _BT_ASSERT_PRE_UUID_NAME "UUID"
1233 #define _BT_ASSERT_PRE_UUID_ID "uuid"
1235 #define BT_ASSERT_PRE_UUID_NON_NULL(_uuid) \
1236 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_UUID_ID, (_uuid), \
1237 _BT_ASSERT_PRE_UUID_NAME)
1239 #define BT_ASSERT_PRE_DEV_UUID_NON_NULL(_uuid) \
1240 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_UUID_ID, (_uuid), \
1241 _BT_ASSERT_PRE_UUID_NAME)
1243 #define _BT_ASSERT_PRE_KEY_NAME "Key"
1244 #define _BT_ASSERT_PRE_KEY_ID "key"
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)
1250 #define BT_ASSERT_PRE_KEY_NON_NULL(_key) \
1251 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_KEY_ID, (_key), \
1252 _BT_ASSERT_PRE_KEY_NAME)
1254 #define BT_ASSERT_PRE_DEV_KEY_NON_NULL(_key) \
1255 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_KEY_ID, (_key), \
1256 _BT_ASSERT_PRE_KEY_NAME)
1258 #endif /* BABELTRACE_ASSERT_COND_INTERNAL_H */
This page took 0.055844 seconds and 4 git commands to generate.