[gnumeric] COT: workaround for gcc/glibc bug.



commit 2b767664aabd3b6bc67d6690a2539d6f9fa217f9
Author: Morten Welinder <terra gnome org>
Date:   Tue Nov 12 14:22:50 2013 -0500

    COT: workaround for gcc/glibc bug.
    
    Using both sin and cos causes sincos to be used and it stinks.

 ChangeLog      |    4 ++++
 src/mathfunc.c |   21 ++++++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1d743c6..32a9d26 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-11-12  Morten Welinder  <terra gnome org>
+
+       * src/mathfunc.c (gnm_cot): Work around gcc/glibc bug.
+
 2013-11-06  Morten Welinder  <terra gnome org>
 
        * src/mathfunc.c (gnm_acoth): Improve accuracy for |x| near 1.
diff --git a/src/mathfunc.c b/src/mathfunc.c
index a8156a3..10e58ff 100644
--- a/src/mathfunc.c
+++ b/src/mathfunc.c
@@ -93,6 +93,18 @@ mathfunc_init (void)
        /* Nothing, for the time being.  */
 }
 
+static gnm_float
+gnm_cot_helper (volatile gnm_float *x)
+{
+       gnm_float s = gnm_sin (*x);
+       gnm_float c = gnm_cos (*x);
+
+       if (s == 0)
+               return gnm_nan;
+       else
+               return c / s;
+}
+
 /**
  * gnm_cot:
  * @x: an angle in radians
@@ -102,13 +114,8 @@ mathfunc_init (void)
 gnm_float
 gnm_cot (gnm_float x)
 {
-       gnm_float s = gnm_sin (x);
-       gnm_float c = gnm_cos (x);
-
-       if (s == 0)
-               return gnm_nan;
-       else
-               return c / s;
+       /* See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59089 */
+       return gnm_cot_helper (&x);
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]