.gitignore: add some more IDE / tools related file
[babeltrace.git] / src / lib / trace-ir / clock-class.h
CommitLineData
273b65be 1/*
0235b0db
MJ
2 * SPDX-License-Identifier: MIT
3 *
e2f7325d 4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
de9dd397 5 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
273b65be
JG
6 */
7
ae2be88d
SM
8#ifndef BABELTRACE_LIB_TRACE_IR_CLOCK_CLASS_H
9#define BABELTRACE_LIB_TRACE_IR_CLOCK_CLASS_H
0235b0db 10
3fadfbc0 11#include <babeltrace2/trace-ir/clock-class.h>
578e048b 12#include "lib/object.h"
578e048b
MJ
13#include "common/common.h"
14#include "lib/object-pool.h"
6162e6b7 15#include "common/uuid.h"
3fadfbc0 16#include <babeltrace2/types.h>
578e048b 17#include "common/assert.h"
036a7cac
PP
18#include <stdbool.h>
19#include <stdint.h>
c55a9f58 20#include <glib.h>
273b65be 21
d24d5663
PP
22#include "lib/func-status.h"
23
50842bdc 24struct bt_clock_class {
83509119 25 struct bt_object base;
44c440bc 26
c6962c96
PP
27 /* Owned by this */
28 struct bt_value *user_attributes;
29
b91e0631
SM
30 gchar *name;
31 gchar *description;
44c440bc 32
273b65be
JG
33 uint64_t frequency;
34 uint64_t precision;
44c440bc
PP
35 int64_t offset_seconds;
36 uint64_t offset_cycles;
37
38 struct {
6162e6b7 39 bt_uuid_t uuid;
44c440bc
PP
40
41 /* NULL or `uuid` above */
42 bt_uuid value;
43 } uuid;
44
5552377a 45 bool origin_is_unix_epoch;
cfeb617e 46
273b65be 47 /*
44c440bc
PP
48 * This is computed every time you call
49 * bt_clock_class_set_frequency() or
50 * bt_clock_class_set_offset(), as well as initially. It is the
51 * base offset in nanoseconds including both `offset_seconds`
52 * and `offset_cycles` above in the result. It is used to
53 * accelerate future calls to
605e1019 54 * bt_clock_snapshot_get_ns_from_origin() and
44c440bc
PP
55 * bt_clock_class_cycles_to_ns_from_origin().
56 *
57 * `overflows` is true if the base offset cannot be computed
58 * because of an overflow.
273b65be 59 */
44c440bc
PP
60 struct {
61 int64_t value_ns;
62 bool overflows;
63 } base_offset;
312c056a 64
605e1019
PP
65 /* Pool of `struct bt_clock_snapshot *` */
66 struct bt_object_pool cs_pool;
44c440bc
PP
67
68 bool frozen;
273b65be
JG
69};
70
40f4ba76 71void _bt_clock_class_freeze(const struct bt_clock_class *clock_class);
273b65be 72
44c440bc
PP
73#ifdef BT_DEV_MODE
74# define bt_clock_class_freeze _bt_clock_class_freeze
75#else
76# define bt_clock_class_freeze(_cc)
77#endif
24626e8b 78
44c440bc 79bt_bool bt_clock_class_is_valid(struct bt_clock_class *clock_class);
93dda901 80
5b9e151d
PP
81static inline
82int bt_clock_class_clock_value_from_ns_from_origin(
83 struct bt_clock_class *cc, int64_t ns_from_origin,
84 uint64_t *raw_value)
85{
98b15851 86 BT_ASSERT_DBG(cc);
7de0e49a
PP
87 return bt_common_clock_value_from_ns_from_origin(cc->offset_seconds,
88 cc->offset_cycles, cc->frequency, ns_from_origin,
520cdc82 89 raw_value) ? BT_FUNC_STATUS_OVERFLOW_ERROR : BT_FUNC_STATUS_OK;
5b9e151d
PP
90}
91
ae2be88d 92#endif /* BABELTRACE_LIB_TRACE_IR_CLOCK_CLASS_H */
This page took 0.118891 seconds and 4 git commands to generate.