+ BT_PUT(trace);
+ bt_put(field_type);
+ return ret;
+}
+
+static
+int get_event_header_timestamp(struct bt_ctf_field *event_header, uint64_t *timestamp)
+{
+ int ret = 0;
+ struct bt_ctf_field *timestamp_field = NULL;
+ struct bt_ctf_field_type *timestamp_field_type = NULL;
+
+ timestamp_field = bt_ctf_field_structure_get_field(event_header,
+ "timestamp");
+ if (!timestamp_field) {
+ ret = -1;
+ goto end;
+ }
+
+ timestamp_field_type = bt_ctf_field_get_type(timestamp_field);
+ assert(timestamp_field_type);
+ if (bt_ctf_field_type_get_type_id(timestamp_field_type) !=
+ CTF_TYPE_INTEGER) {
+ ret = -1;
+ goto end;
+ }
+
+ if (bt_ctf_field_type_integer_get_signed(timestamp_field_type)) {
+ int64_t val;
+
+ ret = bt_ctf_field_signed_integer_get_value(timestamp_field,
+ &val);
+ if (ret) {
+ goto end;
+ }
+ *timestamp = (uint64_t) val;
+ } else {
+ ret = bt_ctf_field_unsigned_integer_get_value(timestamp_field,
+ timestamp);
+ if (ret) {
+ goto end;
+ }