diff options
Diffstat (limited to 'backport-include/linux/hrtimer.h')
-rw-r--r-- | backport-include/linux/hrtimer.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/backport-include/linux/hrtimer.h b/backport-include/linux/hrtimer.h new file mode 100644 index 0000000..cb18567 --- /dev/null +++ b/backport-include/linux/hrtimer.h @@ -0,0 +1,30 @@ +#ifndef __BACKPORT_LINUX_HRTIMER_H +#define __BACKPORT_LINUX_HRTIMER_H +#include_next <linux/hrtimer.h> + +#if LINUX_VERSION_IS_LESS(3,17,0) +#if LINUX_VERSION_IS_LESS(3,3,0) +inline u64 bp_ktime_divns(const ktime_t kt, s64 div) +{ + u64 dclc; + int sft = 0; + + dclc = ktime_to_ns(kt); + /* Make sure the divisor is less than 2^32: */ + while (div >> 32) { + sft++; + div >>= 1; + } + dclc >>= sft; + do_div(dclc, (unsigned long) div); + + return dclc; +} +#define ktime_get_boottime_seconds() bp_ktime_divns(ktime_get_boottime(), NSEC_PER_SEC) +#else +u64 bp_ktime_divns(const ktime_t kt, s64 div); +#define ktime_divns bp_ktime_divns +#endif +#endif /* < 3.17 */ + +#endif /* __BACKPORT_LINUX_HRTIMER_H */ |