aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2013-05-23 18:00:10 +0200
committerThomas Schwinge <thomas@codesourcery.com>2013-08-29 12:22:10 +0200
commit0007fc9bdd1d9efcd52d07837f2cd085b5a8f58b (patch)
treeb3c86dbee5b95c24a8413be634ae11318ceb2f8e /sysdeps
parentf1cc4c8654b6bc431273286d3562942c50975caf (diff)
downloadglibc-0007fc9bdd1d9efcd52d07837f2cd085b5a8f58b.zip
glibc-0007fc9bdd1d9efcd52d07837f2cd085b5a8f58b.tar.gz
glibc-0007fc9bdd1d9efcd52d07837f2cd085b5a8f58b.tar.bz2
[BZ #15522] strtod ("nan(N)") returning a sNaN in some cases
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/ieee754/ldbl-128/strtold_l.c12
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/ieee754.h19
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/strtold_l.c9
-rw-r--r--sysdeps/ieee754/ldbl-64-128/strtold_l.c12
-rw-r--r--sysdeps/ieee754/ldbl-96/strtold_l.c9
5 files changed, 41 insertions, 20 deletions
diff --git a/sysdeps/ieee754/ldbl-128/strtold_l.c b/sysdeps/ieee754/ldbl-128/strtold_l.c
index 8e0bc03..d3a1d1e 100644
--- a/sysdeps/ieee754/ldbl-128/strtold_l.c
+++ b/sysdeps/ieee754/ldbl-128/strtold_l.c
@@ -34,11 +34,13 @@
#define SET_MANTISSA(flt, mant) \
do { union ieee854_long_double u; \
u.d = (flt); \
- u.ieee.mantissa0 = 0x8000; \
- u.ieee.mantissa1 = 0; \
- u.ieee.mantissa2 = ((mant) >> 32); \
- u.ieee.mantissa3 = (mant) & 0xffffffff; \
- (flt) = u.d; \
+ u.ieee_nan.mantissa0 = 0; \
+ u.ieee_nan.mantissa1 = 0; \
+ u.ieee_nan.mantissa2 = (mant) >> 32; \
+ u.ieee_nan.mantissa3 = (mant); \
+ if ((u.ieee.mantissa0 | u.ieee.mantissa1 \
+ | u.ieee.mantissa2 | u.ieee.mantissa3) != 0) \
+ (flt) = u.d; \
} while (0)
#include <strtod_l.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm/ieee754.h b/sysdeps/ieee754/ldbl-128ibm/ieee754.h
index e5644f5..9e94f53 100644
--- a/sysdeps/ieee754/ldbl-128ibm/ieee754.h
+++ b/sysdeps/ieee754/ldbl-128ibm/ieee754.h
@@ -199,6 +199,25 @@ union ibm_extended_long_double
unsigned int mantissa2:20;
unsigned int mantissa3:32;
} ieee;
+
+ /* This format makes it easier to see if a NaN is a signalling NaN. */
+ struct
+ { /* Big endian. There is no other. */
+
+ unsigned int negative:1;
+ unsigned int exponent:11;
+ unsigned int quiet_nan:1;
+ /* Together Mantissa0-3 comprise the mantissa. */
+ unsigned int mantissa0:19;
+ unsigned int mantissa1:32;
+
+ unsigned int negative2:1;
+ unsigned int exponent2:11;
+ /* There is an implied 1 here? */
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa2:20;
+ unsigned int mantissa3:32;
+ } ieee_nan;
};
#define IBM_EXTENDED_LONG_DOUBLE_BIAS 0x3ff /* Added to exponent. */
diff --git a/sysdeps/ieee754/ldbl-128ibm/strtold_l.c b/sysdeps/ieee754/ldbl-128ibm/strtold_l.c
index 93415f0..04e3288 100644
--- a/sysdeps/ieee754/ldbl-128ibm/strtold_l.c
+++ b/sysdeps/ieee754/ldbl-128ibm/strtold_l.c
@@ -44,11 +44,10 @@ libc_hidden_proto (STRTOF)
# define SET_MANTISSA(flt, mant) \
do { union ibm_extended_long_double u; \
u.d = (flt); \
- if ((mant & 0xfffffffffffffULL) == 0) \
- mant = 0x8000000000000ULL; \
- u.ieee.mantissa0 = ((mant) >> 32) & 0xfffff; \
- u.ieee.mantissa1 = (mant) & 0xffffffff; \
- (flt) = u.d; \
+ u.ieee_nan.mantissa0 = (mant) >> 32; \
+ u.ieee_nan.mantissa1 = (mant); \
+ if ((u.ieee.mantissa0 | u.ieee.mantissa1) != 0) \
+ (flt) = u.d; \
} while (0)
#include <strtod_l.c>
diff --git a/sysdeps/ieee754/ldbl-64-128/strtold_l.c b/sysdeps/ieee754/ldbl-64-128/strtold_l.c
index 8182b2b..e9b33f2 100644
--- a/sysdeps/ieee754/ldbl-64-128/strtold_l.c
+++ b/sysdeps/ieee754/ldbl-64-128/strtold_l.c
@@ -44,11 +44,13 @@ libc_hidden_proto (STRTOF)
#define SET_MANTISSA(flt, mant) \
do { union ieee854_long_double u; \
u.d = (flt); \
- u.ieee.mantissa0 = 0x8000; \
- u.ieee.mantissa1 = 0; \
- u.ieee.mantissa2 = ((mant) >> 32); \
- u.ieee.mantissa3 = (mant) & 0xffffffff; \
- (flt) = u.d; \
+ u.ieee_nan.mantissa0 = 0; \
+ u.ieee_nan.mantissa1 = 0; \
+ u.ieee_nan.mantissa2 = (mant) >> 32; \
+ u.ieee_nan.mantissa3 = (mant); \
+ if ((u.ieee.mantissa0 | u.ieee.mantissa1 \
+ | u.ieee.mantissa2 | u.ieee.mantissa3) != 0) \
+ (flt) = u.d; \
} while (0)
#include <strtod_l.c>
diff --git a/sysdeps/ieee754/ldbl-96/strtold_l.c b/sysdeps/ieee754/ldbl-96/strtold_l.c
index ded84f3..dccf98c 100644
--- a/sysdeps/ieee754/ldbl-96/strtold_l.c
+++ b/sysdeps/ieee754/ldbl-96/strtold_l.c
@@ -34,11 +34,10 @@
#define SET_MANTISSA(flt, mant) \
do { union ieee854_long_double u; \
u.d = (flt); \
- if ((mant & 0x7fffffffffffffffULL) == 0) \
- mant = 0x4000000000000000ULL; \
- u.ieee.mantissa0 = (((mant) >> 32) & 0x7fffffff) | 0x80000000; \
- u.ieee.mantissa1 = (mant) & 0xffffffff; \
- (flt) = u.d; \
+ u.ieee_nan.mantissa0 = (mant) >> 32; \
+ u.ieee_nan.mantissa1 = (mant); \
+ if ((u.ieee.mantissa0 | u.ieee.mantissa1) != 0) \
+ (flt) = u.d; \
} while (0)
#include <stdlib/strtod_l.c>