Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

time: Move old timekeeping interfaces to timekeeping32.h

The interfaces based on 'struct timespec' and 'unsigned long' seconds
are no longer recommended for new code, and we are trying to migrate to
ktime_t based interfaces and other y2038-safe variants.

This moves all the legacy interfaces from linux/timekeeping.h into a
new timekeeping32.h to better document this.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Miroslav Lichvar <mlichvar@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>

authored by

Arnd Bergmann and committed by
John Stultz
6546911e abc8f96e

+154 -135
+1
include/linux/ktime.h
··· 270 270 } 271 271 272 272 # include <linux/timekeeping.h> 273 + # include <linux/timekeeping32.h> 273 274 274 275 #endif
+2 -135
include/linux/timekeeping.h
··· 15 15 /* 16 16 * Get and set timeofday 17 17 */ 18 - extern void do_gettimeofday(struct timeval *tv); 19 18 extern int do_settimeofday64(const struct timespec64 *ts); 20 19 extern int do_sys_settimeofday64(const struct timespec64 *tv, 21 20 const struct timezone *tz); 22 21 /* 23 22 * Kernel time accessors 24 23 */ 25 - unsigned long get_seconds(void); 26 24 struct timespec64 current_kernel_time64(void); 27 - /* does not take xtime_lock */ 28 - struct timespec __current_kernel_time(void); 29 - 30 - static inline struct timespec current_kernel_time(void) 31 - { 32 - struct timespec64 now = current_kernel_time64(); 33 - 34 - return timespec64_to_timespec(now); 35 - } 36 25 37 26 /* 38 - * timespec based interfaces 27 + * timespec64 based interfaces 39 28 */ 40 29 struct timespec64 get_monotonic_coarse64(void); 41 30 extern void getrawmonotonic64(struct timespec64 *ts); ··· 35 46 extern int __getnstimeofday64(struct timespec64 *tv); 36 47 extern void getnstimeofday64(struct timespec64 *tv); 37 48 extern void getboottime64(struct timespec64 *ts); 38 - 39 - #if BITS_PER_LONG == 64 40 - /** 41 - * Deprecated. Use do_settimeofday64(). 42 - */ 43 - static inline int do_settimeofday(const struct timespec *ts) 44 - { 45 - return do_settimeofday64(ts); 46 - } 47 - 48 - static inline int __getnstimeofday(struct timespec *ts) 49 - { 50 - return __getnstimeofday64(ts); 51 - } 52 - 53 - static inline void getnstimeofday(struct timespec *ts) 54 - { 55 - getnstimeofday64(ts); 56 - } 57 - 58 - static inline void ktime_get_ts(struct timespec *ts) 59 - { 60 - ktime_get_ts64(ts); 61 - } 62 - 63 - static inline void ktime_get_real_ts(struct timespec *ts) 64 - { 65 - getnstimeofday64(ts); 66 - } 67 - 68 - static inline void getrawmonotonic(struct timespec *ts) 69 - { 70 - getrawmonotonic64(ts); 71 - } 72 - 73 - static inline struct timespec get_monotonic_coarse(void) 74 - { 75 - return get_monotonic_coarse64(); 76 - } 77 - 78 - static inline void getboottime(struct timespec *ts) 79 - { 80 - return getboottime64(ts); 81 - } 82 - #else 83 - /** 84 - * Deprecated. Use do_settimeofday64(). 85 - */ 86 - static inline int do_settimeofday(const struct timespec *ts) 87 - { 88 - struct timespec64 ts64; 89 - 90 - ts64 = timespec_to_timespec64(*ts); 91 - return do_settimeofday64(&ts64); 92 - } 93 - 94 - static inline int __getnstimeofday(struct timespec *ts) 95 - { 96 - struct timespec64 ts64; 97 - int ret = __getnstimeofday64(&ts64); 98 - 99 - *ts = timespec64_to_timespec(ts64); 100 - return ret; 101 - } 102 - 103 - static inline void getnstimeofday(struct timespec *ts) 104 - { 105 - struct timespec64 ts64; 106 - 107 - getnstimeofday64(&ts64); 108 - *ts = timespec64_to_timespec(ts64); 109 - } 110 - 111 - static inline void ktime_get_ts(struct timespec *ts) 112 - { 113 - struct timespec64 ts64; 114 - 115 - ktime_get_ts64(&ts64); 116 - *ts = timespec64_to_timespec(ts64); 117 - } 118 - 119 - static inline void ktime_get_real_ts(struct timespec *ts) 120 - { 121 - struct timespec64 ts64; 122 - 123 - getnstimeofday64(&ts64); 124 - *ts = timespec64_to_timespec(ts64); 125 - } 126 - 127 - static inline void getrawmonotonic(struct timespec *ts) 128 - { 129 - struct timespec64 ts64; 130 - 131 - getrawmonotonic64(&ts64); 132 - *ts = timespec64_to_timespec(ts64); 133 - } 134 - 135 - static inline struct timespec get_monotonic_coarse(void) 136 - { 137 - return timespec64_to_timespec(get_monotonic_coarse64()); 138 - } 139 - 140 - static inline void getboottime(struct timespec *ts) 141 - { 142 - struct timespec64 ts64; 143 - 144 - getboottime64(&ts64); 145 - *ts = timespec64_to_timespec(ts64); 146 - } 147 - #endif 148 49 149 50 #define ktime_get_real_ts64(ts) getnstimeofday64(ts) 150 51 ··· 120 241 extern u64 ktime_get_boot_fast_ns(void); 121 242 122 243 /* 123 - * Timespec interfaces utilizing the ktime based ones 244 + * timespec64 interfaces utilizing the ktime based ones 124 245 */ 125 - static inline void get_monotonic_boottime(struct timespec *ts) 126 - { 127 - *ts = ktime_to_timespec(ktime_get_boottime()); 128 - } 129 - 130 246 static inline void get_monotonic_boottime64(struct timespec64 *ts) 131 247 { 132 248 *ts = ktime_to_timespec64(ktime_get_boottime()); 133 - } 134 - 135 - static inline void timekeeping_clocktai(struct timespec *ts) 136 - { 137 - *ts = ktime_to_timespec(ktime_get_clocktai()); 138 249 } 139 250 140 251 static inline void timekeeping_clocktai64(struct timespec64 *ts) ··· 209 340 */ 210 341 extern int persistent_clock_is_local; 211 342 212 - extern void read_persistent_clock(struct timespec *ts); 213 343 extern void read_persistent_clock64(struct timespec64 *ts); 214 344 extern void read_boot_clock64(struct timespec64 *ts); 215 - extern int update_persistent_clock(struct timespec now); 216 345 extern int update_persistent_clock64(struct timespec64 now); 217 346 218 347
+151
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 + /* does not take xtime_lock */ 13 + struct timespec __current_kernel_time(void); 14 + 15 + static inline struct timespec current_kernel_time(void) 16 + { 17 + struct timespec64 now = current_kernel_time64(); 18 + 19 + return timespec64_to_timespec(now); 20 + } 21 + 22 + #if BITS_PER_LONG == 64 23 + /** 24 + * Deprecated. Use do_settimeofday64(). 25 + */ 26 + static inline int do_settimeofday(const struct timespec *ts) 27 + { 28 + return do_settimeofday64(ts); 29 + } 30 + 31 + static inline int __getnstimeofday(struct timespec *ts) 32 + { 33 + return __getnstimeofday64(ts); 34 + } 35 + 36 + static inline void getnstimeofday(struct timespec *ts) 37 + { 38 + getnstimeofday64(ts); 39 + } 40 + 41 + static inline void ktime_get_ts(struct timespec *ts) 42 + { 43 + ktime_get_ts64(ts); 44 + } 45 + 46 + static inline void ktime_get_real_ts(struct timespec *ts) 47 + { 48 + getnstimeofday64(ts); 49 + } 50 + 51 + static inline void getrawmonotonic(struct timespec *ts) 52 + { 53 + getrawmonotonic64(ts); 54 + } 55 + 56 + static inline struct timespec get_monotonic_coarse(void) 57 + { 58 + return get_monotonic_coarse64(); 59 + } 60 + 61 + static inline void getboottime(struct timespec *ts) 62 + { 63 + return getboottime64(ts); 64 + } 65 + #else 66 + /** 67 + * Deprecated. Use do_settimeofday64(). 68 + */ 69 + static inline int do_settimeofday(const struct timespec *ts) 70 + { 71 + struct timespec64 ts64; 72 + 73 + ts64 = timespec_to_timespec64(*ts); 74 + return do_settimeofday64(&ts64); 75 + } 76 + 77 + static inline int __getnstimeofday(struct timespec *ts) 78 + { 79 + struct timespec64 ts64; 80 + int ret = __getnstimeofday64(&ts64); 81 + 82 + *ts = timespec64_to_timespec(ts64); 83 + return ret; 84 + } 85 + 86 + static inline void getnstimeofday(struct timespec *ts) 87 + { 88 + struct timespec64 ts64; 89 + 90 + getnstimeofday64(&ts64); 91 + *ts = timespec64_to_timespec(ts64); 92 + } 93 + 94 + static inline void ktime_get_ts(struct timespec *ts) 95 + { 96 + struct timespec64 ts64; 97 + 98 + ktime_get_ts64(&ts64); 99 + *ts = timespec64_to_timespec(ts64); 100 + } 101 + 102 + static inline void ktime_get_real_ts(struct timespec *ts) 103 + { 104 + struct timespec64 ts64; 105 + 106 + getnstimeofday64(&ts64); 107 + *ts = timespec64_to_timespec(ts64); 108 + } 109 + 110 + static inline void getrawmonotonic(struct timespec *ts) 111 + { 112 + struct timespec64 ts64; 113 + 114 + getrawmonotonic64(&ts64); 115 + *ts = timespec64_to_timespec(ts64); 116 + } 117 + 118 + static inline struct timespec get_monotonic_coarse(void) 119 + { 120 + return timespec64_to_timespec(get_monotonic_coarse64()); 121 + } 122 + 123 + static inline void getboottime(struct timespec *ts) 124 + { 125 + struct timespec64 ts64; 126 + 127 + getboottime64(&ts64); 128 + *ts = timespec64_to_timespec(ts64); 129 + } 130 + #endif 131 + 132 + /* 133 + * Timespec interfaces utilizing the ktime based ones 134 + */ 135 + static inline void get_monotonic_boottime(struct timespec *ts) 136 + { 137 + *ts = ktime_to_timespec(ktime_get_boottime()); 138 + } 139 + 140 + static inline void timekeeping_clocktai(struct timespec *ts) 141 + { 142 + *ts = ktime_to_timespec(ktime_get_clocktai()); 143 + } 144 + 145 + /* 146 + * Persistent clock related interfaces 147 + */ 148 + extern void read_persistent_clock(struct timespec *ts); 149 + extern int update_persistent_clock(struct timespec now); 150 + 151 + #endif