diff options
Diffstat (limited to 'include/asm-x86/div64.h')
-rw-r--r-- | include/asm-x86/div64.h | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/include/asm-x86/div64.h b/include/asm-x86/div64.h index e98d16e7a37a..0dbf8bf3ef0a 100644 --- a/include/asm-x86/div64.h +++ b/include/asm-x86/div64.h | |||
@@ -17,18 +17,20 @@ | |||
17 | * This ends up being the most efficient "calling | 17 | * This ends up being the most efficient "calling |
18 | * convention" on x86. | 18 | * convention" on x86. |
19 | */ | 19 | */ |
20 | #define do_div(n,base) ({ \ | 20 | #define do_div(n, base) \ |
21 | unsigned long __upper, __low, __high, __mod, __base; \ | 21 | ({ \ |
22 | __base = (base); \ | 22 | unsigned long __upper, __low, __high, __mod, __base; \ |
23 | asm("":"=a" (__low), "=d" (__high):"A" (n)); \ | 23 | __base = (base); \ |
24 | __upper = __high; \ | 24 | asm("":"=a" (__low), "=d" (__high) : "A" (n)); \ |
25 | if (__high) { \ | 25 | __upper = __high; \ |
26 | __upper = __high % (__base); \ | 26 | if (__high) { \ |
27 | __high = __high / (__base); \ | 27 | __upper = __high % (__base); \ |
28 | } \ | 28 | __high = __high / (__base); \ |
29 | asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \ | 29 | } \ |
30 | asm("":"=A" (n):"a" (__low),"d" (__high)); \ | 30 | asm("divl %2":"=a" (__low), "=d" (__mod) \ |
31 | __mod; \ | 31 | : "rm" (__base), "0" (__low), "1" (__upper)); \ |
32 | asm("":"=A" (n) : "a" (__low), "d" (__high)); \ | ||
33 | __mod; \ | ||
32 | }) | 34 | }) |
33 | 35 | ||
34 | /* | 36 | /* |
@@ -37,14 +39,13 @@ | |||
37 | * | 39 | * |
38 | * Warning, this will do an exception if X overflows. | 40 | * Warning, this will do an exception if X overflows. |
39 | */ | 41 | */ |
40 | #define div_long_long_rem(a,b,c) div_ll_X_l_rem(a,b,c) | 42 | #define div_long_long_rem(a, b, c) div_ll_X_l_rem(a, b, c) |
41 | 43 | ||
42 | static inline long | 44 | static inline long div_ll_X_l_rem(long long divs, long div, long *rem) |
43 | div_ll_X_l_rem(long long divs, long div, long *rem) | ||
44 | { | 45 | { |
45 | long dum2; | 46 | long dum2; |
46 | __asm__("divl %2":"=a"(dum2), "=d"(*rem) | 47 | asm("divl %2":"=a"(dum2), "=d"(*rem) |
47 | : "rm"(div), "A"(divs)); | 48 | : "rm"(div), "A"(divs)); |
48 | 49 | ||
49 | return dum2; | 50 | return dum2; |
50 | 51 | ||