diff options
-rw-r--r-- | lib/libc/amd64/Makefile.inc | 2 | ||||
-rw-r--r-- | lib/libc/gdtoa/_ldtoa.c | 12 | ||||
-rw-r--r-- | lib/libc/gdtoa/machdep_ldisQ.c | 4 | ||||
-rw-r--r-- | lib/libc/gdtoa/machdep_ldisx.c | 4 | ||||
-rw-r--r-- | lib/libc/i386/Makefile.inc | 2 | ||||
-rw-r--r-- | lib/libc/ia64/Makefile.inc | 2 | ||||
-rw-r--r-- | lib/libc/sparc64/Makefile.inc | 2 |
7 files changed, 20 insertions, 8 deletions
diff --git a/lib/libc/amd64/Makefile.inc b/lib/libc/amd64/Makefile.inc index e3f0c48..e4c0900 100644 --- a/lib/libc/amd64/Makefile.inc +++ b/lib/libc/amd64/Makefile.inc @@ -4,6 +4,6 @@ # # Long double is 80 bits -GDTOASRCS+=strtopx.c +GDTOASRCS+=strtorx.c MDSRCS+=machdep_ldisx.c SYM_MAPS+=${.CURDIR}/amd64/Symbol.map diff --git a/lib/libc/gdtoa/_ldtoa.c b/lib/libc/gdtoa/_ldtoa.c index 10731c4..952ca98 100644 --- a/lib/libc/gdtoa/_ldtoa.c +++ b/lib/libc/gdtoa/_ldtoa.c @@ -46,11 +46,11 @@ char * __ldtoa(long double *ld, int mode, int ndigits, int *decpt, int *sign, char **rve) { - static FPI fpi = { + FPI fpi = { LDBL_MANT_DIG, /* nbits */ LDBL_MIN_EXP - LDBL_MANT_DIG, /* emin */ LDBL_MAX_EXP - LDBL_MANT_DIG, /* emax */ - FPI_Round_near, /* rounding */ + FLT_ROUNDS, /* rounding */ #ifdef Sudden_Underflow /* unused, but correct anyway */ 1 #else @@ -64,7 +64,15 @@ __ldtoa(long double *ld, int mode, int ndigits, int *decpt, int *sign, void *vbits = bits; u.e = *ld; + + /* + * gdtoa doesn't know anything about the sign of the number, so + * if the number is negative, we need to swap rounding modes of + * 2 (upwards) and 3 (downwards). + */ *sign = u.bits.sign; + fpi.rounding ^= (fpi.rounding >> 1) & u.bits.sign; + be = u.bits.exp - (LDBL_MAX_EXP - 1) - (LDBL_MANT_DIG - 1); LDBL_TO_ARRAY32(u, bits); diff --git a/lib/libc/gdtoa/machdep_ldisQ.c b/lib/libc/gdtoa/machdep_ldisQ.c index e5cf6e6..ebcb37e 100644 --- a/lib/libc/gdtoa/machdep_ldisQ.c +++ b/lib/libc/gdtoa/machdep_ldisQ.c @@ -33,6 +33,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <float.h> + #include "gdtoaimp.h" long double @@ -40,6 +42,6 @@ strtold(const char * __restrict s, char ** __restrict sp) { long double result; - strtopQ(s, sp, &result); + strtorQ(s, sp, FLT_ROUNDS, &result); return result; } diff --git a/lib/libc/gdtoa/machdep_ldisx.c b/lib/libc/gdtoa/machdep_ldisx.c index 0b61de6..c08c85e 100644 --- a/lib/libc/gdtoa/machdep_ldisx.c +++ b/lib/libc/gdtoa/machdep_ldisx.c @@ -33,6 +33,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <float.h> + #include "gdtoaimp.h" long double @@ -40,6 +42,6 @@ strtold(const char * __restrict s, char ** __restrict sp) { long double result; - strtopx(s, sp, &result); + strtorx(s, sp, FLT_ROUNDS, &result); return result; } diff --git a/lib/libc/i386/Makefile.inc b/lib/libc/i386/Makefile.inc index 05b07cc..ba8e502 100644 --- a/lib/libc/i386/Makefile.inc +++ b/lib/libc/i386/Makefile.inc @@ -1,6 +1,6 @@ # $FreeBSD$ # Long double is 80 bits -GDTOASRCS+=strtopx.c +GDTOASRCS+=strtorx.c MDSRCS+=machdep_ldisx.c SYM_MAPS+=${.CURDIR}/i386/Symbol.map diff --git a/lib/libc/ia64/Makefile.inc b/lib/libc/ia64/Makefile.inc index 3043777..b451f85 100644 --- a/lib/libc/ia64/Makefile.inc +++ b/lib/libc/ia64/Makefile.inc @@ -4,6 +4,6 @@ # # Long double is 80 bits -GDTOASRCS+=strtopx.c +GDTOASRCS+=strtorx.c MDSRCS+=machdep_ldisx.c SYM_MAPS+=${.CURDIR}/ia64/Symbol.map diff --git a/lib/libc/sparc64/Makefile.inc b/lib/libc/sparc64/Makefile.inc index 2b9d3ab..76cc8b9 100644 --- a/lib/libc/sparc64/Makefile.inc +++ b/lib/libc/sparc64/Makefile.inc @@ -6,6 +6,6 @@ .include "fpu/Makefile.inc" # Long double is quad precision -GDTOASRCS+=strtopQ.c +GDTOASRCS+=strtorQ.c MDSRCS+=machdep_ldisQ.c SYM_MAPS+=${.CURDIR}/sparc64/Symbol.map |