Use bt_clock_class_set_offset() and bt_clock_class_get_offset().
</dd>
- <dt>\anchor api-tir-clock-cls-prop-precision Precision</dt>
+ <dt>
+ \anchor api-tir-clock-cls-prop-precision Precision
+ (optional when the clock class was created
+ from a \bt_comp which belongs to a trace processing \bt_graph
+ with the effective \bt_mip version 1)
+ </dt>
<dd>
Precision of the clock class's instance (stream clocks) values
(cycles).
anything between 35 cycles and 49 cycles.
Use bt_clock_class_set_precision() and
- bt_clock_class_get_precision().
+ bt_clock_class_get_opt_precision().
</dd>
<dt>
<td>0 cycles
<tr>
<td>\ref api-tir-clock-cls-prop-precision "Precision"
- <td>0 cycles
+ <td>
+ Depending on the effective \bt_mip (MIP) version of the trace
+ processing \bt_graph:
+
+ <dl>
+ <dt>MIP 0</dt>
+ <dd>0 cycles</dd>
+
+ <dt>MIP 1</dt>
+ <dd>Unknown</dd>
+ </dl>
<tr>
<td>\ref api-tir-clock-cls-prop-origin "Origin"
<td>Unix epoch
Returns the precision (cycles) of the clock class
\bt_p{clock_class}.
+@deprecated
+ Use bt_clock_class_get_opt_precision().
+
+@note
+ This function is only available when \bt_p{clock_class} was created
+ from a \bt_comp which belongs to a trace processing \bt_graph with
+ the effective \bt_mip (MIP) version 0.
+
See the \ref api-tir-clock-cls-prop-precision "precision" property.
@param[in] clock_class
Precision (cycles) of \bt_p{clock_class}.
@bt_pre_not_null{clock_class}
+@bt_pre_clock_cls_with_mip{clock_class, 0}
@sa bt_clock_class_set_precision() —
Sets the precision of a clock class.
extern uint64_t bt_clock_class_get_precision(
const bt_clock_class *clock_class) __BT_NOEXCEPT;
+/*!
+@brief
+ Returns the precision of the clock class \bt_p{clock_class}.
+
+See the \ref api-tir-clock-cls-prop-precision "precision" property.
+
+@param[in] clock_class
+ Clock class of which to get the precision.
+@param[out] precision
+ @parblock
+ <strong>If this function returns
+ #BT_PROPERTY_AVAILABILITY_AVAILABLE</strong>, \bt_p{*precision} is
+ the precision (cycles) of \bt_p{clock_class}.
+
+ Otherwise, the precision of \bt_p{clock_class} is unknown.
+ @endparblock
+
+@retval #BT_PROPERTY_AVAILABILITY_AVAILABLE
+ The precision of \bt_p{clock_class} is known.
+@retval #BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
+ The precision of \bt_p{clock_class} is unknown.
+
+@bt_pre_not_null{clock_class}
+@bt_pre_not_null{precision}
+
+@sa bt_clock_class_set_precision() —
+ Sets the precision of a clock class.
+*/
+extern bt_property_availability bt_clock_class_get_opt_precision(
+ const struct bt_clock_class *clock_class,
+ uint64_t *precision) __BT_NOEXCEPT;
+
/*!
@brief
Sets whether the \ref api-tir-clock-cls-origin "origin"
BUF_APPEND_UUID(clock_class->uuid.value);
}
- BUF_APPEND(", %sis-frozen=%d, %sprecision=%" PRIu64 ", "
- "%soffset-s=%" PRId64 ", "
+ BUF_APPEND(", %sis-frozen=%d", PRFIELD(clock_class->frozen));
+
+ if (clock_class->precision.base.avail) {
+ BUF_APPEND(", %sprecision=%" PRIu64,
+ PRFIELD(clock_class->precision.value));
+ }
+
+ BUF_APPEND(", %soffset-s=%" PRId64 ", "
"%soffset-cycles=%" PRIu64 ", "
"%sorigin-namespace=%s, "
"%sorigin-name=%s, "
"%sorigin-uid=%s, "
"%sbase-offset-ns=%" PRId64,
- PRFIELD(clock_class->frozen), PRFIELD(clock_class->precision),
PRFIELD(clock_class->offset_seconds),
PRFIELD(clock_class->offset_cycles),
PRFIELD(clock_class->origin.ns),
}
clock_class->frequency = UINT64_C(1000000000);
+
+ if (clock_class->mip_version == 0) {
+ clock_class->precision.base.avail =
+ BT_PROPERTY_AVAILABILITY_AVAILABLE;
+ }
+
set_origin_unix_epoch(clock_class);
set_base_offset(clock_class);
ret = bt_object_pool_initialize(&clock_class->cs_pool,
uint64_t bt_clock_class_get_precision(const struct bt_clock_class *clock_class)
{
BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(clock_class);
- return clock_class->precision;
+ BT_ASSERT_PRE_CC_MIP_VERSION_EQ(clock_class, 0);
+ BT_ASSERT_DBG(clock_class->precision.base.avail ==
+ BT_PROPERTY_AVAILABILITY_AVAILABLE);
+ return clock_class->precision.value;
+}
+
+BT_EXPORT
+bt_property_availability bt_clock_class_get_opt_precision(
+ const struct bt_clock_class *clock_class, uint64_t *precision)
+{
+ BT_ASSERT_PRE_NO_ERROR();
+ BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(clock_class);
+ BT_ASSERT_PRE_DEV_NON_NULL("precision-output", precision,
+ "Precision (output)");
+
+ *precision = clock_class->precision.value;
+ return clock_class->precision.base.avail;
}
BT_EXPORT
BT_ASSERT_PRE("valid-precision", precision != UINT64_C(-1),
"Invalid precision: %![cc-]+K, new-precision=%" PRIu64,
clock_class, precision);
- clock_class->precision = precision;
+ clock_class->precision.value = precision;
+ clock_class->precision.base.avail = BT_PROPERTY_AVAILABILITY_AVAILABLE;
BT_LIB_LOGD("Set clock class's precision: %!+K", clock_class);
}
#include "lib/object.h"
#include "common/common.h"
#include "lib/object-pool.h"
+#include "lib/property.h"
#include "common/uuid.h"
#include <babeltrace2/types.h>
#include "common/assert.h"
gchar *description;
uint64_t frequency;
- uint64_t precision;
+ struct bt_property_uint precision;
int64_t offset_seconds;
uint64_t offset_cycles;