Make API CTF-agnostic
[babeltrace.git] / include / babeltrace / ctf-ir / clock-value-internal.h
index 7284a35f64a4769fac4e516b84f40e98ce3180af..1beb9fac732b8eb2bebd322c9357ae56af5bcfa2 100644 (file)
  * SOFTWARE.
  */
 
+#include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/object-internal.h>
+#include <babeltrace/ctf-ir/clock-class-internal.h>
+#include <babeltrace/ctf-ir/utils-internal.h>
 #include <stdbool.h>
 #include <stdint.h>
 
-struct bt_ctf_clock_class;
+struct bt_clock_class;
 
-struct bt_ctf_clock_value {
+struct bt_clock_value {
        struct bt_object base;
-       struct bt_ctf_clock_class *clock_class;
-       uint64_t value;
-       bool ns_from_epoch_overflows;
-       int64_t ns_from_epoch;
+       struct bt_clock_class *clock_class;
+       uint64_t value_cycles;
+       bool ns_from_origin_overflows;
+       int64_t ns_from_origin;
+       bool is_set;
 };
 
+static inline
+void bt_clock_value_set(struct bt_clock_value *clock_value)
+{
+       BT_ASSERT(clock_value);
+       clock_value->is_set = true;
+}
+
+static inline
+void bt_clock_value_reset(struct bt_clock_value *clock_value)
+{
+       BT_ASSERT(clock_value);
+       clock_value->is_set = false;
+}
+
+static inline
+void set_ns_from_origin(struct bt_clock_value *clock_value)
+{
+       if (bt_util_ns_from_origin(clock_value->clock_class, clock_value->value_cycles,
+                       &clock_value->ns_from_origin)) {
+               clock_value->ns_from_origin_overflows = true;
+       }
+
+}
+
+static inline
+void bt_clock_value_set_raw_value(struct bt_clock_value *clock_value,
+               uint64_t cycles)
+{
+       BT_ASSERT(clock_value);
+       clock_value->value_cycles = cycles;
+       set_ns_from_origin(clock_value);
+       bt_clock_value_set(clock_value);
+}
+
+static inline
+void bt_clock_value_set_value_inline(struct bt_clock_value *clock_value,
+               uint64_t raw_value)
+{
+       bt_clock_value_set_raw_value(clock_value, raw_value);
+}
+
+BT_HIDDEN
+void bt_clock_value_destroy(struct bt_clock_value *clock_value);
+
+BT_HIDDEN
+struct bt_clock_value *bt_clock_value_new(struct bt_clock_class *clock_class);
+
+BT_HIDDEN
+struct bt_clock_value *bt_clock_value_create(
+               struct bt_clock_class *clock_class);
+
+BT_HIDDEN
+void bt_clock_value_recycle(struct bt_clock_value *clock_value);
+
+BT_HIDDEN
+void bt_clock_value_set_raw_value(struct bt_clock_value *clock_value,
+               uint64_t cycles);
+
 #endif /* BABELTRACE_CTF_IR_CLOCK_VALUE_INTERNAL_H */
This page took 0.025463 seconds and 4 git commands to generate.