Visibility hidden by default
[babeltrace.git] / src / ctf-writer / fields.h
index 9cba266d921a80c317768726b31aba3cd44182db..3893f911eb0cbe5b6a0209ecf501d50c04236057 100644 (file)
@@ -1,33 +1,15 @@
-#ifndef BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H
-
 /*
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@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:
+ * SPDX-License-Identifier: MIT
  *
- * 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.
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
  * The Common Trace Format (CTF) Specification is available at
  * http://www.efficios.com/ctf
  */
 
+#ifndef BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_FIELDS_INTERNAL_H
+
 #include <glib.h>
 #include <inttypes.h>
 #include <stdbool.h>
@@ -35,7 +17,7 @@
 #include <stdint.h>
 #include <string.h>
 
-#include <babeltrace2/ctf-writer/fields.h>
+#include <babeltrace2-ctf-writer/fields.h>
 #include <babeltrace2/types.h>
 
 #include "common/macros.h"
@@ -67,7 +49,7 @@ typedef void (*bt_ctf_field_common_method_set_is_frozen)(struct bt_ctf_field_com
 typedef int (*bt_ctf_field_common_method_validate)(struct bt_ctf_field_common *);
 typedef struct bt_ctf_field_common *(*bt_ctf_field_common_method_copy)(
                struct bt_ctf_field_common *);
-typedef bt_bool (*bt_ctf_field_common_method_is_set)(struct bt_ctf_field_common *);
+typedef bt_ctf_bool (*bt_ctf_field_common_method_is_set)(struct bt_ctf_field_common *);
 typedef void (*bt_ctf_field_common_method_reset)(struct bt_ctf_field_common *);
 
 struct bt_ctf_field_common_methods {
@@ -160,10 +142,8 @@ struct bt_ctf_field_common_string {
        size_t size;
 };
 
-BT_HIDDEN
 struct bt_ctf_field_common *bt_ctf_field_common_copy(struct bt_ctf_field_common *field);
 
-BT_HIDDEN
 int bt_ctf_field_common_structure_initialize(struct bt_ctf_field_common *field,
                struct bt_ctf_field_type_common *type,
                bool is_shared, bt_ctf_object_release_func release_func,
@@ -171,7 +151,6 @@ int bt_ctf_field_common_structure_initialize(struct bt_ctf_field_common *field,
                bt_ctf_field_common_create_func field_create_func,
                GDestroyNotify field_release_func);
 
-BT_HIDDEN
 int bt_ctf_field_common_array_initialize(struct bt_ctf_field_common *field,
                struct bt_ctf_field_type_common *type,
                bool is_shared, bt_ctf_object_release_func release_func,
@@ -179,14 +158,12 @@ int bt_ctf_field_common_array_initialize(struct bt_ctf_field_common *field,
                bt_ctf_field_common_create_func field_create_func,
                GDestroyNotify field_destroy_func);
 
-BT_HIDDEN
 int bt_ctf_field_common_sequence_initialize(struct bt_ctf_field_common *field,
                struct bt_ctf_field_type_common *type,
                bool is_shared, bt_ctf_object_release_func release_func,
                struct bt_ctf_field_common_methods *methods,
                GDestroyNotify field_destroy_func);
 
-BT_HIDDEN
 int bt_ctf_field_common_variant_initialize(struct bt_ctf_field_common *field,
                struct bt_ctf_field_type_common *type,
                bool is_shared, bt_ctf_object_release_func release_func,
@@ -194,81 +171,59 @@ int bt_ctf_field_common_variant_initialize(struct bt_ctf_field_common *field,
                bt_ctf_field_common_create_func field_create_func,
                GDestroyNotify field_release_func);
 
-BT_HIDDEN
 int bt_ctf_field_common_string_initialize(struct bt_ctf_field_common *field,
                struct bt_ctf_field_type_common *type,
                bool is_shared, bt_ctf_object_release_func release_func,
                struct bt_ctf_field_common_methods *methods);
 
-BT_HIDDEN
 int bt_ctf_field_common_generic_validate(struct bt_ctf_field_common *field);
 
-BT_HIDDEN
 int bt_ctf_field_common_structure_validate_recursive(struct bt_ctf_field_common *field);
 
-BT_HIDDEN
 int bt_ctf_field_common_variant_validate_recursive(struct bt_ctf_field_common *field);
 
-BT_HIDDEN
 int bt_ctf_field_common_array_validate_recursive(struct bt_ctf_field_common *field);
 
-BT_HIDDEN
 int bt_ctf_field_common_sequence_validate_recursive(struct bt_ctf_field_common *field);
 
-BT_HIDDEN
 void bt_ctf_field_common_generic_reset(struct bt_ctf_field_common *field);
 
-BT_HIDDEN
 void bt_ctf_field_common_structure_reset_recursive(struct bt_ctf_field_common *field);
 
-BT_HIDDEN
 void bt_ctf_field_common_variant_reset_recursive(struct bt_ctf_field_common *field);
 
-BT_HIDDEN
 void bt_ctf_field_common_array_reset_recursive(struct bt_ctf_field_common *field);
 
-BT_HIDDEN
 void bt_ctf_field_common_sequence_reset_recursive(struct bt_ctf_field_common *field);
 
-BT_HIDDEN
 void bt_ctf_field_common_generic_set_is_frozen(struct bt_ctf_field_common *field,
                bool is_frozen);
 
-BT_HIDDEN
 void bt_ctf_field_common_structure_set_is_frozen_recursive(
                struct bt_ctf_field_common *field, bool is_frozen);
 
-BT_HIDDEN
 void bt_ctf_field_common_variant_set_is_frozen_recursive(
                struct bt_ctf_field_common *field, bool is_frozen);
 
-BT_HIDDEN
 void bt_ctf_field_common_array_set_is_frozen_recursive(
                struct bt_ctf_field_common *field, bool is_frozen);
 
-BT_HIDDEN
 void bt_ctf_field_common_sequence_set_is_frozen_recursive(
                struct bt_ctf_field_common *field, bool is_frozen);
 
-BT_HIDDEN
 void _bt_ctf_field_common_set_is_frozen_recursive(struct bt_ctf_field_common *field,
                bool is_frozen);
 
-BT_HIDDEN
-bt_bool bt_ctf_field_common_generic_is_set(struct bt_ctf_field_common *field);
+bt_ctf_bool bt_ctf_field_common_generic_is_set(struct bt_ctf_field_common *field);
 
-BT_HIDDEN
-bt_bool bt_ctf_field_common_structure_is_set_recursive(
+bt_ctf_bool bt_ctf_field_common_structure_is_set_recursive(
                struct bt_ctf_field_common *field);
 
-BT_HIDDEN
-bt_bool bt_ctf_field_common_variant_is_set_recursive(struct bt_ctf_field_common *field);
+bt_ctf_bool bt_ctf_field_common_variant_is_set_recursive(struct bt_ctf_field_common *field);
 
-BT_HIDDEN
-bt_bool bt_ctf_field_common_array_is_set_recursive(struct bt_ctf_field_common *field);
+bt_ctf_bool bt_ctf_field_common_array_is_set_recursive(struct bt_ctf_field_common *field);
 
-BT_HIDDEN
-bt_bool bt_ctf_field_common_sequence_is_set_recursive(struct bt_ctf_field_common *field);
+bt_ctf_bool bt_ctf_field_common_sequence_is_set_recursive(struct bt_ctf_field_common *field);
 
 #ifdef BT_DEV_MODE
 # define bt_ctf_field_common_validate_recursive                _bt_ctf_field_common_validate_recursive
@@ -279,16 +234,16 @@ bt_bool bt_ctf_field_common_sequence_is_set_recursive(struct bt_ctf_field_common
 #else
 # define bt_ctf_field_common_validate_recursive(_field)        (-1)
 # define bt_ctf_field_common_set_is_frozen_recursive(_field, _is_frozen)
-# define bt_ctf_field_common_is_set_recursive(_field)  (BT_FALSE)
+# define bt_ctf_field_common_is_set_recursive(_field)  (BT_CTF_FALSE)
 # define bt_ctf_field_common_reset_recursive(_field)
 # define bt_ctf_field_common_set(_field, _val)
 #endif
 
-BT_ASSERT_FUNC
+BT_ASSERT_DBG_FUNC
 static inline bool field_type_common_has_known_id(
                struct bt_ctf_field_type_common *ft)
 {
-       return (int) ft->id > BT_CTF_FIELD_TYPE_ID_UNKNOWN ||
+       return (int) ft->id > BT_CTF_FIELD_TYPE_ID_UNKNOWN &&
                (int) ft->id < BT_CTF_FIELD_TYPE_ID_NR;
 }
 
@@ -303,7 +258,7 @@ int _bt_ctf_field_common_validate_recursive(struct bt_ctf_field_common *field)
                goto end;
        }
 
-       BT_ASSERT(field_type_common_has_known_id(field->type));
+       BT_ASSERT_DBG(field_type_common_has_known_id(field->type));
 
        if (field->methods->validate) {
                ret = field->methods->validate(field);
@@ -316,29 +271,29 @@ end:
 static inline
 void _bt_ctf_field_common_reset_recursive(struct bt_ctf_field_common *field)
 {
-       BT_ASSERT(field);
-       BT_ASSERT(field->methods->reset);
+       BT_ASSERT_DBG(field);
+       BT_ASSERT_DBG(field->methods->reset);
        field->methods->reset(field);
 }
 
 static inline
 void _bt_ctf_field_common_set(struct bt_ctf_field_common *field, bool value)
 {
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
        field->payload_set = value;
 }
 
 static inline
-bt_bool _bt_ctf_field_common_is_set_recursive(struct bt_ctf_field_common *field)
+bt_ctf_bool _bt_ctf_field_common_is_set_recursive(struct bt_ctf_field_common *field)
 {
-       bt_bool is_set = BT_FALSE;
+       bt_ctf_bool is_set = BT_CTF_FALSE;
 
        if (!field) {
                goto end;
        }
 
-       BT_ASSERT(field_type_common_has_known_id(field->type));
-       BT_ASSERT(field->methods->is_set);
+       BT_ASSERT_DBG(field_type_common_has_known_id(field->type));
+       BT_ASSERT_DBG(field->methods->is_set);
        is_set = field->methods->is_set(field);
 
 end:
@@ -351,8 +306,8 @@ void bt_ctf_field_common_initialize(struct bt_ctf_field_common *field,
                bt_ctf_object_release_func release_func,
                struct bt_ctf_field_common_methods *methods)
 {
-       BT_ASSERT(field);
-       BT_ASSERT(ft);
+       BT_ASSERT_DBG(field);
+       BT_ASSERT_DBG(ft);
        bt_ctf_object_init(&field->base, is_shared, release_func);
        field->methods = methods;
        field->type = (void *) bt_ctf_object_get_ref(ft);
@@ -411,7 +366,7 @@ int bt_ctf_field_common_sequence_set_length(struct bt_ctf_field_common *field,
                                goto end;
                        }
 
-                       BT_ASSERT(!sequence->elements->pdata[i]);
+                       BT_ASSERT_DBG(!sequence->elements->pdata[i]);
                        sequence->elements->pdata[i] = elem_field;
                }
        }
@@ -443,14 +398,14 @@ struct bt_ctf_field_common *bt_ctf_field_common_structure_borrow_field_by_name(
        if (!g_hash_table_lookup_extended(field_name_to_index,
                        GUINT_TO_POINTER(field_quark),
                        NULL, (gpointer *) &index)) {
-               BT_LOGV("Invalid parameter: no such field in structure field's type: "
+               BT_LOGT("Invalid parameter: no such field in structure field's type: "
                        "struct-field-addr=%p, struct-ft-addr=%p, name=\"%s\"",
                        field, field->type, name);
                goto error;
        }
 
        ret = structure->fields->pdata[index];
-       BT_ASSERT(ret);
+       BT_ASSERT_DBG(ret);
 
 error:
        return ret;
@@ -525,7 +480,7 @@ int bt_ctf_field_common_variant_set_tag(struct bt_ctf_field_common *variant_fiel
        }
 
        /* Select corresponding field */
-       BT_ASSERT(choice_index < variant->fields->len);
+       BT_ASSERT_DBG(choice_index < variant->fields->len);
        variant->current_field = variant->fields->pdata[choice_index];
        variant->tag_value.u = tag_uval;
 
@@ -650,7 +605,7 @@ int bt_ctf_field_common_string_append_len(struct bt_ctf_field_common *field,
                BT_CTF_FIELD_TYPE_ID_STRING, "Field");
 
        /* Make sure no null bytes are appended */
-       BT_CTF_ASSERT_PRE(memchr(value, '\0', length) == NULL,
+       BT_CTF_ASSERT_PRE(!memchr(value, '\0', length),
                "String value to append contains a null character: "
                "partial-value=\"%.32s\", length=%u", value, length);
 
@@ -694,7 +649,7 @@ int bt_ctf_field_common_string_set_value(struct bt_ctf_field_common *field,
 static inline
 void bt_ctf_field_common_finalize(struct bt_ctf_field_common *field)
 {
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
        BT_LOGD_STR("Putting field's type.");
        bt_ctf_object_put_ref(field->type);
 }
@@ -702,7 +657,7 @@ void bt_ctf_field_common_finalize(struct bt_ctf_field_common *field)
 static inline
 void bt_ctf_field_common_integer_finalize(struct bt_ctf_field_common *field)
 {
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
        BT_LOGD("Finalizing common integer field object: addr=%p", field);
        bt_ctf_field_common_finalize(field);
 }
@@ -710,7 +665,7 @@ void bt_ctf_field_common_integer_finalize(struct bt_ctf_field_common *field)
 static inline
 void bt_ctf_field_common_floating_point_finalize(struct bt_ctf_field_common *field)
 {
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
        BT_LOGD("Finalizing common floating point number field object: addr=%p", field);
        bt_ctf_field_common_finalize(field);
 }
@@ -720,7 +675,7 @@ void bt_ctf_field_common_structure_finalize_recursive(struct bt_ctf_field_common
 {
        struct bt_ctf_field_common_structure *structure = BT_CTF_FROM_COMMON(field);
 
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
        BT_LOGD("Finalizing common structure field object: addr=%p", field);
        bt_ctf_field_common_finalize(field);
 
@@ -734,7 +689,7 @@ void bt_ctf_field_common_variant_finalize_recursive(struct bt_ctf_field_common *
 {
        struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(field);
 
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
        BT_LOGD("Finalizing common variant field object: addr=%p", field);
        bt_ctf_field_common_finalize(field);
 
@@ -748,7 +703,7 @@ void bt_ctf_field_common_array_finalize_recursive(struct bt_ctf_field_common *fi
 {
        struct bt_ctf_field_common_array *array = BT_CTF_FROM_COMMON(field);
 
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
        BT_LOGD("Finalizing common array field object: addr=%p", field);
        bt_ctf_field_common_finalize(field);
 
@@ -762,7 +717,7 @@ void bt_ctf_field_common_sequence_finalize_recursive(struct bt_ctf_field_common
 {
        struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field);
 
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
        BT_LOGD("Finalizing common sequence field object: addr=%p", field);
        bt_ctf_field_common_finalize(field);
 
@@ -776,7 +731,7 @@ void bt_ctf_field_common_string_finalize(struct bt_ctf_field_common *field)
 {
        struct bt_ctf_field_common_string *string = BT_CTF_FROM_COMMON(field);
 
-       BT_ASSERT(field);
+       BT_ASSERT_DBG(field);
        BT_LOGD("Finalizing common string field object: addr=%p", field);
        bt_ctf_field_common_finalize(field);
 
@@ -830,21 +785,18 @@ struct bt_ctf_field_variant {
        struct bt_ctf_field_enumeration *tag;
 };
 
-BT_HIDDEN
 int bt_ctf_field_serialize_recursive(struct bt_ctf_field *field,
                struct bt_ctfser *ctfser,
                enum bt_ctf_byte_order native_byte_order);
 
-BT_HIDDEN
 int bt_ctf_field_structure_set_field_by_name(struct bt_ctf_field *field,
                const char *name, struct bt_ctf_field *value);
 
-BT_HIDDEN
 struct bt_ctf_field *bt_ctf_field_enumeration_borrow_container(
                struct bt_ctf_field *field);
 
 static inline
-bt_bool bt_ctf_field_is_set_recursive(struct bt_ctf_field *field)
+bt_ctf_bool bt_ctf_field_is_set_recursive(struct bt_ctf_field *field)
 {
        return bt_ctf_field_common_is_set_recursive((void *) field);
 }
This page took 0.02971 seconds and 4 git commands to generate.