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
)
341 Sets the frequency (Hz) of the clock class \bt_p{clock_class} to
344 See the \ref api-tir-clock-cls-prop-freq "frequency" property.
346 @param[in] clock_class
347 Clock class of which to set the frequency to \bt_p{frequency}.
349 New frequency of \bt_p{clock_class}.
351 @bt_pre_not_null{clock_class}
352 @bt_pre_hot{clock_class}
354 \bt_p{frequency} is not 0.
356 \bt_p{frequency} is not <code>UINT64_C(-1)</code>.
358 \bt_p{frequency} is greater than the clock class's offset in cycles
359 (as returned by bt_clock_class_get_offset()).
361 @sa bt_clock_class_get_frequency() —
362 Returns the frequency of a clock class.
364 extern void bt_clock_class_set_frequency(bt_clock_class
*clock_class
,
365 uint64_t frequency
) __BT_NOEXCEPT
;
369 Returns the frequency (Hz) of the clock class \bt_p{clock_class}.
371 See the \ref api-tir-clock-cls-prop-freq "frequency" property.
373 @param[in] clock_class
374 Clock class of which to get the frequency.
377 Frequency (Hz) of \bt_p{clock_class}.
379 @bt_pre_not_null{clock_class}
381 @sa bt_clock_class_set_frequency() —
382 Sets the frequency of a clock class.
384 extern uint64_t bt_clock_class_get_frequency(
385 const bt_clock_class
*clock_class
) __BT_NOEXCEPT
;
389 Sets the offset of the clock class \bt_p{clock_class} to
390 \bt_p{offset_seconds} plus \bt_p{offset_cycles} from its
391 \ref api-tir-clock-cls-origin "origin".
393 See the \ref api-tir-clock-cls-prop-offset "offset" property.
395 @param[in] clock_class
396 Clock class of which to set the offset to \bt_p{offset_seconds}
397 and \bt_p{offset_cycles}.
398 @param[in] offset_seconds
399 New offset in seconds of \bt_p{clock_class}.
400 @param[in] offset_cycles
401 New offset in cycles of \bt_p{clock_class}.
403 @bt_pre_not_null{clock_class}
404 @bt_pre_hot{clock_class}
406 \bt_p{offset_cycles} is less than the clock class's frequency
407 (as returned by bt_clock_class_get_frequency()).
409 @sa bt_clock_class_get_offset() —
410 Returns the offset of a clock class.
412 extern void bt_clock_class_set_offset(bt_clock_class
*clock_class
,
413 int64_t offset_seconds
, uint64_t offset_cycles
) __BT_NOEXCEPT
;
417 Returns the offsets in seconds and cycles of the clock class
420 See the \ref api-tir-clock-cls-prop-offset "offset" property.
422 @param[in] clock_class
423 Clock class of which to get the offset.
424 @param[out] offset_seconds
425 When this function returns, \bt_p{*offset_seconds} is the offset in
428 @param[out] offset_cycles
429 When this function returns, \bt_p{*offset_cycles} is the offset in
430 cycles of \bt_p{clock_class}.
432 @bt_pre_not_null{clock_class}
433 @bt_pre_not_null{offset_seconds}
434 @bt_pre_not_null{offset_cycles}
436 @sa bt_clock_class_set_offset() —
437 Sets the offset of a clock class.
439 extern void bt_clock_class_get_offset(const bt_clock_class
*clock_class
,
440 int64_t *offset_seconds
, uint64_t *offset_cycles
) __BT_NOEXCEPT
;
444 Sets the precision (cycles) of the clock class \bt_p{clock_class} to
447 See the \ref api-tir-clock-cls-prop-precision "precision" property.
449 @param[in] clock_class
450 Clock class of which to set the precision to \bt_p{precision}.
452 New precision of \bt_p{clock_class}.
454 @bt_pre_not_null{clock_class}
455 @bt_pre_hot{clock_class}
457 @sa bt_clock_class_get_precision() —
458 Returns the precision of a clock class.
460 extern void bt_clock_class_set_precision(bt_clock_class
*clock_class
,
461 uint64_t precision
) __BT_NOEXCEPT
;
465 Returns the precision (cycles) of the clock class
468 See the \ref api-tir-clock-cls-prop-precision "precision" property.
470 @param[in] clock_class
471 Clock class of which to get the precision.
474 Precision (cycles) of \bt_p{clock_class}.
476 @bt_pre_not_null{clock_class}
478 @sa bt_clock_class_set_precision() —
479 Sets the precision of a clock class.
481 extern uint64_t bt_clock_class_get_precision(
482 const bt_clock_class
*clock_class
) __BT_NOEXCEPT
;
486 Sets whether or not the \ref api-tir-clock-cls-origin "origin"
487 of the clock class \bt_p{clock_class} is the
488 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
490 See the \ref api-tir-clock-cls-prop-origin-unix-epoch "origin is Unix epoch?"
493 @param[in] clock_class
494 Clock class of which to set whether or not its origin is the
496 @param[in] origin_is_unix_epoch
497 #BT_TRUE to make \bt_p{clock_class} have a Unix epoch origin.
499 @bt_pre_not_null{clock_class}
500 @bt_pre_hot{clock_class}
502 @sa bt_clock_class_origin_is_unix_epoch() —
503 Returns whether or not the origin of a clock class is the
506 extern void bt_clock_class_set_origin_is_unix_epoch(bt_clock_class
*clock_class
,
507 bt_bool origin_is_unix_epoch
) __BT_NOEXCEPT
;
511 Returns whether or not the \ref api-tir-clock-cls-origin "origin"
512 of the clock class \bt_p{clock_class} is the
513 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
515 See the \ref api-tir-clock-cls-prop-origin-unix-epoch "origin is Unix epoch?"
518 @param[in] clock_class
519 Clock class of which to get whether or not its origin is the
523 #BT_TRUE if the origin of \bt_p{clock_class} is the Unix epoch.
525 @bt_pre_not_null{clock_class}
527 @sa bt_clock_class_set_origin_is_unix_epoch() —
528 Sets whether or not the origin of a clock class is the Unix epoch.
530 extern bt_bool
bt_clock_class_origin_is_unix_epoch(
531 const bt_clock_class
*clock_class
) __BT_NOEXCEPT
;
535 Status codes for bt_clock_class_set_name().
537 typedef enum bt_clock_class_set_name_status
{
542 BT_CLOCK_CLASS_SET_NAME_STATUS_OK
= __BT_FUNC_STATUS_OK
,
548 BT_CLOCK_CLASS_SET_NAME_STATUS_MEMORY_ERROR
= __BT_FUNC_STATUS_MEMORY_ERROR
,
549 } bt_clock_class_set_name_status
;
553 Sets the name of the clock class \bt_p{clock_class} to
554 a copy of \bt_p{name}.
556 See the \ref api-tir-clock-cls-prop-name "name" property.
558 @param[in] clock_class
559 Clock class of which to set the name to \bt_p{name}.
561 New name of \bt_p{clock_class} (copied).
563 @retval #BT_CLOCK_CLASS_SET_NAME_STATUS_OK
565 @retval #BT_CLOCK_CLASS_SET_NAME_STATUS_MEMORY_ERROR
568 @bt_pre_not_null{clock_class}
569 @bt_pre_hot{clock_class}
570 @bt_pre_not_null{name}
572 @sa bt_clock_class_get_name() —
573 Returns the name of a clock class.
575 extern bt_clock_class_set_name_status
bt_clock_class_set_name(
576 bt_clock_class
*clock_class
, const char *name
) __BT_NOEXCEPT
;
580 Returns the name of the clock class \bt_p{clock_class}.
582 See the \ref api-tir-clock-cls-prop-name "name" property.
584 If \bt_p{clock_class} has no name, this function returns \c NULL.
586 @param[in] clock_class
587 Clock class of which to get the name.
591 Name of \bt_p{clock_class}, or \c NULL if none.
593 The returned pointer remains valid as long as \bt_p{clock_class}
597 @bt_pre_not_null{clock_class}
599 @sa bt_clock_class_set_name() —
600 Sets the name of a clock class.
602 extern const char *bt_clock_class_get_name(
603 const bt_clock_class
*clock_class
) __BT_NOEXCEPT
;
607 Status codes for bt_clock_class_set_description().
609 typedef enum bt_clock_class_set_description_status
{
614 BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_OK
= __BT_FUNC_STATUS_OK
,
620 BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR
= __BT_FUNC_STATUS_MEMORY_ERROR
,
621 } bt_clock_class_set_description_status
;
625 Sets the description of the clock class \bt_p{clock_class} to a copy
626 of \bt_p{description}.
628 See the \ref api-tir-clock-cls-prop-descr "description" property.
630 @param[in] clock_class
631 Clock class of which to set the description to \bt_p{description}.
632 @param[in] description
633 New description of \bt_p{clock_class} (copied).
635 @retval #BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_OK
637 @retval #BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR
640 @bt_pre_not_null{clock_class}
641 @bt_pre_hot{clock_class}
642 @bt_pre_not_null{description}
644 @sa bt_clock_class_get_description() —
645 Returns the description of a clock class.
647 extern bt_clock_class_set_description_status
bt_clock_class_set_description(
648 bt_clock_class
*clock_class
, const char *description
)
653 Returns the description of the clock class \bt_p{clock_class}.
655 See the \ref api-tir-clock-cls-prop-descr "description" property.
657 If \bt_p{clock_class} has no description, this function returns \c NULL.
659 @param[in] clock_class
660 Clock class of which to get the description.
664 Description of \bt_p{clock_class}, or \c NULL if none.
666 The returned pointer remains valid as long as \bt_p{clock_class}
670 @bt_pre_not_null{clock_class}
672 @sa bt_clock_class_set_description() —
673 Sets the description of a clock class.
675 extern const char *bt_clock_class_get_description(
676 const bt_clock_class
*clock_class
) __BT_NOEXCEPT
;
681 <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUID</a>
682 of the clock class \bt_p{clock_class} to a copy of \bt_p{uuid}.
684 See the \ref api-tir-clock-cls-prop-uuid "UUID" property.
686 @param[in] clock_class
687 Clock class of which to set the UUID to \bt_p{uuid}.
689 New UUID of \bt_p{clock_class} (copied).
691 @bt_pre_not_null{clock_class}
692 @bt_pre_hot{clock_class}
693 @bt_pre_not_null{uuid}
695 @sa bt_clock_class_get_uuid() —
696 Returns the UUID of a clock class.
698 extern void bt_clock_class_set_uuid(bt_clock_class
*clock_class
,
699 bt_uuid uuid
) __BT_NOEXCEPT
;
703 Returns the UUID of the clock class \bt_p{clock_class}.
705 See the \ref api-tir-clock-cls-prop-uuid "UUID" property.
707 If \bt_p{clock_class} has no UUID, this function returns \c NULL.
709 @param[in] clock_class
710 Clock class of which to get the UUID.
714 UUID of \bt_p{clock_class}, or \c NULL if none.
716 The returned pointer remains valid as long as \bt_p{clock_class}
720 @bt_pre_not_null{clock_class}
722 @sa bt_clock_class_set_uuid() —
723 Sets the UUID of a clock class.
725 extern bt_uuid
bt_clock_class_get_uuid(
726 const bt_clock_class
*clock_class
) __BT_NOEXCEPT
;
730 Sets the user attributes of the clock class \bt_p{clock_class} to
731 \bt_p{user_attributes}.
733 See the \ref api-tir-clock-cls-prop-user-attrs "user attributes"
737 When you create a default clock class with bt_clock_class_create(),
738 the clock class's initial user attributes is an empty \bt_map_val.
739 Therefore you can borrow it with
740 bt_clock_class_borrow_user_attributes() and fill it directly instead
741 of setting a new one with this function.
743 @param[in] clock_class
744 Clock class of which to set the user attributes to
745 \bt_p{user_attributes}.
746 @param[in] user_attributes
747 New user attributes of \bt_p{clock_class}.
749 @bt_pre_not_null{clock_class}
750 @bt_pre_hot{clock_class}
751 @bt_pre_not_null{user_attributes}
752 @bt_pre_is_map_val{user_attributes}
754 @sa bt_clock_class_borrow_user_attributes() —
755 Borrows the user attributes of a clock class.
757 extern void bt_clock_class_set_user_attributes(
758 bt_clock_class
*clock_class
, const bt_value
*user_attributes
)
763 Borrows the user attributes of the clock class \bt_p{clock_class}.
765 See the \ref api-tir-clock-cls-prop-user-attrs "user attributes"
769 When you create a default clock class with bt_clock_class_create(),
770 the clock class's initial user attributes is an empty \bt_map_val.
772 @param[in] clock_class
773 Clock class from which to borrow the user attributes.
776 User attributes of \bt_p{clock_class} (a \bt_map_val).
778 @bt_pre_not_null{clock_class}
780 @sa bt_clock_class_set_user_attributes() —
781 Sets the user attributes of a clock class.
782 @sa bt_clock_class_borrow_user_attributes_const() —
783 \c const version of this function.
785 extern bt_value
*bt_clock_class_borrow_user_attributes(
786 bt_clock_class
*clock_class
) __BT_NOEXCEPT
;
790 Borrows the user attributes of the clock class \bt_p{clock_class}
793 See bt_clock_class_borrow_user_attributes().
795 extern const bt_value
*bt_clock_class_borrow_user_attributes_const(
796 const bt_clock_class
*clock_class
) __BT_NOEXCEPT
;
807 Status codes for bt_clock_class_cycles_to_ns_from_origin().
809 typedef enum bt_clock_class_cycles_to_ns_from_origin_status
{
814 BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OK
= __BT_FUNC_STATUS_OK
,
818 Integer overflow while computing the result.
820 BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR
= __BT_FUNC_STATUS_OVERFLOW_ERROR
,
821 } bt_clock_class_cycles_to_ns_from_origin_status
;
825 Converts the stream clock value \bt_p{value} from cycles to
826 nanoseconds from the \ref api-tir-clock-cls-origin "origin" of the
827 clock class \bt_p{clock_class} and sets \bt_p{*ns_from_origin}
833 \link api-tir-clock-cls-prop-offset "offset in cycles"\endlink
834 property of \bt_p{clock_class} to seconds using its
835 \ref api-tir-clock-cls-prop-freq "frequency".
836 -# Converts the \bt_p{value} value to seconds using the frequency of
838 -# Adds the values of 1., 2., and the
839 \link api-tir-clock-cls-prop-offset "offset in seconds"\endlink
840 property of \bt_p{clock_class}.
841 -# Converts the value of 3. to nanoseconds and sets
842 \bt_p{*ns_from_origin} to this result.
844 The following illustration shows the possible scenarios:
846 @image html clock-terminology.png
848 This function can fail and return the
849 #BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR status
850 code if any step of the computation process causes an integer overflow.
852 @param[in] clock_class
853 Stream clock's class.
855 Stream clock's value (cycles) to convert to nanoseconds from
856 the origin of \bt_p{clock_class}.
857 @param[out] ns_from_origin
858 <strong>On success</strong>, \bt_p{*ns_from_origin} is \bt_p{value}
859 converted to nanoseconds from the origin of \bt_p{clock_class}.
861 @retval #BT_UTIL_CLOCK_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OK
863 @retval #BT_UTIL_CLOCK_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR
864 Integer overflow while computing the result.
866 @bt_pre_not_null{clock_class}
867 @bt_pre_not_null{ns_from_origin}
869 @sa bt_util_clock_cycles_to_ns_from_origin() —
870 Converts a clock value from cycles to nanoseconds from the clock's
873 extern bt_clock_class_cycles_to_ns_from_origin_status
874 bt_clock_class_cycles_to_ns_from_origin(
875 const bt_clock_class
*clock_class
,
876 uint64_t value
, int64_t *ns_from_origin
) __BT_NOEXCEPT
;
881 @name Reference count
887 Increments the \ref api-fund-shared-object "reference count" of
888 the clock class \bt_p{clock_class}.
890 @param[in] clock_class
892 Clock class of which to increment the reference count.
897 @sa bt_clock_class_put_ref() —
898 Decrements the reference count of a clock class.
900 extern void bt_clock_class_get_ref(
901 const bt_clock_class
*clock_class
) __BT_NOEXCEPT
;
905 Decrements the \ref api-fund-shared-object "reference count" of
906 the clock class \bt_p{clock_class}.
908 @param[in] clock_class
910 Clock class of which to decrement the reference count.
915 @sa bt_clock_class_get_ref() —
916 Increments the reference count of a clock class.
918 extern void bt_clock_class_put_ref(
919 const bt_clock_class
*clock_class
) __BT_NOEXCEPT
;
923 Decrements the reference count of the clock class
924 \bt_p{_clock_class}, and then sets \bt_p{_clock_class} to \c NULL.
928 Clock class of which to decrement the reference count.
933 @bt_pre_assign_expr{_clock_class}
935 #define BT_CLOCK_CLASS_PUT_REF_AND_RESET(_clock_class) \
937 bt_clock_class_put_ref(_clock_class); \
938 (_clock_class) = NULL; \
943 Decrements the reference count of the clock class \bt_p{_dst}, sets
944 \bt_p{_dst} to \bt_p{_src}, and then sets \bt_p{_src} to \c NULL.
946 This macro effectively moves a clock class reference from the expression
947 \bt_p{_src} to the expression \bt_p{_dst}, putting the existing
948 \bt_p{_dst} reference.
952 Destination expression.
963 @bt_pre_assign_expr{_dst}
964 @bt_pre_assign_expr{_src}
966 #define BT_CLOCK_CLASS_MOVE_REF(_dst, _src) \
968 bt_clock_class_put_ref(_dst); \
981 #endif /* BABELTRACE2_TRACE_IR_CLOCK_CLASS_H */