Remove unnecessary inclusions of "internal public" headers
[babeltrace.git] / src / ctf-writer / values.c
index 89a808d4e0e98c29eab045f0bca374f19547cb39..e1a9854203ceb40136c8851a39f70df102b94415 100644 (file)
@@ -1,24 +1,8 @@
 /*
+ * SPDX-License-Identifier: MIT
+ *
  * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
  * Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
- *
- * 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 "CTF-WRITER/VALUES"
@@ -28,8 +12,7 @@
 #include <string.h>
 #include <inttypes.h>
 
-#include <babeltrace2/ctf-writer/object.h>
-#include <babeltrace2/types.h>
+#include <babeltrace2-ctf-writer/object.h>
 
 #include "common/assert.h"
 #include "common/common.h"
@@ -86,7 +69,10 @@ struct bt_ctf_value bt_ctf_value_null_instance = {
        .frozen = BT_CTF_TRUE,
 };
 
+BT_EXPORT
 struct bt_ctf_value *const bt_ctf_value_null = &bt_ctf_value_null_instance;
+
+BT_EXPORT
 struct bt_ctf_private_value *const bt_ctf_private_value_null =
        (void *) &bt_ctf_value_null_instance;
 
@@ -165,7 +151,8 @@ void (* const destroy_funcs[])(struct bt_ctf_value *) = {
 };
 
 static
-struct bt_ctf_private_value *bt_ctf_value_null_copy(const struct bt_ctf_value *null_obj)
+struct bt_ctf_private_value *bt_ctf_value_null_copy(
+               const struct bt_ctf_value *null_obj __attribute__((unused)))
 {
        return (void *) bt_ctf_value_null;
 }
@@ -221,7 +208,7 @@ struct bt_ctf_private_value *bt_ctf_value_array_copy(const struct bt_ctf_value *
                        bt_ctf_value_array_borrow_element_by_index(
                                array_obj, i);
 
-               BT_ASSERT(element_obj);
+               BT_ASSERT_DBG(element_obj);
                BT_LOGD("Copying array value's element: element-addr=%p, "
                        "index=%d", element_obj, i);
                ret = bt_ctf_value_copy(&element_obj_copy, element_obj);
@@ -233,7 +220,7 @@ struct bt_ctf_private_value *bt_ctf_value_array_copy(const struct bt_ctf_value *
                        goto end;
                }
 
-               BT_ASSERT(element_obj_copy);
+               BT_ASSERT_DBG(element_obj_copy);
                ret = bt_ctf_private_value_array_append_element(copy_obj,
                        (void *) element_obj_copy);
                BT_CTF_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
@@ -274,7 +261,7 @@ struct bt_ctf_private_value *bt_ctf_value_map_copy(const struct bt_ctf_value *ma
        while (g_hash_table_iter_next(&iter, &key, &element_obj)) {
                const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key));
 
-               BT_ASSERT(key_str);
+               BT_ASSERT_DBG(key_str);
                BT_LOGD("Copying map value's element: element-addr=%p, "
                        "key=\"%s\"", element_obj, key_str);
                ret = bt_ctf_value_copy(&element_obj_copy, element_obj);
@@ -286,7 +273,7 @@ struct bt_ctf_private_value *bt_ctf_value_map_copy(const struct bt_ctf_value *ma
                        goto end;
                }
 
-               BT_ASSERT(element_obj_copy);
+               BT_ASSERT_DBG(element_obj_copy);
                ret = bt_ctf_private_value_map_insert_entry(copy_obj, key_str,
                        (void *) element_obj_copy);
                BT_CTF_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
@@ -316,8 +303,9 @@ struct bt_ctf_private_value *(* const copy_funcs[])(const struct bt_ctf_value *)
 };
 
 static
-bt_ctf_bool bt_ctf_value_null_compare(const struct bt_ctf_value *object_a,
-               const struct bt_ctf_value *object_b)
+bt_ctf_bool bt_ctf_value_null_compare(
+               const struct bt_ctf_value *object_a __attribute__((unused)),
+               const struct bt_ctf_value *object_b __attribute__((unused)))
 {
        /*
         * Always BT_CTF_TRUE since bt_ctf_value_compare() already checks if both
@@ -400,14 +388,14 @@ bt_ctf_bool bt_ctf_value_array_compare(const struct bt_ctf_value *object_a,
        const struct bt_ctf_value_array *array_obj_a =
                BT_CTF_VALUE_TO_ARRAY(object_a);
 
-       if (bt_ctf_value_array_get_size(object_a) !=
-                       bt_ctf_value_array_get_size(object_b)) {
+       if (bt_ctf_value_array_get_length(object_a) !=
+                       bt_ctf_value_array_get_length(object_b)) {
                BT_LOGT("Array values are different: size mismatch "
                        "value-a-addr=%p, value-b-addr=%p, "
                        "value-a-size=%" PRId64 ", value-b-size=%" PRId64,
                        object_a, object_b,
-                       bt_ctf_value_array_get_size(object_a),
-                       bt_ctf_value_array_get_size(object_b));
+                       bt_ctf_value_array_get_length(object_a),
+                       bt_ctf_value_array_get_length(object_b));
                ret = BT_CTF_FALSE;
                goto end;
        }
@@ -490,7 +478,7 @@ bt_ctf_bool (* const compare_funcs[])(const struct bt_ctf_value *,
 };
 
 static
-void bt_ctf_value_null_freeze(struct bt_ctf_value *object)
+void bt_ctf_value_null_freeze(struct bt_ctf_value *object __attribute__((unused)))
 {
 }
 
@@ -561,12 +549,11 @@ void bt_ctf_value_destroy(struct bt_ctf_object *obj)
        g_free(value);
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status _bt_ctf_value_freeze(struct bt_ctf_value *object)
 {
        enum bt_ctf_value_status ret = BT_CTF_VALUE_STATUS_OK;
 
-       BT_ASSERT(object);
+       BT_ASSERT_DBG(object);
 
        if (object->frozen) {
                goto end;
@@ -579,7 +566,6 @@ end:
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_type bt_ctf_value_get_type(const struct bt_ctf_value *object)
 {
        BT_CTF_ASSERT_PRE_NON_NULL(object, "Value object");
@@ -597,7 +583,6 @@ struct bt_ctf_value bt_ctf_value_create_base(enum bt_ctf_value_type type)
        return value;
 }
 
-BT_HIDDEN
 struct bt_ctf_private_value *bt_ctf_private_value_bool_create_init(bt_ctf_bool val)
 {
        struct bt_ctf_value_bool *bool_obj;
@@ -617,13 +602,11 @@ end:
        return (void *) BT_CTF_VALUE_FROM_CONCRETE(bool_obj);
 }
 
-BT_HIDDEN
 struct bt_ctf_private_value *bt_ctf_private_value_bool_create(void)
 {
        return bt_ctf_private_value_bool_create_init(BT_CTF_FALSE);
 }
 
-BT_HIDDEN
 struct bt_ctf_private_value *bt_ctf_private_value_integer_create_init(int64_t val)
 {
        struct bt_ctf_value_integer *integer_obj;
@@ -644,13 +627,11 @@ end:
        return (void *) BT_CTF_VALUE_FROM_CONCRETE(integer_obj);
 }
 
-BT_HIDDEN
 struct bt_ctf_private_value *bt_ctf_private_value_integer_create(void)
 {
        return bt_ctf_private_value_integer_create_init(0);
 }
 
-BT_HIDDEN
 struct bt_ctf_private_value *bt_ctf_private_value_real_create_init(double val)
 {
        struct bt_ctf_value_real *real_obj;
@@ -671,13 +652,11 @@ end:
        return (void *) BT_CTF_VALUE_FROM_CONCRETE(real_obj);
 }
 
-BT_HIDDEN
 struct bt_ctf_private_value *bt_ctf_private_value_real_create(void)
 {
        return bt_ctf_private_value_real_create_init(0.);
 }
 
-BT_HIDDEN
 struct bt_ctf_private_value *bt_ctf_private_value_string_create_init(const char *val)
 {
        struct bt_ctf_value_string *string_obj = NULL;
@@ -710,13 +689,11 @@ end:
        return (void *) BT_CTF_VALUE_FROM_CONCRETE(string_obj);
 }
 
-BT_HIDDEN
 struct bt_ctf_private_value *bt_ctf_private_value_string_create(void)
 {
        return bt_ctf_private_value_string_create_init("");
 }
 
-BT_HIDDEN
 struct bt_ctf_private_value *bt_ctf_private_value_array_create(void)
 {
        struct bt_ctf_value_array *array_obj;
@@ -745,7 +722,6 @@ end:
        return (void *) BT_CTF_VALUE_FROM_CONCRETE(array_obj);
 }
 
-BT_HIDDEN
 struct bt_ctf_private_value *bt_ctf_private_value_map_create(void)
 {
        struct bt_ctf_value_map *map_obj;
@@ -774,7 +750,6 @@ end:
        return (void *) BT_CTF_VALUE_FROM_CONCRETE(map_obj);
 }
 
-BT_HIDDEN
 bt_ctf_bool bt_ctf_value_bool_get(const struct bt_ctf_value *bool_obj)
 {
        BT_CTF_ASSERT_PRE_NON_NULL(bool_obj, "Value object");
@@ -782,7 +757,6 @@ bt_ctf_bool bt_ctf_value_bool_get(const struct bt_ctf_value *bool_obj)
        return BT_CTF_VALUE_TO_BOOL(bool_obj)->value;
 }
 
-BT_HIDDEN
 void bt_ctf_private_value_bool_set(struct bt_ctf_private_value *bool_obj, bt_ctf_bool val)
 {
        BT_CTF_ASSERT_PRE_NON_NULL(bool_obj, "Value object");
@@ -793,7 +767,6 @@ void bt_ctf_private_value_bool_set(struct bt_ctf_private_value *bool_obj, bt_ctf
                bool_obj, val);
 }
 
-BT_HIDDEN
 int64_t bt_ctf_value_integer_get(const struct bt_ctf_value *integer_obj)
 {
        BT_CTF_ASSERT_PRE_NON_NULL(integer_obj, "Value object");
@@ -801,7 +774,6 @@ int64_t bt_ctf_value_integer_get(const struct bt_ctf_value *integer_obj)
        return BT_CTF_VALUE_TO_INTEGER(integer_obj)->value;
 }
 
-BT_HIDDEN
 void bt_ctf_private_value_integer_set(struct bt_ctf_private_value *integer_obj,
                int64_t val)
 {
@@ -813,7 +785,6 @@ void bt_ctf_private_value_integer_set(struct bt_ctf_private_value *integer_obj,
                integer_obj, val);
 }
 
-BT_HIDDEN
 double bt_ctf_value_real_get(const struct bt_ctf_value *real_obj)
 {
        BT_CTF_ASSERT_PRE_NON_NULL(real_obj, "Value object");
@@ -821,7 +792,6 @@ double bt_ctf_value_real_get(const struct bt_ctf_value *real_obj)
        return BT_CTF_VALUE_TO_REAL(real_obj)->value;
 }
 
-BT_HIDDEN
 void bt_ctf_private_value_real_set(struct bt_ctf_private_value *real_obj, double val)
 {
        BT_CTF_ASSERT_PRE_NON_NULL(real_obj, "Value object");
@@ -832,7 +802,6 @@ void bt_ctf_private_value_real_set(struct bt_ctf_private_value *real_obj, double
                real_obj, val);
 }
 
-BT_HIDDEN
 const char *bt_ctf_value_string_get(const struct bt_ctf_value *string_obj)
 {
        BT_CTF_ASSERT_PRE_NON_NULL(string_obj, "Value object");
@@ -840,7 +809,6 @@ const char *bt_ctf_value_string_get(const struct bt_ctf_value *string_obj)
        return BT_CTF_VALUE_TO_STRING(string_obj)->gstr->str;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_string_set(
                struct bt_ctf_private_value *string_obj, const char *val)
 {
@@ -853,15 +821,13 @@ enum bt_ctf_value_status bt_ctf_private_value_string_set(
        return BT_CTF_VALUE_STATUS_OK;
 }
 
-BT_HIDDEN
-uint64_t bt_ctf_value_array_get_size(const struct bt_ctf_value *array_obj)
+uint64_t bt_ctf_value_array_get_length(const struct bt_ctf_value *array_obj)
 {
        BT_CTF_ASSERT_PRE_NON_NULL(array_obj, "Value object");
        BT_CTF_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_CTF_VALUE_TYPE_ARRAY);
        return (uint64_t) BT_CTF_VALUE_TO_ARRAY(array_obj)->garray->len;
 }
 
-BT_HIDDEN
 struct bt_ctf_value *bt_ctf_value_array_borrow_element_by_index(
                const struct bt_ctf_value *array_obj,
                uint64_t index)
@@ -876,7 +842,6 @@ struct bt_ctf_value *bt_ctf_value_array_borrow_element_by_index(
        return g_ptr_array_index(typed_array_obj->garray, index);
 }
 
-BT_HIDDEN
 struct bt_ctf_private_value *bt_ctf_private_value_array_borrow_element_by_index(
                const struct bt_ctf_private_value *array_obj,
                uint64_t index)
@@ -885,7 +850,6 @@ struct bt_ctf_private_value *bt_ctf_private_value_array_borrow_element_by_index(
                (void *) array_obj, index);
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_array_append_element(
                struct bt_ctf_private_value *array_obj,
                struct bt_ctf_value *element_obj)
@@ -905,7 +869,6 @@ enum bt_ctf_value_status bt_ctf_private_value_array_append_element(
        return BT_CTF_VALUE_STATUS_OK;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_array_append_bool_element(
                struct bt_ctf_private_value *array_obj, bt_ctf_bool val)
 {
@@ -919,7 +882,6 @@ enum bt_ctf_value_status bt_ctf_private_value_array_append_bool_element(
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_array_append_integer_element(
                struct bt_ctf_private_value *array_obj, int64_t val)
 {
@@ -933,7 +895,6 @@ enum bt_ctf_value_status bt_ctf_private_value_array_append_integer_element(
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_array_append_real_element(
                struct bt_ctf_private_value *array_obj, double val)
 {
@@ -947,7 +908,6 @@ enum bt_ctf_value_status bt_ctf_private_value_array_append_real_element(
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_array_append_string_element(
                struct bt_ctf_private_value *array_obj, const char *val)
 {
@@ -961,7 +921,6 @@ enum bt_ctf_value_status bt_ctf_private_value_array_append_string_element(
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_array_append_empty_array_element(
                struct bt_ctf_private_value *array_obj)
 {
@@ -975,7 +934,6 @@ enum bt_ctf_value_status bt_ctf_private_value_array_append_empty_array_element(
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_array_append_empty_map_element(
                struct bt_ctf_private_value *array_obj)
 {
@@ -989,7 +947,6 @@ enum bt_ctf_value_status bt_ctf_private_value_array_append_empty_map_element(
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_array_set_element_by_index(
                struct bt_ctf_private_value *array_obj, uint64_t index,
                struct bt_ctf_value *element_obj)
@@ -1012,7 +969,6 @@ enum bt_ctf_value_status bt_ctf_private_value_array_set_element_by_index(
        return BT_CTF_VALUE_STATUS_OK;
 }
 
-BT_HIDDEN
 uint64_t bt_ctf_value_map_get_size(const struct bt_ctf_value *map_obj)
 {
        BT_CTF_ASSERT_PRE_NON_NULL(map_obj, "Value object");
@@ -1020,7 +976,6 @@ uint64_t bt_ctf_value_map_get_size(const struct bt_ctf_value *map_obj)
        return (uint64_t) g_hash_table_size(BT_CTF_VALUE_TO_MAP(map_obj)->ght);
 }
 
-BT_HIDDEN
 struct bt_ctf_value *bt_ctf_value_map_borrow_entry_value(const struct bt_ctf_value *map_obj,
                const char *key)
 {
@@ -1031,14 +986,12 @@ struct bt_ctf_value *bt_ctf_value_map_borrow_entry_value(const struct bt_ctf_val
                GUINT_TO_POINTER(g_quark_from_string(key)));
 }
 
-BT_HIDDEN
 struct bt_ctf_private_value *bt_ctf_private_value_map_borrow_entry_value(
                const struct bt_ctf_private_value *map_obj, const char *key)
 {
        return (void *) bt_ctf_value_map_borrow_entry_value((void *) map_obj, key);
 }
 
-BT_HIDDEN
 bt_ctf_bool bt_ctf_value_map_has_entry(const struct bt_ctf_value *map_obj, const char *key)
 {
        BT_CTF_ASSERT_PRE_NON_NULL(map_obj, "Value object");
@@ -1048,7 +1001,6 @@ bt_ctf_bool bt_ctf_value_map_has_entry(const struct bt_ctf_value *map_obj, const
                GUINT_TO_POINTER(g_quark_from_string(key)));
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_map_insert_entry(
                struct bt_ctf_private_value *map_obj,
                const char *key, struct bt_ctf_value *element_obj)
@@ -1067,7 +1019,6 @@ enum bt_ctf_value_status bt_ctf_private_value_map_insert_entry(
        return BT_CTF_VALUE_STATUS_OK;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_map_insert_bool_entry(
                struct bt_ctf_private_value *map_obj, const char *key, bt_ctf_bool val)
 {
@@ -1081,7 +1032,6 @@ enum bt_ctf_value_status bt_ctf_private_value_map_insert_bool_entry(
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_map_insert_integer_entry(
                struct bt_ctf_private_value *map_obj, const char *key, int64_t val)
 {
@@ -1095,7 +1045,6 @@ enum bt_ctf_value_status bt_ctf_private_value_map_insert_integer_entry(
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_map_insert_real_entry(
                struct bt_ctf_private_value *map_obj, const char *key, double val)
 {
@@ -1109,7 +1058,6 @@ enum bt_ctf_value_status bt_ctf_private_value_map_insert_real_entry(
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_map_insert_string_entry(
                struct bt_ctf_private_value *map_obj, const char *key,
                const char *val)
@@ -1124,7 +1072,6 @@ enum bt_ctf_value_status bt_ctf_private_value_map_insert_string_entry(
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_map_insert_empty_array_entry(
                struct bt_ctf_private_value *map_obj, const char *key)
 {
@@ -1138,7 +1085,6 @@ enum bt_ctf_value_status bt_ctf_private_value_map_insert_empty_array_entry(
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_map_insert_empty_map_entry(
                struct bt_ctf_private_value *map_obj, const char *key)
 {
@@ -1152,7 +1098,6 @@ enum bt_ctf_value_status bt_ctf_private_value_map_insert_empty_map_entry(
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_value_map_foreach_entry(const struct bt_ctf_value *map_obj,
                bt_ctf_value_map_foreach_entry_cb cb, void *data)
 {
@@ -1181,7 +1126,6 @@ enum bt_ctf_value_status bt_ctf_value_map_foreach_entry(const struct bt_ctf_valu
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_private_value_map_foreach_entry(
                const struct bt_ctf_private_value *map_obj,
                bt_ctf_private_value_map_foreach_entry_cb cb, void *data)
@@ -1212,7 +1156,7 @@ bt_ctf_bool extend_map_element(const char *key,
                goto error;
        }
 
-       BT_ASSERT(extension_obj_elem_copy);
+       BT_ASSERT_DBG(extension_obj_elem_copy);
 
        /* Replace in extended object */
        extend_data->status = bt_ctf_private_value_map_insert_entry(
@@ -1229,7 +1173,7 @@ bt_ctf_bool extend_map_element(const char *key,
        goto end;
 
 error:
-       BT_ASSERT(extend_data->status != BT_CTF_VALUE_STATUS_OK);
+       BT_ASSERT_DBG(extend_data->status != BT_CTF_VALUE_STATUS_OK);
        ret = BT_CTF_FALSE;
 
 end:
@@ -1237,7 +1181,6 @@ end:
        return ret;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_value_map_extend(
                struct bt_ctf_private_value **extended_map_obj,
                const struct bt_ctf_value *base_map_obj,
@@ -1266,7 +1209,7 @@ enum bt_ctf_value_status bt_ctf_value_map_extend(
                goto error;
        }
 
-       BT_ASSERT(extended_map_obj);
+       BT_ASSERT_DBG(extended_map_obj);
 
        /*
         * For each key in the extension map object, replace this key
@@ -1299,7 +1242,6 @@ end:
        return extend_data.status;
 }
 
-BT_HIDDEN
 enum bt_ctf_value_status bt_ctf_value_copy(struct bt_ctf_private_value **copy_obj,
                const struct bt_ctf_value *object)
 {
@@ -1321,7 +1263,6 @@ enum bt_ctf_value_status bt_ctf_value_copy(struct bt_ctf_private_value **copy_ob
        return status;
 }
 
-BT_HIDDEN
 bt_ctf_bool bt_ctf_value_compare(const struct bt_ctf_value *object_a,
        const struct bt_ctf_value *object_b)
 {
This page took 0.029239 seconds and 4 git commands to generate.