X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fgraph%2Fmessage%2Fpacket.c;h=9ed9a0c47f2eb3054553feb4402dab82f0d6d504;hb=8cc5f12befb744624f1683cda7d979d7c6cff4a5;hp=df3e0e993cbf8dd67a1e4306ff6ac39e1fb8c248;hpb=649934d212dbc58e6d11dbd9eae6bdb931e65522;p=babeltrace.git diff --git a/lib/graph/message/packet.c b/lib/graph/message/packet.c index df3e0e99..9ed9a0c4 100644 --- a/lib/graph/message/packet.c +++ b/lib/graph/message/packet.c @@ -22,24 +22,24 @@ */ #define BT_LOG_TAG "MSG-PACKET" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include static inline @@ -82,12 +82,12 @@ static inline struct bt_message *create_packet_message( struct bt_self_component_port_input_message_iterator *msg_iter, struct bt_packet *packet, struct bt_object_pool *pool, - bool with_cs, bool is_beginning, uint64_t raw_value) + bool with_cs, uint64_t raw_value) { struct bt_message_packet *message = NULL; struct bt_stream *stream; struct bt_stream_class *stream_class; - bool packet_has_default_clock_snapshot; + bool need_cs; BT_ASSERT(msg_iter); BT_ASSERT_PRE_NON_NULL(packet, "Packet"); @@ -96,23 +96,27 @@ struct bt_message *create_packet_message( stream_class = bt_stream_borrow_class(stream); BT_ASSERT(stream_class); - if (is_beginning) { - packet_has_default_clock_snapshot = - stream_class->packets_have_default_beginning_clock_snapshot; + if (pool == &msg_iter->graph->packet_begin_msg_pool) { + need_cs = stream_class->packets_have_beginning_default_clock_snapshot; } else { - packet_has_default_clock_snapshot = - stream_class->packets_have_default_end_clock_snapshot; + need_cs = stream_class->packets_have_end_default_clock_snapshot; } /* * `packet_has_default_clock_snapshot` implies that the stream * class has a default clock class (precondition). */ - BT_ASSERT_PRE((with_cs && packet_has_default_clock_snapshot) || - (!with_cs && !packet_has_default_clock_snapshot), - "Creating a packet message with a default clock snapshot, but without " - "a default clock class, or without a default clock snapshot, " - "but with a default clock class: ", + BT_ASSERT_PRE(need_cs ? with_cs : true, + "Unexpected stream class configuration when creating " + "a packet beginning or end message: " + "a default clock snapshot is needed, but none was provided: " + "%![stream-]+s, %![sc-]+S, with-cs=%d, " + "cs-val=%" PRIu64, + stream, stream_class, with_cs, raw_value); + BT_ASSERT_PRE(!need_cs ? !with_cs : true, + "Unexpected stream class configuration when creating " + "a packet beginning or end message: " + "no default clock snapshot is needed, but one was provided: " "%![stream-]+s, %![sc-]+S, with-cs=%d, " "cs-val=%" PRIu64, stream, stream_class, with_cs, raw_value); @@ -161,7 +165,7 @@ struct bt_message *bt_message_packet_beginning_create( BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); return create_packet_message(msg_iter, (void *) packet, - &msg_iter->graph->packet_begin_msg_pool, false, true, 0); + &msg_iter->graph->packet_begin_msg_pool, false, 0); } struct bt_message *bt_message_packet_beginning_create_with_default_clock_snapshot( @@ -173,7 +177,7 @@ struct bt_message *bt_message_packet_beginning_create_with_default_clock_snapsho BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); return create_packet_message(msg_iter, (void *) packet, - &msg_iter->graph->packet_begin_msg_pool, true, true, raw_value); + &msg_iter->graph->packet_begin_msg_pool, true, raw_value); } struct bt_message *bt_message_packet_end_create( @@ -185,7 +189,7 @@ struct bt_message *bt_message_packet_end_create( BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); return create_packet_message(msg_iter, (void *) packet, - &msg_iter->graph->packet_end_msg_pool, false, false, 0); + &msg_iter->graph->packet_end_msg_pool, false, 0); } struct bt_message *bt_message_packet_end_create_with_default_clock_snapshot( @@ -197,7 +201,7 @@ struct bt_message *bt_message_packet_end_create_with_default_clock_snapshot( BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); return create_packet_message(msg_iter, (void *) packet, - &msg_iter->graph->packet_end_msg_pool, true, false, raw_value); + &msg_iter->graph->packet_end_msg_pool, true, raw_value); } BT_HIDDEN