2 * SPDX-License-Identifier: MIT
4 * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation
7 #ifndef BABELTRACE2_CTF_WRITER_CLOCK_H
8 #define BABELTRACE2_CTF_WRITER_CLOCK_H
11 #include <babeltrace2-ctf-writer/object.h>
12 #include <babeltrace2-ctf-writer/types.h>
19 struct bt_ctf_clock_class
;
22 * bt_ctf_clock_create: create a clock.
24 * Allocate a new clock setting its reference count to 1.
26 * @param name Name of the clock (will be copied); can be set to NULL
27 * for nameless clocks.
29 * Returns an allocated clock on success, NULL on error.
31 extern struct bt_ctf_clock
*bt_ctf_clock_create(const char *name
);
34 * bt_ctf_clock_get_name: get a clock's name.
36 * Get the clock's name.
38 * @param clock Clock instance.
40 * Returns the clock's name, NULL on error.
42 extern const char *bt_ctf_clock_get_name(struct bt_ctf_clock
*clock
);
45 * bt_ctf_clock_get_description: get a clock's description.
47 * Get the clock's description.
49 * @param clock Clock instance.
51 * Returns the clock's description, NULL if unset.
53 extern const char *bt_ctf_clock_get_description(struct bt_ctf_clock
*clock
);
56 * bt_ctf_clock_set_description: set a clock's description.
58 * Set the clock's description. The description appears in the clock's TSDL
61 * @param clock Clock instance.
62 * @param desc Description of the clock.
64 * Returns 0 on success, a negative value on error.
66 extern int bt_ctf_clock_set_description(struct bt_ctf_clock
*clock
,
70 * bt_ctf_clock_get_frequency: get a clock's frequency.
72 * Get the clock's frequency (Hz).
74 * @param clock Clock instance.
76 * Returns the clock's frequency, -1ULL on error.
78 extern uint64_t bt_ctf_clock_get_frequency(struct bt_ctf_clock
*clock
);
81 * bt_ctf_clock_set_frequency: set a clock's frequency.
83 * Set the clock's frequency (Hz).
85 * @param clock Clock instance.
86 * @param freq Clock's frequency in Hz, defaults to 1 000 000 000 Hz (1ns).
88 * Returns 0 on success, a negative value on error.
90 extern int bt_ctf_clock_set_frequency(struct bt_ctf_clock
*clock
,
94 * bt_ctf_clock_get_precision: get a clock's precision.
96 * Get the clock's precision (in clock ticks).
98 * @param clock Clock instance.
100 * Returns the clock's precision, -1ULL on error.
102 extern uint64_t bt_ctf_clock_get_precision(struct bt_ctf_clock
*clock
);
105 * bt_ctf_clock_set_precision: set a clock's precision.
107 * Set the clock's precision.
109 * @param clock Clock instance.
110 * @param precision Clock's precision in clock ticks, defaults to 1.
112 * Returns 0 on success, a negative value on error.
114 extern int bt_ctf_clock_set_precision(struct bt_ctf_clock
*clock
,
118 * bt_ctf_clock_get_offset_s: get a clock's offset in seconds.
120 * Get the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01.
122 * @param clock Clock instance.
123 * @param offset_s Pointer to clock offset in seconds (output).
125 * Returns 0 on success, a negative value on error.
127 extern int bt_ctf_clock_get_offset_s(struct bt_ctf_clock
*clock
,
131 * bt_ctf_clock_set_offset_s: set a clock's offset in seconds.
133 * Set the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01,
136 * @param clock Clock instance.
137 * @param offset_s Clock's offset in seconds, defaults to 0.
139 * Returns 0 on success, a negative value on error.
141 extern int bt_ctf_clock_set_offset_s(struct bt_ctf_clock
*clock
,
145 * bt_ctf_clock_get_offset: get a clock's offset in ticks.
147 * Get the clock's offset in ticks from Epoch + offset_t.
149 * @param clock Clock instance.
150 * @param offset Clock offset in ticks from Epoch + offset_s (output).
152 * Returns 0 on success, a negative value on error.
154 extern int bt_ctf_clock_get_offset(struct bt_ctf_clock
*clock
,
158 * bt_ctf_clock_set_offset: set a clock's offset in ticks.
160 * Set the clock's offset in ticks from Epoch + offset_s.
162 * @param clock Clock instance.
163 * @param offset Clock's offset in ticks from Epoch + offset_s, defaults to 0.
165 * Returns 0 on success, a negative value on error.
167 extern int bt_ctf_clock_set_offset(struct bt_ctf_clock
*clock
,
171 * bt_ctf_clock_get_is_absolute: get a clock's absolute attribute.
173 * Get the clock's absolute attribute. A clock is absolute if the clock is a
174 * global reference across the trace's other clocks.
176 * @param clock Clock instance.
178 * Returns the clock's absolute attribute, a negative value on error.
180 extern int bt_ctf_clock_get_is_absolute(struct bt_ctf_clock
*clock
);
183 * bt_ctf_clock_set_is_absolute: set a clock's absolute attribute.
185 * Set the clock's absolute attribute. A clock is absolute if the clock is a
186 * global reference across the trace's other clocks.
188 * @param clock Clock instance.
189 * @param is_absolute Clock's absolute attribute, defaults to FALSE.
191 * Returns 0 on success, a negative value on error.
193 extern int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock
*clock
,
197 * bt_ctf_clock_get_uuid: get a clock's UUID.
199 * Get the clock's UUID.
201 * @param clock Clock instance.
203 * Returns a pointer to the clock's UUID (16 byte array) on success,
206 extern const uint8_t *bt_ctf_clock_get_uuid(struct bt_ctf_clock
*clock
);
209 * bt_ctf_clock_set_uuid: set a clock's UUID.
211 * Set a clock's UUID.
213 * @param clock Clock instance.
214 * @param uuid A 16-byte array containing a UUID.
216 * Returns 0 on success, a negative value on error.
218 extern int bt_ctf_clock_set_uuid(struct bt_ctf_clock
*clock
,
219 const uint8_t *uuid
);
222 * bt_ctf_clock_set_time: set a clock's current time value.
224 * Set the current time in nanoseconds since the clock's origin (offset and
225 * offset_s attributes). Defaults to 0.
227 * Returns 0 on success, a negative value on error.
229 extern int bt_ctf_clock_set_time(struct bt_ctf_clock
*clock
,
233 * bt_ctf_clock_get and bt_ctf_clock_put: increment and decrement the
234 * refcount of the clock
236 * You may also use bt_ctf_get() and bt_ctf_put() with clock objects.
238 * These functions ensure that the clock won't be destroyed when it
239 * is in use. The same number of get and put (plus one extra put to
240 * release the initial reference done at creation) has to be done to
243 * When the clock refcount is decremented to 0 by a bt_ctf_clock_put,
244 * the clock is freed.
246 * @param clock Clock instance.
249 /* Pre-2.0 CTF writer compatibility */
251 void bt_ctf_clock_get(struct bt_ctf_clock
*clock
)
253 bt_ctf_object_get_ref(clock
);
256 /* Pre-2.0 CTF writer compatibility */
258 void bt_ctf_clock_put(struct bt_ctf_clock
*clock
)
260 bt_ctf_object_put_ref(clock
);
266 #endif /* BABELTRACE2_CTF_WRITER_CLOCK_H */
This page took 0.035012 seconds and 4 git commands to generate.