X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Fgraph%2Fmessage%2Fmessage.h;h=4c997164e8d72db475e91a56ef5a0430fc33d26c;hb=f2fb1b3297ca0bc13b53189a063b63944be7fae9;hp=98d27b9301c4988458156756ed35202ff56d346b;hpb=91d8147391efdc4d42cc4e1c171a65c0372a008f;p=babeltrace.git diff --git a/src/lib/graph/message/message.h b/src/lib/graph/message/message.h index 98d27b93..4c997164 100644 --- a/src/lib/graph/message/message.h +++ b/src/lib/graph/message/message.h @@ -24,6 +24,11 @@ * SOFTWARE. */ +/* Protection: this file uses BT_LIB_LOG*() macros directly */ +#ifndef BT_LIB_LOG_SUPPORTED +# error Please include "lib/logging.h" before including this file. +#endif + #include "common/macros.h" #include "lib/object.h" #include "common/assert.h" @@ -33,6 +38,11 @@ #include "lib/object-pool.h" #include +/* Protection: this file uses BT_LIB_LOG*() macros directly */ +#ifndef BT_LIB_LOG_SUPPORTED +# error Please include "lib/logging.h" before including this file. +#endif + typedef struct bt_stream *(*get_stream_func)( struct bt_message *message); @@ -45,11 +55,23 @@ struct bt_message { struct bt_graph *graph; }; -#define BT_ASSERT_PRE_MSG_IS_TYPE(_msg, _type) \ - BT_ASSERT_PRE(((struct bt_message *) (_msg))->type == (_type), \ - "Message has the wrong type: expected-type=%s, " \ - "%![msg-]+n", bt_message_type_string(_type), \ - (_msg)) +#define _BT_ASSERT_PRE_MSG_IS_TYPE_COND(_msg, _type) \ + (((struct bt_message *) (_msg))->type == (_type)) + +#define _BT_ASSERT_PRE_MSG_IS_TYPE_FMT \ + "Message has the wrong type: expected-type=%s, %![msg-]+n" + +#define BT_ASSERT_PRE_MSG_IS_TYPE(_msg, _type) \ + BT_ASSERT_PRE( \ + _BT_ASSERT_PRE_MSG_IS_TYPE_COND((_msg), (_type)), \ + _BT_ASSERT_PRE_MSG_IS_TYPE_FMT, \ + bt_message_type_string(_type), (_msg)) + +#define BT_ASSERT_PRE_DEV_MSG_IS_TYPE(_msg, _type) \ + BT_ASSERT_PRE_DEV( \ + _BT_ASSERT_PRE_MSG_IS_TYPE_COND((_msg), (_type)), \ + _BT_ASSERT_PRE_MSG_IS_TYPE_FMT, \ + bt_message_type_string(_type), (_msg)) BT_HIDDEN void bt_message_init(struct bt_message *message, @@ -74,10 +96,9 @@ struct bt_message *bt_message_create_from_pool( struct bt_message *msg = bt_object_pool_create_object(pool); if (G_UNLIKELY(!msg)) { -#ifdef BT_LIB_LOGE - BT_LIB_LOGE("Cannot allocate one message from message pool: " + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot allocate one message from message pool: " "%![pool-]+o, %![graph-]+g", pool, graph); -#endif goto error; } @@ -113,23 +134,19 @@ const char *bt_message_type_string(enum bt_message_type type) { switch (type) { case BT_MESSAGE_TYPE_EVENT: - return "BT_MESSAGE_TYPE_EVENT"; + return "EVENT"; case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY: - return "BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY"; + return "MESSAGE_ITERATOR_INACTIVITY"; case BT_MESSAGE_TYPE_STREAM_BEGINNING: - return "BT_MESSAGE_TYPE_STREAM_BEGINNING"; + return "STREAM_BEGINNING"; case BT_MESSAGE_TYPE_STREAM_END: - return "BT_MESSAGE_TYPE_STREAM_END"; + return "STREAM_END"; case BT_MESSAGE_TYPE_PACKET_BEGINNING: - return "BT_MESSAGE_TYPE_PACKET_BEGINNING"; + return "PACKET_BEGINNING"; case BT_MESSAGE_TYPE_PACKET_END: - return "BT_MESSAGE_TYPE_PACKET_END"; - case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING: - return "BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING"; - case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END: - return "BT_MESSAGE_TYPE_STREAM_ACTIVITY_END"; + return "PACKET_END"; case BT_MESSAGE_TYPE_DISCARDED_EVENTS: - return "BT_MESSAGE_TYPE_DISCARDED_EVENTS"; + return "DISCARDED_EVENTS"; default: return "(unknown)"; }