src.ctf.lttng-live: remove some goto error-handling
[babeltrace.git] / src / lib / assert-cond.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
5 * Copyright (c) 2018-2020 Philippe Proulx <pproulx@efficios.com>
6 */
7
8 #ifndef BABELTRACE_ASSERT_COND_INTERNAL_H
9 #define BABELTRACE_ASSERT_COND_INTERNAL_H
10
11 #include "assert-cond-base.h"
12
13 #include <inttypes.h>
14
15 /*
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
18 * `NULL`.
19 */
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)
23
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)
26
27 /*
28 * Asserts that a given index `_index` is less than a given length
29 * `_length`.
30 */
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))
35
36 #define BT_ASSERT_PRE_VALID_INDEX(_index, _length) \
37 BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(__func__, (_index), (_length))
38
39 /*
40 * Asserts that the current thread has no error set.
41 */
42 #define BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(_func) \
43 do { \
44 const struct bt_error *err = bt_current_thread_take_error(); \
45 if (err) { \
46 bt_current_thread_move_error(err); \
47 } \
48 BT_ASSERT_PRE_FROM_FUNC(_func, "no-error", !err, \
49 "API function called while current thread has an " \
50 "error: function=%s", _func); \
51 } while (0)
52
53 #define BT_ASSERT_PRE_NO_ERROR() \
54 BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(__func__)
55
56 /*
57 * Asserts that, if the current thread has an error, `_status` is an
58 * error status code.
59 *
60 * See _BT_ASSERT_COND() for details about the `_func` parameter.
61 *
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.
64 */
65 #define BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \
66 do { \
67 const struct bt_error *_err = bt_current_thread_take_error(); \
68 if (_err) { \
69 bt_current_thread_move_error(_err); \
70 } \
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)); \
76 } while (0)
77
78 /*
79 * Asserts that the current thread has no error.
80 *
81 * See _BT_ASSERT_COND() for details about the `_func` parameter.
82 */
83 #define BT_ASSERT_POST_NO_ERROR(_func) \
84 do { \
85 const struct bt_error *_err = bt_current_thread_take_error(); \
86 if (_err) { \
87 bt_current_thread_move_error(_err); \
88 } \
89 BT_ASSERT_POST(_func, "no-error", !_err, \
90 "Current thread has an error"); \
91 } while (0)
92
93 #ifdef BT_DEV_MODE
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))
97
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))
101
102 /*
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.
106 *
107 * This macro checks the `frozen` field of `_obj`.
108 *
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.
112 */
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__)
116
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__)
120
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))
124
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))
128
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)
132
133 /* Developer mode version of BT_ASSERT_PRE_NO_ERROR(). */
134 # define BT_ASSERT_PRE_DEV_NO_ERROR() BT_ASSERT_PRE_NO_ERROR()
135
136 /*
137 * Developer mode version of
138 * BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS().
139 */
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))
142
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)
146
147 /*
148 * Marks a function as being only used within a BT_ASSERT_PRE_DEV() or
149 * BT_ASSERT_POST_DEV() context.
150 */
151 # define BT_ASSERT_COND_DEV_FUNC
152 #else
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)
155
156 # define BT_ASSERT_PRE_DEV_NON_NULL(_obj_id, _obj, _obj_name) \
157 BT_USE_EXPR3(_obj_id, (_obj), _obj_name)
158
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)
161
162 # define BT_ASSERT_PRE_DEV_HOT(_obj_id, _obj, _obj_name, _fmt, ...) \
163 BT_USE_EXPR4(_obj_id, (_obj), _obj_name, _fmt)
164
165 # define BT_ASSERT_PRE_DEV_VALID_INDEX_FROM_FUNC(_func, _index, _length) \
166 BT_USE_EXPR3(_func, (_index), (_length))
167
168 # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \
169 BT_USE_EXPR2((_index), (_length))
170
171 # define BT_ASSERT_PRE_DEV_NO_ERROR_FROM_FUNC(_func) \
172 BT_USE_EXPR(_func)
173
174 # define BT_ASSERT_PRE_DEV_NO_ERROR()
175
176 # define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \
177 BT_USE_EXPR2(_func, _status)
178
179 # define BT_ASSERT_POST_DEV_NO_ERROR(_func) \
180 BT_USE_EXPR(_func)
181 #endif /* BT_DEV_MODE */
182
183 #define _BT_ASSERT_PRE_CLK_CLS_NAME "Clock class"
184 #define _BT_ASSERT_PRE_CLK_CLS_ID "clock-class"
185
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)
189
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)
193
194 #define _BT_ASSERT_PRE_DEF_CLK_CLS_NAME "Default clock class"
195 #define _BT_ASSERT_PRE_DEF_CLK_CLS_ID "default-clock-class"
196
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)
200
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)
204
205 #define _BT_ASSERT_PRE_CS_NAME "Clock snapshot"
206 #define _BT_ASSERT_PRE_CS_ID "clock-snapshot"
207
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)
211
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)
215
216 #define _BT_ASSERT_PRE_EVENT_NAME "Event"
217 #define _BT_ASSERT_PRE_EVENT_ID "event"
218
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)
222
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)
226
227 #define _BT_ASSERT_PRE_EC_NAME "Event class"
228 #define _BT_ASSERT_PRE_EC_ID "event-class"
229
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)
233
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)
237
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)
241
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)
245
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)
251
252 #define _BT_ASSERT_PRE_FC_IS_INT_FMT(_name) \
253 _name " is not an integer field class: %![fc-]+F"
254
255 #define _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id) "is-int-field-class:" _fc_id
256
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)
260
261 #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name) \
262 _name " is not an unsigned integer field class: %![fc-]+F"
263
264 #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id) \
265 "is-unsigned-integer-field-class:" _fc_id
266
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)
270
271 #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name) \
272 _name " is not a signed integer field class: %![fc-]+F"
273
274 #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id) \
275 "is-signed-integer-field-class:" _fc_id
276
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)
280
281 #define _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name) \
282 _name " is not an enumeration field class: %![fc-]+F"
283
284 #define _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id) \
285 "is-enumeration-field-class:" _fc_id
286
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)
291
292 #define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name) \
293 _name " is not an array field class: %![fc-]+F"
294
295 #define _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id) \
296 "is-array-field-class:" _fc_id
297
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)
303
304 #define _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name) \
305 _name " is not an option field class: %![fc-]+F"
306
307 #define _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id) \
308 "is-option-field-class:" _fc_id
309
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)
314
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"
317
318 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_ID(_fc_id) \
319 "is-option-field-class-with-selector:" _fc_id
320
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)
324
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"
327
328 #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_ID(_fc_id) \
329 "is-option-field-class-with-integer-selector:" _fc_id
330
331 #define _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name) \
332 _name " is not a structure field class: %![fc-]+F"
333
334 #define _BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc) \
335 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STRUCTURE)
336
337 #define _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id) \
338 "is-structure-field-class:" _fc_id
339
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)
344
345 #define _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name) \
346 _name " is not a variant field class: %![fc-]+F"
347
348 #define _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id) \
349 "is-variant-field-class:" _fc_id
350
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)
354
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"
357
358 #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id) \
359 "is-variant-field-class-with-selector:" _fc_id
360
361 #define _BT_ASSERT_PRE_FC_HAS_TYPE_COND(_fc, _type) \
362 (((const struct bt_field_class *) (_fc))->type == (_type))
363
364 #define _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name) \
365 _name " has the wrong type: expected-type=%s, %![fc-]+F"
366
367 #define _BT_ASSERT_PRE_FC_HAS_TYPE_ID(_fc_id, _type_id) \
368 "is-" _type_id ":" _fc_id
369
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))
375
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)
378
379 #define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc_id, _fc, _name) \
380 BT_ASSERT_PRE( \
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))
384
385 #define BT_ASSERT_PRE_FC_IS_SIGNED_INT(_fc_id, _fc, _name) \
386 BT_ASSERT_PRE( \
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))
390
391 #define BT_ASSERT_PRE_FC_IS_ENUM(_fc_id, _fc, _name) \
392 BT_ASSERT_PRE( \
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))
396
397 #define BT_ASSERT_PRE_FC_IS_ARRAY(_fc_id, _fc, _name) \
398 BT_ASSERT_PRE( \
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))
402
403 #define BT_ASSERT_PRE_FC_IS_STRUCT(_fc_id, _fc, _name) \
404 BT_ASSERT_PRE( \
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))
408
409 #define BT_ASSERT_PRE_FC_IS_OPTION(_fc_id, _fc, _name) \
410 BT_ASSERT_PRE( \
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))
414
415 #define BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL(_fc_id, _fc, _name) \
416 BT_ASSERT_PRE( \
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))
420
421 #define BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(_fc_id, _fc, _name) \
422 BT_ASSERT_PRE( \
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))
426
427 #define BT_ASSERT_PRE_FC_IS_VARIANT(_fc_id, _fc, _name) \
428 BT_ASSERT_PRE( \
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))
432
433 #define BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL(_fc_id, _fc, _name) \
434 BT_ASSERT_PRE( \
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))
438
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))
445
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)
449
450 #define BT_ASSERT_PRE_DEV_FC_IS_INT(_fc_id, _fc, _name) \
451 BT_ASSERT_PRE_DEV( \
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))
455
456 #define BT_ASSERT_PRE_DEV_FC_IS_UNSIGNED_INT(_fc_id, _fc, _name) \
457 BT_ASSERT_PRE_DEV( \
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))
461
462 #define BT_ASSERT_PRE_DEV_FC_IS_SIGNED_INT(_fc_id, _fc, _name) \
463 BT_ASSERT_PRE_DEV( \
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))
467
468 #define BT_ASSERT_PRE_DEV_FC_IS_ENUM(_fc_id, _fc, _name) \
469 BT_ASSERT_PRE_DEV( \
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))
473
474 #define BT_ASSERT_PRE_DEV_FC_IS_ARRAY(_fc_id, _fc, _name) \
475 BT_ASSERT_PRE_DEV( \
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))
479
480 #define BT_ASSERT_PRE_DEV_FC_IS_STRUCT(_fc_id, _fc, _name) \
481 BT_ASSERT_PRE_DEV( \
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))
485
486 #define BT_ASSERT_PRE_DEV_FC_IS_OPTION(_fc_id, _fc, _name) \
487 BT_ASSERT_PRE_DEV( \
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))
491
492 #define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_SEL(_fc_id, _fc, _name) \
493 BT_ASSERT_PRE_DEV( \
494 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \
495 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
496
497 #define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_INT_SEL(_fc_id, _fc, _name) \
498 BT_ASSERT_PRE_DEV( \
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))
502
503 #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT(_fc_id, _fc, _name) \
504 BT_ASSERT_PRE_DEV( \
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))
508
509 #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL(_fc_id, _fc, _name) \
510 BT_ASSERT_PRE_DEV( \
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))
514
515 #define BT_ASSERT_PRE_DEV_FC_HAS_TYPE(_fc_id, _fc, _type_id, _type, _name) \
516 BT_ASSERT_PRE_DEV( \
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))
521
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))
526
527 #define BT_ASSERT_PRE_DEV_FC_HOT(_fc) \
528 BT_ASSERT_PRE_DEV_FC_HOT_FROM_FUNC(__func__, (_fc))
529
530 #define _BT_ASSERT_PRE_FC_NAME "Field class"
531 #define _BT_ASSERT_PRE_FC_ID "field-class"
532
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)
536
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)
540
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"
543
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)
547
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)
551
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"
554
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)
558
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)
562
563 #define _BT_ASSERT_PRE_FP_NAME "Field path"
564 #define _BT_ASSERT_PRE_FP_ID "field-path"
565
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)
569
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)
573
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, " \
578 "%![field-]+f", \
579 bt_common_field_class_type_string(_cls_type), (_field))
580
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)
584
585 #define BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(_field_id, _field, _name) \
586 BT_ASSERT_PRE_DEV( \
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", \
591 (_field))
592
593 #define BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(_field_id, _field, _name) \
594 BT_ASSERT_PRE_DEV( \
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", \
599 (_field))
600
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))
608
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, \
611 (_field), _name)
612
613 #define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(_field_id, _field, _name) \
614 BT_ASSERT_PRE_DEV( \
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))
619
620 #define BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(_field_id, _field, _name) \
621 BT_ASSERT_PRE_DEV( \
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))
628
629 #define BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(_field_id, _field, _name) \
630 BT_ASSERT_PRE_DEV( \
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))
636
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))
641
642 #define _BT_ASSERT_PRE_FIELD_NAME "Field"
643 #define _BT_ASSERT_PRE_FIELD_ID "field"
644
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)
648
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)
653
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)
657
658 #define _BT_ASSERT_PRE_PACKET_NAME "Packet"
659 #define _BT_ASSERT_PRE_PACKET_ID "packet"
660
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)
664
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)
668
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)
672
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)
676
677 #define _BT_ASSERT_PRE_SC_NAME "Stream class"
678 #define _BT_ASSERT_PRE_SC_ID "stream-class"
679
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)
683
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)
687
688 #define _BT_ASSERT_PRE_STREAM_NAME "Stream"
689 #define _BT_ASSERT_PRE_STREAM_ID "stream"
690
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)
695
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)
699
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)
704
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)
708
709 #define _BT_ASSERT_PRE_TC_NAME "Trace class"
710 #define _BT_ASSERT_PRE_TC_ID "trace-class"
711
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)
715
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)
719
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)
723
724 #define _BT_ASSERT_PRE_TRACE_NAME "Trace"
725 #define _BT_ASSERT_PRE_TRACE_ID "trace"
726
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)
730
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)
734
735 #define _BT_ASSERT_PRE_USER_ATTRS_NAME "User attributes value object"
736 #define _BT_ASSERT_PRE_USER_ATTRS_ID "user-attributes-value-object"
737
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)
742
743 #define BT_ASSERT_PRE_USER_ATTRS_NON_NULL(_ua) \
744 BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(__func__, (_ua))
745
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)
749
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.")
755
756 #define BT_ASSERT_PRE_USER_ATTRS_IS_MAP(_ua) \
757 BT_ASSERT_PRE_USER_ATTRS_IS_MAP_FROM_FUNC(__func__, (_ua))
758
759 #define BT_ASSERT_COND_LISTENER_FUNC_NAME "Listener function"
760 #define BT_ASSERT_COND_LISTENER_FUNC_ID "listener-function"
761
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)
765
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)
769
770 #define _BT_ASSERT_PRE_MSG_ITER_NAME "Message iterator"
771 #define _BT_ASSERT_PRE_MSG_ITER_ID "message-iterator"
772
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)
777
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)
781
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)
786
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)
790
791 #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_COND(_sc) \
792 ((_sc)->default_clock_class)
793
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"
797
798 #define _BT_ASSERT_PRE_MSG_SC_DEF_CLK_CLS_ID \
799 "message-stream-class-has-default-clock-class"
800
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, \
806 (_msg), (_sc));
807
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))
810
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, \
816 (_msg), (_sc));
817
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))
820
821 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_COND(_msg, _type) \
822 (((struct bt_message *) (_msg))->type == (_type))
823
824 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT \
825 "Message has the wrong type: expected-type=%s, %![msg-]+n"
826
827 #define _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id) \
828 "is-" _type_id "-message:" _msg_id
829
830 #define BT_ASSERT_PRE_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type) \
831 BT_ASSERT_PRE( \
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))
836
837 #define BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type) \
838 BT_ASSERT_PRE_DEV( \
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))
843
844 #define _BT_ASSERT_PRE_MSG_NAME "Message"
845 #define _BT_ASSERT_PRE_MSG_ID "message"
846
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)
850
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)
854
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);
862
863 #define BT_ASSERT_PRE_DEV_MSG_HOT(_msg) \
864 BT_ASSERT_PRE_DEV_HOT("message", (_msg), "Message", ": %!+n", (_msg));
865
866 #define _BT_ASSERT_PRE_MSG_ITER_CLS_NAME "Message iterator class"
867 #define _BT_ASSERT_PRE_MSG_ITER_CLS_ID "message-iterator-class"
868
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)
872
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)
876
877 #define _BT_ASSERT_PRE_COMP_CLS_NAME "Component class"
878 #define _BT_ASSERT_PRE_COMP_CLS_ID "component-class"
879
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)
884
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)
888
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)
892
893 #define _BT_ASSERT_PRE_COMP_DESCR_SET_NAME "Component descriptor set"
894 #define _BT_ASSERT_PRE_COMP_DESCR_SET_ID "component-descriptor-set"
895
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)
899
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)
903
904 #define _BT_ASSERT_PRE_COMP_NAME "Component"
905 #define _BT_ASSERT_PRE_COMP_ID "component"
906
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)
910
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)
914
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)
918
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)
922
923 #define _BT_ASSERT_PRE_CONN_NAME "Connection"
924 #define _BT_ASSERT_PRE_CONN_ID "connection"
925
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)
929
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)
933
934 #define _BT_ASSERT_PRE_GRAPH_NAME "Graph"
935 #define _BT_ASSERT_PRE_GRAPH_ID "graph"
936
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)
940
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)
944
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)
948
949 #define _BT_ASSERT_PRE_INTR_NAME "Interrupter"
950 #define _BT_ASSERT_PRE_INTR_ID "interrupter"
951
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)
955
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)
959
960 #define _BT_ASSERT_PRE_PORT_NAME "Port"
961 #define _BT_ASSERT_PRE_PORT_ID "port"
962
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)
966
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)
970
971 #define _BT_ASSERT_PRE_QUERY_EXEC_NAME "Query executor"
972 #define _BT_ASSERT_PRE_QUERY_EXEC_ID "query-executor"
973
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)
977
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)
981
982 #define _BT_ASSERT_PRE_PLUGIN_SET_NAME "Plugin set"
983 #define _BT_ASSERT_PRE_PLUGIN_SET_ID "plugin-set"
984
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)
988
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)
992
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"
997
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)
1001
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)
1005
1006 #define _BT_ASSERT_PRE_PLUGIN_NAME "Plugin"
1007 #define _BT_ASSERT_PRE_PLUGIN_ID "plugin"
1008
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)
1012
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)
1016
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"
1021
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)
1025
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)
1029
1030 #define _BT_ASSERT_PRE_ERROR_NAME "Error"
1031 #define _BT_ASSERT_PRE_ERROR_ID "error"
1032
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)
1036
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)
1040
1041 #define _BT_ASSERT_PRE_ERROR_CAUSE_NAME "Error cause"
1042 #define _BT_ASSERT_PRE_ERROR_CAUSE_ID "error-cause"
1043
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)
1047
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)
1051
1052 #define _BT_ASSERT_PRE_INT_RANGE_NAME "Integer range"
1053 #define _BT_ASSERT_PRE_INT_RANGE_ID "integer-range"
1054
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)
1058
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)
1062
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))
1067
1068 #define BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY(_range_set) \
1069 BT_ASSERT_PRE_INT_RANGE_SET_NOT_EMPTY_FROM_FUNC(__func__, \
1070 (_range_set))
1071
1072 #define _BT_ASSERT_PRE_INT_RANGE_SET_NAME "Integer range set"
1073 #define _BT_ASSERT_PRE_INT_RANGE_SET_ID "integer-range-set"
1074
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)
1079
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)
1083
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)
1087
1088 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND(_value, _type) \
1089 (((struct bt_value *) (_value))->type == (_type))
1090
1091 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT \
1092 "Value has the wrong type: expected-type=%s, %![value-]+v"
1093
1094 #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id) \
1095 "is-" _type_id "-value:" _value_id
1096
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))
1103
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));
1107
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);
1111
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);
1115
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);
1119
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);
1123
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);
1127
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);
1131
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);
1135
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);
1139
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))
1146
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);
1150
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);
1154
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);
1158
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);
1162
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);
1166
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);
1170
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);
1174
1175 #define _BT_ASSERT_PRE_VALUE_NAME "Value object"
1176 #define _BT_ASSERT_PRE_VALUE_ID "value-object"
1177
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)
1181
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)
1185
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)
1189
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)
1193
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));
1199
1200 #define BT_ASSERT_PRE_PARAM_VALUE_IS_MAP(_value) \
1201 BT_ASSERT_PRE_PARAM_VALUE_IS_MAP_FROM_FUNC(__func__, (_value))
1202
1203 #define _BT_ASSERT_PRE_RES_OUT_NAME "Result (output)"
1204 #define _BT_ASSERT_PRE_RES_OUT_ID "result-output"
1205
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)
1209
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)
1213
1214 #define BT_ASSERT_PRE_METHOD_NON_NULL(_method) \
1215 BT_ASSERT_PRE_NON_NULL("method", (_method), "Method");
1216
1217 #define _BT_ASSERT_PRE_NAME_NAME "Name"
1218 #define _BT_ASSERT_PRE_NAME_ID "name"
1219
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)
1223
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)
1227
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)
1231
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)
1235
1236 #define _BT_ASSERT_PRE_DESCR_NAME "Description"
1237 #define _BT_ASSERT_PRE_DESCR_ID "description"
1238
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)
1242
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)
1246
1247 #define _BT_ASSERT_PRE_UUID_NAME "UUID"
1248 #define _BT_ASSERT_PRE_UUID_ID "uuid"
1249
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)
1253
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)
1257
1258 #define _BT_ASSERT_PRE_KEY_NAME "Key"
1259 #define _BT_ASSERT_PRE_KEY_ID "key"
1260
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)
1264
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)
1268
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)
1272
1273 #endif /* BABELTRACE_ASSERT_COND_INTERNAL_H */
This page took 0.053467 seconds and 5 git commands to generate.