babeltrace/logging.h \
babeltrace/property.h \
babeltrace/types.h \
+ babeltrace/util.h \
babeltrace/value-const.h \
babeltrace/value.h \
babeltrace/version.h
#include <babeltrace/logging.h>
#include <babeltrace/property.h>
#include <babeltrace/types.h>
+#include <babeltrace/util.h>
#include <babeltrace/value-const.h>
#include <babeltrace/value.h>
#include <babeltrace/version.h>
#include <stdint.h>
-/* For bt_bool, bt_uuid, bt_clock_class */
+/* For bt_bool, bt_uuid, bt_clock_class, bt_trace_class */
#include <babeltrace/types.h>
/* For bt_clock_class_status */
extern "C" {
#endif
-extern bt_clock_class *bt_clock_class_create(void);
+extern bt_clock_class *bt_clock_class_create(bt_trace_class *trace_class);
extern bt_clock_class_status bt_clock_class_set_name(
bt_clock_class *clock_class, const char *name);
static inline
void set_ns_from_origin(struct bt_clock_snapshot *clock_snapshot)
{
- if (bt_util_ns_from_origin(clock_snapshot->clock_class, clock_snapshot->value_cycles,
+ if (bt_util_ns_from_origin_clock_class(clock_snapshot->clock_class,
+ clock_snapshot->value_cycles,
&clock_snapshot->ns_from_origin)) {
clock_snapshot->ns_from_origin_overflows = true;
}
-
}
static inline
}
static inline
-int bt_util_ns_from_origin(const struct bt_clock_class *clock_class,
- uint64_t value, int64_t *ns_from_origin)
+bool bt_util_get_base_offset_ns(int64_t offset_seconds, uint64_t offset_cycles,
+ uint64_t frequency, int64_t *base_offset_ns)
{
- int ret = 0;
- uint64_t value_ns_unsigned;
- int64_t value_ns_signed;
+ bool overflows = false;
+ uint64_t offset_cycles_ns;
- if (clock_class->base_offset.overflows) {
- ret = -1;
+ BT_ASSERT(base_offset_ns);
+
+ /* Initialize nanosecond timestamp to clock's offset in seconds */
+ if (offset_seconds <= (INT64_MIN / INT64_C(1000000000) - 1) ||
+ offset_seconds >= (INT64_MAX / INT64_C(1000000000)) - 1) {
+ /*
+ * Overflow: offset in seconds converted to nanoseconds
+ * is outside the int64_t range. We also subtract 1 here
+ * to leave "space" for the offset in cycles converted
+ * to nanoseconds (which is always less than 1 second by
+ * contract).
+ */
+ overflows = true;
goto end;
}
+ /* Offset (seconds) to nanoseconds */
+ *base_offset_ns = offset_seconds * INT64_C(1000000000);
+
+ /* Add offset in cycles */
+ BT_ASSERT(offset_cycles < frequency);
+ offset_cycles_ns = bt_util_ns_from_value(frequency,
+ offset_cycles);
+ BT_ASSERT(offset_cycles_ns < 1000000000);
+ *base_offset_ns += (int64_t) offset_cycles_ns;
+
+end:
+ return overflows;
+}
+
+static inline
+int bt_util_ns_from_origin_inline(int64_t base_offset_ns,
+ int64_t offset_seconds, uint64_t offset_cycles,
+ uint64_t frequency, uint64_t value, int64_t *ns_from_origin)
+{
+ int ret = 0;
+ uint64_t value_ns_unsigned;
+ int64_t value_ns_signed;
+
/* Initialize to clock class's base offset */
- *ns_from_origin = clock_class->base_offset.value_ns;
+ *ns_from_origin = base_offset_ns;
/* Add given value in cycles */
- value_ns_unsigned = bt_util_ns_from_value(clock_class->frequency, value);
+ value_ns_unsigned = bt_util_ns_from_value(frequency, value);
if (value_ns_unsigned >= (uint64_t) INT64_MAX) {
/*
* FIXME: `value_ns_unsigned` could be greater than
return ret;
}
+static inline
+int bt_util_ns_from_origin_clock_class(const struct bt_clock_class *clock_class,
+ uint64_t value, int64_t *ns_from_origin)
+{
+ int ret = 0;
+
+ if (clock_class->base_offset.overflows) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = bt_util_ns_from_origin_inline(clock_class->base_offset.value_ns,
+ clock_class->offset_seconds, clock_class->offset_cycles,
+ clock_class->frequency, value, ns_from_origin);
+
+end:
+ return ret;
+}
+
static inline
bool bt_util_value_is_in_range_signed(uint64_t size, int64_t value)
{
--- /dev/null
+#ifndef BABELTRACE_UTIL_H
+#define BABELTRACE_UTIL_H
+
+/*
+ * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum bt_util_status {
+ BT_UTIL_STATUS_OK = 0,
+ BT_UTIL_STATUS_OVERFLOW = -75,
+} bt_util_status;
+
+bt_util_status bt_util_clock_cycles_to_ns_from_origin(uint64_t cycles,
+ uint64_t frequency, int64_t offset_seconds,
+ uint64_t offset_cycles, int64_t *ns);
+
+#endif /* BABELTRACE_UTIL_H */
libbabeltrace_la_SOURCES = \
babeltrace.c \
value.c \
+ util.c \
lib-logging.c \
logging.c \
object-pool.c
static inline
void set_base_offset(struct bt_clock_class *clock_class)
{
- uint64_t offset_cycles_ns;
-
- /* Initialize nanosecond timestamp to clock's offset in seconds */
- if (clock_class->offset_seconds <= (INT64_MIN / INT64_C(1000000000) - 1) ||
- clock_class->offset_seconds >= (INT64_MAX / INT64_C(1000000000)) - 1) {
- /*
- * Overflow: offset in seconds converted to nanoseconds
- * is outside the int64_t range. We also subtract 1 here
- * to leave "space" for the offset in cycles converted
- * to nanoseconds (which is always less than 1 second by
- * contract).
- */
- clock_class->base_offset.overflows = true;
- goto end;
- }
-
- /* Offset (seconds) to nanoseconds */
- clock_class->base_offset.value_ns = clock_class->offset_seconds *
- INT64_C(1000000000);
-
- /* Add offset in cycles */
- BT_ASSERT(clock_class->offset_cycles < clock_class->frequency);
- offset_cycles_ns = bt_util_ns_from_value(clock_class->frequency,
- clock_class->offset_cycles);
- BT_ASSERT(offset_cycles_ns < 1000000000);
- clock_class->base_offset.value_ns += (int64_t) offset_cycles_ns;
- clock_class->base_offset.overflows = false;
-
-end:
- return;
+ clock_class->base_offset.overflows = bt_util_get_base_offset_ns(
+ clock_class->offset_seconds, clock_class->offset_cycles,
+ clock_class->frequency, &clock_class->base_offset.value_ns);
}
-struct bt_clock_class *bt_clock_class_create(void)
+struct bt_clock_class *bt_clock_class_create(bt_trace_class *trace_class)
{
int ret;
struct bt_clock_class *clock_class = NULL;
+ BT_ASSERT_PRE_NON_NULL(trace_class, "Trace class");
BT_LOGD_STR("Creating default clock class object");
clock_class = g_new0(struct bt_clock_class, 1);
BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
BT_ASSERT_PRE_NON_NULL(ns, "Nanoseconds (output)");
- ret = bt_util_ns_from_origin(clock_class, cycles, ns);
+ ret = bt_util_ns_from_origin_clock_class(clock_class, cycles, ns);
if (ret) {
ret = BT_CLOCK_CLASS_STATUS_OVERFLOW;
BT_LIB_LOGW("Cannot convert cycles to nanoseconds "
--- /dev/null
+/*
+ * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define BT_LOG_TAG "UTIL"
+#include <babeltrace/lib-logging-internal.h>
+
+#include <babeltrace/assert-pre-internal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <string.h>
+#include <inttypes.h>
+#include <babeltrace/util.h>
+#include <babeltrace/trace-ir/utils-internal.h>
+
+bt_util_status bt_util_clock_cycles_to_ns_from_origin(uint64_t cycles,
+ uint64_t frequency, int64_t offset_seconds,
+ uint64_t offset_cycles, int64_t *ns)
+{
+ bool overflows;
+ int64_t base_offset_ns;
+ bt_util_status status = BT_UTIL_STATUS_OK;
+ int ret;
+
+ BT_ASSERT_PRE_NON_NULL(ns, "Nanoseconds (output)");
+ BT_ASSERT_PRE(frequency != UINT64_C(-1) && frequency != 0,
+ "Invalid frequency: freq=%" PRIu64, frequency);
+ BT_ASSERT_PRE(offset_cycles < frequency,
+ "Offset (cycles) is greater than frequency: "
+ "offset-cycles=%" PRIu64 ", freq=%" PRIu64,
+ offset_cycles, frequency);
+
+ overflows = bt_util_get_base_offset_ns(offset_seconds, offset_cycles,
+ frequency, &base_offset_ns);
+ if (overflows) {
+ status = BT_UTIL_STATUS_OVERFLOW;
+ goto end;
+ }
+
+ ret = bt_util_ns_from_origin_inline(base_offset_ns,
+ offset_seconds, offset_cycles,
+ frequency, cycles, ns);
+ if (ret) {
+ status = BT_UTIL_STATUS_OVERFLOW;
+ }
+
+end:
+ return status;
+}
bt_stream_class_set_assigns_automatic_stream_id(ir_sc, BT_FALSE);
if (sc->default_clock_class) {
+ BT_ASSERT(sc->default_clock_class->ir_cc);
ret = bt_stream_class_set_default_clock_class(ir_sc,
- sc->default_clock_class);
+ sc->default_clock_class->ir_cc);
BT_ASSERT(ret == 0);
}
}
static inline
-int ctf_trace_class_to_ir(bt_trace_class *ir_tc,
- struct ctf_trace_class *tc)
+void ctf_clock_class_to_ir(bt_clock_class *ir_cc, struct ctf_clock_class *cc)
+{
+ int ret;
+
+ if (strlen(cc->name->str) > 0) {
+ ret = bt_clock_class_set_name(ir_cc, cc->name->str);
+ BT_ASSERT(ret == 0);
+ }
+
+ if (strlen(cc->description->str) > 0) {
+ ret = bt_clock_class_set_description(ir_cc, cc->description->str);
+ BT_ASSERT(ret == 0);
+ }
+
+ bt_clock_class_set_frequency(ir_cc, cc->frequency);
+ bt_clock_class_set_precision(ir_cc, cc->precision);
+ bt_clock_class_set_offset(ir_cc, cc->offset_seconds, cc->offset_cycles);
+
+ if (cc->has_uuid) {
+ bt_clock_class_set_uuid(ir_cc, cc->uuid);
+ }
+
+ bt_clock_class_set_is_absolute(ir_cc, cc->is_absolute);
+}
+
+static inline
+int ctf_trace_class_to_ir(bt_trace_class *ir_tc, struct ctf_trace_class *tc)
{
int ret = 0;
uint64_t i;
}
}
+ for (i = 0; i < tc->clock_classes->len; i++) {
+ struct ctf_clock_class *cc = tc->clock_classes->pdata[i];
+
+ cc->ir_cc = bt_clock_class_create(ir_tc);
+ ctf_clock_class_to_ir(cc->ir_cc, cc);
+ }
+
bt_trace_class_set_assigns_automatic_stream_class_id(ir_tc,
BT_FALSE);
tc->is_translated = true;
static inline
int find_mapped_clock_class(struct ctf_field_class *fc,
- bt_clock_class **clock_class)
+ struct ctf_clock_class **clock_class)
{
int ret = 0;
uint64_t i;
BT_LOGE("Stream class contains more than one "
"clock class: expected-cc-name=\"%s\", "
"other-cc-name=\"%s\"",
- bt_clock_class_get_name(*clock_class),
- bt_clock_class_get_name(int_fc->mapped_clock_class));
+ (*clock_class)->name->str,
+ int_fc->mapped_clock_class->name->str);
ret = -1;
goto end;
}
struct ctf_stream_class *stream_class)
{
int ret = 0;
- bt_clock_class *clock_class =
+ struct ctf_clock_class *clock_class =
stream_class->default_clock_class;
uint64_t i;
if (!stream_class->default_clock_class) {
stream_class->default_clock_class = clock_class;
- bt_clock_class_get_ref(stream_class->default_clock_class);
}
end:
{
uint64_t i;
int ret = 0;
- bt_clock_class *clock_class = NULL;
+ struct ctf_clock_class *clock_class = NULL;
- ret = find_mapped_clock_class(ctf_tc->packet_header_fc,
- &clock_class);
+ ret = find_mapped_clock_class(ctf_tc->packet_header_fc, &clock_class);
if (ret) {
goto end;
}
CTF_ENCODING_UTF8,
};
+struct ctf_clock_class {
+ GString *name;
+ GString *description;
+ uint64_t frequency;
+ uint64_t precision;
+ int64_t offset_seconds;
+ uint64_t offset_cycles;
+ uint8_t uuid[16];
+ bool has_uuid;
+ bool is_absolute;
+
+ /* Weak, set during translation */
+ bt_clock_class *ir_cc;
+};
+
struct ctf_field_class {
enum ctf_field_class_type type;
unsigned int alignment;
enum ctf_encoding encoding;
int64_t storing_index;
- /* Owned by this */
- bt_clock_class *mapped_clock_class;
+ /* Weak */
+ struct ctf_clock_class *mapped_clock_class;
};
struct ctf_range {
*/
GHashTable *event_classes_by_id;
- /* Owned by this */
- bt_clock_class *default_clock_class;
+ /* Weak */
+ struct ctf_clock_class *default_clock_class;
/* Weak, set during translation */
bt_stream_class *ir_sc;
uint64_t stored_value_count;
- /* Array of `bt_clock_class *` (owned by this) */
+ /* Array of `struct ctf_clock_class *` (owned by this) */
GPtrArray *clock_classes;
/* Array of `struct ctf_stream_class *` */
void _ctf_field_class_int_destroy(struct ctf_field_class_int *fc)
{
BT_ASSERT(fc);
- bt_clock_class_put_ref(fc->mapped_clock_class);
g_free(fc);
}
void _ctf_field_class_enum_destroy(struct ctf_field_class_enum *fc)
{
BT_ASSERT(fc);
- bt_clock_class_put_ref(fc->base.mapped_clock_class);
if (fc->mappings) {
uint64_t i;
dst_fc->disp_base = src_fc->disp_base;
dst_fc->encoding = src_fc->encoding;
dst_fc->mapped_clock_class = src_fc->mapped_clock_class;
- bt_clock_class_get_ref(dst_fc->mapped_clock_class);
dst_fc->storing_index = src_fc->storing_index;
}
ctf_field_class_destroy(sc->packet_context_fc);
ctf_field_class_destroy(sc->event_header_fc);
ctf_field_class_destroy(sc->event_common_context_fc);
- bt_clock_class_put_ref(sc->default_clock_class);
g_free(sc);
}
}
}
+static inline
+struct ctf_clock_class *ctf_clock_class_create(void)
+{
+ struct ctf_clock_class *cc = g_new0(struct ctf_clock_class, 1);
+
+ BT_ASSERT(cc);
+ cc->name = g_string_new(NULL);
+ BT_ASSERT(cc->name);
+ cc->description = g_string_new(NULL);
+ BT_ASSERT(cc->description);
+ return cc;
+}
+
+static inline
+void ctf_clock_class_destroy(struct ctf_clock_class *cc)
+{
+ if (!cc) {
+ return;
+ }
+
+ if (cc->name) {
+ g_string_free(cc->name, TRUE);
+ }
+
+ if (cc->description) {
+ g_string_free(cc->description, TRUE);
+ }
+
+ bt_clock_class_put_ref(cc->ir_cc);
+ g_free(cc);
+}
+
static inline
struct ctf_trace_class *ctf_trace_class_create(void)
{
BT_ASSERT(tc);
tc->default_byte_order = -1;
tc->clock_classes = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_clock_class_put_ref);
+ (GDestroyNotify) ctf_clock_class_destroy);
BT_ASSERT(tc->clock_classes);
tc->stream_classes = g_ptr_array_new_with_free_func(
(GDestroyNotify) ctf_stream_class_destroy);
}
static inline
-bt_clock_class *ctf_trace_class_borrow_clock_class_by_name(
+struct ctf_clock_class *ctf_trace_class_borrow_clock_class_by_name(
struct ctf_trace_class *tc, const char *name)
{
uint64_t i;
- bt_clock_class *ret_cc = NULL;
+ struct ctf_clock_class *ret_cc = NULL;
BT_ASSERT(tc);
BT_ASSERT(name);
for (i = 0; i < tc->clock_classes->len; i++) {
- bt_clock_class *cc = tc->clock_classes->pdata[i];
- const char *cc_name = bt_clock_class_get_name(cc);
+ struct ctf_clock_class *cc = tc->clock_classes->pdata[i];
- BT_ASSERT(cc_name);
- if (strcmp(cc_name, name) == 0) {
+ BT_ASSERT(cc->name);
+ if (strcmp(cc->name->str, name) == 0) {
ret_cc = cc;
goto end;
}
int signedness = 0;
struct ctf_node *expression;
uint64_t alignment = 0, size = 0;
- bt_clock_class *mapped_clock_class = NULL;
+ struct ctf_clock_class *mapped_clock_class = NULL;
enum ctf_encoding encoding = CTF_ENCODING_NONE;
bt_field_class_integer_preferred_display_base base =
BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL;
(*integer_decl)->disp_base = base;
(*integer_decl)->encoding = encoding;
(*integer_decl)->mapped_clock_class = mapped_clock_class;
- bt_clock_class_get_ref((*integer_decl)->mapped_clock_class);
return 0;
error:
int auto_map_field_to_trace_clock_class(struct ctx *ctx,
struct ctf_field_class *fc)
{
- bt_clock_class *clock_class_to_map_to = NULL;
+ struct ctf_clock_class *clock_class_to_map_to = NULL;
struct ctf_field_class_int *int_fc = (void *) fc;
int ret = 0;
uint64_t clock_class_count;
* implicit one at 1 GHz, named `default`, and use this clock
* class.
*/
- clock_class_to_map_to = bt_clock_class_create();
+ clock_class_to_map_to = ctf_clock_class_create();
BT_ASSERT(clock_class_to_map_to);
- bt_clock_class_set_frequency(clock_class_to_map_to,
- UINT64_C(1000000000));
- ret = bt_clock_class_set_name(clock_class_to_map_to,
- "default");
+ clock_class_to_map_to->frequency = UINT64_C(1000000000);
+ g_string_assign(clock_class_to_map_to->name, "default");
BT_ASSERT(ret == 0);
g_ptr_array_add(ctx->ctf_tc->clock_classes,
clock_class_to_map_to);
- bt_clock_class_get_ref(clock_class_to_map_to);
break;
case 1:
/*
* this one.
*/
clock_class_to_map_to = ctx->ctf_tc->clock_classes->pdata[0];
- bt_clock_class_get_ref(clock_class_to_map_to);
break;
default:
/*
BT_ASSERT(clock_class_to_map_to);
int_fc->mapped_clock_class = clock_class_to_map_to;
- bt_clock_class_get_ref(int_fc->mapped_clock_class);
end:
- bt_clock_class_put_ref(clock_class_to_map_to);
return ret;
}
static
int visit_clock_decl_entry(struct ctx *ctx, struct ctf_node *entry_node,
- bt_clock_class *clock, int *set, int64_t *offset_seconds,
+ struct ctf_clock_class *clock, int *set, int64_t *offset_seconds,
uint64_t *offset_cycles)
{
int ret = 0;
goto error;
}
- ret = bt_clock_class_set_name(clock, right);
- if (ret) {
- _BT_LOGE_NODE(entry_node,
- "cannot set clock class's name");
- g_free(right);
- goto error;
- }
-
+ g_string_assign(clock->name, right);
g_free(right);
_SET(set, _CLOCK_NAME_SET);
} else if (!strcmp(left, "uuid")) {
goto error;
}
- bt_clock_class_set_uuid(clock, uuid);
+ clock->has_uuid = true;
+ memcpy(&clock->uuid[0], uuid, 16);
_SET(set, _CLOCK_UUID_SET);
} else if (!strcmp(left, "description")) {
char *right;
goto error;
}
- ret = bt_clock_class_set_description(clock, right);
- if (ret) {
- _BT_LOGE_NODE(entry_node,
- "Cannot set clock class's description.");
- g_free(right);
- goto error;
- }
-
+ g_string_assign(clock->description, right);
g_free(right);
_SET(set, _CLOCK_DESCRIPTION_SET);
} else if (!strcmp(left, "freq")) {
goto error;
}
- bt_clock_class_set_frequency(clock, freq);
+ clock->frequency = freq;
_SET(set, _CLOCK_FREQ_SET);
} else if (!strcmp(left, "precision")) {
uint64_t precision;
goto error;
}
- bt_clock_class_set_precision(clock, precision);
+ clock->precision = precision;
_SET(set, _CLOCK_PRECISION_SET);
} else if (!strcmp(left, "offset_s")) {
if (_IS_SET(set, _CLOCK_OFFSET_S_SET)) {
goto error;
}
- bt_clock_class_set_is_absolute(clock, ret);
+ clock->is_absolute = ret;
_SET(set, _CLOCK_ABSOLUTE_SET);
} else {
_BT_LOGW_NODE(entry_node,
static
void apply_clock_class_offset(struct ctx *ctx,
- bt_clock_class *clock)
+ struct ctf_clock_class *clock)
{
uint64_t freq;
int64_t offset_s_to_apply = ctx->decoder_config.clock_class_offset_s;
offset_s_to_apply += extra_s;
}
- freq = bt_clock_class_get_frequency(clock);
- bt_clock_class_get_offset(clock,
- &cur_offset_s, &cur_offset_cycles);
+ freq = clock->frequency;
+ cur_offset_s = clock->offset_seconds;
+ cur_offset_cycles = clock->offset_cycles;
/* Apply offsets */
cur_offset_s += offset_s_to_apply;
calibrate_clock_class_offsets(&cur_offset_s, &cur_offset_cycles, freq);
/* Set final offsets */
- bt_clock_class_set_offset(clock, cur_offset_s, cur_offset_cycles);
+ clock->offset_seconds = cur_offset_s;
+ clock->offset_cycles = cur_offset_cycles;
end:
return;
{
int ret = 0;
int set = 0;
- bt_clock_class *clock;
+ struct ctf_clock_class *clock;
struct ctf_node *entry_node;
struct bt_list_head *decl_list = &clock_node->u.clock.declaration_list;
const char *clock_class_name;
clock_node->visited = TRUE;
/* CTF 1.8's default frequency for a clock class is 1 GHz */
- clock = bt_clock_class_create();
+ clock = ctf_clock_class_create();
if (!clock) {
_BT_LOGE_NODE(clock_node,
"Cannot create default clock class.");
goto end;
}
- /* CTF: not absolute by default */
- bt_clock_class_set_is_absolute(clock, BT_FALSE);
-
bt_list_for_each_entry(entry_node, decl_list, siblings) {
ret = visit_clock_decl_entry(ctx, entry_node, clock, &set,
&offset_seconds, &offset_cycles);
goto end;
}
- clock_class_name = bt_clock_class_get_name(clock);
+ clock_class_name = clock->name->str;
BT_ASSERT(clock_class_name);
if (ctx->is_lttng && strcmp(clock_class_name, "monotonic") == 0) {
/*
* it's a condition to be able to sort messages
* from different sources.
*/
- bt_clock_class_set_is_absolute(clock, BT_TRUE);
+ clock->is_absolute = true;
}
/*
* Adjust offsets so that the part in cycles is less than the
* frequency (move to the part in seconds).
*/
- freq = bt_clock_class_get_frequency(clock);
+ freq = clock->frequency;
calibrate_clock_class_offsets(&offset_seconds, &offset_cycles, freq);
- BT_ASSERT(offset_cycles < bt_clock_class_get_frequency(clock));
- bt_clock_class_set_offset(clock, offset_seconds, offset_cycles);
+ BT_ASSERT(offset_cycles < clock->frequency);
+ clock->offset_seconds = offset_seconds;
+ clock->offset_cycles = offset_cycles;
apply_clock_class_offset(ctx, clock);
g_ptr_array_add(ctx->ctf_tc->clock_classes, clock);
- bt_clock_class_get_ref(clock);
+ clock = NULL;
end:
- BT_CLOCK_CLASS_PUT_REF_AND_RESET(clock);
+ if (clock) {
+ ctf_clock_class_destroy(clock);
+ }
+
return ret;
}
}
static
-int convert_cycles_to_ns(bt_clock_class *clock_class,
+int convert_cycles_to_ns(struct ctf_clock_class *clock_class,
uint64_t cycles, int64_t *ns)
{
- return bt_clock_class_cycles_to_ns_from_origin(clock_class, cycles,
- ns);
+ return bt_util_clock_cycles_to_ns_from_origin(cycles,
+ clock_class->frequency, clock_class->offset_seconds,
+ clock_class->offset_cycles, ns);
}
static
if (props.snapshots.beginning_clock != UINT64_C(-1)) {
BT_ASSERT(sc->default_clock_class);
- ret = bt_clock_class_cycles_to_ns_from_origin(
- sc->default_clock_class,
- props.snapshots.beginning_clock, &begin_ns);
+ ret = bt_util_clock_cycles_to_ns_from_origin(
+ props.snapshots.beginning_clock,
+ sc->default_clock_class->frequency,
+ sc->default_clock_class->offset_seconds,
+ sc->default_clock_class->offset_cycles, &begin_ns);
if (ret) {
BT_LOGE("Cannot convert clock cycles to nanoseconds from origin (`%s`).",
path);
}
if (has_ts) {
- dmesg_comp->clock_class = bt_clock_class_create();
+ dmesg_comp->clock_class = bt_clock_class_create(
+ dmesg_comp->trace_class);
if (!dmesg_comp->clock_class) {
BT_LOGE_STR("Cannot create clock class.");
goto error;