This source file includes following definitions.
- ktime_get_real
- ktime_get_coarse_real
- ktime_get_boottime
- ktime_get_coarse_boottime
- ktime_get_clocktai
- ktime_get_coarse_clocktai
- ktime_get_coarse
- ktime_get_coarse_ns
- ktime_get_coarse_real_ns
- ktime_get_coarse_boottime_ns
- ktime_get_coarse_clocktai_ns
- ktime_mono_to_real
- ktime_get_ns
- ktime_get_real_ns
- ktime_get_boottime_ns
- ktime_get_clocktai_ns
- ktime_get_raw_ns
- ktime_get_boottime_ts64
- ktime_get_coarse_boottime_ts64
- ktime_get_boottime_seconds
- ktime_get_clocktai_ts64
- ktime_get_coarse_clocktai_ts64
- ktime_get_clocktai_seconds
1
2 #ifndef _LINUX_TIMEKEEPING_H
3 #define _LINUX_TIMEKEEPING_H
4
5 #include <linux/errno.h>
6
7
8
9 void timekeeping_init(void);
10 extern int timekeeping_suspended;
11
12
13 extern void update_process_times(int user);
14 extern void xtime_update(unsigned long ticks);
15
16
17
18
19 extern int do_settimeofday64(const struct timespec64 *ts);
20 extern int do_sys_settimeofday64(const struct timespec64 *tv,
21 const struct timezone *tz);
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 extern void ktime_get_raw_ts64(struct timespec64 *ts);
42 extern void ktime_get_ts64(struct timespec64 *ts);
43 extern void ktime_get_real_ts64(struct timespec64 *tv);
44 extern void ktime_get_coarse_ts64(struct timespec64 *ts);
45 extern void ktime_get_coarse_real_ts64(struct timespec64 *ts);
46
47 void getboottime64(struct timespec64 *ts);
48
49
50
51
52 extern time64_t ktime_get_seconds(void);
53 extern time64_t __ktime_get_real_seconds(void);
54 extern time64_t ktime_get_real_seconds(void);
55
56
57
58
59
60 enum tk_offsets {
61 TK_OFFS_REAL,
62 TK_OFFS_BOOT,
63 TK_OFFS_TAI,
64 TK_OFFS_MAX,
65 };
66
67 extern ktime_t ktime_get(void);
68 extern ktime_t ktime_get_with_offset(enum tk_offsets offs);
69 extern ktime_t ktime_get_coarse_with_offset(enum tk_offsets offs);
70 extern ktime_t ktime_mono_to_any(ktime_t tmono, enum tk_offsets offs);
71 extern ktime_t ktime_get_raw(void);
72 extern u32 ktime_get_resolution_ns(void);
73
74
75
76
77 static inline ktime_t ktime_get_real(void)
78 {
79 return ktime_get_with_offset(TK_OFFS_REAL);
80 }
81
82 static inline ktime_t ktime_get_coarse_real(void)
83 {
84 return ktime_get_coarse_with_offset(TK_OFFS_REAL);
85 }
86
87
88
89
90
91
92
93 static inline ktime_t ktime_get_boottime(void)
94 {
95 return ktime_get_with_offset(TK_OFFS_BOOT);
96 }
97
98 static inline ktime_t ktime_get_coarse_boottime(void)
99 {
100 return ktime_get_coarse_with_offset(TK_OFFS_BOOT);
101 }
102
103
104
105
106 static inline ktime_t ktime_get_clocktai(void)
107 {
108 return ktime_get_with_offset(TK_OFFS_TAI);
109 }
110
111 static inline ktime_t ktime_get_coarse_clocktai(void)
112 {
113 return ktime_get_coarse_with_offset(TK_OFFS_TAI);
114 }
115
116 static inline ktime_t ktime_get_coarse(void)
117 {
118 struct timespec64 ts;
119
120 ktime_get_coarse_ts64(&ts);
121 return timespec64_to_ktime(ts);
122 }
123
124 static inline u64 ktime_get_coarse_ns(void)
125 {
126 return ktime_to_ns(ktime_get_coarse());
127 }
128
129 static inline u64 ktime_get_coarse_real_ns(void)
130 {
131 return ktime_to_ns(ktime_get_coarse_real());
132 }
133
134 static inline u64 ktime_get_coarse_boottime_ns(void)
135 {
136 return ktime_to_ns(ktime_get_coarse_boottime());
137 }
138
139 static inline u64 ktime_get_coarse_clocktai_ns(void)
140 {
141 return ktime_to_ns(ktime_get_coarse_clocktai());
142 }
143
144
145
146
147 static inline ktime_t ktime_mono_to_real(ktime_t mono)
148 {
149 return ktime_mono_to_any(mono, TK_OFFS_REAL);
150 }
151
152 static inline u64 ktime_get_ns(void)
153 {
154 return ktime_to_ns(ktime_get());
155 }
156
157 static inline u64 ktime_get_real_ns(void)
158 {
159 return ktime_to_ns(ktime_get_real());
160 }
161
162 static inline u64 ktime_get_boottime_ns(void)
163 {
164 return ktime_to_ns(ktime_get_boottime());
165 }
166
167 static inline u64 ktime_get_clocktai_ns(void)
168 {
169 return ktime_to_ns(ktime_get_clocktai());
170 }
171
172 static inline u64 ktime_get_raw_ns(void)
173 {
174 return ktime_to_ns(ktime_get_raw());
175 }
176
177 extern u64 ktime_get_mono_fast_ns(void);
178 extern u64 ktime_get_raw_fast_ns(void);
179 extern u64 ktime_get_boot_fast_ns(void);
180 extern u64 ktime_get_real_fast_ns(void);
181
182
183
184
185
186
187 static inline void ktime_get_boottime_ts64(struct timespec64 *ts)
188 {
189 *ts = ktime_to_timespec64(ktime_get_boottime());
190 }
191
192 static inline void ktime_get_coarse_boottime_ts64(struct timespec64 *ts)
193 {
194 *ts = ktime_to_timespec64(ktime_get_coarse_boottime());
195 }
196
197 static inline time64_t ktime_get_boottime_seconds(void)
198 {
199 return ktime_divns(ktime_get_coarse_boottime(), NSEC_PER_SEC);
200 }
201
202 static inline void ktime_get_clocktai_ts64(struct timespec64 *ts)
203 {
204 *ts = ktime_to_timespec64(ktime_get_clocktai());
205 }
206
207 static inline void ktime_get_coarse_clocktai_ts64(struct timespec64 *ts)
208 {
209 *ts = ktime_to_timespec64(ktime_get_coarse_clocktai());
210 }
211
212 static inline time64_t ktime_get_clocktai_seconds(void)
213 {
214 return ktime_divns(ktime_get_coarse_clocktai(), NSEC_PER_SEC);
215 }
216
217
218
219
220 extern bool timekeeping_rtc_skipsuspend(void);
221 extern bool timekeeping_rtc_skipresume(void);
222
223 extern void timekeeping_inject_sleeptime64(const struct timespec64 *delta);
224
225
226
227
228
229
230
231
232
233
234 struct system_time_snapshot {
235 u64 cycles;
236 ktime_t real;
237 ktime_t raw;
238 unsigned int clock_was_set_seq;
239 u8 cs_was_changed_seq;
240 };
241
242
243
244
245
246
247
248
249 struct system_device_crosststamp {
250 ktime_t device;
251 ktime_t sys_realtime;
252 ktime_t sys_monoraw;
253 };
254
255
256
257
258
259
260
261
262 struct system_counterval_t {
263 u64 cycles;
264 struct clocksource *cs;
265 };
266
267
268
269
270 extern int get_device_system_crosststamp(
271 int (*get_time_fn)(ktime_t *device_time,
272 struct system_counterval_t *system_counterval,
273 void *ctx),
274 void *ctx,
275 struct system_time_snapshot *history,
276 struct system_device_crosststamp *xtstamp);
277
278
279
280
281 extern void ktime_get_snapshot(struct system_time_snapshot *systime_snapshot);
282
283
284
285
286 extern int persistent_clock_is_local;
287
288 extern void read_persistent_clock64(struct timespec64 *ts);
289 void read_persistent_wall_and_boot_offset(struct timespec64 *wall_clock,
290 struct timespec64 *boot_offset);
291 extern int update_persistent_clock64(struct timespec64 now);
292
293 #endif