X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Ftrace-ir%2Ffield-class.h;h=77df580407cadd69af852ab7269ff15a7e0808e4;hb=1353b066072e6c389ff35853bac83f65597e7a6a;hp=02d6f20eaabdeabb924a8abc12ce47ac54baee23;hpb=de821fe507f035622c474f097b226f30cd3c7491;p=babeltrace.git diff --git a/src/lib/trace-ir/field-class.h b/src/lib/trace-ir/field-class.h index 02d6f20e..77df5804 100644 --- a/src/lib/trace-ir/field-class.h +++ b/src/lib/trace-ir/field-class.h @@ -1,217 +1,24 @@ -#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H -#define BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H - /* + * SPDX-License-Identifier: MIT + * * Copyright 2017-2018 Philippe Proulx * Copyright 2013, 2014 Jérémie Galarneau - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ -#include "lib/assert-pre.h" +#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H +#define BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H + +#include "lib/assert-cond.h" #include #include #include "common/macros.h" #include "common/common.h" #include "lib/object.h" #include +#include #include #include -#define _BT_ASSERT_PRE_FC_IS_INT_COND(_fc) \ - (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) - -#define _BT_ASSERT_PRE_FC_IS_INT_FMT(_name) \ - _name " is not an integer field class: %![fc-]+F" - -#define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc) \ - (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION) - -#define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name) \ - _name " is not an unsigned integer field class: %![fc-]+F" - - -#define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc) \ - (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) - -#define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name) \ - _name " is not a signed integer field class: %![fc-]+F" - -#define _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc) \ - (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) - -#define _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name) \ - _name " is not an enumeration field class: %![fc-]+F" - -#define _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc) \ - (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) - -#define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name) \ - _name " is not an array field class: %![fc-]+F" - -#define _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc) \ - (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD) - -#define _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name) \ - _name " is not an option field class: %![fc-]+F" - -#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc) \ - (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD) - -#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name) \ - _name " is not an option field class with a selector: %![fc-]+F" - -#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc) \ - (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD) - -#define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name) \ - _name " is not an option field class with an integer selector: %![fc-]+F" - -#define _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc) \ - (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD) - -#define _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name) \ - _name " is not a variant field class: %![fc-]+F" - -#define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc) \ - (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ - ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD) - -#define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name) \ - _name " is not a variant field class with a selector: %![fc-]+F" - -#define _BT_ASSERT_PRE_FC_HAS_ID_COND(_fc, _type) \ - (((const struct bt_field_class *) (_fc))->type == (_type)) - -#define _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name) \ - _name " has the wrong type: expected-type=%s, %![fc-]+F" - -#define BT_ASSERT_PRE_FC_IS_INT(_fc, _name) \ - BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc, _name) \ - BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_FC_IS_SIGNED_INT(_fc, _name) \ - BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_FC_IS_ENUM(_fc, _name) \ - BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_FC_IS_ARRAY(_fc, _name) \ - BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_FC_IS_OPTION(_fc, _name) \ - BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL(_fc, _name) \ - BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(_fc, _name) \ - BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_FC_IS_VARIANT(_fc, _name) \ - BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL(_fc, _name) \ - BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_FC_HAS_ID(_fc, _type, _name) \ - BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_HAS_ID_COND((_fc), (_type)), \ - _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name), \ - bt_common_field_class_type_string(_type), (_fc)) - -#define BT_ASSERT_PRE_DEV_FC_IS_INT(_fc, _name) \ - BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_DEV_FC_IS_UNSIGNED_INT(_fc, _name) \ - BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_DEV_FC_IS_SIGNED_INT(_fc, _name) \ - BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_DEV_FC_IS_ENUM(_fc, _name) \ - BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_DEV_FC_IS_ARRAY(_fc, _name) \ - BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_DEV_FC_IS_OPTION(_fc, _name) \ - BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_SEL(_fc, _name) \ - BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_INT_SEL(_fc, _name) \ - BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_DEV_FC_IS_VARIANT(_fc, _name) \ - BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL(_fc, _name) \ - BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \ - _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc)) - -#define BT_ASSERT_PRE_DEV_FC_HAS_ID(_fc, _type, _name) \ - BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_HAS_ID_COND((_fc), (_type)), \ - _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name), \ - bt_common_field_class_type_string(_type), (_fc)) - -#define BT_ASSERT_PRE_DEV_FC_HOT(_fc, _name) \ - BT_ASSERT_PRE_DEV_HOT((const struct bt_field_class *) (_fc), \ - (_name), ": %!+F", (_fc)) - #define BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(_fc, _index) \ (&g_array_index(((struct bt_field_class_enumeration *) (_fc))->mappings, \ struct bt_field_class_enumeration_mapping, (_index))) @@ -420,7 +227,6 @@ struct bt_field_class_variant_with_selector_field { struct bt_field_path *selector_field_path; }; -BT_HIDDEN void _bt_field_class_freeze(const struct bt_field_class *field_class); #ifdef BT_DEV_MODE @@ -429,7 +235,6 @@ void _bt_field_class_freeze(const struct bt_field_class *field_class); # define bt_field_class_freeze(_fc) ((void) _fc) #endif -BT_HIDDEN void _bt_named_field_class_freeze(const struct bt_named_field_class *named_fc); #ifdef BT_DEV_MODE @@ -444,7 +249,6 @@ void _bt_named_field_class_freeze(const struct bt_named_field_class *named_fc); * are used at a single location within trace objects even if they are * shared objects for other purposes. */ -BT_HIDDEN void bt_field_class_make_part_of_trace_class( const struct bt_field_class *field_class);