2 * SPDX-License-Identifier: MIT
4 * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation
7 #ifndef BABELTRACE2_TRACE_IR_CLOCK_CLASS_H
8 #define BABELTRACE2_TRACE_IR_CLOCK_CLASS_H
10 /* IWYU pragma: private, include <babeltrace2/babeltrace.h> */
12 #ifndef __BT_IN_BABELTRACE_H
13 # error "Please include <babeltrace2/babeltrace.h> instead."
18 #include <babeltrace2/types.h>
25 @defgroup api-tir-clock-cls Clock class
29 Class of \bt_stream clocks.
31 A <strong><em>clock class</em></strong> is the class of \bt_stream
34 A clock class is a \ref api-tir "trace IR" metadata object.
36 <em>Stream clocks</em> only exist conceptually in \bt_name because they
37 are stateful objects. \bt_cp_msg cannot refer to stateful objects
38 because they must not change while being transported from one
39 \bt_comp to the other.
41 Instead of having a stream clock object, messages have a
42 default \bt_cs: this is a snapshot of the value of a stream's default
43 clock (a clock class instance):
45 @image html clocks.png
47 In the illustration above, notice that:
49 - \bt_cp_stream (horizontal blue rectangles) are instances of a
50 \bt_stream_cls (orange).
51 - A stream class has a default clock class (orange bell alarm clock).
52 - Each stream has a default clock (yellow bell alarm clock): this is an
53 instance of the stream's class's default clock class.
54 - Each \bt_msg (objects in blue stream rectangles) created for a given
55 stream has a default \bt_cs (yellow star): this is a snapshot of the
56 stream's default clock.
58 In other words, a default clock snapshot contains the value of the
59 stream's default clock when this message occurred.
61 The default clock class property of a \bt_stream_cls is optional:
62 if a stream class has no default clock class, then its instances
63 (\bt_p_stream) have no default clock, therefore all the \bt_p_msg
64 created from this stream have no default clock snapshot.
66 A clock class is a \ref api-fund-shared-object "shared object": get a
67 new reference with bt_clock_class_get_ref() and put an existing
68 reference with bt_clock_class_put_ref().
70 Some library functions \ref api-fund-freezing "freeze" clock classes on
71 success. The documentation of those functions indicate this
74 The type of a clock class is #bt_clock_class.
76 Create a default clock class from a \bt_self_comp with
77 bt_clock_class_create().
79 <h1>\anchor api-tir-clock-cls-origin Clock value vs. clock class origin</h1>
81 The value of a \bt_stream clock (a conceptual instance of a clock class)
82 is in <em>cycles</em>. This value is always positive and is relative to
83 the clock's class's offset, which is relative to its origin.
85 A clock class's origin is one of:
88 <dt>If bt_clock_class_origin_is_unix_epoch() returns #BT_TRUE</dt>
91 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
93 The stream clocks of all the clock classes which have a Unix
94 epoch origin, whatever the clock class
95 <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUIDs</a>,
99 <dt>If bt_clock_class_origin_is_unix_epoch() returns #BT_FALSE</dt>
103 In that case, two clock classes which share the same UUID, as
104 returned by bt_clock_class_get_uuid(), including having no UUID,
105 also share the same origin: their instances (stream clocks) are
110 To compute an effective stream clock value, in cycles from its class's
113 -# Convert the clock class's
114 \link api-tir-clock-cls-prop-offset "offset in seconds"\endlink
115 property to cycles using its
116 \ref api-tir-clock-cls-prop-freq "frequency".
117 -# Add the value of 1., the stream clock's value, and the clock class's
118 \link api-tir-clock-cls-prop-offset "offset in cycles"\endlink
121 Because typical tracer clocks have a high frequency (often 1 GHz
122 and more), an effective stream clock value (cycles since Unix epoch, for
123 example) can be larger than \c UINT64_MAX. This is why a clock class has
124 two offset properties (one in seconds and one in cycles): to make it
125 possible for a stream clock to have smaller values, relative to this
128 The bt_clock_class_cycles_to_ns_from_origin(),
129 bt_util_clock_cycles_to_ns_from_origin(), and
130 bt_clock_snapshot_get_ns_from_origin() functions convert a stream clock
131 value (cycles) to an equivalent <em>nanoseconds from origin</em> value
132 using the relevant clock class properties (frequency and offset).
134 Those functions perform this computation:
136 -# Convert the clock class's "offset in cycles" property to seconds
138 -# Convert the stream clock's value to seconds using the clock class's
140 -# Add the values of 1., 2., and the clock class's "offset in seconds"
142 -# Convert the value of 3. to nanoseconds.
144 The following illustration shows the possible scenarios:
146 @image html clock-terminology.png
148 The clock class's "offset in seconds" property can be negative.
149 For example, considering:
151 - Frequency: 1000 Hz.
152 - Offset in seconds: −10 seconds.
153 - Offset in cycles: 500 cycles (that is, 0.5 seconds).
154 - Stream clock's value: 2000 cycles (that is, 2 seconds).
156 Then the computed value is −7.5 seconds from origin, or
157 −7,500,000,000 nanoseconds from origin.
161 A clock class has the following properties:
164 <dt>\anchor api-tir-clock-cls-prop-freq Frequency</dt>
166 Frequency of the clock class's instances (stream clocks)
169 Use bt_clock_class_set_frequency() and
170 bt_clock_class_get_frequency().
174 \anchor api-tir-clock-cls-prop-offset
175 Offset (in seconds and in cycles)
178 Offset in seconds relative to the clock class's
179 \ref api-tir-clock-cls-origin "origin", and offset in cycles
180 relative to the offset in seconds, of the clock class's
181 instances (stream clocks).
183 The values of the clock class's instances are relative to the
186 Use bt_clock_class_set_offset() and bt_clock_class_get_offset().
189 <dt>\anchor api-tir-clock-cls-prop-precision Precision</dt>
191 Precision of the clock class's instance (stream clocks) values
194 For example, considering a precision of 7 cycles and the stream
195 clock value 42 cycles, the real stream clock value can be
196 anything between 35 cycles and 49 cycles.
198 Use bt_clock_class_set_precision() and
199 bt_clock_class_get_precision().
203 \anchor api-tir-clock-cls-prop-origin-unix-epoch
204 Origin is Unix epoch?
207 Whether or not the clock class's
208 \ref api-tir-clock-cls-origin "origin"
210 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
212 Use bt_clock_class_set_origin_is_unix_epoch() and
213 bt_clock_class_origin_is_unix_epoch().
216 <dt>\anchor api-tir-clock-cls-prop-name \bt_dt_opt Name</dt>
218 Name of the clock class.
220 Use bt_clock_class_set_name() and bt_clock_class_get_name().
223 <dt>\anchor api-tir-clock-cls-prop-descr \bt_dt_opt Description</dt>
225 Description of the clock class.
227 Use bt_clock_class_set_description() and
228 bt_clock_class_get_description().
231 <dt>\anchor api-tir-clock-cls-prop-uuid \bt_dt_opt UUID</dt>
233 <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUID</a>
236 The clock class's UUID uniquely identifies the clock class.
238 When the clock class's origin is \em not the
239 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>,
240 then the clock class's UUID determines whether or not two different
241 clock classes have correlatable instances.
243 Use bt_clock_class_set_uuid() and bt_clock_class_get_uuid().
247 \anchor api-tir-clock-cls-prop-user-attrs
248 \bt_dt_opt User attributes
251 User attributes of the clock class.
253 User attributes are custom attributes attached to a clock class.
255 Use bt_clock_class_set_user_attributes(),
256 bt_clock_class_borrow_user_attributes(), and
257 bt_clock_class_borrow_user_attributes_const().
268 @typedef struct bt_clock_class bt_clock_class;
283 Creates a default clock class from the \bt_self_comp
284 \bt_p{self_component}.
286 On success, the returned clock class has the following property values:
293 <td>\ref api-tir-clock-cls-prop-freq "Frequency"
296 <td>\ref api-tir-clock-cls-prop-offset "Offset" in seconds
299 <td>\ref api-tir-clock-cls-prop-offset "Offset" in cycles
302 <td>\ref api-tir-clock-cls-prop-precision "Precision"
305 <td>\ref api-tir-clock-cls-prop-origin-unix-epoch "Origin is Unix epoch?"
308 <td>\ref api-tir-clock-cls-prop-name "Name"
311 <td>\ref api-tir-clock-cls-prop-descr "Description"
314 <td>\ref api-tir-clock-cls-prop-uuid "UUID"
317 <td>\ref api-tir-clock-cls-prop-user-attrs "User attributes"
318 <td>Empty \bt_map_val
321 @param[in] self_component
322 Self component from which to create the default clock class.
325 New clock class reference, or \c NULL on memory error.
327 @bt_pre_not_null{self_component}
329 extern bt_clock_class
*bt_clock_class_create(bt_self_component
*self_component
);
340 Sets the frequency (Hz) of the clock class \bt_p{clock_class} to
343 See the \ref api-tir-clock-cls-prop-freq "frequency" property.
345 @param[in] clock_class
346 Clock class of which to set the frequency to \bt_p{frequency}.
348 New frequency of \bt_p{clock_class}.
350 @bt_pre_not_null{clock_class}
351 @bt_pre_hot{clock_class}
353 \bt_p{frequency} is not 0.
355 \bt_p{frequency} is not <code>UINT64_C(-1)</code>.
357 \bt_p{frequency} is greater than the clock class's offset in cycles
358 (as returned by bt_clock_class_get_offset()).
360 @sa bt_clock_class_get_frequency() —
361 Returns the frequency of a clock class.
363 extern void bt_clock_class_set_frequency(bt_clock_class
*clock_class
,
368 Returns the frequency (Hz) of the clock class \bt_p{clock_class}.
370 See the \ref api-tir-clock-cls-prop-freq "frequency" property.
372 @param[in] clock_class
373 Clock class of which to get the frequency.
376 Frequency (Hz) of \bt_p{clock_class}.
378 @bt_pre_not_null{clock_class}
380 @sa bt_clock_class_set_frequency() —
381 Sets the frequency of a clock class.
383 extern uint64_t bt_clock_class_get_frequency(
384 const bt_clock_class
*clock_class
);
388 Sets the offset of the clock class \bt_p{clock_class} to
389 \bt_p{offset_seconds} plus \bt_p{offset_cycles} from its
390 \ref api-tir-clock-cls-origin "origin".
392 See the \ref api-tir-clock-cls-prop-offset "offset" property.
394 @param[in] clock_class
395 Clock class of which to set the offset to \bt_p{offset_seconds}
396 and \bt_p{offset_cycles}.
397 @param[in] offset_seconds
398 New offset in seconds of \bt_p{clock_class}.
399 @param[in] offset_cycles
400 New offset in cycles of \bt_p{clock_class}.
402 @bt_pre_not_null{clock_class}
403 @bt_pre_hot{clock_class}
405 \bt_p{offset_cycles} is less than the clock class's frequency
406 (as returned by bt_clock_class_get_frequency()).
408 @sa bt_clock_class_get_offset() —
409 Returns the offset of a clock class.
411 extern void bt_clock_class_set_offset(bt_clock_class
*clock_class
,
412 int64_t offset_seconds
, uint64_t offset_cycles
);
416 Returns the offsets in seconds and cycles of the clock class
419 See the \ref api-tir-clock-cls-prop-offset "offset" property.
421 @param[in] clock_class
422 Clock class of which to get the offset.
423 @param[out] offset_seconds
424 When this function returns, \bt_p{*offset_seconds} is the offset in
427 @param[out] offset_cycles
428 When this function returns, \bt_p{*offset_cycles} is the offset in
429 cycles of \bt_p{clock_class}.
431 @bt_pre_not_null{clock_class}
432 @bt_pre_not_null{offset_seconds}
433 @bt_pre_not_null{offset_cycles}
435 @sa bt_clock_class_set_offset() —
436 Sets the offset of a clock class.
438 extern void bt_clock_class_get_offset(const bt_clock_class
*clock_class
,
439 int64_t *offset_seconds
, uint64_t *offset_cycles
);
443 Sets the precision (cycles) of the clock class \bt_p{clock_class} to
446 See the \ref api-tir-clock-cls-prop-precision "precision" property.
448 @param[in] clock_class
449 Clock class of which to set the precision to \bt_p{precision}.
451 New precision of \bt_p{clock_class}.
453 @bt_pre_not_null{clock_class}
454 @bt_pre_hot{clock_class}
456 @sa bt_clock_class_get_precision() —
457 Returns the precision of a clock class.
459 extern void bt_clock_class_set_precision(bt_clock_class
*clock_class
,
464 Returns the precision (cycles) of the clock class
467 See the \ref api-tir-clock-cls-prop-precision "precision" property.
469 @param[in] clock_class
470 Clock class of which to get the precision.
473 Precision (cycles) of \bt_p{clock_class}.
475 @bt_pre_not_null{clock_class}
477 @sa bt_clock_class_set_precision() —
478 Sets the precision of a clock class.
480 extern uint64_t bt_clock_class_get_precision(
481 const bt_clock_class
*clock_class
);
485 Sets whether or not the \ref api-tir-clock-cls-origin "origin"
486 of the clock class \bt_p{clock_class} is the
487 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
489 See the \ref api-tir-clock-cls-prop-origin-unix-epoch "origin is Unix epoch?"
492 @param[in] clock_class
493 Clock class of which to set whether or not its origin is the
495 @param[in] origin_is_unix_epoch
496 #BT_TRUE to make \bt_p{clock_class} have a Unix epoch origin.
498 @bt_pre_not_null{clock_class}
499 @bt_pre_hot{clock_class}
501 @sa bt_clock_class_origin_is_unix_epoch() —
502 Returns whether or not the origin of a clock class is the
505 extern void bt_clock_class_set_origin_is_unix_epoch(bt_clock_class
*clock_class
,
506 bt_bool origin_is_unix_epoch
);
510 Returns whether or not the \ref api-tir-clock-cls-origin "origin"
511 of the clock class \bt_p{clock_class} is the
512 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
514 See the \ref api-tir-clock-cls-prop-origin-unix-epoch "origin is Unix epoch?"
517 @param[in] clock_class
518 Clock class of which to get whether or not its origin is the
522 #BT_TRUE if the origin of \bt_p{clock_class} is the Unix epoch.
524 @bt_pre_not_null{clock_class}
526 @sa bt_clock_class_set_origin_is_unix_epoch() —
527 Sets whether or not the origin of a clock class is the Unix epoch.
529 extern bt_bool
bt_clock_class_origin_is_unix_epoch(
530 const bt_clock_class
*clock_class
);
534 Status codes for bt_clock_class_set_name().
536 typedef enum bt_clock_class_set_name_status
{
541 BT_CLOCK_CLASS_SET_NAME_STATUS_OK
= __BT_FUNC_STATUS_OK
,
547 BT_CLOCK_CLASS_SET_NAME_STATUS_MEMORY_ERROR
= __BT_FUNC_STATUS_MEMORY_ERROR
,
548 } bt_clock_class_set_name_status
;
552 Sets the name of the clock class \bt_p{clock_class} to
553 a copy of \bt_p{name}.
555 See the \ref api-tir-clock-cls-prop-name "name" property.
557 @param[in] clock_class
558 Clock class of which to set the name to \bt_p{name}.
560 New name of \bt_p{clock_class} (copied).
562 @retval #BT_CLOCK_CLASS_SET_NAME_STATUS_OK
564 @retval #BT_CLOCK_CLASS_SET_NAME_STATUS_MEMORY_ERROR
567 @bt_pre_not_null{clock_class}
568 @bt_pre_hot{clock_class}
569 @bt_pre_not_null{name}
571 @sa bt_clock_class_get_name() —
572 Returns the name of a clock class.
574 extern bt_clock_class_set_name_status
bt_clock_class_set_name(
575 bt_clock_class
*clock_class
, const char *name
);
579 Returns the name of the clock class \bt_p{clock_class}.
581 See the \ref api-tir-clock-cls-prop-name "name" property.
583 If \bt_p{clock_class} has no name, this function returns \c NULL.
585 @param[in] clock_class
586 Clock class of which to get the name.
590 Name of \bt_p{clock_class}, or \c NULL if none.
592 The returned pointer remains valid as long as \bt_p{clock_class}
596 @bt_pre_not_null{clock_class}
598 @sa bt_clock_class_set_name() —
599 Sets the name of a clock class.
601 extern const char *bt_clock_class_get_name(
602 const bt_clock_class
*clock_class
);
606 Status codes for bt_clock_class_set_description().
608 typedef enum bt_clock_class_set_description_status
{
613 BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_OK
= __BT_FUNC_STATUS_OK
,
619 BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR
= __BT_FUNC_STATUS_MEMORY_ERROR
,
620 } bt_clock_class_set_description_status
;
624 Sets the description of the clock class \bt_p{clock_class} to a copy
625 of \bt_p{description}.
627 See the \ref api-tir-clock-cls-prop-descr "description" property.
629 @param[in] clock_class
630 Clock class of which to set the description to \bt_p{description}.
631 @param[in] description
632 New description of \bt_p{clock_class} (copied).
634 @retval #BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_OK
636 @retval #BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR
639 @bt_pre_not_null{clock_class}
640 @bt_pre_hot{clock_class}
641 @bt_pre_not_null{description}
643 @sa bt_clock_class_get_description() —
644 Returns the description of a clock class.
646 extern bt_clock_class_set_description_status
bt_clock_class_set_description(
647 bt_clock_class
*clock_class
, const char *description
);
651 Returns the description of the clock class \bt_p{clock_class}.
653 See the \ref api-tir-clock-cls-prop-descr "description" property.
655 If \bt_p{clock_class} has no description, this function returns \c NULL.
657 @param[in] clock_class
658 Clock class of which to get the description.
662 Description of \bt_p{clock_class}, or \c NULL if none.
664 The returned pointer remains valid as long as \bt_p{clock_class}
668 @bt_pre_not_null{clock_class}
670 @sa bt_clock_class_set_description() —
671 Sets the description of a clock class.
673 extern const char *bt_clock_class_get_description(
674 const bt_clock_class
*clock_class
);
679 <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUID</a>
680 of the clock class \bt_p{clock_class} to a copy of \bt_p{uuid}.
682 See the \ref api-tir-clock-cls-prop-uuid "UUID" property.
684 @param[in] clock_class
685 Clock class of which to set the UUID to \bt_p{uuid}.
687 New UUID of \bt_p{clock_class} (copied).
689 @bt_pre_not_null{clock_class}
690 @bt_pre_hot{clock_class}
691 @bt_pre_not_null{uuid}
693 @sa bt_clock_class_get_uuid() —
694 Returns the UUID of a clock class.
696 extern void bt_clock_class_set_uuid(bt_clock_class
*clock_class
,
701 Returns the UUID of the clock class \bt_p{clock_class}.
703 See the \ref api-tir-clock-cls-prop-uuid "UUID" property.
705 If \bt_p{clock_class} has no UUID, this function returns \c NULL.
707 @param[in] clock_class
708 Clock class of which to get the UUID.
712 UUID of \bt_p{clock_class}, or \c NULL if none.
714 The returned pointer remains valid as long as \bt_p{clock_class}
718 @bt_pre_not_null{clock_class}
720 @sa bt_clock_class_set_uuid() —
721 Sets the UUID of a clock class.
723 extern bt_uuid
bt_clock_class_get_uuid(
724 const bt_clock_class
*clock_class
);
728 Sets the user attributes of the clock class \bt_p{clock_class} to
729 \bt_p{user_attributes}.
731 See the \ref api-tir-clock-cls-prop-user-attrs "user attributes"
735 When you create a default clock class with bt_clock_class_create(),
736 the clock class's initial user attributes is an empty \bt_map_val.
737 Therefore you can borrow it with
738 bt_clock_class_borrow_user_attributes() and fill it directly instead
739 of setting a new one with this function.
741 @param[in] clock_class
742 Clock class of which to set the user attributes to
743 \bt_p{user_attributes}.
744 @param[in] user_attributes
745 New user attributes of \bt_p{clock_class}.
747 @bt_pre_not_null{clock_class}
748 @bt_pre_hot{clock_class}
749 @bt_pre_not_null{user_attributes}
750 @bt_pre_is_map_val{user_attributes}
752 @sa bt_clock_class_borrow_user_attributes() —
753 Borrows the user attributes of a clock class.
755 extern void bt_clock_class_set_user_attributes(
756 bt_clock_class
*clock_class
, const bt_value
*user_attributes
);
760 Borrows the user attributes of the clock class \bt_p{clock_class}.
762 See the \ref api-tir-clock-cls-prop-user-attrs "user attributes"
766 When you create a default clock class with bt_clock_class_create(),
767 the clock class's initial user attributes is an empty \bt_map_val.
769 @param[in] clock_class
770 Clock class from which to borrow the user attributes.
773 User attributes of \bt_p{clock_class} (a \bt_map_val).
775 @bt_pre_not_null{clock_class}
777 @sa bt_clock_class_set_user_attributes() —
778 Sets the user attributes of a clock class.
779 @sa bt_clock_class_borrow_user_attributes_const() —
780 \c const version of this function.
782 extern bt_value
*bt_clock_class_borrow_user_attributes(
783 bt_clock_class
*clock_class
);
787 Borrows the user attributes of the clock class \bt_p{clock_class}
790 See bt_clock_class_borrow_user_attributes().
792 extern const bt_value
*bt_clock_class_borrow_user_attributes_const(
793 const bt_clock_class
*clock_class
);
804 Status codes for bt_clock_class_cycles_to_ns_from_origin().
806 typedef enum bt_clock_class_cycles_to_ns_from_origin_status
{
811 BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OK
= __BT_FUNC_STATUS_OK
,
815 Integer overflow while computing the result.
817 BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR
= __BT_FUNC_STATUS_OVERFLOW_ERROR
,
818 } bt_clock_class_cycles_to_ns_from_origin_status
;
822 Converts the stream clock value \bt_p{value} from cycles to
823 nanoseconds from the \ref api-tir-clock-cls-origin "origin" of the
824 clock class \bt_p{clock_class} and sets \bt_p{*ns_from_origin}
830 \link api-tir-clock-cls-prop-offset "offset in cycles"\endlink
831 property of \bt_p{clock_class} to seconds using its
832 \ref api-tir-clock-cls-prop-freq "frequency".
833 -# Converts the \bt_p{value} value to seconds using the frequency of
835 -# Adds the values of 1., 2., and the
836 \link api-tir-clock-cls-prop-offset "offset in seconds"\endlink
837 property of \bt_p{clock_class}.
838 -# Converts the value of 3. to nanoseconds and sets
839 \bt_p{*ns_from_origin} to this result.
841 The following illustration shows the possible scenarios:
843 @image html clock-terminology.png
845 This function can fail and return the
846 #BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR status
847 code if any step of the computation process causes an integer overflow.
849 @param[in] clock_class
850 Stream clock's class.
852 Stream clock's value (cycles) to convert to nanoseconds from
853 the origin of \bt_p{clock_class}.
854 @param[out] ns_from_origin
855 <strong>On success</strong>, \bt_p{*ns_from_origin} is \bt_p{value}
856 converted to nanoseconds from the origin of \bt_p{clock_class}.
858 @retval #BT_UTIL_CLOCK_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OK
860 @retval #BT_UTIL_CLOCK_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR
861 Integer overflow while computing the result.
863 @bt_pre_not_null{clock_class}
864 @bt_pre_not_null{ns_from_origin}
866 @sa bt_util_clock_cycles_to_ns_from_origin() —
867 Converts a clock value from cycles to nanoseconds from the clock's
870 extern bt_clock_class_cycles_to_ns_from_origin_status
871 bt_clock_class_cycles_to_ns_from_origin(
872 const bt_clock_class
*clock_class
,
873 uint64_t value
, int64_t *ns_from_origin
);
878 @name Reference count
884 Increments the \ref api-fund-shared-object "reference count" of
885 the clock class \bt_p{clock_class}.
887 @param[in] clock_class
889 Clock class of which to increment the reference count.
894 @sa bt_clock_class_put_ref() —
895 Decrements the reference count of a clock class.
897 extern void bt_clock_class_get_ref(const bt_clock_class
*clock_class
);
901 Decrements the \ref api-fund-shared-object "reference count" of
902 the clock class \bt_p{clock_class}.
904 @param[in] clock_class
906 Clock class of which to decrement the reference count.
911 @sa bt_clock_class_get_ref() —
912 Increments the reference count of a clock class.
914 extern void bt_clock_class_put_ref(const bt_clock_class
*clock_class
);
918 Decrements the reference count of the clock class
919 \bt_p{_clock_class}, and then sets \bt_p{_clock_class} to \c NULL.
923 Clock class of which to decrement the reference count.
928 @bt_pre_assign_expr{_clock_class}
930 #define BT_CLOCK_CLASS_PUT_REF_AND_RESET(_clock_class) \
932 bt_clock_class_put_ref(_clock_class); \
933 (_clock_class) = NULL; \
938 Decrements the reference count of the clock class \bt_p{_dst}, sets
939 \bt_p{_dst} to \bt_p{_src}, and then sets \bt_p{_src} to \c NULL.
941 This macro effectively moves a clock class reference from the expression
942 \bt_p{_src} to the expression \bt_p{_dst}, putting the existing
943 \bt_p{_dst} reference.
947 Destination expression.
958 @bt_pre_assign_expr{_dst}
959 @bt_pre_assign_expr{_src}
961 #define BT_CLOCK_CLASS_MOVE_REF(_dst, _src) \
963 bt_clock_class_put_ref(_dst); \
976 #endif /* BABELTRACE2_TRACE_IR_CLOCK_CLASS_H */