plugins/common/muxing: compare "origin is Unix epoch" property of clock classes
[babeltrace.git] / src / plugins / common / muxing / muxing.c
index a923b62ea9d6e035ef599a1d67aaeea4581122ba..5e52c4f497cdf77f17bf5e47b11c7c1aafcef5cb 100644 (file)
@@ -170,6 +170,7 @@ int compare_clock_classes(const bt_clock_class *left_cc,
        const char *left_clock_class_name, *right_clock_class_name;
        bt_uuid left_clock_class_uuid, right_clock_class_uuid;
        uint64_t left_freq, right_freq, left_prec, right_prec;
+       bool left_origin_is_unix, right_origin_is_unix;
 
        left_clock_class_uuid = bt_clock_class_get_uuid(left_cc);
        right_clock_class_uuid = bt_clock_class_get_uuid(right_cc);
@@ -188,6 +189,13 @@ int compare_clock_classes(const bt_clock_class *left_cc,
                }
        }
 
+       left_origin_is_unix = bt_clock_class_origin_is_unix_epoch(left_cc);
+       right_origin_is_unix = bt_clock_class_origin_is_unix_epoch(right_cc);
+
+       if (left_origin_is_unix != right_origin_is_unix) {
+               ret = left_origin_is_unix - right_origin_is_unix;
+               goto end;
+       }
 
        left_clock_class_name = bt_clock_class_get_name(left_cc);
        right_clock_class_name = bt_clock_class_get_name(right_cc);
@@ -232,6 +240,7 @@ int compare_streams(const bt_stream *left_stream, const bt_stream *right_stream)
        const char *left_stream_name, *right_stream_name,
              *left_stream_class_name, *right_stream_class_name;
        const bt_stream_class *left_stream_class, *right_stream_class;
+       const bt_clock_class *left_cc, *right_cc;
 
        /*
         * No need to compare stream id as it was checked earlier and if we are
@@ -339,59 +348,74 @@ int compare_streams(const bt_stream *left_stream, const bt_stream *right_stream)
                goto end;
        }
 
-       if (!bt_stream_class_supports_packets(left_stream_class)) {
-               /* Skip all packet related checks. */
-               goto end;
-       }
+       if (bt_stream_class_supports_packets(left_stream_class)) {
+               /*
+               * Compare stream class presence of discarded packets beginning default
+               * clock snapshot.
+               */
+               if (bt_stream_class_packets_have_beginning_default_clock_snapshot(left_stream_class) &&
+                               !bt_stream_class_packets_have_beginning_default_clock_snapshot(right_stream_class)) {
+                       ret = 1;
+                       goto end;
+               } else if (!bt_stream_class_packets_have_beginning_default_clock_snapshot(left_stream_class) &&
+                               bt_stream_class_packets_have_beginning_default_clock_snapshot(right_stream_class)) {
+                       ret = -1;
+                       goto end;
+               }
 
-       /*
-        * Compare stream class presence of discarded packets beginning default
-        * clock snapshot.
-        */
-       if (bt_stream_class_packets_have_beginning_default_clock_snapshot(left_stream_class) &&
-                       !bt_stream_class_packets_have_beginning_default_clock_snapshot(right_stream_class)) {
-               ret = 1;
-               goto end;
-       } else if (!bt_stream_class_packets_have_beginning_default_clock_snapshot(left_stream_class) &&
-                       bt_stream_class_packets_have_beginning_default_clock_snapshot(right_stream_class)) {
-               ret = -1;
-               goto end;
-       }
+               /*
+               * Compare stream class presence of discarded packets end default clock
+               * snapshot.
+               */
+               if (bt_stream_class_packets_have_end_default_clock_snapshot(left_stream_class) &&
+                               !bt_stream_class_packets_have_end_default_clock_snapshot(right_stream_class)) {
+                       ret = 1;
+                       goto end;
+               } else if (!bt_stream_class_packets_have_end_default_clock_snapshot(left_stream_class) &&
+                               bt_stream_class_packets_have_end_default_clock_snapshot(right_stream_class)) {
+                       ret = -1;
+                       goto end;
+               }
 
-       /*
-        * Compare stream class presence of discarded packets end default clock
-        * snapshot.
-        */
-       if (bt_stream_class_packets_have_end_default_clock_snapshot(left_stream_class) &&
-                       !bt_stream_class_packets_have_end_default_clock_snapshot(right_stream_class)) {
-               ret = 1;
-               goto end;
-       } else if (!bt_stream_class_packets_have_end_default_clock_snapshot(left_stream_class) &&
-                       bt_stream_class_packets_have_end_default_clock_snapshot(right_stream_class)) {
-               ret = -1;
-               goto end;
+               /* Compare stream class support of discarded packets. */
+               if (bt_stream_class_supports_discarded_packets(left_stream_class) &&
+                               !bt_stream_class_supports_discarded_packets(right_stream_class)) {
+                       ret = 1;
+                       goto end;
+               } else if (!bt_stream_class_supports_discarded_packets(left_stream_class) &&
+                               bt_stream_class_supports_discarded_packets(right_stream_class)) {
+                       ret = -1;
+                       goto end;
+               }
+
+               /* Compare stream class discarded packets default clock snapshot. */
+               if (bt_stream_class_discarded_packets_have_default_clock_snapshots(left_stream_class) &&
+                               !bt_stream_class_discarded_packets_have_default_clock_snapshots(right_stream_class)) {
+                       ret = 1;
+                       goto end;
+               } else if (!bt_stream_class_discarded_packets_have_default_clock_snapshots(left_stream_class) &&
+                               bt_stream_class_discarded_packets_have_default_clock_snapshots(right_stream_class)) {
+                       ret = -1;
+                       goto end;
+               }
        }
 
-       /* Compare stream class support of discarded packets. */
-       if (bt_stream_class_supports_discarded_packets(left_stream_class) &&
-                       !bt_stream_class_supports_discarded_packets(right_stream_class)) {
-               ret = 1;
-               goto end;
-       } else if (!bt_stream_class_supports_discarded_packets(left_stream_class) &&
-                       bt_stream_class_supports_discarded_packets(right_stream_class)) {
+       /* Compare the clock classes associated to the stream classes. */
+       left_cc = bt_stream_class_borrow_default_clock_class_const(left_stream_class);
+       right_cc = bt_stream_class_borrow_default_clock_class_const(right_stream_class);
+
+       if (!left_cc && !right_cc) {
+               ret = compare_clock_classes(left_cc, right_cc);
+
+               if (ret != 0) {
+                       goto end;
+               }
+       } else if (left_cc && !right_cc) {
                ret = -1;
                goto end;
-       }
-
-       /* Compare stream class discarded packets default clock snapshot. */
-       if (bt_stream_class_discarded_packets_have_default_clock_snapshots(left_stream_class) &&
-                       !bt_stream_class_discarded_packets_have_default_clock_snapshots(right_stream_class)) {
+       } else if (!left_cc && right_cc) {
                ret = 1;
                goto end;
-       } else if (!bt_stream_class_discarded_packets_have_default_clock_snapshots(left_stream_class) &&
-                       bt_stream_class_discarded_packets_have_default_clock_snapshots(right_stream_class)) {
-               ret = -1;
-               goto end;
        }
 
 end:
@@ -632,7 +656,7 @@ int compare_messages_same_type(struct messages_to_compare *msgs)
        int ret = 0;
 
        /*
-        * Both messages are of the same type, we must compare characterics of
+        * Both messages are of the same type, we must compare characteristics of
         * the messages such as the attributes of the event in a event message.
         */
        BT_ASSERT_DBG(bt_message_get_type(msgs->left.msg) ==
This page took 0.025331 seconds and 4 git commands to generate.