Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.6.26-rc1 /lib/div64.c

Filename:/lib/div64.c
Lines Added:27
Lines Deleted:8
Also changed in: (Previous) 2.6.25-git20  2.6.25-git19  2.6.25-git18  2.6.22  2.6.22-rc7  2.6.22-rc6 
(Following) 2.6.26-rc2  2.6.26-rc3  2.6.26-rc4  2.6.26-rc5  2.6.26-rc5-git7  2.6.26-rc6 

Location
[  2.6.26-rc1
  [  lib
     o  div64.c

Patch

diff --git a/lib/div64.c b/lib/div64.c
index b71cf93..bb5bd0c 100644
--- a/lib/div64.c
+++ b/lib/div64.c
@@ -16,9 +16,8 @@
  * assembly versions such as arch/ppc/lib/div64.S and arch/sh/lib/div64.S.
  */
 
-#include <linux/types.h>
 #include <linux/module.h>
-#include <asm/div64.h>
+#include <linux/math64.h>
 
 /* Not needed on 64bit architectures */
 #if BITS_PER_LONG == 32
@@ -58,10 +57,31 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
 
 EXPORT_SYMBOL(__div64_32);
 
+#ifndef div_s64_rem
+s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
+{
+   u64 quotient;
+
+   if (dividend < 0) {
+      quotient = div_u64_rem(-dividend, abs(divisor), (u32 *)remainder);
+      *remainder = -*remainder;
+      if (divisor > 0)
+         quotient = -quotient;
+   } else {
+      quotient = div_u64_rem(dividend, abs(divisor), (u32 *)remainder);
+      if (divisor < 0)
+         quotient = -quotient;
+   }
+   return quotient;
+}
+EXPORT_SYMBOL(div_s64_rem);
+#endif
+
 /* 64bit divisor, dividend and result. dynamic precision */
-uint64_t div64_64(uint64_t dividend, uint64_t divisor)
+#ifndef div64_u64
+u64 div64_u64(u64 dividend, u64 divisor)
 {
-   uint32_t high, d;
+   u32 high, d;
 
    high = divisor >> 32;
    if (high) {
@@ -72,10 +92,9 @@ uint64_t div64_64(uint64_t dividend, uint64_t divisor)
    } else
       d = divisor;
 
-   do_div(dividend, d);
-
-   return dividend;
+   return div_u64(dividend, d);
 }
-EXPORT_SYMBOL(div64_64);
+EXPORT_SYMBOL(div64_u64);
+#endif
 
 #endif /* BITS_PER_LONG == 32 */


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.