]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
PowerPC: Fix for POWER7 sinf/cosf
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Fri, 1 Jun 2012 13:10:18 +0000 (10:10 -0300)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Fri, 1 Jun 2012 13:10:18 +0000 (10:10 -0300)
This patch fixes some sinf/cosf calculations that generated unexpected
underflows exceptions.

ChangeLog
sysdeps/powerpc/fpu/k_cosf.c
sysdeps/powerpc/fpu/k_sinf.c

index 6cb9f2d30dddf4e956d83cfc2a6c39c92a422272..009e75ed17cfa11d4884ccc5b952c7a5919a4c0d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-01  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
+
+       * sysdeps/powerpc/fpu/k_cosf.c: Fix underflow generation.
+       * sysdeps/powerpc/fpu/k_sinf.c: Likewise.
+
 2012-05-31  H.J. Lu  <hongjiu.lu@intel.com>
 
        [BZ #14117]
index e2571d6802d5de3b6dc9006f9035dca1bab40db6..d5668e31274b998984d5837d442ce9f0ae5d61c1 100644 (file)
@@ -18,6 +18,7 @@
    not, see <http://www.gnu.org/licenses/>.  */
 
 #include <math.h>
+#include <fenv.h>
 #include <math_private.h>
 
 static const float twom27   = 7.4505806e-09;
@@ -40,8 +41,8 @@ __kernel_cosf (float x, float y)
   ix = __builtin_fabsf (x);
   if (ix < twom27)
     {                          /* |x| < 2**-27 */
-      if (x == 0.0)
-       return one;
+      __feraiseexcept (FE_INEXACT);
+      return one;
     }
   z = x * x;
   r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * C6)))));
index ab4561e65ea06712fe9ff9639cc9f3e063d1f64e..c8fb8ef81ce61b509394f0942f7be2b256f79353 100644 (file)
@@ -18,6 +18,7 @@
    not, see <http://www.gnu.org/licenses/>.  */
 
 #include <math.h>
+#include <fenv.h>
 #include <math_private.h>
 
 
@@ -39,8 +40,8 @@ __kernel_sinf (float x, float y, int iy)
   ix = __builtin_fabsf (x);
   if (ix < twom27)
     {                          /* |x| < 2**-27 */
-      if (x == 0.0)
-       return x;
+      __feraiseexcept (FE_INEXACT);
+      return x;
     }
   z = x * x;
   v = z * x;