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> 2006-06-22 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/Makefile.am: Add new gdtoa routines. * 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 Exp_mask ((__uint32_t)0x7f800000L)
#define P 24 #define P 24
#define Bias 127 #define Bias 127
#define NO_HEX_FP /* not supported in this case */
#if 0 #if 0
#define IEEE_Arith /* it is, but the code doesn't handle IEEE singles yet */ #define IEEE_Arith /* it is, but the code doesn't handle IEEE singles yet */
#endif #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 Emin (-126)
#define Exp_1 ((__uint32_t)0x3f800000L) #define Exp_1 ((__uint32_t)0x3f800000L)
#define Exp_11 ((__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)) #define Infinite(x) (word0(x) == ((__uint32_t)0x7f800000L))
#undef word0 #undef word0
#undef word1 #undef word1
#undef dword0
#undef dword1
#define word0(x) (x.i[0]) #define word0(x) (x.i[0])
#define word1(x) 0 #define word1(x) 0
#define dword0(x) ((__ULong *)&x)[0]
#define dword1(x) 0
#else #else
#define Exp_shift 20 #define Exp_shift 20
@ -195,6 +206,8 @@ typedef union { double d; __ULong L[2]; } U;
#define Int_max 14 #define Int_max 14
#define Infinite(x) (word0(x) == ((__uint32_t)0x7ff00000L)) /* sufficient test for here */ #define Infinite(x) (word0(x) == ((__uint32_t)0x7ff00000L)) /* sufficient test for here */
#endif /* !_DOUBLE_IS_32BITS */
#ifndef Flt_Rounds #ifndef Flt_Rounds
#ifdef FLT_ROUNDS #ifdef FLT_ROUNDS
#define Flt_Rounds FLT_ROUNDS #define Flt_Rounds FLT_ROUNDS
@ -203,9 +216,7 @@ typedef union { double d; __ULong L[2]; } U;
#endif #endif
#endif /*Flt_Rounds*/ #endif /*Flt_Rounds*/
#endif #else /* !IEEE_8087 && !IEEE_MC68k */
#else
#undef Sudden_Underflow #undef Sudden_Underflow
#define Sudden_Underflow #define Sudden_Underflow
#ifdef IBM #ifdef IBM

View File

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