.gitignore: add some missing files
[babeltrace.git] / include / babeltrace2 / trace-ir / clock-class.h
CommitLineData
ac0c6bdd 1/*
0235b0db 2 * SPDX-License-Identifier: MIT
ac0c6bdd 3 *
0235b0db 4 * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation
ac0c6bdd
PP
5 */
6
0235b0db
MJ
7#ifndef BABELTRACE2_TRACE_IR_CLOCK_CLASS_H
8#define BABELTRACE2_TRACE_IR_CLOCK_CLASS_H
9
f38da6ca
SM
10/* IWYU pragma: private, include <babeltrace2/babeltrace.h> */
11
4fa90f32
PP
12#ifndef __BT_IN_BABELTRACE_H
13# error "Please include <babeltrace2/babeltrace.h> instead."
14#endif
15
ac0c6bdd 16#include <stdint.h>
9d408fca 17
3fadfbc0 18#include <babeltrace2/types.h>
ac0c6bdd
PP
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
43c59509
PP
24/*!
25@defgroup api-tir-clock-cls Clock class
26@ingroup api-tir
44c440bc 27
43c59509
PP
28@brief
29 Class of \bt_stream clocks.
c6962c96 30
43c59509
PP
31A <strong><em>clock class</em></strong> is the class of \bt_stream
32clocks.
33
34A clock class is a \ref api-tir "trace IR" metadata object.
35
3f2ebcee
SM
36<em>Stream clocks</em> only exist conceptually in \bt_name because
37they're stateful objects. \bt_cp_msg cannot refer to stateful objects
43c59509
PP
38because they must not change while being transported from one
39\bt_comp to the other.
40
41Instead of having a stream clock object, messages have a
42default \bt_cs: this is a snapshot of the value of a stream's default
43clock (a clock class instance):
44
45@image html clocks.png
46
47In the illustration above, notice that:
48
49- \bt_cp_stream (horizontal blue rectangles) are instances of a
50 \bt_stream_cls (orange).
3f2ebcee 51
43c59509 52- A stream class has a default clock class (orange bell alarm clock).
3f2ebcee 53
43c59509
PP
54- Each stream has a default clock (yellow bell alarm clock): this is an
55 instance of the stream's class's default clock class.
3f2ebcee 56
43c59509
PP
57- Each \bt_msg (objects in blue stream rectangles) created for a given
58 stream has a default \bt_cs (yellow star): this is a snapshot of the
59 stream's default clock.
60
61 In other words, a default clock snapshot contains the value of the
118ae153 62 stream's default clock when this message occurred.
43c59509
PP
63
64The default clock class property of a \bt_stream_cls is optional:
65if a stream class has no default clock class, then its instances
66(\bt_p_stream) have no default clock, therefore all the \bt_p_msg
67created from this stream have no default clock snapshot.
68
69A clock class is a \ref api-fund-shared-object "shared object": get a
70new reference with bt_clock_class_get_ref() and put an existing
71reference with bt_clock_class_put_ref().
72
73Some library functions \ref api-fund-freezing "freeze" clock classes on
74success. The documentation of those functions indicate this
75postcondition.
76
77The type of a clock class is #bt_clock_class.
78
79Create a default clock class from a \bt_self_comp with
80bt_clock_class_create().
81
3f2ebcee 82<h1>\anchor api-tir-clock-cls-origin Clock value vs. clock origin</h1>
43c59509
PP
83
84The value of a \bt_stream clock (a conceptual instance of a clock class)
85is in <em>cycles</em>. This value is always positive and is relative to
3f2ebcee 86the clock's offset, which is itself relative to its origin.
43c59509 87
3f2ebcee 88A clock's origin is one of, depending on its class:
43c59509
PP
89
90<dl>
3f2ebcee
SM
91 <dt>If bt_clock_class_origin_is_unknown() returns #BT_TRUE</dt>
92 <dd>
93 Undefined.
94
95 Two stream clocks of which the classes have an unknown
96 origin only have a correlation if they share the same
97 \link api-tir-clock-cls-prop-iden identity\endlink.
98 </dd>
99
43c59509
PP
100 <dt>If bt_clock_class_origin_is_unix_epoch() returns #BT_TRUE</dt>
101 <dd>
102 The
103 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
104
3f2ebcee
SM
105 All stream clocks with a Unix epoch origin, whatever their
106 \link api-tir-clock-cls-prop-iden identity\endlink,
107 have a correlation.
c33d46d2
SM
108
109 Check whether or not two clock classes share the same identity
110 with bt_clock_class_has_same_identity().
43c59509
PP
111 </dd>
112
3f2ebcee
SM
113 <dt>
114 Otherwise (only available when the clock class was created
115 from a \bt_comp which belongs to a trace processing \bt_graph
116 with the effective \bt_mip version&nbsp;1)
117 </dt>
43c59509 118 <dd>
3f2ebcee
SM
119 The namespace, name, and
120 <a href="https://en.wikipedia.org/wiki/Unique_identifier">unique identifier</a>
121 (UID) tuple returned by
122 bt_clock_class_get_origin_namespace(),
123 bt_clock_class_get_origin_name(), and
124 bt_clock_class_get_origin_uid().
125
126 All stream clocks with the same custom origin, whatever their
127 \link api-tir-clock-cls-prop-iden identity\endlink,
128 have a correlation.
c33d46d2
SM
129
130 Check whether or not two clock classes share the same identity
131 with bt_clock_class_has_same_identity().
43c59509
PP
132 </dd>
133</dl>
134
3f2ebcee 135To compute an effective stream clock value, in cycles from its origin:
43c59509 136
3f2ebcee 137-# Convert the clock's
43c59509
PP
138 \link api-tir-clock-cls-prop-offset "offset in seconds"\endlink
139 property to cycles using its
140 \ref api-tir-clock-cls-prop-freq "frequency".
3f2ebcee
SM
141
142-# Add the value of step&nbsp;1, the stream clock's value,
143 and the clock's
43c59509
PP
144 \link api-tir-clock-cls-prop-offset "offset in cycles"\endlink
145 property.
146
147Because typical tracer clocks have a high frequency (often 1&nbsp;GHz
148and more), an effective stream clock value (cycles since Unix epoch, for
3f2ebcee
SM
149example) can be \em larger than \c UINT64_MAX. This is why a clock class
150has two offset properties (one in seconds and one in cycles): to make it
43c59509
PP
151possible for a stream clock to have smaller values, relative to this
152offset.
153
154The bt_clock_class_cycles_to_ns_from_origin(),
155bt_util_clock_cycles_to_ns_from_origin(), and
156bt_clock_snapshot_get_ns_from_origin() functions convert a stream clock
157value (cycles) to an equivalent <em>nanoseconds from origin</em> value
158using the relevant clock class properties (frequency and offset).
159
160Those functions perform this computation:
161
3f2ebcee 162-# Convert the clock's "offset in cycles" property to seconds using its
43c59509 163 frequency.
3f2ebcee
SM
164
165-# Convert the clock's value to seconds using the clock's frequency.
166
167-# Add the values of step&nbsp;1, step&nbsp;2, and the clock's
168 "offset in seconds" property.
169
170-# Convert the value of step&nbsp;3 to nanoseconds.
43c59509
PP
171
172The following illustration shows the possible scenarios:
173
174@image html clock-terminology.png
175
3f2ebcee
SM
176The clock's "offset in seconds" property can be negative. For example,
177considering:
43c59509
PP
178
179- Frequency: 1000&nbsp;Hz.
1eca514c 180- Offset in seconds: −10&nbsp;seconds.
43c59509
PP
181- Offset in cycles: 500&nbsp;cycles (that is, 0.5&nbsp;seconds).
182- Stream clock's value: 2000&nbsp;cycles (that is, 2&nbsp;seconds).
183
1eca514c
PP
184Then the computed value is −7.5&nbsp;seconds from origin, or
185−7,500,000,000&nbsp;nanoseconds from origin.
43c59509
PP
186
187<h1>Properties</h1>
188
189A clock class has the following properties:
190
191<dl>
192 <dt>\anchor api-tir-clock-cls-prop-freq Frequency</dt>
193 <dd>
194 Frequency of the clock class's instances (stream clocks)
195 (cycles/second).
196
197 Use bt_clock_class_set_frequency() and
198 bt_clock_class_get_frequency().
199 </dd>
200
201 <dt>
202 \anchor api-tir-clock-cls-prop-offset
203 Offset (in seconds and in cycles)
204 </dt>
205 <dd>
3f2ebcee
SM
206 Offset in seconds relative to the
207 \ref api-tir-clock-cls-origin "origin" of the clock class's
208 instances (stream clocks), and offset in cycles relative to the
209 offset in seconds.
43c59509
PP
210
211 The values of the clock class's instances are relative to the
212 computed offset.
213
214 Use bt_clock_class_set_offset() and bt_clock_class_get_offset().
215 </dd>
216
a8e200ad
SM
217 <dt>
218 \anchor api-tir-clock-cls-prop-precision Precision
219 (optional when the clock class was created
220 from a \bt_comp which belongs to a trace processing \bt_graph
221 with the effective \bt_mip version&nbsp;1)
222 </dt>
43c59509
PP
223 <dd>
224 Precision of the clock class's instance (stream clocks) values
225 (cycles).
226
85f6ebeb
SM
227 For example, considering a precision of 7&nbsp;cycles, an
228 \link api-tir-clock-cls-prop-accuracy accuracy\endlink
229 of 0&nbsp;cycles, and the stream
43c59509
PP
230 clock value 42&nbsp;cycles, the real stream clock value can be
231 anything between 35&nbsp;cycles and 49&nbsp;cycles.
232
233 Use bt_clock_class_set_precision() and
a8e200ad 234 bt_clock_class_get_opt_precision().
43c59509
PP
235 </dd>
236
85f6ebeb
SM
237 <dt>
238 \anchor api-tir-clock-cls-prop-accuracy
239 \bt_dt_opt Accuracy
240 (only available when the clock class was created
241 from a \bt_comp which belongs to a trace processing \bt_graph
242 with the effective \bt_mip version&nbsp;1)
243 </dt>
244 <dd>
245 Accuracy of the clock class's instance (stream clocks) values
246 (cycles).
247
248 For example, considering an accuracy of 7&nbsp;cycles, a
249 \link api-tir-clock-cls-prop-precision precision\endlink
250 of 0&nbsp;cycles, and the stream
251 clock value 42&nbsp;cycles, the real stream clock value can be
252 anything between 35&nbsp;cycles and 49&nbsp;cycles.
253
254 Use bt_clock_class_set_accuracy() and
255 bt_clock_class_get_accuracy().
256 </dd>
257
43c59509 258 <dt>
3f2ebcee
SM
259 \anchor api-tir-clock-cls-prop-origin
260 Origin
43c59509
PP
261 </dt>
262 <dd>
3f2ebcee
SM
263 Origin of the clock class's instances (stream clocks).
264
265 Depending on the effective \bt_mip (MIP) version of the trace
266 processing \bt_graph:
267
268 <dl>
269 <dt>MIP&nbsp;0 or MIP&nbsp;1</dt>
270 <dd>
271 <dl>
272 <dt>Unknown origin</dt>
273 <dd>
274 Use bt_clock_class_set_origin_unknown() and
275 bt_clock_class_origin_is_unknown().
276 </dd>
277
278 <dt>Unix epoch origin</dt>
279 <dd>
280 Use bt_clock_class_set_origin_unix_epoch() and
281 bt_clock_class_origin_is_unix_epoch(),
282 </dd>
283 </dl>
284 </dd>
285
286 <dt>MIP&nbsp;1: custom origin</dt>
287 <dd>
288 Use bt_clock_class_set_origin(),
289 bt_clock_class_get_origin_namespace(),
290 bt_clock_class_get_origin_name(), and
291 bt_clock_class_get_origin_uid().
292 </dd>
293 </dl>
43c59509
PP
294 </dd>
295
3f2ebcee 296 <dt>\anchor api-tir-clock-cls-prop-iden \bt_dt_opt Identity</dt>
43c59509 297 <dd>
3f2ebcee
SM
298 Identity of the clock class's instances (stream clocks).
299
300 Depending on the effective \bt_mip (MIP) version of the trace
301 processing \bt_graph:
302
303 <dl>
304 <dt>MIP&nbsp;0</dt>
305 <dd>
306 The name and UUID property pair.
307
308 A valid identity only requires the UUID property.
43c59509 309
3f2ebcee
SM
310 Use bt_clock_class_set_name(), bt_clock_class_get_name(),
311 bt_clock_class_set_uuid(), and bt_clock_class_get_uuid().
312 </dd>
313
314 <dt>MIP&nbsp;1</dt>
315 <dd>
316 The namespace, name, and UID property tuple.
317
318 A valid identity only requires the name and UID properties.
319
320 Use bt_clock_class_set_namespace(), bt_clock_class_get_namespace(),
321 bt_clock_class_set_name(), bt_clock_class_get_name(),
322 bt_clock_class_set_uid(), and bt_clock_class_get_uid().
323 </dd>
324 </dl>
43c59509
PP
325 </dd>
326
327 <dt>\anchor api-tir-clock-cls-prop-descr \bt_dt_opt Description</dt>
328 <dd>
329 Description of the clock class.
330
331 Use bt_clock_class_set_description() and
332 bt_clock_class_get_description().
333 </dd>
334
43c59509
PP
335 <dt>
336 \anchor api-tir-clock-cls-prop-user-attrs
337 \bt_dt_opt User attributes
338 </dt>
339 <dd>
340 User attributes of the clock class.
341
342 User attributes are custom attributes attached to a clock class.
343
344 Use bt_clock_class_set_user_attributes(),
345 bt_clock_class_borrow_user_attributes(), and
346 bt_clock_class_borrow_user_attributes_const().
347 </dd>
348</dl>
349*/
350
351/*! @{ */
352
353/*!
354@name Type
355@{
356
357@typedef struct bt_clock_class bt_clock_class;
358
359@brief
360 Clock class.
361
362@}
363*/
364
365/*!
366@name Creation
367@{
368*/
369
370/*!
371@brief
372 Creates a default clock class from the \bt_self_comp
373 \bt_p{self_component}.
374
375On success, the returned clock class has the following property values:
376
377<table>
378 <tr>
379 <th>Property
380 <th>Value
381 <tr>
382 <td>\ref api-tir-clock-cls-prop-freq "Frequency"
383 <td>1&nbsp;GHz
384 <tr>
385 <td>\ref api-tir-clock-cls-prop-offset "Offset" in seconds
386 <td>0&nbsp;seconds
387 <tr>
388 <td>\ref api-tir-clock-cls-prop-offset "Offset" in cycles
389 <td>0&nbsp;cycles
390 <tr>
391 <td>\ref api-tir-clock-cls-prop-precision "Precision"
a8e200ad
SM
392 <td>
393 Depending on the effective \bt_mip (MIP) version of the trace
394 processing \bt_graph:
395
396 <dl>
397 <dt>MIP&nbsp;0</dt>
398 <dd>0&nbsp;cycles</dd>
399
400 <dt>MIP&nbsp;1</dt>
401 <dd>Unknown</dd>
402 </dl>
85f6ebeb
SM
403 <tr>
404 <td>
405 \bt_mip version&nbsp;1:
406 \ref api-tir-stream-cls-prop-accuracy "accuracy"
407 <td>Unknown
43c59509 408 <tr>
3f2ebcee
SM
409 <td>\ref api-tir-clock-cls-prop-origin "Origin"
410 <td>Unix epoch
43c59509 411 <tr>
3f2ebcee
SM
412 <td>\ref api-tir-clock-cls-prop-iden "Identity"
413 <td>
414 <em>None</em>, that is, depending on the effective \bt_mip (MIP)
415 version of the trace processing \bt_graph:
416
417 <dl>
418 <dt>MIP&nbsp;0</dt>
419 <dd>No name and no UUID</dd>
420
421 <dt>MIP&nbsp;1</dt>
422 <dd>No namespace, no name, and no UID</dd>
423 </dl>
43c59509
PP
424 <tr>
425 <td>\ref api-tir-clock-cls-prop-descr "Description"
426 <td>\em None
43c59509
PP
427 <tr>
428 <td>\ref api-tir-clock-cls-prop-user-attrs "User attributes"
429 <td>Empty \bt_map_val
430</table>
431
432@param[in] self_component
433 Self component from which to create the default clock class.
434
435@returns
436 New clock class reference, or \c NULL on memory error.
437
438@bt_pre_not_null{self_component}
439*/
4c81a2b7
PP
440extern bt_clock_class *bt_clock_class_create(bt_self_component *self_component)
441 __BT_NOEXCEPT;
43c59509
PP
442
443/*! @} */
444
445/*!
446@name Properties
447@{
448*/
449
450/*!
451@brief
452 Sets the frequency (Hz) of the clock class \bt_p{clock_class} to
453 \bt_p{frequency}.
454
455See the \ref api-tir-clock-cls-prop-freq "frequency" property.
456
457@param[in] clock_class
458 Clock class of which to set the frequency to \bt_p{frequency}.
459@param[in] frequency
460 New frequency of \bt_p{clock_class}.
461
462@bt_pre_not_null{clock_class}
463@bt_pre_hot{clock_class}
464@pre
465 \bt_p{frequency} is not 0.
466@pre
467 \bt_p{frequency} is not <code>UINT64_C(-1)</code>.
468@pre
469 \bt_p{frequency} is greater than the clock class's offset in cycles
470 (as returned by bt_clock_class_get_offset()).
471
472@sa bt_clock_class_get_frequency() &mdash;
473 Returns the frequency of a clock class.
474*/
475extern void bt_clock_class_set_frequency(bt_clock_class *clock_class,
4c81a2b7 476 uint64_t frequency) __BT_NOEXCEPT;
43c59509
PP
477
478/*!
479@brief
480 Returns the frequency (Hz) of the clock class \bt_p{clock_class}.
481
482See the \ref api-tir-clock-cls-prop-freq "frequency" property.
483
484@param[in] clock_class
485 Clock class of which to get the frequency.
486
487@returns
488 Frequency (Hz) of \bt_p{clock_class}.
489
490@bt_pre_not_null{clock_class}
491
492@sa bt_clock_class_set_frequency() &mdash;
493 Sets the frequency of a clock class.
494*/
495extern uint64_t bt_clock_class_get_frequency(
4c81a2b7 496 const bt_clock_class *clock_class) __BT_NOEXCEPT;
43c59509
PP
497
498/*!
499@brief
500 Sets the offset of the clock class \bt_p{clock_class} to
501 \bt_p{offset_seconds} plus \bt_p{offset_cycles} from its
502 \ref api-tir-clock-cls-origin "origin".
503
504See the \ref api-tir-clock-cls-prop-offset "offset" property.
505
506@param[in] clock_class
507 Clock class of which to set the offset to \bt_p{offset_seconds}
508 and \bt_p{offset_cycles}.
509@param[in] offset_seconds
510 New offset in seconds of \bt_p{clock_class}.
511@param[in] offset_cycles
512 New offset in cycles of \bt_p{clock_class}.
513
514@bt_pre_not_null{clock_class}
515@bt_pre_hot{clock_class}
516@pre
517 \bt_p{offset_cycles} is less than the clock class's frequency
518 (as returned by bt_clock_class_get_frequency()).
519
520@sa bt_clock_class_get_offset() &mdash;
521 Returns the offset of a clock class.
522*/
523extern void bt_clock_class_set_offset(bt_clock_class *clock_class,
4c81a2b7 524 int64_t offset_seconds, uint64_t offset_cycles) __BT_NOEXCEPT;
43c59509
PP
525
526/*!
527@brief
528 Returns the offsets in seconds and cycles of the clock class
529 \bt_p{clock_class}.
530
531See the \ref api-tir-clock-cls-prop-offset "offset" property.
532
533@param[in] clock_class
534 Clock class of which to get the offset.
535@param[out] offset_seconds
536 When this function returns, \bt_p{*offset_seconds} is the offset in
537 seconds of
538 \bt_p{clock_class}.
539@param[out] offset_cycles
540 When this function returns, \bt_p{*offset_cycles} is the offset in
541 cycles of \bt_p{clock_class}.
542
543@bt_pre_not_null{clock_class}
544@bt_pre_not_null{offset_seconds}
545@bt_pre_not_null{offset_cycles}
546
547@sa bt_clock_class_set_offset() &mdash;
548 Sets the offset of a clock class.
549*/
550extern void bt_clock_class_get_offset(const bt_clock_class *clock_class,
4c81a2b7 551 int64_t *offset_seconds, uint64_t *offset_cycles) __BT_NOEXCEPT;
43c59509
PP
552
553/*!
554@brief
555 Sets the precision (cycles) of the clock class \bt_p{clock_class} to
556 \bt_p{precision}.
557
558See the \ref api-tir-clock-cls-prop-precision "precision" property.
559
560@param[in] clock_class
561 Clock class of which to set the precision to \bt_p{precision}.
562@param[in] precision
563 New precision of \bt_p{clock_class}.
564
565@bt_pre_not_null{clock_class}
566@bt_pre_hot{clock_class}
567
568@sa bt_clock_class_get_precision() &mdash;
569 Returns the precision of a clock class.
570*/
571extern void bt_clock_class_set_precision(bt_clock_class *clock_class,
4c81a2b7 572 uint64_t precision) __BT_NOEXCEPT;
43c59509
PP
573
574/*!
575@brief
576 Returns the precision (cycles) of the clock class
577 \bt_p{clock_class}.
578
a8e200ad
SM
579@deprecated
580 Use bt_clock_class_get_opt_precision().
581
582@note
583 This function is only available when \bt_p{clock_class} was created
584 from a \bt_comp which belongs to a trace processing \bt_graph with
585 the effective \bt_mip (MIP) version&nbsp;0.
586
43c59509
PP
587See the \ref api-tir-clock-cls-prop-precision "precision" property.
588
589@param[in] clock_class
590 Clock class of which to get the precision.
591
592@returns
593 Precision (cycles) of \bt_p{clock_class}.
594
595@bt_pre_not_null{clock_class}
a8e200ad 596@bt_pre_clock_cls_with_mip{clock_class, 0}
43c59509
PP
597
598@sa bt_clock_class_set_precision() &mdash;
599 Sets the precision of a clock class.
600*/
601extern uint64_t bt_clock_class_get_precision(
4c81a2b7 602 const bt_clock_class *clock_class) __BT_NOEXCEPT;
43c59509 603
a8e200ad
SM
604/*!
605@brief
606 Returns the precision of the clock class \bt_p{clock_class}.
607
608See the \ref api-tir-clock-cls-prop-precision "precision" property.
609
610@param[in] clock_class
611 Clock class of which to get the precision.
612@param[out] precision
613 @parblock
614 <strong>If this function returns
615 #BT_PROPERTY_AVAILABILITY_AVAILABLE</strong>, \bt_p{*precision} is
616 the precision (cycles) of \bt_p{clock_class}.
617
618 Otherwise, the precision of \bt_p{clock_class} is unknown.
619 @endparblock
620
621@retval #BT_PROPERTY_AVAILABILITY_AVAILABLE
622 The precision of \bt_p{clock_class} is known.
623@retval #BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
624 The precision of \bt_p{clock_class} is unknown.
625
626@bt_pre_not_null{clock_class}
627@bt_pre_not_null{precision}
628
629@sa bt_clock_class_set_precision() &mdash;
630 Sets the precision of a clock class.
631*/
632extern bt_property_availability bt_clock_class_get_opt_precision(
633 const struct bt_clock_class *clock_class,
634 uint64_t *precision) __BT_NOEXCEPT;
635
85f6ebeb
SM
636/*!
637@brief
638 Sets the accuracy (cycles) of the clock class \bt_p{clock_class} to
639 \bt_p{accuracy}.
640
641See the \ref api-tir-clock-cls-prop-accuracy "accuracy" property.
642
643@param[in] clock_class
644 Clock class of which to set the accuracy to \bt_p{accuracy}.
645@param[in] accuracy
646 New accuracy of \bt_p{clock_class}.
647
648@bt_pre_not_null{clock_class}
649@bt_pre_hot{clock_class}
650@bt_pre_clock_cls_with_mip{clock_class, 1}
651
652@sa bt_clock_class_get_accuracy() &mdash;
653 Returns the accuracy of a clock class.
654*/
655extern void bt_clock_class_set_accuracy(bt_clock_class *clock_class,
656 uint64_t accuracy) __BT_NOEXCEPT;
657
658/*!
659@brief
660 Returns the accuracy of the clock class \bt_p{clock_class}.
661
662See the \ref api-tir-clock-cls-prop-accuracy "accuracy" property.
663
664@param[in] clock_class
665 Clock class of which to get the accuracy.
666@param[out] accuracy
667 @parblock
668 <strong>If this function returns
669 #BT_PROPERTY_AVAILABILITY_AVAILABLE</strong>, \bt_p{*accuracy} is
670 the accuracy (cycles) of \bt_p{clock_class}.
671
672 Otherwise, the accuracy of \bt_p{clock_class} is unknown.
673 @endparblock
674
675@retval #BT_PROPERTY_AVAILABILITY_AVAILABLE
676 The accuracy of \bt_p{clock_class} is known.
677@retval #BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE
678 The accuracy of \bt_p{clock_class} is unknown.
679
680@bt_pre_not_null{clock_class}
681@bt_pre_not_null{accuracy}
682
683@sa bt_clock_class_set_accuracy() &mdash;
684 Sets the accuracy of a clock class.
685*/
686extern bt_property_availability bt_clock_class_get_accuracy(
687 const struct bt_clock_class *clock_class,
688 uint64_t *accuracy) __BT_NOEXCEPT;
689
43c59509
PP
690/*!
691@brief
3f2ebcee
SM
692 Sets whether the \ref api-tir-clock-cls-origin "origin"
693 of the clock class \bt_p{clock_class} is unknown or the
43c59509
PP
694 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
695
3f2ebcee
SM
696@deprecated
697 Use bt_clock_class_set_origin_unknown() or
698 bt_clock_class_set_origin_unix_epoch().
699
700See the \ref api-tir-clock-cls-prop-origin "origin" property.
43c59509
PP
701
702@param[in] clock_class
3f2ebcee
SM
703 Clock class of which to set whether its origin is unknown or
704 the Unix epoch.
43c59509 705@param[in] origin_is_unix_epoch
3f2ebcee
SM
706 @parblock
707 One of:
708
709 <dl>
710 <dt>#BT_FALSE</dt>
711 <dd>Make the origin of \bt_p{clock_class} unknown.</dd>
712
713 <dt>#BT_TRUE</dt>
714 <dd>Make the origin of \bt_p{clock_class} the Unix epoch.</dd>
715 </dl>
716 @endparblock
43c59509
PP
717
718@bt_pre_not_null{clock_class}
719@bt_pre_hot{clock_class}
c6962c96 720
43c59509
PP
721@sa bt_clock_class_origin_is_unix_epoch() &mdash;
722 Returns whether or not the origin of a clock class is the
723 Unix epoch.
724*/
725extern void bt_clock_class_set_origin_is_unix_epoch(bt_clock_class *clock_class,
4c81a2b7 726 bt_bool origin_is_unix_epoch) __BT_NOEXCEPT;
43c59509 727
3f2ebcee
SM
728/*!
729@brief
730 Makes the \ref api-tir-clock-cls-origin "origin"
731 of the clock class \bt_p{clock_class} unknown.
732
733See the \ref api-tir-clock-cls-prop-origin "origin" property.
734
735@param[in] clock_class
736 Clock class of which to make the origin unknown.
737
738@bt_pre_not_null{clock_class}
739@bt_pre_hot{clock_class}
740
741@post
742 bt_clock_class_get_origin_namespace(),
743 bt_clock_class_get_origin_name(),
744 and bt_clock_class_get_origin_uid() return \c NULL.
745
746@sa bt_clock_class_set_origin_unix_epoch() &mdash;
747 Makes the origin of a clock class the Unix epoch.
748@sa bt_clock_class_set_origin() &mdash;
749 Sets the custom origin of a clock class.
750@sa bt_clock_class_origin_is_unknown() &mdash;
751 Returns whether or not the origin of a clock class is unknown.
752*/
753extern void
754bt_clock_class_set_origin_unknown(bt_clock_class *clock_class) __BT_NOEXCEPT;
755
756/*!
757@brief
758 Makes the \ref api-tir-clock-cls-origin "origin"
759 of the clock class \bt_p{clock_class} the
760 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
761
762See the \ref api-tir-clock-cls-prop-origin "origin" property.
763
764@note
765 @parblock
766 As of \bt_name_version_min_maj, this function sets the origin
767 of the \bt_p{clock_class} to:
768
769 <dl>
770 <dt>Namespace</dt>
771 <dd><code>babeltrace.org,2020</code></dd>
772
773 <dt>Name</dt>
774 <dd><code>unix-epoch</code></dd>
775
776 <dt>UID</dt>
777 <dd>Empty string</dd>
778 </dl>
779
780 You must not rely on the specific values of this special origin.
781 @endparblock
782
783@param[in] clock_class
784 Clock class of which to make the origin the Unix epoch.
785
786@bt_pre_not_null{clock_class}
787@bt_pre_hot{clock_class}
788
789@sa bt_clock_class_set_origin_unknown() &mdash;
790 Makes the origin of a clock class unknown.
791@sa bt_clock_class_set_origin() &mdash;
792 Sets the custom origin of a clock class.
793@sa bt_clock_class_origin_is_unix_epoch() &mdash;
794 Returns whether or not the origin of a clock class is the
795 Unix epoch.
796*/
797extern void
798bt_clock_class_set_origin_unix_epoch(bt_clock_class *clock_class) __BT_NOEXCEPT;
799
800/*!
801@brief
802 Status codes for bt_clock_class_set_origin().
803*/
804typedef enum bt_clock_class_set_origin_status {
805 /*!
806 @brief
807 Success.
808 */
809 BT_CLOCK_CLASS_SET_ORIGIN_STATUS_OK = __BT_FUNC_STATUS_OK,
810
811 /*!
812 @brief
813 Out of memory.
814 */
815 BT_CLOCK_CLASS_SET_ORIGIN_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
816} bt_clock_class_set_origin_status;
817
818/*!
819@brief
820 Sets the custom \ref api-tir-clock-cls-origin "origin"
821 of the clock class \bt_p{clock_class} to the
822 \bt_p{ns}, \bt_p{name}, and \bt_p{uid} tuple.
823
824See the \ref api-tir-clock-cls-prop-origin "origin" property.
825
826@param[in] clock_class
827 Clock class of which to set the origin to the
828 \bt_p{ns}, \bt_p{name}, and \bt_p{uid} tuple.
829@param[in] ns
830 @parblock
831 Namespace of the custom origin of \bt_p{clock_class} (copied).
832
833 Can be \c NULL.
834 @endparblock
835@param[in] name
836 Name of the custom origin of \bt_p{clock_class} (copied).
837@param[in] uid
838 <a href="https://en.wikipedia.org/wiki/Unique_identifier">Unique identifier</a>
839 (UID) of the custom origin of \bt_p{clock_class} (copied).
840
841@retval #BT_CLOCK_CLASS_SET_ORIGIN_STATUS_OK
842 Success.
843@retval #BT_CLOCK_CLASS_SET_ORIGIN_STATUS_MEMORY_ERROR
844 Out of memory.
845
846@bt_pre_not_null{clock_class}
847@bt_pre_hot{clock_class}
848@bt_pre_clock_cls_with_mip{clock_class, 1}
849@bt_pre_not_null{name}
850@bt_pre_not_null{uid}
851
852@sa bt_clock_class_set_origin_unknown() &mdash;
853 Makes the origin of a clock class unknown.
854@sa bt_clock_class_set_origin_unix_epoch() &mdash;
855 Makes the origin of a clock class the Unix epoch.
856@sa bt_clock_class_get_origin_namespace() &mdash;
857 Returns the namespace of the origin of a clock class.
858@sa bt_clock_class_get_origin_name() &mdash;
859 Returns the name of the origin of a clock class.
860@sa bt_clock_class_get_origin_uid() &mdash;
861 Returns the UID of the origin of a clock class.
862*/
863extern bt_clock_class_set_origin_status bt_clock_class_set_origin(
864 bt_clock_class *clock_class, const char *ns, const char *name,
865 const char *uid) __BT_NOEXCEPT;
866
867/*!
868@brief
869 Returns whether or not the \ref api-tir-clock-cls-origin "origin"
870 of the clock class \bt_p{clock_class} is unknown.
871
872See the \ref api-tir-clock-cls-prop-origin "origin" property.
873
874@param[in] clock_class
875 Clock class of which to get whether or not its origin is unknown.
876
877@returns
878 #BT_TRUE if the origin of \bt_p{clock_class} is unknown.
879
880@bt_pre_not_null{clock_class}
881
882@sa bt_clock_class_origin_is_unix_epoch() &mdash;
883 Returns whether or not the origin of a clock class is the
884 Unix epoch.
885@sa bt_clock_class_set_origin_unknown() &mdash;
886 Makes the origin of a clock class unknown.
887@sa bt_clock_class_set_origin_unix_epoch() &mdash;
888 Makes the origin of a clock class the Unix epoch.
889@sa bt_clock_class_set_origin() &mdash;
890 Sets the custom origin of a clock class.
891*/
892extern bt_bool bt_clock_class_origin_is_unknown(
893 const bt_clock_class *clock_class) __BT_NOEXCEPT;
894
43c59509
PP
895/*!
896@brief
897 Returns whether or not the \ref api-tir-clock-cls-origin "origin"
898 of the clock class \bt_p{clock_class} is the
899 <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a>.
900
3f2ebcee 901See the \ref api-tir-clock-cls-prop-origin "origin" property.
43c59509
PP
902
903@param[in] clock_class
904 Clock class of which to get whether or not its origin is the
905 Unix epoch.
906
907@returns
908 #BT_TRUE if the origin of \bt_p{clock_class} is the Unix epoch.
909
910@bt_pre_not_null{clock_class}
911
3f2ebcee
SM
912@sa bt_clock_class_origin_is_unknown() &mdash;
913 Returns whether or not the origin of a clock class is unknown.
914@sa bt_clock_class_set_origin_unknown() &mdash;
915 Makes the origin of a clock class unknown.
916@sa bt_clock_class_set_origin_unix_epoch() &mdash;
917 Makes the origin of a clock class the Unix epoch.
918@sa bt_clock_class_set_origin() &mdash;
919 Sets the custom origin of a clock class.
43c59509
PP
920*/
921extern bt_bool bt_clock_class_origin_is_unix_epoch(
4c81a2b7 922 const bt_clock_class *clock_class) __BT_NOEXCEPT;
43c59509 923
3f2ebcee
SM
924/*!
925@brief
926 Returns the namespace of the \ref api-tir-clock-cls-origin "origin"
927 of the clock class \bt_p{clock_class}.
928
929See the \ref api-tir-clock-cls-prop-origin "origin" property.
930
931@param[in] clock_class
932 Clock class of which to get the origin namespace.
933
934@returns
935 @parblock
936 Origin namespace of \bt_p{clock_class}, or \c NULL if none.
937
938 The returned pointer remains valid as long as \bt_p{clock_class}
939 is not modified.
940 @endparblock
941
942@bt_pre_not_null{clock_class}
943@bt_pre_clock_cls_with_mip{clock_class, 1}
944
945@sa bt_clock_class_get_origin_name() &mdash;
946 Returns the name of the origin of a clock class.
947@sa bt_clock_class_get_origin_uid() &mdash;
948 Returns the UID of the origin of a clock class.
949@sa bt_clock_class_set_origin() &mdash;
950 Sets the custom origin of a clock class.
951*/
952extern const char *bt_clock_class_get_origin_namespace(
953 const bt_clock_class *clock_class) __BT_NOEXCEPT;
954
955/*!
956@brief
957 Returns the name of the \ref api-tir-clock-cls-origin "origin"
958 of the clock class \bt_p{clock_class}.
959
960See the \ref api-tir-clock-cls-prop-origin "origin" property.
961
962@param[in] clock_class
963 Clock class of which to get the origin name.
964
965@returns
966 @parblock
967 Origin name of \bt_p{clock_class}, or \c NULL if none.
968
969 If this function doesn't return \c NULL, then
970 bt_clock_class_get_origin_uid() also doesn't return \c NULL.
971
972 The returned pointer remains valid as long as \bt_p{clock_class}
973 is not modified.
974 @endparblock
975
976@bt_pre_not_null{clock_class}
977@bt_pre_clock_cls_with_mip{clock_class, 1}
978
979@sa bt_clock_class_get_origin_namespace() &mdash;
980 Returns the namespace of the origin of a clock class.
981@sa bt_clock_class_get_origin_uid() &mdash;
982 Returns the UID of the origin of a clock class.
983@sa bt_clock_class_set_origin() &mdash;
984 Sets the custom origin of a clock class.
985*/
986extern const char *bt_clock_class_get_origin_name(
987 const bt_clock_class *clock_class) __BT_NOEXCEPT;
988
989/*!
990@brief
991 Returns the UID of the \ref api-tir-clock-cls-origin "origin"
992 of the clock class \bt_p{clock_class}.
993
994See the \ref api-tir-clock-cls-prop-origin "origin" property.
995
996@param[in] clock_class
997 Clock class of which to get the origin UID.
998
999@returns
1000 @parblock
1001 Origin UID of \bt_p{clock_class}, or \c NULL if none.
1002
1003 If this function doesn't return \c NULL, then
1004 bt_clock_class_get_origin_name() also doesn't return \c NULL.
1005
1006 The returned pointer remains valid as long as \bt_p{clock_class}
1007 is not modified.
1008 @endparblock
1009
1010@bt_pre_not_null{clock_class}
1011@bt_pre_clock_cls_with_mip{clock_class, 1}
1012
1013@sa bt_clock_class_get_origin_namespace() &mdash;
1014 Returns the namespace of the origin of a clock class.
1015@sa bt_clock_class_get_origin_name() &mdash;
1016 Returns the name of the origin of a clock class.
1017@sa bt_clock_class_set_origin() &mdash;
1018 Sets the custom origin of a clock class.
1019*/
1020extern const char *bt_clock_class_get_origin_uid(
1021 const bt_clock_class *clock_class) __BT_NOEXCEPT;
1022
2fc2de47
SM
1023/*!
1024@brief
1025 Status codes for bt_clock_class_set_namespace().
1026*/
1027typedef enum bt_clock_class_set_namespace_status {
1028 /*!
1029 @brief
1030 Success.
1031 */
1032 BT_CLOCK_CLASS_SET_NAMESPACE_STATUS_OK = __BT_FUNC_STATUS_OK,
1033
1034 /*!
1035 @brief
1036 Out of memory.
1037 */
1038 BT_CLOCK_CLASS_SET_NAMESPACE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
1039} bt_clock_class_set_namespace_status;
1040
1041/*!
1042@brief
1043 Sets the namespace of the clock class \bt_p{clock_class} to
1044 a copy of \bt_p{ns}.
1045
1046See the \ref api-tir-clock-cls-prop-iden "identity" property.
1047
1048@param[in] clock_class
1049 Clock class of which to set the namespace to \bt_p{ns}.
1050@param[in] namespace
1051 New namespace of \bt_p{clock_class} (copied).
1052
1053@retval #BT_CLOCK_CLASS_SET_NAMESPACE_STATUS_OK
1054 Success.
1055@retval #BT_CLOCK_CLASS_SET_NAMESPACE_STATUS_MEMORY_ERROR
1056 Out of memory.
1057
1058@bt_pre_not_null{clock_class}
1059@bt_pre_hot{clock_class}
1060@bt_pre_clock_cls_with_mip{clock_class, 1}
1061@bt_pre_not_null{namespace}
1062
1063@sa bt_clock_class_get_namespace() &mdash;
1064 Returns the namespace of a clock class.
1065*/
1066extern bt_clock_class_set_namespace_status bt_clock_class_set_namespace(
1067 bt_clock_class *clock_class, const char *ns) __BT_NOEXCEPT;
1068
1069/*!
1070@brief
1071 Returns the namespace of the clock class \bt_p{clock_class}.
1072
1073See the \ref api-tir-clock-cls-prop-iden "identity" property.
1074
1075If \bt_p{clock_class} has no namespace, this function returns \c NULL.
1076
1077@param[in] clock_class
1078 Clock class of which to get the namespace.
1079
1080@returns
1081 @parblock
1082 Namespace of \bt_p{clock_class}, or \c NULL if none.
1083
1084 The returned pointer remains valid as long as \bt_p{clock_class}
1085 is not modified.
1086 @endparblock
1087
1088@bt_pre_not_null{clock_class}
1089@bt_pre_clock_cls_with_mip{clock_class, 1}
1090
1091@sa bt_clock_class_set_namespace() &mdash;
1092 Sets the namespace of a clock class.
1093*/
1094extern const char *bt_clock_class_get_namespace(
1095 const bt_clock_class *clock_class) __BT_NOEXCEPT;
1096
43c59509
PP
1097/*!
1098@brief
1099 Status codes for bt_clock_class_set_name().
1100*/
d24d5663 1101typedef enum bt_clock_class_set_name_status {
43c59509
PP
1102 /*!
1103 @brief
1104 Success.
1105 */
d24d5663 1106 BT_CLOCK_CLASS_SET_NAME_STATUS_OK = __BT_FUNC_STATUS_OK,
43c59509
PP
1107
1108 /*!
1109 @brief
1110 Out of memory.
1111 */
1112 BT_CLOCK_CLASS_SET_NAME_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
d24d5663
PP
1113} bt_clock_class_set_name_status;
1114
43c59509
PP
1115/*!
1116@brief
1117 Sets the name of the clock class \bt_p{clock_class} to
1118 a copy of \bt_p{name}.
1119
3f2ebcee 1120See the \ref api-tir-clock-cls-prop-iden "identity" property.
43c59509
PP
1121
1122@param[in] clock_class
1123 Clock class of which to set the name to \bt_p{name}.
1124@param[in] name
1125 New name of \bt_p{clock_class} (copied).
1126
1127@retval #BT_CLOCK_CLASS_SET_NAME_STATUS_OK
1128 Success.
1129@retval #BT_CLOCK_CLASS_SET_NAME_STATUS_MEMORY_ERROR
1130 Out of memory.
1131
1132@bt_pre_not_null{clock_class}
1133@bt_pre_hot{clock_class}
1134@bt_pre_not_null{name}
1135
1136@sa bt_clock_class_get_name() &mdash;
1137 Returns the name of a clock class.
1138*/
d24d5663 1139extern bt_clock_class_set_name_status bt_clock_class_set_name(
4c81a2b7 1140 bt_clock_class *clock_class, const char *name) __BT_NOEXCEPT;
44c440bc 1141
43c59509
PP
1142/*!
1143@brief
1144 Returns the name of the clock class \bt_p{clock_class}.
1145
3f2ebcee 1146See the \ref api-tir-clock-cls-prop-iden "identity" property.
43c59509
PP
1147
1148If \bt_p{clock_class} has no name, this function returns \c NULL.
1149
1150@param[in] clock_class
1151 Clock class of which to get the name.
1152
1153@returns
1154 @parblock
1155 Name of \bt_p{clock_class}, or \c NULL if none.
1156
1157 The returned pointer remains valid as long as \bt_p{clock_class}
1158 is not modified.
1159 @endparblock
1160
1161@bt_pre_not_null{clock_class}
1162
1163@sa bt_clock_class_set_name() &mdash;
1164 Sets the name of a clock class.
1165*/
1166extern const char *bt_clock_class_get_name(
4c81a2b7 1167 const bt_clock_class *clock_class) __BT_NOEXCEPT;
43c59509 1168
2fc2de47
SM
1169/*!
1170@brief
1171 Status codes for bt_clock_class_set_uid().
1172*/
1173typedef enum bt_clock_class_set_uid_status {
1174 /*!
1175 @brief
1176 Success.
1177 */
1178 BT_CLOCK_CLASS_SET_UID_STATUS_OK = __BT_FUNC_STATUS_OK,
1179
1180 /*!
1181 @brief
1182 Out of memory.
1183 */
1184 BT_CLOCK_CLASS_SET_UID_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
1185} bt_clock_class_set_uid_status;
1186
1187/*!
1188@brief
1189 Sets the
1190 <a href="https://en.wikipedia.org/wiki/Unique_identifier">unique identifier</a>
1191 (UID) of the clock class \bt_p{clock_class} to a copy of \bt_p{uid}.
1192
1193See the \ref api-tir-clock-cls-prop-iden "identity" property.
1194
1195@param[in] clock_class
1196 Clock class of which to set the UID to \bt_p{uid}.
1197@param[in] UID
1198 New UID of \bt_p{clock_class} (copied).
1199
1200@retval #BT_CLOCK_CLASS_SET_UID_STATUS_OK
1201 Success.
1202@retval #BT_CLOCK_CLASS_SET_UID_STATUS_MEMORY_ERROR
1203 Out of memory.
1204
1205@bt_pre_not_null{clock_class}
1206@bt_pre_hot{clock_class}
1207@bt_pre_clock_cls_with_mip{clock_class, 1}
1208@bt_pre_not_null{uid}
1209
1210@sa bt_clock_class_get_uid() &mdash;
1211 Returns the UID of a clock class.
1212*/
1213extern bt_clock_class_set_uid_status bt_clock_class_set_uid(
1214 bt_clock_class *clock_class, const char *uid) __BT_NOEXCEPT;
1215
1216/*!
1217@brief
1218 Returns the UID of the clock class \bt_p{clock_class}.
1219
1220See the \ref api-tir-clock-cls-prop-iden "identity" property.
1221
1222If \bt_p{clock_class} has no UID, this function returns \c NULL.
1223
1224@param[in] clock_class
1225 Clock class of which to get the UID.
1226
1227@returns
1228 @parblock
1229 UID of \bt_p{clock_class}, or \c NULL if none.
1230
1231 The returned pointer remains valid as long as \bt_p{clock_class}
1232 is not modified.
1233 @endparblock
1234
1235@bt_pre_not_null{clock_class}
1236@bt_pre_clock_cls_with_mip{clock_class, 1}
1237
1238@sa bt_clock_class_set_uid() &mdash;
1239 Sets the UID of a clock class.
1240*/
1241extern const char *
1242bt_clock_class_get_uid(const bt_clock_class *clock_class) __BT_NOEXCEPT;
1243
c33d46d2
SM
1244/*!
1245@brief
1246 Returns whether or not the clock classes \bt_p{clock_class_a}
1247 and \bt_p{clock_class_b} share the same identity.
1248
1249See the \ref api-tir-clock-cls-prop-iden "identity" property.
1250
1251Two clock classes share the same identity when all the following are
1252true:
1253
1254- They both have a name and a UID.
1255
1256- The values of their namespace, name, and UID property tuples
1257 are the same.
1258
1259@param[in] clock_class_a
1260 Clock class A.
1261@param[in] clock_class_b
1262 Clock class B.
1263
1264@returns
1265 #BT_TRUE if \bt_p{clock_class_a} and \bt_p{clock_class_b} share
1266 the same identity
1267
1268@bt_pre_not_null{clock_class_a}
1269@bt_pre_clock_cls_with_mip{clock_class_a, 1}
1270@bt_pre_not_null{clock_class_b}
1271@bt_pre_clock_cls_with_mip{clock_class_b, 1}
1272*/
1273extern bt_bool bt_clock_class_has_same_identity(
1274 const bt_clock_class *clock_class_a,
1275 const bt_clock_class *clock_class_b) __BT_NOEXCEPT;
1276
43c59509
PP
1277/*!
1278@brief
1279 Status codes for bt_clock_class_set_description().
1280*/
d24d5663 1281typedef enum bt_clock_class_set_description_status {
43c59509
PP
1282 /*!
1283 @brief
1284 Success.
1285 */
d24d5663 1286 BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_OK = __BT_FUNC_STATUS_OK,
43c59509
PP
1287
1288 /*!
1289 @brief
1290 Out of memory.
1291 */
1292 BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
d24d5663
PP
1293} bt_clock_class_set_description_status;
1294
43c59509
PP
1295/*!
1296@brief
3f2ebcee
SM
1297 Sets the
1298 <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUID</a>
1299 of the clock class \bt_p{clock_class} to a copy of \bt_p{uuid}.
43c59509 1300
3f2ebcee
SM
1301@note
1302 This function is only available when \bt_p{clock_class} was
1303 created from a \bt_comp which belongs to a trace processing \bt_graph
1304 with the effective \bt_mip (MIP) version&nbsp;0.
43c59509 1305
3f2ebcee 1306See the \ref api-tir-clock-cls-prop-iden "identity" property.
43c59509 1307
3f2ebcee
SM
1308@param[in] clock_class
1309 Clock class of which to set the UUID to \bt_p{uuid}.
1310@param[in] uuid
1311 New UUID of \bt_p{clock_class} (copied).
43c59509
PP
1312
1313@bt_pre_not_null{clock_class}
1314@bt_pre_hot{clock_class}
3f2ebcee
SM
1315@bt_pre_clock_cls_with_mip{clock_class, 0}
1316@bt_pre_not_null{uuid}
43c59509 1317
3f2ebcee
SM
1318@sa bt_clock_class_get_uuid() &mdash;
1319 Returns the UUID of a clock class.
43c59509 1320*/
3f2ebcee
SM
1321extern void bt_clock_class_set_uuid(bt_clock_class *clock_class,
1322 bt_uuid uuid) __BT_NOEXCEPT;
44c440bc 1323
43c59509
PP
1324/*!
1325@brief
3f2ebcee 1326 Returns the UUID of the clock class \bt_p{clock_class}.
44c440bc 1327
3f2ebcee
SM
1328@note
1329 This function is only available when \bt_p{clock_class} was
1330 created from a \bt_comp which belongs to a trace processing \bt_graph
1331 with the effective \bt_mip (MIP) version&nbsp;0.
44c440bc 1332
3f2ebcee
SM
1333See the \ref api-tir-clock-cls-prop-iden "identity" property.
1334
1335If \bt_p{clock_class} has no UUID, this function returns \c NULL.
44c440bc 1336
43c59509 1337@param[in] clock_class
3f2ebcee 1338 Clock class of which to get the UUID.
43c59509
PP
1339
1340@returns
1341 @parblock
3f2ebcee 1342 UUID of \bt_p{clock_class}, or \c NULL if none.
43c59509
PP
1343
1344 The returned pointer remains valid as long as \bt_p{clock_class}
1345 is not modified.
1346 @endparblock
1347
1348@bt_pre_not_null{clock_class}
3f2ebcee 1349@bt_pre_clock_cls_with_mip{clock_class, 0}
44c440bc 1350
3f2ebcee
SM
1351@sa bt_clock_class_set_uuid() &mdash;
1352 Sets the UUID of a clock class.
43c59509 1353*/
3f2ebcee 1354extern bt_uuid bt_clock_class_get_uuid(
4c81a2b7 1355 const bt_clock_class *clock_class) __BT_NOEXCEPT;
43c59509
PP
1356
1357/*!
1358@brief
3f2ebcee
SM
1359 Sets the description of the clock class \bt_p{clock_class} to a copy
1360 of \bt_p{description}.
43c59509 1361
3f2ebcee 1362See the \ref api-tir-clock-cls-prop-descr "description" property.
43c59509
PP
1363
1364@param[in] clock_class
3f2ebcee
SM
1365 Clock class of which to set the description to \bt_p{description}.
1366@param[in] description
1367 New description of \bt_p{clock_class} (copied).
1368
1369@retval #BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_OK
1370 Success.
1371@retval #BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR
1372 Out of memory.
43c59509
PP
1373
1374@bt_pre_not_null{clock_class}
1375@bt_pre_hot{clock_class}
3f2ebcee 1376@bt_pre_not_null{description}
43c59509 1377
3f2ebcee
SM
1378@sa bt_clock_class_get_description() &mdash;
1379 Returns the description of a clock class.
43c59509 1380*/
3f2ebcee
SM
1381extern bt_clock_class_set_description_status bt_clock_class_set_description(
1382 bt_clock_class *clock_class, const char *description)
1383 __BT_NOEXCEPT;
ac0c6bdd 1384
43c59509
PP
1385/*!
1386@brief
3f2ebcee 1387 Returns the description of the clock class \bt_p{clock_class}.
43c59509 1388
3f2ebcee 1389See the \ref api-tir-clock-cls-prop-descr "description" property.
43c59509 1390
3f2ebcee 1391If \bt_p{clock_class} has no description, this function returns \c NULL.
43c59509
PP
1392
1393@param[in] clock_class
3f2ebcee 1394 Clock class of which to get the description.
43c59509
PP
1395
1396@returns
1397 @parblock
3f2ebcee 1398 Description of \bt_p{clock_class}, or \c NULL if none.
43c59509
PP
1399
1400 The returned pointer remains valid as long as \bt_p{clock_class}
1401 is not modified.
1402 @endparblock
1403
1404@bt_pre_not_null{clock_class}
1405
3f2ebcee
SM
1406@sa bt_clock_class_set_description() &mdash;
1407 Sets the description of a clock class.
43c59509 1408*/
3f2ebcee 1409extern const char *bt_clock_class_get_description(
4c81a2b7 1410 const bt_clock_class *clock_class) __BT_NOEXCEPT;
43c59509
PP
1411
1412/*!
1413@brief
1414 Sets the user attributes of the clock class \bt_p{clock_class} to
1415 \bt_p{user_attributes}.
1416
1417See the \ref api-tir-clock-cls-prop-user-attrs "user attributes"
1418property.
1419
1420@note
1421 When you create a default clock class with bt_clock_class_create(),
1422 the clock class's initial user attributes is an empty \bt_map_val.
1423 Therefore you can borrow it with
1424 bt_clock_class_borrow_user_attributes() and fill it directly instead
1425 of setting a new one with this function.
1426
1427@param[in] clock_class
1428 Clock class of which to set the user attributes to
1429 \bt_p{user_attributes}.
1430@param[in] user_attributes
1431 New user attributes of \bt_p{clock_class}.
1432
1433@bt_pre_not_null{clock_class}
1434@bt_pre_hot{clock_class}
1435@bt_pre_not_null{user_attributes}
1436@bt_pre_is_map_val{user_attributes}
1437
1438@sa bt_clock_class_borrow_user_attributes() &mdash;
1439 Borrows the user attributes of a clock class.
1440*/
1441extern void bt_clock_class_set_user_attributes(
4c81a2b7
PP
1442 bt_clock_class *clock_class, const bt_value *user_attributes)
1443 __BT_NOEXCEPT;
43c59509
PP
1444
1445/*!
1446@brief
1447 Borrows the user attributes of the clock class \bt_p{clock_class}.
1448
1449See the \ref api-tir-clock-cls-prop-user-attrs "user attributes"
1450property.
1451
1452@note
1453 When you create a default clock class with bt_clock_class_create(),
1454 the clock class's initial user attributes is an empty \bt_map_val.
1455
1456@param[in] clock_class
1457 Clock class from which to borrow the user attributes.
1458
1459@returns
1460 User attributes of \bt_p{clock_class} (a \bt_map_val).
1461
1462@bt_pre_not_null{clock_class}
1463
1464@sa bt_clock_class_set_user_attributes() &mdash;
1465 Sets the user attributes of a clock class.
1466@sa bt_clock_class_borrow_user_attributes_const() &mdash;
1467 \c const version of this function.
1468*/
1469extern bt_value *bt_clock_class_borrow_user_attributes(
4c81a2b7 1470 bt_clock_class *clock_class) __BT_NOEXCEPT;
43c59509
PP
1471
1472/*!
1473@brief
1474 Borrows the user attributes of the clock class \bt_p{clock_class}
1475 (\c const version).
1476
1477See bt_clock_class_borrow_user_attributes().
1478*/
1479extern const bt_value *bt_clock_class_borrow_user_attributes_const(
4c81a2b7 1480 const bt_clock_class *clock_class) __BT_NOEXCEPT;
43c59509
PP
1481
1482/*! @} */
1483
1484/*!
1485@name Utilities
1486@{
1487*/
1488
1489/*!
1490@brief
1491 Status codes for bt_clock_class_cycles_to_ns_from_origin().
1492*/
1493typedef enum bt_clock_class_cycles_to_ns_from_origin_status {
1494 /*!
1495 @brief
1496 Success.
1497 */
1498 BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OK = __BT_FUNC_STATUS_OK,
1499
1500 /*!
1501 @brief
1502 Integer overflow while computing the result.
1503 */
1504 BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR = __BT_FUNC_STATUS_OVERFLOW_ERROR,
1505} bt_clock_class_cycles_to_ns_from_origin_status;
1506
1507/*!
1508@brief
1509 Converts the stream clock value \bt_p{value} from cycles to
1510 nanoseconds from the \ref api-tir-clock-cls-origin "origin" of the
1511 clock class \bt_p{clock_class} and sets \bt_p{*ns_from_origin}
1512 to the result.
1513
1514This function:
1515
1516-# Converts the
1517 \link api-tir-clock-cls-prop-offset "offset in cycles"\endlink
1518 property of \bt_p{clock_class} to seconds using its
1519 \ref api-tir-clock-cls-prop-freq "frequency".
1520-# Converts the \bt_p{value} value to seconds using the frequency of
1521 \bt_p{clock_class}.
1522-# Adds the values of 1., 2., and the
1523 \link api-tir-clock-cls-prop-offset "offset in seconds"\endlink
1524 property of \bt_p{clock_class}.
1525-# Converts the value of 3. to nanoseconds and sets
1526 \bt_p{*ns_from_origin} to this result.
1527
1528The following illustration shows the possible scenarios:
1529
1530@image html clock-terminology.png
1531
1532This function can fail and return the
1533#BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR status
1534code if any step of the computation process causes an integer overflow.
1535
1536@param[in] clock_class
1537 Stream clock's class.
1538@param[in] value
1539 Stream clock's value (cycles) to convert to nanoseconds from
1540 the origin of \bt_p{clock_class}.
1541@param[out] ns_from_origin
1542 <strong>On success</strong>, \bt_p{*ns_from_origin} is \bt_p{value}
1543 converted to nanoseconds from the origin of \bt_p{clock_class}.
1544
1545@retval #BT_UTIL_CLOCK_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OK
1546 Success.
1547@retval #BT_UTIL_CLOCK_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR
1548 Integer overflow while computing the result.
1549
1550@bt_pre_not_null{clock_class}
1551@bt_pre_not_null{ns_from_origin}
1552
1553@sa bt_util_clock_cycles_to_ns_from_origin() &mdash;
1554 Converts a clock value from cycles to nanoseconds from the clock's
1555 origin.
1556*/
1557extern bt_clock_class_cycles_to_ns_from_origin_status
1558bt_clock_class_cycles_to_ns_from_origin(
1559 const bt_clock_class *clock_class,
4c81a2b7 1560 uint64_t value, int64_t *ns_from_origin) __BT_NOEXCEPT;
43c59509
PP
1561
1562/*! @} */
1563
1564/*!
1565@name Reference count
1566@{
1567*/
1568
1569/*!
1570@brief
1571 Increments the \ref api-fund-shared-object "reference count" of
1572 the clock class \bt_p{clock_class}.
1573
1574@param[in] clock_class
1575 @parblock
1576 Clock class of which to increment the reference count.
1577
1578 Can be \c NULL.
1579 @endparblock
1580
1581@sa bt_clock_class_put_ref() &mdash;
1582 Decrements the reference count of a clock class.
1583*/
4c81a2b7
PP
1584extern void bt_clock_class_get_ref(
1585 const bt_clock_class *clock_class) __BT_NOEXCEPT;
43c59509
PP
1586
1587/*!
1588@brief
1589 Decrements the \ref api-fund-shared-object "reference count" of
1590 the clock class \bt_p{clock_class}.
1591
1592@param[in] clock_class
1593 @parblock
1594 Clock class of which to decrement the reference count.
1595
1596 Can be \c NULL.
1597 @endparblock
1598
1599@sa bt_clock_class_get_ref() &mdash;
1600 Increments the reference count of a clock class.
1601*/
4c81a2b7
PP
1602extern void bt_clock_class_put_ref(
1603 const bt_clock_class *clock_class) __BT_NOEXCEPT;
43c59509
PP
1604
1605/*!
1606@brief
1607 Decrements the reference count of the clock class
1608 \bt_p{_clock_class}, and then sets \bt_p{_clock_class} to \c NULL.
1609
1610@param _clock_class
1611 @parblock
1612 Clock class of which to decrement the reference count.
1613
1614 Can contain \c NULL.
1615 @endparblock
1616
1617@bt_pre_assign_expr{_clock_class}
1618*/
1619#define BT_CLOCK_CLASS_PUT_REF_AND_RESET(_clock_class) \
1620 do { \
1621 bt_clock_class_put_ref(_clock_class); \
1622 (_clock_class) = NULL; \
1623 } while (0)
1624
1625/*!
1626@brief
1627 Decrements the reference count of the clock class \bt_p{_dst}, sets
1628 \bt_p{_dst} to \bt_p{_src}, and then sets \bt_p{_src} to \c NULL.
1629
1630This macro effectively moves a clock class reference from the expression
1631\bt_p{_src} to the expression \bt_p{_dst}, putting the existing
1632\bt_p{_dst} reference.
1633
1634@param _dst
1635 @parblock
1636 Destination expression.
1637
1638 Can contain \c NULL.
1639 @endparblock
1640@param _src
1641 @parblock
1642 Source expression.
1643
1644 Can contain \c NULL.
1645 @endparblock
1646
1647@bt_pre_assign_expr{_dst}
1648@bt_pre_assign_expr{_src}
1649*/
1650#define BT_CLOCK_CLASS_MOVE_REF(_dst, _src) \
1651 do { \
1652 bt_clock_class_put_ref(_dst); \
1653 (_dst) = (_src); \
1654 (_src) = NULL; \
1655 } while (0)
1656
1657/*! @} */
1658
1659/*! @} */
1660
ac0c6bdd
PP
1661#ifdef __cplusplus
1662}
1663#endif
1664
924dc299 1665#endif /* BABELTRACE2_TRACE_IR_CLOCK_CLASS_H */
This page took 0.156676 seconds and 5 git commands to generate.