2 * Copyright (C) 2000, 2004 Maciej W. Rozycki
3 * Copyright (C) 2003, 07 Ralf Baechle (ralf@linux-mips.org)
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
12 #include <asm-generic/div64.h>
14 #if BITS_PER_LONG == 64
16 #include <linux/types.h>
19 * No traps on overflows for any of these...
22 #define __div64_32(n, base) \
24 unsigned long __cf, __tmp, __tmp2, __i; \
25 unsigned long __quot32, __mod32; \
26 unsigned long __high, __low; \
27 unsigned long long __n; \
29 __high = *__n >> 32; \
34 " .set noreorder \n" \
40 " sll $1, %0, 0x1 \n" \
41 " srl %3, %0, 0x1f \n" \
43 " sll %1, %1, 0x1 \n" \
44 " sll %2, %2, 0x1 \n" \
47 " sltu %5, %0, %z6 \n" \
50 " addiu %4, %4, -1 \n" \
51 " subu %0, %0, %z6 \n" \
52 " addiu %2, %2, 1 \n" \
55 " srl %5, %1, 0x1f\n\t" \
57 : "=&r" (__mod32), "=&r" (__tmp), \
58 "=&r" (__quot32), "=&r" (__cf), \
59 "=&r" (__i), "=&r" (__tmp2) \
60 : "Jr" (base), "0" (__high), "1" (__low)); \
66 #endif /* BITS_PER_LONG == 64 */
68 #endif /* __ASM_DIV64_H */