diff options
author | Richard Henderson <rth@twiddle.net> | 2011-04-16 08:24:15 -0700 |
---|---|---|
committer | Richard Henderson <rth@twiddle.net> | 2011-04-16 08:24:15 -0700 |
commit | 5c54b53299d0223877158df6285560b7a69609ff (patch) | |
tree | 81474e4362283ed7d8fe02a9e6e28786c8e8c505 | |
parent | 3fae2a407ae3a09d6191ba407a8ce93c2e57c506 (diff) | |
download | qemu-palcode-5c54b53299d0223877158df6285560b7a69609ff.tar.gz |
Use explicit division avoidance in print_decimal.
-rw-r--r-- | printf.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -14,8 +14,16 @@ static int print_decimal(unsigned long val) { do { - *--p = (val % 10) + '0'; - val /= 10; + unsigned long d, r; + + /* Compiling with -Os results in a call to the division routine. + Do what the compiler ought to have done. */ + d = __builtin_alpha_umulh(val, 0xcccccccccccccccd); + d >>= 3; + r = val - (d * 10); + + *--p = r + '0'; + val = d; } while (val); } |