softfloat: fix float*_scalnb() corner cases
commit326b9e98a391d542cc33c4c91782ff4ba51edfc5
authorAurelien Jarno <aurelien@aurel32.net>
Wed, 20 Apr 2011 11:04:22 +0000 (20 13:04 +0200)
committerAurelien Jarno <aurelien@aurel32.net>
Mon, 25 Apr 2011 09:18:33 +0000 (25 11:18 +0200)
treeb9cde2b1dea8db271bf7a0875aadf11bc1dcc75d
parentf6714d365da068481d83787b4044134ae2ec5dfd
softfloat: fix float*_scalnb() corner cases

float*_scalnb() were not taking into account all cases. This patch fixes
some corner cases:
- NaN values in input were not properly propagated and the invalid flag
  not correctly raised. Use propagateFloat*NaN() for that.
- NaN or infinite values in input of floatx80_scalnb() were not correctly
  detected due to a typo.
- The sum of exponent and n could overflow, leading to strange results.
  Additionally having int16 defined to int make that happening for a very
  small range of values. Fix that by saturating n to the maximum exponent
  range, and using an explicit wider type if needed.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
fpu/softfloat.c