summaryrefslogtreecommitdiff
path: root/include/linux/ktime.h
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2015-01-24 10:11:12 +0100
committerThomas Gleixner <tglx@linutronix.de>2015-01-24 10:11:12 +0100
commitfe31fca35d6af9176eec0024fac2ceeaacbc8639 (patch)
tree8a08632cb92784bb8ca6ffab0a5ecca65ebbd8e9 /include/linux/ktime.h
parent9bc7491906b4113b4c5ae442157c7dfc4e10cd14 (diff)
parent9a4a445e30f0b601ca2d9433274047cbf48ebf9e (diff)
Merge tag 'fortglx-3.20-time' of https://git.linaro.org/people/john.stultz/linux into timers/core
Pull time updates from John Stultz for 3.20: * ktime division optimization * Expose a few more y2038-safe timekeeping interfaces * RTC core changes to address y2038
Diffstat (limited to 'include/linux/ktime.h')
-rw-r--r--include/linux/ktime.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 891ea92a68b0..5fc3d1083071 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -166,7 +166,17 @@ static inline bool ktime_before(const ktime_t cmp1, const ktime_t cmp2)
}
#if BITS_PER_LONG < 64
-extern u64 ktime_divns(const ktime_t kt, s64 div);
+extern u64 __ktime_divns(const ktime_t kt, s64 div);
+static inline u64 ktime_divns(const ktime_t kt, s64 div)
+{
+ if (__builtin_constant_p(div) && !(div >> 32)) {
+ u64 ns = kt.tv64;
+ do_div(ns, div);
+ return ns;
+ } else {
+ return __ktime_divns(kt, div);
+ }
+}
#else /* BITS_PER_LONG < 64 */
# define ktime_divns(kt, div) (u64)((kt).tv64 / (div))
#endif