X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=lib%2Ftrace-ir%2Fstream-class.c;h=5fe060c278b80554297a3a97098be47236f46d20;hb=35fa110e5bea4a35497313adf3e3d0fa09db9ff7;hp=dfef74362bd07354192305c46bf06bcb615e24c5;hpb=66fd07a51b8b2ef764ebb9c88e203c9eda982ac0;p=babeltrace.git diff --git a/lib/trace-ir/stream-class.c b/lib/trace-ir/stream-class.c index dfef7436..5fe060c2 100644 --- a/lib/trace-ir/stream-class.c +++ b/lib/trace-ir/stream-class.c @@ -1,8 +1,7 @@ /* + * Copyright 2017-2018 Philippe Proulx * Copyright 2013, 2014 Jérémie Galarneau * - * Author: 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 @@ -28,15 +27,14 @@ #include #include #include -#include -#include +#include +#include #include #include #include #include #include #include -#include #include #include #include @@ -219,7 +217,7 @@ const char *bt_stream_class_get_name(const struct bt_stream_class *stream_class) return stream_class->name.value; } -int bt_stream_class_set_name( +enum bt_stream_class_status bt_stream_class_set_name( struct bt_stream_class *stream_class, const char *name) { @@ -229,7 +227,7 @@ int bt_stream_class_set_name( g_string_assign(stream_class->name.str, name); stream_class->name.value = stream_class->name.str->str; BT_LIB_LOGV("Set stream class's name: %!+S", stream_class); - return 0; + return BT_STREAM_CLASS_STATUS_OK; } uint64_t bt_stream_class_get_id(const struct bt_stream_class *stream_class) @@ -299,7 +297,7 @@ bt_stream_class_borrow_packet_context_field_class_const( return stream_class->packet_context_fc; } -int bt_stream_class_set_packet_context_field_class( +enum bt_stream_class_status bt_stream_class_set_packet_context_field_class( struct bt_stream_class *stream_class, struct bt_field_class *field_class) { @@ -324,6 +322,12 @@ int bt_stream_class_set_packet_context_field_class( bt_stream_class_borrow_trace_class_inline(stream_class)->packet_header_fc; ret = bt_resolve_field_paths(field_class, &resolve_ctx); if (ret) { + /* + * This is the only reason for which + * bt_resolve_field_paths() can fail: anything else + * would be because a precondition is not satisfied. + */ + ret = BT_STREAM_CLASS_STATUS_NOMEM; goto end; } @@ -346,7 +350,7 @@ const struct bt_field_class *bt_stream_class_borrow_event_header_field_class_con return stream_class->event_header_fc; } -int bt_stream_class_set_event_header_field_class( +enum bt_stream_class_status bt_stream_class_set_event_header_field_class( struct bt_stream_class *stream_class, struct bt_field_class *field_class) { @@ -372,6 +376,12 @@ int bt_stream_class_set_event_header_field_class( resolve_ctx.packet_context = stream_class->packet_context_fc; ret = bt_resolve_field_paths(field_class, &resolve_ctx); if (ret) { + /* + * This is the only reason for which + * bt_resolve_field_paths() can fail: anything else + * would be because a precondition is not satisfied. + */ + ret = BT_STREAM_CLASS_STATUS_NOMEM; goto end; } @@ -395,7 +405,8 @@ bt_stream_class_borrow_event_common_context_field_class_const( return stream_class->event_common_context_fc; } -int bt_stream_class_set_event_common_context_field_class( +enum bt_stream_class_status +bt_stream_class_set_event_common_context_field_class( struct bt_stream_class *stream_class, struct bt_field_class *field_class) { @@ -422,6 +433,12 @@ int bt_stream_class_set_event_common_context_field_class( resolve_ctx.event_header = stream_class->event_header_fc; ret = bt_resolve_field_paths(field_class, &resolve_ctx); if (ret) { + /* + * This is the only reason for which + * bt_resolve_field_paths() can fail: anything else + * would be because a precondition is not satisfied. + */ + ret = BT_STREAM_CLASS_STATUS_NOMEM; goto end; } @@ -446,7 +463,7 @@ void _bt_stream_class_freeze(const struct bt_stream_class *stream_class) ((struct bt_stream_class *) stream_class)->frozen = true; } -int bt_stream_class_set_default_clock_class( +enum bt_stream_class_status bt_stream_class_set_default_clock_class( struct bt_stream_class *stream_class, struct bt_clock_class *clock_class) { @@ -459,7 +476,7 @@ int bt_stream_class_set_default_clock_class( bt_clock_class_freeze(clock_class); BT_LIB_LOGV("Set stream class's default clock class: %!+S", stream_class); - return 0; + return BT_STREAM_CLASS_STATUS_OK; } struct bt_clock_class *bt_stream_class_borrow_default_clock_class( @@ -552,14 +569,14 @@ void bt_stream_class_set_packets_have_packet_counter_snapshot( "%!+S", stream_class); } -bt_bool bt_stream_class_packets_have_default_beginning_clock_value( +bt_bool bt_stream_class_packets_have_default_beginning_clock_snapshot( const struct bt_stream_class *stream_class) { BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); - return (bt_bool) stream_class->packets_have_default_beginning_cv; + return (bt_bool) stream_class->packets_have_default_beginning_cs; } -void bt_stream_class_set_packets_have_default_beginning_clock_value( +void bt_stream_class_set_packets_have_default_beginning_clock_snapshot( struct bt_stream_class *stream_class, bt_bool value) { @@ -568,20 +585,20 @@ void bt_stream_class_set_packets_have_default_beginning_clock_value( BT_ASSERT_PRE(!value || stream_class->default_clock_class, "Stream class does not have a default clock class: %!+S", stream_class); - stream_class->packets_have_default_beginning_cv = (bool) value; + stream_class->packets_have_default_beginning_cs = (bool) value; BT_LIB_LOGV("Set stream class's " - "\"packets have default beginning clock value\" property: " + "\"packets have default beginning clock snapshot\" property: " "%!+S", stream_class); } -bt_bool bt_stream_class_packets_have_default_end_clock_value( +bt_bool bt_stream_class_packets_have_default_end_clock_snapshot( const struct bt_stream_class *stream_class) { BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); - return (bt_bool) stream_class->packets_have_default_end_cv; + return (bt_bool) stream_class->packets_have_default_end_cs; } -void bt_stream_class_set_packets_have_default_end_clock_value( +void bt_stream_class_set_packets_have_default_end_clock_snapshot( struct bt_stream_class *stream_class, bt_bool value) { @@ -590,15 +607,25 @@ void bt_stream_class_set_packets_have_default_end_clock_value( BT_ASSERT_PRE(!value || stream_class->default_clock_class, "Stream class does not have a default clock class: %!+S", stream_class); - stream_class->packets_have_default_end_cv = (bool) value; + stream_class->packets_have_default_end_cs = (bool) value; BT_LIB_LOGV("Set stream class's " - "\"packets have default end clock value\" property: " + "\"packets have default end clock snapshot\" property: " "%!+S", stream_class); } bt_bool bt_stream_class_default_clock_is_always_known( const struct bt_stream_class *stream_class) { - /* BT_CLOCK_VALUE_STATUS_UNKNOWN is not supported as of 2.0 */ + /* BT_CLOCK_SNAPSHOT_STATE_UNKNOWN is not supported as of 2.0 */ return BT_TRUE; } + +void bt_stream_class_get_ref(const struct bt_stream_class *stream_class) +{ + bt_object_get_ref(stream_class); +} + +void bt_stream_class_put_ref(const struct bt_stream_class *stream_class) +{ + bt_object_put_ref(stream_class); +}