babeltrace headers sync
[lttngtop.git] / lib / babeltrace / ctf-ir / clock.h
1 #ifndef BABELTRACE_CTF_IR_CLOCK_H
2 #define BABELTRACE_CTF_IR_CLOCK_H
3
4 /*
5 * BabelTrace - CTF IR: Clock
6 *
7 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 *
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 *
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:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
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
27 * SOFTWARE.
28 *
29 * The Common Trace Format (CTF) Specification is available at
30 * http://www.efficios.com/ctf
31 */
32
33 #include <stdint.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 struct bt_ctf_clock;
40
41 /*
42 * bt_ctf_clock_create: create a clock.
43 *
44 * Allocate a new clock setting its reference count to 1.
45 *
46 * @param name Name of the clock (will be copied).
47 *
48 * Returns an allocated clock on success, NULL on error.
49 */
50 extern struct bt_ctf_clock *bt_ctf_clock_create(const char *name);
51
52 /*
53 * bt_ctf_clock_get_name: get a clock's name.
54 *
55 * Get the clock's name.
56 *
57 * @param clock Clock instance.
58 *
59 * Returns the clock's name, NULL on error.
60 */
61 extern const char *bt_ctf_clock_get_name(struct bt_ctf_clock *clock);
62
63 /*
64 * bt_ctf_clock_get_description: get a clock's description.
65 *
66 * Get the clock's description.
67 *
68 * @param clock Clock instance.
69 *
70 * Returns the clock's description, NULL if unset.
71 */
72 extern const char *bt_ctf_clock_get_description(struct bt_ctf_clock *clock);
73
74 /*
75 * bt_ctf_clock_set_description: set a clock's description.
76 *
77 * Set the clock's description. The description appears in the clock's TSDL
78 * meta-data.
79 *
80 * @param clock Clock instance.
81 * @param desc Description of the clock.
82 *
83 * Returns 0 on success, a negative value on error.
84 */
85 extern int bt_ctf_clock_set_description(struct bt_ctf_clock *clock,
86 const char *desc);
87
88 /*
89 * bt_ctf_clock_get_frequency: get a clock's frequency.
90 *
91 * Get the clock's frequency (Hz).
92 *
93 * @param clock Clock instance.
94 *
95 * Returns the clock's frequency, -1ULL on error.
96 */
97 extern uint64_t bt_ctf_clock_get_frequency(struct bt_ctf_clock *clock);
98
99 /*
100 * bt_ctf_clock_set_frequency: set a clock's frequency.
101 *
102 * Set the clock's frequency (Hz).
103 *
104 * @param clock Clock instance.
105 * @param freq Clock's frequency in Hz, defaults to 1 000 000 000 Hz (1ns).
106 *
107 * Returns 0 on success, a negative value on error.
108 */
109 extern int bt_ctf_clock_set_frequency(struct bt_ctf_clock *clock,
110 uint64_t freq);
111
112 /*
113 * bt_ctf_clock_get_precision: get a clock's precision.
114 *
115 * Get the clock's precision (in clock ticks).
116 *
117 * @param clock Clock instance.
118 *
119 * Returns the clock's precision, -1ULL on error.
120 */
121 extern uint64_t bt_ctf_clock_get_precision(struct bt_ctf_clock *clock);
122
123 /*
124 * bt_ctf_clock_set_precision: set a clock's precision.
125 *
126 * Set the clock's precision.
127 *
128 * @param clock Clock instance.
129 * @param precision Clock's precision in clock ticks, defaults to 1.
130 *
131 * Returns 0 on success, a negative value on error.
132 */
133 extern int bt_ctf_clock_set_precision(struct bt_ctf_clock *clock,
134 uint64_t precision);
135
136 /*
137 * bt_ctf_clock_get_offset_s: get a clock's offset in seconds.
138 *
139 * Get the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01.
140 *
141 * @param clock Clock instance.
142 *
143 * Returns the clock's offset in seconds, -1ULL on error.
144 */
145 extern uint64_t bt_ctf_clock_get_offset_s(struct bt_ctf_clock *clock);
146
147 /*
148 * bt_ctf_clock_set_offset_s: set a clock's offset in seconds.
149 *
150 * Set the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01,
151 * defaults to 0.
152 *
153 * @param clock Clock instance.
154 * @param offset_s Clock's offset in seconds, defaults to 0.
155 *
156 * Returns 0 on success, a negative value on error.
157 */
158 extern int bt_ctf_clock_set_offset_s(struct bt_ctf_clock *clock,
159 uint64_t offset_s);
160
161 /*
162 * bt_ctf_clock_get_offset_s: get a clock's offset in ticks.
163 *
164 * Get the clock's offset in ticks from Epoch + offset_t.
165 *
166 * @param clock Clock instance.
167 *
168 * Returns the clock's offset in ticks from Epoch + offset_s, -1ULL on error.
169 */
170 extern uint64_t bt_ctf_clock_get_offset(struct bt_ctf_clock *clock);
171
172 /*
173 * bt_ctf_clock_set_offset: set a clock's offset in ticks.
174 *
175 * Set the clock's offset in ticks from Epoch + offset_s.
176 *
177 * @param clock Clock instance.
178 * @param offset Clock's offset in ticks from Epoch + offset_s, defaults to 0.
179 *
180 * Returns 0 on success, a negative value on error.
181 */
182 extern int bt_ctf_clock_set_offset(struct bt_ctf_clock *clock,
183 uint64_t offset);
184
185 /*
186 * bt_ctf_clock_get_is_absolute: get a clock's absolute attribute.
187 *
188 * Get the clock's absolute attribute. A clock is absolute if the clock is a
189 * global reference across the trace's other clocks.
190 *
191 * @param clock Clock instance.
192 *
193 * Returns the clock's absolute attribute, a negative value on error.
194 */
195 extern int bt_ctf_clock_get_is_absolute(struct bt_ctf_clock *clock);
196
197 /*
198 * bt_ctf_clock_set_is_absolute: set a clock's absolute attribute.
199 *
200 * Set the clock's absolute attribute. A clock is absolute if the clock is a
201 * global reference across the trace's other clocks.
202 *
203 * @param clock Clock instance.
204 * @param is_absolute Clock's absolute attribute, defaults to FALSE.
205 *
206 * Returns 0 on success, a negative value on error.
207 */
208 extern int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock,
209 int is_absolute);
210
211 /*
212 * bt_ctf_clock_get_time: get a clock's current time value.
213 *
214 * Get the current time in nanoseconds since the clock's origin (offset and
215 * offset_s attributes).
216 *
217 * Returns the clock's current time value, -1ULL on error.
218 */
219 extern uint64_t bt_ctf_clock_get_time(struct bt_ctf_clock *clock);
220
221 /*
222 * bt_ctf_clock_set_time: set a clock's current time value.
223 *
224 * Set the current time in nanoseconds since the clock's origin (offset and
225 * offset_s attributes). Defaults to 0.
226 *
227 * Returns 0 on success, a negative value on error.
228 */
229 extern int bt_ctf_clock_set_time(struct bt_ctf_clock *clock,
230 uint64_t time);
231
232 /*
233 * bt_ctf_clock_get and bt_ctf_clock_put: increment and decrement the
234 * refcount of the clock
235 *
236 * These functions ensure that the clock won't be destroyed when it
237 * is in use. The same number of get and put (plus one extra put to
238 * release the initial reference done at creation) has to be done to
239 * destroy a clock.
240 *
241 * When the clock refcount is decremented to 0 by a bt_ctf_clock_put,
242 * the clock is freed.
243 *
244 * @param clock Clock instance.
245 */
246 extern void bt_ctf_clock_get(struct bt_ctf_clock *clock);
247 extern void bt_ctf_clock_put(struct bt_ctf_clock *clock);
248
249 #ifdef __cplusplus
250 }
251 #endif
252
253 #endif /* BABELTRACE_CTF_IR_CLOCK_H */
This page took 0.033063 seconds and 4 git commands to generate.