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"
16 * Asserts that a given variable `_obj` named `_obj_name` (capitalized)
17 * and having the ID `_obj_id` (within the function's context) is not
20 #define BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _obj_id, _obj, _obj_name) \
21 BT_ASSERT_PRE_FROM_FUNC(_func, "not-null:" _obj_id, (_obj), \
22 "%s is NULL.", _obj_name)
24 #define BT_ASSERT_PRE_NON_NULL(_obj_id, _obj, _obj_name) \
25 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(__func__, _obj_id, (_obj), _obj_name)
28 * Asserts that a given index `_index` is less than a given length
31 #define BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(_func, _index, _length) \
32 BT_ASSERT_PRE_FROM_FUNC(_func, "valid-index", (_index) < (_length), \
33 "Index is out of bounds: index=%" PRIu64 ", " \
34 "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_length))
36 #define BT_ASSERT_PRE_VALID_INDEX(_index, _length) \
37 BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(__func__, (_index), (_length))
40 * Asserts that the current thread has no error set.
42 #define BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(_func) \
44 const struct bt_error *err = bt_current_thread_take_error(); \
46 bt_current_thread_move_error(err); \
48 BT_ASSERT_PRE_FROM_FUNC(_func, "no-error", !err, \
49 "API function called while current thread has an " \
50 "error: function=%s", _func); \
53 #define BT_ASSERT_PRE_NO_ERROR() \
54 BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(__func__)
57 * Asserts that, if the current thread has an error, `_status` is an
60 * See _BT_ASSERT_COND() for details about the `_func` parameter.
62 * Puts back the error in place (if there is one) such that if this
63 * macro aborts, it will be possible to inspect it with a debugger.
65 #define BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \
67 const struct bt_error *_err = bt_current_thread_take_error(); \
69 bt_current_thread_move_error(_err); \
71 BT_ASSERT_POST(_func, "no-error-if-no-error-status", \
72 (_status) < 0 || !_err, \
73 "Current thread has an error, but user function " \
74 "returned a non-error status: status=%s", \
75 bt_common_func_status_string(_status)); \
79 * Asserts that the current thread has no error.
81 * See _BT_ASSERT_COND() for details about the `_func` parameter.
83 #define BT_ASSERT_POST_NO_ERROR(_func) \
85 const struct bt_error *_err = bt_current_thread_take_error(); \
87 bt_current_thread_move_error(_err); \
89 BT_ASSERT_POST(_func, "no-error", !_err, \
90 "Current thread has an error"); \
94 /* Developer mode version of BT_ASSERT_PRE_NON_NULL_FROM_FUNC() */
95 # define BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, _obj_id, _obj, _obj_name) \
96 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _obj_id, (_obj), (_obj_name))
98 /* Developer mode version of BT_ASSERT_PRE_NON_NULL() */
99 # define BT_ASSERT_PRE_DEV_NON_NULL(_obj_id, _obj, _obj_name) \
100 BT_ASSERT_PRE_NON_NULL(_obj_id, (_obj), (_obj_name))
103 * Developer mode: asserts that a given object `_obj` named `_obj_name`
104 * (capitalized) and having the ID `_obj_id` (within the function's
105 * context) is NOT frozen.
107 * This macro checks the `frozen` field of `_obj`.
109 * This currently only exists in developer mode because some freezing
110 * functions can be called on the fast path, so they too are only
111 * enabled in developer mode.
113 # define BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(_func, _obj_id, _obj, _obj_name, _fmt, ...) \
114 BT_ASSERT_PRE_FROM_FUNC(_func, "not-frozen:" _obj_id, \
115 !(_obj)->frozen, "%s is frozen" _fmt, _obj_name, ##__VA_ARGS__)
117 # define BT_ASSERT_PRE_DEV_HOT(_obj_id, _obj, _obj_name, _fmt, ...) \
118 BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(__func__, _obj_id, (_obj), \
119 _obj_name, _fmt, ##__VA_ARGS__)
121 /* Developer mode version of BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC() */
122 # define BT_ASSERT_PRE_DEV_VALID_INDEX_FROM_FUNC(_func, _index, _length) \
123 BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(_func, (_index), (_length))
125 /* Developer mode version of BT_ASSERT_PRE_VALID_INDEX() */
126 # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \
127 BT_ASSERT_PRE_VALID_INDEX((_index), (_length))
129 /* Developer mode version of BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(). */
130 # define BT_ASSERT_PRE_DEV_NO_ERROR_FROM_FUNC(_func) \
131 BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(_func)
133 /* Developer mode version of BT_ASSERT_PRE_NO_ERROR(). */
134 # define BT_ASSERT_PRE_DEV_NO_ERROR() BT_ASSERT_PRE_NO_ERROR()
137 * Developer mode version of
138 * BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS().
140 # define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \
141 BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_func, (_status))
143 /* Developer mode version of BT_ASSERT_POST_NO_ERROR(). */
144 # define BT_ASSERT_POST_DEV_NO_ERROR(_func) \
145 BT_ASSERT_POST_NO_ERROR(_func)
148 * Marks a function as being only used within a BT_ASSERT_PRE_DEV() or
149 * BT_ASSERT_POST_DEV() context.
151 # define BT_ASSERT_COND_DEV_FUNC
153 # define BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, _obj_id, _obj, _obj_name) \
154 BT_USE_EXPR4(_func, _obj_id, (_obj), _obj_name)
156 # define BT_ASSERT_PRE_DEV_NON_NULL(_obj_id, _obj, _obj_name) \
157 BT_USE_EXPR3(_obj_id, (_obj), _obj_name)
159 # define BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(_func, _obj_id, _obj, _obj_name, _fmt, ...) \
160 BT_USE_EXPR5(_func, _obj_id, (_obj), _obj_name, _fmt)
162 # define BT_ASSERT_PRE_DEV_HOT(_obj_id, _obj, _obj_name, _fmt, ...) \
163 BT_USE_EXPR4(_obj_id, (_obj), _obj_name, _fmt)
165 # define BT_ASSERT_PRE_DEV_VALID_INDEX_FROM_FUNC(_func, _index, _length) \
166 BT_USE_EXPR3(_func, (_index), (_length))
168 # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \
169 BT_USE_EXPR2((_index), (_length))
171 # define BT_ASSERT_PRE_DEV_NO_ERROR_FROM_FUNC(_func) \
174 # define BT_ASSERT_PRE_DEV_NO_ERROR()
176 # define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \
177 BT_USE_EXPR2(_func, _status)
179 # define BT_ASSERT_POST_DEV_NO_ERROR(_func) \
181 #endif /* BT_DEV_MODE */
183 #define _BT_ASSERT_PRE_CLK_CLS_NAME "Clock class"
184 #define _BT_ASSERT_PRE_CLK_CLS_ID "clock-class"
186 #define BT_ASSERT_PRE_CLK_CLS_NON_NULL(_cc) \
187 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CLK_CLS_ID, (_cc), \
188 _BT_ASSERT_PRE_CLK_CLS_NAME)
190 #define BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(_cc) \
191 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CLK_CLS_ID, (_cc), \
192 _BT_ASSERT_PRE_CLK_CLS_NAME)
194 #define _BT_ASSERT_PRE_DEF_CLK_CLS_NAME "Default clock class"
195 #define _BT_ASSERT_PRE_DEF_CLK_CLS_ID "default-clock-class"
197 #define BT_ASSERT_PRE_DEF_CLK_CLS_NON_NULL(_cc) \
198 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_DEF_CLK_CLS_ID, (_cc), \
199 _BT_ASSERT_PRE_DEF_CLK_CLS_NAME)
201 #define BT_ASSERT_PRE_DEV_DEF_CLK_CLS_NON_NULL(_cc) \
202 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_DEF_CLK_CLS_ID, \
203 (_cc), _BT_ASSERT_PRE_DEF_CLK_CLS_NAME)
205 #define _BT_ASSERT_PRE_CS_NAME "Clock snapshot"
206 #define _BT_ASSERT_PRE_CS_ID "clock-snapshot"
208 #define BT_ASSERT_PRE_CS_NON_NULL(_cs) \
209 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CS_ID, (_cs), \
210 _BT_ASSERT_PRE_CS_NAME)
212 #define BT_ASSERT_PRE_DEV_CS_NON_NULL(_cs) \
213 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CS_ID, (_cs), \
214 _BT_ASSERT_PRE_CS_NAME)
216 #define _BT_ASSERT_PRE_EVENT_NAME "Event"
217 #define _BT_ASSERT_PRE_EVENT_ID "event"
219 #define BT_ASSERT_PRE_EVENT_NON_NULL(_event) \
220 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_EVENT_ID, (_event), \
221 _BT_ASSERT_PRE_EVENT_NAME)
223 #define BT_ASSERT_PRE_DEV_EVENT_NON_NULL(_event) \
224 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_EVENT_ID, (_event), \
225 _BT_ASSERT_PRE_EVENT_NAME)
227 #define _BT_ASSERT_PRE_EC_NAME "Event class"
228 #define _BT_ASSERT_PRE_EC_ID "event-class"
230 #define BT_ASSERT_PRE_EC_NON_NULL_FROM_FUNC(_func, _ec) \
231 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_EC_ID, \
232 (_ec), _BT_ASSERT_PRE_EC_NAME)
234 #define BT_ASSERT_PRE_EC_NON_NULL(_ec) \
235 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_EC_ID, (_ec), \
236 _BT_ASSERT_PRE_EC_NAME)
238 #define BT_ASSERT_PRE_DEV_EC_NON_NULL_FROM_FUNC(_func, _ec) \
239 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
240 _BT_ASSERT_PRE_EC_ID, (_ec), _BT_ASSERT_PRE_EC_NAME)
242 #define BT_ASSERT_PRE_DEV_EC_NON_NULL(_ec) \
243 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_EC_ID, (_ec), \
244 _BT_ASSERT_PRE_EC_NAME)
246 #define _BT_ASSERT_PRE_FC_IS_INT_COND(_fc) \
247 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
248 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
249 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \
250 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
252 #define _BT_ASSERT_PRE_FC_IS_INT_FMT(_name) \
253 _name " is not an integer field class: %![fc-]+F"
255 #define _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id) "is-int-field-class:" _fc_id
257 #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc) \
258 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
259 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION)
261 #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name) \
262 _name " is not an unsigned integer field class: %![fc-]+F"
264 #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id) \
265 "is-unsigned-integer-field-class:" _fc_id
267 #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc) \
268 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
269 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
271 #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name) \
272 _name " is not a signed integer field class: %![fc-]+F"
274 #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id) \
275 "is-signed-integer-field-class:" _fc_id
277 #define _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc) \
278 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \
279 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
281 #define _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name) \
282 _name " is not an enumeration field class: %![fc-]+F"
284 #define _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id) \
285 "is-enumeration-field-class:" _fc_id
287 #define _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc) \
288 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
289 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
290 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD)
292 #define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name) \
293 _name " is not an array field class: %![fc-]+F"
295 #define _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id) \
296 "is-array-field-class:" _fc_id
298 #define _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc) \
299 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \
300 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
301 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
302 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
304 #define _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name) \
305 _name " is not an option field class: %![fc-]+F"
307 #define _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id) \
308 "is-option-field-class:" _fc_id
310 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc) \
311 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
312 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
313 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
315 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name) \
316 _name " is not an option field class with a selector: %![fc-]+F"
318 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_ID(_fc_id) \
319 "is-option-field-class-with-selector:" _fc_id
321 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc) \
322 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
323 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
325 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name) \
326 _name " is not an option field class with an integer selector: %![fc-]+F"
328 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_ID(_fc_id) \
329 "is-option-field-class-with-integer-selector:" _fc_id
331 #define _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name) \
332 _name " is not a structure field class: %![fc-]+F"
334 #define _BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc) \
335 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STRUCTURE)
337 #define _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id) \
338 "is-structure-field-class:" _fc_id
340 #define _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc) \
341 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \
342 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
343 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
345 #define _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name) \
346 _name " is not a variant field class: %![fc-]+F"
348 #define _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id) \
349 "is-variant-field-class:" _fc_id
351 #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc) \
352 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
353 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
355 #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name) \
356 _name " is not a variant field class with a selector: %![fc-]+F"
358 #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id) \
359 "is-variant-field-class-with-selector:" _fc_id
361 #define _BT_ASSERT_PRE_FC_HAS_TYPE_COND(_fc, _type) \
362 (((const struct bt_field_class *) (_fc))->type == (_type))
364 #define _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name) \
365 _name " has the wrong type: expected-type=%s, %![fc-]+F"
367 #define _BT_ASSERT_PRE_FC_HAS_TYPE_ID(_fc_id, _type_id) \
368 "is-" _type_id ":" _fc_id
370 #define BT_ASSERT_PRE_FC_IS_INT_FROM_FUNC(_func, _fc_id, _fc, _name) \
371 BT_ASSERT_PRE_FROM_FUNC(_func, \
372 _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id), \
373 _BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \
374 _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc))
376 #define BT_ASSERT_PRE_FC_IS_INT(_fc_id, _fc, _name) \
377 BT_ASSERT_PRE_FC_IS_INT_FROM_FUNC(__func__, _fc_id, (_fc), _name)
379 #define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc_id, _fc, _name) \
381 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id), \
382 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \
383 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc))
385 #define BT_ASSERT_PRE_FC_IS_SIGNED_INT(_fc_id, _fc, _name) \
387 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id), \
388 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc), \
389 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc))
391 #define BT_ASSERT_PRE_FC_IS_ENUM(_fc_id, _fc, _name) \
393 _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id), \
394 _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \
395 _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc))
397 #define BT_ASSERT_PRE_FC_IS_ARRAY(_fc_id, _fc, _name) \
399 _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id), \
400 _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \
401 _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc))
403 #define BT_ASSERT_PRE_FC_IS_STRUCT(_fc_id, _fc, _name) \
405 _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id), \
406 _BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc), \
407 _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name), (_fc))
409 #define BT_ASSERT_PRE_FC_IS_OPTION(_fc_id, _fc, _name) \
411 _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id), \
412 _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc), \
413 _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc))
415 #define BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL(_fc_id, _fc, _name) \
417 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_ID(_fc_id), \
418 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \
419 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
421 #define BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(_fc_id, _fc, _name) \
423 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_ID(_fc_id), \
424 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \
425 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc))
427 #define BT_ASSERT_PRE_FC_IS_VARIANT(_fc_id, _fc, _name) \
429 _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id), \
430 _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc), \
431 _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc))
433 #define BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL(_fc_id, _fc, _name) \
435 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id), \
436 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \
437 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc))
439 #define BT_ASSERT_PRE_FC_HAS_TYPE_FROM_FUNC(_func, _fc_id, _fc, _type_id, _type, _name) \
440 BT_ASSERT_PRE_FROM_FUNC(_func, \
441 _BT_ASSERT_PRE_FC_HAS_TYPE_ID(_fc_id, _type_id), \
442 _BT_ASSERT_PRE_FC_HAS_TYPE_COND((_fc), (_type)), \
443 _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name), \
444 bt_common_field_class_type_string(_type), (_fc))
446 #define BT_ASSERT_PRE_FC_HAS_TYPE(_fc_id, _fc, _type_id, _type, _name) \
447 BT_ASSERT_PRE_FC_HAS_TYPE_FROM_FUNC(__func__, _fc_id, (_fc), \
448 _type_id, (_type), _name)
450 #define BT_ASSERT_PRE_DEV_FC_IS_INT(_fc_id, _fc, _name) \
452 _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id), \
453 _BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \
454 _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc))
456 #define BT_ASSERT_PRE_DEV_FC_IS_UNSIGNED_INT(_fc_id, _fc, _name) \
458 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id), \
459 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \
460 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc))
462 #define BT_ASSERT_PRE_DEV_FC_IS_SIGNED_INT(_fc_id, _fc, _name) \
464 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id), \
465 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc), \
466 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc))
468 #define BT_ASSERT_PRE_DEV_FC_IS_ENUM(_fc_id, _fc, _name) \
470 _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id), \
471 _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \
472 _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc))
474 #define BT_ASSERT_PRE_DEV_FC_IS_ARRAY(_fc_id, _fc, _name) \
476 _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id), \
477 _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \
478 _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc))
480 #define BT_ASSERT_PRE_DEV_FC_IS_STRUCT(_fc_id, _fc, _name) \
482 _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id), \
483 _BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc), \
484 _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name), (_fc))
486 #define BT_ASSERT_PRE_DEV_FC_IS_OPTION(_fc_id, _fc, _name) \
488 _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id), \
489 _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc), \
490 _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc))
492 #define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_SEL(_fc_id, _fc, _name) \
494 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \
495 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
497 #define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_INT_SEL(_fc_id, _fc, _name) \
499 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_ID(_fc_id), \
500 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \
501 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc))
503 #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT(_fc_id, _fc, _name) \
505 _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id), \
506 _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc), \
507 _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc))
509 #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL(_fc_id, _fc, _name) \
511 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id), \
512 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \
513 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc))
515 #define BT_ASSERT_PRE_DEV_FC_HAS_TYPE(_fc_id, _fc, _type_id, _type, _name) \
517 _BT_ASSERT_PRE_FC_HAS_TYPE_ID(_fc_id, _type_id), \
518 _BT_ASSERT_PRE_FC_HAS_TYPE_COND((_fc), (_type)), \
519 _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name), \
520 bt_common_field_class_type_string(_type), (_fc))
522 #define BT_ASSERT_PRE_DEV_FC_HOT_FROM_FUNC(_func, _fc) \
523 BT_ASSERT_PRE_DEV_HOT_FROM_FUNC(_func, "field-class", \
524 (const struct bt_field_class *) (_fc), \
525 "Field class", ": %!+F", (_fc))
527 #define BT_ASSERT_PRE_DEV_FC_HOT(_fc) \
528 BT_ASSERT_PRE_DEV_FC_HOT_FROM_FUNC(__func__, (_fc))
530 #define _BT_ASSERT_PRE_FC_NAME "Field class"
531 #define _BT_ASSERT_PRE_FC_ID "field-class"
533 #define BT_ASSERT_PRE_FC_NON_NULL(_fc) \
534 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FC_ID, (_fc), \
535 _BT_ASSERT_PRE_FC_NAME)
537 #define BT_ASSERT_PRE_DEV_FC_NON_NULL(_fc) \
538 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FC_ID, (_fc), \
539 _BT_ASSERT_PRE_FC_NAME)
541 #define _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME "Structure field class member"
542 #define _BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID "structure-field-class-member"
544 #define BT_ASSERT_PRE_STRUCT_FC_MEMBER_NON_NULL(_fc) \
545 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID, \
546 (_fc), _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME)
548 #define BT_ASSERT_PRE_DEV_STRUCT_FC_MEMBER_NON_NULL(_fc) \
549 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID, \
550 (_fc), _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME)
552 #define _BT_ASSERT_PRE_VAR_FC_OPT_NAME "Variant field class option"
553 #define _BT_ASSERT_PRE_VAR_FC_OPT_ID "variant-field-class-option-id"
555 #define BT_ASSERT_PRE_VAR_FC_OPT_NON_NULL(_fc) \
556 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_VAR_FC_OPT_ID, (_fc), \
557 _BT_ASSERT_PRE_VAR_FC_OPT_NAME)
559 #define BT_ASSERT_PRE_DEV_VAR_FC_OPT_NON_NULL(_fc) \
560 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_VAR_FC_OPT_ID, (_fc), \
561 _BT_ASSERT_PRE_VAR_FC_OPT_NAME)
563 #define _BT_ASSERT_PRE_FP_NAME "Field path"
564 #define _BT_ASSERT_PRE_FP_ID "field-path"
566 #define BT_ASSERT_PRE_FP_NON_NULL(_fp) \
567 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FP_ID, (_fp), \
568 _BT_ASSERT_PRE_FP_NAME)
570 #define BT_ASSERT_PRE_DEV_FP_NON_NULL(_fp) \
571 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FP_ID, (_fp), \
572 _BT_ASSERT_PRE_FP_NAME)
574 #define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE_FROM_FUNC(_func, _field_id, _field, _cls_type_id, _cls_type, _name) \
575 BT_ASSERT_PRE_DEV_FROM_FUNC(_func, "is-" _cls_type_id ":" _field_id, \
576 ((const struct bt_field *) (_field))->class->type == (_cls_type), \
577 _name " has the wrong class type: expected-class-type=%s, " \
579 bt_common_field_class_type_string(_cls_type), (_field))
581 #define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(_field_id, _field, _cls_type_id, _cls_type, _name) \
582 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE_FROM_FUNC(__func__, \
583 _field_id, (_field), _cls_type_id, _cls_type, _name)
585 #define BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(_field_id, _field, _name) \
587 "is-unsigned-integer-field:" _field_id, \
588 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
589 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, \
590 _name " is not an unsigned integer field: %![field-]+f", \
593 #define BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(_field_id, _field, _name) \
595 "is-signed-integer-field:" _field_id, \
596 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
597 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, \
598 _name " is not a signed integer field: %![field-]+f", \
601 #define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY_FROM_FUNC(_func, _field_id, _field, _name) \
602 BT_ASSERT_PRE_DEV_FROM_FUNC(_func, \
603 "is-array-field:" _field_id, \
604 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
605 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
606 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
607 _name " is not an array field: %![field-]+f", (_field))
609 #define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(_field_id, _field, _name) \
610 BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY_FROM_FUNC(__func__, _field_id, \
613 #define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(_field_id, _field, _name) \
615 "is-dynamic-array-field:" _field_id, \
616 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
617 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
618 _name " is not a dynamic array field: %![field-]+f", (_field))
620 #define BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(_field_id, _field, _name) \
622 "is-option-field:" _field_id, \
623 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \
624 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
625 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
626 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD, \
627 _name " is not an option field: %![field-]+f", (_field))
629 #define BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(_field_id, _field, _name) \
631 "is-variant-field:" _field_id, \
632 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \
633 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
634 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD, \
635 _name " is not a variant field: %![field-]+f", (_field))
637 #define BT_ASSERT_PRE_DEV_FIELD_IS_SET(_field_id, _field) \
638 BT_ASSERT_PRE_DEV("is-field-set:" _field_id, \
639 bt_field_is_set(_field), \
640 "Field is not set: %!+f", (_field))
642 #define _BT_ASSERT_PRE_FIELD_NAME "Field"
643 #define _BT_ASSERT_PRE_FIELD_ID "field"
645 #define BT_ASSERT_PRE_FIELD_NON_NULL(_field) \
646 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field), \
647 _BT_ASSERT_PRE_FIELD_NAME)
649 #define BT_ASSERT_PRE_DEV_FIELD_NON_NULL_FROM_FUNC(_func, _field) \
650 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
651 _BT_ASSERT_PRE_FIELD_ID, (_field), \
652 _BT_ASSERT_PRE_FIELD_NAME)
654 #define BT_ASSERT_PRE_DEV_FIELD_NON_NULL(_field) \
655 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field), \
656 _BT_ASSERT_PRE_FIELD_NAME)
658 #define _BT_ASSERT_PRE_PACKET_NAME "Packet"
659 #define _BT_ASSERT_PRE_PACKET_ID "packet"
661 #define BT_ASSERT_PRE_PACKET_NON_NULL_FROM_FUNC(_func, _packet) \
662 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
663 _BT_ASSERT_PRE_PACKET_ID, (_packet), _BT_ASSERT_PRE_PACKET_NAME)
665 #define BT_ASSERT_PRE_PACKET_NON_NULL(_packet) \
666 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PACKET_ID, (_packet), \
667 _BT_ASSERT_PRE_PACKET_NAME)
669 #define BT_ASSERT_PRE_DEV_PACKET_NON_NULL_FROM_FUNC(_func, _packet) \
670 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
671 _BT_ASSERT_PRE_PACKET_ID, (_packet), _BT_ASSERT_PRE_PACKET_NAME)
673 #define BT_ASSERT_PRE_DEV_PACKET_NON_NULL(_packet) \
674 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PACKET_ID, (_packet), \
675 _BT_ASSERT_PRE_PACKET_NAME)
677 #define _BT_ASSERT_PRE_SC_NAME "Stream class"
678 #define _BT_ASSERT_PRE_SC_ID "stream-class"
680 #define BT_ASSERT_PRE_SC_NON_NULL(_sc) \
681 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_SC_ID, (_sc), \
682 _BT_ASSERT_PRE_SC_NAME)
684 #define BT_ASSERT_PRE_DEV_SC_NON_NULL(_sc) \
685 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_SC_ID, (_sc), \
686 _BT_ASSERT_PRE_SC_NAME)
688 #define _BT_ASSERT_PRE_STREAM_NAME "Stream"
689 #define _BT_ASSERT_PRE_STREAM_ID "stream"
691 #define BT_ASSERT_PRE_STREAM_NON_NULL_FROM_FUNC(_func, _stream) \
692 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
693 _BT_ASSERT_PRE_STREAM_ID, (_stream), \
694 _BT_ASSERT_PRE_STREAM_NAME)
696 #define BT_ASSERT_PRE_STREAM_NON_NULL(_stream) \
697 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_STREAM_ID, (_stream), \
698 _BT_ASSERT_PRE_STREAM_NAME)
700 #define BT_ASSERT_PRE_DEV_STREAM_NON_NULL_FROM_FUNC(_func, _stream) \
701 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
702 _BT_ASSERT_PRE_STREAM_ID, (_stream), \
703 _BT_ASSERT_PRE_STREAM_NAME)
705 #define BT_ASSERT_PRE_DEV_STREAM_NON_NULL(_stream) \
706 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_STREAM_ID, (_stream), \
707 _BT_ASSERT_PRE_STREAM_NAME)
709 #define _BT_ASSERT_PRE_TC_NAME "Trace class"
710 #define _BT_ASSERT_PRE_TC_ID "trace-class"
712 #define BT_ASSERT_PRE_TC_NON_NULL_FROM_FUNC(_func, _tc) \
713 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_TC_ID, \
714 (_tc), _BT_ASSERT_PRE_TC_NAME)
716 #define BT_ASSERT_PRE_TC_NON_NULL(_tc) \
717 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_TC_ID, (_tc), \
718 _BT_ASSERT_PRE_TC_NAME)
720 #define BT_ASSERT_PRE_DEV_TC_NON_NULL(_tc) \
721 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_TC_ID, (_tc), \
722 _BT_ASSERT_PRE_TC_NAME)
724 #define _BT_ASSERT_PRE_TRACE_NAME "Trace"
725 #define _BT_ASSERT_PRE_TRACE_ID "trace"
727 #define BT_ASSERT_PRE_TRACE_NON_NULL(_trace) \
728 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_TRACE_ID, (_trace), \
729 _BT_ASSERT_PRE_TRACE_NAME)
731 #define BT_ASSERT_PRE_DEV_TRACE_NON_NULL(_trace) \
732 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_TRACE_ID, (_trace), \
733 _BT_ASSERT_PRE_TRACE_NAME)
735 #define _BT_ASSERT_PRE_USER_ATTRS_NAME "User attributes value object"
736 #define _BT_ASSERT_PRE_USER_ATTRS_ID "user-attributes-value-object"
738 #define BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(_func, _ua) \
739 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
740 _BT_ASSERT_PRE_USER_ATTRS_ID, (_ua), \
741 _BT_ASSERT_PRE_USER_ATTRS_NAME)
743 #define BT_ASSERT_PRE_USER_ATTRS_NON_NULL(_ua) \
744 BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(__func__, (_ua))
746 #define BT_ASSERT_PRE_DEV_USER_ATTRS_NON_NULL(_ua) \
747 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_USER_ATTRS_ID, (_ua), \
748 _BT_ASSERT_PRE_USER_ATTRS_NAME)
750 #define BT_ASSERT_PRE_USER_ATTRS_IS_MAP_FROM_FUNC(_func, _ua) \
751 BT_ASSERT_PRE_FROM_FUNC(_func, "is-map-value:user-attributes", \
752 (_ua)->type == BT_VALUE_TYPE_MAP, \
753 _BT_ASSERT_PRE_USER_ATTRS_NAME \
754 " object is not a map value object.")
756 #define BT_ASSERT_PRE_USER_ATTRS_IS_MAP(_ua) \
757 BT_ASSERT_PRE_USER_ATTRS_IS_MAP_FROM_FUNC(__func__, (_ua))
759 #define BT_ASSERT_COND_LISTENER_FUNC_NAME "Listener function"
760 #define BT_ASSERT_COND_LISTENER_FUNC_ID "listener-function"
762 #define BT_ASSERT_PRE_LISTENER_FUNC_NON_NULL(_listener_func) \
763 BT_ASSERT_PRE_NON_NULL(BT_ASSERT_COND_LISTENER_FUNC_ID, \
764 (_listener_func), BT_ASSERT_COND_LISTENER_FUNC_NAME)
766 #define BT_ASSERT_PRE_DEV_LISTENER_FUNC_NON_NULL(_listener_func) \
767 BT_ASSERT_PRE_DEV_NON_NULL(BT_ASSERT_COND_LISTENER_FUNC_ID, \
768 (_listener_func), BT_ASSERT_COND_LISTENER_FUNC_NAME)
770 #define _BT_ASSERT_PRE_MSG_ITER_NAME "Message iterator"
771 #define _BT_ASSERT_PRE_MSG_ITER_ID "message-iterator"
773 #define BT_ASSERT_PRE_MSG_ITER_NON_NULL_FROM_FUNC(_func, _msg_iter) \
774 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
775 _BT_ASSERT_PRE_MSG_ITER_ID, (_msg_iter), \
776 _BT_ASSERT_PRE_MSG_ITER_NAME)
778 #define BT_ASSERT_PRE_MSG_ITER_NON_NULL(_msg_iter) \
779 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_ID, (_msg_iter), \
780 _BT_ASSERT_PRE_MSG_ITER_NAME)
782 #define BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL_FROM_FUNC(_func, _msg_iter) \
783 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
784 _BT_ASSERT_PRE_MSG_ITER_ID, \
785 (_msg_iter), _BT_ASSERT_PRE_MSG_ITER_NAME)
787 #define BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL(_msg_iter) \
788 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_ID, \
789 (_msg_iter), _BT_ASSERT_PRE_MSG_ITER_NAME)
791 #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc) \
792 ((_sc)->default_clock_class)
794 #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT \
795 "Message's stream's class has no default clock class: " \
796 "%![msg-]+n, %![sc-]+S"
798 #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID \
799 "message-stream-class-has-default-clock-class"
801 #define BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FROM_FUNC(_func, _msg, _sc) \
802 BT_ASSERT_PRE_FROM_FUNC(_func, \
803 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID, \
804 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc), \
805 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT, \
808 #define BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS(_msg, _sc) \
809 BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FROM_FUNC(__func__, (_msg), (_sc))
811 #define BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(_func, _msg, _sc) \
812 BT_ASSERT_PRE_DEV_FROM_FUNC(_func, \
813 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID, \
814 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc), \
815 _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_FMT, \
818 #define BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS(_msg, _sc) \
819 BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(__func__, (_msg), (_sc))
821 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_COND(_msg, _type) \
822 (((struct bt_message *) (_msg))->type == (_type))
824 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT \
825 "Message has the wrong type: expected-type=%s, %![msg-]+n"
827 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id) \
828 "is-" _type_id "-message:" _msg_id
830 #define BT_ASSERT_PRE_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type) \
832 _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id), \
833 _BT_ASSERT_PRE_MSG_HAS_TYPE_COND((_msg), (_type)), \
834 _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT, \
835 bt_common_message_type_string(_type), (_msg))
837 #define BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type) \
839 _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id), \
840 _BT_ASSERT_PRE_MSG_HAS_TYPE_COND((_msg), (_type)), \
841 _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT, \
842 bt_common_message_type_string(_type), (_msg))
844 #define _BT_ASSERT_PRE_MSG_NAME "Message"
845 #define _BT_ASSERT_PRE_MSG_ID "message"
847 #define BT_ASSERT_PRE_MSG_NON_NULL(_msg_iter) \
848 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ID, (_msg_iter), \
849 _BT_ASSERT_PRE_MSG_NAME)
851 #define BT_ASSERT_PRE_DEV_MSG_NON_NULL(_msg_iter) \
852 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ID, (_msg_iter), \
853 _BT_ASSERT_PRE_MSG_NAME)
855 #define BT_ASSERT_PRE_MSG_CS_BEGIN_LE_END(_msg_iter, _begin, _end) \
856 BT_ASSERT_PRE("beginning-default-clock-snapshot-lteq-end", \
857 (_begin) <= (_end), \
858 "Beginning default clock snapshot value is greater " \
859 "than end default clock snapshot value: " \
860 "cs-begin-val=%" PRIu64 ", cs-end-val=%" PRIu64 ", " \
861 "%![msg-iter-]+i", (_begin), (_end), _msg_iter);
863 #define BT_ASSERT_PRE_DEV_MSG_HOT(_msg) \
864 BT_ASSERT_PRE_DEV_HOT("message", (_msg), "Message", ": %!+n", (_msg));
866 #define _BT_ASSERT_PRE_MSG_ITER_CLS_NAME "Message iterator class"
867 #define _BT_ASSERT_PRE_MSG_ITER_CLS_ID "message-iterator-class"
869 #define BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(_msg_iter_cls) \
870 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_CLS_ID, \
871 (_msg_iter_cls), _BT_ASSERT_PRE_MSG_ITER_CLS_NAME)
873 #define BT_ASSERT_PRE_DEV_MSG_ITER_CLS_NON_NULL(_msg_iter_cls) \
874 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_CLS_ID, \
875 (_msg_iter_cls), _BT_ASSERT_PRE_MSG_ITER_CLS_NAME)
877 #define _BT_ASSERT_PRE_COMP_CLS_NAME "Component class"
878 #define _BT_ASSERT_PRE_COMP_CLS_ID "component-class"
880 #define BT_ASSERT_PRE_COMP_CLS_NON_NULL_FROM_FUNC(_func, _comp_cls) \
881 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
882 _BT_ASSERT_PRE_COMP_CLS_ID, (_comp_cls), \
883 _BT_ASSERT_PRE_COMP_CLS_NAME)
885 #define BT_ASSERT_PRE_COMP_CLS_NON_NULL(_comp_cls) \
886 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_CLS_ID, (_comp_cls), \
887 _BT_ASSERT_PRE_COMP_CLS_NAME)
889 #define BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(_comp_cls) \
890 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_CLS_ID, \
891 (_comp_cls), _BT_ASSERT_PRE_COMP_CLS_NAME)
893 #define _BT_ASSERT_PRE_COMP_DESCR_SET_NAME "Component descriptor set"
894 #define _BT_ASSERT_PRE_COMP_DESCR_SET_ID "component-descriptor-set"
896 #define BT_ASSERT_PRE_COMP_DESCR_SET_NON_NULL(_comp_descr_set) \
897 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_DESCR_SET_ID, \
898 (_comp_descr_set), _BT_ASSERT_PRE_COMP_DESCR_SET_NAME)
900 #define BT_ASSERT_PRE_DEV_COMP_DESCR_SET_NON_NULL(_comp_descr_set) \
901 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_DESCR_SET_ID, \
902 (_comp_descr_set), _BT_ASSERT_PRE_COMP_DESCR_SET_NAME)
904 #define _BT_ASSERT_PRE_COMP_NAME "Component"
905 #define _BT_ASSERT_PRE_COMP_ID "component"
907 #define BT_ASSERT_PRE_COMP_NON_NULL_FROM_FUNC(_func, _comp) \
908 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_COMP_ID, \
909 (_comp), _BT_ASSERT_PRE_COMP_NAME)
911 #define BT_ASSERT_PRE_COMP_NON_NULL(_comp) \
912 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_ID, (_comp), \
913 _BT_ASSERT_PRE_COMP_NAME)
915 #define BT_ASSERT_PRE_DEV_COMP_NON_NULL_FROM_FUNC(_func, _comp) \
916 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
917 _BT_ASSERT_PRE_COMP_ID, (_comp), _BT_ASSERT_PRE_COMP_NAME)
919 #define BT_ASSERT_PRE_DEV_COMP_NON_NULL(_comp) \
920 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_ID, (_comp), \
921 _BT_ASSERT_PRE_COMP_NAME)
923 #define _BT_ASSERT_PRE_CONN_NAME "Connection"
924 #define _BT_ASSERT_PRE_CONN_ID "connection"
926 #define BT_ASSERT_PRE_CONN_NON_NULL(_conn) \
927 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CONN_ID, (_conn), \
928 _BT_ASSERT_PRE_CONN_NAME)
930 #define BT_ASSERT_PRE_DEV_CONN_NON_NULL(_conn) \
931 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CONN_ID, (_conn), \
932 _BT_ASSERT_PRE_CONN_NAME)
934 #define _BT_ASSERT_PRE_GRAPH_NAME "Graph"
935 #define _BT_ASSERT_PRE_GRAPH_ID "graph"
937 #define BT_ASSERT_PRE_GRAPH_NON_NULL_FROM_FUNC(_func, _graph) \
938 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
939 _BT_ASSERT_PRE_GRAPH_ID, (_graph), _BT_ASSERT_PRE_GRAPH_NAME)
941 #define BT_ASSERT_PRE_GRAPH_NON_NULL(_graph) \
942 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_GRAPH_ID, (_graph), \
943 _BT_ASSERT_PRE_GRAPH_NAME)
945 #define BT_ASSERT_PRE_DEV_GRAPH_NON_NULL(_graph) \
946 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_GRAPH_ID, (_graph), \
947 _BT_ASSERT_PRE_GRAPH_NAME)
949 #define _BT_ASSERT_PRE_INTR_NAME "Interrupter"
950 #define _BT_ASSERT_PRE_INTR_ID "interrupter"
952 #define BT_ASSERT_PRE_INTR_NON_NULL(_intr) \
953 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INTR_ID, (_intr), \
954 _BT_ASSERT_PRE_INTR_NAME)
956 #define BT_ASSERT_PRE_DEV_INTR_NON_NULL(_intr) \
957 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INTR_ID, (_intr), \
958 _BT_ASSERT_PRE_INTR_NAME)
960 #define _BT_ASSERT_PRE_PORT_NAME "Port"
961 #define _BT_ASSERT_PRE_PORT_ID "port"
963 #define BT_ASSERT_PRE_PORT_NON_NULL(_port) \
964 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PORT_ID, (_port), \
965 _BT_ASSERT_PRE_PORT_NAME)
967 #define BT_ASSERT_PRE_DEV_PORT_NON_NULL(_port) \
968 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PORT_ID, (_port), \
969 _BT_ASSERT_PRE_PORT_NAME)
971 #define _BT_ASSERT_PRE_QUERY_EXEC_NAME "Query executor"
972 #define _BT_ASSERT_PRE_QUERY_EXEC_ID "query-executor"
974 #define BT_ASSERT_PRE_QUERY_EXEC_NON_NULL(_query_exec) \
975 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_QUERY_EXEC_ID, \
976 (_query_exec), _BT_ASSERT_PRE_QUERY_EXEC_NAME)
978 #define BT_ASSERT_PRE_DEV_QUERY_EXEC_NON_NULL(_query_exec) \
979 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_QUERY_EXEC_ID, \
980 (_query_exec), _BT_ASSERT_PRE_QUERY_EXEC_NAME)
982 #define _BT_ASSERT_PRE_PLUGIN_SET_NAME "Plugin set"
983 #define _BT_ASSERT_PRE_PLUGIN_SET_ID "plugin-set"
985 #define BT_ASSERT_PRE_PLUGIN_SET_NON_NULL(_plugin_set) \
986 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_ID, \
987 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_NAME)
989 #define BT_ASSERT_PRE_DEV_PLUGIN_SET_NON_NULL(_plugin_set) \
990 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_ID, \
991 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_NAME)
993 #define _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME \
994 _BT_ASSERT_PRE_PLUGIN_SET_NAME " (output)"
995 #define _BT_ASSERT_PRE_PLUGIN_SET_OUT_ID \
996 _BT_ASSERT_PRE_PLUGIN_SET_ID "-output"
998 #define BT_ASSERT_PRE_PLUGIN_SET_OUT_NON_NULL(_plugin_set) \
999 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_OUT_ID, \
1000 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME)
1002 #define BT_ASSERT_PRE_DEV_PLUGIN_SET_OUT_NON_NULL(_plugin_set) \
1003 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_OUT_ID, \
1004 (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME)
1006 #define _BT_ASSERT_PRE_PLUGIN_NAME "Plugin"
1007 #define _BT_ASSERT_PRE_PLUGIN_ID "plugin"
1009 #define BT_ASSERT_PRE_PLUGIN_NON_NULL(_plugin) \
1010 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_ID, (_plugin), \
1011 _BT_ASSERT_PRE_PLUGIN_NAME)
1013 #define BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(_plugin) \
1014 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_ID, (_plugin), \
1015 _BT_ASSERT_PRE_PLUGIN_NAME)
1017 #define _BT_ASSERT_PRE_PLUGIN_OUT_NAME \
1018 _BT_ASSERT_PRE_PLUGIN_NAME " (output)"
1019 #define _BT_ASSERT_PRE_PLUGIN_OUT_ID \
1020 _BT_ASSERT_PRE_PLUGIN_ID "-output"
1022 #define BT_ASSERT_PRE_PLUGIN_OUT_NON_NULL(_plugin) \
1023 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_OUT_ID, (_plugin), \
1024 _BT_ASSERT_PRE_PLUGIN_OUT_NAME)
1026 #define BT_ASSERT_PRE_DEV_PLUGIN_OUT_NON_NULL(_plugin) \
1027 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_OUT_ID, \
1028 (_plugin), _BT_ASSERT_PRE_PLUGIN_OUT_NAME)
1030 #define _BT_ASSERT_PRE_ERROR_NAME "Error"
1031 #define _BT_ASSERT_PRE_ERROR_ID "error"
1033 #define BT_ASSERT_PRE_ERROR_NON_NULL(_error) \
1034 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_ERROR_ID, (_error), \
1035 _BT_ASSERT_PRE_ERROR_NAME)
1037 #define BT_ASSERT_PRE_DEV_ERROR_NON_NULL(_error) \
1038 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_ERROR_ID, (_error), \
1039 _BT_ASSERT_PRE_ERROR_NAME)
1041 #define _BT_ASSERT_PRE_ERROR_CAUSE_NAME "Error cause"
1042 #define _BT_ASSERT_PRE_ERROR_CAUSE_ID "error-cause"
1044 #define BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(_error_cause) \
1045 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_ERROR_CAUSE_ID, \
1046 (_error_cause), _BT_ASSERT_PRE_ERROR_CAUSE_NAME)
1048 #define BT_ASSERT_PRE_DEV_ERROR_CAUSE_NON_NULL(_error_cause) \
1049 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_ERROR_CAUSE_ID, \
1050 (_error_cause), _BT_ASSERT_PRE_ERROR_CAUSE_NAME)
1052 #define _BT_ASSERT_PRE_INT_RANGE_NAME "Integer range"
1053 #define _BT_ASSERT_PRE_INT_RANGE_ID "integer-range"
1055 #define BT_ASSERT_PRE_INT_RANGE_NON_NULL(_int_range) \
1056 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_ID, \
1057 (_int_range), _BT_ASSERT_PRE_INT_RANGE_NAME)
1059 #define BT_ASSERT_PRE_DEV_INT_RANGE_NON_NULL(_int_range) \
1060 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_ID, \
1061 (_int_range), _BT_ASSERT_PRE_INT_RANGE_NAME)
1063 #define BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY_FROM_FUNC(_func, _range_set) \
1064 BT_ASSERT_PRE_FROM_FUNC(_func, "integer-range-set-is-not-empty", \
1065 (_range_set)->ranges->len > 0, \
1066 "Integer range set is empty: %!+R", (_range_set))
1068 #define BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY(_range_set) \
1069 BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY_FROM_FUNC(__func__, \
1072 #define _BT_ASSERT_PRE_INT_RANGE_SET_NAME "Integer range set"
1073 #define _BT_ASSERT_PRE_INT_RANGE_SET_ID "integer-range-set"
1075 #define BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL_FROM_FUNC(_func, _range_set) \
1076 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
1077 _BT_ASSERT_PRE_INT_RANGE_SET_ID, (_range_set), \
1078 _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
1080 #define BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(_range_set) \
1081 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_SET_ID, \
1082 (_range_set), _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
1084 #define BT_ASSERT_PRE_DEV_INT_RANGE_SET_NON_NULL(_range_set) \
1085 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_SET_ID, \
1086 (_range_set), _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
1088 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND(_value, _type) \
1089 (((struct bt_value *) (_value))->type == (_type))
1091 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT \
1092 "Value has the wrong type: expected-type=%s, %![value-]+v"
1094 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id) \
1095 "is-" _type_id "-value:" _value_id
1097 #define BT_ASSERT_PRE_VALUE_HAS_TYPE_FROM_FUNC(_func, _value_id, _value, _type_id, _type) \
1098 BT_ASSERT_PRE_FROM_FUNC(_func, \
1099 _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id), \
1100 _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND((_value), (_type)), \
1101 _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT, \
1102 bt_common_value_type_string(_type), (_value))
1104 #define BT_ASSERT_PRE_VALUE_HAS_TYPE(_value_id, _value, _type_id, _type) \
1105 BT_ASSERT_PRE_VALUE_HAS_TYPE_FROM_FUNC(__func__, _value_id, \
1106 (_value), _type_id, (_type));
1108 #define BT_ASSERT_PRE_VALUE_IS_BOOL(_value) \
1109 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1110 "boolean", BT_VALUE_TYPE_BOOL);
1112 #define BT_ASSERT_PRE_VALUE_IS_UNSIGNED_INT(_value) \
1113 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1114 "unsigned-int", BT_VALUE_TYPE_UNSIGNED_INTEGER);
1116 #define BT_ASSERT_PRE_VALUE_IS_SIGNED_INT(_value) \
1117 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1118 "signed-int", BT_VALUE_TYPE_SIGNED_INTEGER);
1120 #define BT_ASSERT_PRE_VALUE_IS_REAL(_value) \
1121 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1122 "real", BT_VALUE_TYPE_REAL);
1124 #define BT_ASSERT_PRE_VALUE_IS_STRING(_value) \
1125 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1126 "string", BT_VALUE_TYPE_STRING);
1128 #define BT_ASSERT_PRE_VALUE_IS_ARRAY(_value) \
1129 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1130 "array", BT_VALUE_TYPE_ARRAY);
1132 #define BT_ASSERT_PRE_VALUE_IS_MAP_FROM_FUNC(_func, _value) \
1133 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1134 "map", BT_VALUE_TYPE_MAP);
1136 #define BT_ASSERT_PRE_VALUE_IS_MAP(_value) \
1137 BT_ASSERT_PRE_VALUE_HAS_TYPE("value-object", (_value), \
1138 "map", BT_VALUE_TYPE_MAP);
1140 #define BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE(_value_id, _value, _type_id, _type) \
1141 BT_ASSERT_PRE_DEV( \
1142 _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id), \
1143 _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND((_value), (_type)), \
1144 _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT, \
1145 bt_common_value_type_string(_type), (_value))
1147 #define BT_ASSERT_PRE_DEV_VALUE_IS_BOOL(_value) \
1148 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1149 "boolean", BT_VALUE_TYPE_BOOL);
1151 #define BT_ASSERT_PRE_DEV_VALUE_IS_UNSIGNED_INT(_value) \
1152 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1153 "unsigned-int", BT_VALUE_TYPE_UNSIGNED_INTEGER);
1155 #define BT_ASSERT_PRE_DEV_VALUE_IS_SIGNED_INT(_value) \
1156 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1157 "signed-int", BT_VALUE_TYPE_SIGNED_INTEGER);
1159 #define BT_ASSERT_PRE_DEV_VALUE_IS_REAL(_value) \
1160 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1161 "real", BT_VALUE_TYPE_REAL);
1163 #define BT_ASSERT_PRE_DEV_VALUE_IS_STRING(_value) \
1164 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1165 "string", BT_VALUE_TYPE_STRING);
1167 #define BT_ASSERT_PRE_DEV_VALUE_IS_ARRAY(_value) \
1168 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1169 "array", BT_VALUE_TYPE_ARRAY);
1171 #define BT_ASSERT_PRE_DEV_VALUE_IS_MAP(_value) \
1172 BT_ASSERT_PRE_DEV_VALUE_HAS_TYPE("value-object", (_value), \
1173 "map", BT_VALUE_TYPE_MAP);
1175 #define _BT_ASSERT_PRE_VALUE_NAME "Value object"
1176 #define _BT_ASSERT_PRE_VALUE_ID "value-object"
1178 #define BT_ASSERT_PRE_VALUE_NON_NULL_FROM_FUNC(_func, _value) \
1179 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, \
1180 _BT_ASSERT_PRE_VALUE_ID, (_value), _BT_ASSERT_PRE_VALUE_NAME)
1182 #define BT_ASSERT_PRE_VALUE_NON_NULL(_value) \
1183 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_VALUE_ID, (_value), \
1184 _BT_ASSERT_PRE_VALUE_NAME)
1186 #define BT_ASSERT_PRE_DEV_VALUE_NON_NULL_FROM_FUNC(_func, _value) \
1187 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
1188 _BT_ASSERT_PRE_VALUE_ID, (_value), _BT_ASSERT_PRE_VALUE_NAME)
1190 #define BT_ASSERT_PRE_DEV_VALUE_NON_NULL(_value) \
1191 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_VALUE_ID, (_value), \
1192 _BT_ASSERT_PRE_VALUE_NAME)
1194 #define BT_ASSERT_PRE_PARAM_VALUE_IS_MAP_FROM_FUNC(_func, _value) \
1195 BT_ASSERT_PRE_FROM_FUNC(_func, \
1196 "is-map-value:parameters-value-object", \
1197 !(_value) || bt_value_is_map(_value), \
1198 "Parameters value object is not a map value: %!+v", (_value));
1200 #define BT_ASSERT_PRE_PARAM_VALUE_IS_MAP(_value) \
1201 BT_ASSERT_PRE_PARAM_VALUE_IS_MAP_FROM_FUNC(__func__, (_value))
1203 #define _BT_ASSERT_PRE_RES_OUT_NAME "Result (output)"
1204 #define _BT_ASSERT_PRE_RES_OUT_ID "result-output"
1206 #define BT_ASSERT_PRE_RES_OUT_NON_NULL(_res) \
1207 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_RES_OUT_ID, (_res), \
1208 _BT_ASSERT_PRE_RES_OUT_NAME)
1210 #define BT_ASSERT_PRE_DEV_RES_OUT_NON_NULL(_res) \
1211 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_RES_OUT_ID, (_res), \
1212 _BT_ASSERT_PRE_RES_OUT_NAME)
1214 #define BT_ASSERT_PRE_METHOD_NON_NULL(_method) \
1215 BT_ASSERT_PRE_NON_NULL("method", (_method), "Method");
1217 #define _BT_ASSERT_PRE_NAME_NAME "Name"
1218 #define _BT_ASSERT_PRE_NAME_ID "name"
1220 #define BT_ASSERT_PRE_NAME_NON_NULL_FROM_FUNC(_func, _name) \
1221 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_NAME_ID, \
1222 (_name), _BT_ASSERT_PRE_NAME_NAME)
1224 #define BT_ASSERT_PRE_NAME_NON_NULL(_name) \
1225 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_NAME_ID, (_name), \
1226 _BT_ASSERT_PRE_NAME_NAME)
1228 #define BT_ASSERT_PRE_DEV_NAME_NON_NULL_FROM_FUNC(_func, _name) \
1229 BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
1230 _BT_ASSERT_PRE_NAME_ID, (_name), _BT_ASSERT_PRE_NAME_NAME)
1232 #define BT_ASSERT_PRE_DEV_NAME_NON_NULL(_name) \
1233 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_NAME_ID, (_name), \
1234 _BT_ASSERT_PRE_NAME_NAME)
1236 #define _BT_ASSERT_PRE_DESCR_NAME "Description"
1237 #define _BT_ASSERT_PRE_DESCR_ID "description"
1239 #define BT_ASSERT_PRE_DESCR_NON_NULL(_descr) \
1240 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_DESCR_ID, (_descr), \
1241 _BT_ASSERT_PRE_DESCR_NAME)
1243 #define BT_ASSERT_PRE_DEV_DESCR_NON_NULL(_descr) \
1244 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_DESCR_ID, (_descr), \
1245 _BT_ASSERT_PRE_DESCR_NAME)
1247 #define _BT_ASSERT_PRE_UUID_NAME "UUID"
1248 #define _BT_ASSERT_PRE_UUID_ID "uuid"
1250 #define BT_ASSERT_PRE_UUID_NON_NULL(_uuid) \
1251 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_UUID_ID, (_uuid), \
1252 _BT_ASSERT_PRE_UUID_NAME)
1254 #define BT_ASSERT_PRE_DEV_UUID_NON_NULL(_uuid) \
1255 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_UUID_ID, (_uuid), \
1256 _BT_ASSERT_PRE_UUID_NAME)
1258 #define _BT_ASSERT_PRE_KEY_NAME "Key"
1259 #define _BT_ASSERT_PRE_KEY_ID "key"
1261 #define BT_ASSERT_PRE_KEY_NON_NULL_FROM_FUNC(_func, _key) \
1262 BT_ASSERT_PRE_NON_NULL_FROM_FUNC(_func, _BT_ASSERT_PRE_KEY_ID, \
1263 (_key), _BT_ASSERT_PRE_KEY_NAME)
1265 #define BT_ASSERT_PRE_KEY_NON_NULL(_key) \
1266 BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_KEY_ID, (_key), \
1267 _BT_ASSERT_PRE_KEY_NAME)
1269 #define BT_ASSERT_PRE_DEV_KEY_NON_NULL(_key) \
1270 BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_KEY_ID, (_key), \
1271 _BT_ASSERT_PRE_KEY_NAME)
1273 #endif /* BABELTRACE_ASSERT_COND_INTERNAL_H */
This page took 0.054268 seconds and 4 git commands to generate.