X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fctf-writer%2Fclock-class.c;h=0de6c3248608393e3008fc01a8410b04e92de8cc;hb=c4f23e30bf67d2523163614bc9461d84cbe1ae80;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..0de6c324 100644 --- a/src/ctf-writer/clock-class.c +++ b/src/ctf-writer/clock-class.c @@ -26,15 +26,16 @@ * SOFTWARE. */ -#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" @@ -46,7 +47,7 @@ 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; } @@ -89,7 +90,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: @@ -215,7 +216,7 @@ 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: @@ -266,7 +267,7 @@ 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; @@ -310,7 +311,7 @@ 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: @@ -357,7 +358,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); @@ -405,14 +406,14 @@ 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; @@ -428,7 +429,7 @@ end: 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,7 +447,7 @@ 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: @@ -454,10 +455,10 @@ end: } 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 +467,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; @@ -479,7 +480,7 @@ end: 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,27 +500,11 @@ 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; } @@ -561,12 +546,12 @@ 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 +561,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 +576,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 +584,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 +593,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 +602,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 +611,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 +621,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 +644,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);