X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Fgraph%2Fmessage%2Fpacket.c;h=8baa25fc2b575ee80baf9e671136753f5e1cc9f5;hb=d5b13b9b6a434797f856547be1ca6a59f70ba530;hp=b00f2dfc0b7026c540affb5787f21d7c79377387;hpb=26fc5aedf48df3f1654fe4d0b6ada1a10cd804f2;p=babeltrace.git diff --git a/src/lib/graph/message/packet.c b/src/lib/graph/message/packet.c index b00f2dfc..8baa25fc 100644 --- a/src/lib/graph/message/packet.c +++ b/src/lib/graph/message/packet.c @@ -1,31 +1,16 @@ /* + * SPDX-License-Identifier: MIT + * * Copyright 2017-2018 Philippe Proulx * Copyright 2016 Jérémie Galarneau - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ #define BT_LOG_TAG "LIB/MSG-PACKET" #include "lib/logging.h" -#include "lib/assert-pre.h" -#include "lib/assert-post.h" +#include + +#include "lib/assert-cond.h" #include "compat/compiler.h" #include #include "lib/trace-ir/packet.h" @@ -34,10 +19,7 @@ #include "lib/trace-ir/stream.h" #include "lib/trace-ir/stream-class.h" #include "lib/graph/graph.h" -#include -#include -#include -#include +#include #include "common/assert.h" #include "lib/object.h" #include @@ -83,7 +65,7 @@ struct bt_message *bt_message_packet_end_new(struct bt_graph *graph) static inline struct bt_message *create_packet_message( - struct bt_self_component_port_input_message_iterator *msg_iter, + struct bt_message_iterator *msg_iter, struct bt_packet *packet, struct bt_object_pool *pool, bool with_cs, uint64_t raw_value) { @@ -93,7 +75,7 @@ struct bt_message *create_packet_message( bool need_cs; BT_ASSERT(msg_iter); - BT_ASSERT_PRE_NON_NULL(packet, "Packet"); + BT_ASSERT_PRE_PACKET_NON_NULL(packet); stream = bt_packet_borrow_stream(packet); BT_ASSERT(stream); stream_class = bt_stream_borrow_class(stream); @@ -143,7 +125,7 @@ struct bt_message *create_packet_message( message->default_cs = bt_clock_snapshot_create( stream_class->default_clock_class); if (!message->default_cs) { - bt_object_put_no_null_check(message); + bt_object_put_ref_no_null_check(message); message = NULL; goto end; } @@ -153,7 +135,7 @@ struct bt_message *create_packet_message( BT_ASSERT(!message->packet); message->packet = packet; - bt_object_get_no_null_check_no_parent_check( + bt_object_get_ref_no_null_check_no_parent_check( &message->packet->base); bt_packet_set_is_frozen(packet, true); BT_LIB_LOGD("Created packet message object: " @@ -169,10 +151,11 @@ struct bt_message *bt_message_packet_beginning_create( struct bt_self_message_iterator *self_msg_iter, const struct bt_packet *packet) { - struct bt_self_component_port_input_message_iterator *msg_iter = + struct bt_message_iterator *msg_iter = (void *) self_msg_iter; - BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); + BT_ASSERT_PRE_DEV_NO_ERROR(); + BT_ASSERT_PRE_MSG_ITER_NON_NULL(msg_iter); return create_packet_message(msg_iter, (void *) packet, &msg_iter->graph->packet_begin_msg_pool, false, 0); } @@ -181,10 +164,11 @@ struct bt_message *bt_message_packet_beginning_create_with_default_clock_snapsho struct bt_self_message_iterator *self_msg_iter, const struct bt_packet *packet, uint64_t raw_value) { - struct bt_self_component_port_input_message_iterator *msg_iter = + struct bt_message_iterator *msg_iter = (void *) self_msg_iter; - BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); + BT_ASSERT_PRE_DEV_NO_ERROR(); + BT_ASSERT_PRE_MSG_ITER_NON_NULL(msg_iter); return create_packet_message(msg_iter, (void *) packet, &msg_iter->graph->packet_begin_msg_pool, true, raw_value); } @@ -193,10 +177,11 @@ struct bt_message *bt_message_packet_end_create( struct bt_self_message_iterator *self_msg_iter, const struct bt_packet *packet) { - struct bt_self_component_port_input_message_iterator *msg_iter = + struct bt_message_iterator *msg_iter = (void *) self_msg_iter; - BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); + BT_ASSERT_PRE_DEV_NO_ERROR(); + BT_ASSERT_PRE_MSG_ITER_NON_NULL(msg_iter); return create_packet_message(msg_iter, (void *) packet, &msg_iter->graph->packet_end_msg_pool, false, 0); } @@ -205,10 +190,11 @@ struct bt_message *bt_message_packet_end_create_with_default_clock_snapshot( struct bt_self_message_iterator *self_msg_iter, const struct bt_packet *packet, uint64_t raw_value) { - struct bt_self_component_port_input_message_iterator *msg_iter = + struct bt_message_iterator *msg_iter = (void *) self_msg_iter; - BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator"); + BT_ASSERT_PRE_DEV_NO_ERROR(); + BT_ASSERT_PRE_MSG_ITER_NON_NULL(msg_iter); return create_packet_message(msg_iter, (void *) packet, &msg_iter->graph->packet_end_msg_pool, true, raw_value); } @@ -237,7 +223,7 @@ void recycle_packet_message(struct bt_message *msg, struct bt_object_pool *pool) BT_LIB_LOGD("Recycling packet message: %!+n", msg); bt_message_reset(msg); - bt_object_put_no_null_check(&packet_msg->packet->base); + bt_object_put_ref_no_null_check(&packet_msg->packet->base); if (packet_msg->default_cs) { bt_clock_snapshot_recycle(packet_msg->default_cs); @@ -280,8 +266,8 @@ struct bt_packet *bt_message_packet_beginning_borrow_packet( { struct bt_message_packet *packet_msg = (void *) message; - BT_ASSERT_PRE_NON_NULL(message, "Message"); - BT_ASSERT_PRE_MSG_IS_TYPE(message, + BT_ASSERT_PRE_DEV_MSG_NON_NULL(message); + BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(message, BT_MESSAGE_TYPE_PACKET_BEGINNING); return packet_msg->packet; } @@ -298,8 +284,8 @@ struct bt_packet *bt_message_packet_end_borrow_packet( { struct bt_message_packet *packet_msg = (void *) message; - BT_ASSERT_PRE_NON_NULL(message, "Message"); - BT_ASSERT_PRE_MSG_IS_TYPE(message, + BT_ASSERT_PRE_DEV_MSG_NON_NULL(message); + BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(message, BT_MESSAGE_TYPE_PACKET_END); return packet_msg->packet; } @@ -318,11 +304,9 @@ borrow_packet_message_default_clock_snapshot_const( { struct bt_message_packet *packet_msg = (void *) message; - BT_ASSERT(message); - BT_ASSERT_PRE(packet_msg->packet->stream->class->default_clock_class, - "Message's stream's class has no default clock class: " - "%![msg-]+n, %![sc-]+S", - message, packet_msg->packet->stream->class); + BT_ASSERT_DBG(message); + BT_ASSERT_PRE_DEV_MSG_SC_DEF_CLK_CLS(message, + packet_msg->packet->stream->class); return packet_msg->default_cs; } @@ -330,8 +314,8 @@ const struct bt_clock_snapshot * bt_message_packet_beginning_borrow_default_clock_snapshot_const( const struct bt_message *msg) { - BT_ASSERT_PRE_NON_NULL(msg, "Message"); - BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_BEGINNING); + BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg); + BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_BEGINNING); return borrow_packet_message_default_clock_snapshot_const(msg); } @@ -339,8 +323,8 @@ const struct bt_clock_snapshot * bt_message_packet_end_borrow_default_clock_snapshot_const( const struct bt_message *msg) { - BT_ASSERT_PRE_NON_NULL(msg, "Message"); - BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_END); + BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg); + BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_END); return borrow_packet_message_default_clock_snapshot_const(msg); } @@ -351,7 +335,7 @@ borrow_packet_message_stream_class_default_clock_class( { struct bt_message_packet *packet_msg = (void *) msg; - BT_ASSERT(msg); + BT_ASSERT_DBG(msg); return packet_msg->packet->stream->class->default_clock_class; } @@ -359,8 +343,8 @@ const struct bt_clock_class * bt_message_packet_beginning_borrow_stream_class_default_clock_class_const( const struct bt_message *msg) { - BT_ASSERT_PRE_NON_NULL(msg, "Message"); - BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_BEGINNING); + BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg); + BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_BEGINNING); return borrow_packet_message_stream_class_default_clock_class(msg); } @@ -368,7 +352,7 @@ const struct bt_clock_class * bt_message_packet_end_borrow_stream_class_default_clock_class_const( const struct bt_message *msg) { - BT_ASSERT_PRE_NON_NULL(msg, "Message"); - BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_END); + BT_ASSERT_PRE_DEV_MSG_NON_NULL(msg); + BT_ASSERT_PRE_DEV_MSG_HAS_TYPE(msg, BT_MESSAGE_TYPE_PACKET_END); return borrow_packet_message_stream_class_default_clock_class(msg); }