+void ctf_update_current_packet_index(struct ctf_stream_definition *stream,
+ struct packet_index *prev_index,
+ struct packet_index *cur_index)
+{
+ uint64_t events_discarded_diff;
+
+ /* Update packet index time information */
+ stream->prev_cycles_timestamp_end =
+ cur_index->ts_cycles.timestamp_end;
+ stream->prev_cycles_timestamp =
+ cur_index->ts_cycles.timestamp_begin;
+ stream->prev_real_timestamp_end =
+ cur_index->ts_real.timestamp_end;
+ stream->prev_real_timestamp =
+ cur_index->ts_real.timestamp_begin;
+
+ stream->prev_real_timestamp =
+ stream->real_timestamp;
+ stream->prev_cycles_timestamp =
+ stream->cycles_timestamp;
+
+ /* Update packet index discarded event information */
+ events_discarded_diff = cur_index->events_discarded;
+ if (prev_index) {
+ events_discarded_diff -= prev_index->events_discarded;
+ /*
+ * Deal with 32-bit wrap-around if the tracer provided a
+ * 32-bit field.
+ */
+ if (prev_index->events_discarded_len == 32) {
+ events_discarded_diff = (uint32_t) events_discarded_diff;
+ }
+ }
+ stream->events_discarded = events_discarded_diff;
+}
+