2006-07-05 Jeff Johnston <jjohnstn@redhat.com>

* libc/stdlib/mprec.h [_DOUBLE_IS_32BITS]: Turn off C99 hex
        floating-point format support.  Also redefine
        dword0 and dword1 macros.
        * libc/stdlib/strtod.c: Add checks for _DOUBLE_IS_32BITS
        to prevent setting dword1 which is an rvalue only.
This commit is contained in:
Jeff Johnston 2006-07-05 16:18:30 +00:00
parent 8307a41117
commit b0b9243869
3 changed files with 54 additions and 4 deletions

View File

@ -1,3 +1,11 @@
2006-07-05 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/mprec.h [_DOUBLE_IS_32BITS]: Turn off C99 hex
floating-point format support. Also redefine
dword0 and dword1 macros.
* libc/stdlib/strtod.c: Add checks for _DOUBLE_IS_32BITS
to prevent setting dword1 which is an rvalue only.
2006-06-22 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/Makefile.am: Add new gdtoa routines.

View File

@ -138,9 +138,16 @@ typedef union { double d; __ULong L[2]; } U;
#define Exp_mask ((__uint32_t)0x7f800000L)
#define P 24
#define Bias 127
#define NO_HEX_FP /* not supported in this case */
#if 0
#define IEEE_Arith /* it is, but the code doesn't handle IEEE singles yet */
#endif
/* Following is needed due to IEEE_Arith not being set on above. */
#if defined(__v800)
#define n_bigtens 2
#else
#define n_bigtens 5
#endif
#define Emin (-126)
#define Exp_1 ((__uint32_t)0x3f800000L)
#define Exp_11 ((__uint32_t)0x3f800000L)
@ -163,9 +170,13 @@ typedef union { double d; __ULong L[2]; } U;
#define Infinite(x) (word0(x) == ((__uint32_t)0x7f800000L))
#undef word0
#undef word1
#undef dword0
#undef dword1
#define word0(x) (x.i[0])
#define word1(x) 0
#define dword0(x) ((__ULong *)&x)[0]
#define dword1(x) 0
#else
#define Exp_shift 20
@ -195,6 +206,8 @@ typedef union { double d; __ULong L[2]; } U;
#define Int_max 14
#define Infinite(x) (word0(x) == ((__uint32_t)0x7ff00000L)) /* sufficient test for here */
#endif /* !_DOUBLE_IS_32BITS */
#ifndef Flt_Rounds
#ifdef FLT_ROUNDS
#define Flt_Rounds FLT_ROUNDS
@ -203,9 +216,7 @@ typedef union { double d; __ULong L[2]; } U;
#endif
#endif /*Flt_Rounds*/
#endif
#else
#else /* !IEEE_8087 && !IEEE_MC68k */
#undef Sudden_Underflow
#define Sudden_Underflow
#ifdef IBM

View File

@ -137,6 +137,8 @@ static _CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128,
#define Rounding Flt_Rounds
#endif
#ifndef NO_HEX_FP
static void
_DEFUN (ULtod, (L, bits, exp, k),
__ULong *L _AND
@ -173,7 +175,8 @@ _DEFUN (ULtod, (L, bits, exp, k),
if (k & STRTOG_Neg)
L[_0] |= 0x80000000L;
}
#endif /* !NO_HEX_FP */
#ifdef INFNAN_CHECK
static int
_DEFUN (match, (sp, t),
@ -543,15 +546,21 @@ _DEFUN (_strtod_r, (ptr, s00, se),
case 0: /* toward 0 */
case 3: /* toward -infinity */
dword0(rv) = Big0;
#ifndef _DOUBLE_IS_32BITS
dword1(rv) = Big1;
#endif /*!_DOUBLE_IS_32BITS*/
break;
default:
dword0(rv) = Exp_mask;
#ifndef _DOUBLE_IS_32BITS
dword1(rv) = 0;
#endif /*!_DOUBLE_IS_32BITS*/
}
#else /*Honor_FLT_ROUNDS*/
dword0(rv) = Exp_mask;
#ifndef _DOUBLE_IS_32BITS
dword1(rv) = 0;
#endif /*!_DOUBLE_IS_32BITS*/
#endif /*Honor_FLT_ROUNDS*/
#ifdef SET_INEXACT
/* set overflow bit */
@ -560,7 +569,9 @@ _DEFUN (_strtod_r, (ptr, s00, se),
#endif
#else /*IEEE_Arith*/
dword0(rv) = Big0;
#ifndef _DOUBLE_IS_32BITS
dword1(rv) = Big1;
#endif /*!_DOUBLE_IS_32BITS*/
#endif /*IEEE_Arith*/
if (bd0)
goto retfree;
@ -580,7 +591,9 @@ _DEFUN (_strtod_r, (ptr, s00, se),
/* set to largest number */
/* (Can't trust DBL_MAX) */
dword0(rv) = Big0;
#ifndef _DOUBLE_IS_32BITS
dword1(rv) = Big1;
#endif /*!_DOUBLE_IS_32BITS*/
}
else
dword0(rv) += P*Exp_msk1;
@ -603,15 +616,19 @@ _DEFUN (_strtod_r, (ptr, s00, se),
>> Exp_shift)) > 0) {
/* scaled rv is denormal; zap j low bits */
if (j >= 32) {
#ifndef _DOUBLE_IS_32BITS
dword1(rv) = 0;
#endif /*!_DOUBLE_IS_32BITS*/
if (j >= 53)
dword0(rv) = (P+2)*Exp_msk1;
else
dword0(rv) &= 0xffffffff << (j-32);
}
#ifndef _DOUBLE_IS_32BITS
else
dword1(rv) &= 0xffffffff << j;
}
#endif /*!_DOUBLE_IS_32BITS*/
#else
for(j = 0; e1 > 1; j++, e1 >>= 1)
if (e1 & 1)
@ -634,8 +651,12 @@ _DEFUN (_strtod_r, (ptr, s00, se),
goto ret;
}
#ifndef Avoid_Underflow
#ifndef _DOUBLE_IS_32BITS
dword0(rv) = Tiny0;
dword1(rv) = Tiny1;
#else
dword0(rv) = Tiny1;
#endif /*_DOUBLE_IS_32BITS*/
/* The refinement below will clean
* this approximation up.
*/
@ -866,7 +887,9 @@ _DEFUN (_strtod_r, (ptr, s00, se),
| Exp_msk1 >> 4
#endif
;
#ifndef _DOUBLE_IS_32BITS
dword1(rv) = 0;
#endif /*!_DOUBLE_IS_32BITS*/
#ifdef Avoid_Underflow
dsign = 0;
#endif
@ -906,7 +929,9 @@ _DEFUN (_strtod_r, (ptr, s00, se),
L = (dword0(rv) & Exp_mask) - Exp_msk1;
#endif /*Sudden_Underflow}*/
dword0(rv) = L | Bndry_mask1;
#ifndef _DOUBLE_IS_32BITS
dword1(rv) = 0xffffffff;
#endif /*!_DOUBLE_IS_32BITS*/
#ifdef IBM
goto cont;
#else
@ -986,7 +1011,9 @@ _DEFUN (_strtod_r, (ptr, s00, se),
if (dword0(rv0) == Big0 && dword1(rv0) == Big1)
goto ovfl;
dword0(rv) = Big0;
#ifndef _DOUBLE_IS_32BITS
dword1(rv) = Big1;
#endif /*!_DOUBLE_IS_32BITS*/
goto cont;
}
else
@ -1021,8 +1048,12 @@ _DEFUN (_strtod_r, (ptr, s00, se),
if (dword0(rv0) == Tiny0
&& dword1(rv0) == Tiny1)
goto undfl;
#ifndef _DOUBLE_IS_32BITS
dword0(rv) = Tiny0;
dword1(rv) = Tiny1;
#else
dword0(rv) = Tiny1;
#endif /*_DOUBLE_IS_32BITS*/
goto cont;
}
else