summaryrefslogtreecommitdiff
path: root/backport-include/linux/hrtimer.h
blob: cb18567a6581111508078252b42169fae0f5e5fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 */