ir: stream: add bt_ctf_stream_is_writer()
[babeltrace.git] / include / 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 struct bt_ctf_clock_value;
41
42 /*
43 * bt_ctf_clock_create: create a clock.
44 *
45 * Allocate a new clock setting its reference count to 1.
46 *
47 * @param name Name of the clock (will be copied); can be set to NULL
48 * for nameless clocks.
49 *
50 * Returns an allocated clock on success, NULL on error.
51 */
52 extern struct bt_ctf_clock *bt_ctf_clock_create(const char *name);
53
54 /*
55 * bt_ctf_clock_get_name: get a clock's name.
56 *
57 * Get the clock's name.
58 *
59 * @param clock Clock instance.
60 *
61 * Returns the clock's name, NULL on error.
62 */
63 extern const char *bt_ctf_clock_get_name(struct bt_ctf_clock *clock);
64
65 /*
66 * bt_ctf_clock_set_name: set a clock's name.
67 *
68 * Set a clock's name.
69 *
70 * @param name Name of the clock (will be copied).
71 *
72 * Returns 0 on success, a negative value on error.
73 */
74 extern int bt_ctf_clock_set_name(struct bt_ctf_clock *clock, const char *name);
75
76 /*
77 * bt_ctf_clock_get_description: get a clock's description.
78 *
79 * Get the clock's description.
80 *
81 * @param clock Clock instance.
82 *
83 * Returns the clock's description, NULL if unset.
84 */
85 extern const char *bt_ctf_clock_get_description(struct bt_ctf_clock *clock);
86
87 /*
88 * bt_ctf_clock_set_description: set a clock's description.
89 *
90 * Set the clock's description. The description appears in the clock's TSDL
91 * meta-data.
92 *
93 * @param clock Clock instance.
94 * @param desc Description of the clock.
95 *
96 * Returns 0 on success, a negative value on error.
97 */
98 extern int bt_ctf_clock_set_description(struct bt_ctf_clock *clock,
99 const char *desc);
100
101 /*
102 * bt_ctf_clock_get_frequency: get a clock's frequency.
103 *
104 * Get the clock's frequency (Hz).
105 *
106 * @param clock Clock instance.
107 *
108 * Returns the clock's frequency, -1ULL on error.
109 */
110 extern uint64_t bt_ctf_clock_get_frequency(struct bt_ctf_clock *clock);
111
112 /*
113 * bt_ctf_clock_set_frequency: set a clock's frequency.
114 *
115 * Set the clock's frequency (Hz).
116 *
117 * @param clock Clock instance.
118 * @param freq Clock's frequency in Hz, defaults to 1 000 000 000 Hz (1ns).
119 *
120 * Returns 0 on success, a negative value on error.
121 */
122 extern int bt_ctf_clock_set_frequency(struct bt_ctf_clock *clock,
123 uint64_t freq);
124
125 /*
126 * bt_ctf_clock_get_precision: get a clock's precision.
127 *
128 * Get the clock's precision (in clock ticks).
129 *
130 * @param clock Clock instance.
131 *
132 * Returns the clock's precision, -1ULL on error.
133 */
134 extern uint64_t bt_ctf_clock_get_precision(struct bt_ctf_clock *clock);
135
136 /*
137 * bt_ctf_clock_set_precision: set a clock's precision.
138 *
139 * Set the clock's precision.
140 *
141 * @param clock Clock instance.
142 * @param precision Clock's precision in clock ticks, defaults to 1.
143 *
144 * Returns 0 on success, a negative value on error.
145 */
146 extern int bt_ctf_clock_set_precision(struct bt_ctf_clock *clock,
147 uint64_t precision);
148
149 /*
150 * bt_ctf_clock_get_offset_s: get a clock's offset in seconds.
151 *
152 * Get the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01.
153 *
154 * @param clock Clock instance.
155 * @param offset_s Pointer to clock offset in seconds (output).
156 *
157 * Returns 0 on success, a negative value on error.
158 */
159 extern int bt_ctf_clock_get_offset_s(struct bt_ctf_clock *clock,
160 int64_t *offset_s);
161
162 /*
163 * bt_ctf_clock_set_offset_s: set a clock's offset in seconds.
164 *
165 * Set the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01,
166 * defaults to 0.
167 *
168 * @param clock Clock instance.
169 * @param offset_s Clock's offset in seconds, defaults to 0.
170 *
171 * Returns 0 on success, a negative value on error.
172 */
173 extern int bt_ctf_clock_set_offset_s(struct bt_ctf_clock *clock,
174 int64_t offset_s);
175
176 /*
177 * bt_ctf_clock_get_offset: get a clock's offset in ticks.
178 *
179 * Get the clock's offset in ticks from Epoch + offset_t.
180 *
181 * @param clock Clock instance.
182 * @param offset Clock offset in ticks from Epoch + offset_s (output).
183 *
184 * Returns 0 on success, a negative value on error.
185 */
186 extern int bt_ctf_clock_get_offset(struct bt_ctf_clock *clock,
187 int64_t *offset);
188
189 /*
190 * bt_ctf_clock_set_offset: set a clock's offset in ticks.
191 *
192 * Set the clock's offset in ticks from Epoch + offset_s.
193 *
194 * @param clock Clock instance.
195 * @param offset Clock's offset in ticks from Epoch + offset_s, defaults to 0.
196 *
197 * Returns 0 on success, a negative value on error.
198 */
199 extern int bt_ctf_clock_set_offset(struct bt_ctf_clock *clock,
200 int64_t offset);
201
202 /*
203 * bt_ctf_clock_get_is_absolute: get a clock's absolute attribute.
204 *
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.
207 *
208 * @param clock Clock instance.
209 *
210 * Returns the clock's absolute attribute, a negative value on error.
211 */
212 extern int bt_ctf_clock_get_is_absolute(struct bt_ctf_clock *clock);
213
214 /*
215 * bt_ctf_clock_set_is_absolute: set a clock's absolute attribute.
216 *
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.
219 *
220 * @param clock Clock instance.
221 * @param is_absolute Clock's absolute attribute, defaults to FALSE.
222 *
223 * Returns 0 on success, a negative value on error.
224 */
225 extern int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock,
226 int is_absolute);
227
228 /*
229 * bt_ctf_clock_get_uuid: get a clock's UUID.
230 *
231 * Get the clock's UUID.
232 *
233 * @param clock Clock instance.
234 *
235 * Returns a pointer to the clock's UUID (16 byte array) on success,
236 * NULL on error.
237 */
238 extern const unsigned char *bt_ctf_clock_get_uuid(struct bt_ctf_clock *clock);
239
240 /*
241 * bt_ctf_clock_set_uuid: set a clock's UUID.
242 *
243 * Set a clock's UUID.
244 *
245 * @param clock Clock instance.
246 * @param uuid A 16-byte array containing a UUID.
247 *
248 * Returns 0 on success, a negative value on error.
249 */
250 extern int bt_ctf_clock_set_uuid(struct bt_ctf_clock *clock,
251 const unsigned char *uuid);
252
253 extern struct bt_ctf_clock_value *bt_ctf_clock_value_create(
254 struct bt_ctf_clock *clock, uint64_t value);
255
256 extern int bt_ctf_clock_value_get_value(
257 struct bt_ctf_clock_value *clock_value, uint64_t *raw_value);
258
259 extern int bt_ctf_clock_value_get_value_ns_from_epoch(
260 struct bt_ctf_clock_value *clock_value, int64_t *value_ns);
261
262 #ifdef __cplusplus
263 }
264 #endif
265
266 #endif /* BABELTRACE_CTF_IR_CLOCK_H */
This page took 0.037162 seconds and 4 git commands to generate.