1 #ifndef BABELTRACE_CTF_IR_PACKET_INTERNAL_H
2 #define BABELTRACE_CTF_IR_PACKET_INTERNAL_H
5 * Babeltrace - CTF IR: Stream packet internal
7 * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 #include <babeltrace/assert-internal.h>
30 #include <babeltrace/ctf-ir/packet.h>
31 #include <babeltrace/ctf-ir/fields.h>
32 #include <babeltrace/ctf-ir/stream.h>
33 #include <babeltrace/ctf-ir/field-wrapper-internal.h>
34 #include <babeltrace/object-internal.h>
35 #include <babeltrace/babeltrace-internal.h>
36 #include <babeltrace/ctf-ir/clock-value-set-internal.h>
38 struct bt_packet_prop_uint64
{
39 enum bt_packet_property_availability avail
;
44 struct bt_object base
;
45 struct bt_field_wrapper
*header
;
46 struct bt_field_wrapper
*context
;
47 struct bt_stream
*stream
;
48 struct bt_clock_value_set begin_cv_set
;
49 struct bt_clock_value_set end_cv_set
;
50 struct bt_packet_prop_uint64 discarded_event_counter
;
51 struct bt_packet_prop_uint64 seq_num
;
52 struct bt_packet_prop_uint64 discarded_event_count
;
53 struct bt_packet_prop_uint64 discarded_packet_count
;
58 * We keep this here to avoid keeping a reference on the
59 * previous packet object: those properties are
60 * snapshots of the previous packet's properties when
61 * calling bt_packet_create(). We know that the previous
62 * packet's properties do not change afterwards because
63 * we freeze the previous packet when bt_packet_create()
66 enum bt_packet_previous_packet_availability avail
;
67 struct bt_packet_prop_uint64 discarded_event_counter
;
68 struct bt_packet_prop_uint64 seq_num
;
70 enum bt_packet_property_availability avail
;
72 /* Owned by this (copy of previous packet's or NULL) */
73 struct bt_clock_value
*cv
;
81 void _bt_packet_set_is_frozen(struct bt_packet
*packet
, bool is_frozen
);
84 # define bt_packet_set_is_frozen _bt_packet_set_is_frozen
86 # define bt_packet_set_is_frozen(_packet, _is_frozen)
87 #endif /* BT_DEV_MODE */
90 struct bt_packet
*bt_packet_new(struct bt_stream
*stream
);
93 void bt_packet_recycle(struct bt_packet
*packet
);
96 void bt_packet_destroy(struct bt_packet
*packet
);
99 * Sets a packet's properties using its current context fields and its
100 * previous packet's snapshotted properties (if any). The packet context
101 * field must not be modified until the packet is recycled.
103 * This function does NOT set the `props_are_set` flag (does not
104 * validate the properties): call bt_packet_validate_properties() to
105 * mark the properties as definitely cached.
108 int bt_packet_set_properties(struct bt_packet
*packet
);
111 void bt_packet_invalidate_properties(struct bt_packet
*packet
)
114 packet
->props_are_set
= false;
118 void bt_packet_validate_properties(struct bt_packet
*packet
)
121 packet
->props_are_set
= true;
124 #endif /* BABELTRACE_CTF_IR_PACKET_INTERNAL_H */