Commit d8e791e2 authored by Linus Torvalds's avatar Linus Torvalds

Make x86 do_div() macro evaluate its "base" argument only once.

parent 359a118a
...@@ -14,14 +14,15 @@ ...@@ -14,14 +14,15 @@
* convention" on x86. * convention" on x86.
*/ */
#define do_div(n,base) ({ \ #define do_div(n,base) ({ \
unsigned long __upper, __low, __high, __mod; \ unsigned long __upper, __low, __high, __mod, __base; \
__base = (base); \
asm("":"=a" (__low), "=d" (__high):"A" (n)); \ asm("":"=a" (__low), "=d" (__high):"A" (n)); \
__upper = __high; \ __upper = __high; \
if (__high) { \ if (__high) { \
__upper = __high % (base); \ __upper = __high % (__base); \
__high = __high / (base); \ __high = __high / (__base); \
} \ } \
asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (base), "0" (__low), "1" (__upper)); \ asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \
asm("":"=A" (n):"a" (__low),"d" (__high)); \ asm("":"=A" (n):"a" (__low),"d" (__high)); \
__mod; \ __mod; \
}) })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment