2 * SPDX-License-Identifier: MIT
4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
7 #ifndef BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_INTERNAL_H
8 #define BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_INTERNAL_H
10 #include "common/macros.h"
11 #include "lib/object.h"
15 #include "clock-class.h"
18 struct bt_clock_class
;
20 struct bt_clock_snapshot
{
21 struct bt_object base
;
22 struct bt_clock_class
*clock_class
;
23 uint64_t value_cycles
;
24 bool ns_from_origin_overflows
;
25 int64_t ns_from_origin
;
30 void bt_clock_snapshot_set(struct bt_clock_snapshot
*clock_snapshot
)
32 BT_ASSERT_DBG(clock_snapshot
);
33 clock_snapshot
->is_set
= true;
37 void bt_clock_snapshot_reset(struct bt_clock_snapshot
*clock_snapshot
)
39 BT_ASSERT_DBG(clock_snapshot
);
40 clock_snapshot
->is_set
= false;
44 void set_ns_from_origin(struct bt_clock_snapshot
*clock_snapshot
)
46 if (bt_util_ns_from_origin_clock_class(clock_snapshot
->clock_class
,
47 clock_snapshot
->value_cycles
,
48 &clock_snapshot
->ns_from_origin
)) {
49 clock_snapshot
->ns_from_origin_overflows
= true;
54 void bt_clock_snapshot_set_raw_value(struct bt_clock_snapshot
*clock_snapshot
,
57 BT_ASSERT_DBG(clock_snapshot
);
58 clock_snapshot
->value_cycles
= cycles
;
59 set_ns_from_origin(clock_snapshot
);
60 bt_clock_snapshot_set(clock_snapshot
);
64 void bt_clock_snapshot_destroy(struct bt_clock_snapshot
*clock_snapshot
);
67 struct bt_clock_snapshot
*bt_clock_snapshot_new(struct bt_clock_class
*clock_class
);
70 struct bt_clock_snapshot
*bt_clock_snapshot_create(
71 struct bt_clock_class
*clock_class
);
74 void bt_clock_snapshot_recycle(struct bt_clock_snapshot
*clock_snapshot
);
76 #endif /* BABELTRACE_TRACE_IR_CLOCK_SNAPSHOT_INTERNAL_H */
This page took 0.032249 seconds and 4 git commands to generate.