Merge tag 'mlx5-updates-2018-05-17' of git://git.kernel.org/pub/scm/linux/kernel...
[sfrench/cifs-2.6.git] / include / linux / timekeeping32.h
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
9 extern void do_gettimeofday(struct timeval *tv);
10 unsigned long get_seconds(void);
11
12 static inline struct timespec current_kernel_time(void)
13 {
14         struct timespec64 now = current_kernel_time64();
15
16         return timespec64_to_timespec(now);
17 }
18
19 #if BITS_PER_LONG == 64
20 /**
21  * Deprecated. Use do_settimeofday64().
22  */
23 static inline int do_settimeofday(const struct timespec *ts)
24 {
25         return do_settimeofday64(ts);
26 }
27
28 static inline int __getnstimeofday(struct timespec *ts)
29 {
30         return __getnstimeofday64(ts);
31 }
32
33 static inline void getnstimeofday(struct timespec *ts)
34 {
35         getnstimeofday64(ts);
36 }
37
38 static inline void ktime_get_ts(struct timespec *ts)
39 {
40         ktime_get_ts64(ts);
41 }
42
43 static inline void ktime_get_real_ts(struct timespec *ts)
44 {
45         getnstimeofday64(ts);
46 }
47
48 static inline void getrawmonotonic(struct timespec *ts)
49 {
50         getrawmonotonic64(ts);
51 }
52
53 static inline struct timespec get_monotonic_coarse(void)
54 {
55         return get_monotonic_coarse64();
56 }
57
58 static inline void getboottime(struct timespec *ts)
59 {
60         return getboottime64(ts);
61 }
62 #else
63 /**
64  * Deprecated. Use do_settimeofday64().
65  */
66 static inline int do_settimeofday(const struct timespec *ts)
67 {
68         struct timespec64 ts64;
69
70         ts64 = timespec_to_timespec64(*ts);
71         return do_settimeofday64(&ts64);
72 }
73
74 static inline int __getnstimeofday(struct timespec *ts)
75 {
76         struct timespec64 ts64;
77         int ret = __getnstimeofday64(&ts64);
78
79         *ts = timespec64_to_timespec(ts64);
80         return ret;
81 }
82
83 static inline void getnstimeofday(struct timespec *ts)
84 {
85         struct timespec64 ts64;
86
87         getnstimeofday64(&ts64);
88         *ts = timespec64_to_timespec(ts64);
89 }
90
91 static inline void ktime_get_ts(struct timespec *ts)
92 {
93         struct timespec64 ts64;
94
95         ktime_get_ts64(&ts64);
96         *ts = timespec64_to_timespec(ts64);
97 }
98
99 static inline void ktime_get_real_ts(struct timespec *ts)
100 {
101         struct timespec64 ts64;
102
103         getnstimeofday64(&ts64);
104         *ts = timespec64_to_timespec(ts64);
105 }
106
107 static inline void getrawmonotonic(struct timespec *ts)
108 {
109         struct timespec64 ts64;
110
111         getrawmonotonic64(&ts64);
112         *ts = timespec64_to_timespec(ts64);
113 }
114
115 static inline struct timespec get_monotonic_coarse(void)
116 {
117         return timespec64_to_timespec(get_monotonic_coarse64());
118 }
119
120 static inline void getboottime(struct timespec *ts)
121 {
122         struct timespec64 ts64;
123
124         getboottime64(&ts64);
125         *ts = timespec64_to_timespec(ts64);
126 }
127 #endif
128
129 /*
130  * Timespec interfaces utilizing the ktime based ones
131  */
132 static inline void get_monotonic_boottime(struct timespec *ts)
133 {
134         *ts = ktime_to_timespec(ktime_get_boottime());
135 }
136
137 static inline void timekeeping_clocktai(struct timespec *ts)
138 {
139         *ts = ktime_to_timespec(ktime_get_clocktai());
140 }
141
142 /*
143  * Persistent clock related interfaces
144  */
145 extern void read_persistent_clock(struct timespec *ts);
146 extern int update_persistent_clock(struct timespec now);
147
148 #endif