summaryrefslogtreecommitdiffstats
path: root/lib/libc/sparc64
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2012-01-16 04:09:45 +0000
committerdas <das@FreeBSD.org>2012-01-16 04:09:45 +0000
commitc3eb99c02f5a835a7f7ab6408db640e2ec155392 (patch)
tree5da7d359f406b602030ecc37cc313bdadd5206e4 /lib/libc/sparc64
parent16087d23a4c4032e1bbaa43c668ac2a5afd1a333 (diff)
downloadFreeBSD-src-c3eb99c02f5a835a7f7ab6408db640e2ec155392.zip
FreeBSD-src-c3eb99c02f5a835a7f7ab6408db640e2ec155392.tar.gz
Computations on NaNs are supposed to return one of the input NaNs unchanged.
Fix a few places in the sparc64 floating-point emulator where this wasn't being handled properly. Submitted by: bde
Diffstat (limited to 'lib/libc/sparc64')
-rw-r--r--lib/libc/sparc64/fpu/fpu_emu.h3
-rw-r--r--lib/libc/sparc64/fpu/fpu_mul.c4
2 files changed, 3 insertions, 4 deletions
diff --git a/lib/libc/sparc64/fpu/fpu_emu.h b/lib/libc/sparc64/fpu/fpu_emu.h
index 0d1d16d..0822de8 100644
--- a/lib/libc/sparc64/fpu/fpu_emu.h
+++ b/lib/libc/sparc64/fpu/fpu_emu.h
@@ -159,7 +159,8 @@ struct fpemu {
* Each of these may modify its inputs (f1,f2) and/or the temporary.
* Each returns a pointer to the result and/or sets exceptions.
*/
-#define __fpu_sub(fe) ((fe)->fe_f2.fp_sign ^= 1, __fpu_add(fe))
+#define __fpu_sub(fe) (ISNAN(&(fe)->fe_f2) ? 0 : ((fe)->fe_f2.fp_sign ^= 1), \
+ __fpu_add(fe))
#ifdef FPU_DEBUG
#define FPE_INSN 0x1
diff --git a/lib/libc/sparc64/fpu/fpu_mul.c b/lib/libc/sparc64/fpu/fpu_mul.c
index 173810e..3fe27c4 100644
--- a/lib/libc/sparc64/fpu/fpu_mul.c
+++ b/lib/libc/sparc64/fpu/fpu_mul.c
@@ -125,10 +125,8 @@ __fpu_mul(fe)
* The result is x * y (XOR sign, multiply bits, add exponents).
*/
ORDER(x, y);
- if (ISNAN(y)) {
- y->fp_sign ^= x->fp_sign;
+ if (ISNAN(y))
return (y);
- }
if (ISINF(y)) {
if (ISZERO(x))
return (__fpu_newnan(fe));
OpenPOWER on IntegriCloud