Clock snapshot API: use status
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 8 Dec 2018 19:47:56 +0000 (14:47 -0500)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 2 May 2019 20:50:15 +0000 (20:50 +0000)
`enum bt_clock_snapshot_status` is renamed to `enum
bt_clock_snapshot_state` (known or unknown), while `enum
bt_clock_snapshot_status` is the API status enumeration like with other
APIs.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
14 files changed:
include/babeltrace/graph/message-inactivity-const.h
include/babeltrace/graph/message-inactivity.h
include/babeltrace/graph/message-stream-const.h
include/babeltrace/trace-ir/clock-snapshot-const.h
include/babeltrace/trace-ir/event-const.h
include/babeltrace/trace-ir/packet-const.h
lib/graph/message/inactivity.c
lib/graph/message/stream.c
lib/trace-ir/clock-snapshot.c
lib/trace-ir/event.c
lib/trace-ir/packet.c
lib/trace-ir/stream-class.c
plugins/text/pretty/print.c
plugins/utils/muxer/muxer.c

index 9c1a825ba6aee5a2cdabdf7d3b0d87203961565e..0642c4099c544cb2d6969251acd4254ba7730b4a 100644 (file)
 /* For bt_message, bt_clock_snapshot */
 #include <babeltrace/types.h>
 
+/* For enum bt_clock_snapshot_state */
+#include <babeltrace/trace-ir/clock-snapshot-const.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-extern const bt_clock_snapshot *
+extern enum bt_clock_snapshot_state
 bt_message_inactivity_borrow_default_clock_snapshot_const(
-               const bt_message *msg);
+               const bt_message *msg, const bt_clock_snapshot **snapshot);
 
 #ifdef __cplusplus
 }
index f958eb668a73456c7b81a425aeca0842d90371eb..2549815d288f3a4f907d13d994b22dcc62c36651 100644 (file)
  * SOFTWARE.
  */
 
+#include <stdint.h>
+
 /* For bt_self_message_iterator, bt_message, bt_clock_class */
 #include <babeltrace/types.h>
 
-#include <stdint.h>
-
 #ifdef __cplusplus
 extern "C" {
 #endif
index f1c2c2ec8ee46bb7921baa5a3b88e204805421a0..7b902f0732661b94a7c68db4e9a119c4d7db25d7 100644 (file)
@@ -27,6 +27,9 @@
 /* For bt_message, bt_clock_snapshot, bt_stream */
 #include <babeltrace/types.h>
 
+/* For enum bt_clock_snapshot_state */
+#include <babeltrace/trace-ir/clock-snapshot-const.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -34,16 +37,16 @@ extern "C" {
 extern const bt_stream *bt_message_stream_beginning_borrow_stream_const(
                const bt_message *message);
 
-extern const bt_clock_snapshot *
+extern enum bt_clock_snapshot_state
 bt_message_stream_beginning_borrow_default_clock_snapshot_const(
-               const bt_message *msg);
+               const bt_message *msg, const bt_clock_snapshot **snapshot);
 
 extern const bt_stream *bt_message_stream_end_borrow_stream_const(
                const bt_message *message);
 
-extern const bt_clock_snapshot *
+extern enum bt_clock_snapshot_state
 bt_message_stream_end_borrow_default_clock_snapshot_const(
-               const bt_message *msg);
+               const bt_message *msg, const bt_clock_snapshot **snapshot);
 
 #ifdef __cplusplus
 }
index e0b0e39274a6919552bc013700c97b377ccdf0bc..e0f5f05fcd221d3431fa301d31d2435eaac5a02e 100644 (file)
 extern "C" {
 #endif
 
+enum bt_clock_snapshot_state {
+       BT_CLOCK_SNAPSHOT_STATE_KNOWN,
+       BT_CLOCK_SNAPSHOT_STATE_UNKNOWN,
+};
+
 enum bt_clock_snapshot_status {
-       BT_CLOCK_SNAPSHOT_STATUS_KNOWN,
-       BT_CLOCK_SNAPSHOT_STATUS_UNKNOWN,
+       BT_CLOCK_SNAPSHOT_STATUS_OK = 0,
+       BT_CLOCK_SNAPSHOT_STATUS_OVERFLOW = -75,
 };
 
 extern const bt_clock_class *bt_clock_snapshot_borrow_clock_class_const(
@@ -47,7 +52,7 @@ extern const bt_clock_class *bt_clock_snapshot_borrow_clock_class_const(
 extern uint64_t bt_clock_snapshot_get_value(
                const bt_clock_snapshot *clock_snapshot);
 
-extern int bt_clock_snapshot_get_ns_from_origin(
+extern enum bt_clock_snapshot_status bt_clock_snapshot_get_ns_from_origin(
                const bt_clock_snapshot *clock_snapshot,
                int64_t *ns_from_origin);
 
index 9aa4e692f0d307f79d3b3f3c3e5aab73554ea740..00b58cab4f5c42237417799c109a387f202e50c5 100644 (file)
@@ -27,7 +27,7 @@
  * http://www.efficios.com/ctf
  */
 
-/* For enum bt_clock_snapshot_status */
+/* For enum bt_clock_snapshot_state */
 #include <babeltrace/trace-ir/clock-snapshot-const.h>
 
 /* For bt_event, bt_clock_snapshot, bt_event_class, bt_field, bt_packet */
@@ -58,7 +58,7 @@ extern const bt_field *bt_event_borrow_specific_context_field_const(
 extern const bt_field *bt_event_borrow_payload_field_const(
                const bt_event *event);
 
-extern enum bt_clock_snapshot_status bt_event_borrow_default_clock_snapshot_const(
+extern enum bt_clock_snapshot_state bt_event_borrow_default_clock_snapshot_const(
                const bt_event *event,
                const bt_clock_snapshot **clock_snapshot);
 
index 877def8113682bda14341d0ba46142a36b2f849f..52a0b3059f795cc6261834bd1f0680bbe72769b6 100644 (file)
@@ -31,7 +31,7 @@
 /* For enum bt_property_availability */
 #include <babeltrace/property.h>
 
-/* For enum bt_clock_snapshot_status */
+/* For enum bt_clock_snapshot_state */
 #include <babeltrace/trace-ir/clock-snapshot-const.h>
 
 /*
@@ -56,12 +56,13 @@ const bt_field *bt_packet_borrow_context_field_const(
                const bt_packet *packet);
 
 extern
-enum bt_clock_snapshot_status bt_packet_borrow_default_beginning_clock_snapshot_const(
+enum bt_clock_snapshot_state
+bt_packet_borrow_default_beginning_clock_snapshot_const(
                const bt_packet *packet,
                const bt_clock_snapshot **clock_snapshot);
 
 extern
-enum bt_clock_snapshot_status bt_packet_borrow_default_end_clock_valeu_const(
+enum bt_clock_snapshot_state bt_packet_borrow_default_end_clock_snapshot_const(
                const bt_packet *packet,
                const bt_clock_snapshot **clock_snapshot);
 
index f61f1fdcaf0bf9b698f58850856001fdc8ac3e9d..7a766677b3dea5d6f5d6167b3d7c828427a486bd 100644 (file)
@@ -99,13 +99,15 @@ void bt_message_inactivity_set_default_clock_snapshot(
                "%![msg-]+n, value=%" PRIu64, msg, value_cycles);
 }
 
-const struct bt_clock_snapshot *
+extern enum bt_clock_snapshot_state
 bt_message_inactivity_borrow_default_clock_snapshot_const(
-               const struct bt_message *msg)
+               const bt_message *msg, const bt_clock_snapshot **snapshot)
 {
        struct bt_message_inactivity *inactivity = (void *) msg;
 
        BT_ASSERT_PRE_NON_NULL(msg, "Message");
+       BT_ASSERT_PRE_NON_NULL(snapshot, "Clock snapshot (output)");
        BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_INACTIVITY);
-       return inactivity->default_cs;
+       *snapshot = inactivity->default_cs;
+       return BT_CLOCK_SNAPSHOT_STATE_KNOWN;
 }
index d2483b4b058b8bcda7ad3fcf7edf0c8b3501b75c..fe35f1f65e3562c5ad0a704fa347abd5971338f9 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <babeltrace/assert-pre-internal.h>
 #include <babeltrace/compiler-internal.h>
+#include <babeltrace/trace-ir/clock-snapshot-const.h>
 #include <babeltrace/trace-ir/stream-internal.h>
 #include <babeltrace/trace-ir/stream-class.h>
 #include <babeltrace/trace-ir/stream-class-internal.h>
@@ -127,14 +128,17 @@ void bt_message_stream_end_set_default_clock_snapshot(
                "value=%" PRIu64, value_cycles);
 }
 
-struct bt_clock_snapshot *bt_message_stream_end_borrow_default_clock_snapshot(
-               struct bt_message *msg)
+enum bt_clock_snapshot_state
+bt_message_stream_end_borrow_default_clock_snapshot_const(
+               const bt_message *msg, const bt_clock_snapshot **snapshot)
 {
        struct bt_message_stream_end *stream_end = (void *) msg;
 
        BT_ASSERT_PRE_NON_NULL(msg, "Message");
+       BT_ASSERT_PRE_NON_NULL(snapshot, "Clock snapshot (output)");
        BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_STREAM_END);
-       return stream_end->default_cs;
+       *snapshot = stream_end->default_cs;
+       return BT_CLOCK_SNAPSHOT_STATE_KNOWN;
 }
 
 static
@@ -229,12 +233,15 @@ void bt_message_stream_beginning_set_default_clock_snapshot(
                "value=%" PRIu64, value_cycles);
 }
 
-struct bt_clock_snapshot *bt_message_stream_beginning_borrow_default_clock_snapshot(
-               struct bt_message *msg)
+enum bt_clock_snapshot_state
+bt_message_stream_beginning_borrow_default_clock_snapshot_const(
+               const bt_message *msg, const bt_clock_snapshot **snapshot)
 {
-       struct bt_message_stream_beginning *stream_begin = (void *) msg;
+       struct bt_message_stream_beginning *stream_beginning = (void *) msg;
 
        BT_ASSERT_PRE_NON_NULL(msg, "Message");
-       BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_STREAM_BEGINNING);
-       return stream_begin->default_cs;
+       BT_ASSERT_PRE_NON_NULL(snapshot, "Clock snapshot (output)");
+       BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_STREAM_END);
+       *snapshot = stream_beginning->default_cs;
+       return BT_CLOCK_SNAPSHOT_STATE_KNOWN;
 }
index 7dcf2893fac2f0b0123f12b582c8a5f8d9560505..792b3fc08bd7ebfcdcd5b22d228a5754339d7cf3 100644 (file)
@@ -27,6 +27,7 @@
 #include <babeltrace/compat/uuid-internal.h>
 #include <babeltrace/trace-ir/clock-class-internal.h>
 #include <babeltrace/trace-ir/clock-snapshot-internal.h>
+#include <babeltrace/trace-ir/clock-snapshot-const.h>
 #include <babeltrace/compiler-internal.h>
 #include <babeltrace/types.h>
 #include <babeltrace/compat/string-internal.h>
@@ -142,10 +143,12 @@ uint64_t bt_clock_snapshot_get_value(const struct bt_clock_snapshot *clock_snaps
        return clock_snapshot->value_cycles;
 }
 
-int bt_clock_snapshot_get_ns_from_origin(const struct bt_clock_snapshot *clock_snapshot,
+enum bt_clock_snapshot_status bt_clock_snapshot_get_ns_from_origin(
+               const struct bt_clock_snapshot *clock_snapshot,
                int64_t *ret_value_ns)
 {
-       int ret = 0;
+       int ret = BT_CLOCK_SNAPSHOT_STATUS_OK;
+
        BT_ASSERT_PRE_NON_NULL(clock_snapshot, "Clock snapshot");
        BT_ASSERT_PRE_NON_NULL(ret_value_ns, "Value (ns) (output)");
        BT_ASSERT_PRE(clock_snapshot->is_set,
@@ -155,7 +158,7 @@ int bt_clock_snapshot_get_ns_from_origin(const struct bt_clock_snapshot *clock_s
                BT_LIB_LOGD("Clock snapshot, once converted to nanoseconds from origin, "
                        "overflows the signed 64-bit integer range: "
                        "%![cs-]+k", clock_snapshot);
-               ret = -1;
+               ret = BT_CLOCK_SNAPSHOT_STATUS_OVERFLOW;
                goto end;
        }
 
index 1b3a085f494fb27e2bbb3d301ea78b0c94e33a7a..8bbb1fcacfc662ecd902d933953350e0eb61cbdd 100644 (file)
@@ -349,14 +349,14 @@ void bt_event_set_default_clock_snapshot(struct bt_event *event,
                "value=%" PRIu64, event, value_cycles);
 }
 
-enum bt_clock_snapshot_status bt_event_borrow_default_clock_snapshot_const(
+enum bt_clock_snapshot_state bt_event_borrow_default_clock_snapshot_const(
                const struct bt_event *event,
                const struct bt_clock_snapshot **clock_snapshot)
 {
        BT_ASSERT_PRE_NON_NULL(event, "Event");
        BT_ASSERT_PRE_NON_NULL(clock_snapshot, "Clock snapshot (output)");
        *clock_snapshot = event->default_cs;
-       return BT_CLOCK_SNAPSHOT_STATUS_KNOWN;
+       return BT_CLOCK_SNAPSHOT_STATE_KNOWN;
 }
 
 struct bt_packet *bt_event_borrow_packet(struct bt_event *event)
index 41bd4119cd24e7023ce46759e86154a7d7b4791e..501a8249c407b63c4cfa1a8218a7239995e23317 100644 (file)
@@ -424,14 +424,14 @@ void bt_packet_set_default_beginning_clock_snapshot(struct bt_packet *packet,
                "%![packet-]+a, value=%" PRIu64, packet, value_cycles);
 }
 
-enum bt_clock_snapshot_status bt_packet_borrow_default_beginning_clock_snapshot(
+enum bt_clock_snapshot_state bt_packet_borrow_default_beginning_clock_snapshot(
                const struct bt_packet *packet,
                const struct bt_clock_snapshot **clock_snapshot)
 {
        BT_ASSERT_PRE_NON_NULL(packet, "Packet");
        BT_ASSERT_PRE_NON_NULL(clock_snapshot, "Clock snapshot (output)");
        *clock_snapshot = packet->default_beginning_cs;
-       return BT_CLOCK_SNAPSHOT_STATUS_KNOWN;
+       return BT_CLOCK_SNAPSHOT_STATE_KNOWN;
 }
 
 void bt_packet_set_default_end_clock_snapshot(struct bt_packet *packet,
@@ -456,14 +456,14 @@ void bt_packet_set_default_end_clock_snapshot(struct bt_packet *packet,
                "%![packet-]+a, value=%" PRIu64, packet, value_cycles);
 }
 
-enum bt_clock_snapshot_status bt_packet_borrow_default_end_clock_snapshot(
+enum bt_clock_snapshot_state bt_packet_borrow_default_end_clock_snapshot(
                const struct bt_packet *packet,
                const struct bt_clock_snapshot **clock_snapshot)
 {
        BT_ASSERT_PRE_NON_NULL(packet, "Packet");
        BT_ASSERT_PRE_NON_NULL(clock_snapshot, "Clock snapshot (output)");
        *clock_snapshot = packet->default_end_cs;
-       return BT_CLOCK_SNAPSHOT_STATUS_KNOWN;
+       return BT_CLOCK_SNAPSHOT_STATE_KNOWN;
 }
 
 enum bt_property_availability bt_packet_get_discarded_event_counter_snapshot(
index 9b3dd621293df3faba890837018759434fa41ef7..f8dd5999ee9a059c8659fd151eaeab2dfcc1f10a 100644 (file)
@@ -597,7 +597,7 @@ void bt_stream_class_set_packets_have_default_end_clock_snapshot(
 bt_bool bt_stream_class_default_clock_is_always_known(
                const struct bt_stream_class *stream_class)
 {
-       /* BT_CLOCK_SNAPSHOT_STATUS_UNKNOWN is not supported as of 2.0 */
+       /* BT_CLOCK_SNAPSHOT_STATE_UNKNOWN is not supported as of 2.0 */
        return BT_TRUE;
 }
 
index cdbbc1b66084804ed5c8411ab56a6e2b8aa5522f..3661a64a15c42d63719d5bb712c5aa647492d7d4 100644 (file)
@@ -82,10 +82,10 @@ void print_timestamp_cycles(struct pretty_component *pretty,
 {
        const bt_clock_snapshot *clock_snapshot;
        uint64_t cycles;
-       enum bt_clock_snapshot_status cv_status;
+       enum bt_clock_snapshot_state cs_state;
 
-       cv_status = bt_event_borrow_default_clock_snapshot_const(event, &clock_snapshot);
-       if (cv_status != BT_CLOCK_SNAPSHOT_STATUS_KNOWN || !clock_snapshot) {
+       cs_state = bt_event_borrow_default_clock_snapshot_const(event, &clock_snapshot);
+       if (cs_state != BT_CLOCK_SNAPSHOT_STATE_KNOWN || !clock_snapshot) {
                g_string_append(pretty->string, "????????????????????");
                return;
        }
@@ -223,7 +223,7 @@ int print_event_timestamp(struct pretty_component *pretty,
        const bt_stream *stream = NULL;
        const bt_stream_class *stream_class = NULL;
        const bt_clock_snapshot *clock_snapshot = NULL;
-       enum bt_clock_snapshot_status cv_status;
+       enum bt_clock_snapshot_state cs_state;
 
        stream = bt_event_borrow_stream_const(event);
        if (!stream) {
@@ -237,9 +237,9 @@ int print_event_timestamp(struct pretty_component *pretty,
                goto end;
        }
 
-       cv_status = bt_event_borrow_default_clock_snapshot_const(event,
+       cs_state = bt_event_borrow_default_clock_snapshot_const(event,
                &clock_snapshot);
-       if (cv_status != BT_CLOCK_SNAPSHOT_STATUS_KNOWN || !clock_snapshot) {
+       if (cs_state != BT_CLOCK_SNAPSHOT_STATE_KNOWN || !clock_snapshot) {
                /* No default clock value: skip the timestamp without an error */
                goto end;
        }
@@ -256,7 +256,7 @@ int print_event_timestamp(struct pretty_component *pretty,
                print_timestamp_cycles(pretty, event);
        } else {
                clock_snapshot = NULL;
-               cv_status = bt_event_borrow_default_clock_snapshot_const(event,
+               cs_state = bt_event_borrow_default_clock_snapshot_const(event,
                        &clock_snapshot);
                print_timestamp_wall(pretty, clock_snapshot);
        }
index 077a8f8d3d3323203c4017711498ebd0d8376a26..82344b723a42590900e2e13b3c1d81c9ca7da25c 100644 (file)
@@ -608,7 +608,7 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp,
        int ret = 0;
        const unsigned char *cc_uuid;
        const char *cc_name;
-       enum bt_clock_snapshot_status cv_status = BT_CLOCK_SNAPSHOT_STATUS_KNOWN;
+       enum bt_clock_snapshot_state cs_state = BT_CLOCK_SNAPSHOT_STATE_KNOWN;
 
        BT_ASSERT(msg);
        BT_ASSERT(ts_ns);
@@ -622,14 +622,14 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp,
        case BT_MESSAGE_TYPE_EVENT:
                event = bt_message_event_borrow_event_const(msg);
                BT_ASSERT(event);
-               cv_status = bt_event_borrow_default_clock_snapshot_const(event,
+               cs_state = bt_event_borrow_default_clock_snapshot_const(event,
                        &clock_snapshot);
                break;
 
        case BT_MESSAGE_TYPE_INACTIVITY:
-               clock_snapshot =
+               cs_state =
                        bt_message_inactivity_borrow_default_clock_snapshot_const(
-                               msg);
+                               msg, &clock_snapshot);
                break;
        default:
                /* All the other messages have a higher priority */
@@ -638,7 +638,7 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp,
                goto end;
        }
 
-       if (cv_status != BT_CLOCK_SNAPSHOT_STATUS_KNOWN) {
+       if (cs_state != BT_CLOCK_SNAPSHOT_STATE_KNOWN) {
                BT_LOGE_STR("Unsupported unknown clock snapshot.");
                ret = -1;
                goto end;
This page took 0.03318 seconds and 4 git commands to generate.