diff options
author | Baolin Wang <baolin.wang@linaro.org> | 2015-07-29 08:09:43 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2015-08-17 14:25:35 -0400 |
commit | 8758a240e2d74c5932ab51a73377e6507b7fd441 (patch) | |
tree | f430066a32f00ee1c4e434e51936067e80e618c3 | |
parent | 19a46fe57a005a884ccb38419071f772ac2fca2b (diff) |
time: Introduce current_kernel_time64()
The current_kernel_time() is not year 2038 safe on 32bit systems
since it returns a timespec value. Introduce current_kernel_time64()
which returns a timespec64 value.
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r-- | include/linux/timekeeping.h | 9 | ||||
-rw-r--r-- | kernel/time/timekeeping.c | 6 |
2 files changed, 11 insertions, 4 deletions
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 3aa72e648650..657ea03fff40 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h | |||
@@ -18,10 +18,17 @@ extern int do_sys_settimeofday(const struct timespec *tv, | |||
18 | * Kernel time accessors | 18 | * Kernel time accessors |
19 | */ | 19 | */ |
20 | unsigned long get_seconds(void); | 20 | unsigned long get_seconds(void); |
21 | struct timespec current_kernel_time(void); | 21 | struct timespec64 current_kernel_time64(void); |
22 | /* does not take xtime_lock */ | 22 | /* does not take xtime_lock */ |
23 | struct timespec __current_kernel_time(void); | 23 | struct timespec __current_kernel_time(void); |
24 | 24 | ||
25 | static inline struct timespec current_kernel_time(void) | ||
26 | { | ||
27 | struct timespec64 now = current_kernel_time64(); | ||
28 | |||
29 | return timespec64_to_timespec(now); | ||
30 | } | ||
31 | |||
25 | /* | 32 | /* |
26 | * timespec based interfaces | 33 | * timespec based interfaces |
27 | */ | 34 | */ |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 4cdb771913c8..f6ee2e6b6f5d 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -1881,7 +1881,7 @@ struct timespec __current_kernel_time(void) | |||
1881 | return timespec64_to_timespec(tk_xtime(tk)); | 1881 | return timespec64_to_timespec(tk_xtime(tk)); |
1882 | } | 1882 | } |
1883 | 1883 | ||
1884 | struct timespec current_kernel_time(void) | 1884 | struct timespec64 current_kernel_time64(void) |
1885 | { | 1885 | { |
1886 | struct timekeeper *tk = &tk_core.timekeeper; | 1886 | struct timekeeper *tk = &tk_core.timekeeper; |
1887 | struct timespec64 now; | 1887 | struct timespec64 now; |
@@ -1893,9 +1893,9 @@ struct timespec current_kernel_time(void) | |||
1893 | now = tk_xtime(tk); | 1893 | now = tk_xtime(tk); |
1894 | } while (read_seqcount_retry(&tk_core.seq, seq)); | 1894 | } while (read_seqcount_retry(&tk_core.seq, seq)); |
1895 | 1895 | ||
1896 | return timespec64_to_timespec(now); | 1896 | return now; |
1897 | } | 1897 | } |
1898 | EXPORT_SYMBOL(current_kernel_time); | 1898 | EXPORT_SYMBOL(current_kernel_time64); |
1899 | 1899 | ||
1900 | struct timespec64 get_monotonic_coarse64(void) | 1900 | struct timespec64 get_monotonic_coarse64(void) |
1901 | { | 1901 | { |