1 #ifndef BABELTRACE_CTF_IR_CLOCK_H
2 #define BABELTRACE_CTF_IR_CLOCK_H
5 * BabelTrace - CTF IR: Clock
7 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 * The Common Trace Format (CTF) Specification is available at
30 * http://www.efficios.com/ctf
40 struct bt_ctf_clock_value
;
43 * bt_ctf_clock_create: create a clock.
45 * Allocate a new clock setting its reference count to 1.
47 * @param name Name of the clock (will be copied); can be set to NULL
48 * for nameless clocks.
50 * Returns an allocated clock on success, NULL on error.
52 extern struct bt_ctf_clock
*bt_ctf_clock_create(const char *name
);
55 * bt_ctf_clock_get_name: get a clock's name.
57 * Get the clock's name.
59 * @param clock Clock instance.
61 * Returns the clock's name, NULL on error.
63 extern const char *bt_ctf_clock_get_name(struct bt_ctf_clock
*clock
);
66 * bt_ctf_clock_set_name: set a clock's name.
70 * @param name Name of the clock (will be copied).
72 * Returns 0 on success, a negative value on error.
74 extern int bt_ctf_clock_set_name(struct bt_ctf_clock
*clock
, const char *name
);
77 * bt_ctf_clock_get_description: get a clock's description.
79 * Get the clock's description.
81 * @param clock Clock instance.
83 * Returns the clock's description, NULL if unset.
85 extern const char *bt_ctf_clock_get_description(struct bt_ctf_clock
*clock
);
88 * bt_ctf_clock_set_description: set a clock's description.
90 * Set the clock's description. The description appears in the clock's TSDL
93 * @param clock Clock instance.
94 * @param desc Description of the clock.
96 * Returns 0 on success, a negative value on error.
98 extern int bt_ctf_clock_set_description(struct bt_ctf_clock
*clock
,
102 * bt_ctf_clock_get_frequency: get a clock's frequency.
104 * Get the clock's frequency (Hz).
106 * @param clock Clock instance.
108 * Returns the clock's frequency, -1ULL on error.
110 extern uint64_t bt_ctf_clock_get_frequency(struct bt_ctf_clock
*clock
);
113 * bt_ctf_clock_set_frequency: set a clock's frequency.
115 * Set the clock's frequency (Hz).
117 * @param clock Clock instance.
118 * @param freq Clock's frequency in Hz, defaults to 1 000 000 000 Hz (1ns).
120 * Returns 0 on success, a negative value on error.
122 extern int bt_ctf_clock_set_frequency(struct bt_ctf_clock
*clock
,
126 * bt_ctf_clock_get_precision: get a clock's precision.
128 * Get the clock's precision (in clock ticks).
130 * @param clock Clock instance.
132 * Returns the clock's precision, -1ULL on error.
134 extern uint64_t bt_ctf_clock_get_precision(struct bt_ctf_clock
*clock
);
137 * bt_ctf_clock_set_precision: set a clock's precision.
139 * Set the clock's precision.
141 * @param clock Clock instance.
142 * @param precision Clock's precision in clock ticks, defaults to 1.
144 * Returns 0 on success, a negative value on error.
146 extern int bt_ctf_clock_set_precision(struct bt_ctf_clock
*clock
,
150 * bt_ctf_clock_get_offset_s: get a clock's offset in seconds.
152 * Get the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01.
154 * @param clock Clock instance.
155 * @param offset_s Pointer to clock offset in seconds (output).
157 * Returns 0 on success, a negative value on error.
159 extern int bt_ctf_clock_get_offset_s(struct bt_ctf_clock
*clock
,
163 * bt_ctf_clock_set_offset_s: set a clock's offset in seconds.
165 * Set the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01,
168 * @param clock Clock instance.
169 * @param offset_s Clock's offset in seconds, defaults to 0.
171 * Returns 0 on success, a negative value on error.
173 extern int bt_ctf_clock_set_offset_s(struct bt_ctf_clock
*clock
,
177 * bt_ctf_clock_get_offset: get a clock's offset in ticks.
179 * Get the clock's offset in ticks from Epoch + offset_t.
181 * @param clock Clock instance.
182 * @param offset Clock offset in ticks from Epoch + offset_s (output).
184 * Returns 0 on success, a negative value on error.
186 extern int bt_ctf_clock_get_offset(struct bt_ctf_clock
*clock
,
190 * bt_ctf_clock_set_offset: set a clock's offset in ticks.
192 * Set the clock's offset in ticks from Epoch + offset_s.
194 * @param clock Clock instance.
195 * @param offset Clock's offset in ticks from Epoch + offset_s, defaults to 0.
197 * Returns 0 on success, a negative value on error.
199 extern int bt_ctf_clock_set_offset(struct bt_ctf_clock
*clock
,
203 * bt_ctf_clock_get_is_absolute: get a clock's absolute attribute.
205 * Get the clock's absolute attribute. A clock is absolute if the clock is a
206 * global reference across the trace's other clocks.
208 * @param clock Clock instance.
210 * Returns the clock's absolute attribute, a negative value on error.
212 extern int bt_ctf_clock_get_is_absolute(struct bt_ctf_clock
*clock
);
215 * bt_ctf_clock_set_is_absolute: set a clock's absolute attribute.
217 * Set the clock's absolute attribute. A clock is absolute if the clock is a
218 * global reference across the trace's other clocks.
220 * @param clock Clock instance.
221 * @param is_absolute Clock's absolute attribute, defaults to FALSE.
223 * Returns 0 on success, a negative value on error.
225 extern int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock
*clock
,
229 * bt_ctf_clock_get_uuid: get a clock's UUID.
231 * Get the clock's UUID.
233 * @param clock Clock instance.
235 * Returns a pointer to the clock's UUID (16 byte array) on success,
238 extern const unsigned char *bt_ctf_clock_get_uuid(struct bt_ctf_clock
*clock
);
241 * bt_ctf_clock_set_uuid: set a clock's UUID.
243 * Set a clock's UUID.
245 * @param clock Clock instance.
246 * @param uuid A 16-byte array containing a UUID.
248 * Returns 0 on success, a negative value on error.
250 extern int bt_ctf_clock_set_uuid(struct bt_ctf_clock
*clock
,
251 const unsigned char *uuid
);
253 extern struct bt_ctf_clock_value
*bt_ctf_clock_value_create(
254 struct bt_ctf_clock
*clock
, uint64_t value
);
256 extern int bt_ctf_clock_value_get_value(
257 struct bt_ctf_clock_value
*clock_value
, uint64_t *raw_value
);
259 extern int bt_ctf_clock_value_get_value_ns_from_epoch(
260 struct bt_ctf_clock_value
*clock_value
, int64_t *value_ns
);
266 #endif /* BABELTRACE_CTF_IR_CLOCK_H */
This page took 0.040863 seconds and 4 git commands to generate.