| 1 | #ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H |
| 2 | #define BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H |
| 3 | |
| 4 | /* |
| 5 | * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com> |
| 6 | * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 7 | * |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | * of this software and associated documentation files (the "Software"), to deal |
| 10 | * in the Software without restriction, including without limitation the rights |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | * copies of the Software, and to permit persons to whom the Software is |
| 13 | * furnished to do so, subject to the following conditions: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice shall be included in |
| 16 | * all copies or substantial portions of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 24 | * SOFTWARE. |
| 25 | */ |
| 26 | |
| 27 | #include "lib/assert-pre.h" |
| 28 | #include <babeltrace2/trace-ir/clock-class.h> |
| 29 | #include <babeltrace2/trace-ir/field-class.h> |
| 30 | #include "common/macros.h" |
| 31 | #include "common/common.h" |
| 32 | #include "lib/object.h" |
| 33 | #include <babeltrace2/types.h> |
| 34 | #include <stdbool.h> |
| 35 | #include <stdint.h> |
| 36 | #include <glib.h> |
| 37 | |
| 38 | #define _BT_ASSERT_PRE_FC_IS_INT_COND(_fc) \ |
| 39 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \ |
| 40 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \ |
| 41 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \ |
| 42 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) |
| 43 | |
| 44 | #define _BT_ASSERT_PRE_FC_IS_INT_FMT(_name) \ |
| 45 | _name " is not an integer field class: %![fc-]+F" |
| 46 | |
| 47 | #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc) \ |
| 48 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \ |
| 49 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION) |
| 50 | |
| 51 | #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name) \ |
| 52 | _name " is not an unsigned integer field class: %![fc-]+F" |
| 53 | |
| 54 | |
| 55 | #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc) \ |
| 56 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \ |
| 57 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) |
| 58 | |
| 59 | #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name) \ |
| 60 | _name " is not a signed integer field class: %![fc-]+F" |
| 61 | |
| 62 | #define _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc) \ |
| 63 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \ |
| 64 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) |
| 65 | |
| 66 | #define _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name) \ |
| 67 | _name " is not an enumeration field class: %![fc-]+F" |
| 68 | |
| 69 | #define _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc) \ |
| 70 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \ |
| 71 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \ |
| 72 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) |
| 73 | |
| 74 | #define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name) \ |
| 75 | _name " is not an array field class: %![fc-]+F" |
| 76 | |
| 77 | #define _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc) \ |
| 78 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \ |
| 79 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \ |
| 80 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ |
| 81 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD) |
| 82 | |
| 83 | #define _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name) \ |
| 84 | _name " is not an option field class: %![fc-]+F" |
| 85 | |
| 86 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc) \ |
| 87 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \ |
| 88 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ |
| 89 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD) |
| 90 | |
| 91 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name) \ |
| 92 | _name " is not an option field class with a selector: %![fc-]+F" |
| 93 | |
| 94 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc) \ |
| 95 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ |
| 96 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD) |
| 97 | |
| 98 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name) \ |
| 99 | _name " is not an option field class with an integer selector: %![fc-]+F" |
| 100 | |
| 101 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc) \ |
| 102 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \ |
| 103 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ |
| 104 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD) |
| 105 | |
| 106 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name) \ |
| 107 | _name " is not a variant field class: %![fc-]+F" |
| 108 | |
| 109 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc) \ |
| 110 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ |
| 111 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD) |
| 112 | |
| 113 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name) \ |
| 114 | _name " is not a variant field class with a selector: %![fc-]+F" |
| 115 | |
| 116 | #define _BT_ASSERT_PRE_FC_HAS_ID_COND(_fc, _type) \ |
| 117 | (((const struct bt_field_class *) (_fc))->type == (_type)) |
| 118 | |
| 119 | #define _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name) \ |
| 120 | _name " has the wrong type: expected-type=%s, %![fc-]+F" |
| 121 | |
| 122 | #define BT_ASSERT_PRE_FC_IS_INT(_fc, _name) \ |
| 123 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \ |
| 124 | _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc)) |
| 125 | |
| 126 | #define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc, _name) \ |
| 127 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \ |
| 128 | _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc)) |
| 129 | |
| 130 | #define BT_ASSERT_PRE_FC_IS_SIGNED_INT(_fc, _name) \ |
| 131 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc), \ |
| 132 | _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc)) |
| 133 | |
| 134 | #define BT_ASSERT_PRE_FC_IS_ENUM(_fc, _name) \ |
| 135 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \ |
| 136 | _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc)) |
| 137 | |
| 138 | #define BT_ASSERT_PRE_FC_IS_ARRAY(_fc, _name) \ |
| 139 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \ |
| 140 | _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc)) |
| 141 | |
| 142 | #define BT_ASSERT_PRE_FC_IS_OPTION(_fc, _name) \ |
| 143 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc), \ |
| 144 | _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc)) |
| 145 | |
| 146 | #define BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL(_fc, _name) \ |
| 147 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \ |
| 148 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc)) |
| 149 | |
| 150 | #define BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(_fc, _name) \ |
| 151 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \ |
| 152 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc)) |
| 153 | |
| 154 | #define BT_ASSERT_PRE_FC_IS_VARIANT(_fc, _name) \ |
| 155 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc), \ |
| 156 | _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc)) |
| 157 | |
| 158 | #define BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL(_fc, _name) \ |
| 159 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \ |
| 160 | _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc)) |
| 161 | |
| 162 | #define BT_ASSERT_PRE_FC_HAS_ID(_fc, _type, _name) \ |
| 163 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_HAS_ID_COND((_fc), (_type)), \ |
| 164 | _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name), \ |
| 165 | bt_common_field_class_type_string(_type), (_fc)) |
| 166 | |
| 167 | #define BT_ASSERT_PRE_DEV_FC_IS_INT(_fc, _name) \ |
| 168 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \ |
| 169 | _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc)) |
| 170 | |
| 171 | #define BT_ASSERT_PRE_DEV_FC_IS_UNSIGNED_INT(_fc, _name) \ |
| 172 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \ |
| 173 | _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc)) |
| 174 | |
| 175 | #define BT_ASSERT_PRE_DEV_FC_IS_SIGNED_INT(_fc, _name) \ |
| 176 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc), \ |
| 177 | _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc)) |
| 178 | |
| 179 | #define BT_ASSERT_PRE_DEV_FC_IS_ENUM(_fc, _name) \ |
| 180 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \ |
| 181 | _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc)) |
| 182 | |
| 183 | #define BT_ASSERT_PRE_DEV_FC_IS_ARRAY(_fc, _name) \ |
| 184 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \ |
| 185 | _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc)) |
| 186 | |
| 187 | #define BT_ASSERT_PRE_DEV_FC_IS_OPTION(_fc, _name) \ |
| 188 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc), \ |
| 189 | _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc)) |
| 190 | |
| 191 | #define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_SEL(_fc, _name) \ |
| 192 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \ |
| 193 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc)) |
| 194 | |
| 195 | #define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_INT_SEL(_fc, _name) \ |
| 196 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \ |
| 197 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc)) |
| 198 | |
| 199 | #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT(_fc, _name) \ |
| 200 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc), \ |
| 201 | _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc)) |
| 202 | |
| 203 | #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL(_fc, _name) \ |
| 204 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \ |
| 205 | _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc)) |
| 206 | |
| 207 | #define BT_ASSERT_PRE_DEV_FC_HAS_ID(_fc, _type, _name) \ |
| 208 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_HAS_ID_COND((_fc), (_type)), \ |
| 209 | _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name), \ |
| 210 | bt_common_field_class_type_string(_type), (_fc)) |
| 211 | |
| 212 | #define BT_ASSERT_PRE_DEV_FC_HOT(_fc, _name) \ |
| 213 | BT_ASSERT_PRE_DEV_HOT((const struct bt_field_class *) (_fc), \ |
| 214 | (_name), ": %!+F", (_fc)) |
| 215 | |
| 216 | #define BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(_fc, _index) \ |
| 217 | (&g_array_index(((struct bt_field_class_enumeration *) (_fc))->mappings, \ |
| 218 | struct bt_field_class_enumeration_mapping, (_index))) |
| 219 | |
| 220 | #define BT_FIELD_CLASS_ENUM_MAPPING_RANGE_AT_INDEX(_mapping, _index) \ |
| 221 | (&g_array_index((_mapping)->ranges, \ |
| 222 | struct bt_field_class_enumeration_mapping_range, (_index))) |
| 223 | |
| 224 | struct bt_field; |
| 225 | struct bt_field_class; |
| 226 | |
| 227 | struct bt_field_class { |
| 228 | struct bt_object base; |
| 229 | enum bt_field_class_type type; |
| 230 | bool frozen; |
| 231 | |
| 232 | /* Owned by this */ |
| 233 | struct bt_value *user_attributes; |
| 234 | |
| 235 | /* |
| 236 | * This flag indicates whether or not this field class is part |
| 237 | * of a trace class. |
| 238 | */ |
| 239 | bool part_of_trace_class; |
| 240 | }; |
| 241 | |
| 242 | struct bt_field_class_bool { |
| 243 | struct bt_field_class common; |
| 244 | }; |
| 245 | |
| 246 | struct bt_field_class_bit_array { |
| 247 | struct bt_field_class common; |
| 248 | uint64_t length; |
| 249 | }; |
| 250 | |
| 251 | struct bt_field_class_integer { |
| 252 | struct bt_field_class common; |
| 253 | |
| 254 | /* |
| 255 | * Value range of fields built from this integer field class: |
| 256 | * this is an equivalent integer size in bits. More formally, |
| 257 | * `range` is `n` in: |
| 258 | * |
| 259 | * Unsigned range: [0, 2^n - 1] |
| 260 | * Signed range: [-2^(n - 1), 2^(n - 1) - 1] |
| 261 | */ |
| 262 | uint64_t range; |
| 263 | |
| 264 | enum bt_field_class_integer_preferred_display_base base; |
| 265 | }; |
| 266 | |
| 267 | struct bt_field_class_enumeration_mapping { |
| 268 | GString *label; |
| 269 | |
| 270 | /* Owner by this */ |
| 271 | const struct bt_integer_range_set *range_set; |
| 272 | }; |
| 273 | |
| 274 | struct bt_field_class_enumeration_unsigned_mapping; |
| 275 | struct bt_field_class_enumeration_signed_mapping; |
| 276 | |
| 277 | struct bt_field_class_enumeration { |
| 278 | struct bt_field_class_integer common; |
| 279 | |
| 280 | /* Array of `struct bt_field_class_enumeration_mapping *` */ |
| 281 | GArray *mappings; |
| 282 | |
| 283 | /* |
| 284 | * This is an array of `const char *` which acts as a temporary |
| 285 | * (potentially growing) buffer for |
| 286 | * bt_field_class_enumeration_unsigned_get_mapping_labels_for_value() |
| 287 | * and |
| 288 | * bt_field_class_enumeration_signed_get_mapping_labels_for_value(). |
| 289 | * |
| 290 | * The actual strings are owned by the mappings above. |
| 291 | */ |
| 292 | GPtrArray *label_buf; |
| 293 | }; |
| 294 | |
| 295 | struct bt_field_class_real { |
| 296 | struct bt_field_class common; |
| 297 | }; |
| 298 | |
| 299 | struct bt_field_class_string { |
| 300 | struct bt_field_class common; |
| 301 | }; |
| 302 | |
| 303 | /* A named field class is a (name, field class) pair */ |
| 304 | struct bt_named_field_class { |
| 305 | GString *name; |
| 306 | |
| 307 | /* Owned by this */ |
| 308 | struct bt_value *user_attributes; |
| 309 | |
| 310 | /* Owned by this */ |
| 311 | struct bt_field_class *fc; |
| 312 | |
| 313 | bool frozen; |
| 314 | }; |
| 315 | |
| 316 | struct bt_field_class_structure_member; |
| 317 | struct bt_field_class_variant_option; |
| 318 | struct bt_field_class_variant_with_selector_field_integer_unsigned_option; |
| 319 | struct bt_field_class_variant_with_selector_field_integer_signed_option; |
| 320 | |
| 321 | struct bt_field_class_named_field_class_container { |
| 322 | struct bt_field_class common; |
| 323 | |
| 324 | /* |
| 325 | * Key: `const char *`, not owned by this (owned by named field |
| 326 | * class objects contained in `named_fcs` below). |
| 327 | */ |
| 328 | GHashTable *name_to_index; |
| 329 | |
| 330 | /* Array of `struct bt_named_field_class *` */ |
| 331 | GPtrArray *named_fcs; |
| 332 | }; |
| 333 | |
| 334 | struct bt_field_class_structure { |
| 335 | struct bt_field_class_named_field_class_container common; |
| 336 | }; |
| 337 | |
| 338 | struct bt_field_class_array { |
| 339 | struct bt_field_class common; |
| 340 | |
| 341 | /* Owned by this */ |
| 342 | struct bt_field_class *element_fc; |
| 343 | }; |
| 344 | |
| 345 | struct bt_field_class_array_static { |
| 346 | struct bt_field_class_array common; |
| 347 | uint64_t length; |
| 348 | }; |
| 349 | |
| 350 | struct bt_field_class_array_dynamic { |
| 351 | struct bt_field_class_array common; |
| 352 | |
| 353 | /* Owned by this */ |
| 354 | struct bt_field_class *length_fc; |
| 355 | |
| 356 | /* Owned by this */ |
| 357 | struct bt_field_path *length_field_path; |
| 358 | }; |
| 359 | |
| 360 | struct bt_field_class_option { |
| 361 | struct bt_field_class common; |
| 362 | |
| 363 | /* Owned by this */ |
| 364 | struct bt_field_class *content_fc; |
| 365 | }; |
| 366 | |
| 367 | struct bt_field_class_option_with_selector_field { |
| 368 | struct bt_field_class_option common; |
| 369 | |
| 370 | /* Owned by this */ |
| 371 | struct bt_field_class *selector_fc; |
| 372 | |
| 373 | /* Owned by this */ |
| 374 | struct bt_field_path *selector_field_path; |
| 375 | }; |
| 376 | |
| 377 | struct bt_field_class_option_with_selector_field_bool { |
| 378 | struct bt_field_class_option_with_selector_field common; |
| 379 | |
| 380 | /* Owned by this */ |
| 381 | bool sel_is_reversed; |
| 382 | }; |
| 383 | |
| 384 | struct bt_field_class_option_with_selector_field_integer { |
| 385 | struct bt_field_class_option_with_selector_field common; |
| 386 | |
| 387 | /* Owned by this */ |
| 388 | const struct bt_integer_range_set *range_set; |
| 389 | }; |
| 390 | |
| 391 | /* Variant FC (with selector) option: named field class + range set */ |
| 392 | struct bt_field_class_variant_with_selector_field_option { |
| 393 | struct bt_named_field_class common; |
| 394 | |
| 395 | /* Owned by this */ |
| 396 | const struct bt_integer_range_set *range_set; |
| 397 | }; |
| 398 | |
| 399 | struct bt_field_class_variant { |
| 400 | /* |
| 401 | * Depending on the variant field class type, the contained |
| 402 | * named field classes are of type |
| 403 | * `struct bt_named_field_class *` if the variant field class |
| 404 | * doesn't have a selector, or |
| 405 | * `struct bt_field_class_variant_with_selector_field_option *` |
| 406 | * if it has. |
| 407 | */ |
| 408 | struct bt_field_class_named_field_class_container common; |
| 409 | }; |
| 410 | |
| 411 | struct bt_field_class_variant_with_selector_field { |
| 412 | struct bt_field_class_variant common; |
| 413 | |
| 414 | /* |
| 415 | * Owned by this, but never dereferenced: only use to find it |
| 416 | * elsewhere. |
| 417 | */ |
| 418 | const struct bt_field_class *selector_fc; |
| 419 | |
| 420 | /* Owned by this */ |
| 421 | struct bt_field_path *selector_field_path; |
| 422 | }; |
| 423 | |
| 424 | BT_HIDDEN |
| 425 | void _bt_field_class_freeze(const struct bt_field_class *field_class); |
| 426 | |
| 427 | #ifdef BT_DEV_MODE |
| 428 | # define bt_field_class_freeze _bt_field_class_freeze |
| 429 | #else |
| 430 | # define bt_field_class_freeze(_fc) ((void) _fc) |
| 431 | #endif |
| 432 | |
| 433 | BT_HIDDEN |
| 434 | void _bt_named_field_class_freeze(const struct bt_named_field_class *named_fc); |
| 435 | |
| 436 | #ifdef BT_DEV_MODE |
| 437 | # define bt_named_field_class_freeze _bt_named_field_class_freeze |
| 438 | #else |
| 439 | # define bt_named_field_class_freeze(_named_fc) ((void) _named_fc) |
| 440 | #endif |
| 441 | |
| 442 | /* |
| 443 | * This function recursively marks `field_class` and its children as |
| 444 | * being part of a trace. This is used to validate that all field classes |
| 445 | * are used at a single location within trace objects even if they are |
| 446 | * shared objects for other purposes. |
| 447 | */ |
| 448 | BT_HIDDEN |
| 449 | void bt_field_class_make_part_of_trace_class( |
| 450 | const struct bt_field_class *field_class); |
| 451 | |
| 452 | #endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H */ |