Skip to content

Commit

Permalink
[ARM] 3471/1: FTOSI functions should return 0 for NaN
Browse files Browse the repository at this point in the history
Patch from Catalin Marinas

The NaN case was dealed with by the "exponent >= ... + 32" condition but it
was not setting the value "d" to 0.

Signed-off-by: Ken'ichi Kuromusha <musha@aplix.co.jp>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Catalin Marinas authored and Russell King committed Apr 10, 2006
1 parent adeff42 commit 1320a80
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 7 additions & 2 deletions arch/arm/vfp/vfpdouble.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,17 +588,22 @@ static u32 vfp_double_ftosi(int sd, int unused, int dm, u32 fpscr)
struct vfp_double vdm;
u32 d, exceptions = 0;
int rmode = fpscr & FPSCR_RMODE_MASK;
int tm;

vfp_double_unpack(&vdm, vfp_get_double(dm));
vfp_double_dump("VDM", &vdm);

/*
* Do we have denormalised number?
*/
if (vfp_double_type(&vdm) & VFP_DENORMAL)
tm = vfp_double_type(&vdm);
if (tm & VFP_DENORMAL)
exceptions |= FPSCR_IDC;

if (vdm.exponent >= 1023 + 32) {
if (tm & VFP_NAN) {
d = 0;
exceptions |= FPSCR_IOC;
} else if (vdm.exponent >= 1023 + 32) {
d = 0x7fffffff;
if (vdm.sign)
d = ~d;
Expand Down
7 changes: 6 additions & 1 deletion arch/arm/vfp/vfpsingle.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,17 +632,22 @@ static u32 vfp_single_ftosi(int sd, int unused, s32 m, u32 fpscr)
struct vfp_single vsm;
u32 d, exceptions = 0;
int rmode = fpscr & FPSCR_RMODE_MASK;
int tm;

vfp_single_unpack(&vsm, m);
vfp_single_dump("VSM", &vsm);

/*
* Do we have a denormalised number?
*/
tm = vfp_single_type(&vsm);
if (vfp_single_type(&vsm) & VFP_DENORMAL)
exceptions |= FPSCR_IDC;

if (vsm.exponent >= 127 + 32) {
if (tm & VFP_NAN) {
d = 0;
exceptions |= FPSCR_IOC;
} else if (vsm.exponent >= 127 + 32) {
/*
* m >= 2^31-2^7: invalid
*/
Expand Down

0 comments on commit 1320a80

Please sign in to comment.