990cb08e7d5dffa221553b73d70811b89c908137
4 * Babeltrace CTF IR - Clock class
6 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 #define BT_LOG_TAG "CLOCK-CLASS"
30 #include <babeltrace/lib-logging-internal.h>
32 #include <babeltrace/compat/uuid-internal.h>
33 #include <babeltrace/ctf-ir/clock-class-internal.h>
34 #include <babeltrace/ctf-ir/clock-value-internal.h>
35 #include <babeltrace/ctf-ir/utils.h>
36 #include <babeltrace/ref.h>
37 #include <babeltrace/compiler-internal.h>
38 #include <babeltrace/types.h>
39 #include <babeltrace/compat/string-internal.h>
41 #include <babeltrace/object-internal.h>
42 #include <babeltrace/assert-internal.h>
45 void bt_clock_class_destroy(struct bt_object
*obj
);
48 bt_bool
bt_clock_class_is_valid(struct bt_clock_class
*clock_class
)
50 return clock_class
&& clock_class
->name
;
53 int bt_clock_class_set_name(struct bt_clock_class
*clock_class
,
59 BT_LOGW_STR("Invalid parameter: clock class is NULL.");
64 if (clock_class
->frozen
) {
65 BT_LOGW("Invalid parameter: clock class is frozen: addr=%p, name=\"%s\"",
66 clock_class
, bt_clock_class_get_name(clock_class
));
71 if (!bt_identifier_is_valid(name
)) {
72 BT_LOGE("Clock class's name is not a valid CTF identifier: "
73 "addr=%p, name=\"%s\"",
79 if (clock_class
->name
) {
80 g_string_assign(clock_class
->name
, name
);
82 clock_class
->name
= g_string_new(name
);
83 if (!clock_class
->name
) {
84 BT_LOGE_STR("Failed to allocate a GString.");
90 BT_LOGV("Set clock class's name: addr=%p, name=\"%s\"",
98 bool validate_freq(struct bt_clock_class
*clock_class
,
99 const char *name
, uint64_t freq
)
101 bool is_valid
= true;
103 if (freq
== -1ULL || freq
== 0) {
104 BT_LOGW("Invalid parameter: frequency is invalid: "
105 "addr=%p, name=\"%s\", freq=%" PRIu64
,
106 clock_class
, name
, freq
);
115 struct bt_clock_class
*bt_clock_class_create(const char *name
,
119 struct bt_clock_class
*clock_class
= NULL
;
121 BT_LOGD("Creating default clock class object: name=\"%s\"",
124 if (!validate_freq(NULL
, name
, freq
)) {
125 /* validate_freq() logs errors */
129 clock_class
= g_new0(struct bt_clock_class
, 1);
131 BT_LOGE_STR("Failed to allocate one clock class.");
135 clock_class
->precision
= 1;
136 clock_class
->frequency
= freq
;
137 bt_object_init(clock_class
, bt_clock_class_destroy
);
140 ret
= bt_clock_class_set_name(clock_class
, name
);
142 BT_LOGE("Cannot set clock class's name: "
143 "addr=%p, name=\"%s\"",
149 BT_LOGD("Created clock class object: addr=%p, name=\"%s\"",
157 const char *bt_clock_class_get_name(struct bt_clock_class
*clock_class
)
159 const char *ret
= NULL
;
162 BT_LOGW_STR("Invalid parameter: clock class is NULL.");
166 if (clock_class
->name
) {
167 ret
= clock_class
->name
->str
;
174 const char *bt_clock_class_get_description(
175 struct bt_clock_class
*clock_class
)
177 const char *ret
= NULL
;
180 BT_LOGW_STR("Invalid parameter: clock class is NULL.");
184 if (clock_class
->description
) {
185 ret
= clock_class
->description
->str
;
191 int bt_clock_class_set_description(struct bt_clock_class
*clock_class
,
196 if (!clock_class
|| !desc
) {
197 BT_LOGW("Invalid parameter: clock class or description is NULL: "
198 "clock-class-addr=%p, name=\"%s\", desc-addr=%p",
199 clock_class
, bt_clock_class_get_name(clock_class
),
205 if (clock_class
->frozen
) {
206 BT_LOGW("Invalid parameter: clock class is frozen: addr=%p, name=\"%s\"",
207 clock_class
, bt_clock_class_get_name(clock_class
));
212 clock_class
->description
= g_string_new(desc
);
213 ret
= clock_class
->description
? 0 : -1;
214 BT_LOGV("Set clock class's description: addr=%p, "
215 "name=\"%s\", desc=\"%s\"",
216 clock_class
, bt_clock_class_get_name(clock_class
), desc
);
221 uint64_t bt_clock_class_get_frequency(
222 struct bt_clock_class
*clock_class
)
224 uint64_t ret
= -1ULL;
227 BT_LOGW_STR("Invalid parameter: clock class is NULL.");
231 ret
= clock_class
->frequency
;
236 int bt_clock_class_set_frequency(struct bt_clock_class
*clock_class
,
242 BT_LOGW("Invalid parameter: clock class is NULL or frequency is invalid: "
243 "addr=%p, name=\"%s\"",
244 clock_class
, bt_clock_class_get_name(clock_class
));
249 if (!validate_freq(clock_class
, bt_clock_class_get_name(clock_class
),
251 /* validate_freq() logs errors */
255 if (clock_class
->frozen
) {
256 BT_LOGW("Invalid parameter: clock class is frozen: addr=%p, name=\"%s\"",
257 clock_class
, bt_clock_class_get_name(clock_class
));
262 clock_class
->frequency
= freq
;
263 BT_LOGV("Set clock class's frequency: addr=%p, name=\"%s\", freq=%" PRIu64
,
264 clock_class
, bt_clock_class_get_name(clock_class
), freq
);
269 uint64_t bt_clock_class_get_precision(struct bt_clock_class
*clock_class
)
271 uint64_t ret
= -1ULL;
274 BT_LOGW_STR("Invalid parameter: clock class is NULL.");
278 ret
= clock_class
->precision
;
283 int bt_clock_class_set_precision(struct bt_clock_class
*clock_class
,
288 if (!clock_class
|| precision
== -1ULL) {
289 BT_LOGW("Invalid parameter: clock class is NULL or precision is invalid: "
290 "addr=%p, name=\"%s\", precision=%" PRIu64
,
291 clock_class
, bt_clock_class_get_name(clock_class
),
297 if (clock_class
->frozen
) {
298 BT_LOGW("Invalid parameter: clock class is frozen: addr=%p, name=\"%s\"",
299 clock_class
, bt_clock_class_get_name(clock_class
));
304 clock_class
->precision
= precision
;
305 BT_LOGV("Set clock class's precision: addr=%p, name=\"%s\", precision=%" PRIu64
,
306 clock_class
, bt_clock_class_get_name(clock_class
),
312 int bt_clock_class_get_offset_s(struct bt_clock_class
*clock_class
,
317 if (!clock_class
|| !offset_s
) {
318 BT_LOGW("Invalid parameter: clock class or offset pointer is NULL: "
319 "clock-class-addr=%p, name=\"%s\", offset-addr=%p",
320 clock_class
, bt_clock_class_get_name(clock_class
),
326 *offset_s
= clock_class
->offset_s
;
331 int bt_clock_class_set_offset_s(struct bt_clock_class
*clock_class
,
337 BT_LOGW_STR("Invalid parameter: clock class is NULL.");
342 if (clock_class
->frozen
) {
343 BT_LOGW("Invalid parameter: clock class is frozen: addr=%p, name=\"%s\"",
344 clock_class
, bt_clock_class_get_name(clock_class
));
349 clock_class
->offset_s
= offset_s
;
350 BT_LOGV("Set clock class's offset (seconds): "
351 "addr=%p, name=\"%s\", offset-s=%" PRId64
,
352 clock_class
, bt_clock_class_get_name(clock_class
),
358 int bt_clock_class_get_offset_cycles(struct bt_clock_class
*clock_class
,
363 if (!clock_class
|| !offset
) {
364 BT_LOGW("Invalid parameter: clock class or offset pointer is NULL: "
365 "clock-class-addr=%p, name=\"%s\", offset-addr=%p",
366 clock_class
, bt_clock_class_get_name(clock_class
),
372 *offset
= clock_class
->offset
;
377 int bt_clock_class_set_offset_cycles(struct bt_clock_class
*clock_class
,
383 BT_LOGW_STR("Invalid parameter: clock class is NULL.");
388 if (clock_class
->frozen
) {
389 BT_LOGW("Invalid parameter: clock class is frozen: addr=%p, name=\"%s\"",
390 clock_class
, bt_clock_class_get_name(clock_class
));
395 clock_class
->offset
= offset
;
396 BT_LOGV("Set clock class's offset (cycles): addr=%p, name=\"%s\", offset-cycles=%" PRId64
,
397 clock_class
, bt_clock_class_get_name(clock_class
), offset
);
402 bt_bool
bt_clock_class_is_absolute(struct bt_clock_class
*clock_class
)
407 BT_LOGW_STR("Invalid parameter: clock class is NULL.");
411 ret
= clock_class
->absolute
;
416 int bt_clock_class_set_is_absolute(struct bt_clock_class
*clock_class
,
422 BT_LOGW_STR("Invalid parameter: clock class is NULL.");
427 if (clock_class
->frozen
) {
428 BT_LOGW("Invalid parameter: clock class is frozen: addr=%p, name=\"%s\"",
429 clock_class
, bt_clock_class_get_name(clock_class
));
434 clock_class
->absolute
= !!is_absolute
;
435 BT_LOGV("Set clock class's absolute flag: addr=%p, name=\"%s\", is-absolute=%d",
436 clock_class
, bt_clock_class_get_name(clock_class
),
442 const unsigned char *bt_clock_class_get_uuid(
443 struct bt_clock_class
*clock_class
)
445 const unsigned char *ret
;
448 BT_LOGW_STR("Invalid parameter: clock class is NULL.");
453 if (!clock_class
->uuid_set
) {
454 BT_LOGV("Clock class's UUID is not set: addr=%p, name=\"%s\"",
455 clock_class
, bt_clock_class_get_name(clock_class
));
460 ret
= clock_class
->uuid
;
465 int bt_clock_class_set_uuid(struct bt_clock_class
*clock_class
,
466 const unsigned char *uuid
)
470 if (!clock_class
|| !uuid
) {
471 BT_LOGW("Invalid parameter: clock class or UUID is NULL: "
472 "clock-class-addr=%p, name=\"%s\", uuid-addr=%p",
473 clock_class
, bt_clock_class_get_name(clock_class
),
479 if (clock_class
->frozen
) {
480 BT_LOGW("Invalid parameter: clock class is frozen: addr=%p, name=\"%s\"",
481 clock_class
, bt_clock_class_get_name(clock_class
));
486 memcpy(clock_class
->uuid
, uuid
, BABELTRACE_UUID_LEN
);
487 clock_class
->uuid_set
= 1;
488 BT_LOGV("Set clock class's UUID: addr=%p, name=\"%s\", "
489 "uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
490 clock_class
, bt_clock_class_get_name(clock_class
),
491 (unsigned int) uuid
[0],
492 (unsigned int) uuid
[1],
493 (unsigned int) uuid
[2],
494 (unsigned int) uuid
[3],
495 (unsigned int) uuid
[4],
496 (unsigned int) uuid
[5],
497 (unsigned int) uuid
[6],
498 (unsigned int) uuid
[7],
499 (unsigned int) uuid
[8],
500 (unsigned int) uuid
[9],
501 (unsigned int) uuid
[10],
502 (unsigned int) uuid
[11],
503 (unsigned int) uuid
[12],
504 (unsigned int) uuid
[13],
505 (unsigned int) uuid
[14],
506 (unsigned int) uuid
[15]);
511 static uint64_t ns_from_value(uint64_t frequency
, uint64_t value
)
515 if (frequency
== 1000000000) {
518 double dblres
= ((1e9
* (double) value
) / (double) frequency
);
520 if (dblres
>= (double) UINT64_MAX
) {
521 /* Overflows uint64_t */
524 ns
= (uint64_t) dblres
;
532 void bt_clock_class_freeze(struct bt_clock_class
*clock_class
)
535 BT_LOGW_STR("Invalid parameter: clock class is NULL.");
539 if (!clock_class
->frozen
) {
540 BT_LOGD("Freezing clock class: addr=%p, name=\"%s\"",
541 clock_class
, bt_clock_class_get_name(clock_class
));
542 clock_class
->frozen
= 1;
547 void bt_clock_class_serialize(struct bt_clock_class
*clock_class
,
548 struct metadata_context
*context
)
552 BT_LOGD("Serializing clock class's metadata: clock-class-addr=%p, "
553 "name=\"%s\", metadata-context-addr=%p", clock_class
,
554 bt_clock_class_get_name(clock_class
), context
);
556 if (!clock_class
|| !context
) {
557 BT_LOGW("Invalid parameter: clock class or metadata context is NULL: "
558 "clock-class-addr=%p, name=\"%s\", metadata-context-addr=%p",
559 clock_class
, bt_clock_class_get_name(clock_class
),
564 uuid
= clock_class
->uuid
;
565 g_string_append(context
->string
, "clock {\n");
566 g_string_append_printf(context
->string
, "\tname = %s;\n",
567 clock_class
->name
->str
);
569 if (clock_class
->uuid_set
) {
570 g_string_append_printf(context
->string
,
571 "\tuuid = \"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\";\n",
572 uuid
[0], uuid
[1], uuid
[2], uuid
[3],
573 uuid
[4], uuid
[5], uuid
[6], uuid
[7],
574 uuid
[8], uuid
[9], uuid
[10], uuid
[11],
575 uuid
[12], uuid
[13], uuid
[14], uuid
[15]);
578 if (clock_class
->description
) {
579 g_string_append_printf(context
->string
, "\tdescription = \"%s\";\n",
580 clock_class
->description
->str
);
583 g_string_append_printf(context
->string
, "\tfreq = %" PRIu64
";\n",
584 clock_class
->frequency
);
585 g_string_append_printf(context
->string
, "\tprecision = %" PRIu64
";\n",
586 clock_class
->precision
);
587 g_string_append_printf(context
->string
, "\toffset_s = %" PRIu64
";\n",
588 clock_class
->offset_s
);
589 g_string_append_printf(context
->string
, "\toffset = %" PRIu64
";\n",
590 clock_class
->offset
);
591 g_string_append_printf(context
->string
, "\tabsolute = %s;\n",
592 clock_class
->absolute
? "true" : "false");
593 g_string_append(context
->string
, "};\n\n");
597 void bt_clock_class_destroy(struct bt_object
*obj
)
599 struct bt_clock_class
*clock_class
;
601 clock_class
= container_of(obj
, struct bt_clock_class
, base
);
602 BT_LOGD("Destroying clock class: addr=%p, name=\"%s\"",
603 obj
, bt_clock_class_get_name(clock_class
));
604 if (clock_class
->name
) {
605 g_string_free(clock_class
->name
, TRUE
);
607 if (clock_class
->description
) {
608 g_string_free(clock_class
->description
, TRUE
);
615 void bt_clock_value_destroy(struct bt_object
*obj
)
617 struct bt_clock_value
*value
;
623 value
= container_of(obj
, struct bt_clock_value
, base
);
624 BT_LOGD("Destroying clock value: addr=%p, clock-class-addr=%p, "
625 "clock-class-name=\"%s\"", obj
, value
->clock_class
,
626 bt_clock_class_get_name(value
->clock_class
));
627 bt_put(value
->clock_class
);
632 void set_ns_from_epoch(struct bt_clock_value
*clock_value
)
634 struct bt_clock_class
*clock_class
= clock_value
->clock_class
;
640 /* Initialize nanosecond timestamp to clock's offset in seconds */
641 if (clock_class
->offset_s
<= (INT64_MIN
/ 1000000000) ||
642 clock_class
->offset_s
>= (INT64_MAX
/ 1000000000)) {
644 * Overflow: offset in seconds converted to nanoseconds
645 * is outside the int64_t range.
647 clock_value
->ns_from_epoch_overflows
= true;
651 clock_value
->ns_from_epoch
= clock_class
->offset_s
* (int64_t) 1000000000;
653 /* Add offset in cycles */
654 if (clock_class
->offset
< 0) {
655 cycles
= (uint64_t) (-clock_class
->offset
);
657 cycles
= (uint64_t) clock_class
->offset
;
660 u_ns
= ns_from_value(clock_class
->frequency
, cycles
);
662 if (u_ns
== -1ULL || u_ns
>= INT64_MAX
) {
664 * Overflow: offset in cycles converted to nanoseconds
665 * is outside the int64_t range.
667 clock_value
->ns_from_epoch_overflows
= true;
671 s_ns
= (int64_t) u_ns
;
672 BT_ASSERT(s_ns
>= 0);
674 if (clock_class
->offset
< 0) {
675 if (clock_value
->ns_from_epoch
>= 0) {
677 * Offset in cycles is negative so it must also
678 * be negative once converted to nanoseconds.
684 diff
= clock_value
->ns_from_epoch
- INT64_MIN
;
688 * Overflow: current timestamp in nanoseconds
689 * plus the offset in cycles converted to
690 * nanoseconds is outside the int64_t range.
692 clock_value
->ns_from_epoch_overflows
= true;
697 * Offset in cycles is negative so it must also be
698 * negative once converted to nanoseconds.
702 if (clock_value
->ns_from_epoch
<= 0) {
706 diff
= INT64_MAX
- clock_value
->ns_from_epoch
;
710 * Overflow: current timestamp in nanoseconds
711 * plus the offset in cycles converted to
712 * nanoseconds is outside the int64_t range.
714 clock_value
->ns_from_epoch_overflows
= true;
720 clock_value
->ns_from_epoch
+= s_ns
;
722 /* Add clock value (cycles) */
723 u_ns
= ns_from_value(clock_class
->frequency
, clock_value
->value
);
725 if (u_ns
== -1ULL || u_ns
>= INT64_MAX
) {
727 * Overflow: value converted to nanoseconds is outside
730 clock_value
->ns_from_epoch_overflows
= true;
734 s_ns
= (int64_t) u_ns
;
735 BT_ASSERT(s_ns
>= 0);
737 /* Clock value (cycles) is always positive */
738 if (clock_value
->ns_from_epoch
<= 0) {
742 diff
= INT64_MAX
- clock_value
->ns_from_epoch
;
746 * Overflow: current timestamp in nanoseconds plus the
747 * clock value converted to nanoseconds is outside the
750 clock_value
->ns_from_epoch_overflows
= true;
755 clock_value
->ns_from_epoch
+= s_ns
;
758 if (clock_value
->ns_from_epoch_overflows
) {
759 clock_value
->ns_from_epoch
= 0;
763 struct bt_clock_value
*bt_clock_value_create(
764 struct bt_clock_class
*clock_class
, uint64_t value
)
766 struct bt_clock_value
*ret
= NULL
;
768 BT_LOGD("Creating clock value object: clock-class-addr=%p, "
769 "clock-class-name=\"%s\", value=%" PRIu64
, clock_class
,
770 bt_clock_class_get_name(clock_class
), value
);
773 BT_LOGW_STR("Invalid parameter: clock class is NULL.");
777 ret
= g_new0(struct bt_clock_value
, 1);
779 BT_LOGE_STR("Failed to allocate one clock value.");
783 bt_object_init(ret
, bt_clock_value_destroy
);
784 ret
->clock_class
= bt_get(clock_class
);
786 set_ns_from_epoch(ret
);
787 bt_clock_class_freeze(clock_class
);
788 BT_LOGD("Created clock value object: clock-value-addr=%p, "
789 "clock-class-addr=%p, clock-class-name=\"%s\", "
790 "ns-from-epoch=%" PRId64
", ns-from-epoch-overflows=%d",
791 ret
, clock_class
, bt_clock_class_get_name(clock_class
),
792 ret
->ns_from_epoch
, ret
->ns_from_epoch_overflows
);
798 int bt_clock_value_get_value(
799 struct bt_clock_value
*clock_value
, uint64_t *raw_value
)
803 if (!clock_value
|| !raw_value
) {
804 BT_LOGW("Invalid parameter: clock value or raw value is NULL: "
805 "clock-value-addr=%p, raw-value-addr=%p",
806 clock_value
, raw_value
);
811 *raw_value
= clock_value
->value
;
816 int bt_clock_value_get_value_ns_from_epoch(struct bt_clock_value
*value
,
817 int64_t *ret_value_ns
)
821 if (!value
|| !ret_value_ns
) {
822 BT_LOGW("Invalid parameter: clock value or return value pointer is NULL: "
823 "clock-value-addr=%p, ret-value-addr=%p",
824 value
, ret_value_ns
);
829 if (value
->ns_from_epoch_overflows
) {
830 BT_LOGW("Clock value converted to nanoseconds from Epoch overflows the signed 64-bit integer range: "
831 "clock-value-addr=%p, "
832 "clock-class-offset-s=%" PRId64
", "
833 "clock-class-offset-cycles=%" PRId64
", "
835 value
, value
->clock_class
->offset_s
,
836 value
->clock_class
->offset
,
842 *ret_value_ns
= value
->ns_from_epoch
;
848 struct bt_clock_class
*bt_clock_value_get_class(
849 struct bt_clock_value
*clock_value
)
851 struct bt_clock_class
*clock_class
= NULL
;
854 BT_LOGW_STR("Invalid parameter: clock value is NULL.");
858 clock_class
= bt_get(clock_value
->clock_class
);
865 int bt_clock_class_compare(struct bt_clock_class
*clock_class_a
,
866 struct bt_clock_class
*clock_class_b
)
869 BT_ASSERT(clock_class_a
);
870 BT_ASSERT(clock_class_b
);
873 if (strcmp(clock_class_a
->name
->str
, clock_class_b
->name
->str
) != 0) {
874 BT_LOGV("Clock classes differ: different names: "
875 "cc-a-name=\"%s\", cc-b-name=\"%s\"",
876 clock_class_a
->name
->str
,
877 clock_class_b
->name
->str
);
882 if (clock_class_a
->description
) {
883 if (!clock_class_b
->description
) {
884 BT_LOGV_STR("Clock classes differ: clock class A has a "
885 "description, but clock class B does not.");
889 if (strcmp(clock_class_a
->name
->str
, clock_class_b
->name
->str
)
891 BT_LOGV("Clock classes differ: different descriptions: "
892 "cc-a-descr=\"%s\", cc-b-descr=\"%s\"",
893 clock_class_a
->description
->str
,
894 clock_class_b
->description
->str
);
898 if (clock_class_b
->description
) {
899 BT_LOGV_STR("Clock classes differ: clock class A has "
900 "no description, but clock class B has one.");
906 if (clock_class_a
->frequency
!= clock_class_b
->frequency
) {
907 BT_LOGV("Clock classes differ: different frequencies: "
908 "cc-a-freq=%" PRIu64
", cc-b-freq=%" PRIu64
,
909 clock_class_a
->frequency
,
910 clock_class_b
->frequency
);
915 if (clock_class_a
->precision
!= clock_class_b
->precision
) {
916 BT_LOGV("Clock classes differ: different precisions: "
917 "cc-a-freq=%" PRIu64
", cc-b-freq=%" PRIu64
,
918 clock_class_a
->precision
,
919 clock_class_b
->precision
);
923 /* Offset (seconds) */
924 if (clock_class_a
->offset_s
!= clock_class_b
->offset_s
) {
925 BT_LOGV("Clock classes differ: different offsets (seconds): "
926 "cc-a-offset-s=%" PRId64
", cc-b-offset-s=%" PRId64
,
927 clock_class_a
->offset_s
,
928 clock_class_b
->offset_s
);
932 /* Offset (cycles) */
933 if (clock_class_a
->offset
!= clock_class_b
->offset
) {
934 BT_LOGV("Clock classes differ: different offsets (cycles): "
935 "cc-a-offset-s=%" PRId64
", cc-b-offset-s=%" PRId64
,
936 clock_class_a
->offset
,
937 clock_class_b
->offset
);
942 if (clock_class_a
->uuid_set
) {
943 if (!clock_class_b
->uuid_set
) {
944 BT_LOGV_STR("Clock classes differ: clock class A has a "
945 "UUID, but clock class B does not.");
949 if (memcmp(clock_class_a
->uuid
, clock_class_b
->uuid
,
950 BABELTRACE_UUID_LEN
) != 0) {
951 BT_LOGV("Clock classes differ: different UUIDs: "
952 "cc-a-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\", "
953 "cc-b-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
954 (unsigned int) clock_class_a
->uuid
[0],
955 (unsigned int) clock_class_a
->uuid
[1],
956 (unsigned int) clock_class_a
->uuid
[2],
957 (unsigned int) clock_class_a
->uuid
[3],
958 (unsigned int) clock_class_a
->uuid
[4],
959 (unsigned int) clock_class_a
->uuid
[5],
960 (unsigned int) clock_class_a
->uuid
[6],
961 (unsigned int) clock_class_a
->uuid
[7],
962 (unsigned int) clock_class_a
->uuid
[8],
963 (unsigned int) clock_class_a
->uuid
[9],
964 (unsigned int) clock_class_a
->uuid
[10],
965 (unsigned int) clock_class_a
->uuid
[11],
966 (unsigned int) clock_class_a
->uuid
[12],
967 (unsigned int) clock_class_a
->uuid
[13],
968 (unsigned int) clock_class_a
->uuid
[14],
969 (unsigned int) clock_class_a
->uuid
[15],
970 (unsigned int) clock_class_b
->uuid
[0],
971 (unsigned int) clock_class_b
->uuid
[1],
972 (unsigned int) clock_class_b
->uuid
[2],
973 (unsigned int) clock_class_b
->uuid
[3],
974 (unsigned int) clock_class_b
->uuid
[4],
975 (unsigned int) clock_class_b
->uuid
[5],
976 (unsigned int) clock_class_b
->uuid
[6],
977 (unsigned int) clock_class_b
->uuid
[7],
978 (unsigned int) clock_class_b
->uuid
[8],
979 (unsigned int) clock_class_b
->uuid
[9],
980 (unsigned int) clock_class_b
->uuid
[10],
981 (unsigned int) clock_class_b
->uuid
[11],
982 (unsigned int) clock_class_b
->uuid
[12],
983 (unsigned int) clock_class_b
->uuid
[13],
984 (unsigned int) clock_class_b
->uuid
[14],
985 (unsigned int) clock_class_b
->uuid
[15]);
989 if (clock_class_b
->uuid_set
) {
990 BT_LOGV_STR("Clock classes differ: clock class A has "
991 "no UUID, but clock class B has one.");
997 if (!!clock_class_a
->absolute
!= !!clock_class_b
->absolute
) {
998 BT_LOGV("Clock classes differ: one is absolute, the other "
999 "is not: cc-a-is-absolute=%d, cc-b-is-absolute=%d",
1000 !!clock_class_a
->absolute
,
1001 !!clock_class_b
->absolute
);
This page took 0.074457 seconds and 4 git commands to generate.