]> err.no Git - linux-2.6/blobdiff - lib/div64.c
debugobjects: add timer specific object debugging code
[linux-2.6] / lib / div64.c
index 365719f84832dc7629ecfe6ed55a4070da06e7d1..b71cf93c529adaa3364afa4a1b997c54cc9ef363 100644 (file)
@@ -23,7 +23,7 @@
 /* Not needed on 64bit architectures */
 #if BITS_PER_LONG == 32
 
-uint32_t __div64_32(uint64_t *n, uint32_t base)
+uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
 {
        uint64_t rem = *n;
        uint64_t b = base;
@@ -58,4 +58,24 @@ uint32_t __div64_32(uint64_t *n, uint32_t base)
 
 EXPORT_SYMBOL(__div64_32);
 
+/* 64bit divisor, dividend and result. dynamic precision */
+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;
+}
+EXPORT_SYMBOL(div64_64);
+
 #endif /* BITS_PER_LONG == 32 */