Commit | Line | Data |
---|---|---|
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 | 12 | |
5a3fec55 SM |
13 | #include <inttypes.h> |
14 | ||
d98421f2 PP |
15 | /* |
16 | * Asserts that a given variable `_obj` named `_obj_name` (capitalized) | |
1778c2a4 PP |
17 | * and having the ID `_obj_id` (within the function's context) is not |
18 | * `NULL`. | |
d98421f2 | 19 | */ |
1778c2a4 PP |
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), \ | |
2831529d | 22 | "%s is NULL.", _obj_name) |
1778c2a4 PP |
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) | |
d98421f2 PP |
26 | |
27 | /* | |
28 | * Asserts that a given index `_index` is less than a given length | |
29 | * `_length`. | |
30 | */ | |
1778c2a4 PP |
31 | #define BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(_func, _index, _length) \ |
32 | BT_ASSERT_PRE_FROM_FUNC(_func, "valid-index", (_index) < (_length), \ | |
d98421f2 PP |
33 | "Index is out of bounds: index=%" PRIu64 ", " \ |
34 | "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_length)) | |
35 | ||
1778c2a4 PP |
36 | #define BT_ASSERT_PRE_VALID_INDEX(_index, _length) \ |
37 | BT_ASSERT_PRE_VALID_INDEX_FROM_FUNC(__func__, (_index), (_length)) | |
38 | ||
d98421f2 PP |
39 | /* |
40 | * Asserts that the current thread has no error set. | |
41 | */ | |
1778c2a4 PP |
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); \ | |
d98421f2 PP |
51 | } while (0) |
52 | ||
1778c2a4 PP |
53 | #define BT_ASSERT_PRE_NO_ERROR() \ |
54 | BT_ASSERT_PRE_NO_ERROR_FROM_FUNC(__func__) | |
55 | ||
d98421f2 PP |
56 | /* |
57 | * Asserts that, if the current thread has an error, `_status` is an | |
58 | * error status code. | |
59 | * | |
1778c2a4 PP |
60 | * See _BT_ASSERT_COND() for details about the `_func` parameter. |
61 | * | |
d98421f2 PP |
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 | */ | |
1778c2a4 | 65 | #define BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \ |
d98421f2 | 66 | do { \ |
1778c2a4 PP |
67 | const struct bt_error *_err = bt_current_thread_take_error(); \ |
68 | if (_err) { \ | |
69 | bt_current_thread_move_error(_err); \ | |
d98421f2 | 70 | } \ |
1778c2a4 PP |
71 | BT_ASSERT_POST(_func, "no-error-if-no-error-status", \ |
72 | (_status) < 0 || !_err, \ | |
d98421f2 PP |
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. | |
1778c2a4 PP |
80 | * |
81 | * See _BT_ASSERT_COND() for details about the `_func` parameter. | |
d98421f2 | 82 | */ |
1778c2a4 PP |
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) | |
d98421f2 PP |
92 | |
93 | #ifdef BT_DEV_MODE | |
1778c2a4 PP |
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 | ||
d98421f2 | 98 | /* Developer mode version of BT_ASSERT_PRE_NON_NULL() */ |
1778c2a4 PP |
99 | # define BT_ASSERT_PRE_DEV_NON_NULL(_obj_id, _obj, _obj_name) \ |
100 | BT_ASSERT_PRE_NON_NULL(_obj_id, (_obj), (_obj_name)) | |
d98421f2 PP |
101 | |
102 | /* | |
103 | * Developer mode: asserts that a given object `_obj` named `_obj_name` | |
1778c2a4 PP |
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`. | |
d98421f2 PP |
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 | */ | |
1778c2a4 PP |
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)) | |
d98421f2 PP |
124 | |
125 | /* Developer mode version of BT_ASSERT_PRE_VALID_INDEX() */ | |
1778c2a4 | 126 | # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \ |
d98421f2 PP |
127 | BT_ASSERT_PRE_VALID_INDEX((_index), (_length)) |
128 | ||
1778c2a4 PP |
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 | ||
d98421f2 | 133 | /* Developer mode version of BT_ASSERT_PRE_NO_ERROR(). */ |
1778c2a4 | 134 | # define BT_ASSERT_PRE_DEV_NO_ERROR() BT_ASSERT_PRE_NO_ERROR() |
d98421f2 | 135 | |
d98421f2 PP |
136 | /* |
137 | * Developer mode version of | |
138 | * BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(). | |
139 | */ | |
1778c2a4 PP |
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)) | |
d98421f2 PP |
142 | |
143 | /* Developer mode version of BT_ASSERT_POST_NO_ERROR(). */ | |
1778c2a4 PP |
144 | # define BT_ASSERT_POST_DEV_NO_ERROR(_func) \ |
145 | BT_ASSERT_POST_NO_ERROR(_func) | |
d98421f2 | 146 | |
d98421f2 PP |
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 | |
1778c2a4 PP |
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) | |
2bdc32f7 | 161 | |
1778c2a4 PP |
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)) | |
2bdc32f7 | 167 | |
d98421f2 | 168 | # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \ |
1778c2a4 PP |
169 | BT_USE_EXPR2((_index), (_length)) |
170 | ||
171 | # define BT_ASSERT_PRE_DEV_NO_ERROR_FROM_FUNC(_func) \ | |
172 | BT_USE_EXPR(_func) | |
2bdc32f7 | 173 | |
d98421f2 | 174 | # define BT_ASSERT_PRE_DEV_NO_ERROR() |
2bdc32f7 | 175 | |
1778c2a4 PP |
176 | # define BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(_func, _status) \ |
177 | BT_USE_EXPR2(_func, _status) | |
2bdc32f7 | 178 | |
1778c2a4 PP |
179 | # define BT_ASSERT_POST_DEV_NO_ERROR(_func) \ |
180 | BT_USE_EXPR(_func) | |
d98421f2 PP |
181 | #endif /* BT_DEV_MODE */ |
182 | ||
2bdc32f7 | 183 | #define _BT_ASSERT_PRE_CLK_CLS_NAME "Clock class" |
1778c2a4 | 184 | #define _BT_ASSERT_PRE_CLK_CLS_ID "clock-class" |
2bdc32f7 PP |
185 | |
186 | #define BT_ASSERT_PRE_CLK_CLS_NON_NULL(_cc) \ | |
1778c2a4 PP |
187 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CLK_CLS_ID, (_cc), \ |
188 | _BT_ASSERT_PRE_CLK_CLS_NAME) | |
2bdc32f7 PP |
189 | |
190 | #define BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(_cc) \ | |
1778c2a4 PP |
191 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CLK_CLS_ID, (_cc), \ |
192 | _BT_ASSERT_PRE_CLK_CLS_NAME) | |
2bdc32f7 PP |
193 | |
194 | #define _BT_ASSERT_PRE_DEF_CLK_CLS_NAME "Default clock class" | |
1778c2a4 | 195 | #define _BT_ASSERT_PRE_DEF_CLK_CLS_ID "default-clock-class" |
2bdc32f7 PP |
196 | |
197 | #define BT_ASSERT_PRE_DEF_CLK_CLS_NON_NULL(_cc) \ | |
1778c2a4 PP |
198 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_DEF_CLK_CLS_ID, (_cc), \ |
199 | _BT_ASSERT_PRE_DEF_CLK_CLS_NAME) | |
2bdc32f7 PP |
200 | |
201 | #define BT_ASSERT_PRE_DEV_DEF_CLK_CLS_NON_NULL(_cc) \ | |
1778c2a4 PP |
202 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_DEF_CLK_CLS_ID, \ |
203 | (_cc), _BT_ASSERT_PRE_DEF_CLK_CLS_NAME) | |
2bdc32f7 PP |
204 | |
205 | #define _BT_ASSERT_PRE_CS_NAME "Clock snapshot" | |
1778c2a4 | 206 | #define _BT_ASSERT_PRE_CS_ID "clock-snapshot" |
2bdc32f7 PP |
207 | |
208 | #define BT_ASSERT_PRE_CS_NON_NULL(_cs) \ | |
1778c2a4 PP |
209 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CS_ID, (_cs), \ |
210 | _BT_ASSERT_PRE_CS_NAME) | |
2bdc32f7 PP |
211 | |
212 | #define BT_ASSERT_PRE_DEV_CS_NON_NULL(_cs) \ | |
1778c2a4 PP |
213 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CS_ID, (_cs), \ |
214 | _BT_ASSERT_PRE_CS_NAME) | |
2bdc32f7 PP |
215 | |
216 | #define _BT_ASSERT_PRE_EVENT_NAME "Event" | |
1778c2a4 | 217 | #define _BT_ASSERT_PRE_EVENT_ID "event" |
2bdc32f7 | 218 | |
1778c2a4 PP |
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) | |
2bdc32f7 | 222 | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
226 | |
227 | #define _BT_ASSERT_PRE_EC_NAME "Event class" | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
233 | |
234 | #define BT_ASSERT_PRE_EC_NON_NULL(_ec) \ | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
241 | |
242 | #define BT_ASSERT_PRE_DEV_EC_NON_NULL(_ec) \ | |
1778c2a4 PP |
243 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_EC_ID, (_ec), \ |
244 | _BT_ASSERT_PRE_EC_NAME) | |
2bdc32f7 PP |
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 | ||
1778c2a4 PP |
255 | #define _BT_ASSERT_PRE_FC_IS_INT_ID(_fc_id) "is-int-field-class:" _fc_id |
256 | ||
2bdc32f7 PP |
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 | ||
1778c2a4 PP |
264 | #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_ID(_fc_id) \ |
265 | "is-unsigned-integer-field-class:" _fc_id | |
2bdc32f7 PP |
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 | ||
1778c2a4 PP |
274 | #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_ID(_fc_id) \ |
275 | "is-signed-integer-field-class:" _fc_id | |
276 | ||
2bdc32f7 PP |
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 | ||
1778c2a4 PP |
284 | #define _BT_ASSERT_PRE_FC_IS_ENUM_ID(_fc_id) \ |
285 | "is-enumeration-field-class:" _fc_id | |
286 | ||
2bdc32f7 PP |
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 | ||
1778c2a4 PP |
295 | #define _BT_ASSERT_PRE_FC_IS_ARRAY_ID(_fc_id) \ |
296 | "is-array-field-class:" _fc_id | |
297 | ||
2bdc32f7 PP |
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 | ||
1778c2a4 PP |
307 | #define _BT_ASSERT_PRE_FC_IS_OPTION_ID(_fc_id) \ |
308 | "is-option-field-class:" _fc_id | |
309 | ||
2bdc32f7 PP |
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 | ||
1778c2a4 PP |
318 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_ID(_fc_id) \ |
319 | "is-option-field-class-with-selector:" _fc_id | |
320 | ||
2bdc32f7 PP |
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 | ||
1778c2a4 PP |
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 | ||
2bdc32f7 PP |
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 | ||
1778c2a4 PP |
337 | #define _BT_ASSERT_PRE_FC_IS_STRUCT_ID(_fc_id) \ |
338 | "is-structure-field-class:" _fc_id | |
339 | ||
2bdc32f7 PP |
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 | ||
1778c2a4 PP |
348 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_ID(_fc_id) \ |
349 | "is-variant-field-class:" _fc_id | |
350 | ||
2bdc32f7 PP |
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 | ||
1778c2a4 PP |
358 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_ID(_fc_id) \ |
359 | "is-variant-field-class-with-selector:" _fc_id | |
360 | ||
0a83319b | 361 | #define _BT_ASSERT_PRE_FC_HAS_TYPE_COND(_fc, _type) \ |
2bdc32f7 PP |
362 | (((const struct bt_field_class *) (_fc))->type == (_type)) |
363 | ||
0a83319b | 364 | #define _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name) \ |
2bdc32f7 PP |
365 | _name " has the wrong type: expected-type=%s, %![fc-]+F" |
366 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
374 | _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc)) |
375 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
383 | _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc)) |
384 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
389 | _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc)) |
390 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
395 | _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc)) |
396 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
401 | _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc)) |
402 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
407 | _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name), (_fc)) |
408 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
413 | _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc)) |
414 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
419 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc)) |
420 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
425 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc)) |
426 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
431 | _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc)) |
432 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
437 | _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc)) |
438 | ||
1778c2a4 PP |
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)), \ | |
0a83319b | 443 | _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name), \ |
2bdc32f7 PP |
444 | bt_common_field_class_type_string(_type), (_fc)) |
445 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
454 | _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc)) |
455 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
460 | _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc)) |
461 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
466 | _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc)) |
467 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
472 | _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc)) |
473 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
478 | _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc)) |
479 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
484 | _BT_ASSERT_PRE_FC_IS_STRUCT_FMT(_name), (_fc)) |
485 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
490 | _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc)) |
491 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
495 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc)) |
496 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
501 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc)) |
502 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
507 | _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc)) |
508 | ||
1778c2a4 PP |
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), \ | |
2bdc32f7 PP |
513 | _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc)) |
514 | ||
1778c2a4 PP |
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)), \ | |
0a83319b | 519 | _BT_ASSERT_PRE_FC_HAS_TYPE_FMT(_name), \ |
2bdc32f7 PP |
520 | bt_common_field_class_type_string(_type), (_fc)) |
521 | ||
1778c2a4 PP |
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)) | |
2bdc32f7 PP |
529 | |
530 | #define _BT_ASSERT_PRE_FC_NAME "Field class" | |
1778c2a4 | 531 | #define _BT_ASSERT_PRE_FC_ID "field-class" |
2bdc32f7 PP |
532 | |
533 | #define BT_ASSERT_PRE_FC_NON_NULL(_fc) \ | |
1778c2a4 PP |
534 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FC_ID, (_fc), \ |
535 | _BT_ASSERT_PRE_FC_NAME) | |
2bdc32f7 PP |
536 | |
537 | #define BT_ASSERT_PRE_DEV_FC_NON_NULL(_fc) \ | |
1778c2a4 PP |
538 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FC_ID, (_fc), \ |
539 | _BT_ASSERT_PRE_FC_NAME) | |
2bdc32f7 PP |
540 | |
541 | #define _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME "Structure field class member" | |
1778c2a4 | 542 | #define _BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID "structure-field-class-member" |
2bdc32f7 PP |
543 | |
544 | #define BT_ASSERT_PRE_STRUCT_FC_MEMBER_NON_NULL(_fc) \ | |
1778c2a4 PP |
545 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID, \ |
546 | (_fc), _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME) | |
2bdc32f7 PP |
547 | |
548 | #define BT_ASSERT_PRE_DEV_STRUCT_FC_MEMBER_NON_NULL(_fc) \ | |
1778c2a4 PP |
549 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_STRUCT_FC_MEMBER_ID, \ |
550 | (_fc), _BT_ASSERT_PRE_STRUCT_FC_MEMBER_NAME) | |
2bdc32f7 PP |
551 | |
552 | #define _BT_ASSERT_PRE_VAR_FC_OPT_NAME "Variant field class option" | |
1778c2a4 | 553 | #define _BT_ASSERT_PRE_VAR_FC_OPT_ID "variant-field-class-option-id" |
2bdc32f7 PP |
554 | |
555 | #define BT_ASSERT_PRE_VAR_FC_OPT_NON_NULL(_fc) \ | |
1778c2a4 PP |
556 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_VAR_FC_OPT_ID, (_fc), \ |
557 | _BT_ASSERT_PRE_VAR_FC_OPT_NAME) | |
2bdc32f7 PP |
558 | |
559 | #define BT_ASSERT_PRE_DEV_VAR_FC_OPT_NON_NULL(_fc) \ | |
1778c2a4 PP |
560 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_VAR_FC_OPT_ID, (_fc), \ |
561 | _BT_ASSERT_PRE_VAR_FC_OPT_NAME) | |
2bdc32f7 PP |
562 | |
563 | #define _BT_ASSERT_PRE_FP_NAME "Field path" | |
1778c2a4 | 564 | #define _BT_ASSERT_PRE_FP_ID "field-path" |
2bdc32f7 PP |
565 | |
566 | #define BT_ASSERT_PRE_FP_NON_NULL(_fp) \ | |
1778c2a4 PP |
567 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FP_ID, (_fp), \ |
568 | _BT_ASSERT_PRE_FP_NAME) | |
2bdc32f7 PP |
569 | |
570 | #define BT_ASSERT_PRE_DEV_FP_NON_NULL(_fp) \ | |
1778c2a4 PP |
571 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FP_ID, (_fp), \ |
572 | _BT_ASSERT_PRE_FP_NAME) | |
2bdc32f7 | 573 | |
867eb763 SM |
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, \ | |
1778c2a4 | 576 | ((const struct bt_field *) (_field))->class->type == (_cls_type), \ |
2bdc32f7 PP |
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 | ||
867eb763 SM |
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 | ||
1778c2a4 | 585 | #define BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(_field_id, _field, _name) \ |
2bdc32f7 | 586 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 587 | "is-unsigned-integer-field:" _field_id, \ |
2bdc32f7 PP |
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 | ||
1778c2a4 | 593 | #define BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(_field_id, _field, _name) \ |
2bdc32f7 | 594 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 595 | "is-signed-integer-field:" _field_id, \ |
2bdc32f7 PP |
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 | ||
867eb763 SM |
601 | #define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY_FROM_FUNC(_func, _field_id, _field, _name) \ |
602 | BT_ASSERT_PRE_DEV_FROM_FUNC(_func, \ | |
1778c2a4 | 603 | "is-array-field:" _field_id, \ |
2bdc32f7 PP |
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 | ||
867eb763 SM |
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 | ||
1778c2a4 | 613 | #define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(_field_id, _field, _name) \ |
2bdc32f7 | 614 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 615 | "is-dynamic-array-field:" _field_id, \ |
2bdc32f7 PP |
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 | ||
1778c2a4 | 620 | #define BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(_field_id, _field, _name) \ |
2bdc32f7 | 621 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 622 | "is-option-field:" _field_id, \ |
2bdc32f7 PP |
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 | ||
1778c2a4 | 629 | #define BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(_field_id, _field, _name) \ |
2bdc32f7 | 630 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 631 | "is-variant-field:" _field_id, \ |
2bdc32f7 PP |
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 | ||
1778c2a4 PP |
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), \ | |
d5b13b9b | 640 | "Field is not set: %!+f", (_field)) |
2bdc32f7 PP |
641 | |
642 | #define _BT_ASSERT_PRE_FIELD_NAME "Field" | |
1778c2a4 | 643 | #define _BT_ASSERT_PRE_FIELD_ID "field" |
2bdc32f7 PP |
644 | |
645 | #define BT_ASSERT_PRE_FIELD_NON_NULL(_field) \ | |
1778c2a4 PP |
646 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field), \ |
647 | _BT_ASSERT_PRE_FIELD_NAME) | |
2bdc32f7 | 648 | |
867eb763 SM |
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 | ||
2bdc32f7 | 654 | #define BT_ASSERT_PRE_DEV_FIELD_NON_NULL(_field) \ |
1778c2a4 PP |
655 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field), \ |
656 | _BT_ASSERT_PRE_FIELD_NAME) | |
2bdc32f7 PP |
657 | |
658 | #define _BT_ASSERT_PRE_PACKET_NAME "Packet" | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
664 | |
665 | #define BT_ASSERT_PRE_PACKET_NON_NULL(_packet) \ | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
672 | |
673 | #define BT_ASSERT_PRE_DEV_PACKET_NON_NULL(_packet) \ | |
1778c2a4 PP |
674 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PACKET_ID, (_packet), \ |
675 | _BT_ASSERT_PRE_PACKET_NAME) | |
2bdc32f7 PP |
676 | |
677 | #define _BT_ASSERT_PRE_SC_NAME "Stream class" | |
1778c2a4 | 678 | #define _BT_ASSERT_PRE_SC_ID "stream-class" |
2bdc32f7 PP |
679 | |
680 | #define BT_ASSERT_PRE_SC_NON_NULL(_sc) \ | |
1778c2a4 PP |
681 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_SC_ID, (_sc), \ |
682 | _BT_ASSERT_PRE_SC_NAME) | |
2bdc32f7 PP |
683 | |
684 | #define BT_ASSERT_PRE_DEV_SC_NON_NULL(_sc) \ | |
1778c2a4 PP |
685 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_SC_ID, (_sc), \ |
686 | _BT_ASSERT_PRE_SC_NAME) | |
2bdc32f7 PP |
687 | |
688 | #define _BT_ASSERT_PRE_STREAM_NAME "Stream" | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
695 | |
696 | #define BT_ASSERT_PRE_STREAM_NON_NULL(_stream) \ | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
704 | |
705 | #define BT_ASSERT_PRE_DEV_STREAM_NON_NULL(_stream) \ | |
1778c2a4 PP |
706 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_STREAM_ID, (_stream), \ |
707 | _BT_ASSERT_PRE_STREAM_NAME) | |
2bdc32f7 PP |
708 | |
709 | #define _BT_ASSERT_PRE_TC_NAME "Trace class" | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
715 | |
716 | #define BT_ASSERT_PRE_TC_NON_NULL(_tc) \ | |
1778c2a4 PP |
717 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_TC_ID, (_tc), \ |
718 | _BT_ASSERT_PRE_TC_NAME) | |
2bdc32f7 PP |
719 | |
720 | #define BT_ASSERT_PRE_DEV_TC_NON_NULL(_tc) \ | |
1778c2a4 PP |
721 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_TC_ID, (_tc), \ |
722 | _BT_ASSERT_PRE_TC_NAME) | |
2bdc32f7 PP |
723 | |
724 | #define _BT_ASSERT_PRE_TRACE_NAME "Trace" | |
1778c2a4 | 725 | #define _BT_ASSERT_PRE_TRACE_ID "trace" |
2bdc32f7 PP |
726 | |
727 | #define BT_ASSERT_PRE_TRACE_NON_NULL(_trace) \ | |
1778c2a4 PP |
728 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_TRACE_ID, (_trace), \ |
729 | _BT_ASSERT_PRE_TRACE_NAME) | |
2bdc32f7 PP |
730 | |
731 | #define BT_ASSERT_PRE_DEV_TRACE_NON_NULL(_trace) \ | |
1778c2a4 PP |
732 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_TRACE_ID, (_trace), \ |
733 | _BT_ASSERT_PRE_TRACE_NAME) | |
2bdc32f7 | 734 | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
742 | |
743 | #define BT_ASSERT_PRE_USER_ATTRS_NON_NULL(_ua) \ | |
1778c2a4 | 744 | BT_ASSERT_PRE_USER_ATTRS_NON_NULL_FROM_FUNC(__func__, (_ua)) |
2bdc32f7 PP |
745 | |
746 | #define BT_ASSERT_PRE_DEV_USER_ATTRS_NON_NULL(_ua) \ | |
1778c2a4 PP |
747 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_USER_ATTRS_ID, (_ua), \ |
748 | _BT_ASSERT_PRE_USER_ATTRS_NAME) | |
2bdc32f7 | 749 | |
1778c2a4 PP |
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, \ | |
2bdc32f7 PP |
753 | _BT_ASSERT_PRE_USER_ATTRS_NAME \ |
754 | " object is not a map value object.") | |
755 | ||
1778c2a4 PP |
756 | #define BT_ASSERT_PRE_USER_ATTRS_IS_MAP(_ua) \ |
757 | BT_ASSERT_PRE_USER_ATTRS_IS_MAP_FROM_FUNC(__func__, (_ua)) | |
758 | ||
2bdc32f7 | 759 | #define BT_ASSERT_COND_LISTENER_FUNC_NAME "Listener function" |
1778c2a4 | 760 | #define BT_ASSERT_COND_LISTENER_FUNC_ID "listener-function" |
2bdc32f7 | 761 | |
1778c2a4 PP |
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) | |
2bdc32f7 | 765 | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
769 | |
770 | #define _BT_ASSERT_PRE_MSG_ITER_NAME "Message iterator" | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
777 | |
778 | #define BT_ASSERT_PRE_MSG_ITER_NON_NULL(_msg_iter) \ | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
786 | |
787 | #define BT_ASSERT_PRE_DEV_MSG_ITER_NON_NULL(_msg_iter) \ | |
1778c2a4 PP |
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)); | |
2bdc32f7 PP |
817 | |
818 | #define BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS(_msg, _sc) \ | |
1778c2a4 | 819 | BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS_FROM_FUNC(__func__, (_msg), (_sc)) |
2bdc32f7 | 820 | |
0a83319b | 821 | #define _BT_ASSERT_PRE_MSG_HAS_TYPE_COND(_msg, _type) \ |
2bdc32f7 PP |
822 | (((struct bt_message *) (_msg))->type == (_type)) |
823 | ||
0a83319b | 824 | #define _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT \ |
2bdc32f7 PP |
825 | "Message has the wrong type: expected-type=%s, %![msg-]+n" |
826 | ||
1778c2a4 PP |
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) \ | |
2bdc32f7 | 831 | BT_ASSERT_PRE( \ |
1778c2a4 | 832 | _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id), \ |
0a83319b PP |
833 | _BT_ASSERT_PRE_MSG_HAS_TYPE_COND((_msg), (_type)), \ |
834 | _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT, \ | |
1e123ed6 | 835 | bt_common_message_type_string(_type), (_msg)) |
2bdc32f7 | 836 | |
1778c2a4 | 837 | #define BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(_msg_id, _msg, _type_id, _type) \ |
2bdc32f7 | 838 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 839 | _BT_ASSERT_PRE_MSG_HAS_TYPE_ID(_msg_id, _type_id), \ |
0a83319b PP |
840 | _BT_ASSERT_PRE_MSG_HAS_TYPE_COND((_msg), (_type)), \ |
841 | _BT_ASSERT_PRE_MSG_HAS_TYPE_FMT, \ | |
1e123ed6 | 842 | bt_common_message_type_string(_type), (_msg)) |
2bdc32f7 PP |
843 | |
844 | #define _BT_ASSERT_PRE_MSG_NAME "Message" | |
1778c2a4 | 845 | #define _BT_ASSERT_PRE_MSG_ID "message" |
2bdc32f7 PP |
846 | |
847 | #define BT_ASSERT_PRE_MSG_NON_NULL(_msg_iter) \ | |
1778c2a4 PP |
848 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ID, (_msg_iter), \ |
849 | _BT_ASSERT_PRE_MSG_NAME) | |
2bdc32f7 PP |
850 | |
851 | #define BT_ASSERT_PRE_DEV_MSG_NON_NULL(_msg_iter) \ | |
1778c2a4 PP |
852 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_MSG_ID, (_msg_iter), \ |
853 | _BT_ASSERT_PRE_MSG_NAME) | |
2bdc32f7 | 854 | |
4030a924 | 855 | #define BT_ASSERT_PRE_MSG_CS_BEGIN_LE_END(_msg_iter, _begin, _end) \ |
1778c2a4 PP |
856 | BT_ASSERT_PRE("beginning-default-clock-snapshot-lteq-end", \ |
857 | (_begin) <= (_end), \ | |
2bdc32f7 PP |
858 | "Beginning default clock snapshot value is greater " \ |
859 | "than end default clock snapshot value: " \ | |
860 | "cs-begin-val=%" PRIu64 ", cs-end-val=%" PRIu64 ", " \ | |
1778c2a4 | 861 | "%![msg-iter-]+i", (_begin), (_end), _msg_iter); |
2bdc32f7 PP |
862 | |
863 | #define BT_ASSERT_PRE_DEV_MSG_HOT(_msg) \ | |
1778c2a4 | 864 | BT_ASSERT_PRE_DEV_HOT("message", (_msg), "Message", ": %!+n", (_msg)); |
2bdc32f7 PP |
865 | |
866 | #define _BT_ASSERT_PRE_MSG_ITER_CLS_NAME "Message iterator class" | |
1778c2a4 | 867 | #define _BT_ASSERT_PRE_MSG_ITER_CLS_ID "message-iterator-class" |
2bdc32f7 PP |
868 | |
869 | #define BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(_msg_iter_cls) \ | |
1778c2a4 PP |
870 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_MSG_ITER_CLS_ID, \ |
871 | (_msg_iter_cls), _BT_ASSERT_PRE_MSG_ITER_CLS_NAME) | |
2bdc32f7 PP |
872 | |
873 | #define BT_ASSERT_PRE_DEV_MSG_ITER_CLS_NON_NULL(_msg_iter_cls) \ | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
876 | |
877 | #define _BT_ASSERT_PRE_COMP_CLS_NAME "Component class" | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
884 | |
885 | #define BT_ASSERT_PRE_COMP_CLS_NON_NULL(_comp_cls) \ | |
1778c2a4 PP |
886 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_CLS_ID, (_comp_cls), \ |
887 | _BT_ASSERT_PRE_COMP_CLS_NAME) | |
2bdc32f7 PP |
888 | |
889 | #define BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(_comp_cls) \ | |
1778c2a4 PP |
890 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_CLS_ID, \ |
891 | (_comp_cls), _BT_ASSERT_PRE_COMP_CLS_NAME) | |
2bdc32f7 PP |
892 | |
893 | #define _BT_ASSERT_PRE_COMP_DESCR_SET_NAME "Component descriptor set" | |
1778c2a4 | 894 | #define _BT_ASSERT_PRE_COMP_DESCR_SET_ID "component-descriptor-set" |
2bdc32f7 PP |
895 | |
896 | #define BT_ASSERT_PRE_COMP_DESCR_SET_NON_NULL(_comp_descr_set) \ | |
1778c2a4 PP |
897 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_COMP_DESCR_SET_ID, \ |
898 | (_comp_descr_set), _BT_ASSERT_PRE_COMP_DESCR_SET_NAME) | |
2bdc32f7 PP |
899 | |
900 | #define BT_ASSERT_PRE_DEV_COMP_DESCR_SET_NON_NULL(_comp_descr_set) \ | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
903 | |
904 | #define _BT_ASSERT_PRE_COMP_NAME "Component" | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
910 | |
911 | #define BT_ASSERT_PRE_COMP_NON_NULL(_comp) \ | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
918 | |
919 | #define BT_ASSERT_PRE_DEV_COMP_NON_NULL(_comp) \ | |
1778c2a4 PP |
920 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_COMP_ID, (_comp), \ |
921 | _BT_ASSERT_PRE_COMP_NAME) | |
2bdc32f7 PP |
922 | |
923 | #define _BT_ASSERT_PRE_CONN_NAME "Connection" | |
1778c2a4 | 924 | #define _BT_ASSERT_PRE_CONN_ID "connection" |
2bdc32f7 PP |
925 | |
926 | #define BT_ASSERT_PRE_CONN_NON_NULL(_conn) \ | |
1778c2a4 PP |
927 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_CONN_ID, (_conn), \ |
928 | _BT_ASSERT_PRE_CONN_NAME) | |
2bdc32f7 PP |
929 | |
930 | #define BT_ASSERT_PRE_DEV_CONN_NON_NULL(_conn) \ | |
1778c2a4 PP |
931 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_CONN_ID, (_conn), \ |
932 | _BT_ASSERT_PRE_CONN_NAME) | |
2bdc32f7 PP |
933 | |
934 | #define _BT_ASSERT_PRE_GRAPH_NAME "Graph" | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
940 | |
941 | #define BT_ASSERT_PRE_GRAPH_NON_NULL(_graph) \ | |
1778c2a4 PP |
942 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_GRAPH_ID, (_graph), \ |
943 | _BT_ASSERT_PRE_GRAPH_NAME) | |
2bdc32f7 PP |
944 | |
945 | #define BT_ASSERT_PRE_DEV_GRAPH_NON_NULL(_graph) \ | |
1778c2a4 PP |
946 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_GRAPH_ID, (_graph), \ |
947 | _BT_ASSERT_PRE_GRAPH_NAME) | |
2bdc32f7 PP |
948 | |
949 | #define _BT_ASSERT_PRE_INTR_NAME "Interrupter" | |
1778c2a4 | 950 | #define _BT_ASSERT_PRE_INTR_ID "interrupter" |
2bdc32f7 PP |
951 | |
952 | #define BT_ASSERT_PRE_INTR_NON_NULL(_intr) \ | |
1778c2a4 PP |
953 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INTR_ID, (_intr), \ |
954 | _BT_ASSERT_PRE_INTR_NAME) | |
2bdc32f7 PP |
955 | |
956 | #define BT_ASSERT_PRE_DEV_INTR_NON_NULL(_intr) \ | |
1778c2a4 PP |
957 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_INTR_ID, (_intr), \ |
958 | _BT_ASSERT_PRE_INTR_NAME) | |
2bdc32f7 PP |
959 | |
960 | #define _BT_ASSERT_PRE_PORT_NAME "Port" | |
1778c2a4 | 961 | #define _BT_ASSERT_PRE_PORT_ID "port" |
2bdc32f7 PP |
962 | |
963 | #define BT_ASSERT_PRE_PORT_NON_NULL(_port) \ | |
1778c2a4 PP |
964 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PORT_ID, (_port), \ |
965 | _BT_ASSERT_PRE_PORT_NAME) | |
2bdc32f7 PP |
966 | |
967 | #define BT_ASSERT_PRE_DEV_PORT_NON_NULL(_port) \ | |
1778c2a4 PP |
968 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PORT_ID, (_port), \ |
969 | _BT_ASSERT_PRE_PORT_NAME) | |
2bdc32f7 PP |
970 | |
971 | #define _BT_ASSERT_PRE_QUERY_EXEC_NAME "Query executor" | |
1778c2a4 | 972 | #define _BT_ASSERT_PRE_QUERY_EXEC_ID "query-executor" |
2bdc32f7 PP |
973 | |
974 | #define BT_ASSERT_PRE_QUERY_EXEC_NON_NULL(_query_exec) \ | |
1778c2a4 PP |
975 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_QUERY_EXEC_ID, \ |
976 | (_query_exec), _BT_ASSERT_PRE_QUERY_EXEC_NAME) | |
2bdc32f7 PP |
977 | |
978 | #define BT_ASSERT_PRE_DEV_QUERY_EXEC_NON_NULL(_query_exec) \ | |
1778c2a4 PP |
979 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_QUERY_EXEC_ID, \ |
980 | (_query_exec), _BT_ASSERT_PRE_QUERY_EXEC_NAME) | |
2bdc32f7 PP |
981 | |
982 | #define _BT_ASSERT_PRE_PLUGIN_SET_NAME "Plugin set" | |
1778c2a4 | 983 | #define _BT_ASSERT_PRE_PLUGIN_SET_ID "plugin-set" |
2bdc32f7 PP |
984 | |
985 | #define BT_ASSERT_PRE_PLUGIN_SET_NON_NULL(_plugin_set) \ | |
1778c2a4 PP |
986 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_ID, \ |
987 | (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_NAME) | |
2bdc32f7 PP |
988 | |
989 | #define BT_ASSERT_PRE_DEV_PLUGIN_SET_NON_NULL(_plugin_set) \ | |
1778c2a4 PP |
990 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_ID, \ |
991 | (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_NAME) | |
2bdc32f7 PP |
992 | |
993 | #define _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME \ | |
994 | _BT_ASSERT_PRE_PLUGIN_SET_NAME " (output)" | |
1778c2a4 PP |
995 | #define _BT_ASSERT_PRE_PLUGIN_SET_OUT_ID \ |
996 | _BT_ASSERT_PRE_PLUGIN_SET_ID "-output" | |
2bdc32f7 PP |
997 | |
998 | #define BT_ASSERT_PRE_PLUGIN_SET_OUT_NON_NULL(_plugin_set) \ | |
1778c2a4 PP |
999 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_OUT_ID, \ |
1000 | (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME) | |
2bdc32f7 PP |
1001 | |
1002 | #define BT_ASSERT_PRE_DEV_PLUGIN_SET_OUT_NON_NULL(_plugin_set) \ | |
1778c2a4 PP |
1003 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_SET_OUT_ID, \ |
1004 | (_plugin_set), _BT_ASSERT_PRE_PLUGIN_SET_OUT_NAME) | |
2bdc32f7 PP |
1005 | |
1006 | #define _BT_ASSERT_PRE_PLUGIN_NAME "Plugin" | |
1778c2a4 | 1007 | #define _BT_ASSERT_PRE_PLUGIN_ID "plugin" |
2bdc32f7 PP |
1008 | |
1009 | #define BT_ASSERT_PRE_PLUGIN_NON_NULL(_plugin) \ | |
1778c2a4 PP |
1010 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_ID, (_plugin), \ |
1011 | _BT_ASSERT_PRE_PLUGIN_NAME) | |
2bdc32f7 PP |
1012 | |
1013 | #define BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(_plugin) \ | |
1778c2a4 PP |
1014 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_ID, (_plugin), \ |
1015 | _BT_ASSERT_PRE_PLUGIN_NAME) | |
2bdc32f7 PP |
1016 | |
1017 | #define _BT_ASSERT_PRE_PLUGIN_OUT_NAME \ | |
1018 | _BT_ASSERT_PRE_PLUGIN_NAME " (output)" | |
1778c2a4 PP |
1019 | #define _BT_ASSERT_PRE_PLUGIN_OUT_ID \ |
1020 | _BT_ASSERT_PRE_PLUGIN_ID "-output" | |
2bdc32f7 PP |
1021 | |
1022 | #define BT_ASSERT_PRE_PLUGIN_OUT_NON_NULL(_plugin) \ | |
1778c2a4 PP |
1023 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_PLUGIN_OUT_ID, (_plugin), \ |
1024 | _BT_ASSERT_PRE_PLUGIN_OUT_NAME) | |
2bdc32f7 PP |
1025 | |
1026 | #define BT_ASSERT_PRE_DEV_PLUGIN_OUT_NON_NULL(_plugin) \ | |
1778c2a4 PP |
1027 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_PLUGIN_OUT_ID, \ |
1028 | (_plugin), _BT_ASSERT_PRE_PLUGIN_OUT_NAME) | |
2bdc32f7 PP |
1029 | |
1030 | #define _BT_ASSERT_PRE_ERROR_NAME "Error" | |
1778c2a4 | 1031 | #define _BT_ASSERT_PRE_ERROR_ID "error" |
2bdc32f7 PP |
1032 | |
1033 | #define BT_ASSERT_PRE_ERROR_NON_NULL(_error) \ | |
1778c2a4 PP |
1034 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_ERROR_ID, (_error), \ |
1035 | _BT_ASSERT_PRE_ERROR_NAME) | |
2bdc32f7 PP |
1036 | |
1037 | #define BT_ASSERT_PRE_DEV_ERROR_NON_NULL(_error) \ | |
1778c2a4 PP |
1038 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_ERROR_ID, (_error), \ |
1039 | _BT_ASSERT_PRE_ERROR_NAME) | |
2bdc32f7 PP |
1040 | |
1041 | #define _BT_ASSERT_PRE_ERROR_CAUSE_NAME "Error cause" | |
1778c2a4 | 1042 | #define _BT_ASSERT_PRE_ERROR_CAUSE_ID "error-cause" |
2bdc32f7 PP |
1043 | |
1044 | #define BT_ASSERT_PRE_ERROR_CAUSE_NON_NULL(_error_cause) \ | |
1778c2a4 PP |
1045 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_ERROR_CAUSE_ID, \ |
1046 | (_error_cause), _BT_ASSERT_PRE_ERROR_CAUSE_NAME) | |
2bdc32f7 PP |
1047 | |
1048 | #define BT_ASSERT_PRE_DEV_ERROR_CAUSE_NON_NULL(_error_cause) \ | |
1778c2a4 PP |
1049 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_ERROR_CAUSE_ID, \ |
1050 | (_error_cause), _BT_ASSERT_PRE_ERROR_CAUSE_NAME) | |
2bdc32f7 PP |
1051 | |
1052 | #define _BT_ASSERT_PRE_INT_RANGE_NAME "Integer range" | |
1778c2a4 | 1053 | #define _BT_ASSERT_PRE_INT_RANGE_ID "integer-range" |
2bdc32f7 PP |
1054 | |
1055 | #define BT_ASSERT_PRE_INT_RANGE_NON_NULL(_int_range) \ | |
1778c2a4 PP |
1056 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_INT_RANGE_ID, \ |
1057 | (_int_range), _BT_ASSERT_PRE_INT_RANGE_NAME) | |
2bdc32f7 PP |
1058 | |
1059 | #define BT_ASSERT_PRE_DEV_INT_RANGE_NON_NULL(_int_range) \ | |
1778c2a4 PP |
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)) | |
2bdc32f7 PP |
1071 | |
1072 | #define _BT_ASSERT_PRE_INT_RANGE_SET_NAME "Integer range set" | |
1778c2a4 | 1073 | #define _BT_ASSERT_PRE_INT_RANGE_SET_ID "integer-range-set" |
2bdc32f7 | 1074 | |
1778c2a4 PP |
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) | |
2bdc32f7 | 1079 | |
1778c2a4 PP |
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) | |
2bdc32f7 | 1087 | |
0a83319b | 1088 | #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND(_value, _type) \ |
2bdc32f7 PP |
1089 | (((struct bt_value *) (_value))->type == (_type)) |
1090 | ||
0a83319b | 1091 | #define _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT \ |
2bdc32f7 PP |
1092 | "Value has the wrong type: expected-type=%s, %![value-]+v" |
1093 | ||
1778c2a4 PP |
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), \ | |
0a83319b PP |
1100 | _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND((_value), (_type)), \ |
1101 | _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT, \ | |
2bdc32f7 PP |
1102 | bt_common_value_type_string(_type), (_value)) |
1103 | ||
1778c2a4 PP |
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) \ | |
2bdc32f7 | 1141 | BT_ASSERT_PRE_DEV( \ |
1778c2a4 | 1142 | _BT_ASSERT_PRE_VALUE_HAS_TYPE_ID(_value_id, _type_id), \ |
0a83319b PP |
1143 | _BT_ASSERT_PRE_VALUE_HAS_TYPE_COND((_value), (_type)), \ |
1144 | _BT_ASSERT_PRE_VALUE_HAS_TYPE_FMT, \ | |
2bdc32f7 PP |
1145 | bt_common_value_type_string(_type), (_value)) |
1146 | ||
1778c2a4 PP |
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 | ||
2bdc32f7 | 1175 | #define _BT_ASSERT_PRE_VALUE_NAME "Value object" |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
1181 | |
1182 | #define BT_ASSERT_PRE_VALUE_NON_NULL(_value) \ | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
1189 | |
1190 | #define BT_ASSERT_PRE_DEV_VALUE_NON_NULL(_value) \ | |
1778c2a4 PP |
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)); | |
2bdc32f7 PP |
1199 | |
1200 | #define BT_ASSERT_PRE_PARAM_VALUE_IS_MAP(_value) \ | |
1778c2a4 | 1201 | BT_ASSERT_PRE_PARAM_VALUE_IS_MAP_FROM_FUNC(__func__, (_value)) |
2bdc32f7 PP |
1202 | |
1203 | #define _BT_ASSERT_PRE_RES_OUT_NAME "Result (output)" | |
1778c2a4 | 1204 | #define _BT_ASSERT_PRE_RES_OUT_ID "result-output" |
2bdc32f7 PP |
1205 | |
1206 | #define BT_ASSERT_PRE_RES_OUT_NON_NULL(_res) \ | |
1778c2a4 PP |
1207 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_RES_OUT_ID, (_res), \ |
1208 | _BT_ASSERT_PRE_RES_OUT_NAME) | |
2bdc32f7 PP |
1209 | |
1210 | #define BT_ASSERT_PRE_DEV_RES_OUT_NON_NULL(_res) \ | |
1778c2a4 PP |
1211 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_RES_OUT_ID, (_res), \ |
1212 | _BT_ASSERT_PRE_RES_OUT_NAME) | |
2bdc32f7 PP |
1213 | |
1214 | #define BT_ASSERT_PRE_METHOD_NON_NULL(_method) \ | |
1778c2a4 | 1215 | BT_ASSERT_PRE_NON_NULL("method", (_method), "Method"); |
2bdc32f7 PP |
1216 | |
1217 | #define _BT_ASSERT_PRE_NAME_NAME "Name" | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
1223 | |
1224 | #define BT_ASSERT_PRE_NAME_NON_NULL(_name) \ | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
1231 | |
1232 | #define BT_ASSERT_PRE_DEV_NAME_NON_NULL(_name) \ | |
1778c2a4 PP |
1233 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_NAME_ID, (_name), \ |
1234 | _BT_ASSERT_PRE_NAME_NAME) | |
2bdc32f7 PP |
1235 | |
1236 | #define _BT_ASSERT_PRE_DESCR_NAME "Description" | |
1778c2a4 | 1237 | #define _BT_ASSERT_PRE_DESCR_ID "description" |
2bdc32f7 PP |
1238 | |
1239 | #define BT_ASSERT_PRE_DESCR_NON_NULL(_descr) \ | |
1778c2a4 PP |
1240 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_DESCR_ID, (_descr), \ |
1241 | _BT_ASSERT_PRE_DESCR_NAME) | |
2bdc32f7 PP |
1242 | |
1243 | #define BT_ASSERT_PRE_DEV_DESCR_NON_NULL(_descr) \ | |
1778c2a4 PP |
1244 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_DESCR_ID, (_descr), \ |
1245 | _BT_ASSERT_PRE_DESCR_NAME) | |
2bdc32f7 PP |
1246 | |
1247 | #define _BT_ASSERT_PRE_UUID_NAME "UUID" | |
1778c2a4 | 1248 | #define _BT_ASSERT_PRE_UUID_ID "uuid" |
2bdc32f7 PP |
1249 | |
1250 | #define BT_ASSERT_PRE_UUID_NON_NULL(_uuid) \ | |
1778c2a4 PP |
1251 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_UUID_ID, (_uuid), \ |
1252 | _BT_ASSERT_PRE_UUID_NAME) | |
2bdc32f7 PP |
1253 | |
1254 | #define BT_ASSERT_PRE_DEV_UUID_NON_NULL(_uuid) \ | |
1778c2a4 PP |
1255 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_UUID_ID, (_uuid), \ |
1256 | _BT_ASSERT_PRE_UUID_NAME) | |
2bdc32f7 PP |
1257 | |
1258 | #define _BT_ASSERT_PRE_KEY_NAME "Key" | |
1778c2a4 PP |
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) | |
2bdc32f7 PP |
1264 | |
1265 | #define BT_ASSERT_PRE_KEY_NON_NULL(_key) \ | |
1778c2a4 PP |
1266 | BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_KEY_ID, (_key), \ |
1267 | _BT_ASSERT_PRE_KEY_NAME) | |
2bdc32f7 PP |
1268 | |
1269 | #define BT_ASSERT_PRE_DEV_KEY_NON_NULL(_key) \ | |
1778c2a4 PP |
1270 | BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_KEY_ID, (_key), \ |
1271 | _BT_ASSERT_PRE_KEY_NAME) | |
d98421f2 PP |
1272 | |
1273 | #endif /* BABELTRACE_ASSERT_COND_INTERNAL_H */ |