From 0c5e21000b711a86f360fc29220ea6d6b6b830fa Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Tue, 19 Feb 2019 15:08:26 -0500 Subject: [PATCH] lib: Pass raw snapshot value to bt_message_inactivity_create() Having both bt_message_inactivity_create(bt_self_message_iterator *message_iterator, const bt_clock_class *default_clock_class); and bt_message_inactivity_set_default_clock_snapshot( bt_message *msg, uint64_t raw_value); is redundant given that setting the clock snapshot value is required to send the inactivity message down the graph. This commit makes it so that the value of the snapshot is required at the creation of the inactivity message. Signed-off-by: Francis Deslauriers --- include/babeltrace/graph/message-inactivity.h | 5 +---- lib/graph/message/inactivity.c | 21 +++++-------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/include/babeltrace/graph/message-inactivity.h b/include/babeltrace/graph/message-inactivity.h index d2d43d01..e7d1c404 100644 --- a/include/babeltrace/graph/message-inactivity.h +++ b/include/babeltrace/graph/message-inactivity.h @@ -35,10 +35,7 @@ extern "C" { extern bt_message *bt_message_inactivity_create( bt_self_message_iterator *message_iterator, - const bt_clock_class *default_clock_class); - -extern void bt_message_inactivity_set_default_clock_snapshot( - bt_message *msg, uint64_t raw_value); + const bt_clock_class *default_clock_class, uint64_t raw_value); #ifdef __cplusplus } diff --git a/lib/graph/message/inactivity.c b/lib/graph/message/inactivity.c index ada6dc67..9cee20e6 100644 --- a/lib/graph/message/inactivity.c +++ b/lib/graph/message/inactivity.c @@ -51,7 +51,8 @@ void bt_message_inactivity_destroy(struct bt_object *obj) struct bt_message *bt_message_inactivity_create( struct bt_self_message_iterator *self_msg_iter, - const struct bt_clock_class *default_clock_class) + const struct bt_clock_class *default_clock_class, + uint64_t value_cycles) { struct bt_self_component_port_input_message_iterator *msg_iter = (void *) self_msg_iter; @@ -61,8 +62,8 @@ struct bt_message *bt_message_inactivity_create( BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); BT_ASSERT_PRE_NON_NULL(default_clock_class, "Default clock class"); BT_LIB_LOGD("Creating inactivity message object: " - "%![iter-]+i, %![default-cc-]+K", msg_iter, - default_clock_class); + "%![iter-]+i, %![default-cc-]+K, value=%" PRIu64, msg_iter, + default_clock_class, value_cycles); message = g_new0(struct bt_message_inactivity, 1); if (!message) { BT_LOGE_STR("Failed to allocate one inactivity message."); @@ -77,6 +78,7 @@ struct bt_message *bt_message_inactivity_create( if (!message->default_cs) { goto error; } + bt_clock_snapshot_set_raw_value(message->default_cs, value_cycles); BT_LIB_LOGD("Created inactivity message object: %!+n", ret_msg); goto end; @@ -88,19 +90,6 @@ end: return (void *) ret_msg; } -void bt_message_inactivity_set_default_clock_snapshot( - struct bt_message *msg, uint64_t value_cycles) -{ - struct bt_message_inactivity *inactivity = (void *) msg; - - BT_ASSERT_PRE_NON_NULL(msg, "Message"); - BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_INACTIVITY); - BT_ASSERT_PRE_HOT(msg, "Message", ": %!+n", msg); - bt_clock_snapshot_set_raw_value(inactivity->default_cs, value_cycles); - BT_LIB_LOGV("Set inactivity message's default clock snapshot: " - "%![msg-]+n, value=%" PRIu64, msg, value_cycles); -} - extern enum bt_clock_snapshot_state bt_message_inactivity_borrow_default_clock_snapshot_const( const bt_message *msg, const bt_clock_snapshot **snapshot) -- 2.34.1