1 #ifndef BABELTRACE2_CTF_WRITER_CLOCK_H
2 #define BABELTRACE2_CTF_WRITER_CLOCK_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
27 #include <babeltrace2-ctf-writer/object.h>
28 #include <babeltrace2-ctf-writer/types.h>
35 struct bt_ctf_clock_class
;
38 * bt_ctf_clock_create: create a clock.
40 * Allocate a new clock setting its reference count to 1.
42 * @param name Name of the clock (will be copied); can be set to NULL
43 * for nameless clocks.
45 * Returns an allocated clock on success, NULL on error.
47 extern struct bt_ctf_clock
*bt_ctf_clock_create(const char *name
);
50 * bt_ctf_clock_get_name: get a clock's name.
52 * Get the clock's name.
54 * @param clock Clock instance.
56 * Returns the clock's name, NULL on error.
58 extern const char *bt_ctf_clock_get_name(struct bt_ctf_clock
*clock
);
61 * bt_ctf_clock_get_description: get a clock's description.
63 * Get the clock's description.
65 * @param clock Clock instance.
67 * Returns the clock's description, NULL if unset.
69 extern const char *bt_ctf_clock_get_description(struct bt_ctf_clock
*clock
);
72 * bt_ctf_clock_set_description: set a clock's description.
74 * Set the clock's description. The description appears in the clock's TSDL
77 * @param clock Clock instance.
78 * @param desc Description of the clock.
80 * Returns 0 on success, a negative value on error.
82 extern int bt_ctf_clock_set_description(struct bt_ctf_clock
*clock
,
86 * bt_ctf_clock_get_frequency: get a clock's frequency.
88 * Get the clock's frequency (Hz).
90 * @param clock Clock instance.
92 * Returns the clock's frequency, -1ULL on error.
94 extern uint64_t bt_ctf_clock_get_frequency(struct bt_ctf_clock
*clock
);
97 * bt_ctf_clock_set_frequency: set a clock's frequency.
99 * Set the clock's frequency (Hz).
101 * @param clock Clock instance.
102 * @param freq Clock's frequency in Hz, defaults to 1 000 000 000 Hz (1ns).
104 * Returns 0 on success, a negative value on error.
106 extern int bt_ctf_clock_set_frequency(struct bt_ctf_clock
*clock
,
110 * bt_ctf_clock_get_precision: get a clock's precision.
112 * Get the clock's precision (in clock ticks).
114 * @param clock Clock instance.
116 * Returns the clock's precision, -1ULL on error.
118 extern uint64_t bt_ctf_clock_get_precision(struct bt_ctf_clock
*clock
);
121 * bt_ctf_clock_set_precision: set a clock's precision.
123 * Set the clock's precision.
125 * @param clock Clock instance.
126 * @param precision Clock's precision in clock ticks, defaults to 1.
128 * Returns 0 on success, a negative value on error.
130 extern int bt_ctf_clock_set_precision(struct bt_ctf_clock
*clock
,
134 * bt_ctf_clock_get_offset_s: get a clock's offset in seconds.
136 * Get the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01.
138 * @param clock Clock instance.
139 * @param offset_s Pointer to clock offset in seconds (output).
141 * Returns 0 on success, a negative value on error.
143 extern int bt_ctf_clock_get_offset_s(struct bt_ctf_clock
*clock
,
147 * bt_ctf_clock_set_offset_s: set a clock's offset in seconds.
149 * Set the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01,
152 * @param clock Clock instance.
153 * @param offset_s Clock's offset in seconds, defaults to 0.
155 * Returns 0 on success, a negative value on error.
157 extern int bt_ctf_clock_set_offset_s(struct bt_ctf_clock
*clock
,
161 * bt_ctf_clock_get_offset: get a clock's offset in ticks.
163 * Get the clock's offset in ticks from Epoch + offset_t.
165 * @param clock Clock instance.
166 * @param offset Clock offset in ticks from Epoch + offset_s (output).
168 * Returns 0 on success, a negative value on error.
170 extern int bt_ctf_clock_get_offset(struct bt_ctf_clock
*clock
,
174 * bt_ctf_clock_set_offset: set a clock's offset in ticks.
176 * Set the clock's offset in ticks from Epoch + offset_s.
178 * @param clock Clock instance.
179 * @param offset Clock's offset in ticks from Epoch + offset_s, defaults to 0.
181 * Returns 0 on success, a negative value on error.
183 extern int bt_ctf_clock_set_offset(struct bt_ctf_clock
*clock
,
187 * bt_ctf_clock_get_is_absolute: get a clock's absolute attribute.
189 * Get the clock's absolute attribute. A clock is absolute if the clock is a
190 * global reference across the trace's other clocks.
192 * @param clock Clock instance.
194 * Returns the clock's absolute attribute, a negative value on error.
196 extern int bt_ctf_clock_get_is_absolute(struct bt_ctf_clock
*clock
);
199 * bt_ctf_clock_set_is_absolute: set a clock's absolute attribute.
201 * Set the clock's absolute attribute. A clock is absolute if the clock is a
202 * global reference across the trace's other clocks.
204 * @param clock Clock instance.
205 * @param is_absolute Clock's absolute attribute, defaults to FALSE.
207 * Returns 0 on success, a negative value on error.
209 extern int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock
*clock
,
213 * bt_ctf_clock_get_uuid: get a clock's UUID.
215 * Get the clock's UUID.
217 * @param clock Clock instance.
219 * Returns a pointer to the clock's UUID (16 byte array) on success,
222 extern const uint8_t *bt_ctf_clock_get_uuid(struct bt_ctf_clock
*clock
);
225 * bt_ctf_clock_set_uuid: set a clock's UUID.
227 * Set a clock's UUID.
229 * @param clock Clock instance.
230 * @param uuid A 16-byte array containing a UUID.
232 * Returns 0 on success, a negative value on error.
234 extern int bt_ctf_clock_set_uuid(struct bt_ctf_clock
*clock
,
235 const uint8_t *uuid
);
238 * bt_ctf_clock_set_time: set a clock's current time value.
240 * Set the current time in nanoseconds since the clock's origin (offset and
241 * offset_s attributes). Defaults to 0.
243 * Returns 0 on success, a negative value on error.
245 extern int bt_ctf_clock_set_time(struct bt_ctf_clock
*clock
,
249 * bt_ctf_clock_get and bt_ctf_clock_put: increment and decrement the
250 * refcount of the clock
252 * You may also use bt_ctf_get() and bt_ctf_put() with clock objects.
254 * These functions ensure that the clock won't be destroyed when it
255 * is in use. The same number of get and put (plus one extra put to
256 * release the initial reference done at creation) has to be done to
259 * When the clock refcount is decremented to 0 by a bt_ctf_clock_put,
260 * the clock is freed.
262 * @param clock Clock instance.
265 /* Pre-2.0 CTF writer compatibility */
267 void bt_ctf_clock_get(struct bt_ctf_clock
*clock
)
269 bt_ctf_object_get_ref(clock
);
272 /* Pre-2.0 CTF writer compatibility */
274 void bt_ctf_clock_put(struct bt_ctf_clock
*clock
)
276 bt_ctf_object_put_ref(clock
);
282 #endif /* BABELTRACE2_CTF_WRITER_CLOCK_H */
This page took 0.038612 seconds and 4 git commands to generate.