lib: commonize some precondition assertion macros
[babeltrace.git] / src / lib / assert-cond.h
CommitLineData
d98421f2
PP
1/*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
5 * Copyright (c) 2018-2020 Philippe Proulx <pproulx@efficios.com>
6 */
7
8#ifndef BABELTRACE_ASSERT_COND_INTERNAL_H
9#define BABELTRACE_ASSERT_COND_INTERNAL_H
10
2bdc32f7 11#include "assert-cond-base.h"
d98421f2
PP
12
13/*
14 * Asserts that a given variable `_obj` named `_obj_name` (capitalized)
15 * is not `NULL`.
16 */
17#define BT_ASSERT_PRE_NON_NULL(_obj, _obj_name) \
18 BT_ASSERT_PRE((_obj), "%s is NULL: ", _obj_name)
19
20/*
21 * Asserts that a given index `_index` is less than a given length
22 * `_length`.
23 */
24#define BT_ASSERT_PRE_VALID_INDEX(_index, _length) \
25 BT_ASSERT_PRE((_index) < (_length), \
26 "Index is out of bounds: index=%" PRIu64 ", " \
27 "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_length))
28
29/*
30 * Asserts that the current thread has no error set.
31 */
32#define BT_ASSERT_PRE_NO_ERROR() \
33 do { \
34 const struct bt_error *err = bt_current_thread_take_error(); \
35 if (err) { \
36 bt_current_thread_move_error(err); \
37 } \
38 BT_ASSERT_PRE(!err, \
39 "API function called while current thread has an " \
40 "error: function=%s", __func__); \
41 } while (0)
42
43/*
44 * Asserts that, if the current thread has an error, `_status` is an
45 * error status code.
46 *
47 * Puts back the error in place (if there is one) such that if this
48 * macro aborts, it will be possible to inspect it with a debugger.
49 */
50#define BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_status) \
51 do { \
52 const struct bt_error *err = bt_current_thread_take_error(); \
53 if (err) { \
54 bt_current_thread_move_error(err); \
55 } \
56 BT_ASSERT_POST(_status < 0 || !err, \
57 "Current thread has an error, but user function " \
58 "returned a non-error status: status=%s", \
59 bt_common_func_status_string(_status)); \
60 } while (0)
61
62/*
63 * Asserts that the current thread has no error.
64 */
65#define BT_ASSERT_POST_NO_ERROR() \
66 BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(0)
67
68#ifdef BT_DEV_MODE
d98421f2
PP
69/* Developer mode version of BT_ASSERT_PRE_NON_NULL() */
70# define BT_ASSERT_PRE_DEV_NON_NULL(_obj, _obj_name) \
71 BT_ASSERT_PRE_NON_NULL((_obj), (_obj_name))
72
73/*
74 * Developer mode: asserts that a given object `_obj` named `_obj_name`
75 * (capitalized) is NOT frozen. This macro checks the `frozen` field of
76 * `_obj`.
77 *
78 * This currently only exists in developer mode because some freezing
79 * functions can be called on the fast path, so they too are only
80 * enabled in developer mode.
81 */
82# define BT_ASSERT_PRE_DEV_HOT(_obj, _obj_name, _fmt, ...) \
83 BT_ASSERT_PRE(!(_obj)->frozen, "%s is frozen" _fmt, _obj_name, \
84 ##__VA_ARGS__)
85
86/* Developer mode version of BT_ASSERT_PRE_VALID_INDEX() */
87# define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \
88 BT_ASSERT_PRE_VALID_INDEX((_index), (_length))
89
90/* Developer mode version of BT_ASSERT_PRE_NO_ERROR(). */
2bdc32f7 91# define BT_ASSERT_PRE_DEV_NO_ERROR() \
d98421f2
PP
92 BT_ASSERT_PRE_NO_ERROR()
93
d98421f2
PP
94/*
95 * Developer mode version of
96 * BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS().
97 */
2bdc32f7 98# define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_status) \
d98421f2
PP
99 BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_status)
100
101/* Developer mode version of BT_ASSERT_POST_NO_ERROR(). */
2bdc32f7 102# define BT_ASSERT_POST_DEV_NO_ERROR() \
d98421f2
PP
103 BT_ASSERT_POST_NO_ERROR()
104
d98421f2
PP
105/*
106 * Marks a function as being only used within a BT_ASSERT_PRE_DEV() or
107 * BT_ASSERT_POST_DEV() context.
108 */
109# define BT_ASSERT_COND_DEV_FUNC
110#else
d98421f2
PP
111# define BT_ASSERT_PRE_DEV_NON_NULL(_obj, _obj_name) \
112 ((void) sizeof((void) (_obj), (void) (_obj_name), 0))
2bdc32f7 113
d98421f2
PP
114# define BT_ASSERT_PRE_DEV_HOT(_obj, _obj_name, _fmt, ...) \
115 ((void) sizeof((void) (_obj), (void) (_obj_name), 0))
2bdc32f7 116
d98421f2
PP
117# define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \
118 ((void) sizeof((void) (_index), (void) (_length), 0))
2bdc32f7 119
d98421f2 120# define BT_ASSERT_PRE_DEV_NO_ERROR()
2bdc32f7
PP
121
122# define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_status) \
d98421f2 123 ((void) sizeof((void) (_status), 0))
2bdc32f7 124
d98421f2 125# define BT_ASSERT_POST_DEV_NO_ERROR()
d98421f2
PP
126#endif /* BT_DEV_MODE */
127
2bdc32f7
PP
128#define _BT_ASSERT_PRE_CLK_CLS_NAME "Clock class"
129
130#define BT_ASSERT_PRE_CLK_CLS_NON_NULL(_cc) \
131 BT_ASSERT_PRE_NON_NULL(clock_class, _BT_ASSERT_PRE_CLK_CLS_NAME)
132
133#define BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(_cc) \
134 BT_ASSERT_PRE_DEV_NON_NULL(clock_class, _BT_ASSERT_PRE_CLK_CLS_NAME)
135
136#define _BT_ASSERT_PRE_DEF_CLK_CLS_NAME "Default clock class"
137
138#define BT_ASSERT_PRE_DEF_CLK_CLS_NON_NULL(_cc) \
139 BT_ASSERT_PRE_NON_NULL(clock_class, _BT_ASSERT_PRE_DEF_CLK_CLS_NAME)
140
141#define BT_ASSERT_PRE_DEV_DEF_CLK_CLS_NON_NULL(_cc) \
142 BT_ASSERT_PRE_DEV_NON_NULL(clock_class, _BT_ASSERT_PRE_DEF_CLK_CLS_NAME)
143
144#define _BT_ASSERT_PRE_CS_NAME "Clock snapshot"
145
146#define BT_ASSERT_PRE_CS_NON_NULL(_cs) \
147 BT_ASSERT_PRE_NON_NULL(_cs, _BT_ASSERT_PRE_CS_NAME)
148
149#define BT_ASSERT_PRE_DEV_CS_NON_NULL(_cs) \
150 BT_ASSERT_PRE_DEV_NON_NULL(_cs, _BT_ASSERT_PRE_CS_NAME)
151
152#define _BT_ASSERT_PRE_EVENT_NAME "Event"
153
154#define BT_ASSERT_PRE_EVENT_NON_NULL(_ec) \
155 BT_ASSERT_PRE_NON_NULL(_ec, _BT_ASSERT_PRE_EVENT_NAME)
156
157#define BT_ASSERT_PRE_DEV_EVENT_NON_NULL(_ec) \
158 BT_ASSERT_PRE_DEV_NON_NULL(_ec, _BT_ASSERT_PRE_EVENT_NAME)
159
160#define _BT_ASSERT_PRE_EC_NAME "Event class"
161
162#define BT_ASSERT_PRE_EC_NON_NULL(_ec) \
163 BT_ASSERT_PRE_NON_NULL(_ec, _BT_ASSERT_PRE_EC_NAME)
164
165#define BT_ASSERT_PRE_DEV_EC_NON_NULL(_ec) \
166 BT_ASSERT_PRE_DEV_NON_NULL(_ec, _BT_ASSERT_PRE_EC_NAME)
167
168#define _BT_ASSERT_PRE_FC_IS_INT_COND(_fc) \
169 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
170 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
171 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \
172 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
173
174#define _BT_ASSERT_PRE_FC_IS_INT_FMT(_name) \
175 _name " is not an integer field class: %![fc-]+F"
176
177#define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc) \
178 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
179 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION)
180
181#define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name) \
182 _name " is not an unsigned integer field class: %![fc-]+F"
183
184
185#define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc) \
186 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
187 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
188
189#define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name) \
190 _name " is not a signed integer field class: %![fc-]+F"
191
192#define _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc) \
193 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \
194 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION)
195
196#define _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name) \
197 _name " is not an enumeration field class: %![fc-]+F"
198
199#define _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc) \
200 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
201 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
202 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD)
203
204#define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name) \
205 _name " is not an array field class: %![fc-]+F"
206
207#define _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc) \
208 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \
209 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
210 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
211 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
212
213#define _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name) \
214 _name " is not an option field class: %![fc-]+F"
215
216#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc) \
217 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
218 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
219 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
220
221#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name) \
222 _name " is not an option field class with a selector: %![fc-]+F"
223
224#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc) \
225 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
226 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
227
228#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name) \
229 _name " is not an option field class with an integer selector: %![fc-]+F"
230
231#define _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name) \
232 _name " is not a structure field class: %![fc-]+F"
233
234#define _BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc) \
235 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STRUCTURE)
236
237#define _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc) \
238 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \
239 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
240 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
241
242#define _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name) \
243 _name " is not a variant field class: %![fc-]+F"
244
245#define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc) \
246 (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
247 ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD)
248
249#define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name) \
250 _name " is not a variant field class with a selector: %![fc-]+F"
251
252#define _BT_ASSERT_PRE_FC_HAS_ID_COND(_fc, _type) \
253 (((const struct bt_field_class *) (_fc))->type == (_type))
254
255#define _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name) \
256 _name " has the wrong type: expected-type=%s, %![fc-]+F"
257
258#define BT_ASSERT_PRE_FC_IS_INT(_fc, _name) \
259 BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \
260 _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc))
261
262#define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc, _name) \
263 BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \
264 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc))
265
266#define BT_ASSERT_PRE_FC_IS_SIGNED_INT(_fc, _name) \
267 BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc), \
268 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc))
269
270#define BT_ASSERT_PRE_FC_IS_ENUM(_fc, _name) \
271 BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \
272 _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc))
273
274#define BT_ASSERT_PRE_FC_IS_ARRAY(_fc, _name) \
275 BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \
276 _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc))
277
278#define BT_ASSERT_PRE_FC_IS_STRUCT(_fc, _name) \
279 BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc), \
280 _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name), (_fc))
281
282#define BT_ASSERT_PRE_FC_IS_OPTION(_fc, _name) \
283 BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc), \
284 _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc))
285
286#define BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL(_fc, _name) \
287 BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \
288 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
289
290#define BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(_fc, _name) \
291 BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \
292 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc))
293
294#define BT_ASSERT_PRE_FC_IS_VARIANT(_fc, _name) \
295 BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc), \
296 _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc))
297
298#define BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL(_fc, _name) \
299 BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \
300 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc))
301
302#define BT_ASSERT_PRE_FC_HAS_ID(_fc, _type, _name) \
303 BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_HAS_ID_COND((_fc), (_type)), \
304 _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name), \
305 bt_common_field_class_type_string(_type), (_fc))
306
307#define BT_ASSERT_PRE_DEV_FC_IS_INT(_fc, _name) \
308 BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \
309 _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc))
310
311#define BT_ASSERT_PRE_DEV_FC_IS_UNSIGNED_INT(_fc, _name) \
312 BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \
313 _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc))
314
315#define BT_ASSERT_PRE_DEV_FC_IS_SIGNED_INT(_fc, _name) \
316 BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc), \
317 _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc))
318
319#define BT_ASSERT_PRE_DEV_FC_IS_ENUM(_fc, _name) \
320 BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \
321 _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc))
322
323#define BT_ASSERT_PRE_DEV_FC_IS_ARRAY(_fc, _name) \
324 BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \
325 _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc))
326
327#define BT_ASSERT_PRE_DEV_FC_IS_STRUCT(_fc, _name) \
328 BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_STRUCT_COND(_fc), \
329 _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name), (_fc))
330
331#define BT_ASSERT_PRE_DEV_FC_IS_OPTION(_fc, _name) \
332 BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc), \
333 _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc))
334
335#define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_SEL(_fc, _name) \
336 BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \
337 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc))
338
339#define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_INT_SEL(_fc, _name) \
340 BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \
341 _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc))
342
343#define BT_ASSERT_PRE_DEV_FC_IS_VARIANT(_fc, _name) \
344 BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc), \
345 _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc))
346
347#define BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL(_fc, _name) \
348 BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \
349 _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc))
350
351#define BT_ASSERT_PRE_DEV_FC_HAS_ID(_fc, _type, _name) \
352 BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_HAS_ID_COND((_fc), (_type)), \
353 _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name), \
354 bt_common_field_class_type_string(_type), (_fc))
355
356#define BT_ASSERT_PRE_DEV_FC_HOT(_fc, _name) \
357 BT_ASSERT_PRE_DEV_HOT((const struct bt_field_class *) (_fc), \
358 (_name), ": %!+F", (_fc))
359
360#define _BT_ASSERT_PRE_FC_NAME "Field class"
361
362#define BT_ASSERT_PRE_FC_NON_NULL(_fc) \
363 BT_ASSERT_PRE_NON_NULL(_fc, _BT_ASSERT_PRE_FC_NAME)
364
365#define BT_ASSERT_PRE_DEV_FC_NON_NULL(_fc) \
366 BT_ASSERT_PRE_DEV_NON_NULL(_fc, _BT_ASSERT_PRE_FC_NAME)
367
368#define _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME "Structure field class member"
369
370#define BT_ASSERT_PRE_STRUCT_FC_MEMBER_NON_NULL(_fc) \
371 BT_ASSERT_PRE_NON_NULL(_fc, _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME)
372
373#define BT_ASSERT_PRE_DEV_STRUCT_FC_MEMBER_NON_NULL(_fc) \
374 BT_ASSERT_PRE_DEV_NON_NULL(_fc, _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME)
375
376#define _BT_ASSERT_PRE_VAR_FC_OPT_NAME "Variant field class option"
377
378#define BT_ASSERT_PRE_VAR_FC_OPT_NON_NULL(_fc) \
379 BT_ASSERT_PRE_NON_NULL(_fc, _BT_ASSERT_PRE_VAR_FC_OPT_NAME)
380
381#define BT_ASSERT_PRE_DEV_VAR_FC_OPT_NON_NULL(_fc) \
382 BT_ASSERT_PRE_DEV_NON_NULL(_fc, _BT_ASSERT_PRE_VAR_FC_OPT_NAME)
383
384#define _BT_ASSERT_PRE_FP_NAME "Field path"
385
386#define BT_ASSERT_PRE_FP_NON_NULL(_fp) \
387 BT_ASSERT_PRE_NON_NULL(_fp, _BT_ASSERT_PRE_FP_NAME)
388
389#define BT_ASSERT_PRE_DEV_FP_NON_NULL(_fp) \
390 BT_ASSERT_PRE_DEV_NON_NULL(_fp, _BT_ASSERT_PRE_FP_NAME)
391
392#define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(_field, _cls_type, _name) \
393 BT_ASSERT_PRE_DEV(((const struct bt_field *) (_field))->class->type == (_cls_type), \
394 _name " has the wrong class type: expected-class-type=%s, " \
395 "%![field-]+f", \
396 bt_common_field_class_type_string(_cls_type), (_field))
397
398#define BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(_field, _name) \
399 BT_ASSERT_PRE_DEV( \
400 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
401 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, \
402 _name " is not an unsigned integer field: %![field-]+f", \
403 (_field))
404
405#define BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(_field, _name) \
406 BT_ASSERT_PRE_DEV( \
407 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
408 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, \
409 _name " is not a signed integer field: %![field-]+f", \
410 (_field))
411
412#define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(_field, _name) \
413 BT_ASSERT_PRE_DEV( \
414 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
415 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
416 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
417 _name " is not an array field: %![field-]+f", (_field))
418
419#define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(_field, _name) \
420 BT_ASSERT_PRE_DEV( \
421 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
422 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
423 _name " is not a dynamic array field: %![field-]+f", (_field))
424
425#define BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(_field, _name) \
426 BT_ASSERT_PRE_DEV( \
427 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \
428 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \
429 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
430 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD, \
431 _name " is not an option field: %![field-]+f", (_field))
432
433#define BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(_field, _name) \
434 BT_ASSERT_PRE_DEV( \
435 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \
436 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \
437 ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD, \
438 _name " is not a variant field: %![field-]+f", (_field))
439
440#define BT_ASSERT_PRE_DEV_FIELD_IS_SET(_field, _name) \
441 BT_ASSERT_PRE_DEV(bt_field_is_set(_field), \
442 _name " is not set: %!+f", (_field))
443
444#define _BT_ASSERT_PRE_FIELD_NAME "Field"
445
446#define BT_ASSERT_PRE_FIELD_NON_NULL(_field) \
447 BT_ASSERT_PRE_NON_NULL(_field, _BT_ASSERT_PRE_FIELD_NAME)
448
449#define BT_ASSERT_PRE_DEV_FIELD_NON_NULL(_field) \
450 BT_ASSERT_PRE_DEV_NON_NULL(_field, _BT_ASSERT_PRE_FIELD_NAME)
451
452#define _BT_ASSERT_PRE_PACKET_NAME "Packet"
453
454#define BT_ASSERT_PRE_PACKET_NON_NULL(_packet) \
455 BT_ASSERT_PRE_NON_NULL(_packet, _BT_ASSERT_PRE_PACKET_NAME)
456
457#define BT_ASSERT_PRE_DEV_PACKET_NON_NULL(_packet) \
458 BT_ASSERT_PRE_DEV_NON_NULL(_packet, _BT_ASSERT_PRE_PACKET_NAME)
459
460#define _BT_ASSERT_PRE_SC_NAME "Stream class"
461
462#define BT_ASSERT_PRE_SC_NON_NULL(_sc) \
463 BT_ASSERT_PRE_NON_NULL(_sc, _BT_ASSERT_PRE_SC_NAME)
464
465#define BT_ASSERT_PRE_DEV_SC_NON_NULL(_sc) \
466 BT_ASSERT_PRE_DEV_NON_NULL(_sc, _BT_ASSERT_PRE_SC_NAME)
467
468#define _BT_ASSERT_PRE_STREAM_NAME "Stream"
469
470#define BT_ASSERT_PRE_STREAM_NON_NULL(_stream) \
471 BT_ASSERT_PRE_NON_NULL(_stream, _BT_ASSERT_PRE_STREAM_NAME)
472
473#define BT_ASSERT_PRE_DEV_STREAM_NON_NULL(_stream) \
474 BT_ASSERT_PRE_DEV_NON_NULL(_stream, _BT_ASSERT_PRE_STREAM_NAME)
475
476#define _BT_ASSERT_PRE_TC_NAME "Trace class"
477
478#define BT_ASSERT_PRE_TC_NON_NULL(_tc) \
479 BT_ASSERT_PRE_NON_NULL(_tc, _BT_ASSERT_PRE_TC_NAME)
480
481#define BT_ASSERT_PRE_DEV_TC_NON_NULL(_tc) \
482 BT_ASSERT_PRE_DEV_NON_NULL(_tc, _BT_ASSERT_PRE_TC_NAME)
483
484#define _BT_ASSERT_PRE_TRACE_NAME "Trace"
485
486#define BT_ASSERT_PRE_TRACE_NON_NULL(_trace) \
487 BT_ASSERT_PRE_NON_NULL(_trace, _BT_ASSERT_PRE_TRACE_NAME)
488
489#define BT_ASSERT_PRE_DEV_TRACE_NON_NULL(_trace) \
490 BT_ASSERT_PRE_DEV_NON_NULL(_trace, _BT_ASSERT_PRE_TRACE_NAME)
491
492#define _BT_ASSERT_PRE_USER_ATTRS_NAME "User attributes"
493
494#define BT_ASSERT_PRE_USER_ATTRS_NON_NULL(_ua) \
495 BT_ASSERT_PRE_NON_NULL(_ua, _BT_ASSERT_PRE_USER_ATTRS_NAME)
496
497#define BT_ASSERT_PRE_DEV_USER_ATTRS_NON_NULL(_ua) \
498 BT_ASSERT_PRE_DEV_NON_NULL(_ua, _BT_ASSERT_PRE_USER_ATTRS_NAME)
499
500#define BT_ASSERT_PRE_USER_ATTRS_IS_MAP(_ua) \
501 BT_ASSERT_PRE((_ua)->type == BT_VALUE_TYPE_MAP, \
502 _BT_ASSERT_PRE_USER_ATTRS_NAME \
503 " object is not a map value object.")
504
505#define BT_ASSERT_COND_LISTENER_FUNC_NAME "Listener function"
506
507#define BT_ASSERT_PRE_LISTENER_FUNC_NON_NULL(_func) \
508 BT_ASSERT_PRE_NON_NULL(_func, BT_ASSERT_COND_LISTENER_FUNC_NAME)
509
510#define BT_ASSERT_PRE_DEV_LISTENER_FUNC_NON_NULL(_func) \
511 BT_ASSERT_PRE_DEV_NON_NULL(_func, BT_ASSERT_COND_LISTENER_FUNC_NAME)
512
513#define _BT_ASSERT_PRE_MSG_ITER_NAME "Message iterator"
514
515#define BT_ASSERT_PRE_MSG_ITER_NON_NULL(_msg_iter) \
516 BT_ASSERT_PRE_NON_NULL(_msg_iter, _BT_ASSERT_PRE_MSG_ITER_NAME)
517
518#define BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL(_msg_iter) \
519 BT_ASSERT_PRE_DEV_NON_NULL(_msg_iter, _BT_ASSERT_PRE_MSG_ITER_NAME)
520
521#define BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS(_msg, _sc) \
522 BT_ASSERT_PRE_DEV((_sc)->default_clock_class, \
523 "Message's stream's class has no default clock class: " \
524 "%![msg-]+n, %![sc-]+S", (_msg), (_sc));
525
526#define _BT_ASSERT_PRE_MSG_IS_TYPE_COND(_msg, _type) \
527 (((struct bt_message *) (_msg))->type == (_type))
528
529#define _BT_ASSERT_PRE_MSG_IS_TYPE_FMT \
530 "Message has the wrong type: expected-type=%s, %![msg-]+n"
531
532#define BT_ASSERT_PRE_MSG_IS_TYPE(_msg, _type) \
533 BT_ASSERT_PRE( \
534 _BT_ASSERT_PRE_MSG_IS_TYPE_COND((_msg), (_type)), \
535 _BT_ASSERT_PRE_MSG_IS_TYPE_FMT, \
536 bt_message_type_string(_type), (_msg))
537
538#define BT_ASSERT_PRE_DEV_MSG_IS_TYPE(_msg, _type) \
539 BT_ASSERT_PRE_DEV( \
540 _BT_ASSERT_PRE_MSG_IS_TYPE_COND((_msg), (_type)), \
541 _BT_ASSERT_PRE_MSG_IS_TYPE_FMT, \
542 bt_message_type_string(_type), (_msg))
543
544#define _BT_ASSERT_PRE_MSG_NAME "Message"
545
546#define BT_ASSERT_PRE_MSG_NON_NULL(_msg_iter) \
547 BT_ASSERT_PRE_NON_NULL(_msg_iter, _BT_ASSERT_PRE_MSG_NAME)
548
549#define BT_ASSERT_PRE_DEV_MSG_NON_NULL(_msg_iter) \
550 BT_ASSERT_PRE_DEV_NON_NULL(_msg_iter, _BT_ASSERT_PRE_MSG_NAME)
551
552#define BT_ASSERT_PRE_BEGIN_LE_END(_msg_iter, _begin, _end) \
553 BT_ASSERT_PRE( \
554 _begin <= _end, \
555 "Beginning default clock snapshot value is greater " \
556 "than end default clock snapshot value: " \
557 "cs-begin-val=%" PRIu64 ", cs-end-val=%" PRIu64 ", " \
558 "%![msg-iter-]+i", \
559 _begin, _end, _msg_iter);
560
561#define BT_ASSERT_PRE_DEV_MSG_HOT(_msg) \
562 BT_ASSERT_PRE_DEV_HOT((_msg), "Message", ": %!+n", (_msg));
563
564#define _BT_ASSERT_PRE_MSG_ITER_CLS_NAME "Message iterator class"
565
566#define BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(_msg_iter_cls) \
567 BT_ASSERT_PRE_NON_NULL(_msg_iter_cls, _BT_ASSERT_PRE_MSG_ITER_CLS_NAME)
568
569#define BT_ASSERT_PRE_DEV_MSG_ITER_CLS_NON_NULL(_msg_iter_cls) \
570 BT_ASSERT_PRE_DEV_NON_NULL(_msg_iter_cls, _BT_ASSERT_PRE_MSG_ITER_CLS_NAME)
571
572#define _BT_ASSERT_PRE_COMP_CLS_NAME "Component class"
573
574#define BT_ASSERT_PRE_COMP_CLS_NON_NULL(_comp_cls) \
575 BT_ASSERT_PRE_NON_NULL(_comp_cls, _BT_ASSERT_PRE_COMP_CLS_NAME)
576
577#define BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(_comp_cls) \
578 BT_ASSERT_PRE_DEV_NON_NULL(_comp_cls, _BT_ASSERT_PRE_COMP_CLS_NAME)
579
580#define _BT_ASSERT_PRE_COMP_DESCR_SET_NAME "Component descriptor set"
581
582#define BT_ASSERT_PRE_COMP_DESCR_SET_NON_NULL(_comp_descr_set) \
583 BT_ASSERT_PRE_NON_NULL(_comp_descr_set, _BT_ASSERT_PRE_COMP_DESCR_SET_NAME)
584
585#define BT_ASSERT_PRE_DEV_COMP_DESCR_SET_NON_NULL(_comp_descr_set) \
586 BT_ASSERT_PRE_DEV_NON_NULL(_comp_descr_set, _BT_ASSERT_PRE_COMP_DESCR_SET_NAME)
587
588#define _BT_ASSERT_PRE_COMP_NAME "Component"
589
590#define BT_ASSERT_PRE_COMP_NON_NULL(_comp) \
591 BT_ASSERT_PRE_NON_NULL(_comp, _BT_ASSERT_PRE_COMP_NAME)
592
593#define BT_ASSERT_PRE_DEV_COMP_NON_NULL(_comp) \
594 BT_ASSERT_PRE_DEV_NON_NULL(_comp, _BT_ASSERT_PRE_COMP_NAME)
595
596#define _BT_ASSERT_PRE_CONN_NAME "Connection"
597
598#define BT_ASSERT_PRE_CONN_NON_NULL(_conn) \
599 BT_ASSERT_PRE_NON_NULL(_conn, _BT_ASSERT_PRE_CONN_NAME)
600
601#define BT_ASSERT_PRE_DEV_CONN_NON_NULL(_conn) \
602 BT_ASSERT_PRE_DEV_NON_NULL(_conn, _BT_ASSERT_PRE_CONN_NAME)
603
604#define _BT_ASSERT_PRE_GRAPH_NAME "Graph"
605
606#define BT_ASSERT_PRE_GRAPH_NON_NULL(_graph) \
607 BT_ASSERT_PRE_NON_NULL(_graph, _BT_ASSERT_PRE_GRAPH_NAME)
608
609#define BT_ASSERT_PRE_DEV_GRAPH_NON_NULL(_graph) \
610 BT_ASSERT_PRE_DEV_NON_NULL(_graph, _BT_ASSERT_PRE_GRAPH_NAME)
611
612#define _BT_ASSERT_PRE_INTR_NAME "Interrupter"
613
614#define BT_ASSERT_PRE_INTR_NON_NULL(_intr) \
615 BT_ASSERT_PRE_NON_NULL(_intr, _BT_ASSERT_PRE_INTR_NAME)
616
617#define BT_ASSERT_PRE_DEV_INTR_NON_NULL(_intr) \
618 BT_ASSERT_PRE_DEV_NON_NULL(_intr, _BT_ASSERT_PRE_INTR_NAME)
619
620#define _BT_ASSERT_PRE_PORT_NAME "Port"
621
622#define BT_ASSERT_PRE_PORT_NON_NULL(_port) \
623 BT_ASSERT_PRE_NON_NULL(_port, _BT_ASSERT_PRE_PORT_NAME)
624
625#define BT_ASSERT_PRE_DEV_PORT_NON_NULL(_port) \
626 BT_ASSERT_PRE_DEV_NON_NULL(_port, _BT_ASSERT_PRE_PORT_NAME)
627
628#define _BT_ASSERT_PRE_QUERY_EXEC_NAME "Query executor"
629
630#define BT_ASSERT_PRE_QUERY_EXEC_NON_NULL(_query_exec) \
631 BT_ASSERT_PRE_NON_NULL(_query_exec, _BT_ASSERT_PRE_QUERY_EXEC_NAME)
632
633#define BT_ASSERT_PRE_DEV_QUERY_EXEC_NON_NULL(_query_exec) \
634 BT_ASSERT_PRE_DEV_NON_NULL(_query_exec, _BT_ASSERT_PRE_QUERY_EXEC_NAME)
635
636#define _BT_ASSERT_PRE_PLUGIN_SET_NAME "Plugin set"
637
638#define BT_ASSERT_PRE_PLUGIN_SET_NON_NULL(_plugin_set) \
639 BT_ASSERT_PRE_NON_NULL(_plugin_set, _BT_ASSERT_PRE_PLUGIN_SET_NAME)
640
641#define BT_ASSERT_PRE_DEV_PLUGIN_SET_NON_NULL(_plugin_set) \
642 BT_ASSERT_PRE_DEV_NON_NULL(_plugin_set, _BT_ASSERT_PRE_PLUGIN_SET_NAME)
643
644#define _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME \
645 _BT_ASSERT_PRE_PLUGIN_SET_NAME " (output)"
646
647#define BT_ASSERT_PRE_PLUGIN_SET_OUT_NON_NULL(_plugin_set) \
648 BT_ASSERT_PRE_NON_NULL(_plugin_set, _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME)
649
650#define BT_ASSERT_PRE_DEV_PLUGIN_SET_OUT_NON_NULL(_plugin_set) \
651 BT_ASSERT_PRE_DEV_NON_NULL(_plugin_set, _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME)
652
653#define _BT_ASSERT_PRE_PLUGIN_NAME "Plugin"
654
655#define BT_ASSERT_PRE_PLUGIN_NON_NULL(_plugin) \
656 BT_ASSERT_PRE_NON_NULL(_plugin, _BT_ASSERT_PRE_PLUGIN_NAME)
657
658#define BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(_plugin) \
659 BT_ASSERT_PRE_DEV_NON_NULL(_plugin, _BT_ASSERT_PRE_PLUGIN_NAME)
660
661#define _BT_ASSERT_PRE_PLUGIN_OUT_NAME \
662 _BT_ASSERT_PRE_PLUGIN_NAME " (output)"
663
664#define BT_ASSERT_PRE_PLUGIN_OUT_NON_NULL(_plugin) \
665 BT_ASSERT_PRE_NON_NULL(_plugin, _BT_ASSERT_PRE_PLUGIN_OUT_NAME)
666
667#define BT_ASSERT_PRE_DEV_PLUGIN_OUT_NON_NULL(_plugin) \
668 BT_ASSERT_PRE_DEV_NON_NULL(_plugin, _BT_ASSERT_PRE_PLUGIN_OUT_NAME)
669
670#define _BT_ASSERT_PRE_ERROR_NAME "Error"
671
672#define BT_ASSERT_PRE_ERROR_NON_NULL(_error) \
673 BT_ASSERT_PRE_NON_NULL(_error, _BT_ASSERT_PRE_ERROR_NAME)
674
675#define BT_ASSERT_PRE_DEV_ERROR_NON_NULL(_error) \
676 BT_ASSERT_PRE_DEV_NON_NULL(_error, _BT_ASSERT_PRE_ERROR_NAME)
677
678#define _BT_ASSERT_PRE_ERROR_CAUSE_NAME "Error cause"
679
680#define BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(_error_cause) \
681 BT_ASSERT_PRE_NON_NULL(_error_cause, _BT_ASSERT_PRE_ERROR_CAUSE_NAME)
682
683#define BT_ASSERT_PRE_DEV_ERROR_CAUSE_NON_NULL(_error_cause) \
684 BT_ASSERT_PRE_DEV_NON_NULL(_error_cause, _BT_ASSERT_PRE_ERROR_CAUSE_NAME)
685
686#define _BT_ASSERT_PRE_INT_RANGE_NAME "Integer range"
687
688#define BT_ASSERT_PRE_INT_RANGE_NON_NULL(_int_range) \
689 BT_ASSERT_PRE_NON_NULL(_int_range, _BT_ASSERT_PRE_INT_RANGE_NAME)
690
691#define BT_ASSERT_PRE_DEV_INT_RANGE_NON_NULL(_int_range) \
692 BT_ASSERT_PRE_DEV_NON_NULL(_int_range, _BT_ASSERT_PRE_INT_RANGE_NAME)
693
694#define _BT_ASSERT_PRE_INT_RANGE_SET_NAME "Integer range set"
695
696#define BT_ASSERT_PRE_INT_RANGE_SET_NON_NULL(_int_range_set) \
697 BT_ASSERT_PRE_NON_NULL(_int_range_set, _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
698
699#define BT_ASSERT_PRE_DEV_INT_RANGE_SET_NON_NULL(_int_range_set) \
700 BT_ASSERT_PRE_DEV_NON_NULL(_int_range_set, _BT_ASSERT_PRE_INT_RANGE_SET_NAME)
701
702#define _BT_ASSERT_PRE_VALUE_IS_TYPE_COND(_value, _type) \
703 (((struct bt_value *) (_value))->type == (_type))
704
705#define _BT_ASSERT_PRE_VALUE_IS_TYPE_FMT \
706 "Value has the wrong type: expected-type=%s, %![value-]+v"
707
708#define BT_ASSERT_PRE_VALUE_IS_TYPE(_value, _type) \
709 BT_ASSERT_PRE( \
710 _BT_ASSERT_PRE_VALUE_IS_TYPE_COND((_value), (_type)), \
711 _BT_ASSERT_PRE_VALUE_IS_TYPE_FMT, \
712 bt_common_value_type_string(_type), (_value))
713
714#define BT_ASSERT_PRE_DEV_VALUE_IS_TYPE(_value, _type) \
715 BT_ASSERT_PRE_DEV( \
716 _BT_ASSERT_PRE_VALUE_IS_TYPE_COND((_value), (_type)), \
717 _BT_ASSERT_PRE_VALUE_IS_TYPE_FMT, \
718 bt_common_value_type_string(_type), (_value))
719
720#define _BT_ASSERT_PRE_VALUE_NAME "Value object"
721
722#define BT_ASSERT_PRE_VALUE_NON_NULL(_value) \
723 BT_ASSERT_PRE_NON_NULL(_value, _BT_ASSERT_PRE_VALUE_NAME)
724
725#define BT_ASSERT_PRE_DEV_VALUE_NON_NULL(_value) \
726 BT_ASSERT_PRE_DEV_NON_NULL(_value, _BT_ASSERT_PRE_VALUE_NAME)
727
728#define BT_ASSERT_PRE_PARAM_VALUE_IS_MAP(_value) \
729 BT_ASSERT_PRE(!(_value) || bt_value_is_map(_value), \
730 "Parameter value is not a map value: %!+v", (_value));
731
732#define _BT_ASSERT_PRE_RES_OUT_NAME "Result (output)"
733
734#define BT_ASSERT_PRE_RES_OUT_NON_NULL(_res) \
735 BT_ASSERT_PRE_NON_NULL(_res, _BT_ASSERT_PRE_RES_OUT_NAME)
736
737#define BT_ASSERT_PRE_DEV_RES_OUT_NON_NULL(_res) \
738 BT_ASSERT_PRE_DEV_NON_NULL(_res, _BT_ASSERT_PRE_RES_OUT_NAME)
739
740#define BT_ASSERT_PRE_METHOD_NON_NULL(_method) \
741 BT_ASSERT_PRE_NON_NULL(_method, "Method");
742
743#define _BT_ASSERT_PRE_NAME_NAME "Name"
744
745#define BT_ASSERT_PRE_NAME_NON_NULL(_name) \
746 BT_ASSERT_PRE_NON_NULL(_name, _BT_ASSERT_PRE_NAME_NAME)
747
748#define BT_ASSERT_PRE_DEV_NAME_NON_NULL(_name) \
749 BT_ASSERT_PRE_DEV_NON_NULL(_name, _BT_ASSERT_PRE_NAME_NAME)
750
751#define _BT_ASSERT_PRE_DESCR_NAME "Description"
752
753#define BT_ASSERT_PRE_DESCR_NON_NULL(_descr) \
754 BT_ASSERT_PRE_NON_NULL(_descr, _BT_ASSERT_PRE_DESCR_NAME)
755
756#define BT_ASSERT_PRE_DEV_DESCR_NON_NULL(_descr) \
757 BT_ASSERT_PRE_DEV_NON_NULL(_descr, _BT_ASSERT_PRE_DESCR_NAME)
758
759#define _BT_ASSERT_PRE_UUID_NAME "UUID"
760
761#define BT_ASSERT_PRE_UUID_NON_NULL(_uuid) \
762 BT_ASSERT_PRE_NON_NULL(_uuid, _BT_ASSERT_PRE_UUID_NAME)
763
764#define BT_ASSERT_PRE_DEV_UUID_NON_NULL(_uuid) \
765 BT_ASSERT_PRE_DEV_NON_NULL(_uuid, _BT_ASSERT_PRE_UUID_NAME)
766
767#define _BT_ASSERT_PRE_KEY_NAME "Key"
768
769#define BT_ASSERT_PRE_KEY_NON_NULL(_key) \
770 BT_ASSERT_PRE_NON_NULL(_key, _BT_ASSERT_PRE_KEY_NAME)
771
772#define BT_ASSERT_PRE_DEV_KEY_NON_NULL(_key) \
773 BT_ASSERT_PRE_DEV_NON_NULL(_key, _BT_ASSERT_PRE_KEY_NAME)
d98421f2
PP
774
775#endif /* BABELTRACE_ASSERT_COND_INTERNAL_H */
This page took 0.050839 seconds and 4 git commands to generate.