blob: 4ea45d0df1d4b68e67a0f03622568905a5fa3969 [file] [log] [blame]
Arnd Bergmann65469112017-10-19 13:14:49 +02001#ifndef _LINUX_TIMEKEEPING32_H
2#define _LINUX_TIMEKEEPING32_H
3/*
4 * These interfaces are all based on the old timespec type
5 * and should get replaced with the timespec64 based versions
6 * over time so we can remove the file here.
7 */
8
9extern void do_gettimeofday(struct timeval *tv);
10unsigned long get_seconds(void);
11
Arnd Bergmann65469112017-10-19 13:14:49 +020012static inline struct timespec current_kernel_time(void)
13{
14 struct timespec64 now = current_kernel_time64();
15
16 return timespec64_to_timespec(now);
17}
18
Arnd Bergmann65469112017-10-19 13:14:49 +020019/**
20 * Deprecated. Use do_settimeofday64().
21 */
22static inline int do_settimeofday(const struct timespec *ts)
23{
24 struct timespec64 ts64;
25
26 ts64 = timespec_to_timespec64(*ts);
27 return do_settimeofday64(&ts64);
28}
29
30static inline int __getnstimeofday(struct timespec *ts)
31{
32 struct timespec64 ts64;
33 int ret = __getnstimeofday64(&ts64);
34
35 *ts = timespec64_to_timespec(ts64);
36 return ret;
37}
38
39static inline void getnstimeofday(struct timespec *ts)
40{
41 struct timespec64 ts64;
42
43 getnstimeofday64(&ts64);
44 *ts = timespec64_to_timespec(ts64);
45}
46
47static inline void ktime_get_ts(struct timespec *ts)
48{
49 struct timespec64 ts64;
50
51 ktime_get_ts64(&ts64);
52 *ts = timespec64_to_timespec(ts64);
53}
54
55static inline void ktime_get_real_ts(struct timespec *ts)
56{
57 struct timespec64 ts64;
58
59 getnstimeofday64(&ts64);
60 *ts = timespec64_to_timespec(ts64);
61}
62
63static inline void getrawmonotonic(struct timespec *ts)
64{
65 struct timespec64 ts64;
66
67 getrawmonotonic64(&ts64);
68 *ts = timespec64_to_timespec(ts64);
69}
70
71static inline struct timespec get_monotonic_coarse(void)
72{
73 return timespec64_to_timespec(get_monotonic_coarse64());
74}
75
76static inline void getboottime(struct timespec *ts)
77{
78 struct timespec64 ts64;
79
80 getboottime64(&ts64);
81 *ts = timespec64_to_timespec(ts64);
82}
Arnd Bergmann65469112017-10-19 13:14:49 +020083
84/*
85 * Timespec interfaces utilizing the ktime based ones
86 */
87static inline void get_monotonic_boottime(struct timespec *ts)
88{
89 *ts = ktime_to_timespec(ktime_get_boottime());
90}
91
92static inline void timekeeping_clocktai(struct timespec *ts)
93{
94 *ts = ktime_to_timespec(ktime_get_clocktai());
95}
96
97/*
98 * Persistent clock related interfaces
99 */
100extern void read_persistent_clock(struct timespec *ts);
101extern int update_persistent_clock(struct timespec now);
102
103#endif