X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;f=src%2Fctf-writer%2Fclock-class.c;h=94a5c8df77c9adc7a5d720eb22816fd68378f2fb;hb=afe77d4f77220b7fa0a27cbe6e2aef34c6935174;hp=258d4a6c466e64f893ed37cb0ef80afae0e5c23c;hpb=578e048b5debf169e286e5b5cc747b5d6c16886d;p=babeltrace.git diff --git a/src/ctf-writer/clock-class.c b/src/ctf-writer/clock-class.c index 258d4a6c..94a5c8df 100644 --- a/src/ctf-writer/clock-class.c +++ b/src/ctf-writer/clock-class.c @@ -1,40 +1,20 @@ /* - * clock-class.c - * - * Babeltrace CTF writer - Clock class + * SPDX-License-Identifier: MIT * * Copyright 2013, 2014 Jérémie Galarneau * - * Author: 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. + * Babeltrace CTF writer - Clock class */ -#define BT_LOG_TAG "CTF-WRITER-CLOCK-CLASS" +#define BT_LOG_TAG "CTF-WRITER/CLOCK-CLASS" #include "logging.h" -#include "compat/uuid.h" -#include -#include +#include "common/uuid.h" +#include +#include #include "compat/compiler.h" -#include #include "compat/string.h" +#include #include #include "common/assert.h" @@ -45,13 +25,11 @@ static void bt_ctf_clock_class_destroy(struct bt_ctf_object *obj); -BT_HIDDEN -bt_bool bt_ctf_clock_class_is_valid(struct bt_ctf_clock_class *clock_class) +bt_ctf_bool bt_ctf_clock_class_is_valid(struct bt_ctf_clock_class *clock_class) { return clock_class && clock_class->name; } -BT_HIDDEN int bt_ctf_clock_class_set_name(struct bt_ctf_clock_class *clock_class, const char *name) { @@ -89,7 +67,7 @@ int bt_ctf_clock_class_set_name(struct bt_ctf_clock_class *clock_class, } } - BT_LOGV("Set clock class's name: addr=%p, name=\"%s\"", + BT_LOGT("Set clock class's name: addr=%p, name=\"%s\"", clock_class, name); end: @@ -114,7 +92,6 @@ end: return is_valid; } -BT_HIDDEN struct bt_ctf_clock_class *bt_ctf_clock_class_create(const char *name, uint64_t freq) { @@ -155,7 +132,6 @@ error: return clock_class; } -BT_HIDDEN const char *bt_ctf_clock_class_get_name(struct bt_ctf_clock_class *clock_class) { const char *ret = NULL; @@ -173,7 +149,6 @@ end: return ret; } -BT_HIDDEN const char *bt_ctf_clock_class_get_description( struct bt_ctf_clock_class *clock_class) { @@ -191,7 +166,6 @@ end: return ret; } -BT_HIDDEN int bt_ctf_clock_class_set_description(struct bt_ctf_clock_class *clock_class, const char *desc) { @@ -215,14 +189,13 @@ int bt_ctf_clock_class_set_description(struct bt_ctf_clock_class *clock_class, clock_class->description = g_string_new(desc); ret = clock_class->description ? 0 : -1; - BT_LOGV("Set clock class's description: addr=%p, " + BT_LOGT("Set clock class's description: addr=%p, " "name=\"%s\", desc=\"%s\"", clock_class, bt_ctf_clock_class_get_name(clock_class), desc); end: return ret; } -BT_HIDDEN uint64_t bt_ctf_clock_class_get_frequency( struct bt_ctf_clock_class *clock_class) { @@ -238,7 +211,6 @@ end: return ret; } -BT_HIDDEN int bt_ctf_clock_class_set_frequency(struct bt_ctf_clock_class *clock_class, uint64_t freq) { @@ -266,13 +238,12 @@ int bt_ctf_clock_class_set_frequency(struct bt_ctf_clock_class *clock_class, } clock_class->frequency = freq; - BT_LOGV("Set clock class's frequency: addr=%p, name=\"%s\", freq=%" PRIu64, + BT_LOGT("Set clock class's frequency: addr=%p, name=\"%s\", freq=%" PRIu64, clock_class, bt_ctf_clock_class_get_name(clock_class), freq); end: return ret; } -BT_HIDDEN uint64_t bt_ctf_clock_class_get_precision(struct bt_ctf_clock_class *clock_class) { uint64_t ret = -1ULL; @@ -287,7 +258,6 @@ end: return ret; } -BT_HIDDEN int bt_ctf_clock_class_set_precision(struct bt_ctf_clock_class *clock_class, uint64_t precision) { @@ -310,14 +280,13 @@ int bt_ctf_clock_class_set_precision(struct bt_ctf_clock_class *clock_class, } clock_class->precision = precision; - BT_LOGV("Set clock class's precision: addr=%p, name=\"%s\", precision=%" PRIu64, + BT_LOGT("Set clock class's precision: addr=%p, name=\"%s\", precision=%" PRIu64, clock_class, bt_ctf_clock_class_get_name(clock_class), precision); end: return ret; } -BT_HIDDEN int bt_ctf_clock_class_get_offset_s(struct bt_ctf_clock_class *clock_class, int64_t *offset_s) { @@ -337,7 +306,6 @@ end: return ret; } -BT_HIDDEN int bt_ctf_clock_class_set_offset_s(struct bt_ctf_clock_class *clock_class, int64_t offset_s) { @@ -357,7 +325,7 @@ int bt_ctf_clock_class_set_offset_s(struct bt_ctf_clock_class *clock_class, } clock_class->offset_s = offset_s; - BT_LOGV("Set clock class's offset (seconds): " + BT_LOGT("Set clock class's offset (seconds): " "addr=%p, name=\"%s\", offset-s=%" PRId64, clock_class, bt_ctf_clock_class_get_name(clock_class), offset_s); @@ -365,7 +333,6 @@ end: return ret; } -BT_HIDDEN int bt_ctf_clock_class_get_offset_cycles(struct bt_ctf_clock_class *clock_class, int64_t *offset) { @@ -385,7 +352,6 @@ end: return ret; } -BT_HIDDEN int bt_ctf_clock_class_set_offset_cycles(struct bt_ctf_clock_class *clock_class, int64_t offset) { @@ -405,14 +371,13 @@ int bt_ctf_clock_class_set_offset_cycles(struct bt_ctf_clock_class *clock_class, } clock_class->offset = offset; - BT_LOGV("Set clock class's offset (cycles): addr=%p, name=\"%s\", offset-cycles=%" PRId64, + BT_LOGT("Set clock class's offset (cycles): addr=%p, name=\"%s\", offset-cycles=%" PRId64, clock_class, bt_ctf_clock_class_get_name(clock_class), offset); end: return ret; } -BT_HIDDEN -bt_bool bt_ctf_clock_class_is_absolute(struct bt_ctf_clock_class *clock_class) +bt_ctf_bool bt_ctf_clock_class_is_absolute(struct bt_ctf_clock_class *clock_class) { int ret = -1; @@ -426,9 +391,8 @@ end: return ret; } -BT_HIDDEN int bt_ctf_clock_class_set_is_absolute(struct bt_ctf_clock_class *clock_class, - bt_bool is_absolute) + bt_ctf_bool is_absolute) { int ret = 0; @@ -446,18 +410,17 @@ int bt_ctf_clock_class_set_is_absolute(struct bt_ctf_clock_class *clock_class, } clock_class->absolute = !!is_absolute; - BT_LOGV("Set clock class's absolute flag: addr=%p, name=\"%s\", is-absolute=%d", + BT_LOGT("Set clock class's absolute flag: addr=%p, name=\"%s\", is-absolute=%d", clock_class, bt_ctf_clock_class_get_name(clock_class), is_absolute); end: return ret; } -BT_HIDDEN -const unsigned char *bt_ctf_clock_class_get_uuid( +const uint8_t *bt_ctf_clock_class_get_uuid( struct bt_ctf_clock_class *clock_class) { - const unsigned char *ret; + const uint8_t *ret; if (!clock_class) { BT_LOGW_STR("Invalid parameter: clock class is NULL."); @@ -466,7 +429,7 @@ const unsigned char *bt_ctf_clock_class_get_uuid( } if (!clock_class->uuid_set) { - BT_LOGV("Clock class's UUID is not set: addr=%p, name=\"%s\"", + BT_LOGT("Clock class's UUID is not set: addr=%p, name=\"%s\"", clock_class, bt_ctf_clock_class_get_name(clock_class)); ret = NULL; goto end; @@ -477,9 +440,8 @@ end: return ret; } -BT_HIDDEN int bt_ctf_clock_class_set_uuid(struct bt_ctf_clock_class *clock_class, - const unsigned char *uuid) + const uint8_t *uuid) { int ret = 0; @@ -499,32 +461,15 @@ int bt_ctf_clock_class_set_uuid(struct bt_ctf_clock_class *clock_class, goto end; } - memcpy(clock_class->uuid, uuid, BABELTRACE_UUID_LEN); + bt_uuid_copy(clock_class->uuid, uuid); clock_class->uuid_set = 1; - BT_LOGV("Set clock class's UUID: addr=%p, name=\"%s\", " - "uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"", + BT_LOGT("Set clock class's UUID: addr=%p, name=\"%s\", uuid=\"" BT_UUID_FMT "\"", clock_class, bt_ctf_clock_class_get_name(clock_class), - (unsigned int) uuid[0], - (unsigned int) uuid[1], - (unsigned int) uuid[2], - (unsigned int) uuid[3], - (unsigned int) uuid[4], - (unsigned int) uuid[5], - (unsigned int) uuid[6], - (unsigned int) uuid[7], - (unsigned int) uuid[8], - (unsigned int) uuid[9], - (unsigned int) uuid[10], - (unsigned int) uuid[11], - (unsigned int) uuid[12], - (unsigned int) uuid[13], - (unsigned int) uuid[14], - (unsigned int) uuid[15]); + BT_UUID_FMT_VALUES(uuid)); end: return ret; } -BT_HIDDEN void bt_ctf_clock_class_freeze(struct bt_ctf_clock_class *clock_class) { if (!clock_class || clock_class->frozen) { @@ -556,17 +501,16 @@ void bt_ctf_clock_class_destroy(struct bt_ctf_object *obj) g_free(clock_class); } -BT_HIDDEN int bt_ctf_clock_class_compare(struct bt_ctf_clock_class *clock_class_a, struct bt_ctf_clock_class *clock_class_b) { int ret = 1; - BT_ASSERT(clock_class_a); - BT_ASSERT(clock_class_b); + BT_ASSERT_DBG(clock_class_a); + BT_ASSERT_DBG(clock_class_b); /* Name */ if (strcmp(clock_class_a->name->str, clock_class_b->name->str) != 0) { - BT_LOGV("Clock classes differ: different names: " + BT_LOGT("Clock classes differ: different names: " "cc-a-name=\"%s\", cc-b-name=\"%s\"", clock_class_a->name->str, clock_class_b->name->str); @@ -576,14 +520,14 @@ int bt_ctf_clock_class_compare(struct bt_ctf_clock_class *clock_class_a, /* Description */ if (clock_class_a->description) { if (!clock_class_b->description) { - BT_LOGV_STR("Clock classes differ: clock class A has a " + BT_LOGT_STR("Clock classes differ: clock class A has a " "description, but clock class B does not."); goto end; } if (strcmp(clock_class_a->name->str, clock_class_b->name->str) != 0) { - BT_LOGV("Clock classes differ: different descriptions: " + BT_LOGT("Clock classes differ: different descriptions: " "cc-a-descr=\"%s\", cc-b-descr=\"%s\"", clock_class_a->description->str, clock_class_b->description->str); @@ -591,7 +535,7 @@ int bt_ctf_clock_class_compare(struct bt_ctf_clock_class *clock_class_a, } } else { if (clock_class_b->description) { - BT_LOGV_STR("Clock classes differ: clock class A has " + BT_LOGT_STR("Clock classes differ: clock class A has " "no description, but clock class B has one."); goto end; } @@ -599,7 +543,7 @@ int bt_ctf_clock_class_compare(struct bt_ctf_clock_class *clock_class_a, /* Frequency */ if (clock_class_a->frequency != clock_class_b->frequency) { - BT_LOGV("Clock classes differ: different frequencies: " + BT_LOGT("Clock classes differ: different frequencies: " "cc-a-freq=%" PRIu64 ", cc-b-freq=%" PRIu64, clock_class_a->frequency, clock_class_b->frequency); @@ -608,7 +552,7 @@ int bt_ctf_clock_class_compare(struct bt_ctf_clock_class *clock_class_a, /* Precision */ if (clock_class_a->precision != clock_class_b->precision) { - BT_LOGV("Clock classes differ: different precisions: " + BT_LOGT("Clock classes differ: different precisions: " "cc-a-freq=%" PRIu64 ", cc-b-freq=%" PRIu64, clock_class_a->precision, clock_class_b->precision); @@ -617,7 +561,7 @@ int bt_ctf_clock_class_compare(struct bt_ctf_clock_class *clock_class_a, /* Offset (seconds) */ if (clock_class_a->offset_s != clock_class_b->offset_s) { - BT_LOGV("Clock classes differ: different offsets (seconds): " + BT_LOGT("Clock classes differ: different offsets (seconds): " "cc-a-offset-s=%" PRId64 ", cc-b-offset-s=%" PRId64, clock_class_a->offset_s, clock_class_b->offset_s); @@ -626,7 +570,7 @@ int bt_ctf_clock_class_compare(struct bt_ctf_clock_class *clock_class_a, /* Offset (cycles) */ if (clock_class_a->offset != clock_class_b->offset) { - BT_LOGV("Clock classes differ: different offsets (cycles): " + BT_LOGT("Clock classes differ: different offsets (cycles): " "cc-a-offset-s=%" PRId64 ", cc-b-offset-s=%" PRId64, clock_class_a->offset, clock_class_b->offset); @@ -636,53 +580,22 @@ int bt_ctf_clock_class_compare(struct bt_ctf_clock_class *clock_class_a, /* UUIDs */ if (clock_class_a->uuid_set) { if (!clock_class_b->uuid_set) { - BT_LOGV_STR("Clock classes differ: clock class A has a " + BT_LOGT_STR("Clock classes differ: clock class A has a " "UUID, but clock class B does not."); goto end; } - if (memcmp(clock_class_a->uuid, clock_class_b->uuid, - BABELTRACE_UUID_LEN) != 0) { - BT_LOGV("Clock classes differ: different UUIDs: " - "cc-a-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\", " - "cc-b-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"", - (unsigned int) clock_class_a->uuid[0], - (unsigned int) clock_class_a->uuid[1], - (unsigned int) clock_class_a->uuid[2], - (unsigned int) clock_class_a->uuid[3], - (unsigned int) clock_class_a->uuid[4], - (unsigned int) clock_class_a->uuid[5], - (unsigned int) clock_class_a->uuid[6], - (unsigned int) clock_class_a->uuid[7], - (unsigned int) clock_class_a->uuid[8], - (unsigned int) clock_class_a->uuid[9], - (unsigned int) clock_class_a->uuid[10], - (unsigned int) clock_class_a->uuid[11], - (unsigned int) clock_class_a->uuid[12], - (unsigned int) clock_class_a->uuid[13], - (unsigned int) clock_class_a->uuid[14], - (unsigned int) clock_class_a->uuid[15], - (unsigned int) clock_class_b->uuid[0], - (unsigned int) clock_class_b->uuid[1], - (unsigned int) clock_class_b->uuid[2], - (unsigned int) clock_class_b->uuid[3], - (unsigned int) clock_class_b->uuid[4], - (unsigned int) clock_class_b->uuid[5], - (unsigned int) clock_class_b->uuid[6], - (unsigned int) clock_class_b->uuid[7], - (unsigned int) clock_class_b->uuid[8], - (unsigned int) clock_class_b->uuid[9], - (unsigned int) clock_class_b->uuid[10], - (unsigned int) clock_class_b->uuid[11], - (unsigned int) clock_class_b->uuid[12], - (unsigned int) clock_class_b->uuid[13], - (unsigned int) clock_class_b->uuid[14], - (unsigned int) clock_class_b->uuid[15]); + if (bt_uuid_compare(clock_class_a->uuid, clock_class_b->uuid) != 0) { + BT_LOGT("Clock classes differ: different UUIDs: " + "cc-a-uuid=\"" BT_UUID_FMT "\", " + "cc-b-uuid=\"" BT_UUID_FMT "\"", + BT_UUID_FMT_VALUES(clock_class_a->uuid), + BT_UUID_FMT_VALUES(clock_class_b->uuid)); goto end; } } else { if (clock_class_b->uuid_set) { - BT_LOGV_STR("Clock classes differ: clock class A has " + BT_LOGT_STR("Clock classes differ: clock class A has " "no UUID, but clock class B has one."); goto end; } @@ -690,7 +603,7 @@ int bt_ctf_clock_class_compare(struct bt_ctf_clock_class *clock_class_a, /* Absolute */ if (!!clock_class_a->absolute != !!clock_class_b->absolute) { - BT_LOGV("Clock classes differ: one is absolute, the other " + BT_LOGT("Clock classes differ: one is absolute, the other " "is not: cc-a-is-absolute=%d, cc-b-is-absolute=%d", !!clock_class_a->absolute, !!clock_class_b->absolute);