1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +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

@ -1,3 +1,17 @@
2013-10-04 Alan Modra <amodra@gmail.com>
* 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.
2013-10-04 Alan Modra <amodra@gmail.com> 2013-10-04 Alan Modra <amodra@gmail.com>
[BZ #15680] [BZ #15680]

View File

@ -722,300 +722,161 @@ main (void)
#ifndef NO_LONG_DOUBLE #ifndef NO_LONG_DOUBLE
{ {
union ieee854_long_double v1; long double v1, v2;
union ieee854_long_double v2;
long double ld;
v1.d = ld = LDBL_MIN; v1 = LDBL_MIN;
if (fpclassify (ld) != FP_NORMAL) if (fpclassify (v1) != FP_NORMAL)
{ {
printf ("fpclassify (LDBL_MIN) failed: %d\n", fpclassify (ld)); printf ("fpclassify (LDBL_MIN) failed: %d (%La)\n",
fpclassify (v1), v1);
result = 1; result = 1;
} }
ld = nextafterl (ld, LDBL_MIN / 2.0); v2 = nextafterl (v1, LDBL_MIN / 2.0);
if (fpclassify (ld) != FP_SUBNORMAL) if (fpclassify (v2) != FP_SUBNORMAL)
{ {
printf ("fpclassify (LDBL_MIN-epsilon) failed: %d (%La)\n", printf ("fpclassify (LDBL_MIN-epsilon) failed: %d (%La)\n",
fpclassify (ld), ld); fpclassify (v2), v2);
result = 1; result = 1;
} }
v2.d = ld = nextafterl (ld, LDBL_MIN); v2 = nextafterl (v2, LDBL_MIN);
if (fpclassify (ld) != FP_NORMAL) if (fpclassify (v2) != FP_NORMAL)
{ {
printf ("fpclassify (LDBL_MIN-epsilon+epsilon) failed: %d (%La)\n", printf ("fpclassify (LDBL_MIN-epsilon+epsilon) failed: %d (%La)\n",
fpclassify (ld), ld); fpclassify (v2), v2);
result = 1; result = 1;
} }
if (v1.ieee.mantissa0 != v2.ieee.mantissa0) if (v1 != v2)
{ {
printf ("LDBL_MIN: mantissa0 differs: %8x vs %8x\n", printf ("LDBL_MIN-epsilon+epsilon != LDBL_MIN: %La vs %La\n", v2, v1);
v1.ieee.mantissa0, v2.ieee.mantissa0);
result = 1;
}
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
{
printf ("LDBL_MIN: mantissa1 differs: %8x vs %8x\n",
v1.ieee.mantissa1, v2.ieee.mantissa1);
result = 1;
}
if (v1.ieee.exponent != v2.ieee.exponent)
{
printf ("LDBL_MIN: exponent differs: %4x vs %4x\n",
v1.ieee.exponent, v2.ieee.exponent);
result = 1;
}
if (v1.ieee.negative != v2.ieee.negative)
{
printf ("LDBL_MIN: negative differs: %d vs %d\n",
v1.ieee.negative, v2.ieee.negative);
result = 1; result = 1;
} }
v1.d = ld = -LDBL_MIN; v1 = -LDBL_MIN;
if (fpclassify (ld) != FP_NORMAL) if (fpclassify (v1) != FP_NORMAL)
{ {
printf ("fpclassify (-LDBL_MIN) failed: %d\n", fpclassify (ld)); printf ("fpclassify (-LDBL_MIN) failed: %d (%La)\n",
fpclassify (v1), v1);
result = 1; result = 1;
} }
ld = nextafterl (ld, -LDBL_MIN / 2.0); v2 = nextafterl (v1, -LDBL_MIN / 2.0);
if (fpclassify (ld) != FP_SUBNORMAL) if (fpclassify (v2) != FP_SUBNORMAL)
{ {
printf ("fpclassify (-LDBL_MIN-epsilon) failed: %d (%La)\n", printf ("fpclassify (-LDBL_MIN-epsilon) failed: %d (%La)\n",
fpclassify (ld), ld); fpclassify (v2), v2);
result = 1; result = 1;
} }
v2.d = ld = nextafterl (ld, -LDBL_MIN); v2 = nextafterl (v2, -LDBL_MIN);
if (fpclassify (ld) != FP_NORMAL) if (fpclassify (v2) != FP_NORMAL)
{ {
printf ("fpclassify (-LDBL_MIN-epsilon+epsilon) failed: %d (%La)\n", printf ("fpclassify (-LDBL_MIN-epsilon+epsilon) failed: %d (%La)\n",
fpclassify (ld), ld); fpclassify (v2), v2);
result = 1; result = 1;
} }
if (v1.ieee.mantissa0 != v2.ieee.mantissa0) if (v1 != v2)
{ {
printf ("-LDBL_MIN: mantissa0 differs: %8x vs %8x\n", printf ("-LDBL_MIN-epsilon+epsilon != -LDBL_MIN: %La vs %La\n", v2, v1);
v1.ieee.mantissa0, v2.ieee.mantissa0);
result = 1;
}
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
{
printf ("-LDBL_MIN: mantissa1 differs: %8x vs %8x\n",
v1.ieee.mantissa1, v2.ieee.mantissa1);
result = 1;
}
if (v1.ieee.exponent != v2.ieee.exponent)
{
printf ("-LDBL_MIN: exponent differs: %4x vs %4x\n",
v1.ieee.exponent, v2.ieee.exponent);
result = 1;
}
if (v1.ieee.negative != v2.ieee.negative)
{
printf ("-LDBL_MIN: negative differs: %d vs %d\n",
v1.ieee.negative, v2.ieee.negative);
result = 1; result = 1;
} }
ld = LDBL_MAX; v1 = LDBL_MAX;
if (fpclassify (ld) != FP_NORMAL) if (fpclassify (v1) != FP_NORMAL)
{ {
printf ("fpclassify (LDBL_MAX) failed: %d\n", fpclassify (ld)); printf ("fpclassify (LDBL_MAX) failed: %d (%La)\n",
fpclassify (v1), v1);
result = 1; result = 1;
} }
ld = nextafterl (ld, INFINITY); v2 = nextafterl (v1, INFINITY);
if (fpclassify (ld) != FP_INFINITE) if (fpclassify (v2) != FP_INFINITE)
{ {
printf ("fpclassify (LDBL_MAX+epsilon) failed: %d\n", fpclassify (ld)); printf ("fpclassify (LDBL_MAX+epsilon) failed: %d (%La)\n",
fpclassify (v2), v2);
result = 1; result = 1;
} }
ld = -LDBL_MAX; v1 = -LDBL_MAX;
if (fpclassify (ld) != FP_NORMAL) if (fpclassify (v1) != FP_NORMAL)
{ {
printf ("fpclassify (-LDBL_MAX) failed: %d\n", fpclassify (ld)); printf ("fpclassify (-LDBL_MAX) failed: %d (%La)\n",
fpclassify (v1), v1);
result = 1; result = 1;
} }
ld = nextafterl (ld, -INFINITY); v2 = nextafterl (v1, -INFINITY);
if (fpclassify (ld) != FP_INFINITE) if (fpclassify (v2) != FP_INFINITE)
{ {
printf ("fpclassify (-LDBL_MAX-epsilon) failed: %d\n", printf ("fpclassify (-LDBL_MAX-epsilon) failed: %d (%La)\n",
fpclassify (ld)); fpclassify (v2), v2);
result = 1; result = 1;
} }
v1.d = ld = 0.0625; v1 = 0.0625;
ld = nextafterl (ld, 0.0); v2 = nextafterl (v1, 0.0);
v2.d = ld = nextafterl (ld, 1.0); v2 = nextafterl (v2, 1.0);
if (v1.ieee.mantissa0 != v2.ieee.mantissa0) if (v1 != v2)
{ {
printf ("0.0625L down: mantissa0 differs: %8x vs %8x\n", printf ("0.0625L-epsilon+epsilon != 0.0625L: %La vs %La\n", v2, v1);
v1.ieee.mantissa0, v2.ieee.mantissa0);
result = 1;
}
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
{
printf ("0.0625L down: mantissa1 differs: %8x vs %8x\n",
v1.ieee.mantissa1, v2.ieee.mantissa1);
result = 1;
}
if (v1.ieee.exponent != v2.ieee.exponent)
{
printf ("0.0625L down: exponent differs: %4x vs %4x\n",
v1.ieee.exponent, v2.ieee.exponent);
result = 1;
}
if (v1.ieee.negative != v2.ieee.negative)
{
printf ("0.0625L down: negative differs: %d vs %d\n",
v1.ieee.negative, v2.ieee.negative);
result = 1; result = 1;
} }
v1.d = ld = 0.0625; v1 = 0.0625;
ld = nextafterl (ld, 1.0); v2 = nextafterl (v1, 1.0);
v2.d = ld = nextafterl (ld, 0.0); v2 = nextafterl (v2, 0.0);
if (v1.ieee.mantissa0 != v2.ieee.mantissa0) if (v1 != v2)
{ {
printf ("0.0625L up: mantissa0 differs: %8x vs %8x\n", printf ("0.0625L+epsilon-epsilon != 0.0625L: %La vs %La\n", v2, v1);
v1.ieee.mantissa0, v2.ieee.mantissa0);
result = 1;
}
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
{
printf ("0.0625L up: mantissa1 differs: %8x vs %8x\n",
v1.ieee.mantissa1, v2.ieee.mantissa1);
result = 1;
}
if (v1.ieee.exponent != v2.ieee.exponent)
{
printf ("0.0625L up: exponent differs: %4x vs %4x\n",
v1.ieee.exponent, v2.ieee.exponent);
result = 1;
}
if (v1.ieee.negative != v2.ieee.negative)
{
printf ("0.0625L up: negative differs: %d vs %d\n",
v1.ieee.negative, v2.ieee.negative);
result = 1; result = 1;
} }
v1.d = ld = -0.0625; v1 = -0.0625;
ld = nextafterl (ld, 0.0); v2 = nextafterl (v1, 0.0);
v2.d = ld = nextafterl (ld, -1.0); v2 = nextafterl (v2, -1.0);
if (v1.ieee.mantissa0 != v2.ieee.mantissa0) if (v1 != v2)
{ {
printf ("-0.0625L up: mantissa0 differs: %8x vs %8x\n", printf ("-0.0625L+epsilon-epsilon != -0.0625L: %La vs %La\n", v2, v1);
v1.ieee.mantissa0, v2.ieee.mantissa0);
result = 1;
}
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
{
printf ("-0.0625L up: mantissa1 differs: %8x vs %8x\n",
v1.ieee.mantissa1, v2.ieee.mantissa1);
result = 1;
}
if (v1.ieee.exponent != v2.ieee.exponent)
{
printf ("-0.0625L up: exponent differs: %4x vs %4x\n",
v1.ieee.exponent, v2.ieee.exponent);
result = 1;
}
if (v1.ieee.negative != v2.ieee.negative)
{
printf ("-0.0625L up: negative differs: %d vs %d\n",
v1.ieee.negative, v2.ieee.negative);
result = 1; result = 1;
} }
v1.d = ld = -0.0625; v1 = -0.0625;
ld = nextafterl (ld, -1.0); v2 = nextafterl (v1, -1.0);
v2.d = ld = nextafterl (ld, 0.0); v2 = nextafterl (v2, 0.0);
if (v1.ieee.mantissa0 != v2.ieee.mantissa0) if (v1 != v2)
{ {
printf ("-0.0625L down: mantissa0 differs: %8x vs %8x\n", printf ("-0.0625L-epsilon+epsilon != -0.0625L: %La vs %La\n", v2, v1);
v1.ieee.mantissa0, v2.ieee.mantissa0);
result = 1;
}
if (v1.ieee.mantissa1 != v2.ieee.mantissa1)
{
printf ("-0.0625L down: mantissa1 differs: %8x vs %8x\n",
v1.ieee.mantissa1, v2.ieee.mantissa1);
result = 1;
}
if (v1.ieee.exponent != v2.ieee.exponent)
{
printf ("-0.0625L down: exponent differs: %4x vs %4x\n",
v1.ieee.exponent, v2.ieee.exponent);
result = 1;
}
if (v1.ieee.negative != v2.ieee.negative)
{
printf ("-0.0625L down: negative differs: %d vs %d\n",
v1.ieee.negative, v2.ieee.negative);
result = 1; result = 1;
} }
v1.d = ld = 0.0; v1 = 0.0;
ld = nextafterl (ld, 1.0); v2 = nextafterl (v1, 1.0);
v2.d = nextafterl (ld, -1.0); v2 = nextafterl (v2, -1.0);
if (v1.ieee.mantissa0 != v2.ieee.mantissa0) if (v1 != v2)
{ {
printf ("0.0L up: mantissa0 differs: %8x vs %8x\n", printf ("0.0+epsilon-epsilon != 0.0L: %La vs %La\n", v2, v1);
v1.ieee.mantissa0, v2.ieee.mantissa0);
result = 1; result = 1;
} }
if (v1.ieee.mantissa1 != v2.ieee.mantissa1) if (signbit (v2))
{ {
printf ("0.0L up: mantissa1 differs: %8x vs %8x\n", printf ("0.0+epsilon-epsilon is negative\n");
v1.ieee.mantissa1, v2.ieee.mantissa1);
result = 1;
}
if (v1.ieee.exponent != v2.ieee.exponent)
{
printf ("0.0L up: exponent differs: %4x vs %4x\n",
v1.ieee.exponent, v2.ieee.exponent);
result = 1;
}
if (0 != v2.ieee.negative)
{
printf ("0.0L up: negative differs: 0 vs %d\n",
v2.ieee.negative);
result = 1; result = 1;
} }
v1.d = ld = 0.0; v1 = 0.0;
ld = nextafterl (ld, -1.0); v2 = nextafterl (v1, -1.0);
v2.d = nextafterl (ld, 1.0); v2 = nextafterl (v2, 1.0);
if (v1.ieee.mantissa0 != v2.ieee.mantissa0) if (v1 != v2)
{ {
printf ("0.0L down: mantissa0 differs: %8x vs %8x\n", printf ("0.0-epsilon+epsilon != 0.0L: %La vs %La\n", v2, v1);
v1.ieee.mantissa0, v2.ieee.mantissa0);
result = 1; result = 1;
} }
if (v1.ieee.mantissa1 != v2.ieee.mantissa1) if (!signbit (v2))
{ {
printf ("0.0L down: mantissa1 differs: %8x vs %8x\n", printf ("0.0-epsilon+epsilon is positive\n");
v1.ieee.mantissa1, v2.ieee.mantissa1);
result = 1;
}
if (v1.ieee.exponent != v2.ieee.exponent)
{
printf ("0.0L down: exponent differs: %4x vs %4x\n",
v1.ieee.exponent, v2.ieee.exponent);
result = 1;
}
if (1 != v2.ieee.negative)
{
printf ("0.0L down: negative differs: 1 vs %d\n",
v2.ieee.negative);
result = 1; result = 1;
} }

View File

@ -1,3 +1,7 @@
2013-19-04 Alan Modra <amodra@gmail.com>
* sysdeps/ia64/fpu/printf_fphex.c: Adjust for fpnum change.
2013-09-02 Mike Frysinger <vapier@gentoo.org> 2013-09-02 Mike Frysinger <vapier@gentoo.org>
* sysdeps/unix/sysv/linux/hppa/syscalls.list (fanotify_mark): New * sysdeps/unix/sysv/linux/hppa/syscalls.list (fanotify_mark): New

View File

@ -25,9 +25,11 @@ do { \
/* The "strange" 80 bit format on ia64 has an explicit \ /* The "strange" 80 bit format on ia64 has an explicit \
leading digit in the 64 bit mantissa. */ \ leading digit in the 64 bit mantissa. */ \
unsigned long long int num; \ unsigned long long int num; \
union ieee854_long_double u; \
u.d = fpnum.ldbl; \
\ \
num = (((unsigned long long int) fpnum.ldbl.ieee.mantissa0) << 32 \ num = (((unsigned long long int) u.ieee.mantissa0) << 32 \
| fpnum.ldbl.ieee.mantissa1); \ | u.ieee.mantissa1); \
\ \
zero_mantissa = num == 0; \ zero_mantissa = num == 0; \
\ \
@ -49,8 +51,8 @@ do { \
\ \
/* We have 3 bits from the mantissa in the leading nibble. \ /* We have 3 bits from the mantissa in the leading nibble. \
Therefore we are here using `IEEE854_LONG_DOUBLE_BIAS + 3'. */ \ Therefore we are here using `IEEE854_LONG_DOUBLE_BIAS + 3'. */ \
exponent = fpnum.ldbl.ieee.exponent; \ exponent = u.ieee.exponent; \
\ \
if (exponent == 0) \ if (exponent == 0) \
{ \ { \
if (zero_mantissa) \ if (zero_mantissa) \

View File

@ -332,8 +332,7 @@ ___printf_fp (FILE *fp,
int res; int res;
if (__isnanl (fpnum.ldbl)) if (__isnanl (fpnum.ldbl))
{ {
union ieee854_long_double u = { .d = fpnum.ldbl }; is_neg = signbit (fpnum.ldbl);
is_neg = u.ieee.negative != 0;
if (isupper (info->spec)) if (isupper (info->spec))
{ {
special = "NAN"; special = "NAN";

View File

@ -93,7 +93,7 @@ __printf_fphex (FILE *fp,
union union
{ {
union ieee754_double dbl; union ieee754_double dbl;
union ieee854_long_double ldbl; long double ldbl;
} }
fpnum; fpnum;
@ -162,12 +162,11 @@ __printf_fphex (FILE *fp,
#ifndef __NO_LONG_DOUBLE_MATH #ifndef __NO_LONG_DOUBLE_MATH
if (info->is_long_double && sizeof (long double) > sizeof (double)) 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. */ /* 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)) if (isupper (info->spec))
{ {
special = "NAN"; special = "NAN";
@ -181,8 +180,7 @@ __printf_fphex (FILE *fp,
} }
else else
{ {
int res = __isinfl (fpnum.ldbl.d); if (__isinfl (fpnum.ldbl))
if (res)
{ {
if (isupper (info->spec)) if (isupper (info->spec))
{ {
@ -194,11 +192,9 @@ __printf_fphex (FILE *fp,
special = "inf"; special = "inf";
wspecial = L"inf"; wspecial = L"inf";
} }
negative = res < 0;
} }
else
negative = signbit (fpnum.ldbl.d);
} }
negative = signbit (fpnum.ldbl);
} }
else else
#endif /* no long double */ #endif /* no long double */

View File

@ -103,7 +103,7 @@ __printf_size (FILE *fp, const struct printf_info *info,
union union
{ {
union ieee754_double dbl; union ieee754_double dbl;
union ieee854_long_double ldbl; long double ldbl;
} }
fpnum; fpnum;
const void *ptr = &fpnum; const void *ptr = &fpnum;
@ -123,25 +123,25 @@ __printf_size (FILE *fp, const struct printf_info *info,
#ifndef __NO_LONG_DOUBLE_MATH #ifndef __NO_LONG_DOUBLE_MATH
if (info->is_long_double && sizeof (long double) > sizeof (double)) 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. */ /* Check for special values: not a number or infinity. */
if (__isnanl (fpnum.ldbl.d)) if (__isnanl (fpnum.ldbl))
{ {
special = "nan"; special = "nan";
wspecial = L"nan"; wspecial = L"nan";
// fpnum_sign = 0; Already zero // fpnum_sign = 0; Already zero
} }
else if ((res = __isinfl (fpnum.ldbl.d))) else if ((res = __isinfl (fpnum.ldbl)))
{ {
fpnum_sign = res; fpnum_sign = res;
special = "inf"; special = "inf";
wspecial = L"inf"; wspecial = L"inf";
} }
else else
while (fpnum.ldbl.d >= divisor && tag[1] != '\0') while (fpnum.ldbl >= divisor && tag[1] != '\0')
{ {
fpnum.ldbl.d /= divisor; fpnum.ldbl /= divisor;
++tag; ++tag;
} }
} }

View File

@ -24,13 +24,15 @@ do { \
digits we use only the implicit digits for the number before \ digits we use only the implicit digits for the number before \
the decimal point. */ \ the decimal point. */ \
unsigned long long int num0, num1; \ unsigned long long int num0, num1; \
union ieee854_long_double u; \
u.d = fpnum.ldbl; \
\ \
assert (sizeof (long double) == 16); \ assert (sizeof (long double) == 16); \
\ \
num0 = (((unsigned long long int) fpnum.ldbl.ieee.mantissa0) << 32 \ num0 = (((unsigned long long int) u.ieee.mantissa0) << 32 \
| fpnum.ldbl.ieee.mantissa1); \ | u.ieee.mantissa1); \
num1 = (((unsigned long long int) fpnum.ldbl.ieee.mantissa2) << 32 \ num1 = (((unsigned long long int) u.ieee.mantissa2) << 32 \
| fpnum.ldbl.ieee.mantissa3); \ | u.ieee.mantissa3); \
\ \
zero_mantissa = (num0|num1) == 0; \ zero_mantissa = (num0|num1) == 0; \
\ \
@ -75,9 +77,9 @@ do { \
*--wnumstr = L'0'; \ *--wnumstr = L'0'; \
} \ } \
\ \
leading = fpnum.ldbl.ieee.exponent == 0 ? '0' : '1'; \ leading = u.ieee.exponent == 0 ? '0' : '1'; \
\ \
exponent = fpnum.ldbl.ieee.exponent; \ exponent = u.ieee.exponent; \
\ \
if (exponent == 0) \ if (exponent == 0) \
{ \ { \

View File

@ -27,14 +27,14 @@ do { \
unsigned long long hi, lo; \ unsigned long long hi, lo; \
int ediff; \ int ediff; \
union ibm_extended_long_double u; \ union ibm_extended_long_double u; \
u.ld = fpnum.ldbl.d; \ u.ld = fpnum.ldbl; \
\ \
assert (sizeof (long double) == 16); \ assert (sizeof (long double) == 16); \
\ \
lo = ((long long)u.d[1].ieee.mantissa0 << 32) | u.d[1].ieee.mantissa1; \ lo = ((long long)u.d[1].ieee.mantissa0 << 32) | u.d[1].ieee.mantissa1; \
hi = ((long long)u.d[0].ieee.mantissa0 << 32) | u.d[0].ieee.mantissa1; \ hi = ((long long)u.d[0].ieee.mantissa0 << 32) | u.d[0].ieee.mantissa1; \
lo <<= 7; /* pre-shift lo to match ieee854. */ \ lo <<= 7; /* pre-shift lo to match ieee854. */ \
/* If the lower double is not a denomal or zero then set the hidden \ /* If the lower double is not a denormal or zero then set the hidden \
53rd bit. */ \ 53rd bit. */ \
if (u.d[1].ieee.exponent != 0) \ if (u.d[1].ieee.exponent != 0) \
lo |= (1ULL << (52 + 7)); \ lo |= (1ULL << (52 + 7)); \

View File

@ -25,11 +25,13 @@ do { \
/* The "strange" 80 bit format on ix86 and m68k has an explicit \ /* The "strange" 80 bit format on ix86 and m68k has an explicit \
leading digit in the 64 bit mantissa. */ \ leading digit in the 64 bit mantissa. */ \
unsigned long long int num; \ unsigned long long int num; \
union ieee854_long_double u; \
u.d = fpnum.ldbl; \
\ \
assert (sizeof (long double) == 12); \ assert (sizeof (long double) == 12); \
\ \
num = (((unsigned long long int) fpnum.ldbl.ieee.mantissa0) << 32 \ num = (((unsigned long long int) u.ieee.mantissa0) << 32 \
| fpnum.ldbl.ieee.mantissa1); \ | u.ieee.mantissa1); \
\ \
zero_mantissa = num == 0; \ zero_mantissa = num == 0; \
\ \
@ -62,7 +64,7 @@ do { \
\ \
/* We have 3 bits from the mantissa in the leading nibble. \ /* We have 3 bits from the mantissa in the leading nibble. \
Therefore we are here using `IEEE854_LONG_DOUBLE_BIAS + 3'. */ \ Therefore we are here using `IEEE854_LONG_DOUBLE_BIAS + 3'. */ \
exponent = fpnum.ldbl.ieee.exponent; \ exponent = u.ieee.exponent; \
\ \
if (exponent == 0) \ if (exponent == 0) \
{ \ { \

View File

@ -25,10 +25,11 @@ do { \
/* The "strange" 80 bit format on ix86 and m68k has an explicit \ /* The "strange" 80 bit format on ix86 and m68k has an explicit \
leading digit in the 64 bit mantissa. */ \ leading digit in the 64 bit mantissa. */ \
unsigned long long int num; \ unsigned long long int num; \
union ieee854_long_double u; \
u.d = fpnum.ldbl; \
\ \
\ num = (((unsigned long long int) u.ieee.mantissa0) << 32 \
num = (((unsigned long long int) fpnum.ldbl.ieee.mantissa0) << 32 \ | u.ieee.mantissa1); \
| fpnum.ldbl.ieee.mantissa1); \
\ \
zero_mantissa = num == 0; \ zero_mantissa = num == 0; \
\ \
@ -61,7 +62,7 @@ do { \
\ \
/* We have 3 bits from the mantissa in the leading nibble. \ /* We have 3 bits from the mantissa in the leading nibble. \
Therefore we are here using `IEEE854_LONG_DOUBLE_BIAS + 3'. */ \ Therefore we are here using `IEEE854_LONG_DOUBLE_BIAS + 3'. */ \
exponent = fpnum.ldbl.ieee.exponent; \ exponent = u.ieee.exponent; \
\ \
if (exponent == 0) \ if (exponent == 0) \
{ \ { \