1 From: Ralf Baechle <ralf@linux-mips.org>
2 Date: Thu, 30 Apr 2009 16:14:56 +0000 (+0200)
3 Subject: MIPS: Rewrite <asm/div64.h> to work with gcc 4.4.0.
4 X-Git-Url: http://www.linux-mips.org/git?p=linux.git;a=commitdiff_plain;h=a1b68289997030df64cba8478d5767fe10e42a58
6 MIPS: Rewrite <asm/div64.h> to work with gcc 4.4.0.
8 The inline assembler used on 32-bit kernels was using the "h" constraint
9 which was considered dangerous and removed for gcc 4.4.0.
11 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
14 diff --git a/arch/mips/include/asm/div64.h b/arch/mips/include/asm/div64.h
15 index d1d6991..dc5ea57 100644
16 --- a/arch/mips/include/asm/div64.h
17 +++ b/arch/mips/include/asm/div64.h
19 * License. See the file "COPYING" in the main directory of this archive
24 +#ifndef __ASM_DIV64_H
25 +#define __ASM_DIV64_H
27 -#include <linux/types.h>
28 +#include <asm-generic/div64.h>
30 -#if (_MIPS_SZLONG == 32)
31 +#if BITS_PER_LONG == 64
33 -#include <asm/compiler.h>
34 +#include <linux/types.h>
37 * No traps on overflows for any of these...
40 -#define do_div64_32(res, high, low, base) ({ \
41 - unsigned long __quot32, __mod32; \
42 - unsigned long __cf, __tmp, __tmp2, __i; \
44 - __asm__(".set push\n\t" \
46 - ".set noreorder\n\t" \
52 - "sll $1, %0, 0x1\n\t" \
53 - "srl %3, %0, 0x1f\n\t" \
54 - "or %0, $1, %5\n\t" \
55 - "sll %1, %1, 0x1\n\t" \
56 - "sll %2, %2, 0x1\n" \
59 - " sltu %5, %0, %z6\n\t" \
62 - " addiu %4, %4, -1\n\t" \
63 - "subu %0, %0, %z6\n\t" \
64 - "addiu %2, %2, 1\n" \
67 - " srl %5, %1, 0x1f\n\t" \
69 - : "=&r" (__mod32), "=&r" (__tmp), \
70 - "=&r" (__quot32), "=&r" (__cf), \
71 - "=&r" (__i), "=&r" (__tmp2) \
72 - : "Jr" (base), "0" (high), "1" (low)); \
77 -#define do_div(n, base) ({ \
78 - unsigned long long __quot; \
79 - unsigned long __mod; \
80 - unsigned long long __div; \
81 - unsigned long __upper, __low, __high, __base; \
86 - __high = __div >> 32; \
91 - __asm__("divu $0, %z2, %z3" \
92 - : "=h" (__upper), "=l" (__high) \
93 - : "Jr" (__high), "Jr" (__base) \
96 - __mod = do_div64_32(__low, __upper, __low, __base); \
99 - __quot = __quot << 32 | __low; \
103 -#endif /* (_MIPS_SZLONG == 32) */
105 -#if (_MIPS_SZLONG == 64)
108 - * Hey, we're already 64-bit, no
109 - * need to play games..
111 -#define do_div(n, base) ({ \
112 - unsigned long __quot; \
113 - unsigned int __mod; \
114 - unsigned long __div; \
115 - unsigned int __base; \
120 - __mod = __div % __base; \
121 - __quot = __div / __base; \
125 +#define __div64_32(n, base) \
127 + unsigned long __cf, __tmp, __tmp2, __i; \
128 + unsigned long __quot32, __mod32; \
129 + unsigned long __high, __low; \
130 + unsigned long long __n; \
132 + __high = *__n >> 32; \
137 + " .set noreorder \n" \
138 + " move %2, $0 \n" \
139 + " move %3, $0 \n" \
141 + " li %4, 0x21 \n" \
143 + " sll $1, %0, 0x1 \n" \
144 + " srl %3, %0, 0x1f \n" \
145 + " or %0, $1, %5 \n" \
146 + " sll %1, %1, 0x1 \n" \
147 + " sll %2, %2, 0x1 \n" \
149 + " bnez %3, 2f \n" \
150 + " sltu %5, %0, %z6 \n" \
151 + " bnez %5, 3f \n" \
153 + " addiu %4, %4, -1 \n" \
154 + " subu %0, %0, %z6 \n" \
155 + " addiu %2, %2, 1 \n" \
157 + " bnez %4, 0b\n\t" \
158 + " srl %5, %1, 0x1f\n\t" \
160 + : "=&r" (__mod32), "=&r" (__tmp), \
161 + "=&r" (__quot32), "=&r" (__cf), \
162 + "=&r" (__i), "=&r" (__tmp2) \
163 + : "Jr" (base), "0" (__high), "1" (__low)); \
165 + (__n) = __quot32; \
169 -#endif /* (_MIPS_SZLONG == 64) */
170 +#endif /* BITS_PER_LONG == 64 */
172 -#endif /* _ASM_DIV64_H */
173 +#endif /* __ASM_DIV64_H */