This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.24-80-g4482ff2


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  4482ff226e4b286ab171f3c5841ae1f7e61780cd (commit)
       via  01ee387015a2075c45a4e1ad45d39e50b5a6d40b (commit)
       via  281f5073e5a6d2cd3733acd9c773c8c6340468c4 (commit)
       via  466929465e881a2d09df39097d026195fe2f26ed (commit)
      from  d3bf0bade622ccc51da2f66cea967101b6cc33fb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=4482ff226e4b286ab171f3c5841ae1f7e61780cd

commit 4482ff226e4b286ab171f3c5841ae1f7e61780cd
Author: Paul E. Murphy <murphyp@linux.vnet.ibm.com>
Date:   Mon Aug 8 15:58:28 2016 -0500

    Merge common usage of mul_split function
    
    A number of files share identical code for the
    mul_split function.
    
    This moves the duplicated function mul_split into its
    own header, and refactors the fma usage into a single
    selection macro.  Likewise, mul_split when used by a
    long double implementation is renamed mul_splitl for
    clarity.

diff --git a/ChangeLog b/ChangeLog
index a9eb75d..0b4b5c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
 2016-08-19  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
 
+	* sysdeps/ieee754/ldbl-128/gamma_productl.c:
+	(mul_split) Remove, rename as mul_splitl, remove
+	redundant float.h include, and include via mul_splitl.h
+
+	* sysdeps/ieee754/ldbl-128/lgamma_productl.c: Likewise.
+	* sysdeps/ieee754/ldbl-128/x2y2m1l.c: Likewise.
+	* sysdeps/ieee754/ldbl-96/gamma_product.c: Likewise.
+	* sysdeps/ieee754/ldbl-96/lgamma_product.c: Likewise.
+	* sysdeps/ieee754/ldbl-96/x2y2m1.c: Likewise.
+
+	* math/mul_splitl.h: New file.
+
+	* sysdeps/ieee754/dbl-64/gamma_product.c (mul_split):
+	Move into mul_split.h, and remove redundant float.h include.
+
+	* sysdeps/ieee754/dbl-64/lgamma_product.c: Likewise.
+	* sysdeps/ieee754/dbl-64/x2y2m1.c: Likewise.
+	* sysdeps/ieee754/ldbl-128ibm/s_fmal.c: Likewise.
+	* sysdeps/ieee754/ldbl-128ibm/x2y2m1.c: Likewise.
+
+	* math/mul_split.h: New file.
+
+2016-08-19  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
+
 	* math/Makefile (libm-gen-calls): Move
 	s_cacos, s_cacosh, s_ccos, s_ccosh from ...
 	(libm-calls): Remove above.
diff --git a/math/mul_split.h b/math/mul_split.h
new file mode 100644
index 0000000..85038dc
--- /dev/null
+++ b/math/mul_split.h
@@ -0,0 +1,50 @@
+/* Compute full X * Y for double type.
+   Copyright (C) 2013-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _MUL_SPLIT_H
+#define _MUL_SPLIT_H
+
+#include <float.h>
+
+/* Calculate X * Y exactly and store the result in *HI + *LO.  It is
+   given that the values are small enough that no overflow occurs and
+   large enough (or zero) that no underflow occurs.  */
+
+static void
+mul_split (double *hi, double *lo, double x, double y)
+{
+#ifdef __FP_FAST_FMA
+  /* Fast built-in fused multiply-add.  */
+  *hi = x * y;
+  *lo = __builtin_fma (x, y, -*hi);
+#else
+  /* Apply Dekker's algorithm.  */
+  *hi = x * y;
+# define C ((1 << (DBL_MANT_DIG + 1) / 2) + 1)
+  double x1 = x * C;
+  double y1 = y * C;
+# undef C
+  x1 = (x - x1) + x1;
+  y1 = (y - y1) + y1;
+  double x2 = x - x1;
+  double y2 = y - y1;
+  *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
+#endif
+}
+
+#endif /* _MUL_SPLIT_H */
diff --git a/sysdeps/ieee754/dbl-64/gamma_product.c b/math/mul_splitl.h
similarity index 50%
copy from sysdeps/ieee754/dbl-64/gamma_product.c
copy to math/mul_splitl.h
index 7ae144a..8a39ce0 100644
--- a/sysdeps/ieee754/dbl-64/gamma_product.c
+++ b/math/mul_splitl.h
@@ -1,4 +1,4 @@
-/* Compute a product of X, X+1, ..., with an error estimate.
+/* Compute full X * Y for long double type.
    Copyright (C) 2013-2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,60 +16,35 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <math.h>
-#include <math_private.h>
+#ifndef _MUL_SPLITL_H
+#define _MUL_SPLITL_H
+
 #include <float.h>
 
 /* Calculate X * Y exactly and store the result in *HI + *LO.  It is
    given that the values are small enough that no overflow occurs and
    large enough (or zero) that no underflow occurs.  */
 
-static void
-mul_split (double *hi, double *lo, double x, double y)
+static inline void
+mul_splitl (long double *hi, long double *lo, long double x, long double y)
 {
-#ifdef __FP_FAST_FMA
+#ifdef __FP_FAST_FMAL
   /* Fast built-in fused multiply-add.  */
   *hi = x * y;
-  *lo = __builtin_fma (x, y, -*hi);
-#elif defined FP_FAST_FMA
-  /* Fast library fused multiply-add, compiler before GCC 4.6.  */
-  *hi = x * y;
-  *lo = __fma (x, y, -*hi);
+  *lo = __builtin_fmal (x, y, -*hi);
 #else
   /* Apply Dekker's algorithm.  */
   *hi = x * y;
-# define C ((1 << (DBL_MANT_DIG + 1) / 2) + 1)
-  double x1 = x * C;
-  double y1 = y * C;
+# define C ((1LL << (LDBL_MANT_DIG + 1) / 2) + 1)
+  long double x1 = x * C;
+  long double y1 = y * C;
 # undef C
   x1 = (x - x1) + x1;
   y1 = (y - y1) + y1;
-  double x2 = x - x1;
-  double y2 = y - y1;
+  long double x2 = x - x1;
+  long double y2 = y - y1;
   *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
 #endif
 }
 
-/* Compute the product of X + X_EPS, X + X_EPS + 1, ..., X + X_EPS + N
-   - 1, in the form R * (1 + *EPS) where the return value R is an
-   approximation to the product and *EPS is set to indicate the
-   approximate error in the return value.  X is such that all the
-   values X + 1, ..., X + N - 1 are exactly representable, and X_EPS /
-   X is small enough that factors quadratic in it can be
-   neglected.  */
-
-double
-__gamma_product (double x, double x_eps, int n, double *eps)
-{
-  SET_RESTORE_ROUND (FE_TONEAREST);
-  double ret = x;
-  *eps = x_eps / x;
-  for (int i = 1; i < n; i++)
-    {
-      *eps += x_eps / (x + i);
-      double lo;
-      mul_split (&ret, &lo, ret, x + i);
-      *eps += lo / ret;
-    }
-  return ret;
-}
+#endif /* _MUL_SPLITL_H */
diff --git a/sysdeps/ieee754/dbl-64/gamma_product.c b/sysdeps/ieee754/dbl-64/gamma_product.c
index 7ae144a..51407b1 100644
--- a/sysdeps/ieee754/dbl-64/gamma_product.c
+++ b/sysdeps/ieee754/dbl-64/gamma_product.c
@@ -18,37 +18,7 @@
 
 #include <math.h>
 #include <math_private.h>
-#include <float.h>
-
-/* Calculate X * Y exactly and store the result in *HI + *LO.  It is
-   given that the values are small enough that no overflow occurs and
-   large enough (or zero) that no underflow occurs.  */
-
-static void
-mul_split (double *hi, double *lo, double x, double y)
-{
-#ifdef __FP_FAST_FMA
-  /* Fast built-in fused multiply-add.  */
-  *hi = x * y;
-  *lo = __builtin_fma (x, y, -*hi);
-#elif defined FP_FAST_FMA
-  /* Fast library fused multiply-add, compiler before GCC 4.6.  */
-  *hi = x * y;
-  *lo = __fma (x, y, -*hi);
-#else
-  /* Apply Dekker's algorithm.  */
-  *hi = x * y;
-# define C ((1 << (DBL_MANT_DIG + 1) / 2) + 1)
-  double x1 = x * C;
-  double y1 = y * C;
-# undef C
-  x1 = (x - x1) + x1;
-  y1 = (y - y1) + y1;
-  double x2 = x - x1;
-  double y2 = y - y1;
-  *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
-#endif
-}
+#include <mul_split.h>
 
 /* Compute the product of X + X_EPS, X + X_EPS + 1, ..., X + X_EPS + N
    - 1, in the form R * (1 + *EPS) where the return value R is an
diff --git a/sysdeps/ieee754/dbl-64/lgamma_product.c b/sysdeps/ieee754/dbl-64/lgamma_product.c
index d956575..fa89337 100644
--- a/sysdeps/ieee754/dbl-64/lgamma_product.c
+++ b/sysdeps/ieee754/dbl-64/lgamma_product.c
@@ -18,37 +18,7 @@
 
 #include <math.h>
 #include <math_private.h>
-#include <float.h>
-
-/* Calculate X * Y exactly and store the result in *HI + *LO.  It is
-   given that the values are small enough that no overflow occurs and
-   large enough (or zero) that no underflow occurs.  */
-
-static void
-mul_split (double *hi, double *lo, double x, double y)
-{
-#ifdef __FP_FAST_FMA
-  /* Fast built-in fused multiply-add.  */
-  *hi = x * y;
-  *lo = __builtin_fma (x, y, -*hi);
-#elif defined FP_FAST_FMA
-  /* Fast library fused multiply-add, compiler before GCC 4.6.  */
-  *hi = x * y;
-  *lo = __fma (x, y, -*hi);
-#else
-  /* Apply Dekker's algorithm.  */
-  *hi = x * y;
-# define C ((1 << (DBL_MANT_DIG + 1) / 2) + 1)
-  double x1 = x * C;
-  double y1 = y * C;
-# undef C
-  x1 = (x - x1) + x1;
-  y1 = (y - y1) + y1;
-  double x2 = x - x1;
-  double y2 = y - y1;
-  *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
-#endif
-}
+#include <mul_split.h>
 
 /* Compute the product of 1 + (T / (X + X_EPS)), 1 + (T / (X + X_EPS +
    1)), ..., 1 + (T / (X + X_EPS + N - 1)), minus 1.  X is such that
diff --git a/sysdeps/ieee754/dbl-64/x2y2m1.c b/sysdeps/ieee754/dbl-64/x2y2m1.c
index 9607888..7505215 100644
--- a/sysdeps/ieee754/dbl-64/x2y2m1.c
+++ b/sysdeps/ieee754/dbl-64/x2y2m1.c
@@ -18,7 +18,7 @@
 
 #include <math.h>
 #include <math_private.h>
-#include <float.h>
+#include <mul_split.h>
 #include <stdlib.h>
 
 /* Calculate X + Y exactly and store the result in *HI + *LO.  It is
@@ -33,36 +33,6 @@ add_split (double *hi, double *lo, double x, double y)
   *lo = (x - *hi) + y;
 }
 
-/* Calculate X * Y exactly and store the result in *HI + *LO.  It is
-   given that the values are small enough that no overflow occurs and
-   large enough (or zero) that no underflow occurs.  */
-
-static void
-mul_split (double *hi, double *lo, double x, double y)
-{
-#ifdef __FP_FAST_FMA
-  /* Fast built-in fused multiply-add.  */
-  *hi = x * y;
-  *lo = __builtin_fma (x, y, -*hi);
-#elif defined FP_FAST_FMA
-  /* Fast library fused multiply-add, compiler before GCC 4.6.  */
-  *hi = x * y;
-  *lo = __fma (x, y, -*hi);
-#else
-  /* Apply Dekker's algorithm.  */
-  *hi = x * y;
-# define C ((1 << (DBL_MANT_DIG + 1) / 2) + 1)
-  double x1 = x * C;
-  double y1 = y * C;
-# undef C
-  x1 = (x - x1) + x1;
-  y1 = (y - y1) + y1;
-  double x2 = x - x1;
-  double y2 = y - y1;
-  *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
-#endif
-}
-
 /* Compare absolute values of floating-point values pointed to by P
    and Q for qsort.  */
 
diff --git a/sysdeps/ieee754/ldbl-128/gamma_productl.c b/sysdeps/ieee754/ldbl-128/gamma_productl.c
index 849b57d..8ad0452 100644
--- a/sysdeps/ieee754/ldbl-128/gamma_productl.c
+++ b/sysdeps/ieee754/ldbl-128/gamma_productl.c
@@ -18,37 +18,7 @@
 
 #include <math.h>
 #include <math_private.h>
-#include <float.h>
-
-/* Calculate X * Y exactly and store the result in *HI + *LO.  It is
-   given that the values are small enough that no overflow occurs and
-   large enough (or zero) that no underflow occurs.  */
-
-static inline void
-mul_split (long double *hi, long double *lo, long double x, long double y)
-{
-#ifdef __FP_FAST_FMAL
-  /* Fast built-in fused multiply-add.  */
-  *hi = x * y;
-  *lo = __builtin_fmal (x, y, -*hi);
-#elif defined FP_FAST_FMAL
-  /* Fast library fused multiply-add, compiler before GCC 4.6.  */
-  *hi = x * y;
-  *lo = __fmal (x, y, -*hi);
-#else
-  /* Apply Dekker's algorithm.  */
-  *hi = x * y;
-# define C ((1LL << (LDBL_MANT_DIG + 1) / 2) + 1)
-  long double x1 = x * C;
-  long double y1 = y * C;
-# undef C
-  x1 = (x - x1) + x1;
-  y1 = (y - y1) + y1;
-  long double x2 = x - x1;
-  long double y2 = y - y1;
-  *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
-#endif
-}
+#include <mul_splitl.h>
 
 /* Compute the product of X + X_EPS, X + X_EPS + 1, ..., X + X_EPS + N
    - 1, in the form R * (1 + *EPS) where the return value R is an
@@ -68,7 +38,7 @@ __gamma_productl (long double x, long double x_eps, int n, long double *eps)
     {
       *eps += x_eps / (x + i);
       long double lo;
-      mul_split (&ret, &lo, ret, x + i);
+      mul_splitl (&ret, &lo, ret, x + i);
       *eps += lo / ret;
     }
   return ret;
diff --git a/sysdeps/ieee754/ldbl-128/lgamma_productl.c b/sysdeps/ieee754/ldbl-128/lgamma_productl.c
index de67cbe..9aa0137 100644
--- a/sysdeps/ieee754/ldbl-128/lgamma_productl.c
+++ b/sysdeps/ieee754/ldbl-128/lgamma_productl.c
@@ -18,37 +18,7 @@
 
 #include <math.h>
 #include <math_private.h>
-#include <float.h>
-
-/* Calculate X * Y exactly and store the result in *HI + *LO.  It is
-   given that the values are small enough that no overflow occurs and
-   large enough (or zero) that no underflow occurs.  */
-
-static void
-mul_split (long double *hi, long double *lo, long double x, long double y)
-{
-#ifdef __FP_FAST_FMAL
-  /* Fast built-in fused multiply-add.  */
-  *hi = x * y;
-  *lo = __builtin_fmal (x, y, -*hi);
-#elif defined FP_FAST_FMAL
-  /* Fast library fused multiply-add, compiler before GCC 4.6.  */
-  *hi = x * y;
-  *lo = __fmal (x, y, -*hi);
-#else
-  /* Apply Dekker's algorithm.  */
-  *hi = x * y;
-# define C ((1LL << (LDBL_MANT_DIG + 1) / 2) + 1)
-  long double x1 = x * C;
-  long double y1 = y * C;
-# undef C
-  x1 = (x - x1) + x1;
-  y1 = (y - y1) + y1;
-  long double x2 = x - x1;
-  long double y2 = y - y1;
-  *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
-#endif
-}
+#include <mul_splitl.h>
 
 /* Compute the product of 1 + (T / (X + X_EPS)), 1 + (T / (X + X_EPS +
    1)), ..., 1 + (T / (X + X_EPS + N - 1)), minus 1.  X is such that
@@ -65,11 +35,11 @@ __lgamma_productl (long double t, long double x, long double x_eps, int n)
       long double xi = x + i;
       long double quot = t / xi;
       long double mhi, mlo;
-      mul_split (&mhi, &mlo, quot, xi);
+      mul_splitl (&mhi, &mlo, quot, xi);
       long double quot_lo = (t - mhi - mlo) / xi - t * x_eps / (xi * xi);
       /* We want (1 + RET + RET_EPS) * (1 + QUOT + QUOT_LO) - 1.  */
       long double rhi, rlo;
-      mul_split (&rhi, &rlo, ret, quot);
+      mul_splitl (&rhi, &rlo, ret, quot);
       long double rpq = ret + quot;
       long double rpq_eps = (ret - rpq) + quot;
       long double nret = rpq + rhi;
diff --git a/sysdeps/ieee754/ldbl-128/x2y2m1l.c b/sysdeps/ieee754/ldbl-128/x2y2m1l.c
index 733742d..4e97885 100644
--- a/sysdeps/ieee754/ldbl-128/x2y2m1l.c
+++ b/sysdeps/ieee754/ldbl-128/x2y2m1l.c
@@ -18,9 +18,10 @@
 
 #include <math.h>
 #include <math_private.h>
-#include <float.h>
+#include <mul_splitl.h>
 #include <stdlib.h>
 
+
 /* Calculate X + Y exactly and store the result in *HI + *LO.  It is
    given that |X| >= |Y| and the values are small enough that no
    overflow occurs.  */
@@ -33,36 +34,6 @@ add_split (long double *hi, long double *lo, long double x, long double y)
   *lo = (x - *hi) + y;
 }
 
-/* Calculate X * Y exactly and store the result in *HI + *LO.  It is
-   given that the values are small enough that no overflow occurs and
-   large enough (or zero) that no underflow occurs.  */
-
-static inline void
-mul_split (long double *hi, long double *lo, long double x, long double y)
-{
-#ifdef __FP_FAST_FMAL
-  /* Fast built-in fused multiply-add.  */
-  *hi = x * y;
-  *lo = __builtin_fmal (x, y, -*hi);
-#elif defined FP_FAST_FMAL
-  /* Fast library fused multiply-add, compiler before GCC 4.6.  */
-  *hi = x * y;
-  *lo = __fmal (x, y, -*hi);
-#else
-  /* Apply Dekker's algorithm.  */
-  *hi = x * y;
-# define C ((1LL << (LDBL_MANT_DIG + 1) / 2) + 1)
-  long double x1 = x * C;
-  long double y1 = y * C;
-# undef C
-  x1 = (x - x1) + x1;
-  y1 = (y - y1) + y1;
-  long double x2 = x - x1;
-  long double y2 = y - y1;
-  *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
-#endif
-}
-
 /* Compare absolute values of floating-point values pointed to by P
    and Q for qsort.  */
 
@@ -88,8 +59,8 @@ __x2y2m1l (long double x, long double y)
 {
   long double vals[5];
   SET_RESTORE_ROUNDL (FE_TONEAREST);
-  mul_split (&vals[1], &vals[0], x, x);
-  mul_split (&vals[3], &vals[2], y, y);
+  mul_splitl (&vals[1], &vals[0], x, x);
+  mul_splitl (&vals[3], &vals[2], y, y);
   vals[4] = -1.0L;
   qsort (vals, 5, sizeof (long double), compare);
   /* Add up the values so that each element of VALS has absolute value
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_fmal.c b/sysdeps/ieee754/ldbl-128ibm/s_fmal.c
index 177a048..1405763 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_fmal.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_fmal.c
@@ -22,6 +22,7 @@
 #include <math.h>
 #include <math_private.h>
 #include <math_ldbl_opt.h>
+#include <mul_split.h>
 #include <stdlib.h>
 
 /* Calculate X + Y exactly and store the result in *HI + *LO.  It is
@@ -36,32 +37,6 @@ add_split (double *hi, double *lo, double x, double y)
   *lo = (x - *hi) + y;
 }
 
-/* Calculate X * Y exactly and store the result in *HI + *LO.  It is
-   given that the values are small enough that no overflow occurs and
-   large enough (or zero) that no underflow occurs.  */
-
-static void
-mul_split (double *hi, double *lo, double x, double y)
-{
-#ifdef __FP_FAST_FMA
-  /* Fast built-in fused multiply-add.  */
-  *hi = x * y;
-  *lo = __builtin_fma (x, y, -*hi);
-#else
-  /* Apply Dekker's algorithm.  */
-  *hi = x * y;
-# define C ((1 << (DBL_MANT_DIG + 1) / 2) + 1)
-  double x1 = x * C;
-  double y1 = y * C;
-# undef C
-  x1 = (x - x1) + x1;
-  y1 = (y - y1) + y1;
-  double x2 = x - x1;
-  double y2 = y - y1;
-  *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
-#endif
-}
-
 /* Value with extended range, used in intermediate computations.  */
 typedef struct
 {
diff --git a/sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c b/sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c
index da2e929..a8b4895 100644
--- a/sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c
+++ b/sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c
@@ -18,7 +18,7 @@
 
 #include <math.h>
 #include <math_private.h>
-#include <float.h>
+#include <mul_split.h>
 #include <stdlib.h>
 
 /* Calculate X + Y exactly and store the result in *HI + *LO.  It is
@@ -33,36 +33,6 @@ add_split (double *hi, double *lo, double x, double y)
   *lo = (x - *hi) + y;
 }
 
-/* Calculate X * Y exactly and store the result in *HI + *LO.  It is
-   given that the values are small enough that no overflow occurs and
-   large enough (or zero) that no underflow occurs.  */
-
-static inline void
-mul_split (double *hi, double *lo, double x, double y)
-{
-#ifdef __FP_FAST_FMA
-  /* Fast built-in fused multiply-add.  */
-  *hi = x * y;
-  *lo = __builtin_fma (x, y, -*hi);
-#elif defined FP_FAST_FMA
-  /* Fast library fused multiply-add, compiler before GCC 4.6.  */
-  *hi = x * y;
-  *lo = __fma (x, y, -*hi);
-#else
-  /* Apply Dekker's algorithm.  */
-  *hi = x * y;
-# define C ((1 << (DBL_MANT_DIG + 1) / 2) + 1)
-  double x1 = x * C;
-  double y1 = y * C;
-# undef C
-  x1 = (x - x1) + x1;
-  y1 = (y - y1) + y1;
-  double x2 = x - x1;
-  double y2 = y - y1;
-  *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
-#endif
-}
-
 /* Compare absolute values of floating-point values pointed to by P
    and Q for qsort.  */
 
diff --git a/sysdeps/ieee754/ldbl-96/gamma_productl.c b/sysdeps/ieee754/ldbl-96/gamma_productl.c
index 849b57d..8ad0452 100644
--- a/sysdeps/ieee754/ldbl-96/gamma_productl.c
+++ b/sysdeps/ieee754/ldbl-96/gamma_productl.c
@@ -18,37 +18,7 @@
 
 #include <math.h>
 #include <math_private.h>
-#include <float.h>
-
-/* Calculate X * Y exactly and store the result in *HI + *LO.  It is
-   given that the values are small enough that no overflow occurs and
-   large enough (or zero) that no underflow occurs.  */
-
-static inline void
-mul_split (long double *hi, long double *lo, long double x, long double y)
-{
-#ifdef __FP_FAST_FMAL
-  /* Fast built-in fused multiply-add.  */
-  *hi = x * y;
-  *lo = __builtin_fmal (x, y, -*hi);
-#elif defined FP_FAST_FMAL
-  /* Fast library fused multiply-add, compiler before GCC 4.6.  */
-  *hi = x * y;
-  *lo = __fmal (x, y, -*hi);
-#else
-  /* Apply Dekker's algorithm.  */
-  *hi = x * y;
-# define C ((1LL << (LDBL_MANT_DIG + 1) / 2) + 1)
-  long double x1 = x * C;
-  long double y1 = y * C;
-# undef C
-  x1 = (x - x1) + x1;
-  y1 = (y - y1) + y1;
-  long double x2 = x - x1;
-  long double y2 = y - y1;
-  *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
-#endif
-}
+#include <mul_splitl.h>
 
 /* Compute the product of X + X_EPS, X + X_EPS + 1, ..., X + X_EPS + N
    - 1, in the form R * (1 + *EPS) where the return value R is an
@@ -68,7 +38,7 @@ __gamma_productl (long double x, long double x_eps, int n, long double *eps)
     {
       *eps += x_eps / (x + i);
       long double lo;
-      mul_split (&ret, &lo, ret, x + i);
+      mul_splitl (&ret, &lo, ret, x + i);
       *eps += lo / ret;
     }
   return ret;
diff --git a/sysdeps/ieee754/ldbl-96/lgamma_productl.c b/sysdeps/ieee754/ldbl-96/lgamma_productl.c
index de67cbe..9aa0137 100644
--- a/sysdeps/ieee754/ldbl-96/lgamma_productl.c
+++ b/sysdeps/ieee754/ldbl-96/lgamma_productl.c
@@ -18,37 +18,7 @@
 
 #include <math.h>
 #include <math_private.h>
-#include <float.h>
-
-/* Calculate X * Y exactly and store the result in *HI + *LO.  It is
-   given that the values are small enough that no overflow occurs and
-   large enough (or zero) that no underflow occurs.  */
-
-static void
-mul_split (long double *hi, long double *lo, long double x, long double y)
-{
-#ifdef __FP_FAST_FMAL
-  /* Fast built-in fused multiply-add.  */
-  *hi = x * y;
-  *lo = __builtin_fmal (x, y, -*hi);
-#elif defined FP_FAST_FMAL
-  /* Fast library fused multiply-add, compiler before GCC 4.6.  */
-  *hi = x * y;
-  *lo = __fmal (x, y, -*hi);
-#else
-  /* Apply Dekker's algorithm.  */
-  *hi = x * y;
-# define C ((1LL << (LDBL_MANT_DIG + 1) / 2) + 1)
-  long double x1 = x * C;
-  long double y1 = y * C;
-# undef C
-  x1 = (x - x1) + x1;
-  y1 = (y - y1) + y1;
-  long double x2 = x - x1;
-  long double y2 = y - y1;
-  *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
-#endif
-}
+#include <mul_splitl.h>
 
 /* Compute the product of 1 + (T / (X + X_EPS)), 1 + (T / (X + X_EPS +
    1)), ..., 1 + (T / (X + X_EPS + N - 1)), minus 1.  X is such that
@@ -65,11 +35,11 @@ __lgamma_productl (long double t, long double x, long double x_eps, int n)
       long double xi = x + i;
       long double quot = t / xi;
       long double mhi, mlo;
-      mul_split (&mhi, &mlo, quot, xi);
+      mul_splitl (&mhi, &mlo, quot, xi);
       long double quot_lo = (t - mhi - mlo) / xi - t * x_eps / (xi * xi);
       /* We want (1 + RET + RET_EPS) * (1 + QUOT + QUOT_LO) - 1.  */
       long double rhi, rlo;
-      mul_split (&rhi, &rlo, ret, quot);
+      mul_splitl (&rhi, &rlo, ret, quot);
       long double rpq = ret + quot;
       long double rpq_eps = (ret - rpq) + quot;
       long double nret = rpq + rhi;
diff --git a/sysdeps/ieee754/ldbl-96/x2y2m1l.c b/sysdeps/ieee754/ldbl-96/x2y2m1l.c
index 733742d..b86ba1c 100644
--- a/sysdeps/ieee754/ldbl-96/x2y2m1l.c
+++ b/sysdeps/ieee754/ldbl-96/x2y2m1l.c
@@ -18,7 +18,7 @@
 
 #include <math.h>
 #include <math_private.h>
-#include <float.h>
+#include <mul_splitl.h>
 #include <stdlib.h>
 
 /* Calculate X + Y exactly and store the result in *HI + *LO.  It is
@@ -33,36 +33,6 @@ add_split (long double *hi, long double *lo, long double x, long double y)
   *lo = (x - *hi) + y;
 }
 
-/* Calculate X * Y exactly and store the result in *HI + *LO.  It is
-   given that the values are small enough that no overflow occurs and
-   large enough (or zero) that no underflow occurs.  */
-
-static inline void
-mul_split (long double *hi, long double *lo, long double x, long double y)
-{
-#ifdef __FP_FAST_FMAL
-  /* Fast built-in fused multiply-add.  */
-  *hi = x * y;
-  *lo = __builtin_fmal (x, y, -*hi);
-#elif defined FP_FAST_FMAL
-  /* Fast library fused multiply-add, compiler before GCC 4.6.  */
-  *hi = x * y;
-  *lo = __fmal (x, y, -*hi);
-#else
-  /* Apply Dekker's algorithm.  */
-  *hi = x * y;
-# define C ((1LL << (LDBL_MANT_DIG + 1) / 2) + 1)
-  long double x1 = x * C;
-  long double y1 = y * C;
-# undef C
-  x1 = (x - x1) + x1;
-  y1 = (y - y1) + y1;
-  long double x2 = x - x1;
-  long double y2 = y - y1;
-  *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
-#endif
-}
-
 /* Compare absolute values of floating-point values pointed to by P
    and Q for qsort.  */
 
@@ -88,8 +58,8 @@ __x2y2m1l (long double x, long double y)
 {
   long double vals[5];
   SET_RESTORE_ROUNDL (FE_TONEAREST);
-  mul_split (&vals[1], &vals[0], x, x);
-  mul_split (&vals[3], &vals[2], y, y);
+  mul_splitl (&vals[1], &vals[0], x, x);
+  mul_splitl (&vals[3], &vals[2], y, y);
   vals[4] = -1.0L;
   qsort (vals, 5, sizeof (long double), compare);
   /* Add up the values so that each element of VALS has absolute value

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=01ee387015a2075c45a4e1ad45d39e50b5a6d40b

commit 01ee387015a2075c45a4e1ad45d39e50b5a6d40b
Author: Paul E. Murphy <murphyp@linux.vnet.ibm.com>
Date:   Mon Jun 27 17:11:46 2016 -0500

    Convert _Complex cosine functions to generated code
    
    This is fairly straight fowards.  m68k overrides are
    updated to use the framework, and thus are simplified
    a bit.

diff --git a/ChangeLog b/ChangeLog
index 2b24e14..a9eb75d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,46 @@
 2016-08-19  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
 
+	* math/Makefile (libm-gen-calls): Move
+	s_cacos, s_cacosh, s_ccos, s_ccosh from ...
+	(libm-calls): Remove above.
+
+	* math/s_cacos_template.c: Update using type-generic macros.
+	* math/s_cacosh_template.c: Likewise.
+	* math/s_ccos_template.c: Likewise.
+	* math/s_ccosh_template.c: Likwise.
+
+	* math/s_cacosf.c: Removed.
+	* math/s_cacos.c: Removed.
+	* math/s_cacosl.c: Removed.
+	* math/s_cacoshf.c: Removed.
+	* math/s_cacosh.c: Removed.
+	* math/s_cacoshl.c: Removed.
+	* math/s_ccosf.c: Removed.
+	* math/s_ccos.c: Removed.
+	* math/s_ccosl.c: Removed.
+	* math/s_ccoshf.c: Removed.
+	* math/s_ccosh.c: Removed.
+	* math/s_ccoshl.c: Removed.
+
+	* sysdeps/ieee754/ldbl-opt/s_cacoshl.c: Removed.
+	* sysdeps/ieee754/ldbl-opt/s_cacosl.c: Removed.
+	* sysdeps/ieee754/ldbl-opt/s_ccos.c: Removed.
+	* sysdeps/ieee754/ldbl-opt/s_ccosh.c: Removed.
+	* sysdeps/ieee754/ldbl-opt/s_ccoshl.c: Removed.
+	* sysdeps/ieee754/ldbl-opt/s_ccosl.c: Removed.
+
+	* sysdeps/m68k/m680x0/fpu/s_ccosh.c: Refactor into.
+	* sysdeps/m68k/m680x0/fpu/s_ccosh_template.c: New file.
+	* sysdeps/m68k/m680x0/fpu/s_ccoshf.c: Removed.
+	* sysdeps/m68k/m680x0/fpu/s_ccoshl.c: Removed.
+
+	* sysdeps/alpha/fpu/s_cacosf.c: Update to use template file.
+	* sysdeps/alpha/fpu/s_cacoshf.c: Likewise.
+	* sysdeps/alpha/fpu/s_ccosf.c: Likewise.
+	* sysdeps/alpha/fpu/s_ccoshf.c: Likewise.
+
+2016-08-19  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
+
 	* s_cacos_template.c: Copy of s_cacos.c.
 	* s_cacosh_template.c: Copy of s_cacosh.c.
 	* s_ccos_template.c: Copy of s_ccos.c.
diff --git a/math/Makefile b/math/Makefile
index 2ff1405..e02b430 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -45,7 +45,8 @@ libm-support = s_lib_version s_matherr s_signgam			\
 
 # Wrappers for these functions generated per type using a file named
 # <func>_template.c and the appropriate math-type-macros-<TYPE>.h.
-gen-libm-calls = cargF conjF cimagF crealF cabsF
+gen-libm-calls = cargF conjF cimagF crealF cabsF s_cacosF \
+	         s_cacoshF s_ccosF s_ccoshF
 
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
@@ -63,9 +64,9 @@ libm-calls =								  \
 	w_ilogbF							  \
 	s_fpclassifyF s_fmaxF s_fminF s_fdimF s_nanF s_truncF		  \
 	s_remquoF e_log2F e_exp2F s_roundF s_nearbyintF s_sincosF	  \
-	s_cexpF s_csinhF s_ccoshF s_clogF				  \
-	s_catanF s_casinF s_ccosF s_csinF s_ctanF s_ctanhF s_cacosF	  \
-	s_casinhF s_cacoshF s_catanhF s_csqrtF s_cpowF s_cprojF s_clog10F \
+	s_cexpF s_csinhF s_clogF				  	  \
+	s_catanF s_casinF s_csinF s_ctanF s_ctanhF			  \
+	s_casinhF s_catanhF s_csqrtF s_cpowF s_cprojF s_clog10F 	  \
 	s_fmaF s_lrintF s_llrintF s_lroundF s_llroundF e_exp10F w_log2F	  \
 	s_issignalingF $(calls:s_%=m_%) x2y2m1F k_casinhF		  \
 	gamma_productF lgamma_negF lgamma_productF			  \
diff --git a/math/s_cacos.c b/math/s_cacos.c
deleted file mode 100644
index 234b122..0000000
--- a/math/s_cacos.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Return cosine of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <complex.h>
-#include <math.h>
-
-__complex__ double
-__cacos (__complex__ double x)
-{
-  __complex__ double y;
-  __complex__ double res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (rcls <= FP_INFINITE || icls <= FP_INFINITE
-      || (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      y = __casin (x);
-
-      __real__ res = (double) M_PI_2 - __real__ y;
-      if (__real__ res == 0.0)
-	__real__ res = 0.0;
-      __imag__ res = -__imag__ y;
-    }
-  else
-    {
-      __real__ y = -__imag__ x;
-      __imag__ y = __real__ x;
-
-      y = __kernel_casinh (y, 1);
-
-      __real__ res = __imag__ y;
-      __imag__ res = __real__ y;
-    }
-
-  return res;
-}
-weak_alias (__cacos, cacos)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cacos, __cacosl)
-weak_alias (__cacos, cacosl)
-#endif
diff --git a/math/s_cacos_template.c b/math/s_cacos_template.c
index 234b122..6494a1f 100644
--- a/math/s_cacos_template.c
+++ b/math/s_cacos_template.c
@@ -1,4 +1,4 @@
-/* Return cosine of complex double value.
+/* Return cosine of a complex type.
    Copyright (C) 1997-2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -20,22 +20,22 @@
 #include <complex.h>
 #include <math.h>
 
-__complex__ double
-__cacos (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__cacos) (CFLOAT x)
 {
-  __complex__ double y;
-  __complex__ double res;
+  CFLOAT y;
+  CFLOAT res;
   int rcls = fpclassify (__real__ x);
   int icls = fpclassify (__imag__ x);
 
   if (rcls <= FP_INFINITE || icls <= FP_INFINITE
       || (rcls == FP_ZERO && icls == FP_ZERO))
     {
-      y = __casin (x);
+      y = M_SUF (__casin) (x);
 
-      __real__ res = (double) M_PI_2 - __real__ y;
-      if (__real__ res == 0.0)
-	__real__ res = 0.0;
+      __real__ res = (FLOAT) M_MLIT (M_PI_2) - __real__ y;
+      if (__real__ res == 0)
+	__real__ res = 0;
       __imag__ res = -__imag__ y;
     }
   else
@@ -43,7 +43,7 @@ __cacos (__complex__ double x)
       __real__ y = -__imag__ x;
       __imag__ y = __real__ x;
 
-      y = __kernel_casinh (y, 1);
+      y = M_SUF (__kernel_casinh) (y, 1);
 
       __real__ res = __imag__ y;
       __imag__ res = __real__ y;
@@ -51,8 +51,9 @@ __cacos (__complex__ double x)
 
   return res;
 }
-weak_alias (__cacos, cacos)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cacos, __cacosl)
-weak_alias (__cacos, cacosl)
+
+declare_mgen_alias (__cacos, cacos);
+
+#if M_LIBM_NEED_COMPAT (carg)
+declare_mgen_libm_compat (__cacos, cacos)
 #endif
diff --git a/math/s_cacosf.c b/math/s_cacosf.c
deleted file mode 100644
index ab52392..0000000
--- a/math/s_cacosf.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Return cosine of complex float value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <complex.h>
-#include <math.h>
-
-__complex__ float
-__cacosf (__complex__ float x)
-{
-  __complex__ float y;
-  __complex__ float res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (rcls <= FP_INFINITE || icls <= FP_INFINITE
-      || (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      y = __casinf (x);
-
-      __real__ res = (float) M_PI_2 - __real__ y;
-      if (__real__ res == 0.0f)
-	__real__ res = 0.0f;
-      __imag__ res = -__imag__ y;
-    }
-  else
-    {
-      __real__ y = -__imag__ x;
-      __imag__ y = __real__ x;
-
-      y = __kernel_casinhf (y, 1);
-
-      __real__ res = __imag__ y;
-      __imag__ res = __real__ y;
-    }
-
-  return res;
-}
-#ifndef __cacosf
-weak_alias (__cacosf, cacosf)
-#endif
diff --git a/math/s_cacosh.c b/math/s_cacosh.c
deleted file mode 100644
index 20bf215..0000000
--- a/math/s_cacosh.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Return arc hyperbole cosine for double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <complex.h>
-#include <math.h>
-#include <math_private.h>
-
-
-__complex__ double
-__cacosh (__complex__ double x)
-{
-  __complex__ double res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (rcls <= FP_INFINITE || icls <= FP_INFINITE)
-    {
-      if (icls == FP_INFINITE)
-	{
-	  __real__ res = HUGE_VAL;
-
-	  if (rcls == FP_NAN)
-	    __imag__ res = __nan ("");
-	  else
-	    __imag__ res = __copysign ((rcls == FP_INFINITE
-					? (__real__ x < 0.0
-					   ? M_PI - M_PI_4 : M_PI_4)
-					: M_PI_2), __imag__ x);
-	}
-      else if (rcls == FP_INFINITE)
-	{
-	  __real__ res = HUGE_VAL;
-
-	  if (icls >= FP_ZERO)
-	    __imag__ res = __copysign (signbit (__real__ x) ? M_PI : 0.0,
-				       __imag__ x);
-	  else
-	    __imag__ res = __nan ("");
-	}
-      else
-	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
-	}
-    }
-  else if (rcls == FP_ZERO && icls == FP_ZERO)
-    {
-      __real__ res = 0.0;
-      __imag__ res = __copysign (M_PI_2, __imag__ x);
-    }
-  else
-    {
-      __complex__ double y;
-
-      __real__ y = -__imag__ x;
-      __imag__ y = __real__ x;
-
-      y = __kernel_casinh (y, 1);
-
-      if (signbit (__imag__ x))
-	{
-	  __real__ res = __real__ y;
-	  __imag__ res = -__imag__ y;
-	}
-      else
-	{
-	  __real__ res = -__real__ y;
-	  __imag__ res = __imag__ y;
-	}
-    }
-
-  return res;
-}
-weak_alias (__cacosh, cacosh)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cacosh, __cacoshl)
-weak_alias (__cacosh, cacoshl)
-#endif
diff --git a/math/s_cacosh_template.c b/math/s_cacosh_template.c
index 20bf215..e44da39 100644
--- a/math/s_cacosh_template.c
+++ b/math/s_cacosh_template.c
@@ -1,4 +1,4 @@
-/* Return arc hyperbole cosine for double value.
+/* Return arc hyperbolic cosine for a complex type.
    Copyright (C) 1997-2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -22,10 +22,10 @@
 #include <math_private.h>
 
 
-__complex__ double
-__cacosh (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__cacosh) (CFLOAT x)
 {
-  __complex__ double res;
+  CFLOAT res;
   int rcls = fpclassify (__real__ x);
   int icls = fpclassify (__imag__ x);
 
@@ -33,45 +33,46 @@ __cacosh (__complex__ double x)
     {
       if (icls == FP_INFINITE)
 	{
-	  __real__ res = HUGE_VAL;
+	  __real__ res = M_HUGE_VAL;
 
 	  if (rcls == FP_NAN)
-	    __imag__ res = __nan ("");
+	    __imag__ res = M_NAN;
 	  else
-	    __imag__ res = __copysign ((rcls == FP_INFINITE
-					? (__real__ x < 0.0
-					   ? M_PI - M_PI_4 : M_PI_4)
-					: M_PI_2), __imag__ x);
+	    __imag__ res = M_COPYSIGN ((rcls == FP_INFINITE
+					? (__real__ x < 0
+					   ? M_MLIT (M_PI) - M_MLIT (M_PI_4)
+					   : M_MLIT (M_PI_4))
+					: M_MLIT (M_PI_2)), __imag__ x);
 	}
       else if (rcls == FP_INFINITE)
 	{
-	  __real__ res = HUGE_VAL;
+	  __real__ res = M_HUGE_VAL;
 
 	  if (icls >= FP_ZERO)
-	    __imag__ res = __copysign (signbit (__real__ x) ? M_PI : 0.0,
-				       __imag__ x);
+	    __imag__ res = M_COPYSIGN (signbit (__real__ x)
+				       ? M_MLIT (M_PI) : 0, __imag__ x);
 	  else
-	    __imag__ res = __nan ("");
+	    __imag__ res = M_NAN;
 	}
       else
 	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
+	  __real__ res = M_NAN;
+	  __imag__ res = M_NAN;
 	}
     }
   else if (rcls == FP_ZERO && icls == FP_ZERO)
     {
-      __real__ res = 0.0;
-      __imag__ res = __copysign (M_PI_2, __imag__ x);
+      __real__ res = 0;
+      __imag__ res = M_COPYSIGN (M_MLIT (M_PI_2), __imag__ x);
     }
   else
     {
-      __complex__ double y;
+      CFLOAT y;
 
       __real__ y = -__imag__ x;
       __imag__ y = __real__ x;
 
-      y = __kernel_casinh (y, 1);
+      y = M_SUF (__kernel_casinh) (y, 1);
 
       if (signbit (__imag__ x))
 	{
@@ -87,8 +88,9 @@ __cacosh (__complex__ double x)
 
   return res;
 }
-weak_alias (__cacosh, cacosh)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cacosh, __cacoshl)
-weak_alias (__cacosh, cacoshl)
+
+declare_mgen_alias (__cacosh, cacosh)
+
+#if M_LIBM_NEED_COMPAT (cacosh)
+declare_mgen_libm_compat (__cacosh, cacosh)
 #endif
diff --git a/math/s_cacoshf.c b/math/s_cacoshf.c
deleted file mode 100644
index f1a1369..0000000
--- a/math/s_cacoshf.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* Return arc hyperbole cosine for float value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <complex.h>
-#include <math.h>
-
-#include <math_private.h>
-
-__complex__ float
-__cacoshf (__complex__ float x)
-{
-  __complex__ float res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (rcls <= FP_INFINITE || icls <= FP_INFINITE)
-    {
-      if (icls == FP_INFINITE)
-	{
-	  __real__ res = HUGE_VALF;
-
-	  if (rcls == FP_NAN)
-	    __imag__ res = __nanf ("");
-	  else
-	    __imag__ res = __copysignf ((rcls == FP_INFINITE
-					 ? (__real__ x < 0.0
-					    ? M_PI - M_PI_4 : M_PI_4)
-					 : M_PI_2), __imag__ x);
-	}
-      else if (rcls == FP_INFINITE)
-	{
-	  __real__ res = HUGE_VALF;
-
-	  if (icls >= FP_ZERO)
-	    __imag__ res = __copysignf (signbit (__real__ x) ? M_PI : 0.0,
-					__imag__ x);
-	  else
-	    __imag__ res = __nanf ("");
-	}
-      else
-	{
-	  __real__ res = __nanf ("");
-	  __imag__ res = __nanf ("");
-	}
-    }
-  else if (rcls == FP_ZERO && icls == FP_ZERO)
-    {
-      __real__ res = 0.0;
-      __imag__ res = __copysignf (M_PI_2, __imag__ x);
-    }
-  else
-    {
-      __complex__ float y;
-
-      __real__ y = -__imag__ x;
-      __imag__ y = __real__ x;
-
-      y = __kernel_casinhf (y, 1);
-
-      if (signbit (__imag__ x))
-	{
-	  __real__ res = __real__ y;
-	  __imag__ res = -__imag__ y;
-	}
-      else
-	{
-	  __real__ res = -__real__ y;
-	  __imag__ res = __imag__ y;
-	}
-    }
-
-  return res;
-}
-#ifndef __cacoshf
-weak_alias (__cacoshf, cacoshf)
-#endif
diff --git a/math/s_cacoshl.c b/math/s_cacoshl.c
deleted file mode 100644
index c512c2a..0000000
--- a/math/s_cacoshl.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Return arc hyperbole cosine for long double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <complex.h>
-#include <math.h>
-#include <math_private.h>
-
-
-__complex__ long double
-__cacoshl (__complex__ long double x)
-{
-  __complex__ long double res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (rcls <= FP_INFINITE || icls <= FP_INFINITE)
-    {
-      if (icls == FP_INFINITE)
-	{
-	  __real__ res = HUGE_VALL;
-
-	  if (rcls == FP_NAN)
-	    __imag__ res = __nanl ("");
-	  else
-	    __imag__ res = __copysignl ((rcls == FP_INFINITE
-					 ? (__real__ x < 0.0
-					    ? M_PIl - M_PI_4l : M_PI_4l)
-					 : M_PI_2l), __imag__ x);
-	}
-      else if (rcls == FP_INFINITE)
-	{
-	  __real__ res = HUGE_VALL;
-
-	  if (icls >= FP_ZERO)
-	    __imag__ res = __copysignl (signbit (__real__ x) ? M_PIl : 0.0,
-					__imag__ x);
-	  else
-	    __imag__ res = __nanl ("");
-	}
-      else
-	{
-	  __real__ res = __nanl ("");
-	  __imag__ res = __nanl ("");
-	}
-    }
-  else if (rcls == FP_ZERO && icls == FP_ZERO)
-    {
-      __real__ res = 0.0;
-      __imag__ res = __copysignl (M_PI_2l, __imag__ x);
-    }
-  else
-    {
-      __complex__ long double y;
-
-      __real__ y = -__imag__ x;
-      __imag__ y = __real__ x;
-
-      y = __kernel_casinhl (y, 1);
-
-      if (signbit (__imag__ x))
-	{
-	  __real__ res = __real__ y;
-	  __imag__ res = -__imag__ y;
-	}
-      else
-	{
-	  __real__ res = -__real__ y;
-	  __imag__ res = __imag__ y;
-	}
-    }
-
-  return res;
-}
-weak_alias (__cacoshl, cacoshl)
diff --git a/math/s_cacosl.c b/math/s_cacosl.c
deleted file mode 100644
index 3385887..0000000
--- a/math/s_cacosl.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Return cosine of complex long double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <complex.h>
-#include <math.h>
-
-__complex__ long double
-__cacosl (__complex__ long double x)
-{
-  __complex__ long double y;
-  __complex__ long double res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (rcls <= FP_INFINITE || icls <= FP_INFINITE
-      || (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      y = __casinl (x);
-
-      __real__ res = M_PI_2l - __real__ y;
-      if (__real__ res == 0.0L)
-	__real__ res = 0.0L;
-      __imag__ res = -__imag__ y;
-    }
-  else
-    {
-      __real__ y = -__imag__ x;
-      __imag__ y = __real__ x;
-
-      y = __kernel_casinhl (y, 1);
-
-      __real__ res = __imag__ y;
-      __imag__ res = __real__ y;
-    }
-
-  return res;
-}
-weak_alias (__cacosl, cacosl)
diff --git a/math/s_ccos.c b/math/s_ccos.c
deleted file mode 100644
index e484551..0000000
--- a/math/s_ccos.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Return cosine of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <complex.h>
-#include <fenv.h>
-#include <math.h>
-#include <math_private.h>
-
-
-__complex__ double
-__ccos (__complex__ double x)
-{
-  __complex__ double y;
-
-  __real__ y = -__imag__ x;
-  __imag__ y = __real__ x;
-
-  return __ccosh (y);
-}
-weak_alias (__ccos, ccos)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__ccos, __ccosl)
-weak_alias (__ccos, ccosl)
-#endif
diff --git a/math/s_ccos_template.c b/math/s_ccos_template.c
index e484551..becaa2d 100644
--- a/math/s_ccos_template.c
+++ b/math/s_ccos_template.c
@@ -1,4 +1,4 @@
-/* Return cosine of complex double value.
+/* Return cosine of complex float type.
    Copyright (C) 1997-2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -22,19 +22,19 @@
 #include <math.h>
 #include <math_private.h>
 
-
-__complex__ double
-__ccos (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__ccos) (CFLOAT x)
 {
-  __complex__ double y;
+  CFLOAT y;
 
   __real__ y = -__imag__ x;
   __imag__ y = __real__ x;
 
-  return __ccosh (y);
+  return M_SUF (__ccosh) (y);
 }
-weak_alias (__ccos, ccos)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__ccos, __ccosl)
-weak_alias (__ccos, ccosl)
+
+declare_mgen_alias (__ccos, ccos);
+
+#if M_LIBM_NEED_COMPAT (carg)
+declare_mgen_libm_compat (__ccos, ccos)
 #endif
diff --git a/math/s_ccosf.c b/math/s_ccosf.c
deleted file mode 100644
index c7da3fe..0000000
--- a/math/s_ccosf.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Return cosine of complex float value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <complex.h>
-#include <fenv.h>
-#include <math.h>
-#include <math_private.h>
-
-
-__complex__ float
-__ccosf (__complex__ float x)
-{
-  __complex__ float y;
-
-  __real__ y = -__imag__ x;
-  __imag__ y = __real__ x;
-
-  return __ccoshf (y);
-}
-#ifndef __ccosf
-weak_alias (__ccosf, ccosf)
-#endif
diff --git a/math/s_ccosh.c b/math/s_ccosh.c
deleted file mode 100644
index 4c2f300..0000000
--- a/math/s_ccosh.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/* Complex cosine hyperbole function for double.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <complex.h>
-#include <fenv.h>
-#include <math.h>
-#include <math_private.h>
-#include <float.h>
-
-__complex__ double
-__ccosh (__complex__ double x)
-{
-  __complex__ double retval;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_likely (rcls >= FP_ZERO))
-    {
-      /* Real part is finite.  */
-      if (__glibc_likely (icls >= FP_ZERO))
-	{
-	  /* Imaginary part is finite.  */
-	  const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2);
-	  double sinix, cosix;
-
-	  if (__glibc_likely (fabs (__imag__ x) > DBL_MIN))
-	    {
-	      __sincos (__imag__ x, &sinix, &cosix);
-	    }
-	  else
-	    {
-	      sinix = __imag__ x;
-	      cosix = 1.0;
-	    }
-
-	  if (fabs (__real__ x) > t)
-	    {
-	      double exp_t = __ieee754_exp (t);
-	      double rx = fabs (__real__ x);
-	      if (signbit (__real__ x))
-		sinix = -sinix;
-	      rx -= t;
-	      sinix *= exp_t / 2.0;
-	      cosix *= exp_t / 2.0;
-	      if (rx > t)
-		{
-		  rx -= t;
-		  sinix *= exp_t;
-		  cosix *= exp_t;
-		}
-	      if (rx > t)
-		{
-		  /* Overflow (original real part of x > 3t).  */
-		  __real__ retval = DBL_MAX * cosix;
-		  __imag__ retval = DBL_MAX * sinix;
-		}
-	      else
-		{
-		  double exp_val = __ieee754_exp (rx);
-		  __real__ retval = exp_val * cosix;
-		  __imag__ retval = exp_val * sinix;
-		}
-	    }
-	  else
-	    {
-	      __real__ retval = __ieee754_cosh (__real__ x) * cosix;
-	      __imag__ retval = __ieee754_sinh (__real__ x) * sinix;
-	    }
-
-	  math_check_force_underflow_complex (retval);
-	}
-      else
-	{
-	  __imag__ retval = __real__ x == 0.0 ? 0.0 : __nan ("");
-	  __real__ retval = __nan ("") + __nan ("");
-
-	  if (icls == FP_INFINITE)
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else if (rcls == FP_INFINITE)
-    {
-      /* Real part is infinite.  */
-      if (__glibc_likely (icls > FP_ZERO))
-	{
-	  /* Imaginary part is finite.  */
-	  double sinix, cosix;
-
-	  if (__glibc_likely (fabs (__imag__ x) > DBL_MIN))
-	    {
-	      __sincos (__imag__ x, &sinix, &cosix);
-	    }
-	  else
-	    {
-	      sinix = __imag__ x;
-	      cosix = 1.0;
-	    }
-
-	  __real__ retval = __copysign (HUGE_VAL, cosix);
-	  __imag__ retval = (__copysign (HUGE_VAL, sinix)
-			     * __copysign (1.0, __real__ x));
-	}
-      else if (icls == FP_ZERO)
-	{
-	  /* Imaginary part is 0.0.  */
-	  __real__ retval = HUGE_VAL;
-	  __imag__ retval = __imag__ x * __copysign (1.0, __real__ x);
-	}
-      else
-	{
-	  /* The addition raises the invalid exception.  */
-	  __real__ retval = HUGE_VAL;
-	  __imag__ retval = __nan ("") + __nan ("");
-
-	  if (icls == FP_INFINITE)
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else
-    {
-      __real__ retval = __nan ("");
-      __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nan ("");
-    }
-
-  return retval;
-}
-weak_alias (__ccosh, ccosh)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__ccosh, __ccoshl)
-weak_alias (__ccosh, ccoshl)
-#endif
diff --git a/math/s_ccosh_template.c b/math/s_ccosh_template.c
index 4c2f300..68de41d 100644
--- a/math/s_ccosh_template.c
+++ b/math/s_ccosh_template.c
@@ -1,4 +1,4 @@
-/* Complex cosine hyperbole function for double.
+/* Complex cosine hyperbolic function for float types.
    Copyright (C) 1997-2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -23,10 +23,10 @@
 #include <math_private.h>
 #include <float.h>
 
-__complex__ double
-__ccosh (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__ccosh) (CFLOAT x)
 {
-  __complex__ double retval;
+  CFLOAT retval;
   int rcls = fpclassify (__real__ x);
   int icls = fpclassify (__imag__ x);
 
@@ -36,28 +36,28 @@ __ccosh (__complex__ double x)
       if (__glibc_likely (icls >= FP_ZERO))
 	{
 	  /* Imaginary part is finite.  */
-	  const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2);
-	  double sinix, cosix;
+	  const int t = (int) ((M_MAX_EXP - 1) * M_MLIT (M_LN2));
+	  FLOAT sinix, cosix;
 
-	  if (__glibc_likely (fabs (__imag__ x) > DBL_MIN))
+	  if (__glibc_likely (M_FABS (__imag__ x) > M_MIN))
 	    {
-	      __sincos (__imag__ x, &sinix, &cosix);
+	      M_SINCOS (__imag__ x, &sinix, &cosix);
 	    }
 	  else
 	    {
 	      sinix = __imag__ x;
-	      cosix = 1.0;
+	      cosix = 1;
 	    }
 
-	  if (fabs (__real__ x) > t)
+	  if (M_FABS (__real__ x) > t)
 	    {
-	      double exp_t = __ieee754_exp (t);
-	      double rx = fabs (__real__ x);
+	      FLOAT exp_t = M_EXP (t);
+	      FLOAT rx = M_FABS (__real__ x);
 	      if (signbit (__real__ x))
 		sinix = -sinix;
 	      rx -= t;
-	      sinix *= exp_t / 2.0;
-	      cosix *= exp_t / 2.0;
+	      sinix *= exp_t / 2;
+	      cosix *= exp_t / 2;
 	      if (rx > t)
 		{
 		  rx -= t;
@@ -67,28 +67,28 @@ __ccosh (__complex__ double x)
 	      if (rx > t)
 		{
 		  /* Overflow (original real part of x > 3t).  */
-		  __real__ retval = DBL_MAX * cosix;
-		  __imag__ retval = DBL_MAX * sinix;
+		  __real__ retval = M_MAX * cosix;
+		  __imag__ retval = M_MAX * sinix;
 		}
 	      else
 		{
-		  double exp_val = __ieee754_exp (rx);
+		  FLOAT exp_val = M_EXP (rx);
 		  __real__ retval = exp_val * cosix;
 		  __imag__ retval = exp_val * sinix;
 		}
 	    }
 	  else
 	    {
-	      __real__ retval = __ieee754_cosh (__real__ x) * cosix;
-	      __imag__ retval = __ieee754_sinh (__real__ x) * sinix;
+	      __real__ retval = M_COSH (__real__ x) * cosix;
+	      __imag__ retval = M_SINH (__real__ x) * sinix;
 	    }
 
 	  math_check_force_underflow_complex (retval);
 	}
       else
 	{
-	  __imag__ retval = __real__ x == 0.0 ? 0.0 : __nan ("");
-	  __real__ retval = __nan ("") + __nan ("");
+	  __imag__ retval = __real__ x == 0 ? 0 : M_NAN;
+	  __real__ retval = M_NAN + M_NAN;
 
 	  if (icls == FP_INFINITE)
 	    feraiseexcept (FE_INVALID);
@@ -100,33 +100,33 @@ __ccosh (__complex__ double x)
       if (__glibc_likely (icls > FP_ZERO))
 	{
 	  /* Imaginary part is finite.  */
-	  double sinix, cosix;
+	  FLOAT sinix, cosix;
 
-	  if (__glibc_likely (fabs (__imag__ x) > DBL_MIN))
+	  if (__glibc_likely (M_FABS (__imag__ x) > M_MIN))
 	    {
-	      __sincos (__imag__ x, &sinix, &cosix);
+	      M_SINCOS (__imag__ x, &sinix, &cosix);
 	    }
 	  else
 	    {
 	      sinix = __imag__ x;
-	      cosix = 1.0;
+	      cosix = 1;
 	    }
 
-	  __real__ retval = __copysign (HUGE_VAL, cosix);
-	  __imag__ retval = (__copysign (HUGE_VAL, sinix)
-			     * __copysign (1.0, __real__ x));
+	  __real__ retval = M_COPYSIGN (M_HUGE_VAL, cosix);
+	  __imag__ retval = (M_COPYSIGN (M_HUGE_VAL, sinix)
+			     * M_COPYSIGN (1, __real__ x));
 	}
       else if (icls == FP_ZERO)
 	{
 	  /* Imaginary part is 0.0.  */
-	  __real__ retval = HUGE_VAL;
-	  __imag__ retval = __imag__ x * __copysign (1.0, __real__ x);
+	  __real__ retval = M_HUGE_VAL;
+	  __imag__ retval = __imag__ x * M_COPYSIGN (1, __real__ x);
 	}
       else
 	{
 	  /* The addition raises the invalid exception.  */
-	  __real__ retval = HUGE_VAL;
-	  __imag__ retval = __nan ("") + __nan ("");
+	  __real__ retval = M_HUGE_VAL;
+	  __imag__ retval = M_NAN + M_NAN;
 
 	  if (icls == FP_INFINITE)
 	    feraiseexcept (FE_INVALID);
@@ -134,14 +134,15 @@ __ccosh (__complex__ double x)
     }
   else
     {
-      __real__ retval = __nan ("");
-      __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nan ("");
+      __real__ retval = M_NAN;
+      __imag__ retval = __imag__ x == 0 ? __imag__ x : M_NAN;
     }
 
   return retval;
 }
-weak_alias (__ccosh, ccosh)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__ccosh, __ccoshl)
-weak_alias (__ccosh, ccoshl)
+
+declare_mgen_alias (__ccosh, ccosh);
+
+#if M_LIBM_NEED_COMPAT (carg)
+declare_mgen_libm_compat (__ccosh, ccosh)
 #endif
diff --git a/math/s_ccoshf.c b/math/s_ccoshf.c
deleted file mode 100644
index d572b76..0000000
--- a/math/s_ccoshf.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/* Complex cosine hyperbole function for float.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <complex.h>
-#include <fenv.h>
-#include <math.h>
-#include <math_private.h>
-#include <float.h>
-
-__complex__ float
-__ccoshf (__complex__ float x)
-{
-  __complex__ float retval;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_likely (rcls >= FP_ZERO))
-    {
-      /* Real part is finite.  */
-      if (__glibc_likely (icls >= FP_ZERO))
-	{
-	  /* Imaginary part is finite.  */
-	  const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2);
-	  float sinix, cosix;
-
-	  if (__glibc_likely (fabsf (__imag__ x) > FLT_MIN))
-	    {
-	      __sincosf (__imag__ x, &sinix, &cosix);
-	    }
-	  else
-	    {
-	      sinix = __imag__ x;
-	      cosix = 1.0f;
-	    }
-
-	  if (fabsf (__real__ x) > t)
-	    {
-	      float exp_t = __ieee754_expf (t);
-	      float rx = fabsf (__real__ x);
-	      if (signbit (__real__ x))
-		sinix = -sinix;
-	      rx -= t;
-	      sinix *= exp_t / 2.0f;
-	      cosix *= exp_t / 2.0f;
-	      if (rx > t)
-		{
-		  rx -= t;
-		  sinix *= exp_t;
-		  cosix *= exp_t;
-		}
-	      if (rx > t)
-		{
-		  /* Overflow (original real part of x > 3t).  */
-		  __real__ retval = FLT_MAX * cosix;
-		  __imag__ retval = FLT_MAX * sinix;
-		}
-	      else
-		{
-		  float exp_val = __ieee754_expf (rx);
-		  __real__ retval = exp_val * cosix;
-		  __imag__ retval = exp_val * sinix;
-		}
-	    }
-	  else
-	    {
-	      __real__ retval = __ieee754_coshf (__real__ x) * cosix;
-	      __imag__ retval = __ieee754_sinhf (__real__ x) * sinix;
-	    }
-
-	  math_check_force_underflow_complex (retval);
-	}
-      else
-	{
-	  __imag__ retval = __real__ x == 0.0 ? 0.0 : __nanf ("");
-	  __real__ retval = __nanf ("");
-
-	  if (icls == FP_INFINITE)
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else if (rcls == FP_INFINITE)
-    {
-      /* Real part is infinite.  */
-      if (__glibc_likely (icls > FP_ZERO))
-	{
-	  /* Imaginary part is finite.  */
-	  float sinix, cosix;
-
-	  if (__glibc_likely (fabsf (__imag__ x) > FLT_MIN))
-	    {
-	      __sincosf (__imag__ x, &sinix, &cosix);
-	    }
-	  else
-	    {
-	      sinix = __imag__ x;
-	      cosix = 1.0f;
-	    }
-
-	  __real__ retval = __copysignf (HUGE_VALF, cosix);
-	  __imag__ retval = (__copysignf (HUGE_VALF, sinix)
-			     * __copysignf (1.0, __real__ x));
-	}
-      else if (icls == FP_ZERO)
-	{
-	  /* Imaginary part is 0.0.  */
-	  __real__ retval = HUGE_VALF;
-	  __imag__ retval = __imag__ x * __copysignf (1.0, __real__ x);
-	}
-      else
-	{
-	  /* The addition raises the invalid exception.  */
-	  __real__ retval = HUGE_VALF;
-	  __imag__ retval = __nanf ("") + __nanf ("");
-
-	  if (icls == FP_INFINITE)
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else
-    {
-      __real__ retval = __nanf ("");
-      __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nanf ("");
-    }
-
-  return retval;
-}
-#ifndef __ccoshf
-weak_alias (__ccoshf, ccoshf)
-#endif
diff --git a/math/s_ccoshl.c b/math/s_ccoshl.c
deleted file mode 100644
index d38f0aa..0000000
--- a/math/s_ccoshl.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/* Complex cosine hyperbole function for long double.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <complex.h>
-#include <fenv.h>
-#include <math.h>
-#include <math_private.h>
-#include <float.h>
-
-__complex__ long double
-__ccoshl (__complex__ long double x)
-{
-  __complex__ long double retval;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_likely (rcls >= FP_ZERO))
-    {
-      /* Real part is finite.  */
-      if (__glibc_likely (icls >= FP_ZERO))
-	{
-	  /* Imaginary part is finite.  */
-	  const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l);
-	  long double sinix, cosix;
-
-	  if (__glibc_likely (fabsl (__imag__ x) > LDBL_MIN))
-	    {
-	      __sincosl (__imag__ x, &sinix, &cosix);
-	    }
-	  else
-	    {
-	      sinix = __imag__ x;
-	      cosix = 1.0;
-	    }
-
-	  if (fabsl (__real__ x) > t)
-	    {
-	      long double exp_t = __ieee754_expl (t);
-	      long double rx = fabsl (__real__ x);
-	      if (signbit (__real__ x))
-		sinix = -sinix;
-	      rx -= t;
-	      sinix *= exp_t / 2.0L;
-	      cosix *= exp_t / 2.0L;
-	      if (rx > t)
-		{
-		  rx -= t;
-		  sinix *= exp_t;
-		  cosix *= exp_t;
-		}
-	      if (rx > t)
-		{
-		  /* Overflow (original real part of x > 3t).  */
-		  __real__ retval = LDBL_MAX * cosix;
-		  __imag__ retval = LDBL_MAX * sinix;
-		}
-	      else
-		{
-		  long double exp_val = __ieee754_expl (rx);
-		  __real__ retval = exp_val * cosix;
-		  __imag__ retval = exp_val * sinix;
-		}
-	    }
-	  else
-	    {
-	      __real__ retval = __ieee754_coshl (__real__ x) * cosix;
-	      __imag__ retval = __ieee754_sinhl (__real__ x) * sinix;
-	    }
-
-	  math_check_force_underflow_complex (retval);
-	}
-      else
-	{
-	  __imag__ retval = __real__ x == 0.0 ? 0.0 : __nanl ("");
-	  __real__ retval = __nanl ("") + __nanl ("");
-
-	  if (icls == FP_INFINITE)
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else if (rcls == FP_INFINITE)
-    {
-      /* Real part is infinite.  */
-      if (__glibc_likely (icls > FP_ZERO))
-	{
-	  /* Imaginary part is finite.  */
-	  long double sinix, cosix;
-
-	  if (__glibc_likely (fabsl (__imag__ x) > LDBL_MIN))
-	    {
-	      __sincosl (__imag__ x, &sinix, &cosix);
-	    }
-	  else
-	    {
-	      sinix = __imag__ x;
-	      cosix = 1.0;
-	    }
-
-	  __real__ retval = __copysignl (HUGE_VALL, cosix);
-	  __imag__ retval = (__copysignl (HUGE_VALL, sinix)
-			     * __copysignl (1.0, __real__ x));
-	}
-      else if (icls == FP_ZERO)
-	{
-	  /* Imaginary part is 0.0.  */
-	  __real__ retval = HUGE_VALL;
-	  __imag__ retval = __imag__ x * __copysignl (1.0, __real__ x);
-	}
-      else
-	{
-	  /* The addition raises the invalid exception.  */
-	  __real__ retval = HUGE_VALL;
-	  __imag__ retval = __nanl ("") + __nanl ("");
-
-	  if (icls == FP_INFINITE)
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else
-    {
-      __real__ retval = __nanl ("");
-      __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nanl ("");
-    }
-
-  return retval;
-}
-weak_alias (__ccoshl, ccoshl)
diff --git a/math/s_ccosl.c b/math/s_ccosl.c
deleted file mode 100644
index 9e98114..0000000
--- a/math/s_ccosl.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Return cosine of complex long double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <complex.h>
-#include <fenv.h>
-#include <math.h>
-#include <math_private.h>
-
-
-__complex__ long double
-__ccosl (__complex__ long double x)
-{
-  __complex__ long double y;
-
-  __real__ y = -__imag__ x;
-  __imag__ y = __real__ x;
-
-  return __ccoshl (y);
-}
-weak_alias (__ccosl, ccosl)
diff --git a/sysdeps/alpha/fpu/s_cacosf.c b/sysdeps/alpha/fpu/s_cacosf.c
index 25e21bb..d98ff9c 100644
--- a/sysdeps/alpha/fpu/s_cacosf.c
+++ b/sysdeps/alpha/fpu/s_cacosf.c
@@ -24,11 +24,18 @@
 
 #undef __cacosf
 #undef cacosf
-#define __cacosf internal_cacosf
 
 static _Complex float internal_cacosf (_Complex float x);
 
-#include <math/s_cacosf.c>
+#define M_DECL_FUNC(f) internal_cacosf
+#include <math-type-macros-float.h>
+
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_cacos_template.c>
+
 #include "cfloat-compat.h"
 
 #undef __cacosf
diff --git a/sysdeps/alpha/fpu/s_cacoshf.c b/sysdeps/alpha/fpu/s_cacoshf.c
index 43b6542..06b422f 100644
--- a/sysdeps/alpha/fpu/s_cacoshf.c
+++ b/sysdeps/alpha/fpu/s_cacoshf.c
@@ -24,11 +24,17 @@
 
 #undef __cacoshf
 #undef cacoshf
-#define __cacoshf internal_cacoshf
 
 static _Complex float internal_cacoshf (_Complex float x);
 
-#include <math/s_cacoshf.c>
+#define M_DECL_FUNC(f) internal_cacoshf
+#include <math-type-macros-float.h>
+
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_cacosh_template.c>
 #include "cfloat-compat.h"
 
 #undef __cacoshf
diff --git a/sysdeps/alpha/fpu/s_ccosf.c b/sysdeps/alpha/fpu/s_ccosf.c
index 886be62..2e7d4a2 100644
--- a/sysdeps/alpha/fpu/s_ccosf.c
+++ b/sysdeps/alpha/fpu/s_ccosf.c
@@ -24,14 +24,18 @@
 
 #undef __ccosf
 #undef ccosf
-#define __ccosf internal_ccosf
 
 static _Complex float internal_ccosf (_Complex float x);
 
-#include <math/s_ccosf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_ccosf
+#include <math-type-macros-float.h>
 
-#undef __ccosf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_ccos_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_ccosf (c1_cfloat_decl (x))
diff --git a/sysdeps/alpha/fpu/s_ccoshf.c b/sysdeps/alpha/fpu/s_ccoshf.c
index 16f49de..e5de040 100644
--- a/sysdeps/alpha/fpu/s_ccoshf.c
+++ b/sysdeps/alpha/fpu/s_ccoshf.c
@@ -24,14 +24,18 @@
 
 #undef __ccoshf
 #undef ccoshf
-#define __ccoshf internal_ccoshf
 
 static _Complex float internal_ccoshf (_Complex float x);
 
-#include <math/s_ccoshf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_ccoshf
+#include <math-type-macros-float.h>
 
-#undef __ccoshf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_ccosh_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_ccoshf (c1_cfloat_decl (x))
diff --git a/sysdeps/ieee754/ldbl-opt/s_cacos.c b/sysdeps/ieee754/ldbl-opt/s_cacos.c
deleted file mode 100644
index db90a9e..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_cacos.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_cacos.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cacos, cacosl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_cacosh.c b/sysdeps/ieee754/ldbl-opt/s_cacosh.c
deleted file mode 100644
index e68049d..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_cacosh.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_cacosh.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cacosh, cacoshl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_cacoshl.c b/sysdeps/ieee754/ldbl-opt/s_cacoshl.c
deleted file mode 100644
index ed4a299..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_cacoshl.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#undef weak_alias
-#define weak_alias(n,a)
-#include <math/s_cacoshl.c>
-long_double_symbol (libm, __cacoshl, cacoshl);
diff --git a/sysdeps/ieee754/ldbl-opt/s_cacosl.c b/sysdeps/ieee754/ldbl-opt/s_cacosl.c
deleted file mode 100644
index 9b84005..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_cacosl.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#undef weak_alias
-#define weak_alias(n,a)
-#include <math/s_cacosl.c>
-long_double_symbol (libm, __cacosl, cacosl);
diff --git a/sysdeps/ieee754/ldbl-opt/s_ccos.c b/sysdeps/ieee754/ldbl-opt/s_ccos.c
deleted file mode 100644
index 2c43c7f..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_ccos.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_ccos.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __ccos, ccosl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_ccosh.c b/sysdeps/ieee754/ldbl-opt/s_ccosh.c
deleted file mode 100644
index 3753cd5..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_ccosh.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_ccosh.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __ccosh, ccoshl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_ccoshl.c b/sysdeps/ieee754/ldbl-opt/s_ccoshl.c
deleted file mode 100644
index 9f0c1e1..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_ccoshl.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#undef weak_alias
-#define weak_alias(n,a)
-#include <math/s_ccoshl.c>
-long_double_symbol (libm, __ccoshl, ccoshl);
diff --git a/sysdeps/ieee754/ldbl-opt/s_ccosl.c b/sysdeps/ieee754/ldbl-opt/s_ccosl.c
deleted file mode 100644
index e93e805..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_ccosl.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#undef weak_alias
-#define weak_alias(n,a)
-#include <math/s_ccosl.c>
-long_double_symbol (libm, __ccosl, ccosl);
diff --git a/sysdeps/m68k/m680x0/fpu/s_ccosh.c b/sysdeps/m68k/m680x0/fpu/s_ccosh_template.c
similarity index 87%
rename from sysdeps/m68k/m680x0/fpu/s_ccosh.c
rename to sysdeps/m68k/m680x0/fpu/s_ccosh_template.c
index 47a4fb0..83b449e 100644
--- a/sysdeps/m68k/m680x0/fpu/s_ccosh.c
+++ b/sysdeps/m68k/m680x0/fpu/s_ccosh_template.c
@@ -21,27 +21,19 @@
 #include <math.h>
 #include "mathimpl.h"
 
-#ifndef SUFF
-#define SUFF
-#endif
-#ifndef float_type
-#define float_type double
-#endif
-
-#define CONCATX(a,b) __CONCAT(a,b)
-#define s(name) CONCATX(name,SUFF)
+#define s(name) M_SUF (name)
 #define m81(func) __m81_u(s(func))
 
-__complex__ float_type
-s(__ccosh) (__complex__ float_type x)
+CFLOAT
+s(__ccosh) (CFLOAT x)
 {
-  __complex__ float_type retval;
+  CFLOAT retval;
   unsigned long ix_cond = __m81_test (__imag__ x);
 
   if ((ix_cond & (__M81_COND_INF|__M81_COND_NAN)) == 0)
     {
       /* Imaginary part is finite.  */
-      float_type sin_ix, cos_ix;
+      FLOAT sin_ix, cos_ix;
 
       __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_ix), "=f" (cos_ix)
 	     : "f" (__imag__ x));
diff --git a/sysdeps/m68k/m680x0/fpu/s_ccoshf.c b/sysdeps/m68k/m680x0/fpu/s_ccoshf.c
deleted file mode 100644
index 3c8e7c7..0000000
--- a/sysdeps/m68k/m680x0/fpu/s_ccoshf.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define SUFF f
-#define float_type float
-#include <s_ccosh.c>
diff --git a/sysdeps/m68k/m680x0/fpu/s_ccoshl.c b/sysdeps/m68k/m680x0/fpu/s_ccoshl.c
deleted file mode 100644
index 772d578..0000000
--- a/sysdeps/m68k/m680x0/fpu/s_ccoshl.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define SUFF l
-#define float_type long double
-#include <s_ccosh.c>

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=281f5073e5a6d2cd3733acd9c773c8c6340468c4

commit 281f5073e5a6d2cd3733acd9c773c8c6340468c4
Author: Paul E. Murphy <murphyp@linux.vnet.ibm.com>
Date:   Fri Jul 1 10:49:03 2016 -0500

    Prepare to convert _Complex cosine functions
    
    This patch has no function changes, except to
    ensure the git history correctly tracks the
    changes to convert the double version of these
    functions into a templated version.

diff --git a/ChangeLog b/ChangeLog
index e91bd08..2b24e14 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2016-08-19  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
 
+	* s_cacos_template.c: Copy of s_cacos.c.
+	* s_cacosh_template.c: Copy of s_cacosh.c.
+	* s_ccos_template.c: Copy of s_ccos.c.
+	* s_ccosh_template.c: Copy of s_ccosh.c.
+
+2016-08-19  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
+
 	* stdlib/tst-strtod-round-skeleton.c:
 	Refactored from tst-strtod-round.c.
 
diff --git a/math/s_cacos_template.c b/math/s_cacos_template.c
new file mode 100644
index 0000000..234b122
--- /dev/null
+++ b/math/s_cacos_template.c
@@ -0,0 +1,58 @@
+/* Return cosine of complex double value.
+   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <complex.h>
+#include <math.h>
+
+__complex__ double
+__cacos (__complex__ double x)
+{
+  __complex__ double y;
+  __complex__ double res;
+  int rcls = fpclassify (__real__ x);
+  int icls = fpclassify (__imag__ x);
+
+  if (rcls <= FP_INFINITE || icls <= FP_INFINITE
+      || (rcls == FP_ZERO && icls == FP_ZERO))
+    {
+      y = __casin (x);
+
+      __real__ res = (double) M_PI_2 - __real__ y;
+      if (__real__ res == 0.0)
+	__real__ res = 0.0;
+      __imag__ res = -__imag__ y;
+    }
+  else
+    {
+      __real__ y = -__imag__ x;
+      __imag__ y = __real__ x;
+
+      y = __kernel_casinh (y, 1);
+
+      __real__ res = __imag__ y;
+      __imag__ res = __real__ y;
+    }
+
+  return res;
+}
+weak_alias (__cacos, cacos)
+#ifdef NO_LONG_DOUBLE
+strong_alias (__cacos, __cacosl)
+weak_alias (__cacos, cacosl)
+#endif
diff --git a/math/s_cacosh_template.c b/math/s_cacosh_template.c
new file mode 100644
index 0000000..20bf215
--- /dev/null
+++ b/math/s_cacosh_template.c
@@ -0,0 +1,94 @@
+/* Return arc hyperbole cosine for double value.
+   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <complex.h>
+#include <math.h>
+#include <math_private.h>
+
+
+__complex__ double
+__cacosh (__complex__ double x)
+{
+  __complex__ double res;
+  int rcls = fpclassify (__real__ x);
+  int icls = fpclassify (__imag__ x);
+
+  if (rcls <= FP_INFINITE || icls <= FP_INFINITE)
+    {
+      if (icls == FP_INFINITE)
+	{
+	  __real__ res = HUGE_VAL;
+
+	  if (rcls == FP_NAN)
+	    __imag__ res = __nan ("");
+	  else
+	    __imag__ res = __copysign ((rcls == FP_INFINITE
+					? (__real__ x < 0.0
+					   ? M_PI - M_PI_4 : M_PI_4)
+					: M_PI_2), __imag__ x);
+	}
+      else if (rcls == FP_INFINITE)
+	{
+	  __real__ res = HUGE_VAL;
+
+	  if (icls >= FP_ZERO)
+	    __imag__ res = __copysign (signbit (__real__ x) ? M_PI : 0.0,
+				       __imag__ x);
+	  else
+	    __imag__ res = __nan ("");
+	}
+      else
+	{
+	  __real__ res = __nan ("");
+	  __imag__ res = __nan ("");
+	}
+    }
+  else if (rcls == FP_ZERO && icls == FP_ZERO)
+    {
+      __real__ res = 0.0;
+      __imag__ res = __copysign (M_PI_2, __imag__ x);
+    }
+  else
+    {
+      __complex__ double y;
+
+      __real__ y = -__imag__ x;
+      __imag__ y = __real__ x;
+
+      y = __kernel_casinh (y, 1);
+
+      if (signbit (__imag__ x))
+	{
+	  __real__ res = __real__ y;
+	  __imag__ res = -__imag__ y;
+	}
+      else
+	{
+	  __real__ res = -__real__ y;
+	  __imag__ res = __imag__ y;
+	}
+    }
+
+  return res;
+}
+weak_alias (__cacosh, cacosh)
+#ifdef NO_LONG_DOUBLE
+strong_alias (__cacosh, __cacoshl)
+weak_alias (__cacosh, cacoshl)
+#endif
diff --git a/math/s_ccos_template.c b/math/s_ccos_template.c
new file mode 100644
index 0000000..e484551
--- /dev/null
+++ b/math/s_ccos_template.c
@@ -0,0 +1,40 @@
+/* Return cosine of complex double value.
+   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <complex.h>
+#include <fenv.h>
+#include <math.h>
+#include <math_private.h>
+
+
+__complex__ double
+__ccos (__complex__ double x)
+{
+  __complex__ double y;
+
+  __real__ y = -__imag__ x;
+  __imag__ y = __real__ x;
+
+  return __ccosh (y);
+}
+weak_alias (__ccos, ccos)
+#ifdef NO_LONG_DOUBLE
+strong_alias (__ccos, __ccosl)
+weak_alias (__ccos, ccosl)
+#endif
diff --git a/math/s_ccosh_template.c b/math/s_ccosh_template.c
new file mode 100644
index 0000000..4c2f300
--- /dev/null
+++ b/math/s_ccosh_template.c
@@ -0,0 +1,147 @@
+/* Complex cosine hyperbole function for double.
+   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <complex.h>
+#include <fenv.h>
+#include <math.h>
+#include <math_private.h>
+#include <float.h>
+
+__complex__ double
+__ccosh (__complex__ double x)
+{
+  __complex__ double retval;
+  int rcls = fpclassify (__real__ x);
+  int icls = fpclassify (__imag__ x);
+
+  if (__glibc_likely (rcls >= FP_ZERO))
+    {
+      /* Real part is finite.  */
+      if (__glibc_likely (icls >= FP_ZERO))
+	{
+	  /* Imaginary part is finite.  */
+	  const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2);
+	  double sinix, cosix;
+
+	  if (__glibc_likely (fabs (__imag__ x) > DBL_MIN))
+	    {
+	      __sincos (__imag__ x, &sinix, &cosix);
+	    }
+	  else
+	    {
+	      sinix = __imag__ x;
+	      cosix = 1.0;
+	    }
+
+	  if (fabs (__real__ x) > t)
+	    {
+	      double exp_t = __ieee754_exp (t);
+	      double rx = fabs (__real__ x);
+	      if (signbit (__real__ x))
+		sinix = -sinix;
+	      rx -= t;
+	      sinix *= exp_t / 2.0;
+	      cosix *= exp_t / 2.0;
+	      if (rx > t)
+		{
+		  rx -= t;
+		  sinix *= exp_t;
+		  cosix *= exp_t;
+		}
+	      if (rx > t)
+		{
+		  /* Overflow (original real part of x > 3t).  */
+		  __real__ retval = DBL_MAX * cosix;
+		  __imag__ retval = DBL_MAX * sinix;
+		}
+	      else
+		{
+		  double exp_val = __ieee754_exp (rx);
+		  __real__ retval = exp_val * cosix;
+		  __imag__ retval = exp_val * sinix;
+		}
+	    }
+	  else
+	    {
+	      __real__ retval = __ieee754_cosh (__real__ x) * cosix;
+	      __imag__ retval = __ieee754_sinh (__real__ x) * sinix;
+	    }
+
+	  math_check_force_underflow_complex (retval);
+	}
+      else
+	{
+	  __imag__ retval = __real__ x == 0.0 ? 0.0 : __nan ("");
+	  __real__ retval = __nan ("") + __nan ("");
+
+	  if (icls == FP_INFINITE)
+	    feraiseexcept (FE_INVALID);
+	}
+    }
+  else if (rcls == FP_INFINITE)
+    {
+      /* Real part is infinite.  */
+      if (__glibc_likely (icls > FP_ZERO))
+	{
+	  /* Imaginary part is finite.  */
+	  double sinix, cosix;
+
+	  if (__glibc_likely (fabs (__imag__ x) > DBL_MIN))
+	    {
+	      __sincos (__imag__ x, &sinix, &cosix);
+	    }
+	  else
+	    {
+	      sinix = __imag__ x;
+	      cosix = 1.0;
+	    }
+
+	  __real__ retval = __copysign (HUGE_VAL, cosix);
+	  __imag__ retval = (__copysign (HUGE_VAL, sinix)
+			     * __copysign (1.0, __real__ x));
+	}
+      else if (icls == FP_ZERO)
+	{
+	  /* Imaginary part is 0.0.  */
+	  __real__ retval = HUGE_VAL;
+	  __imag__ retval = __imag__ x * __copysign (1.0, __real__ x);
+	}
+      else
+	{
+	  /* The addition raises the invalid exception.  */
+	  __real__ retval = HUGE_VAL;
+	  __imag__ retval = __nan ("") + __nan ("");
+
+	  if (icls == FP_INFINITE)
+	    feraiseexcept (FE_INVALID);
+	}
+    }
+  else
+    {
+      __real__ retval = __nan ("");
+      __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nan ("");
+    }
+
+  return retval;
+}
+weak_alias (__ccosh, ccosh)
+#ifdef NO_LONG_DOUBLE
+strong_alias (__ccosh, __ccoshl)
+weak_alias (__ccosh, ccoshl)
+#endif

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=466929465e881a2d09df39097d026195fe2f26ed

commit 466929465e881a2d09df39097d026195fe2f26ed
Author: Paul E. Murphy <murphyp@linux.vnet.ibm.com>
Date:   Thu Jul 28 11:14:11 2016 -0500

    Add tst-wcstod-round
    
    This extends tst-strtod-round with a few trivial changes
    to also test the wide character variants of strto* using
    similar macros to other shared tests.

diff --git a/ChangeLog b/ChangeLog
index 3e39147..e91bd08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2016-08-19  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
+
+	* stdlib/tst-strtod-round-skeleton.c:
+	Refactored from tst-strtod-round.c.
+
+	(L_): New macro to apply literal modifier.
+	(FNPFX): New macro to select str or wcs prefix.
+	(CHAR): New macro to choose wchar_t or char.
+	(STRM): New macro to choose printf for tested character type.
+
+	(STRTO): New macro to choose appropriate string -> real function.
+	(FNPFXS): Stringitized version of FNPFX.
+	(STR): Support for above macro.
+	(STRX): Likewise.
+
+	(TEST): Update with above macros.
+	(test): Likewise.
+	(GEN_ONE_TEST): Likewise.
+	(test_in_one_mode): Likewise.
+
+	* stdlib/tst-strtod-round.c: New file.
+	* wcsmbs/tst-wcstod-round.c: New file.
+
+	* wcsmbs/Makefile: (tests): Add tst-wcstod-round
+	(tst-wcstod-round): Add libm depencency for fesetround.
+
 2016-08-19  Zack Weinberg  <zackw@panix.com>
 
 	* debug/tst-chk1.c: Add tests for fortification of bcopy and bzero.
diff --git a/stdlib/tst-strtod-round.c b/stdlib/tst-strtod-round-skeleton.c
similarity index 86%
copy from stdlib/tst-strtod-round.c
copy to stdlib/tst-strtod-round-skeleton.c
index 509f96a..1853c52 100644
--- a/stdlib/tst-strtod-round.c
+++ b/stdlib/tst-strtod-round-skeleton.c
@@ -31,9 +31,23 @@
 
 #include "tst-strtod.h"
 
+/* Non-standard macros expected to be externally defined:
+
+   L_(str): Pastes the appropriate modifier to a string literal str.
+
+   FNPFX: Expands to the correct prefix for the strtod equivalent
+          of type CHAR. (e.g str or wcs).
+
+   CHAR: Expands to the string type being tested (e.g wchar_t or char).
+
+   STRM: Expands to a string literal suitable for printing CHAR* via
+         printf (e.g "%s" or "%ls"). */
+
 #define _CONCAT(a, b) a ## b
 #define CONCAT(a, b) _CONCAT (a, b)
 
+#define STRTO(x) CONCAT (CONCAT (FNPFX, to), x)
+
 #if LDBL_MANT_DIG == 106 && LDBL_MAX_EXP == 1024
 /* This is a stupid hack for IBM long double.  This test ignores
    inexact values for long double due to the limitations of the
@@ -110,7 +124,7 @@
 	     ld106x, ld106d, ld106n, ld106z, ld106u,	\
 	     ld113x, ld113d, ld113n, ld113z, ld113u)	\
   {							\
-    s,							\
+    L_ (s),						\
     { XNTRY (fx, dx, ld64ix, ld64mx, ld106x, ld113x) },	\
     {							\
     { ENTRY (fn, dn, ld64in, ld64mn, ld106n, ld113n) },	\
@@ -131,7 +145,7 @@ struct test_results
   };
 
 struct test {
-  const char *s;
+  const CHAR *s;
   struct test_exactness exact;
   struct test_results r[4];
 };
@@ -139,19 +153,25 @@ struct test {
 /* Include the generated test data.  */
 #include "tst-strtod-round-data.h"
 
+#define STRX(x) #x
+#define STR(x) STRX (x)
+#define FNPFXS STR (FNPFX)
+
 #define GEN_ONE_TEST(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF)	\
 {								\
-  FTYPE f = strto ## FSUF (s, NULL);				\
+  FTYPE f = STRTO (FSUF) (s, NULL);				\
   if (f != expected->FSUF					\
       || (copysign ## CSUF) (1.0 ## LSUF, f)			\
 	 != (copysign ## CSUF) (1.0 ## LSUF, expected->FSUF))	\
     {								\
-      char efstr[FSTRLENMAX];					\
-      char fstr[FSTRLENMAX];					\
-      FTOSTR (efstr, FSTRLENMAX, "%" FTOSTRM "a", expected->FSUF); \
-      FTOSTR (fstr, FSTRLENMAX, "%" FTOSTRM "a", f);		\
-      printf ("strto" #FSUF " (%s) returned %s not %s"		\
-	      " (%s)\n", s, fstr, efstr, mode_name);		\
+      CHAR efstr[FSTRLENMAX];					\
+      CHAR fstr[FSTRLENMAX];					\
+      FTOSTR (efstr, FSTRLENMAX, L_("%") L_(FTOSTRM) L_("a"),   \
+	      expected->FSUF);    				\
+      FTOSTR (fstr, FSTRLENMAX, L_("%") L_(FTOSTRM) L_("a"), f);\
+      printf (FNPFXS "to" #FSUF  " (" STRM ") returned " STRM   \
+	      " not " STRM " (%s)\n",				\
+	      s, fstr, efstr, mode_name);			\
       if (ROUNDING_TESTS (FTYPE, rnd_mode) || exact->FSUF)	\
 	result = 1;						\
       else							\
@@ -160,7 +180,7 @@ struct test {
 }
 
 static int
-test_in_one_mode (const char *s, const struct test_results *expected,
+test_in_one_mode (const CHAR *s, const struct test_results *expected,
 		  const struct test_exactness *exact, const char *mode_name,
 		  int rnd_mode)
 {
diff --git a/stdlib/tst-strtod-round.c b/stdlib/tst-strtod-round.c
index 509f96a..ae5d6f8 100644
--- a/stdlib/tst-strtod-round.c
+++ b/stdlib/tst-strtod-round.c
@@ -1,6 +1,5 @@
-/* Test for correct rounding of results of strtod and related
-   functions.
-   Copyright (C) 2012-2016 Free Software Foundation, Inc.
+/* char shim for tst-strtod-round-skeleton.c.
+   Copyright (C) 2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -17,200 +16,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* Defining _LIBC_TEST ensures long double math functions are
-   declared in the headers.  */
-#define _LIBC_TEST 1
-#include <fenv.h>
-#include <float.h>
-#include <math.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math-tests.h>
+#define L_(str) str
+#define FNPFX   str
+#define CHAR    char
+#define STRM    "%s"
 
-#include "tst-strtod.h"
-
-#define _CONCAT(a, b) a ## b
-#define CONCAT(a, b) _CONCAT (a, b)
-
-#if LDBL_MANT_DIG == 106 && LDBL_MAX_EXP == 1024
-/* This is a stupid hack for IBM long double.  This test ignores
-   inexact values for long double due to the limitations of the
-   format.  This ensures rounding tests are ignored.  */
-# undef ROUNDING_TESTS_long_double
-# define ROUNDING_TESTS_long_double(x) 0
-#endif
-
-/* Generator to create an FTYPE member variabled named FSUF
-   used to populate struct member variables.  */
-#define FTYPE_MEMBER(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF)  \
-       FTYPE FSUF;
-
-/* Likewise, but each member is of type bool.  */
-#define BOOL_MEMBER(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF)  \
-       bool FSUF;
-
-#define STRUCT_FOREACH_FLOAT_FTYPE GEN_TEST_STRTOD_FOREACH (FTYPE_MEMBER)
-#define STRUCT_FOREACH_FLOAT_BOOL GEN_TEST_STRTOD_FOREACH (BOOL_MEMBER)
-
-/* Define the long double choose (CHOOSE_ld) macro
-   to select the appropriate generated long double
-   value from the generated test data.  */
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-/* This is for the long double == double format.  */
-# define CHOOSE_ld(f,d,...) d
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && LDBL_MIN_EXP == -16381
-/* This is for the Intel extended float format.  */
-# define CHOOSE_ld(f,d,ld64i,...) ld64i
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && LDBL_MIN_EXP == -16382
-/* This is for the Motorola extended float format.  */
-# define CHOOSE_ld(f,d,ld64i,ld64m,...) ld64m
-#elif LDBL_MANT_DIG == 106 && LDBL_MAX_EXP == 1024
-/* This is for the IBM extended double format.  */
-# define CHOOSE_ld(f,d,ld64i,ld64m,ld106,...) ld106
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-/* This is for the IEEE binary128 format.  */
-# define CHOOSE_ld(f,d,ld64i,ld64m,ld106,ld113,...) ld113
-#else
-# error "unknown long double format"
-#endif
-
-/* Add type specific choosing macros below.  */
-#define CHOOSE_f(f,...) f
-#define CHOOSE_d(f,d,...) d
-/* long double is special, and handled above.  */
-
-/* Selector for expected result field of a given type.  */
-#define _ENTRY(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF, ...)  \
-  CONCAT (CHOOSE_ ## FSUF (__VA_ARGS__), LSUF),
-#define ENTRY(...) \
-  GEN_TEST_STRTOD_FOREACH (_ENTRY, __VA_ARGS__)
-
-/* Selector for boolean exact tag of expected results.  */
-#define _XNTRY(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF, ...)  \
-  CHOOSE_ ## FSUF (__VA_ARGS__),
-#define XNTRY(...) \
-  GEN_TEST_STRTOD_FOREACH (_XNTRY, __VA_ARGS__)
-
-/* This is hacky way around the seemingly unavoidable macro
-   expansion of the INFINITY or HUGE_VAL like macros in the
-   above.  It is assumed the compiler will implicitly convert
-   the infinity correctly.  */
-#define INF INFINITY + 0.0
-
-/* This macro is used in conjunction with the output from the
-   gen-tst-strtod-round utility to select the appropriately
-   rounded long double value for a given format.  */
-#define TEST(s,						\
-	     fx, fd, fn, fz, fu,			\
-	     dx, dd, dn, dz, du,			\
-	     ld64ix, ld64id, ld64in, ld64iz, ld64iu,	\
-	     ld64mx, ld64md, ld64mn, ld64mz, ld64mu,	\
-	     ld106x, ld106d, ld106n, ld106z, ld106u,	\
-	     ld113x, ld113d, ld113n, ld113z, ld113u)	\
-  {							\
-    s,							\
-    { XNTRY (fx, dx, ld64ix, ld64mx, ld106x, ld113x) },	\
-    {							\
-    { ENTRY (fn, dn, ld64in, ld64mn, ld106n, ld113n) },	\
-    { ENTRY (fd, dd, ld64id, ld64md, ld106d, ld113d) },	\
-    { ENTRY (fz, dz, ld64iz, ld64mz, ld106z, ld113z) },	\
-    { ENTRY (fu, du, ld64iu, ld64mu, ld106u, ld113u) }	\
-    }							\
-  }
-
-struct test_exactness
-  {
-  STRUCT_FOREACH_FLOAT_BOOL
-  };
-
-struct test_results
-  {
-  STRUCT_FOREACH_FLOAT_FTYPE
-  };
-
-struct test {
-  const char *s;
-  struct test_exactness exact;
-  struct test_results r[4];
-};
-
-/* Include the generated test data.  */
-#include "tst-strtod-round-data.h"
-
-#define GEN_ONE_TEST(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF)	\
-{								\
-  FTYPE f = strto ## FSUF (s, NULL);				\
-  if (f != expected->FSUF					\
-      || (copysign ## CSUF) (1.0 ## LSUF, f)			\
-	 != (copysign ## CSUF) (1.0 ## LSUF, expected->FSUF))	\
-    {								\
-      char efstr[FSTRLENMAX];					\
-      char fstr[FSTRLENMAX];					\
-      FTOSTR (efstr, FSTRLENMAX, "%" FTOSTRM "a", expected->FSUF); \
-      FTOSTR (fstr, FSTRLENMAX, "%" FTOSTRM "a", f);		\
-      printf ("strto" #FSUF " (%s) returned %s not %s"		\
-	      " (%s)\n", s, fstr, efstr, mode_name);		\
-      if (ROUNDING_TESTS (FTYPE, rnd_mode) || exact->FSUF)	\
-	result = 1;						\
-      else							\
-	printf ("ignoring this inexact result\n");		\
-    }								\
-}
-
-static int
-test_in_one_mode (const char *s, const struct test_results *expected,
-		  const struct test_exactness *exact, const char *mode_name,
-		  int rnd_mode)
-{
-  int result = 0;
-  GEN_TEST_STRTOD_FOREACH (GEN_ONE_TEST)
-  return result;
-}
-
-static const struct fetestmodes
-  {
-  const char *mode_name;
-  int rnd_mode;
-  int rnd_i; /* Corresponding index into r array of struct test.  */
-  } modes[] = {
-    { "default rounding mode", FE_TONEAREST, 0 },
-#ifdef FE_DOWNWARD
-    { "FE_DOWNWARD", FE_DOWNWARD, 1 },
-#endif
-#ifdef FE_TOWARDZERO
-    { "FE_TOWARDZERO", FE_TOWARDZERO, 2 },
-#endif
-#ifdef FE_UPWARD
-    { "FE_UPWARD", FE_UPWARD, 3 },
-#endif
-    {}
-};
-
-static int
-do_test (void)
-{
-  int save_round_mode __attribute__ ((unused)) = fegetround ();
-  int result = 0;
-  for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
-    {
-      result |= test_in_one_mode (tests[i].s, &tests[i].r[modes[0].rnd_i],
-				  &tests[i].exact, modes[0].mode_name,
-				  modes[0].rnd_mode);
-      for (const struct fetestmodes *m = &modes[1]; m->mode_name != NULL; m++)
-	{
-	  if (!fesetround (m->rnd_mode))
-	    {
-	      result |= test_in_one_mode (tests[i].s, &tests[i].r[m->rnd_i],
-					  &tests[i].exact, m->mode_name,
-					  m->rnd_mode);
-	      fesetround (save_round_mode);
-	    }
-	}
-    }
-  return result;
-}
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <tst-strtod-round-skeleton.c>
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
index 8b599f7..9384a10 100644
--- a/wcsmbs/Makefile
+++ b/wcsmbs/Makefile
@@ -49,6 +49,7 @@ strop-tests :=  wcscmp wcsncmp wmemcmp wcslen wcschr wcsrchr wcscpy wcsnlen \
 tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen tst-btowc tst-mbrtowc \
 	 tst-wcrtomb tst-wcpncpy tst-mbsrtowcs tst-wchar-h tst-mbrtowc2 \
 	 tst-c16c32-1 wcsatcliff tst-wcstol-locale tst-wcstod-nan-locale \
+	 tst-wcstod-round \
 	 $(addprefix test-,$(strop-tests))
 
 include ../Rules
@@ -68,6 +69,8 @@ $(objpfx)tst-wcstol-locale.out: $(gen-locales)
 $(objpfx)tst-wcstod-nan-locale.out: $(gen-locales)
 endif
 
+$(objpfx)tst-wcstod-round: $(libm)
+
 CFLAGS-wcwidth.c = -I../wctype
 CFLAGS-wcswidth.c = -I../wctype
 
diff --git a/wcsmbs/tst-wcstod-round.c b/wcsmbs/tst-wcstod-round.c
new file mode 100644
index 0000000..38ddaea
--- /dev/null
+++ b/wcsmbs/tst-wcstod-round.c
@@ -0,0 +1,31 @@
+/* wide character shim for tst-strtod-round-skeleton.c.
+   Copyright (C) 2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+/* Include stdio.h early to avoid issues with the snprintf
+   redefinition below.  */
+#include <stdio.h>
+
+#define L_(str) L ## str
+#define FNPFX wcs
+#define CHAR wchar_t
+#define STRM "%ls"
+#define snprintf swprintf
+
+#include <stdlib/tst-strtod-round-skeleton.c>

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                  |   98 ++++++++++++
 math/Makefile                              |    9 +-
 math/mul_split.h                           |   50 ++++++
 math/mul_splitl.h                          |   50 ++++++
 math/s_cacos.c                             |   58 -------
 math/s_cacos_template.c                    |   59 +++++++
 math/s_cacosf.c                            |   56 -------
 math/s_cacosh.c                            |   94 -----------
 math/s_cacosh_template.c                   |   96 +++++++++++
 math/s_cacoshf.c                           |   92 -----------
 math/s_cacoshl.c                           |   90 -----------
 math/s_cacosl.c                            |   54 -------
 math/s_ccos.c                              |   40 -----
 math/s_ccos_template.c                     |   40 +++++
 math/s_ccosf.c                             |   38 -----
 math/s_ccosh.c                             |  147 -----------------
 math/s_ccosh_template.c                    |  148 +++++++++++++++++
 math/s_ccoshf.c                            |  145 -----------------
 math/s_ccoshl.c                            |  143 -----------------
 math/s_ccosl.c                             |   36 -----
 stdlib/tst-strtod-round-skeleton.c         |  236 ++++++++++++++++++++++++++++
 stdlib/tst-strtod-round.c                  |  206 +-----------------------
 sysdeps/alpha/fpu/s_cacosf.c               |   11 +-
 sysdeps/alpha/fpu/s_cacoshf.c              |   10 +-
 sysdeps/alpha/fpu/s_ccosf.c                |   12 +-
 sysdeps/alpha/fpu/s_ccoshf.c               |   12 +-
 sysdeps/ieee754/dbl-64/gamma_product.c     |   32 +----
 sysdeps/ieee754/dbl-64/lgamma_product.c    |   32 +----
 sysdeps/ieee754/dbl-64/x2y2m1.c            |   32 +----
 sysdeps/ieee754/ldbl-128/gamma_productl.c  |   34 +----
 sysdeps/ieee754/ldbl-128/lgamma_productl.c |   36 +----
 sysdeps/ieee754/ldbl-128/x2y2m1l.c         |   37 +----
 sysdeps/ieee754/ldbl-128ibm/s_fmal.c       |   27 +---
 sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c      |   32 +----
 sysdeps/ieee754/ldbl-96/gamma_productl.c   |   34 +----
 sysdeps/ieee754/ldbl-96/lgamma_productl.c  |   36 +----
 sysdeps/ieee754/ldbl-96/x2y2m1l.c          |   36 +----
 sysdeps/ieee754/ldbl-opt/s_cacos.c         |    6 -
 sysdeps/ieee754/ldbl-opt/s_cacosh.c        |    6 -
 sysdeps/ieee754/ldbl-opt/s_cacoshl.c       |    6 -
 sysdeps/ieee754/ldbl-opt/s_cacosl.c        |    6 -
 sysdeps/ieee754/ldbl-opt/s_ccos.c          |    6 -
 sysdeps/ieee754/ldbl-opt/s_ccosh.c         |    6 -
 sysdeps/ieee754/ldbl-opt/s_ccoshl.c        |    6 -
 sysdeps/ieee754/ldbl-opt/s_ccosl.c         |    6 -
 sysdeps/m68k/m680x0/fpu/s_ccosh.c          |   76 ---------
 sysdeps/m68k/m680x0/fpu/s_ccosh_template.c |   68 ++++++++
 sysdeps/m68k/m680x0/fpu/s_ccoshf.c         |    3 -
 sysdeps/m68k/m680x0/fpu/s_ccoshl.c         |    3 -
 wcsmbs/Makefile                            |    3 +
 wcsmbs/tst-wcstod-round.c                  |   31 ++++
 51 files changed, 946 insertions(+), 1684 deletions(-)
 create mode 100644 math/mul_split.h
 create mode 100644 math/mul_splitl.h
 delete mode 100644 math/s_cacos.c
 create mode 100644 math/s_cacos_template.c
 delete mode 100644 math/s_cacosf.c
 delete mode 100644 math/s_cacosh.c
 create mode 100644 math/s_cacosh_template.c
 delete mode 100644 math/s_cacoshf.c
 delete mode 100644 math/s_cacoshl.c
 delete mode 100644 math/s_cacosl.c
 delete mode 100644 math/s_ccos.c
 create mode 100644 math/s_ccos_template.c
 delete mode 100644 math/s_ccosf.c
 delete mode 100644 math/s_ccosh.c
 create mode 100644 math/s_ccosh_template.c
 delete mode 100644 math/s_ccoshf.c
 delete mode 100644 math/s_ccoshl.c
 delete mode 100644 math/s_ccosl.c
 create mode 100644 stdlib/tst-strtod-round-skeleton.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_cacos.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_cacosh.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_cacoshl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_cacosl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ccos.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ccosh.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ccoshl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ccosl.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_ccosh.c
 create mode 100644 sysdeps/m68k/m680x0/fpu/s_ccosh_template.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_ccoshf.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_ccoshl.c
 create mode 100644 wcsmbs/tst-wcstod-round.c


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]