Do not use `bool` type; use new `bt_bool` instead
[babeltrace.git] / lib / ctf-ir / trace.c
index 8737bfd392e793105fcb59375141814ad69d9140..d36d49816e147e11733093f00b50280f66a76fa7 100644 (file)
@@ -43,6 +43,7 @@
 #include <babeltrace/compiler-internal.h>
 #include <babeltrace/values.h>
 #include <babeltrace/ref.h>
+#include <babeltrace/types.h>
 #include <babeltrace/endian-internal.h>
 #include <inttypes.h>
 #include <stdint.h>
@@ -59,8 +60,6 @@ struct listener_wrapper {
 static
 void bt_ctf_trace_destroy(struct bt_object *obj);
 static
-int init_trace_packet_header(struct bt_ctf_trace *trace);
-static
 void bt_ctf_trace_freeze(struct bt_ctf_trace *trace);
 
 static
@@ -84,6 +83,7 @@ const unsigned int field_type_aliases_sizes[] = {
 struct bt_ctf_trace *bt_ctf_trace_create(void)
 {
        struct bt_ctf_trace *trace = NULL;
+       struct bt_ctf_field_type *packet_header_type = NULL;
 
        trace = g_new0(struct bt_ctf_trace, 1);
        if (!trace) {
@@ -102,10 +102,13 @@ struct bt_ctf_trace *bt_ctf_trace_create(void)
                goto error;
        }
 
-       if (init_trace_packet_header(trace)) {
+       packet_header_type = bt_ctf_field_type_structure_create();
+       if (!packet_header_type) {
                goto error;
        }
 
+       BT_MOVE(trace->packet_header_type, packet_header_type);
+
        /* Create the environment array object */
        trace->environment = bt_ctf_attributes_create();
        if (!trace->environment) {
@@ -122,6 +125,7 @@ struct bt_ctf_trace *bt_ctf_trace_create(void)
 
 error:
        BT_PUT(trace);
+       bt_put(packet_header_type);
        return trace;
 }
 
@@ -172,7 +176,7 @@ int bt_ctf_trace_set_uuid(struct bt_ctf_trace *trace, const unsigned char *uuid)
        }
 
        memcpy(trace->uuid, uuid, sizeof(uuid_t));
-       trace->uuid_set = true;
+       trace->uuid_set = BT_TRUE;
 
 end:
        return ret;
@@ -864,7 +868,7 @@ end:
 }
 
 BT_HIDDEN
-bool bt_ctf_trace_has_clock_class(struct bt_ctf_trace *trace,
+bt_bool bt_ctf_trace_has_clock_class(struct bt_ctf_trace *trace,
                struct bt_ctf_clock_class *clock_class)
 {
        struct search_query query = { .value = clock_class, .found = 0 };
@@ -892,7 +896,7 @@ const char *get_byte_order_string(enum bt_ctf_byte_order byte_order)
                string = "native";
                break;
        default:
-               assert(false);
+               assert(BT_FALSE);
        }
 
        return string;
@@ -1069,7 +1073,8 @@ end:
        return metadata;
 }
 
-enum bt_ctf_byte_order bt_ctf_trace_get_byte_order(struct bt_ctf_trace *trace)
+enum bt_ctf_byte_order bt_ctf_trace_get_native_byte_order(
+               struct bt_ctf_trace *trace)
 {
        enum bt_ctf_byte_order ret = BT_CTF_BYTE_ORDER_UNKNOWN;
 
@@ -1288,61 +1293,9 @@ void bt_ctf_trace_freeze(struct bt_ctf_trace *trace)
        trace->frozen = 1;
 }
 
-static
-int init_trace_packet_header(struct bt_ctf_trace *trace)
-{
-       int ret = 0;
-       struct bt_ctf_field *magic = NULL, *uuid_array = NULL;
-       struct bt_ctf_field_type *_uint32_t =
-               get_field_type(FIELD_TYPE_ALIAS_UINT32_T);
-       struct bt_ctf_field_type *_uint8_t =
-               get_field_type(FIELD_TYPE_ALIAS_UINT8_T);
-       struct bt_ctf_field_type *trace_packet_header_type =
-               bt_ctf_field_type_structure_create();
-       struct bt_ctf_field_type *uuid_array_type =
-               bt_ctf_field_type_array_create(_uint8_t, 16);
-
-       if (!trace_packet_header_type || !uuid_array_type) {
-               ret = -1;
-               goto end;
-       }
-
-       ret = bt_ctf_field_type_structure_add_field(trace_packet_header_type,
-               _uint32_t, "magic");
-       if (ret) {
-               goto end;
-       }
-
-       ret = bt_ctf_field_type_structure_add_field(trace_packet_header_type,
-               uuid_array_type, "uuid");
-       if (ret) {
-               goto end;
-       }
-
-       ret = bt_ctf_field_type_structure_add_field(trace_packet_header_type,
-               _uint32_t, "stream_id");
-       if (ret) {
-               goto end;
-       }
-
-       ret = bt_ctf_trace_set_packet_header_type(trace,
-               trace_packet_header_type);
-       if (ret) {
-               goto end;
-       }
-end:
-       bt_put(uuid_array_type);
-       bt_put(_uint32_t);
-       bt_put(_uint8_t);
-       bt_put(magic);
-       bt_put(uuid_array);
-       bt_put(trace_packet_header_type);
-       return ret;
-}
-
-bool bt_ctf_trace_is_static(struct bt_ctf_trace *trace)
+bt_bool bt_ctf_trace_is_static(struct bt_ctf_trace *trace)
 {
-       bool is_static = false;
+       bt_bool is_static = BT_FALSE;
 
        if (!trace) {
                goto end;
@@ -1363,7 +1316,7 @@ int bt_ctf_trace_set_is_static(struct bt_ctf_trace *trace)
                goto end;
        }
 
-       trace->is_static = true;
+       trace->is_static = BT_TRUE;
        bt_ctf_trace_freeze(trace);
 
 end:
This page took 0.024752 seconds and 4 git commands to generate.