Arnd Bergmann | 6546911 | 2017-10-19 13:14:49 +0200 | [diff] [blame] | 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 | |
Arnd Bergmann | 6546911 | 2017-10-19 13:14:49 +0200 | [diff] [blame] | 12 | static inline struct timespec current_kernel_time(void) |
| 13 | { |
Arnd Bergmann | fb7fcc9 | 2018-04-27 15:40:14 +0200 | [diff] [blame] | 14 | struct timespec64 ts64; |
Arnd Bergmann | 6546911 | 2017-10-19 13:14:49 +0200 | [diff] [blame] | 15 | |
Arnd Bergmann | fb7fcc9 | 2018-04-27 15:40:14 +0200 | [diff] [blame] | 16 | ktime_get_coarse_real_ts64(&ts64); |
| 17 | |
| 18 | return timespec64_to_timespec(ts64); |
Arnd Bergmann | 6546911 | 2017-10-19 13:14:49 +0200 | [diff] [blame] | 19 | } |
| 20 | |
Arnd Bergmann | 6546911 | 2017-10-19 13:14:49 +0200 | [diff] [blame] | 21 | /** |
| 22 | * Deprecated. Use do_settimeofday64(). |
| 23 | */ |
| 24 | static inline int do_settimeofday(const struct timespec *ts) |
| 25 | { |
| 26 | struct timespec64 ts64; |
| 27 | |
| 28 | ts64 = timespec_to_timespec64(*ts); |
| 29 | return do_settimeofday64(&ts64); |
| 30 | } |
| 31 | |
Arnd Bergmann | 6546911 | 2017-10-19 13:14:49 +0200 | [diff] [blame] | 32 | static inline void getnstimeofday(struct timespec *ts) |
| 33 | { |
| 34 | struct timespec64 ts64; |
| 35 | |
Arnd Bergmann | edca71f | 2018-04-27 15:40:13 +0200 | [diff] [blame] | 36 | ktime_get_real_ts64(&ts64); |
Arnd Bergmann | 6546911 | 2017-10-19 13:14:49 +0200 | [diff] [blame] | 37 | *ts = timespec64_to_timespec(ts64); |
| 38 | } |
| 39 | |
| 40 | static inline void ktime_get_ts(struct timespec *ts) |
| 41 | { |
| 42 | struct timespec64 ts64; |
| 43 | |
| 44 | ktime_get_ts64(&ts64); |
| 45 | *ts = timespec64_to_timespec(ts64); |
| 46 | } |
| 47 | |
| 48 | static inline void ktime_get_real_ts(struct timespec *ts) |
| 49 | { |
| 50 | struct timespec64 ts64; |
| 51 | |
Arnd Bergmann | edca71f | 2018-04-27 15:40:13 +0200 | [diff] [blame] | 52 | ktime_get_real_ts64(&ts64); |
Arnd Bergmann | 6546911 | 2017-10-19 13:14:49 +0200 | [diff] [blame] | 53 | *ts = timespec64_to_timespec(ts64); |
| 54 | } |
| 55 | |
| 56 | static inline void getrawmonotonic(struct timespec *ts) |
| 57 | { |
| 58 | struct timespec64 ts64; |
| 59 | |
Arnd Bergmann | fb7fcc9 | 2018-04-27 15:40:14 +0200 | [diff] [blame] | 60 | ktime_get_raw_ts64(&ts64); |
Arnd Bergmann | 6546911 | 2017-10-19 13:14:49 +0200 | [diff] [blame] | 61 | *ts = timespec64_to_timespec(ts64); |
| 62 | } |
| 63 | |
| 64 | static inline struct timespec get_monotonic_coarse(void) |
| 65 | { |
Arnd Bergmann | fb7fcc9 | 2018-04-27 15:40:14 +0200 | [diff] [blame] | 66 | struct timespec64 ts64; |
| 67 | |
| 68 | ktime_get_coarse_ts64(&ts64); |
| 69 | |
| 70 | return timespec64_to_timespec(ts64); |
Arnd Bergmann | 6546911 | 2017-10-19 13:14:49 +0200 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | static inline void getboottime(struct timespec *ts) |
| 74 | { |
| 75 | struct timespec64 ts64; |
| 76 | |
| 77 | getboottime64(&ts64); |
| 78 | *ts = timespec64_to_timespec(ts64); |
| 79 | } |
Arnd Bergmann | 6546911 | 2017-10-19 13:14:49 +0200 | [diff] [blame] | 80 | |
| 81 | /* |
| 82 | * Timespec interfaces utilizing the ktime based ones |
| 83 | */ |
| 84 | static inline void get_monotonic_boottime(struct timespec *ts) |
| 85 | { |
| 86 | *ts = ktime_to_timespec(ktime_get_boottime()); |
| 87 | } |
| 88 | |
| 89 | static inline void timekeeping_clocktai(struct timespec *ts) |
| 90 | { |
| 91 | *ts = ktime_to_timespec(ktime_get_clocktai()); |
| 92 | } |
| 93 | |
| 94 | /* |
| 95 | * Persistent clock related interfaces |
| 96 | */ |
| 97 | extern void read_persistent_clock(struct timespec *ts); |
| 98 | extern int update_persistent_clock(struct timespec now); |
| 99 | |
| 100 | #endif |