1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

PowerPC floating point little-endian [1 of 15]

http://sourceware.org/ml/libc-alpha/2013-08/msg00081.html

This is the first of a series of patches to ban ieee854_long_double
and the ieee854_long_double macros when using IBM long double.  union
ieee854_long_double just isn't correct for IBM long double, especially
when little-endian, and pretending it is OK has allowed a number of
bugs to remain undetected in sysdeps/ieee754/ldbl-128ibm/.

This changes the few places in generic code that use it.

	* stdio-common/printf_size.c (__printf_size): Don't use
	union ieee854_long_double in fpnum union.
	* stdio-common/printf_fphex.c (__printf_fphex): Likewise.  Use
	signbit macro to retrieve sign from long double.
	* stdio-common/printf_fp.c (___printf_fp): Use signbit macro to
	retrieve sign from long double.
	* sysdeps/ieee754/ldbl-128ibm/printf_fphex.c: Adjust for fpnum change.
	* sysdeps/ieee754/ldbl-128/printf_fphex.c: Likewise.
	* sysdeps/ieee754/ldbl-96/printf_fphex.c: Likewise.
	* sysdeps/x86_64/fpu/printf_fphex.c: Likewise.
	* math/test-misc.c (main): Don't use union ieee854_long_double.
ports/
	* sysdeps/ia64/fpu/printf_fphex.c: Adjust for fpnum change.
This commit is contained in:
Alan Modra
2013-08-17 18:21:58 +09:30
parent 4cf69995e2
commit 1b6adf888d
11 changed files with 131 additions and 250 deletions

View File

@ -93,7 +93,7 @@ __printf_fphex (FILE *fp,
union
{
union ieee754_double dbl;
union ieee854_long_double ldbl;
long double ldbl;
}
fpnum;
@ -162,12 +162,11 @@ __printf_fphex (FILE *fp,
#ifndef __NO_LONG_DOUBLE_MATH
if (info->is_long_double && sizeof (long double) > sizeof (double))
{
fpnum.ldbl.d = *(const long double *) args[0];
fpnum.ldbl = *(const long double *) args[0];
/* Check for special values: not a number or infinity. */
if (__isnanl (fpnum.ldbl.d))
if (__isnanl (fpnum.ldbl))
{
negative = fpnum.ldbl.ieee.negative != 0;
if (isupper (info->spec))
{
special = "NAN";
@ -181,8 +180,7 @@ __printf_fphex (FILE *fp,
}
else
{
int res = __isinfl (fpnum.ldbl.d);
if (res)
if (__isinfl (fpnum.ldbl))
{
if (isupper (info->spec))
{
@ -194,11 +192,9 @@ __printf_fphex (FILE *fp,
special = "inf";
wspecial = L"inf";
}
negative = res < 0;
}
else
negative = signbit (fpnum.ldbl.d);
}
negative = signbit (fpnum.ldbl);
}
else
#endif /* no long double */