#include <babeltrace/compat/uuid-internal.h>
#include <babeltrace/trace-ir/clock-class-internal.h>
#include <babeltrace/trace-ir/clock-value-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/types.h>
#include <babeltrace/compat/string-internal.h>
void bt_clock_value_destroy(struct bt_clock_value *clock_value)
{
BT_LIB_LOGD("Destroying clock value: %!+k", clock_value);
- bt_put(clock_value->clock_class);
+ BT_OBJECT_PUT_REF_AND_RESET(clock_value->clock_class);
g_free(clock_value);
}
}
bt_object_init_unique(&ret->base);
- ret->clock_class = bt_get(clock_class);
+ ret->clock_class = clock_class;
+ bt_object_get_no_null_check(clock_class);
bt_clock_class_freeze(clock_class);
BT_LIB_LOGD("Created clock value object: %!+k", ret);
}
if (likely(!clock_value->clock_class)) {
- clock_value->clock_class = bt_get(clock_class);
+ clock_value->clock_class = clock_class;
+ bt_object_get_no_null_check(clock_class);
}
goto end;
* variable so that we can set the clock value's clock class
* member to NULL before recycling it. We CANNOT do this
* after we put the clock class reference because this
- * bt_put() could destroy the clock class, also destroying
+ * bt_object_put_ref() could destroy the clock class, also destroying
* its clock value pool, thus also destroying our clock value
* object (this would result in an invalid write access).
*
BT_ASSERT(clock_class);
clock_value->clock_class = NULL;
bt_object_pool_recycle_object(&clock_class->cv_pool, clock_value);
- bt_put(clock_class);
+ bt_object_put_ref(clock_class);
}
-uint64_t bt_clock_value_get_value(struct bt_clock_value *clock_value)
+uint64_t bt_clock_value_get_value(const struct bt_clock_value *clock_value)
{
BT_ASSERT_PRE_NON_NULL(clock_value, "Clock value");
BT_ASSERT_PRE(clock_value->is_set,
return clock_value->value_cycles;
}
-int bt_clock_value_get_ns_from_origin(struct bt_clock_value *clock_value,
+int bt_clock_value_get_ns_from_origin(const struct bt_clock_value *clock_value,
int64_t *ret_value_ns)
{
int ret = 0;
return ret;
}
-struct bt_clock_class *bt_clock_value_borrow_clock_class(
- struct bt_clock_value *clock_value)
+const struct bt_clock_class *bt_clock_value_borrow_clock_class_const(
+ const struct bt_clock_value *clock_value)
{
BT_ASSERT_PRE_NON_NULL(clock_value, "Clock value");
return clock_value->clock_class;