2 * SPDX-License-Identifier: MIT
4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
5 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 #ifndef BABELTRACE_TRACE_IR_CLOCK_CLASS_INTERNAL_H
9 #define BABELTRACE_TRACE_IR_CLOCK_CLASS_INTERNAL_H
11 #include <babeltrace2/trace-ir/clock-class.h>
12 #include "lib/object.h"
13 #include "common/macros.h"
14 #include "common/common.h"
15 #include "lib/object-pool.h"
16 #include "common/uuid.h"
17 #include <babeltrace2/types.h>
18 #include "lib/property.h"
19 #include "common/assert.h"
24 #include "lib/func-status.h"
26 struct bt_clock_class
{
27 struct bt_object base
;
30 struct bt_value
*user_attributes
;
35 /* NULL or `str->str` above */
42 /* NULL or `str->str` above */
48 int64_t offset_seconds
;
49 uint64_t offset_cycles
;
54 /* NULL or `uuid` above */
58 bool origin_is_unix_epoch
;
61 * This is computed every time you call
62 * bt_clock_class_set_frequency() or
63 * bt_clock_class_set_offset(), as well as initially. It is the
64 * base offset in nanoseconds including both `offset_seconds`
65 * and `offset_cycles` above in the result. It is used to
66 * accelerate future calls to
67 * bt_clock_snapshot_get_ns_from_origin() and
68 * bt_clock_class_cycles_to_ns_from_origin().
70 * `overflows` is true if the base offset cannot be computed
71 * because of an overflow.
78 /* Pool of `struct bt_clock_snapshot *` */
79 struct bt_object_pool cs_pool
;
85 void _bt_clock_class_freeze(const struct bt_clock_class
*clock_class
);
88 # define bt_clock_class_freeze _bt_clock_class_freeze
90 # define bt_clock_class_freeze(_cc)
94 bt_bool
bt_clock_class_is_valid(struct bt_clock_class
*clock_class
);
97 int bt_clock_class_clock_value_from_ns_from_origin(
98 struct bt_clock_class
*cc
, int64_t ns_from_origin
,
102 return bt_common_clock_value_from_ns_from_origin(cc
->offset_seconds
,
103 cc
->offset_cycles
, cc
->frequency
, ns_from_origin
,
104 raw_value
) ? BT_FUNC_STATUS_OVERFLOW_ERROR
: BT_FUNC_STATUS_OK
;
107 #endif /* BABELTRACE_TRACE_IR_CLOCK_CLASS_INTERNAL_H */