Precision of the clock class's instance (stream clocks) values
(cycles).
- For example, considering a precision of 7 cycles and the stream
+ For example, considering a precision of 7 cycles, an
+ \link api-tir-clock-cls-prop-accuracy accuracy\endlink
+ of 0 cycles, and the stream
clock value 42 cycles, the real stream clock value can be
anything between 35 cycles and 49 cycles.
bt_clock_class_get_opt_precision().
</dd>
+ <dt>
+ \anchor api-tir-clock-cls-prop-accuracy
+ \bt_dt_opt Accuracy
+ (only available 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>
+ Accuracy of the clock class's instance (stream clocks) values
+ (cycles).
+
+ For example, considering an accuracy of 7 cycles, a
+ \link api-tir-clock-cls-prop-precision precision\endlink
+ of 0 cycles, and the stream
+ clock value 42 cycles, the real stream clock value can be
+ anything between 35 cycles and 49 cycles.
+
+ Use bt_clock_class_set_accuracy() and
+ bt_clock_class_get_accuracy().
+ </dd>
+
<dt>
\anchor api-tir-clock-cls-prop-origin
Origin
<dt>MIP 1</dt>
<dd>Unknown</dd>
</dl>
+ <tr>
+ <td>
+ \bt_mip version 1:
+ \ref api-tir-stream-cls-prop-accuracy "accuracy"
+ <td>Unknown
<tr>
<td>\ref api-tir-clock-cls-prop-origin "Origin"
<td>Unix epoch
const struct bt_clock_class *clock_class,
uint64_t *precision) __BT_NOEXCEPT;
+/*!
+@brief
+ Sets the accuracy (cycles) of the clock class \bt_p{clock_class} to
+ \bt_p{accuracy}.
+
+See the \ref api-tir-clock-cls-prop-accuracy "accuracy" property.
+
+@param[in] clock_class
+ Clock class of which to set the accuracy to \bt_p{accuracy}.
+@param[in] accuracy
+ New accuracy of \bt_p{clock_class}.
+
+@bt_pre_not_null{clock_class}
+@bt_pre_hot{clock_class}
+@bt_pre_clock_cls_with_mip{clock_class, 1}
+
+@sa bt_clock_class_get_accuracy() —
+ Returns the accuracy of a clock class.
+*/
+extern void bt_clock_class_set_accuracy(bt_clock_class *clock_class,
+ uint64_t accuracy) __BT_NOEXCEPT;
+
+/*!
+@brief
+ Returns the accuracy of the clock class \bt_p{clock_class}.
+
+See the \ref api-tir-clock-cls-prop-accuracy "accuracy" property.
+
+@param[in] clock_class
+ Clock class of which to get the accuracy.
+@param[out] accuracy
+ @parblock
+ <strong>If this function returns
+ #BT_PROPERTY_AVAILABILITY_AVAILABLE</strong>, \bt_p{*accuracy} is
+ the accuracy (cycles) of \bt_p{clock_class}.
+
+ Otherwise, the accuracy of \bt_p{clock_class} is unknown.
+ @endparblock
+
+@retval #BT_PROPERTY_AVAILABILITY_AVAILABLE
+ The accuracy of \bt_p{clock_class} is known.
+@retval #BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
+ The accuracy of \bt_p{clock_class} is unknown.
+
+@bt_pre_not_null{clock_class}
+@bt_pre_not_null{accuracy}
+
+@sa bt_clock_class_set_accuracy() —
+ Sets the accuracy of a clock class.
+*/
+extern bt_property_availability bt_clock_class_get_accuracy(
+ const struct bt_clock_class *clock_class,
+ uint64_t *accuracy) __BT_NOEXCEPT;
+
/*!
@brief
Sets whether the \ref api-tir-clock-cls-origin "origin"
BT_LIB_LOGD("Set clock class's precision: %!+K", clock_class);
}
+BT_EXPORT
+void bt_clock_class_set_accuracy(bt_clock_class *clock_class,
+ uint64_t accuracy)
+{
+ BT_ASSERT_PRE_NO_ERROR();
+ BT_ASSERT_PRE_CLK_CLS_NON_NULL(clock_class);
+ BT_ASSERT_PRE_DEV_CLOCK_CLASS_HOT(clock_class);
+ BT_ASSERT_PRE_CC_MIP_VERSION_GE(clock_class, 1);
+ BT_ASSERT_PRE("valid-accuracy", accuracy != UINT64_C(-1),
+ "Invalid accuracy: %![cc-]+K, new-accuracy=%" PRIu64,
+ clock_class, accuracy);
+ clock_class->accuracy.value = accuracy;
+ clock_class->accuracy.base.avail = BT_PROPERTY_AVAILABILITY_AVAILABLE;
+ BT_LIB_LOGD("Set clock class's accuracy: %!+K", clock_class);
+}
+
+BT_EXPORT
+bt_property_availability bt_clock_class_get_accuracy(
+ const struct bt_clock_class *clock_class, uint64_t *accuracy)
+{
+ BT_ASSERT_PRE_NO_ERROR();
+ BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(clock_class);
+ BT_ASSERT_PRE_CC_MIP_VERSION_GE(clock_class, 1);
+ BT_ASSERT_PRE_DEV_NON_NULL("accuracy-output", accuracy,
+ "Accuracy (output)");
+
+ *accuracy = clock_class->accuracy.value;
+ return clock_class->accuracy.base.avail;
+}
+
BT_EXPORT
void bt_clock_class_get_offset(const struct bt_clock_class *clock_class,
int64_t *seconds, uint64_t *cycles)