repository: /home/avi/kvm branch: master commit f8e8a8e1df0bdda7e8ecc1f7e3a54e07d1d0e92a Author: Avi Kivity <[EMAIL PROTECTED]> Date: Wed Sep 12 12:56:53 2007 +0300
kvm: external module: compatibility for div64_64() diff --git a/kernel/external-module-compat.h b/kernel/external-module-compat.h index 74bc072..b180775 100644 --- a/kernel/external-module-compat.h +++ b/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 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ kvm-commits mailing list kvm-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-commits