aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-09-12 12:56:53 +0300
committerAvi Kivity <avi@qumranet.com>2007-09-12 13:35:27 +0300
commit45e141aa5520cb2ce4c6d620729733e926f63a01 (patch)
treea72683280e3ff3ce9b6a9072806da02e689a41a8
parentb3167de08a81030e1231354f614ebf762a932faf (diff)
kvm: external module: compatibility for div64_64()kvm-39
-rw-r--r--kvm/kernel/external-module-compat.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/kvm/kernel/external-module-compat.h b/kvm/kernel/external-module-compat.h
index 74bc07249..b1807756d 100644
--- a/kvm/kernel/external-module-compat.h
+++ b/kvm/kernel/external-module-compat.h
@@ -13,6 +13,7 @@
#include <linux/cpu.h>
#include <asm/processor.h>
#include <linux/hrtimer.h>
+#include <asm/bitops.h>
/*
* 2.6.16 does not have GFP_NOWAIT
@@ -368,3 +369,38 @@ static inline void preempt_notifier_sys_exit(void) {}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
#define HRTIMER_MODE_ABS HRTIMER_ABS
#endif
+
+/* div64_64 is fairly new */
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
+
+#ifdef CONFIG_64BIT
+
+static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
+{
+ return dividend / divisor;
+}
+
+#else
+
+/* 64bit divisor, dividend and result. dynamic precision */
+static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
+{
+ uint32_t high, d;
+
+ high = divisor >> 32;
+ if (high) {
+ unsigned int shift = fls(high);
+
+ d = divisor >> shift;
+ dividend >>= shift;
+ } else
+ d = divisor;
+
+ do_div(dividend, d);
+
+ return dividend;
+}
+
+#endif
+
+#endif