X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Ftrace-ir%2Ffield-path.c;h=92bca3f15c6403be130fc20b41bcefcbc4075ea4;hb=HEAD;hp=32d805524fa3ee46e73a62a64890e9fe6eea4b7a;hpb=350ad6c1c5f45a4e90c33e3c1354125c209bbf02;p=babeltrace.git diff --git a/src/lib/trace-ir/field-path.c b/src/lib/trace-ir/field-path.c index 32d80552..92bca3f1 100644 --- a/src/lib/trace-ir/field-path.c +++ b/src/lib/trace-ir/field-path.c @@ -1,39 +1,20 @@ /* + * SPDX-License-Identifier: MIT + * * Copyright 2016-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. */ #define BT_LOG_TAG "LIB/FIELD-PATH" -#include "lib/lib-logging.h" +#include "lib/logging.h" -#include "lib/assert-pre.h" +#include "lib/assert-cond.h" #include -#include -#include +#include #include -#include #include "common/assert.h" #include -#include "field-class.h" #include "field-path.h" static @@ -48,7 +29,6 @@ void destroy_field_path(struct bt_object *obj) g_free(field_path); } -BT_HIDDEN struct bt_field_path *bt_field_path_create(void) { struct bt_field_path *field_path = NULL; @@ -57,7 +37,7 @@ struct bt_field_path *bt_field_path_create(void) field_path = g_new0(struct bt_field_path, 1); if (!field_path) { - BT_LOGE_STR("Failed to allocate one field path."); + BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one field path."); goto error; } @@ -65,7 +45,7 @@ struct bt_field_path *bt_field_path_create(void) field_path->items = g_array_new(FALSE, FALSE, sizeof(struct bt_field_path_item)); if (!field_path->items) { - BT_LOGE_STR("Failed to allocate a GArray."); + BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GArray."); goto error; } @@ -79,50 +59,60 @@ end: return field_path; } -enum bt_scope bt_field_path_get_root_scope( +BT_EXPORT +enum bt_field_path_scope bt_field_path_get_root_scope( const struct bt_field_path *field_path) { - BT_ASSERT_PRE_NON_NULL(field_path, "Field path"); + BT_ASSERT_PRE_DEV_FP_NON_NULL(field_path); return field_path->root; } +BT_EXPORT uint64_t bt_field_path_get_item_count(const struct bt_field_path *field_path) { - BT_ASSERT_PRE_NON_NULL(field_path, "Field path"); + BT_ASSERT_PRE_DEV_FP_NON_NULL(field_path); return (uint64_t) field_path->items->len; } +BT_EXPORT const struct bt_field_path_item *bt_field_path_borrow_item_by_index_const( const struct bt_field_path *field_path, uint64_t index) { - BT_ASSERT_PRE_NON_NULL(field_path, "Field path"); - BT_ASSERT_PRE_VALID_INDEX(index, field_path->items->len); + BT_ASSERT_PRE_DEV_FP_NON_NULL(field_path); + BT_ASSERT_PRE_DEV_VALID_INDEX(index, field_path->items->len); return bt_field_path_borrow_item_by_index_inline(field_path, index); } +BT_EXPORT enum bt_field_path_item_type bt_field_path_item_get_type( const struct bt_field_path_item *field_path_item) { - BT_ASSERT_PRE_NON_NULL(field_path_item, "Field path item"); + BT_ASSERT_PRE_DEV_NON_NULL("field-path-item", field_path_item, + "Field path item"); return field_path_item->type; } +BT_EXPORT uint64_t bt_field_path_item_index_get_index( const struct bt_field_path_item *field_path_item) { - BT_ASSERT_PRE_NON_NULL(field_path_item, "Field path item"); - BT_ASSERT_PRE(field_path_item->type == BT_FIELD_PATH_ITEM_TYPE_INDEX, + BT_ASSERT_PRE_DEV_NON_NULL("field-path-item", field_path_item, + "Field path item"); + BT_ASSERT_PRE_DEV("is-index-field-path-item", + field_path_item->type == BT_FIELD_PATH_ITEM_TYPE_INDEX, "Field path item is not an index field path item: " "addr=%p, type=%s", field_path_item, bt_field_path_item_type_string(field_path_item->type)); return field_path_item->index; } +BT_EXPORT void bt_field_path_get_ref(const struct bt_field_path *field_path) { bt_object_get_ref(field_path); } +BT_EXPORT void bt_field_path_put_ref(const struct bt_field_path *field_path) { bt_object_put_ref(field_path);