patch-2.4.23 linux-2.4.23/include/asm-sh/div64.h
Next file: linux-2.4.23/include/asm-sh/elf.h
Previous file: linux-2.4.23/include/asm-sh/delay.h
Back to the patch index
Back to the overall index
- Lines: 24
- Date:
2003-11-28 10:26:21.000000000 -0800
- Orig file:
linux-2.4.22/include/asm-sh/div64.h
- Orig date:
2000-03-05 09:33:55.000000000 -0800
diff -urN linux-2.4.22/include/asm-sh/div64.h linux-2.4.23/include/asm-sh/div64.h
@@ -1,10 +1,20 @@
#ifndef __ASM_SH_DIV64
#define __ASM_SH_DIV64
+extern u64 __xdiv64_32(u64 n, u32 d);
+
#define do_div(n,base) ({ \
-int __res; \
-__res = ((unsigned long) n) % (unsigned) base; \
-n = ((unsigned long) n) / (unsigned) base; \
+u64 __n = (n), __q; \
+u32 __base = (base); \
+u32 __res; \
+if ((__n >> 32) == 0) { \
+ __res = ((unsigned long) __n) % (unsigned) __base; \
+ (n) = ((unsigned long) __n) / (unsigned) __base; \
+} else { \
+ __q = __xdiv64_32(__n, __base); \
+ __res = __n - __q * __base; \
+ (n) = __q; \
+} \
__res; })
#endif /* __ASM_SH_DIV64 */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)