X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Futils%2Ftrimmer%2Fiterator.c;h=b7e958ac937b88facf94102095a804beb37187d5;hb=b19ff26f04df428047676dd736bd7cc9473906fe;hp=335bcfd14ea1fb4f9e123a1324588d417cea77fa;hpb=5cd6d0e5fa67c2bdd21dc153313618260595d7bc;p=babeltrace.git diff --git a/plugins/utils/trimmer/iterator.c b/plugins/utils/trimmer/iterator.c index 335bcfd1..b7e958ac 100644 --- a/plugins/utils/trimmer/iterator.c +++ b/plugins/utils/trimmer/iterator.c @@ -42,21 +42,21 @@ static gboolean close_packets(gpointer key, gpointer value, gpointer user_data) { - struct bt_packet *writer_packet = value; + const bt_packet *writer_packet = value; - bt_put(writer_packet); + bt_packet_put_ref(writer_packet); return TRUE; } BT_HIDDEN -void trimmer_iterator_finalize(struct bt_private_connection_private_notification_iterator *it) +void trimmer_iterator_finalize(bt_self_notification_iterator *it) { struct trimmer_iterator *trim_it; - trim_it = bt_private_connection_private_notification_iterator_get_user_data(it); + trim_it = bt_self_notification_iterator_get_user_data(it); BT_ASSERT(trim_it); - bt_put(trim_it->input_iterator); + bt_object_put_ref(trim_it->input_iterator); g_hash_table_foreach_remove(trim_it->packet_map, close_packets, NULL); g_hash_table_destroy(trim_it->packet_map); @@ -65,7 +65,7 @@ void trimmer_iterator_finalize(struct bt_private_connection_private_notification BT_HIDDEN enum bt_notification_iterator_status trimmer_iterator_init( - struct bt_private_connection_private_notification_iterator *iterator, + bt_self_notification_iterator *iterator, struct bt_private_port *port) { enum bt_notification_iterator_status ret = @@ -74,8 +74,8 @@ enum bt_notification_iterator_status trimmer_iterator_init( enum bt_connection_status conn_status; struct bt_private_port *input_port = NULL; struct bt_private_connection *connection = NULL; - struct bt_private_component *component = - bt_private_connection_private_notification_iterator_get_private_component(iterator); + bt_self_component *component = + bt_self_notification_iterator_get_private_component(iterator); struct trimmer_iterator *it_data = g_new0(struct trimmer_iterator, 1); if (!it_data) { @@ -84,10 +84,10 @@ enum bt_notification_iterator_status trimmer_iterator_init( } /* Create a new iterator on the upstream component. */ - input_port = bt_private_component_filter_get_input_private_port_by_name( + input_port = bt_self_component_filter_get_input_port_by_name( component, "in"); BT_ASSERT(input_port); - connection = bt_private_port_get_private_connection(input_port); + connection = bt_private_port_get_connection(input_port); BT_ASSERT(connection); conn_status = bt_private_connection_create_notification_iterator(connection, @@ -101,15 +101,15 @@ enum bt_notification_iterator_status trimmer_iterator_init( it_data->packet_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL); - it_ret = bt_private_connection_private_notification_iterator_set_user_data(iterator, + it_ret = bt_self_notification_iterator_set_user_data(iterator, it_data); if (it_ret) { goto end; } end: - bt_put(component); - bt_put(connection); - bt_put(input_port); + bt_object_put_ref(component); + bt_object_put_ref(connection); + bt_object_put_ref(input_port); return ret; } @@ -137,7 +137,7 @@ int update_lazy_bound(struct trimmer_bound *bound, const char *name, } tm.tm_sec = bound->lazy_values.ss; tm.tm_min = bound->lazy_values.mm; - tm.tm_hour = bound->lazy_values.hh; + tm.tm_hour = bound->lazy_value.hh; timeval = bt_timegm(&tm); if (timeval < 0) { BT_LOGE("Failure in bt_timegm(), incorrectly formatted %s timestamp", @@ -152,7 +152,7 @@ int update_lazy_bound(struct trimmer_bound *bound, const char *name, } tm.tm_sec = bound->lazy_values.ss; tm.tm_min = bound->lazy_values.mm; - tm.tm_hour = bound->lazy_values.hh; + tm.tm_hour = bound->lazy_value.hh; timeval = mktime(&tm); if (timeval < 0) { BT_LOGE("Failure in mktime(), incorrectly formatted %s timestamp", @@ -174,24 +174,24 @@ error: } static -struct bt_notification *evaluate_event_notification( - struct bt_notification *notification, +const bt_notification *evaluate_event_notification( + const bt_notification *notification, struct trimmer_iterator *trim_it, struct trimmer_bound *begin, struct trimmer_bound *end, bool *_event_in_range, bool *finished) { int64_t ts; int clock_ret; - struct bt_event *event = NULL, *writer_event; + const bt_event *event = NULL, *writer_event; bool in_range = true; - struct bt_clock_class *clock_class = NULL; - struct bt_trace *trace = NULL; - struct bt_stream *stream = NULL; - struct bt_stream_class *stream_class = NULL; - struct bt_clock_value *clock_value = NULL; + const bt_clock_class *clock_class = NULL; + const bt_trace *trace = NULL; + const bt_stream *stream = NULL; + const bt_stream_class *stream_class = NULL; + bt_clock_value *clock_value = NULL; bool lazy_update = false; - struct bt_notification *new_notification = NULL; - struct bt_clock_class_priority_map *cc_prio_map; + const bt_notification *new_notification = NULL; + bt_clock_class_priority_map *cc_prio_map; event = bt_notification_event_get_event(notification); BT_ASSERT(event); @@ -202,7 +202,7 @@ struct bt_notification *evaluate_event_notification( BT_ASSERT(writer_event); new_notification = bt_notification_event_create(writer_event, cc_prio_map); BT_ASSERT(new_notification); - bt_put(cc_prio_map); + bt_object_put_ref(cc_prio_map); stream = bt_event_get_stream(event); BT_ASSERT(stream); @@ -254,28 +254,28 @@ struct bt_notification *evaluate_event_notification( goto end; error: - BT_PUT(new_notification); + BT_NOTIFICATION_PUT_REF_AND_RESET(new_notification); end: - bt_put(event); - bt_put(writer_event); - bt_put(clock_class); - bt_put(trace); - bt_put(stream); - bt_put(stream_class); - bt_put(clock_value); + bt_object_put_ref(event); + bt_object_put_ref(writer_event); + bt_clock_class_put_ref(clock_class); + bt_trace_put_ref(trace); + bt_stream_put_ref(stream); + bt_stream_class_put_ref(stream_class); + bt_object_put_ref(clock_value); *_event_in_range = in_range; return new_notification; } static -int ns_from_integer_field(struct bt_field *integer, int64_t *ns) +int ns_from_integer_field(const bt_field *integer, int64_t *ns) { int ret = 0; int is_signed; uint64_t raw_clock_value; - struct bt_field_class *integer_class = NULL; - struct bt_clock_class *clock_class = NULL; - struct bt_clock_value *clock_value = NULL; + const bt_field_class *integer_class = NULL; + const bt_clock_class *clock_class = NULL; + bt_clock_value *clock_value = NULL; integer_class = bt_field_get_class(integer); BT_ASSERT(integer_class); @@ -306,9 +306,9 @@ int ns_from_integer_field(struct bt_field *integer, int64_t *ns) ret = bt_clock_value_get_value_ns_from_epoch(clock_value, ns); end: - bt_put(integer_class); - bt_put(clock_class); - bt_put(clock_value); + bt_field_class_put_ref(integer_class); + bt_clock_class_put_ref(clock_class); + bt_object_put_ref(clock_value); return ret; } @@ -329,14 +329,14 @@ static uint64_t ns_from_value(uint64_t frequency, uint64_t value) * timestamp minus the offset. */ static -int64_t get_raw_timestamp(struct bt_packet *writer_packet, +int64_t get_raw_timestamp(const bt_packet *writer_packet, int64_t timestamp) { - struct bt_clock_class *writer_clock_class; + const bt_clock_class *writer_clock_class; int64_t sec_offset, cycles_offset, ns; - struct bt_trace *writer_trace; - struct bt_stream *writer_stream; - struct bt_stream_class *writer_stream_class; + const bt_trace *writer_trace; + const bt_stream *writer_stream; + const bt_stream_class *writer_stream_class; int ret; uint64_t freq; @@ -366,34 +366,34 @@ int64_t get_raw_timestamp(struct bt_packet *writer_packet, ns += ns_from_value(freq, cycles_offset); - bt_put(writer_clock_class); - bt_put(writer_trace); - bt_put(writer_stream_class); - bt_put(writer_stream); + bt_clock_class_put_ref(writer_clock_class); + bt_trace_put_ref(writer_trace); + bt_stream_class_put_ref(writer_stream_class); + bt_stream_put_ref(writer_stream); return timestamp - ns; } static -struct bt_notification *evaluate_packet_notification( - struct bt_notification *notification, +const bt_notification *evaluate_packet_notification( + const bt_notification *notification, struct trimmer_iterator *trim_it, struct trimmer_bound *begin, struct trimmer_bound *end, bool *_packet_in_range, bool *finished) { int64_t begin_ns, pkt_begin_ns, end_ns, pkt_end_ns; bool in_range = true; - struct bt_packet *packet = NULL, *writer_packet = NULL; - struct bt_field *packet_context = NULL, + const bt_packet *packet = NULL, *writer_packet = NULL; + const bt_field *packet_context = NULL, *timestamp_begin = NULL, *timestamp_end = NULL; - struct bt_notification *new_notification = NULL; + const bt_notification *new_notification = NULL; enum bt_component_status ret; bool lazy_update = false; switch (bt_notification_get_type(notification)) { - case BT_NOTIFICATION_TYPE_PACKET_BEGIN: - packet = bt_notification_packet_begin_get_packet(notification); + case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: + packet = bt_notification_packet_beginning_get_packet(notification); BT_ASSERT(packet); writer_packet = trimmer_new_packet(trim_it, packet); BT_ASSERT(writer_packet); @@ -479,8 +479,8 @@ struct bt_notification *evaluate_packet_notification( end: switch (bt_notification_get_type(notification)) { - case BT_NOTIFICATION_TYPE_PACKET_BEGIN: - new_notification = bt_notification_packet_begin_create(writer_packet); + case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: + new_notification = bt_notification_packet_beginning_create(writer_packet); BT_ASSERT(new_notification); break; case BT_NOTIFICATION_TYPE_PACKET_END: @@ -492,20 +492,20 @@ end: } end_no_notif: *_packet_in_range = in_range; - bt_put(packet); - bt_put(writer_packet); - bt_put(packet_context); - bt_put(timestamp_begin); - bt_put(timestamp_end); + bt_packet_put_ref(packet); + bt_packet_put_ref(writer_packet); + bt_object_put_ref(packet_context); + bt_object_put_ref(timestamp_begin); + bt_object_put_ref(timestamp_end); return new_notification; } static -struct bt_notification *evaluate_stream_notification( - struct bt_notification *notification, +const bt_notification *evaluate_stream_notification( + const bt_notification *notification, struct trimmer_iterator *trim_it) { - struct bt_stream *stream; + const bt_stream *stream; stream = bt_notification_stream_end_get_stream(notification); BT_ASSERT(stream); @@ -517,13 +517,13 @@ struct bt_notification *evaluate_stream_notification( /* Return true if the notification should be forwarded. */ static enum bt_notification_iterator_status evaluate_notification( - struct bt_notification **notification, + const bt_notification **notification, struct trimmer_iterator *trim_it, struct trimmer_bound *begin, struct trimmer_bound *end, bool *in_range) { enum bt_notification_type type; - struct bt_notification *new_notification = NULL; + const bt_notification *new_notification = NULL; bool finished = false; *in_range = true; @@ -533,7 +533,7 @@ enum bt_notification_iterator_status evaluate_notification( new_notification = evaluate_event_notification(*notification, trim_it, begin, end, in_range, &finished); break; - case BT_NOTIFICATION_TYPE_PACKET_BEGIN: + case BT_NOTIFICATION_TYPE_PACKET_BEGINNING: case BT_NOTIFICATION_TYPE_PACKET_END: new_notification = evaluate_packet_notification(*notification, trim_it, begin, end, in_range, &finished); @@ -545,7 +545,7 @@ enum bt_notification_iterator_status evaluate_notification( default: break; } - BT_PUT(*notification); + BT_NOTIFICATION_PUT_REF_AND_RESET(*notification); *notification = new_notification; if (finished) { @@ -556,26 +556,26 @@ enum bt_notification_iterator_status evaluate_notification( } BT_HIDDEN -struct bt_notification_iterator_next_method_return trimmer_iterator_next( - struct bt_private_connection_private_notification_iterator *iterator) +bt_notification_iterator_next_method_return trimmer_iterator_next( + bt_self_notification_iterator *iterator) { struct trimmer_iterator *trim_it = NULL; - struct bt_private_component *component = NULL; + bt_self_component *component = NULL; struct trimmer *trimmer = NULL; - struct bt_notification_iterator *source_it = NULL; - struct bt_notification_iterator_next_method_return ret = { + bt_notification_iterator *source_it = NULL; + bt_notification_iterator_next_method_return ret = { .status = BT_NOTIFICATION_ITERATOR_STATUS_OK, .notification = NULL, }; bool notification_in_range = false; - trim_it = bt_private_connection_private_notification_iterator_get_user_data(iterator); + trim_it = bt_self_notification_iterator_get_user_data(iterator); BT_ASSERT(trim_it); - component = bt_private_connection_private_notification_iterator_get_private_component( + component = bt_self_notification_iterator_get_private_component( iterator); BT_ASSERT(component); - trimmer = bt_private_component_get_user_data(component); + trimmer = bt_self_component_get_user_data(component); BT_ASSERT(trimmer); source_it = trim_it->input_iterator; @@ -598,7 +598,7 @@ struct bt_notification_iterator_next_method_return trimmer_iterator_next( &trimmer->begin, &trimmer->end, ¬ification_in_range); if (!notification_in_range) { - BT_PUT(ret.notification); + BT_OBJECT_PUT_REF_AND_RESET(ret.notification); } if (ret.status != BT_NOTIFICATION_ITERATOR_STATUS_OK) { @@ -606,6 +606,6 @@ struct bt_notification_iterator_next_method_return trimmer_iterator_next( } } end: - bt_put(component); + bt_object_put_ref(component); return ret; }