1 #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 
do_gettimeofday(struct timeval * tv)9 static inline void do_gettimeofday(struct timeval *tv)
10 {
11 	struct timespec64 now;
12 
13 	ktime_get_real_ts64(&now);
14 	tv->tv_sec = now.tv_sec;
15 	tv->tv_usec = now.tv_nsec/1000;
16 }
17 
get_seconds(void)18 static inline unsigned long get_seconds(void)
19 {
20 	return ktime_get_real_seconds();
21 }
22 
current_kernel_time(void)23 static inline struct timespec current_kernel_time(void)
24 {
25 	struct timespec64 ts64;
26 
27 	ktime_get_coarse_real_ts64(&ts64);
28 
29 	return timespec64_to_timespec(ts64);
30 }
31 
32 /**
33  * Deprecated. Use do_settimeofday64().
34  */
do_settimeofday(const struct timespec * ts)35 static inline int do_settimeofday(const struct timespec *ts)
36 {
37 	struct timespec64 ts64;
38 
39 	ts64 = timespec_to_timespec64(*ts);
40 	return do_settimeofday64(&ts64);
41 }
42 
getnstimeofday(struct timespec * ts)43 static inline void getnstimeofday(struct timespec *ts)
44 {
45 	struct timespec64 ts64;
46 
47 	ktime_get_real_ts64(&ts64);
48 	*ts = timespec64_to_timespec(ts64);
49 }
50 
ktime_get_ts(struct timespec * ts)51 static inline void ktime_get_ts(struct timespec *ts)
52 {
53 	struct timespec64 ts64;
54 
55 	ktime_get_ts64(&ts64);
56 	*ts = timespec64_to_timespec(ts64);
57 }
58 
ktime_get_real_ts(struct timespec * ts)59 static inline void ktime_get_real_ts(struct timespec *ts)
60 {
61 	struct timespec64 ts64;
62 
63 	ktime_get_real_ts64(&ts64);
64 	*ts = timespec64_to_timespec(ts64);
65 }
66 
getrawmonotonic(struct timespec * ts)67 static inline void getrawmonotonic(struct timespec *ts)
68 {
69 	struct timespec64 ts64;
70 
71 	ktime_get_raw_ts64(&ts64);
72 	*ts = timespec64_to_timespec(ts64);
73 }
74 
get_monotonic_coarse(void)75 static inline struct timespec get_monotonic_coarse(void)
76 {
77 	struct timespec64 ts64;
78 
79 	ktime_get_coarse_ts64(&ts64);
80 
81 	return timespec64_to_timespec(ts64);
82 }
83 
getboottime(struct timespec * ts)84 static inline void getboottime(struct timespec *ts)
85 {
86 	struct timespec64 ts64;
87 
88 	getboottime64(&ts64);
89 	*ts = timespec64_to_timespec(ts64);
90 }
91 
92 /*
93  * Timespec interfaces utilizing the ktime based ones
94  */
get_monotonic_boottime(struct timespec * ts)95 static inline void get_monotonic_boottime(struct timespec *ts)
96 {
97 	*ts = ktime_to_timespec(ktime_get_boottime());
98 }
99 
timekeeping_clocktai(struct timespec * ts)100 static inline void timekeeping_clocktai(struct timespec *ts)
101 {
102 	*ts = ktime_to_timespec(ktime_get_clocktai());
103 }
104 
105 /*
106  * Persistent clock related interfaces
107  */
108 extern void read_persistent_clock(struct timespec *ts);
109 extern int update_persistent_clock(struct timespec now);
110 
111 #endif
112