7cfc073f741b5d8e3d495a975e66ce481a969301
[lttngtop.git] / lib / babeltrace / ctf-writer / clock.h
1 #ifndef BABELTRACE_CTF_WRITER_CLOCK_H
2 #define BABELTRACE_CTF_WRITER_CLOCK_H
3
4 /*
5 * BabelTrace - CTF Writer: Clock
6 *
7 * Copyright 2013 EfficiOS Inc.
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_set_description: set a clock's description.
54 *
55 * Set the clock's description. The description appears in the clock's TSDL
56 * meta-data.
57 *
58 * @param clock Clock instance.
59 * @param desc Description of the clock.
60 *
61 * Returns 0 on success, a negative value on error.
62 */
63 extern int bt_ctf_clock_set_description(struct bt_ctf_clock *clock,
64 const char *desc);
65
66 /*
67 * bt_ctf_clock_set_frequency: set a clock's frequency.
68 *
69 * Set the clock's frequency (Hz).
70 *
71 * @param clock Clock instance.
72 * @param freq Clock's frequency in Hz, defaults to 1 000 000 000 Hz (1ns).
73 *
74 * Returns 0 on success, a negative value on error.
75 */
76 extern int bt_ctf_clock_set_frequency(struct bt_ctf_clock *clock,
77 uint64_t freq);
78
79 /*
80 * bt_ctf_clock_set_precision: set a clock's precision.
81 *
82 * Set the clock's precision.
83 *
84 * @param clock Clock instance.
85 * @param precision Clock's precision in clock ticks, defaults to 1.
86 *
87 * Returns 0 on success, a negative value on error.
88 */
89 extern int bt_ctf_clock_set_precision(struct bt_ctf_clock *clock,
90 uint64_t precision);
91
92 /*
93 * bt_ctf_clock_set_offset_s: set a clock's offset in seconds.
94 *
95 * Set the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01,
96 * defaults to 0.
97 *
98 * @param clock Clock instance.
99 * @param offset_s Clock's offset in seconds, defaults to 0.
100 *
101 * Returns 0 on success, a negative value on error.
102 */
103 extern int bt_ctf_clock_set_offset_s(struct bt_ctf_clock *clock,
104 uint64_t offset_s);
105
106
107 /*
108 * bt_ctf_clock_set_offset: set a clock's offset in ticks.
109 *
110 * Set the clock's offset in ticks from Epoch + offset_s.
111 *
112 * @param clock Clock instance.
113 * @param offset Clock's offset in ticks from Epoch + offset_s, defaults to 0.
114 *
115 * Returns 0 on success, a negative value on error.
116 */
117 extern int bt_ctf_clock_set_offset(struct bt_ctf_clock *clock,
118 uint64_t offset);
119
120 /*
121 * bt_ctf_clock_set_is_absolute: set a clock's absolute attribute.
122 *
123 * A clock is absolute if the clock is a global reference across the trace's
124 * other clocks.
125 *
126 * @param clock Clock instance.
127 * @param is_absolute Clock's absolute attribute, defaults to FALSE.
128 *
129 * Returns 0 on success, a negative value on error.
130 */
131 extern int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock,
132 int is_absolute);
133
134 /*
135 * bt_ctf_clock_set_time: set a clock's current time value.
136 *
137 * Set the current time in nanoseconds since the clock's origin (offset and
138 * offset_s attributes). The clock's value will be sampled as events are
139 * appended to a stream.
140 *
141 * Returns 0 on success, a negative value on error.
142 */
143 extern int bt_ctf_clock_set_time(struct bt_ctf_clock *clock, uint64_t time);
144
145 /*
146 * bt_ctf_clock_get and bt_ctf_clock_put: increment and decrement the
147 * refcount of the clock
148 *
149 * These functions ensure that the clock won't be destroyed when it
150 * is in use. The same number of get and put (plus one extra put to
151 * release the initial reference done at creation) has to be done to
152 * destroy a clock.
153 *
154 * When the clock refcount is decremented to 0 by a bt_ctf_clock_put,
155 * the clock is freed.
156 *
157 * @param clock Clock instance.
158 */
159 extern void bt_ctf_clock_get(struct bt_ctf_clock *clock);
160 extern void bt_ctf_clock_put(struct bt_ctf_clock *clock);
161
162 #ifdef __cplusplus
163 }
164 #endif
165
166 #endif /* BABELTRACE_CTF_WRITER_CLOCK_H */
This page took 0.031308 seconds and 3 git commands to generate.