X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=include%2Fbabeltrace%2Fctf-ir%2Fpacket-internal.h;fp=include%2Fbabeltrace%2Fctf-ir%2Fpacket-internal.h;h=759c371a38849e023f0c12d72f94c6a9eff6c202;hp=206215bf4ca2eb558ace535d6fcb073da378829e;hb=ccf8299313561a76a88583d047d61890c6ed1d8a;hpb=35244b4cee8cb8a2b592d18ec00f10efc3508df4 diff --git a/include/babeltrace/ctf-ir/packet-internal.h b/include/babeltrace/ctf-ir/packet-internal.h index 206215bf..759c371a 100644 --- a/include/babeltrace/ctf-ir/packet-internal.h +++ b/include/babeltrace/ctf-ir/packet-internal.h @@ -25,7 +25,9 @@ * SOFTWARE. */ +#include #include +#include #include #include #include @@ -33,6 +35,11 @@ #include #include +struct bt_packet_prop_uint64 { + enum bt_packet_property_availability avail; + uint64_t value; +}; + struct bt_packet { struct bt_object base; struct bt_field_wrapper *header; @@ -40,6 +47,33 @@ struct bt_packet { struct bt_stream *stream; struct bt_clock_value_set begin_cv_set; struct bt_clock_value_set end_cv_set; + struct bt_packet_prop_uint64 discarded_event_counter; + struct bt_packet_prop_uint64 seq_num; + struct bt_packet_prop_uint64 discarded_event_count; + struct bt_packet_prop_uint64 discarded_packet_count; + bool props_are_set; + + struct { + /* + * We keep this here to avoid keeping a reference on the + * previous packet object: those properties are + * snapshots of the previous packet's properties when + * calling bt_packet_create(). We know that the previous + * packet's properties do not change afterwards because + * we freeze the previous packet when bt_packet_create() + * is successful. + */ + enum bt_packet_previous_packet_availability avail; + struct bt_packet_prop_uint64 discarded_event_counter; + struct bt_packet_prop_uint64 seq_num; + struct { + enum bt_packet_property_availability avail; + + /* Owned by this (copy of previous packet's or NULL) */ + struct bt_clock_value *cv; + } default_end_cv; + } prev_packet_info; + int frozen; }; @@ -61,4 +95,30 @@ void bt_packet_recycle(struct bt_packet *packet); BT_HIDDEN void bt_packet_destroy(struct bt_packet *packet); +/* + * Sets a packet's properties using its current context fields and its + * previous packet's snapshotted properties (if any). The packet context + * field must not be modified until the packet is recycled. + * + * This function does NOT set the `props_are_set` flag (does not + * validate the properties): call bt_packet_validate_properties() to + * mark the properties as definitely cached. + */ +BT_HIDDEN +int bt_packet_set_properties(struct bt_packet *packet); + +static inline +void bt_packet_invalidate_properties(struct bt_packet *packet) +{ + BT_ASSERT(packet); + packet->props_are_set = false; +} + +static inline +void bt_packet_validate_properties(struct bt_packet *packet) +{ + BT_ASSERT(packet); + packet->props_are_set = true; +} + #endif /* BABELTRACE_CTF_IR_PACKET_INTERNAL_H */