patch-2.4.21 linux-2.4.21/include/asm-ppc/div64.h
Next file: linux-2.4.21/include/asm-ppc/dma.h
Previous file: linux-2.4.21/include/asm-ppc/delay.h
Back to the patch index
Back to the overall index
- Lines: 32
- Date:
2003-06-13 07:51:38.000000000 -0700
- Orig file:
linux-2.4.20/include/asm-ppc/div64.h
- Orig date:
2001-05-21 15:02:06.000000000 -0700
diff -urN linux-2.4.20/include/asm-ppc/div64.h linux-2.4.21/include/asm-ppc/div64.h
@@ -1,13 +1,23 @@
-/*
- * BK Id: SCCS/s.div64.h 1.5 05/17/01 18:14:24 cort
- */
#ifndef __PPC_DIV64
#define __PPC_DIV64
-#define do_div(n,base) ({ \
-int __res; \
-__res = ((unsigned long) n) % (unsigned) base; \
-n = ((unsigned long) n) / (unsigned) base; \
-__res; })
+#include <linux/types.h>
+
+extern u32 __div64_32(u64 *dividend, u32 div);
+
+#define do_div(n, div) ({ \
+ u64 __n = (n); \
+ u32 __d = (div); \
+ u32 __q, __r; \
+ if ((__n >> 32) == 0) { \
+ __q = (u32)__n / __d; \
+ __r = (u32)__n - __q * __d; \
+ (n) = __q; \
+ } else { \
+ __r = __div64_32(&__n, __d); \
+ (n) = __n; \
+ } \
+ __r; \
+})
#endif
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)