1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
This patch workarounds a GCC bug on PowerPC 32-bit, converting 0 from
int to float might return -0.0. Upstream consider the bug fixed, as it
doesn't affect GCC built for PPC970/Power4 or later. It is clearly
something we don't want in Debian.
2012-07-22 Aurelien Jarno <aurelien@aurel32.net>
* sysdeps/ieee754/dbl-64/s_logb.c (__logb): avoid logb_downward (0.0)
return -0.0.
* sysdeps/ieee754/flt-32/s_logbf.c (__logbf): Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_logbl.c (__logbl): Likewise.
diff --git a/sysdeps/ieee754/dbl-64/s_logb.c b/sysdeps/ieee754/dbl-64/s_logb.c
index 17aa94b..d7fd59d 100644
--- a/sysdeps/ieee754/dbl-64/s_logb.c
+++ b/sysdeps/ieee754/dbl-64/s_logb.c
@@ -23,6 +23,7 @@ double
__logb (double x)
{
int32_t lx, ix, rix;
+ double ret;
EXTRACT_WORDS (ix, lx, x);
ix &= 0x7fffffff; /* high |x| */
@@ -41,7 +42,9 @@ __logb (double x)
ma = __builtin_clz (ix);
rix -= ma - 12;
}
- return (double) (rix - 1023);
+ ret = (double) (rix - 1023);
+ /* The test is to avoid logb_downward (0.0) == -0.0. */
+ return ret == -0.0 ? 0.0 : ret;
}
weak_alias (__logb, logb)
#ifdef NO_LONG_DOUBLE
diff --git a/sysdeps/ieee754/flt-32/s_logbf.c b/sysdeps/ieee754/flt-32/s_logbf.c
index e2b3aaa..1dce251 100644
--- a/sysdeps/ieee754/flt-32/s_logbf.c
+++ b/sysdeps/ieee754/flt-32/s_logbf.c
@@ -20,6 +20,7 @@ float
__logbf (float x)
{
int32_t ix, rix;
+ float ret;
GET_FLOAT_WORD (ix, x);
ix &= 0x7fffffff; /* high |x| */
@@ -33,6 +34,8 @@ __logbf (float x)
though it were normalized. */
rix -= __builtin_clz (ix) - 9;
}
- return (float) (rix - 127);
+ ret = (float) (rix - 127);
+ /* The test is to avoid logb_downward (0.0) == -0.0. */
+ return ret == -0.0 ? 0.0 : ret;
}
weak_alias (__logbf, logbf)
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_logbl.c b/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
index 92ce2c1..db030a7 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
@@ -27,6 +27,7 @@ long double
{
int64_t hx, rhx;
double xhi;
+ long double ret;
xhi = ldbl_high (x);
EXTRACT_WORDS64 (hx, xhi);
@@ -40,7 +41,9 @@ __logbl (long double x)
though it were normalized. */
rhx -= __builtin_clzll (hx) - 12;
}
- return (long double) (rhx - 1023);
+ ret = (long double) (rhx - 1023);
+ /* The test is to avoid logb_downward (0.0) == -0.0. */
+ return ret == -0.0 ? 0.0 : ret;
}
#ifndef __logbl
long_double_symbol (libm, __logbl, logbl);
|