make oldconfig will rebuild these...
[linux-2.4.21-pre4.git] / include / asm-mips64 / div64.h
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  */
6 #ifndef _ASM_DIV64_H
7 #define _ASM_DIV64_H
8
9 /*
10  * Don't use this one in new code
11  */
12 #define do_div64_32(res, high, low, base) ({ \
13         unsigned long __quot, __mod; \
14         unsigned long __cf, __tmp, __tmp2, __i; \
15         \
16         __asm__(".set   push\n\t" \
17                 ".set   noat\n\t" \
18                 ".set   noreorder\n\t" \
19                 "move   %2, $0\n\t" \
20                 "move   %3, $0\n\t" \
21                 "b      1f\n\t" \
22                 " li    %4, 0x21\n" \
23                 "0:\n\t" \
24                 "sll    $1, %0, 0x1\n\t" \
25                 "srl    %3, %0, 0x1f\n\t" \
26                 "or     %0, $1, %5\n\t" \
27                 "sll    %1, %1, 0x1\n\t" \
28                 "sll    %2, %2, 0x1\n" \
29                 "1:\n\t" \
30                 "bnez   %3, 2f\n\t" \
31                 "sltu   %5, %0, %z6\n\t" \
32                 "bnez   %5, 3f\n\t" \
33                 "2:\n\t" \
34                 " addiu %4,%4,-1\n\t" \
35                 "subu   %0, %0, %z6\n\t" \
36                 "addiu  %2, %2, 1\n" \
37                 "3:\n\t" \
38                 "bnez   %4, 0b\n\t" \
39                 " srl   %5, %1, 0x1f\n\t" \
40                 ".set   pop" \
41                 : "=&r" (__mod), "=&r" (__tmp), "=&r" (__quot), "=&r" (__cf), \
42                   "=&r" (__i), "=&r" (__tmp2) \
43                 : "Jr" (base), "0" (high), "1" (low)); \
44         \
45         (res) = __quot; \
46         __mod; })
47
48 /*
49  * Hey, we're already 64-bit, no
50  * need to play games..
51  */
52 #define do_div(n,base) ({ \
53         int __res; \
54         __res = ((unsigned long) n) % (unsigned) base; \
55         n = ((unsigned long) n) / (unsigned) base; \
56         __res; })
57
58 #endif /* _ASM_DIV64_H */