1 #ifndef BABELTRACE2_TRACE_IR_CLOCK_CLASS_H
2 #define BABELTRACE2_TRACE_IR_CLOCK_CLASS_H
5 * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 #ifndef __BT_IN_BABELTRACE_H
27 # error "Please include <babeltrace2/babeltrace.h> instead."
32 #include <babeltrace2/types.h>
39 @defgroup api-tir-clock-cls Clock class
43 Class of \bt_stream clocks.
45 A <strong><em>clock class</em></strong> is the class of \bt_stream
48 A clock class is a \ref api-tir "trace IR" metadata object.
50 <em>Stream clocks</em> only exist conceptually in \bt_name because they
51 are stateful objects. \bt_cp_msg cannot refer to stateful objects
52 because they must not change while being transported from one
53 \bt_comp to the other.
55 Instead of having a stream clock object, messages have a
56 default \bt_cs: this is a snapshot of the value of a stream's default
57 clock (a clock class instance):
59 @image html clocks.png
61 In the illustration above, notice that:
63 - \bt_cp_stream (horizontal blue rectangles) are instances of a
64 \bt_stream_cls (orange).
65 - A stream class has a default clock class (orange bell alarm clock).
66 - Each stream has a default clock (yellow bell alarm clock): this is an
67 instance of the stream's class's default clock class.
68 - Each \bt_msg (objects in blue stream rectangles) created for a given
69 stream has a default \bt_cs (yellow star): this is a snapshot of the
70 stream's default clock.
72 In other words, a default clock snapshot contains the value of the
73 stream's default clock when this message occured.
75 The default clock class property of a \bt_stream_cls is optional:
76 if a stream class has no default clock class, then its instances
77 (\bt_p_stream) have no default clock, therefore all the \bt_p_msg
78 created from this stream have no default clock snapshot.
80 A clock class is a \ref api-fund-shared-object "shared object": get a
81 new reference with bt_clock_class_get_ref() and put an existing
82 reference with bt_clock_class_put_ref().
84 Some library functions \ref api-fund-freezing "freeze" clock classes on
85 success. The documentation of those functions indicate this
88 The type of a clock class is #bt_clock_class.
90 Create a default clock class from a \bt_self_comp with
91 bt_clock_class_create().
93 <h1>\anchor api-tir-clock-cls-origin Clock value vs. clock class origin</h1>
95 The value of a \bt_stream clock (a conceptual instance of a clock class)
96 is in <em>cycles</em>. This value is always positive and is relative to
97 the clock's class's offset, which is relative to its origin.
99 A clock class's origin is one of:
102 <dt>If bt_clock_class_origin_is_unix_epoch() returns #BT_TRUE</dt>
105 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
107 The stream clocks of all the clock classes which have a Unix
108 epoch origin, whatever the clock class
109 <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUIDs</a>,
113 <dt>If bt_clock_class_origin_is_unix_epoch() returns #BT_FALSE</dt>
117 In that case, two clock classes which share the same UUID, as
118 returned by bt_clock_class_get_uuid(), including having no UUID,
119 also share the same origin: their instances (stream clocks) are
124 To compute an effective stream clock value, in cycles from its class's
127 -# Convert the clock class's
128 \link api-tir-clock-cls-prop-offset "offset in seconds"\endlink
129 property to cycles using its
130 \ref api-tir-clock-cls-prop-freq "frequency".
131 -# Add the value of 1., the stream clock's value, and the clock class's
132 \link api-tir-clock-cls-prop-offset "offset in cycles"\endlink
135 Because typical tracer clocks have a high frequency (often 1 GHz
136 and more), an effective stream clock value (cycles since Unix epoch, for
137 example) can be larger than \c UINT64_MAX. This is why a clock class has
138 two offset properties (one in seconds and one in cycles): to make it
139 possible for a stream clock to have smaller values, relative to this
142 The bt_clock_class_cycles_to_ns_from_origin(),
143 bt_util_clock_cycles_to_ns_from_origin(), and
144 bt_clock_snapshot_get_ns_from_origin() functions convert a stream clock
145 value (cycles) to an equivalent <em>nanoseconds from origin</em> value
146 using the relevant clock class properties (frequency and offset).
148 Those functions perform this computation:
150 -# Convert the clock class's "offset in cycles" property to seconds
152 -# Convert the stream clock's value to seconds using the clock class's
154 -# Add the values of 1., 2., and the clock class's "offset in seconds"
156 -# Convert the value of 3. to nanoseconds.
158 The following illustration shows the possible scenarios:
160 @image html clock-terminology.png
162 The clock class's "offset in seconds" property can be negative.
163 For example, considering:
165 - Frequency: 1000 Hz.
166 - Offset in seconds: -10 seconds.
167 - Offset in cycles: 500 cycles (that is, 0.5 seconds).
168 - Stream clock's value: 2000 cycles (that is, 2 seconds).
170 Then the computed value is -7.5 seconds from origin, or
171 -7,500,000,000 nanoseconds from origin.
175 A clock class has the following properties:
178 <dt>\anchor api-tir-clock-cls-prop-freq Frequency</dt>
180 Frequency of the clock class's instances (stream clocks)
183 Use bt_clock_class_set_frequency() and
184 bt_clock_class_get_frequency().
188 \anchor api-tir-clock-cls-prop-offset
189 Offset (in seconds and in cycles)
192 Offset in seconds relative to the clock class's
193 \ref api-tir-clock-cls-origin "origin", and offset in cycles
194 relative to the offset in seconds, of the clock class's
195 instances (stream clocks).
197 The values of the clock class's instances are relative to the
200 Use bt_clock_class_set_offset() and bt_clock_class_get_offset().
203 <dt>\anchor api-tir-clock-cls-prop-precision Precision</dt>
205 Precision of the clock class's instance (stream clocks) values
208 For example, considering a precision of 7 cycles and the stream
209 clock value 42 cycles, the real stream clock value can be
210 anything between 35 cycles and 49 cycles.
212 Use bt_clock_class_set_precision() and
213 bt_clock_class_get_precision().
217 \anchor api-tir-clock-cls-prop-origin-unix-epoch
218 Origin is Unix epoch?
221 Whether or not the clock class's
222 \ref api-tir-clock-cls-origin "origin"
224 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
226 Use bt_clock_class_set_origin_is_unix_epoch() and
227 bt_clock_class_origin_is_unix_epoch().
230 <dt>\anchor api-tir-clock-cls-prop-name \bt_dt_opt Name</dt>
232 Name of the clock class.
234 Use bt_clock_class_set_name() and bt_clock_class_get_name().
237 <dt>\anchor api-tir-clock-cls-prop-descr \bt_dt_opt Description</dt>
239 Description of the clock class.
241 Use bt_clock_class_set_description() and
242 bt_clock_class_get_description().
245 <dt>\anchor api-tir-clock-cls-prop-uuid \bt_dt_opt UUID</dt>
247 <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUID</a>
250 The clock class's UUID uniquely identifies the clock class.
252 When the clock class's origin is \em not the
253 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>,
254 then the clock class's UUID determines whether or not two different
255 clock classes have correlatable instances.
257 Use bt_clock_class_set_uuid() and bt_clock_class_get_uuid().
261 \anchor api-tir-clock-cls-prop-user-attrs
262 \bt_dt_opt User attributes
265 User attributes of the clock class.
267 User attributes are custom attributes attached to a clock class.
269 Use bt_clock_class_set_user_attributes(),
270 bt_clock_class_borrow_user_attributes(), and
271 bt_clock_class_borrow_user_attributes_const().
282 @typedef struct bt_clock_class bt_clock_class;
297 Creates a default clock class from the \bt_self_comp
298 \bt_p{self_component}.
300 On success, the returned clock class has the following property values:
307 <td>\ref api-tir-clock-cls-prop-freq "Frequency"
310 <td>\ref api-tir-clock-cls-prop-offset "Offset" in seconds
313 <td>\ref api-tir-clock-cls-prop-offset "Offset" in cycles
316 <td>\ref api-tir-clock-cls-prop-precision "Precision"
319 <td>\ref api-tir-clock-cls-prop-origin-unix-epoch "Origin is Unix epoch?"
322 <td>\ref api-tir-clock-cls-prop-name "Name"
325 <td>\ref api-tir-clock-cls-prop-descr "Description"
328 <td>\ref api-tir-clock-cls-prop-uuid "UUID"
331 <td>\ref api-tir-clock-cls-prop-user-attrs "User attributes"
332 <td>Empty \bt_map_val
335 @param[in] self_component
336 Self component from which to create the default clock class.
339 New clock class reference, or \c NULL on memory error.
341 @bt_pre_not_null{self_component}
343 extern bt_clock_class
*bt_clock_class_create(bt_self_component
*self_component
);
354 Sets the frequency (Hz) of the clock class \bt_p{clock_class} to
357 See the \ref api-tir-clock-cls-prop-freq "frequency" property.
359 @param[in] clock_class
360 Clock class of which to set the frequency to \bt_p{frequency}.
362 New frequency of \bt_p{clock_class}.
364 @bt_pre_not_null{clock_class}
365 @bt_pre_hot{clock_class}
367 \bt_p{frequency} is not 0.
369 \bt_p{frequency} is not <code>UINT64_C(-1)</code>.
371 \bt_p{frequency} is greater than the clock class's offset in cycles
372 (as returned by bt_clock_class_get_offset()).
374 @sa bt_clock_class_get_frequency() —
375 Returns the frequency of a clock class.
377 extern void bt_clock_class_set_frequency(bt_clock_class
*clock_class
,
382 Returns the frequency (Hz) of the clock class \bt_p{clock_class}.
384 See the \ref api-tir-clock-cls-prop-freq "frequency" property.
386 @param[in] clock_class
387 Clock class of which to get the frequency.
390 Frequency (Hz) of \bt_p{clock_class}.
392 @bt_pre_not_null{clock_class}
394 @sa bt_clock_class_set_frequency() —
395 Sets the frequency of a clock class.
397 extern uint64_t bt_clock_class_get_frequency(
398 const bt_clock_class
*clock_class
);
402 Sets the offset of the clock class \bt_p{clock_class} to
403 \bt_p{offset_seconds} plus \bt_p{offset_cycles} from its
404 \ref api-tir-clock-cls-origin "origin".
406 See the \ref api-tir-clock-cls-prop-offset "offset" property.
408 @param[in] clock_class
409 Clock class of which to set the offset to \bt_p{offset_seconds}
410 and \bt_p{offset_cycles}.
411 @param[in] offset_seconds
412 New offset in seconds of \bt_p{clock_class}.
413 @param[in] offset_cycles
414 New offset in cycles of \bt_p{clock_class}.
416 @bt_pre_not_null{clock_class}
417 @bt_pre_hot{clock_class}
419 \bt_p{offset_cycles} is less than the clock class's frequency
420 (as returned by bt_clock_class_get_frequency()).
422 @sa bt_clock_class_get_offset() —
423 Returns the offset of a clock class.
425 extern void bt_clock_class_set_offset(bt_clock_class
*clock_class
,
426 int64_t offset_seconds
, uint64_t offset_cycles
);
430 Returns the offsets in seconds and cycles of the clock class
433 See the \ref api-tir-clock-cls-prop-offset "offset" property.
435 @param[in] clock_class
436 Clock class of which to get the offset.
437 @param[out] offset_seconds
438 When this function returns, \bt_p{*offset_seconds} is the offset in
441 @param[out] offset_cycles
442 When this function returns, \bt_p{*offset_cycles} is the offset in
443 cycles of \bt_p{clock_class}.
445 @bt_pre_not_null{clock_class}
446 @bt_pre_not_null{offset_seconds}
447 @bt_pre_not_null{offset_cycles}
449 @sa bt_clock_class_set_offset() —
450 Sets the offset of a clock class.
452 extern void bt_clock_class_get_offset(const bt_clock_class
*clock_class
,
453 int64_t *offset_seconds
, uint64_t *offset_cycles
);
457 Sets the precision (cycles) of the clock class \bt_p{clock_class} to
460 See the \ref api-tir-clock-cls-prop-precision "precision" property.
462 @param[in] clock_class
463 Clock class of which to set the precision to \bt_p{precision}.
465 New precision of \bt_p{clock_class}.
467 @bt_pre_not_null{clock_class}
468 @bt_pre_hot{clock_class}
470 @sa bt_clock_class_get_precision() —
471 Returns the precision of a clock class.
473 extern void bt_clock_class_set_precision(bt_clock_class
*clock_class
,
478 Returns the precision (cycles) of the clock class
481 See the \ref api-tir-clock-cls-prop-precision "precision" property.
483 @param[in] clock_class
484 Clock class of which to get the precision.
487 Precision (cycles) of \bt_p{clock_class}.
489 @bt_pre_not_null{clock_class}
491 @sa bt_clock_class_set_precision() —
492 Sets the precision of a clock class.
494 extern uint64_t bt_clock_class_get_precision(
495 const bt_clock_class
*clock_class
);
499 Sets whether or not the \ref api-tir-clock-cls-origin "origin"
500 of the clock class \bt_p{clock_class} is the
501 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
503 See the \ref api-tir-clock-cls-prop-origin-unix-epoch "origin is Unix epoch?"
506 @param[in] clock_class
507 Clock class of which to set whether or not its origin is the
509 @param[in] origin_is_unix_epoch
510 #BT_TRUE to make \bt_p{clock_class} have a Unix epoch origin.
512 @bt_pre_not_null{clock_class}
513 @bt_pre_hot{clock_class}
515 @sa bt_clock_class_origin_is_unix_epoch() —
516 Returns whether or not the origin of a clock class is the
519 extern void bt_clock_class_set_origin_is_unix_epoch(bt_clock_class
*clock_class
,
520 bt_bool origin_is_unix_epoch
);
524 Returns whether or not the \ref api-tir-clock-cls-origin "origin"
525 of the clock class \bt_p{clock_class} is the
526 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
528 See the \ref api-tir-clock-cls-prop-origin-unix-epoch "origin is Unix epoch?"
531 @param[in] clock_class
532 Clock class of which to get whether or not its origin is the
536 #BT_TRUE if the origin of \bt_p{clock_class} is the Unix epoch.
538 @bt_pre_not_null{clock_class}
540 @sa bt_clock_class_set_origin_is_unix_epoch() —
541 Sets whether or not the origin of a clock class is the Unix epoch.
543 extern bt_bool
bt_clock_class_origin_is_unix_epoch(
544 const bt_clock_class
*clock_class
);
548 Status codes for bt_clock_class_set_name().
550 typedef enum bt_clock_class_set_name_status
{
555 BT_CLOCK_CLASS_SET_NAME_STATUS_OK
= __BT_FUNC_STATUS_OK
,
561 BT_CLOCK_CLASS_SET_NAME_STATUS_MEMORY_ERROR
= __BT_FUNC_STATUS_MEMORY_ERROR
,
562 } bt_clock_class_set_name_status
;
566 Sets the name of the clock class \bt_p{clock_class} to
567 a copy of \bt_p{name}.
569 See the \ref api-tir-clock-cls-prop-name "name" property.
571 @param[in] clock_class
572 Clock class of which to set the name to \bt_p{name}.
574 New name of \bt_p{clock_class} (copied).
576 @retval #BT_CLOCK_CLASS_SET_NAME_STATUS_OK
578 @retval #BT_CLOCK_CLASS_SET_NAME_STATUS_MEMORY_ERROR
581 @bt_pre_not_null{clock_class}
582 @bt_pre_hot{clock_class}
583 @bt_pre_not_null{name}
585 @sa bt_clock_class_get_name() —
586 Returns the name of a clock class.
588 extern bt_clock_class_set_name_status
bt_clock_class_set_name(
589 bt_clock_class
*clock_class
, const char *name
);
593 Returns the name of the clock class \bt_p{clock_class}.
595 See the \ref api-tir-clock-cls-prop-name "name" property.
597 If \bt_p{clock_class} has no name, this function returns \c NULL.
599 @param[in] clock_class
600 Clock class of which to get the name.
604 Name of \bt_p{clock_class}, or \c NULL if none.
606 The returned pointer remains valid as long as \bt_p{clock_class}
610 @bt_pre_not_null{clock_class}
612 @sa bt_clock_class_set_name() —
613 Sets the name of a clock class.
615 extern const char *bt_clock_class_get_name(
616 const bt_clock_class
*clock_class
);
620 Status codes for bt_clock_class_set_description().
622 typedef enum bt_clock_class_set_description_status
{
627 BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_OK
= __BT_FUNC_STATUS_OK
,
633 BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR
= __BT_FUNC_STATUS_MEMORY_ERROR
,
634 } bt_clock_class_set_description_status
;
638 Sets the description of the clock class \bt_p{clock_class} to a copy
639 of \bt_p{description}.
641 See the \ref api-tir-clock-cls-prop-descr "description" property.
643 @param[in] clock_class
644 Clock class of which to set the description to \bt_p{description}.
645 @param[in] description
646 New description of \bt_p{clock_class} (copied).
648 @retval #BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_OK
650 @retval #BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR
653 @bt_pre_not_null{clock_class}
654 @bt_pre_hot{clock_class}
655 @bt_pre_not_null{description}
657 @sa bt_clock_class_get_description() —
658 Returns the description of a clock class.
660 extern bt_clock_class_set_description_status
bt_clock_class_set_description(
661 bt_clock_class
*clock_class
, const char *description
);
665 Returns the description of the clock class \bt_p{clock_class}.
667 See the \ref api-tir-clock-cls-prop-descr "description" property.
669 If \bt_p{clock_class} has no description, this function returns \c NULL.
671 @param[in] clock_class
672 Clock class of which to get the description.
676 Description of \bt_p{clock_class}, or \c NULL if none.
678 The returned pointer remains valid as long as \bt_p{clock_class}
682 @bt_pre_not_null{clock_class}
684 @sa bt_clock_class_set_description() —
685 Sets the description of a clock class.
687 extern const char *bt_clock_class_get_description(
688 const bt_clock_class
*clock_class
);
693 <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUID</a>
694 of the clock class \bt_p{clock_class} to a copy of \bt_p{uuid}.
696 See the \ref api-tir-clock-cls-prop-uuid "UUID" property.
698 @param[in] clock_class
699 Clock class of which to set the UUID to \bt_p{uuid}.
701 New UUID of \bt_p{clock_class} (copied).
703 @bt_pre_not_null{clock_class}
704 @bt_pre_hot{clock_class}
705 @bt_pre_not_null{uuid}
707 @sa bt_clock_class_get_uuid() —
708 Returns the UUID of a clock class.
710 extern void bt_clock_class_set_uuid(bt_clock_class
*clock_class
,
715 Returns the UUID of the clock class \bt_p{clock_class}.
717 See the \ref api-tir-clock-cls-prop-uuid "UUID" property.
719 If \bt_p{clock_class} has no UUID, this function returns \c NULL.
721 @param[in] clock_class
722 Clock class of which to get the UUID.
726 UUID of \bt_p{clock_class}, or \c NULL if none.
728 The returned pointer remains valid as long as \bt_p{clock_class}
732 @bt_pre_not_null{clock_class}
734 @sa bt_clock_class_set_uuid() —
735 Sets the UUID of a clock class.
737 extern bt_uuid
bt_clock_class_get_uuid(
738 const bt_clock_class
*clock_class
);
742 Sets the user attributes of the clock class \bt_p{clock_class} to
743 \bt_p{user_attributes}.
745 See the \ref api-tir-clock-cls-prop-user-attrs "user attributes"
749 When you create a default clock class with bt_clock_class_create(),
750 the clock class's initial user attributes is an empty \bt_map_val.
751 Therefore you can borrow it with
752 bt_clock_class_borrow_user_attributes() and fill it directly instead
753 of setting a new one with this function.
755 @param[in] clock_class
756 Clock class of which to set the user attributes to
757 \bt_p{user_attributes}.
758 @param[in] user_attributes
759 New user attributes of \bt_p{clock_class}.
761 @bt_pre_not_null{clock_class}
762 @bt_pre_hot{clock_class}
763 @bt_pre_not_null{user_attributes}
764 @bt_pre_is_map_val{user_attributes}
766 @sa bt_clock_class_borrow_user_attributes() —
767 Borrows the user attributes of a clock class.
769 extern void bt_clock_class_set_user_attributes(
770 bt_clock_class
*clock_class
, const bt_value
*user_attributes
);
774 Borrows the user attributes of the clock class \bt_p{clock_class}.
776 See the \ref api-tir-clock-cls-prop-user-attrs "user attributes"
780 When you create a default clock class with bt_clock_class_create(),
781 the clock class's initial user attributes is an empty \bt_map_val.
783 @param[in] clock_class
784 Clock class from which to borrow the user attributes.
787 User attributes of \bt_p{clock_class} (a \bt_map_val).
789 @bt_pre_not_null{clock_class}
791 @sa bt_clock_class_set_user_attributes() —
792 Sets the user attributes of a clock class.
793 @sa bt_clock_class_borrow_user_attributes_const() —
794 \c const version of this function.
796 extern bt_value
*bt_clock_class_borrow_user_attributes(
797 bt_clock_class
*clock_class
);
801 Borrows the user attributes of the clock class \bt_p{clock_class}
804 See bt_clock_class_borrow_user_attributes().
806 extern const bt_value
*bt_clock_class_borrow_user_attributes_const(
807 const bt_clock_class
*clock_class
);
818 Status codes for bt_clock_class_cycles_to_ns_from_origin().
820 typedef enum bt_clock_class_cycles_to_ns_from_origin_status
{
825 BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OK
= __BT_FUNC_STATUS_OK
,
829 Integer overflow while computing the result.
831 BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR
= __BT_FUNC_STATUS_OVERFLOW_ERROR
,
832 } bt_clock_class_cycles_to_ns_from_origin_status
;
836 Converts the stream clock value \bt_p{value} from cycles to
837 nanoseconds from the \ref api-tir-clock-cls-origin "origin" of the
838 clock class \bt_p{clock_class} and sets \bt_p{*ns_from_origin}
844 \link api-tir-clock-cls-prop-offset "offset in cycles"\endlink
845 property of \bt_p{clock_class} to seconds using its
846 \ref api-tir-clock-cls-prop-freq "frequency".
847 -# Converts the \bt_p{value} value to seconds using the frequency of
849 -# Adds the values of 1., 2., and the
850 \link api-tir-clock-cls-prop-offset "offset in seconds"\endlink
851 property of \bt_p{clock_class}.
852 -# Converts the value of 3. to nanoseconds and sets
853 \bt_p{*ns_from_origin} to this result.
855 The following illustration shows the possible scenarios:
857 @image html clock-terminology.png
859 This function can fail and return the
860 #BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR status
861 code if any step of the computation process causes an integer overflow.
863 @param[in] clock_class
864 Stream clock's class.
866 Stream clock's value (cycles) to convert to nanoseconds from
867 the origin of \bt_p{clock_class}.
868 @param[out] ns_from_origin
869 <strong>On success</strong>, \bt_p{*ns_from_origin} is \bt_p{value}
870 converted to nanoseconds from the origin of \bt_p{clock_class}.
872 @retval #BT_UTIL_CLOCK_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OK
874 @retval #BT_UTIL_CLOCK_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR
875 Integer overflow while computing the result.
877 @bt_pre_not_null{clock_class}
878 @bt_pre_not_null{ns_from_origin}
880 @sa bt_util_clock_cycles_to_ns_from_origin() —
881 Converts a clock value from cycles to nanoseconds from the clock's
884 extern bt_clock_class_cycles_to_ns_from_origin_status
885 bt_clock_class_cycles_to_ns_from_origin(
886 const bt_clock_class
*clock_class
,
887 uint64_t value
, int64_t *ns_from_origin
);
892 @name Reference count
898 Increments the \ref api-fund-shared-object "reference count" of
899 the clock class \bt_p{clock_class}.
901 @param[in] clock_class
903 Clock class of which to increment the reference count.
908 @sa bt_clock_class_put_ref() —
909 Decrements the reference count of a clock class.
911 extern void bt_clock_class_get_ref(const bt_clock_class
*clock_class
);
915 Decrements the \ref api-fund-shared-object "reference count" of
916 the clock class \bt_p{clock_class}.
918 @param[in] clock_class
920 Clock class of which to decrement the reference count.
925 @sa bt_clock_class_get_ref() —
926 Increments the reference count of a clock class.
928 extern void bt_clock_class_put_ref(const bt_clock_class
*clock_class
);
932 Decrements the reference count of the clock class
933 \bt_p{_clock_class}, and then sets \bt_p{_clock_class} to \c NULL.
937 Clock class of which to decrement the reference count.
942 @bt_pre_assign_expr{_clock_class}
944 #define BT_CLOCK_CLASS_PUT_REF_AND_RESET(_clock_class) \
946 bt_clock_class_put_ref(_clock_class); \
947 (_clock_class) = NULL; \
952 Decrements the reference count of the clock class \bt_p{_dst}, sets
953 \bt_p{_dst} to \bt_p{_src}, and then sets \bt_p{_src} to \c NULL.
955 This macro effectively moves a clock class reference from the expression
956 \bt_p{_src} to the expression \bt_p{_dst}, putting the existing
957 \bt_p{_dst} reference.
961 Destination expression.
972 @bt_pre_assign_expr{_dst}
973 @bt_pre_assign_expr{_src}
975 #define BT_CLOCK_CLASS_MOVE_REF(_dst, _src) \
977 bt_clock_class_put_ref(_dst); \
990 #endif /* BABELTRACE2_TRACE_IR_CLOCK_CLASS_H */