2000-12-13 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/ldtoa.c (_ldcheck): New routine that categorizes a long double as NaN, Infinity, or other. * libc/stdio/vfprintf.c [WANT_IO_LONG_DBL](_VFPRINTF_R): Removed isinfl and isnanl static routines which were i386-specific. Changed calls to the two removed routines to a single _ldcheck call. * libc/stdio/vfieeefp.h (ldieee): Fixed missing semi-colons.
This commit is contained in:
parent
adbbb0348c
commit
b6182a09dd
|
@ -1,3 +1,12 @@
|
||||||
|
2000-12-13 Jeff Johnston <jjohnstn@redhat.com>
|
||||||
|
|
||||||
|
* libc/stdlib/ldtoa.c (_ldcheck): New routine
|
||||||
|
that categorizes a long double as NaN, Infinity, or other.
|
||||||
|
* libc/stdio/vfprintf.c [WANT_IO_LONG_DBL](_VFPRINTF_R): Removed
|
||||||
|
isinfl and isnanl static routines which were i386-specific. Changed
|
||||||
|
calls to the two removed routines to a single _ldcheck call.
|
||||||
|
* libc/stdio/vfieeefp.h (ldieee): Fixed missing semi-colons.
|
||||||
|
|
||||||
2000-12-13 Jeff Johnston <jjohnstn@redhat.com>
|
2000-12-13 Jeff Johnston <jjohnstn@redhat.com>
|
||||||
|
|
||||||
* Makefile.am: Fixed install-data-local target to use
|
* Makefile.am: Fixed install-data-local target to use
|
||||||
|
|
|
@ -70,7 +70,7 @@ struct ldieee
|
||||||
unsigned manh:23;
|
unsigned manh:23;
|
||||||
unsigned exp:8;
|
unsigned exp:8;
|
||||||
unsigned sign:1;
|
unsigned sign:1;
|
||||||
}
|
};
|
||||||
#elif LDBL_MANT_DIG == 53
|
#elif LDBL_MANT_DIG == 53
|
||||||
struct ldieee
|
struct ldieee
|
||||||
{
|
{
|
||||||
|
@ -78,7 +78,7 @@ struct ldieee
|
||||||
unsigned manh:32;
|
unsigned manh:32;
|
||||||
unsigned exp:11;
|
unsigned exp:11;
|
||||||
unsigned sign:1;
|
unsigned sign:1;
|
||||||
}
|
};
|
||||||
#elif LDBL_MANT_DIG == 64
|
#elif LDBL_MANT_DIG == 64
|
||||||
struct ldieee
|
struct ldieee
|
||||||
{
|
{
|
||||||
|
@ -105,7 +105,7 @@ struct ldieee
|
||||||
unsigned sign:1;
|
unsigned sign:1;
|
||||||
unsigned exp:8;
|
unsigned exp:8;
|
||||||
unsigned manh:23;
|
unsigned manh:23;
|
||||||
}
|
};
|
||||||
#elif LDBL_MANT_DIG == 53
|
#elif LDBL_MANT_DIG == 53
|
||||||
struct ldieee
|
struct ldieee
|
||||||
{
|
{
|
||||||
|
@ -113,7 +113,7 @@ struct ldieee
|
||||||
unsigned exp:11;
|
unsigned exp:11;
|
||||||
unsigned manh:32;
|
unsigned manh:32;
|
||||||
unsigned manl:20;
|
unsigned manl:20;
|
||||||
}
|
};
|
||||||
#elif LDBL_MANT_DIG == 64
|
#elif LDBL_MANT_DIG == 64
|
||||||
struct ldieee
|
struct ldieee
|
||||||
{
|
{
|
||||||
|
@ -121,7 +121,7 @@ struct ldieee
|
||||||
unsigned exp:15;
|
unsigned exp:15;
|
||||||
unsigned manh:32;
|
unsigned manh:32;
|
||||||
unsigned manl:32;
|
unsigned manl:32;
|
||||||
}
|
};
|
||||||
#elif LDBL_MANT_DIG > 64
|
#elif LDBL_MANT_DIG > 64
|
||||||
struct ldieee
|
struct ldieee
|
||||||
{
|
{
|
||||||
|
|
|
@ -252,8 +252,7 @@ __sbprintf(fp, fmt, ap)
|
||||||
static char *cvt _PARAMS((struct _reent *, double, int, int, char *, int *, int, int *));
|
static char *cvt _PARAMS((struct _reent *, double, int, int, char *, int *, int, int *));
|
||||||
#else
|
#else
|
||||||
static char *cvt _PARAMS((struct _reent *, _LONG_DOUBLE, int, int, char *, int *, int, int *));
|
static char *cvt _PARAMS((struct _reent *, _LONG_DOUBLE, int, int, char *, int *, int, int *));
|
||||||
static int isinfl _PARAMS((_LONG_DOUBLE *));
|
extern int _ldcheck _PARAMS((_LONG_DOUBLE *));
|
||||||
static int isnanl _PARAMS((_LONG_DOUBLE *));
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int exponent _PARAMS((char *, int, int));
|
static int exponent _PARAMS((char *, int, int));
|
||||||
|
@ -322,6 +321,7 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap),
|
||||||
#else
|
#else
|
||||||
union { int i; _LONG_DOUBLE ld; } _long_double_ = {0};
|
union { int i; _LONG_DOUBLE ld; } _long_double_ = {0};
|
||||||
#define _fpvalue (_long_double_.ld)
|
#define _fpvalue (_long_double_.ld)
|
||||||
|
int tmp;
|
||||||
#endif
|
#endif
|
||||||
int expt; /* integer value of exponent */
|
int expt; /* integer value of exponent */
|
||||||
int expsize = 0; /* character count for expstr */
|
int expsize = 0; /* character count for expstr */
|
||||||
|
@ -604,14 +604,15 @@ reswitch: switch (ch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* do this before tricky precision changes */
|
/* do this before tricky precision changes */
|
||||||
if (isinfl(&_fpvalue)) {
|
tmp = _ldcheck (&_fpvalue);
|
||||||
|
if (tmp == 2) {
|
||||||
if (_fpvalue < 0)
|
if (_fpvalue < 0)
|
||||||
sign = '-';
|
sign = '-';
|
||||||
cp = "Inf";
|
cp = "Inf";
|
||||||
size = 3;
|
size = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (isnanl(&_fpvalue)) {
|
if (tmp == 1) {
|
||||||
cp = "NaN";
|
cp = "NaN";
|
||||||
size = 3;
|
size = 3;
|
||||||
break;
|
break;
|
||||||
|
@ -912,32 +913,6 @@ extern char *_ldtoa_r _PARAMS((struct _reent *, _LONG_DOUBLE, int,
|
||||||
int, int *, int *, char **));
|
int, int *, int *, char **));
|
||||||
#undef word0
|
#undef word0
|
||||||
#define word0(x) ldword0(x)
|
#define word0(x) ldword0(x)
|
||||||
|
|
||||||
static int
|
|
||||||
isinfl (value)
|
|
||||||
_LONG_DOUBLE *value;
|
|
||||||
{
|
|
||||||
struct ldieee *ldptr;
|
|
||||||
|
|
||||||
ldptr = (struct ldieee *)value;
|
|
||||||
|
|
||||||
if (ldptr->exp == 0x7fff && !(ldptr->manh & 0x7fffffff) && !ldptr->manl)
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
isnanl (value)
|
|
||||||
_LONG_DOUBLE *value;
|
|
||||||
{
|
|
||||||
struct ldieee *ldptr;
|
|
||||||
|
|
||||||
ldptr = (struct ldieee *)value;
|
|
||||||
|
|
||||||
if (ldptr->exp == 0x7fff && ((ldptr->manh & 0x7fffffff) || ldptr->manl))
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
/* linux name: long double _IO_strtold (char *, char **); */
|
/* linux name: long double _IO_strtold (char *, char **); */
|
||||||
long double _strtold (char *, char **);
|
long double _strtold (char *, char **);
|
||||||
char * _ldtoa_r (struct _reent *, long double, int, int, int *, int *, char **);
|
char * _ldtoa_r (struct _reent *, long double, int, int, int *, int *, char **);
|
||||||
|
int _ldcheck (long double *);
|
||||||
#if 0
|
#if 0
|
||||||
void _IO_ldtostr(long double *, char *, int, int, char);
|
void _IO_ldtostr(long double *, char *, int, int, char);
|
||||||
#endif
|
#endif
|
||||||
|
@ -2826,6 +2827,46 @@ if( rve )
|
||||||
return outstr;
|
return outstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Routine used to tell if long double is NaN or Infinity or regular number.
|
||||||
|
Returns: 0 = regular number
|
||||||
|
1 = Nan
|
||||||
|
2 = Infinity
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
_ldcheck (long double *d)
|
||||||
|
{
|
||||||
|
unsigned short e[NI];
|
||||||
|
char *s, *p;
|
||||||
|
int k;
|
||||||
|
LDPARMS rnd;
|
||||||
|
LDPARMS *ldp = &rnd;
|
||||||
|
char *outstr;
|
||||||
|
|
||||||
|
rnd.rlast = -1;
|
||||||
|
rnd.rndprc = NBITS;
|
||||||
|
|
||||||
|
#if LDBL_MANT_DIG == 24
|
||||||
|
e24toe( (unsigned short *)d, e, ldp );
|
||||||
|
#elif LDBL_MANT_DIG == 53
|
||||||
|
e53toe( (unsigned short *)d, e, ldp );
|
||||||
|
#elif LDBL_MANT_DIG == 64
|
||||||
|
e64toe( (unsigned short *)d, e, ldp );
|
||||||
|
#else
|
||||||
|
e113toe( (unsigned short *)d, e, ldp );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if( (e[NE-1] & 0x7fff) == 0x7fff )
|
||||||
|
{
|
||||||
|
#ifdef NANS
|
||||||
|
if( eisnan(e) )
|
||||||
|
return( 1 );
|
||||||
|
#endif
|
||||||
|
return( 2 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return( 0 );
|
||||||
|
} /* _ldcheck */
|
||||||
|
|
||||||
static void etoasc(short unsigned int *x, char *string, int ndigits, int outformat, LDPARMS *ldp)
|
static void etoasc(short unsigned int *x, char *string, int ndigits, int outformat, LDPARMS *ldp)
|
||||||
{
|
{
|
||||||
long digit;
|
long digit;
|
||||||
|
|
Loading…
Reference in New Issue