Rev 1870 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1870 | Rev 3031 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | #define _ASM_X86_DIV64_H |
2 | #define _ASM_X86_DIV64_H |
Line 3... | Line 3... | ||
3 | 3 | ||
Line 4... | Line 4... | ||
4 | #ifdef CONFIG_X86_32 |
4 | #ifdef CONFIG_X86_32 |
- | 5 | ||
Line 5... | Line 6... | ||
5 | 6 | #include |
|
6 | #include |
7 | #include |
7 | 8 | ||
8 | /* |
9 | /* |
Line 19... | Line 20... | ||
19 | */ |
20 | */ |
20 | #define do_div(n, base) \ |
21 | #define do_div(n, base) \ |
21 | ({ \ |
22 | ({ \ |
22 | unsigned long __upper, __low, __high, __mod, __base; \ |
23 | unsigned long __upper, __low, __high, __mod, __base; \ |
23 | __base = (base); \ |
24 | __base = (base); \ |
- | 25 | if (__builtin_constant_p(__base) && is_power_of_2(__base)) { \ |
|
- | 26 | __mod = n & (__base - 1); \ |
|
- | 27 | n >>= ilog2(__base); \ |
|
- | 28 | } else { \ |
|
24 | asm("":"=a" (__low), "=d" (__high) : "A" (n)); \ |
29 | asm("" : "=a" (__low), "=d" (__high) : "A" (n));\ |
25 | __upper = __high; \ |
30 | __upper = __high; \ |
26 | if (__high) { \ |
31 | if (__high) { \ |
27 | __upper = __high % (__base); \ |
32 | __upper = __high % (__base); \ |
28 | __high = __high / (__base); \ |
33 | __high = __high / (__base); \ |
29 | } \ |
34 | } \ |
30 | asm("divl %2":"=a" (__low), "=d" (__mod) \ |
35 | asm("divl %2" : "=a" (__low), "=d" (__mod) \ |
31 | : "rm" (__base), "0" (__low), "1" (__upper)); \ |
36 | : "rm" (__base), "0" (__low), "1" (__upper)); \ |
32 | asm("":"=A" (n) : "a" (__low), "d" (__high)); \ |
37 | asm("" : "=A" (n) : "a" (__low), "d" (__high)); \ |
- | 38 | } \ |
|
33 | __mod; \ |
39 | __mod; \ |
34 | }) |
40 | }) |
Line 35... | Line 41... | ||
35 | 41 | ||
36 | static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) |
42 | static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) |