summaryrefslogtreecommitdiff
path: root/include/linux/jiffies.h
diff options
context:
space:
mode:
authorBaolin Wang <baolin.wang@linaro.org>2015-07-29 15:18:31 +0300
committerJohn Stultz <john.stultz@linaro.org>2015-08-17 21:25:41 +0300
commit9ca308506062fc4a4ee8ca7ad2f71033c831c2fb (patch)
treeb2d7d5d5dabaef01962504d8c1a1027efbbaf1b8 /include/linux/jiffies.h
parent8758a240e2d74c5932ab51a73377e6507b7fd441 (diff)
downloadlinux-9ca308506062fc4a4ee8ca7ad2f71033c831c2fb.tar.xz
time: Introduce timespec64_to_jiffies()/jiffies_to_timespec64()
The conversion between struct timespec and jiffies is not year 2038 safe on 32bit systems. Introduce timespec64_to_jiffies() and jiffies_to_timespec64() functions which use struct timespec64 to make it ready for 2038 issue. 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>
Diffstat (limited to 'include/linux/jiffies.h')
-rw-r--r--include/linux/jiffies.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index 535fd3bb1ba8..bf96d9f27bd0 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -416,9 +416,25 @@ static inline unsigned long usecs_to_jiffies(const unsigned int u)
}
}
-extern unsigned long timespec_to_jiffies(const struct timespec *value);
-extern void jiffies_to_timespec(const unsigned long jiffies,
- struct timespec *value);
+extern unsigned long timespec64_to_jiffies(const struct timespec64 *value);
+extern void jiffies_to_timespec64(const unsigned long jiffies,
+ struct timespec64 *value);
+static inline unsigned long timespec_to_jiffies(const struct timespec *value)
+{
+ struct timespec64 ts = timespec_to_timespec64(*value);
+
+ return timespec64_to_jiffies(&ts);
+}
+
+static inline void jiffies_to_timespec(const unsigned long jiffies,
+ struct timespec *value)
+{
+ struct timespec64 ts;
+
+ jiffies_to_timespec64(jiffies, &ts);
+ *value = timespec64_to_timespec(ts);
+}
+
extern unsigned long timeval_to_jiffies(const struct timeval *value);
extern void jiffies_to_timeval(const unsigned long jiffies,
struct timeval *value);