public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCHv4 6/8] Convert _Complex tangent functions to generated code
  2016-08-18 22:35 [PATCHv4 1/8] Prepare to convert _Complex cosine functions Paul E. Murphy
                   ` (3 preceding siblings ...)
  2016-08-18 22:35 ` [PATCHv4 2/8] Convert _Complex cosine " Paul E. Murphy
@ 2016-08-18 22:35 ` Paul E. Murphy
  2016-08-19 20:18   ` Joseph Myers
  2016-08-18 22:35 ` [PATCHv4 7/8] Prepare to convert remaining _Complex functions Paul E. Murphy
  2016-08-18 22:35 ` [PATCHv4 8/8] Convert remaining complex function to generated files Paul E. Murphy
  6 siblings, 1 reply; 20+ messages in thread
From: Paul E. Murphy @ 2016-08-18 22:35 UTC (permalink / raw)
  To: libc-alpha

This is fairly straight fowards.  m68k overrides are
updated to use the framework, and thus are simplified
a bit.

This converts s_c{,a}tan{,h}{f,,l} into a single
templated file c{,a}tan{,h}_template.c with the
exception of alpha.

	* math/Makefile (libm-gen-calls): Add
	catan, catanh, ctan, ctanh.
	(libm-calls): Remove the above.

	* math/s_catan_template.c: Update using type-generic macros.
	* math/s_catanh_template.c: Likewise.
	* math/s_ctan_template.c: Likewise.
	* math/s_ctanh_template.c: Likewise.

	* math/s_catanf.c: Removed.
	* math/s_catan.c: Removed.
	* math/s_catanl.c: Removed.
	* math/s_catanhf.c: Removed.
	* math/s_catanh.c: Removed.
	* math/s_catanhl.c: Removed.
	* math/s_ctanf.c: Removed.
	* math/s_ctan.c: Removed.
	* math/s_ctanl.c: Removed.
	* math/s_ctanhf.c: Removed.
	* math/s_ctanh.c: Removed.
	* math/s_ctanhl.c: Removed.

	* sysdeps/ieee754/ldbl-opt/s_catanhl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_catanl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_ctan.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_ctanh.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_ctanhl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_ctanl.c: Removed.

	* sysdeps/m68k/m680x0/fpu/s_ctanh.c: Refactor into ...
	* sysdeps/m68k/m680x0/fpu/s_ctanh_template.c: New file.
	* sysdeps/m68k/m680x0/fpu/s_ctanhf.c: Removed.
	* sysdeps/m68k/m680x0/fpu/s_ctanhl.c: Removed.

	* sysdeps/alpha/fpu/s_catanf.c: Update to use template file.
	* sysdeps/alpha/fpu/s_catanhf.c: Likewise.
	* sysdeps/alpha/fpu/s_ctanf.c: Likewise.
	* sysdeps/alpha/fpu/s_ctanhf.c: Likewise.
---
 math/Makefile                        |   6 +-
 math/s_catan.c                       | 143 ----------------------------------
 math/s_catan_template.c              | 104 +++++++++++++------------
 math/s_catanf.c                      | 143 ----------------------------------
 math/s_catanh.c                      | 137 --------------------------------
 math/s_catanh_template.c             | 102 ++++++++++++------------
 math/s_catanhf.c                     | 137 --------------------------------
 math/s_catanhl.c                     | 141 ---------------------------------
 math/s_catanl.c                      | 147 -----------------------------------
 math/s_ctan.c                        | 129 ------------------------------
 math/s_ctan_template.c               |  69 ++++++++--------
 math/s_ctanf.c                       | 127 ------------------------------
 math/s_ctanh.c                       | 129 ------------------------------
 math/s_ctanh_template.c              |  69 ++++++++--------
 math/s_ctanhf.c                      | 127 ------------------------------
 math/s_ctanhl.c                      | 132 -------------------------------
 math/s_ctanl.c                       | 132 -------------------------------
 sysdeps/alpha/fpu/s_catanf.c         |  12 ++-
 sysdeps/alpha/fpu/s_catanhf.c        |  12 ++-
 sysdeps/alpha/fpu/s_ctanf.c          |  12 ++-
 sysdeps/alpha/fpu/s_ctanhf.c         |  12 ++-
 sysdeps/ieee754/ldbl-opt/s_catan.c   |   6 --
 sysdeps/ieee754/ldbl-opt/s_catanh.c  |   6 --
 sysdeps/ieee754/ldbl-opt/s_catanhl.c |   6 --
 sysdeps/ieee754/ldbl-opt/s_catanl.c  |   6 --
 sysdeps/ieee754/ldbl-opt/s_ctan.c    |   6 --
 sysdeps/ieee754/ldbl-opt/s_ctanh.c   |   6 --
 sysdeps/ieee754/ldbl-opt/s_ctanhl.c  |   6 --
 sysdeps/ieee754/ldbl-opt/s_ctanl.c   |   6 --
 29 files changed, 210 insertions(+), 1860 deletions(-)
 delete mode 100644 math/s_catan.c
 delete mode 100644 math/s_catanf.c
 delete mode 100644 math/s_catanh.c
 delete mode 100644 math/s_catanhf.c
 delete mode 100644 math/s_catanhl.c
 delete mode 100644 math/s_catanl.c
 delete mode 100644 math/s_ctan.c
 delete mode 100644 math/s_ctanf.c
 delete mode 100644 math/s_ctanh.c
 delete mode 100644 math/s_ctanhf.c
 delete mode 100644 math/s_ctanhl.c
 delete mode 100644 math/s_ctanl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_catan.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_catanh.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_catanhl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_catanl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ctan.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ctanh.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ctanhl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ctanl.c

diff --git a/math/Makefile b/math/Makefile
index 8873a9e..03cbd1d 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -47,7 +47,8 @@ libm-support = s_lib_version s_matherr s_signgam			\
 # <func>_template.c and the appropriate math-type-macros-<TYPE>.h.
 gen-libm-calls = cargF conjF cimagF crealF cabsF s_cacosF		  \
 	         s_cacoshF s_ccosF s_ccoshF s_casinF s_csinF s_casinhF	  \
-		 k_casinhF s_csinhF
+		 k_casinhF s_csinhF k_casinhF s_csinhF s_catanhF s_catanF \
+		 s_ctanF s_ctanhF
 
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
@@ -66,8 +67,7 @@ libm-calls =								  \
 	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_clogF							  \
-	s_catanF s_ctanF s_ctanhF					  \
-	s_catanhF s_csqrtF s_cpowF s_cprojF s_clog10F			  \
+	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				  \
 	gamma_productF lgamma_negF lgamma_productF			  \
diff --git a/math/s_catan.c b/math/s_catan.c
deleted file mode 100644
index 5ab4c0d..0000000
--- a/math/s_catan.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/* Return arc tangent 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>
-#include <math_private.h>
-#include <float.h>
-
-__complex__ double
-__catan (__complex__ double x)
-{
-  __complex__ double res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE))
-    {
-      if (rcls == FP_INFINITE)
-	{
-	  __real__ res = __copysign (M_PI_2, __real__ x);
-	  __imag__ res = __copysign (0.0, __imag__ x);
-	}
-      else if (icls == FP_INFINITE)
-	{
-	  if (rcls >= FP_ZERO)
-	    __real__ res = __copysign (M_PI_2, __real__ x);
-	  else
-	    __real__ res = __nan ("");
-	  __imag__ res = __copysign (0.0, __imag__ x);
-	}
-      else if (icls == FP_ZERO || icls == FP_INFINITE)
-	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __copysign (0.0, __imag__ x);
-	}
-      else
-	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
-	}
-    }
-  else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      res = x;
-    }
-  else
-    {
-      if (fabs (__real__ x) >= 16.0 / DBL_EPSILON
-	  || fabs (__imag__ x) >= 16.0 / DBL_EPSILON)
-	{
-	  __real__ res = __copysign (M_PI_2, __real__ x);
-	  if (fabs (__real__ x) <= 1.0)
-	    __imag__ res = 1.0 / __imag__ x;
-	  else if (fabs (__imag__ x) <= 1.0)
-	    __imag__ res = __imag__ x / __real__ x / __real__ x;
-	  else
-	    {
-	      double h = __ieee754_hypot (__real__ x / 2.0, __imag__ x / 2.0);
-	      __imag__ res = __imag__ x / h / h / 4.0;
-	    }
-	}
-      else
-	{
-	  double den, absx, absy;
-
-	  absx = fabs (__real__ x);
-	  absy = fabs (__imag__ x);
-	  if (absx < absy)
-	    {
-	      double t = absx;
-	      absx = absy;
-	      absy = t;
-	    }
-
-	  if (absy < DBL_EPSILON / 2.0)
-	    {
-	      den = (1.0 - absx) * (1.0 + absx);
-	      if (den == -0.0)
-		den = 0.0;
-	    }
-	  else if (absx >= 1.0)
-	    den = (1.0 - absx) * (1.0 + absx) - absy * absy;
-	  else if (absx >= 0.75 || absy >= 0.5)
-	    den = -__x2y2m1 (absx, absy);
-	  else
-	    den = (1.0 - absx) * (1.0 + absx) - absy * absy;
-
-	  __real__ res = 0.5 * __ieee754_atan2 (2.0 * __real__ x, den);
-
-	  if (fabs (__imag__ x) == 1.0
-	      && fabs (__real__ x) < DBL_EPSILON * DBL_EPSILON)
-	    __imag__ res = (__copysign (0.5, __imag__ x)
-			    * (M_LN2 - __ieee754_log (fabs (__real__ x))));
-	  else
-	    {
-	      double r2 = 0.0, num, f;
-
-	      if (fabs (__real__ x) >= DBL_EPSILON * DBL_EPSILON)
-		r2 = __real__ x * __real__ x;
-
-	      num = __imag__ x + 1.0;
-	      num = r2 + num * num;
-
-	      den = __imag__ x - 1.0;
-	      den = r2 + den * den;
-
-	      f = num / den;
-	      if (f < 0.5)
-		__imag__ res = 0.25 * __ieee754_log (f);
-	      else
-		{
-		  num = 4.0 * __imag__ x;
-		  __imag__ res = 0.25 * __log1p (num / den);
-		}
-	    }
-	}
-
-      math_check_force_underflow_complex (res);
-    }
-
-  return res;
-}
-weak_alias (__catan, catan)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__catan, __catanl)
-weak_alias (__catan, catanl)
-#endif
diff --git a/math/s_catan_template.c b/math/s_catan_template.c
index 5ab4c0d..c6a94ae 100644
--- a/math/s_catan_template.c
+++ b/math/s_catan_template.c
@@ -1,4 +1,4 @@
-/* Return arc tangent of complex double value.
+/* Return arc tangent 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,10 +22,10 @@
 #include <math_private.h>
 #include <float.h>
 
-__complex__ double
-__catan (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__catan) (CFLOAT x)
 {
-  __complex__ double res;
+  CFLOAT res;
   int rcls = fpclassify (__real__ x);
   int icls = fpclassify (__imag__ x);
 
@@ -33,26 +33,26 @@ __catan (__complex__ double x)
     {
       if (rcls == FP_INFINITE)
 	{
-	  __real__ res = __copysign (M_PI_2, __real__ x);
-	  __imag__ res = __copysign (0.0, __imag__ x);
+	  __real__ res = M_COPYSIGN (M_MLIT (M_PI_2), __real__ x);
+	  __imag__ res = M_COPYSIGN (0, __imag__ x);
 	}
       else if (icls == FP_INFINITE)
 	{
 	  if (rcls >= FP_ZERO)
-	    __real__ res = __copysign (M_PI_2, __real__ x);
+	    __real__ res = M_COPYSIGN (M_MLIT (M_PI_2), __real__ x);
 	  else
-	    __real__ res = __nan ("");
-	  __imag__ res = __copysign (0.0, __imag__ x);
+	    __real__ res = M_NAN;
+	  __imag__ res = M_COPYSIGN (0, __imag__ x);
 	}
       else if (icls == FP_ZERO || icls == FP_INFINITE)
 	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __copysign (0.0, __imag__ x);
+	  __real__ res = M_NAN;
+	  __imag__ res = M_COPYSIGN (0, __imag__ x);
 	}
       else
 	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
+	  __real__ res = M_NAN;
+	  __imag__ res = M_NAN;
 	}
     }
   else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
@@ -61,72 +61,73 @@ __catan (__complex__ double x)
     }
   else
     {
-      if (fabs (__real__ x) >= 16.0 / DBL_EPSILON
-	  || fabs (__imag__ x) >= 16.0 / DBL_EPSILON)
+      if (M_FABS (__real__ x) >= 16 / M_EPSILON
+	  || M_FABS (__imag__ x) >= 16 / M_EPSILON)
 	{
-	  __real__ res = __copysign (M_PI_2, __real__ x);
-	  if (fabs (__real__ x) <= 1.0)
-	    __imag__ res = 1.0 / __imag__ x;
-	  else if (fabs (__imag__ x) <= 1.0)
+	  __real__ res = M_COPYSIGN (M_MLIT (M_PI_2), __real__ x);
+	  if (M_FABS (__real__ x) <= 1)
+	    __imag__ res = 1 / __imag__ x;
+	  else if (M_FABS (__imag__ x) <= 1)
 	    __imag__ res = __imag__ x / __real__ x / __real__ x;
 	  else
 	    {
-	      double h = __ieee754_hypot (__real__ x / 2.0, __imag__ x / 2.0);
-	      __imag__ res = __imag__ x / h / h / 4.0;
+	      FLOAT h = M_HYPOT (__real__ x / 2, __imag__ x / 2);
+	      __imag__ res = __imag__ x / h / h / 4;
 	    }
 	}
       else
 	{
-	  double den, absx, absy;
+	  FLOAT den, absx, absy;
 
-	  absx = fabs (__real__ x);
-	  absy = fabs (__imag__ x);
+	  absx = M_FABS (__real__ x);
+	  absy = M_FABS (__imag__ x);
 	  if (absx < absy)
 	    {
-	      double t = absx;
+	      FLOAT t = absx;
 	      absx = absy;
 	      absy = t;
 	    }
 
-	  if (absy < DBL_EPSILON / 2.0)
+	  if (absy < M_EPSILON / 2)
 	    {
-	      den = (1.0 - absx) * (1.0 + absx);
-	      if (den == -0.0)
-		den = 0.0;
+	      den = (1 - absx) * (1 + absx);
+	      if (den == -0)
+		den = 0;
 	    }
-	  else if (absx >= 1.0)
-	    den = (1.0 - absx) * (1.0 + absx) - absy * absy;
-	  else if (absx >= 0.75 || absy >= 0.5)
-	    den = -__x2y2m1 (absx, absy);
+	  else if (absx >= 1)
+	    den = (1 - absx) * (1 + absx) - absy * absy;
+	  else if (absx >= M_LIT (0.75) || absy >= M_LIT (0.5))
+	    den = -M_SUF (__x2y2m1) (absx, absy);
 	  else
-	    den = (1.0 - absx) * (1.0 + absx) - absy * absy;
+	    den = (1 - absx) * (1 + absx) - absy * absy;
 
-	  __real__ res = 0.5 * __ieee754_atan2 (2.0 * __real__ x, den);
+	  __real__ res = M_LIT (0.5) * M_ATAN2 (2 * __real__ x, den);
 
-	  if (fabs (__imag__ x) == 1.0
-	      && fabs (__real__ x) < DBL_EPSILON * DBL_EPSILON)
-	    __imag__ res = (__copysign (0.5, __imag__ x)
-			    * (M_LN2 - __ieee754_log (fabs (__real__ x))));
+	  if (M_FABS (__imag__ x) == 1
+	      && M_FABS (__real__ x) < M_EPSILON * M_EPSILON)
+	    __imag__ res = (M_COPYSIGN (M_LIT (0.5), __imag__ x)
+			    * ((FLOAT) M_MLIT (M_LN2)
+			       - M_LOG (M_FABS (__real__ x))));
 	  else
 	    {
-	      double r2 = 0.0, num, f;
+	      FLOAT r2 = 0, num, f;
 
-	      if (fabs (__real__ x) >= DBL_EPSILON * DBL_EPSILON)
+	      if (M_FABS (__real__ x) >= M_EPSILON * M_EPSILON)
 		r2 = __real__ x * __real__ x;
 
-	      num = __imag__ x + 1.0;
+	      num = __imag__ x + 1;
 	      num = r2 + num * num;
 
-	      den = __imag__ x - 1.0;
+	      den = __imag__ x - 1;
 	      den = r2 + den * den;
 
 	      f = num / den;
-	      if (f < 0.5)
-		__imag__ res = 0.25 * __ieee754_log (f);
+	      if (f < M_LIT (0.5))
+		__imag__ res = M_LIT (0.25) * M_LOG (f);
 	      else
 		{
-		  num = 4.0 * __imag__ x;
-		  __imag__ res = 0.25 * __log1p (num / den);
+		  num = 4 * __imag__ x;
+		  __imag__ res = M_LIT (0.25) * M_LOG1P (num / den);
 		}
 	    }
 	}
@@ -136,8 +137,9 @@ __catan (__complex__ double x)
 
   return res;
 }
-weak_alias (__catan, catan)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__catan, __catanl)
-weak_alias (__catan, catanl)
+
+declare_mgen_alias (__catan, catan)
+
+#if M_LIBM_NEED_COMPAT (catan)
+declare_mgen_libm_compat (__catan, catan)
 #endif
diff --git a/math/s_catanf.c b/math/s_catanf.c
deleted file mode 100644
index 63e6b6e..0000000
--- a/math/s_catanf.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/* Return arc tangent 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>
-#include <math_private.h>
-#include <float.h>
-
-__complex__ float
-__catanf (__complex__ float x)
-{
-  __complex__ float res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE))
-    {
-      if (rcls == FP_INFINITE)
-	{
-	  __real__ res = __copysignf (M_PI_2, __real__ x);
-	  __imag__ res = __copysignf (0.0, __imag__ x);
-	}
-      else if (icls == FP_INFINITE)
-	{
-	  if (rcls >= FP_ZERO)
-	    __real__ res = __copysignf (M_PI_2, __real__ x);
-	  else
-	    __real__ res = __nanf ("");
-	  __imag__ res = __copysignf (0.0, __imag__ x);
-	}
-      else if (icls == FP_ZERO || icls == FP_INFINITE)
-	{
-	  __real__ res = __nanf ("");
-	  __imag__ res = __copysignf (0.0, __imag__ x);
-	}
-      else
-	{
-	  __real__ res = __nanf ("");
-	  __imag__ res = __nanf ("");
-	}
-    }
-  else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      res = x;
-    }
-  else
-    {
-      if (fabsf (__real__ x) >= 16.0f / FLT_EPSILON
-	  || fabsf (__imag__ x) >= 16.0f / FLT_EPSILON)
-	{
-	  __real__ res = __copysignf ((float) M_PI_2, __real__ x);
-	  if (fabsf (__real__ x) <= 1.0f)
-	    __imag__ res = 1.0f / __imag__ x;
-	  else if (fabsf (__imag__ x) <= 1.0f)
-	    __imag__ res = __imag__ x / __real__ x / __real__ x;
-	  else
-	    {
-	      float h = __ieee754_hypotf (__real__ x / 2.0f,
-					  __imag__ x / 2.0f);
-	      __imag__ res = __imag__ x / h / h / 4.0f;
-	    }
-	}
-      else
-	{
-	  float den, absx, absy;
-
-	  absx = fabsf (__real__ x);
-	  absy = fabsf (__imag__ x);
-	  if (absx < absy)
-	    {
-	      float t = absx;
-	      absx = absy;
-	      absy = t;
-	    }
-
-	  if (absy < FLT_EPSILON / 2.0f)
-	    {
-	      den = (1.0f - absx) * (1.0f + absx);
-	      if (den == -0.0f)
-		den = 0.0f;
-	    }
-	  else if (absx >= 1.0f)
-	    den = (1.0f - absx) * (1.0f + absx) - absy * absy;
-	  else if (absx >= 0.75f || absy >= 0.5f)
-	    den = -__x2y2m1f (absx, absy);
-	  else
-	    den = (1.0f - absx) * (1.0f + absx) - absy * absy;
-
-	  __real__ res = 0.5f * __ieee754_atan2f (2.0f * __real__ x, den);
-
-	  if (fabsf (__imag__ x) == 1.0f
-	      && fabsf (__real__ x) < FLT_EPSILON * FLT_EPSILON)
-	    __imag__ res = (__copysignf (0.5f, __imag__ x)
-			    * ((float) M_LN2
-			       - __ieee754_logf (fabsf (__real__ x))));
-	  else
-	    {
-	      float r2 = 0.0f, num, f;
-
-	      if (fabsf (__real__ x) >= FLT_EPSILON * FLT_EPSILON)
-		r2 = __real__ x * __real__ x;
-
-	      num = __imag__ x + 1.0f;
-	      num = r2 + num * num;
-
-	      den = __imag__ x - 1.0f;
-	      den = r2 + den * den;
-
-	      f = num / den;
-	      if (f < 0.5f)
-		__imag__ res = 0.25f * __ieee754_logf (f);
-	      else
-		{
-		  num = 4.0f * __imag__ x;
-		  __imag__ res = 0.25f * __log1pf (num / den);
-		}
-	    }
-	}
-
-      math_check_force_underflow_complex (res);
-    }
-
-  return res;
-}
-#ifndef __catanf
-weak_alias (__catanf, catanf)
-#endif
diff --git a/math/s_catanh.c b/math/s_catanh.c
deleted file mode 100644
index 11ea062..0000000
--- a/math/s_catanh.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/* Return arc hyperbole tangent 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>
-#include <float.h>
-
-__complex__ double
-__catanh (__complex__ double x)
-{
-  __complex__ double res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE))
-    {
-      if (icls == FP_INFINITE)
-	{
-	  __real__ res = __copysign (0.0, __real__ x);
-	  __imag__ res = __copysign (M_PI_2, __imag__ x);
-	}
-      else if (rcls == FP_INFINITE || rcls == FP_ZERO)
-	{
-	  __real__ res = __copysign (0.0, __real__ x);
-	  if (icls >= FP_ZERO)
-	    __imag__ res = __copysign (M_PI_2, __imag__ x);
-	  else
-	    __imag__ res = __nan ("");
-	}
-      else
-	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
-	}
-    }
-  else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      res = x;
-    }
-  else
-    {
-      if (fabs (__real__ x) >= 16.0 / DBL_EPSILON
-	  || fabs (__imag__ x) >= 16.0 / DBL_EPSILON)
-	{
-	  __imag__ res = __copysign (M_PI_2, __imag__ x);
-	  if (fabs (__imag__ x) <= 1.0)
-	    __real__ res = 1.0 / __real__ x;
-	  else if (fabs (__real__ x) <= 1.0)
-	    __real__ res = __real__ x / __imag__ x / __imag__ x;
-	  else
-	    {
-	      double h = __ieee754_hypot (__real__ x / 2.0, __imag__ x / 2.0);
-	      __real__ res = __real__ x / h / h / 4.0;
-	    }
-	}
-      else
-	{
-	  if (fabs (__real__ x) == 1.0
-	      && fabs (__imag__ x) < DBL_EPSILON * DBL_EPSILON)
-	    __real__ res = (__copysign (0.5, __real__ x)
-			    * (M_LN2 - __ieee754_log (fabs (__imag__ x))));
-	  else
-	    {
-	      double i2 = 0.0;
-	      if (fabs (__imag__ x) >= DBL_EPSILON * DBL_EPSILON)
-		i2 = __imag__ x * __imag__ x;
-
-	      double num = 1.0 + __real__ x;
-	      num = i2 + num * num;
-
-	      double den = 1.0 - __real__ x;
-	      den = i2 + den * den;
-
-	      double f = num / den;
-	      if (f < 0.5)
-		__real__ res = 0.25 * __ieee754_log (f);
-	      else
-		{
-		  num = 4.0 * __real__ x;
-		  __real__ res = 0.25 * __log1p (num / den);
-		}
-	    }
-
-	  double absx, absy, den;
-
-	  absx = fabs (__real__ x);
-	  absy = fabs (__imag__ x);
-	  if (absx < absy)
-	    {
-	      double t = absx;
-	      absx = absy;
-	      absy = t;
-	    }
-
-	  if (absy < DBL_EPSILON / 2.0)
-	    {
-	      den = (1.0 - absx) * (1.0 + absx);
-	      if (den == -0.0)
-		den = 0.0;
-	    }
-	  else if (absx >= 1.0)
-	    den = (1.0 - absx) * (1.0 + absx) - absy * absy;
-	  else if (absx >= 0.75 || absy >= 0.5)
-	    den = -__x2y2m1 (absx, absy);
-	  else
-	    den = (1.0 - absx) * (1.0 + absx) - absy * absy;
-
-	  __imag__ res = 0.5 * __ieee754_atan2 (2.0 * __imag__ x, den);
-	}
-
-      math_check_force_underflow_complex (res);
-    }
-
-  return res;
-}
-weak_alias (__catanh, catanh)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__catanh, __catanhl)
-weak_alias (__catanh, catanhl)
-#endif
diff --git a/math/s_catanh_template.c b/math/s_catanh_template.c
index 11ea062..e6755e1 100644
--- a/math/s_catanh_template.c
+++ b/math/s_catanh_template.c
@@ -1,4 +1,4 @@
-/* Return arc hyperbole tangent for double value.
+/* Return arc hyperbolic tangent for a 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,10 +22,10 @@
 #include <math_private.h>
 #include <float.h>
 
-__complex__ double
-__catanh (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__catanh) (CFLOAT x)
 {
-  __complex__ double res;
+  CFLOAT res;
   int rcls = fpclassify (__real__ x);
   int icls = fpclassify (__imag__ x);
 
@@ -33,21 +33,21 @@ __catanh (__complex__ double x)
     {
       if (icls == FP_INFINITE)
 	{
-	  __real__ res = __copysign (0.0, __real__ x);
-	  __imag__ res = __copysign (M_PI_2, __imag__ x);
+	  __real__ res = M_COPYSIGN (0, __real__ x);
+	  __imag__ res = M_COPYSIGN (M_MLIT (M_PI_2), __imag__ x);
 	}
       else if (rcls == FP_INFINITE || rcls == FP_ZERO)
 	{
-	  __real__ res = __copysign (0.0, __real__ x);
+	  __real__ res = M_COPYSIGN (0, __real__ x);
 	  if (icls >= FP_ZERO)
-	    __imag__ res = __copysign (M_PI_2, __imag__ x);
+	    __imag__ res = M_COPYSIGN (M_MLIT (M_PI_2), __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 (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
@@ -56,73 +56,74 @@ __catanh (__complex__ double x)
     }
   else
     {
-      if (fabs (__real__ x) >= 16.0 / DBL_EPSILON
-	  || fabs (__imag__ x) >= 16.0 / DBL_EPSILON)
+      if (M_FABS (__real__ x) >= 16 / M_EPSILON
+	  || M_FABS (__imag__ x) >= 16 / M_EPSILON)
 	{
-	  __imag__ res = __copysign (M_PI_2, __imag__ x);
-	  if (fabs (__imag__ x) <= 1.0)
-	    __real__ res = 1.0 / __real__ x;
-	  else if (fabs (__real__ x) <= 1.0)
+	  __imag__ res = M_COPYSIGN (M_MLIT (M_PI_2), __imag__ x);
+	  if (M_FABS (__imag__ x) <= 1)
+	    __real__ res = 1 / __real__ x;
+	  else if (M_FABS (__real__ x) <= 1)
 	    __real__ res = __real__ x / __imag__ x / __imag__ x;
 	  else
 	    {
-	      double h = __ieee754_hypot (__real__ x / 2.0, __imag__ x / 2.0);
-	      __real__ res = __real__ x / h / h / 4.0;
+	      FLOAT h = M_HYPOT (__real__ x / 2, __imag__ x / 2);
+	      __real__ res = __real__ x / h / h / 4;
 	    }
 	}
       else
 	{
-	  if (fabs (__real__ x) == 1.0
-	      && fabs (__imag__ x) < DBL_EPSILON * DBL_EPSILON)
-	    __real__ res = (__copysign (0.5, __real__ x)
-			    * (M_LN2 - __ieee754_log (fabs (__imag__ x))));
+	  if (M_FABS (__real__ x) == 1
+	      && M_FABS (__imag__ x) < M_EPSILON * M_EPSILON)
+	    __real__ res = (M_COPYSIGN (M_LIT (0.5), __real__ x)
+			    * ((FLOAT) M_MLIT (M_LN2)
+			       - M_LOG (M_FABS (__imag__ x))));
 	  else
 	    {
-	      double i2 = 0.0;
-	      if (fabs (__imag__ x) >= DBL_EPSILON * DBL_EPSILON)
+	      FLOAT i2 = 0;
+	      if (M_FABS (__imag__ x) >= M_EPSILON * M_EPSILON)
 		i2 = __imag__ x * __imag__ x;
 
-	      double num = 1.0 + __real__ x;
+	      FLOAT num = 1 + __real__ x;
 	      num = i2 + num * num;
 
-	      double den = 1.0 - __real__ x;
+	      FLOAT den = 1 - __real__ x;
 	      den = i2 + den * den;
 
-	      double f = num / den;
-	      if (f < 0.5)
-		__real__ res = 0.25 * __ieee754_log (f);
+	      FLOAT f = num / den;
+	      if (f < M_LIT (0.5))
+		__real__ res = M_LIT (0.25) * M_LOG (f);
 	      else
 		{
-		  num = 4.0 * __real__ x;
-		  __real__ res = 0.25 * __log1p (num / den);
+		  num = 4 * __real__ x;
+		  __real__ res = M_LIT (0.25) * M_LOG1P (num / den);
 		}
 	    }
 
-	  double absx, absy, den;
+	  FLOAT absx, absy, den;
 
-	  absx = fabs (__real__ x);
-	  absy = fabs (__imag__ x);
+	  absx = M_FABS (__real__ x);
+	  absy = M_FABS (__imag__ x);
 	  if (absx < absy)
 	    {
-	      double t = absx;
+	      FLOAT t = absx;
 	      absx = absy;
 	      absy = t;
 	    }
 
-	  if (absy < DBL_EPSILON / 2.0)
+	  if (absy < M_EPSILON / 2)
 	    {
-	      den = (1.0 - absx) * (1.0 + absx);
-	      if (den == -0.0)
-		den = 0.0;
+	      den = (1 - absx) * (1 + absx);
+	      if (den == M_LIT (-0.0))
+		den = 0;
 	    }
-	  else if (absx >= 1.0)
-	    den = (1.0 - absx) * (1.0 + absx) - absy * absy;
-	  else if (absx >= 0.75 || absy >= 0.5)
-	    den = -__x2y2m1 (absx, absy);
+	  else if (absx >= 1)
+	    den = (1 - absx) * (1 + absx) - absy * absy;
+	  else if (absx >= M_LIT (0.75) || absy >= M_LIT (0.5))
+	    den = -M_SUF (__x2y2m1) (absx, absy);
 	  else
-	    den = (1.0 - absx) * (1.0 + absx) - absy * absy;
+	    den = (1 - absx) * (1 + absx) - absy * absy;
 
-	  __imag__ res = 0.5 * __ieee754_atan2 (2.0 * __imag__ x, den);
+	  __imag__ res = M_LIT (0.5) * M_ATAN2 (2 * __imag__ x, den);
 	}
 
       math_check_force_underflow_complex (res);
@@ -130,8 +131,9 @@ __catanh (__complex__ double x)
 
   return res;
 }
-weak_alias (__catanh, catanh)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__catanh, __catanhl)
-weak_alias (__catanh, catanhl)
+
+declare_mgen_alias (__catanh, catanh)
+
+#if M_LIBM_NEED_COMPAT (catanh)
+declare_mgen_libm_compat (__catanh, catanh)
 #endif
diff --git a/math/s_catanhf.c b/math/s_catanhf.c
deleted file mode 100644
index fe43a51..0000000
--- a/math/s_catanhf.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/* Return arc hyperbole tangent 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>
-#include <float.h>
-
-__complex__ float
-__catanhf (__complex__ float x)
-{
-  __complex__ float res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE))
-    {
-      if (icls == FP_INFINITE)
-	{
-	  __real__ res = __copysignf (0.0, __real__ x);
-	  __imag__ res = __copysignf (M_PI_2, __imag__ x);
-	}
-      else if (rcls == FP_INFINITE || rcls == FP_ZERO)
-	{
-	  __real__ res = __copysignf (0.0, __real__ x);
-	  if (icls >= FP_ZERO)
-	    __imag__ res = __copysignf (M_PI_2, __imag__ x);
-	  else
-	    __imag__ res = __nanf ("");
-	}
-      else
-	{
-	  __real__ res = __nanf ("");
-	  __imag__ res = __nanf ("");
-	}
-    }
-  else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      res = x;
-    }
-  else
-    {
-      if (fabsf (__real__ x) >= 16.0f / FLT_EPSILON
-	  || fabsf (__imag__ x) >= 16.0f / FLT_EPSILON)
-	{
-	  __imag__ res = __copysignf ((float) M_PI_2, __imag__ x);
-	  if (fabsf (__imag__ x) <= 1.0f)
-	    __real__ res = 1.0f / __real__ x;
-	  else if (fabsf (__real__ x) <= 1.0f)
-	    __real__ res = __real__ x / __imag__ x / __imag__ x;
-	  else
-	    {
-	      float h = __ieee754_hypotf (__real__ x / 2.0f,
-					  __imag__ x / 2.0f);
-	      __real__ res = __real__ x / h / h / 4.0f;
-	    }
-	}
-      else
-	{
-	  if (fabsf (__real__ x) == 1.0f
-	      && fabsf (__imag__ x) < FLT_EPSILON * FLT_EPSILON)
-	    __real__ res = (__copysignf (0.5f, __real__ x)
-			    * ((float) M_LN2
-			       - __ieee754_logf (fabsf (__imag__ x))));
-	  else
-	    {
-	      float i2 = 0.0f;
-	      if (fabsf (__imag__ x) >= FLT_EPSILON * FLT_EPSILON)
-		i2 = __imag__ x * __imag__ x;
-
-	      float num = 1.0f + __real__ x;
-	      num = i2 + num * num;
-
-	      float den = 1.0f - __real__ x;
-	      den = i2 + den * den;
-
-	      float f = num / den;
-	      if (f < 0.5f)
-		__real__ res = 0.25f * __ieee754_logf (f);
-	      else
-		{
-		  num = 4.0f * __real__ x;
-		  __real__ res = 0.25f * __log1pf (num / den);
-		}
-	    }
-
-	  float absx, absy, den;
-
-	  absx = fabsf (__real__ x);
-	  absy = fabsf (__imag__ x);
-	  if (absx < absy)
-	    {
-	      float t = absx;
-	      absx = absy;
-	      absy = t;
-	    }
-
-	  if (absy < FLT_EPSILON / 2.0f)
-	    {
-	      den = (1.0f - absx) * (1.0f + absx);
-	      if (den == -0.0f)
-		den = 0.0f;
-	    }
-	  else if (absx >= 1.0f)
-	    den = (1.0f - absx) * (1.0f + absx) - absy * absy;
-	  else if (absx >= 0.75f || absy >= 0.5f)
-	    den = -__x2y2m1f (absx, absy);
-	  else
-	    den = (1.0f - absx) * (1.0f + absx) - absy * absy;
-
-	  __imag__ res = 0.5f * __ieee754_atan2f (2.0f * __imag__ x, den);
-	}
-
-      math_check_force_underflow_complex (res);
-    }
-
-  return res;
-}
-#ifndef __catanhf
-weak_alias (__catanhf, catanhf)
-#endif
diff --git a/math/s_catanhl.c b/math/s_catanhl.c
deleted file mode 100644
index 4c8e871..0000000
--- a/math/s_catanhl.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/* Return arc hyperbole tangent 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>
-#include <float.h>
-
-/* To avoid spurious overflows, use this definition to treat IBM long
-   double as approximating an IEEE-style format.  */
-#if LDBL_MANT_DIG == 106
-# undef LDBL_EPSILON
-# define LDBL_EPSILON 0x1p-106L
-#endif
-
-__complex__ long double
-__catanhl (__complex__ long double x)
-{
-  __complex__ long double res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE))
-    {
-      if (icls == FP_INFINITE)
-	{
-	  __real__ res = __copysignl (0.0, __real__ x);
-	  __imag__ res = __copysignl (M_PI_2l, __imag__ x);
-	}
-      else if (rcls == FP_INFINITE || rcls == FP_ZERO)
-	{
-	  __real__ res = __copysignl (0.0, __real__ x);
-	  if (icls >= FP_ZERO)
-	    __imag__ res = __copysignl (M_PI_2l, __imag__ x);
-	  else
-	    __imag__ res = __nanl ("");
-	}
-      else
-	{
-	  __real__ res = __nanl ("");
-	  __imag__ res = __nanl ("");
-	}
-    }
-  else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      res = x;
-    }
-  else
-    {
-      if (fabsl (__real__ x) >= 16.0L / LDBL_EPSILON
-	  || fabsl (__imag__ x) >= 16.0L / LDBL_EPSILON)
-	{
-	  __imag__ res = __copysignl (M_PI_2l, __imag__ x);
-	  if (fabsl (__imag__ x) <= 1.0L)
-	    __real__ res = 1.0L / __real__ x;
-	  else if (fabsl (__real__ x) <= 1.0L)
-	    __real__ res = __real__ x / __imag__ x / __imag__ x;
-	  else
-	    {
-	      long double h = __ieee754_hypotl (__real__ x / 2.0L,
-						__imag__ x / 2.0L);
-	      __real__ res = __real__ x / h / h / 4.0L;
-	    }
-	}
-      else
-	{
-	  if (fabsl (__real__ x) == 1.0L
-	      && fabsl (__imag__ x) < LDBL_EPSILON * LDBL_EPSILON)
-	    __real__ res = (__copysignl (0.5L, __real__ x)
-			    * (M_LN2l - __ieee754_logl (fabsl (__imag__ x))));
-	  else
-	    {
-	      long double i2 = 0.0;
-	      if (fabsl (__imag__ x) >= LDBL_EPSILON * LDBL_EPSILON)
-		i2 = __imag__ x * __imag__ x;
-
-	      long double num = 1.0L + __real__ x;
-	      num = i2 + num * num;
-
-	      long double den = 1.0L - __real__ x;
-	      den = i2 + den * den;
-
-	      long double f = num / den;
-	      if (f < 0.5L)
-		__real__ res = 0.25L * __ieee754_logl (f);
-	      else
-		{
-		  num = 4.0L * __real__ x;
-		  __real__ res = 0.25L * __log1pl (num / den);
-		}
-	    }
-
-	  long double absx, absy, den;
-
-	  absx = fabsl (__real__ x);
-	  absy = fabsl (__imag__ x);
-	  if (absx < absy)
-	    {
-	      long double t = absx;
-	      absx = absy;
-	      absy = t;
-	    }
-
-	  if (absy < LDBL_EPSILON / 2.0L)
-	    {
-	      den = (1.0L - absx) * (1.0L + absx);
-	      if (den == -0.0L)
-		den = 0.0L;
-	    }
-	  else if (absx >= 1.0L)
-	    den = (1.0L - absx) * (1.0L + absx) - absy * absy;
-	  else if (absx >= 0.75L || absy >= 0.5L)
-	    den = -__x2y2m1l (absx, absy);
-	  else
-	    den = (1.0L - absx) * (1.0L + absx) - absy * absy;
-
-	  __imag__ res = 0.5L * __ieee754_atan2l (2.0L * __imag__ x, den);
-	}
-
-      math_check_force_underflow_complex (res);
-    }
-
-  return res;
-}
-weak_alias (__catanhl, catanhl)
diff --git a/math/s_catanl.c b/math/s_catanl.c
deleted file mode 100644
index 4425002..0000000
--- a/math/s_catanl.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/* Return arc tangent 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>
-#include <math_private.h>
-#include <float.h>
-
-/* To avoid spurious overflows, use this definition to treat IBM long
-   double as approximating an IEEE-style format.  */
-#if LDBL_MANT_DIG == 106
-# undef LDBL_EPSILON
-# define LDBL_EPSILON 0x1p-106L
-#endif
-
-__complex__ long double
-__catanl (__complex__ long double x)
-{
-  __complex__ long double res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE))
-    {
-      if (rcls == FP_INFINITE)
-	{
-	  __real__ res = __copysignl (M_PI_2l, __real__ x);
-	  __imag__ res = __copysignl (0.0, __imag__ x);
-	}
-      else if (icls == FP_INFINITE)
-	{
-	  if (rcls >= FP_ZERO)
-	    __real__ res = __copysignl (M_PI_2l, __real__ x);
-	  else
-	    __real__ res = __nanl ("");
-	  __imag__ res = __copysignl (0.0, __imag__ x);
-	}
-      else if (icls == FP_ZERO || icls == FP_INFINITE)
-	{
-	  __real__ res = __nanl ("");
-	  __imag__ res = __copysignl (0.0, __imag__ x);
-	}
-      else
-	{
-	  __real__ res = __nanl ("");
-	  __imag__ res = __nanl ("");
-	}
-    }
-  else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      res = x;
-    }
-  else
-    {
-      if (fabsl (__real__ x) >= 16.0L / LDBL_EPSILON
-	  || fabsl (__imag__ x) >= 16.0L / LDBL_EPSILON)
-	{
-	  __real__ res = __copysignl (M_PI_2l, __real__ x);
-	  if (fabsl (__real__ x) <= 1.0L)
-	    __imag__ res = 1.0L / __imag__ x;
-	  else if (fabsl (__imag__ x) <= 1.0L)
-	    __imag__ res = __imag__ x / __real__ x / __real__ x;
-	  else
-	    {
-	      long double h = __ieee754_hypotl (__real__ x / 2.0L,
-						__imag__ x / 2.0L);
-	      __imag__ res = __imag__ x / h / h / 4.0L;
-	    }
-	}
-      else
-	{
-	  long double den, absx, absy;
-
-	  absx = fabsl (__real__ x);
-	  absy = fabsl (__imag__ x);
-	  if (absx < absy)
-	    {
-	      long double t = absx;
-	      absx = absy;
-	      absy = t;
-	    }
-
-	  if (absy < LDBL_EPSILON / 2.0L)
-	    {
-	      den = (1.0L - absx) * (1.0L + absx);
-	      if (den == -0.0L)
-		den = 0.0L;
-	    }
-	  else if (absx >= 1.0L)
-	    den = (1.0L - absx) * (1.0L + absx) - absy * absy;
-	  else if (absx >= 0.75L || absy >= 0.5L)
-	    den = -__x2y2m1l (absx, absy);
-	  else
-	    den = (1.0L - absx) * (1.0L + absx) - absy * absy;
-
-	  __real__ res = 0.5L * __ieee754_atan2l (2.0L * __real__ x, den);
-
-	  if (fabsl (__imag__ x) == 1.0L
-	      && fabsl (__real__ x) < LDBL_EPSILON * LDBL_EPSILON)
-	    __imag__ res = (__copysignl (0.5L, __imag__ x)
-			    * (M_LN2l - __ieee754_logl (fabsl (__real__ x))));
-	  else
-	    {
-	      long double r2 = 0.0L, num, f;
-
-	      if (fabsl (__real__ x) >= LDBL_EPSILON * LDBL_EPSILON)
-		r2 = __real__ x * __real__ x;
-
-	      num = __imag__ x + 1.0L;
-	      num = r2 + num * num;
-
-	      den = __imag__ x - 1.0L;
-	      den = r2 + den * den;
-
-	      f = num / den;
-	      if (f < 0.5L)
-		__imag__ res = 0.25L * __ieee754_logl (f);
-	      else
-		{
-		  num = 4.0L * __imag__ x;
-		  __imag__ res = 0.25L * __log1pl (num / den);
-		}
-	    }
-	}
-
-      math_check_force_underflow_complex (res);
-    }
-
-  return res;
-}
-weak_alias (__catanl, catanl)
diff --git a/math/s_ctan.c b/math/s_ctan.c
deleted file mode 100644
index 8e8bf2e..0000000
--- a/math/s_ctan.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Complex tangent 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
-__ctan (__complex__ double x)
-{
-  __complex__ double res;
-
-  if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x)))
-    {
-      if (isinf (__imag__ x))
-	{
-	  if (isfinite (__real__ x) && fabs (__real__ x) > 1.0)
-	    {
-	      double sinrx, cosrx;
-	      __sincos (__real__ x, &sinrx, &cosrx);
-	      __real__ res = __copysign (0.0, sinrx * cosrx);
-	    }
-	  else
-	    __real__ res = __copysign (0.0, __real__ x);
-	  __imag__ res = __copysign (1.0, __imag__ x);
-	}
-      else if (__real__ x == 0.0)
-	{
-	  res = x;
-	}
-      else
-	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
-
-	  if (isinf (__real__ x))
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else
-    {
-      double sinrx, cosrx;
-      double den;
-      const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2 / 2);
-
-      /* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y))
-	 = (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */
-
-      if (__glibc_likely (fabs (__real__ x) > DBL_MIN))
-	{
-	  __sincos (__real__ x, &sinrx, &cosrx);
-	}
-      else
-	{
-	  sinrx = __real__ x;
-	  cosrx = 1.0;
-	}
-
-      if (fabs (__imag__ x) > t)
-	{
-	  /* Avoid intermediate overflow when the real part of the
-	     result may be subnormal.  Ignoring negligible terms, the
-	     imaginary part is +/- 1, the real part is
-	     sin(x)*cos(x)/sinh(y)^2 = 4*sin(x)*cos(x)/exp(2y).  */
-	  double exp_2t = __ieee754_exp (2 * t);
-
-	  __imag__ res = __copysign (1.0, __imag__ x);
-	  __real__ res = 4 * sinrx * cosrx;
-	  __imag__ x = fabs (__imag__ x);
-	  __imag__ x -= t;
-	  __real__ res /= exp_2t;
-	  if (__imag__ x > t)
-	    {
-	      /* Underflow (original imaginary part of x has absolute
-		 value > 2t).  */
-	      __real__ res /= exp_2t;
-	    }
-	  else
-	    __real__ res /= __ieee754_exp (2 * __imag__ x);
-	}
-      else
-	{
-	  double sinhix, coshix;
-	  if (fabs (__imag__ x) > DBL_MIN)
-	    {
-	      sinhix = __ieee754_sinh (__imag__ x);
-	      coshix = __ieee754_cosh (__imag__ x);
-	    }
-	  else
-	    {
-	      sinhix = __imag__ x;
-	      coshix = 1.0;
-	    }
-
-	  if (fabs (sinhix) > fabs (cosrx) * DBL_EPSILON)
-	    den = cosrx * cosrx + sinhix * sinhix;
-	  else
-	    den = cosrx * cosrx;
-	  __real__ res = sinrx * cosrx / den;
-	  __imag__ res = sinhix * coshix / den;
-	}
-      math_check_force_underflow_complex (res);
-    }
-
-  return res;
-}
-weak_alias (__ctan, ctan)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__ctan, __ctanl)
-weak_alias (__ctan, ctanl)
-#endif
diff --git a/math/s_ctan_template.c b/math/s_ctan_template.c
index 8e8bf2e..96efa47 100644
--- a/math/s_ctan_template.c
+++ b/math/s_ctan_template.c
@@ -1,4 +1,4 @@
-/* Complex tangent function for double.
+/* Complex tangent function for a 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.
@@ -23,33 +23,33 @@
 #include <math_private.h>
 #include <float.h>
 
-__complex__ double
-__ctan (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__ctan) (CFLOAT x)
 {
-  __complex__ double res;
+  CFLOAT res;
 
   if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x)))
     {
       if (isinf (__imag__ x))
 	{
-	  if (isfinite (__real__ x) && fabs (__real__ x) > 1.0)
+	  if (isfinite (__real__ x) && M_FABS (__real__ x) > 1)
 	    {
-	      double sinrx, cosrx;
-	      __sincos (__real__ x, &sinrx, &cosrx);
-	      __real__ res = __copysign (0.0, sinrx * cosrx);
+	      FLOAT sinrx, cosrx;
+	      M_SINCOS (__real__ x, &sinrx, &cosrx);
+	      __real__ res = M_COPYSIGN (0, sinrx * cosrx);
 	    }
 	  else
-	    __real__ res = __copysign (0.0, __real__ x);
-	  __imag__ res = __copysign (1.0, __imag__ x);
+	    __real__ res = M_COPYSIGN (0, __real__ x);
+	  __imag__ res = M_COPYSIGN (1, __imag__ x);
 	}
-      else if (__real__ x == 0.0)
+      else if (__real__ x == 0)
 	{
 	  res = x;
 	}
       else
 	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
+	  __real__ res = M_NAN;
+	  __imag__ res = M_NAN;
 
 	  if (isinf (__real__ x))
 	    feraiseexcept (FE_INVALID);
@@ -57,34 +57,34 @@ __ctan (__complex__ double x)
     }
   else
     {
-      double sinrx, cosrx;
-      double den;
-      const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2 / 2);
+      FLOAT sinrx, cosrx;
+      FLOAT den;
+      const int t = (int) ((M_MAX_EXP - 1) * M_MLIT (M_LN2) / 2);
 
       /* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y))
 	 = (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */
 
-      if (__glibc_likely (fabs (__real__ x) > DBL_MIN))
+      if (__glibc_likely (M_FABS (__real__ x) > M_MIN))
 	{
-	  __sincos (__real__ x, &sinrx, &cosrx);
+	  M_SINCOS (__real__ x, &sinrx, &cosrx);
 	}
       else
 	{
 	  sinrx = __real__ x;
-	  cosrx = 1.0;
+	  cosrx = 1;
 	}
 
-      if (fabs (__imag__ x) > t)
+      if (M_FABS (__imag__ x) > t)
 	{
 	  /* Avoid intermediate overflow when the real part of the
 	     result may be subnormal.  Ignoring negligible terms, the
 	     imaginary part is +/- 1, the real part is
 	     sin(x)*cos(x)/sinh(y)^2 = 4*sin(x)*cos(x)/exp(2y).  */
-	  double exp_2t = __ieee754_exp (2 * t);
+	  FLOAT exp_2t = M_EXP (2 * t);
 
-	  __imag__ res = __copysign (1.0, __imag__ x);
+	  __imag__ res = M_COPYSIGN (1, __imag__ x);
 	  __real__ res = 4 * sinrx * cosrx;
-	  __imag__ x = fabs (__imag__ x);
+	  __imag__ x = M_FABS (__imag__ x);
 	  __imag__ x -= t;
 	  __real__ res /= exp_2t;
 	  if (__imag__ x > t)
@@ -94,23 +94,23 @@ __ctan (__complex__ double x)
 	      __real__ res /= exp_2t;
 	    }
 	  else
-	    __real__ res /= __ieee754_exp (2 * __imag__ x);
+	    __real__ res /= M_EXP (2 * __imag__ x);
 	}
       else
 	{
-	  double sinhix, coshix;
-	  if (fabs (__imag__ x) > DBL_MIN)
+	  FLOAT sinhix, coshix;
+	  if (M_FABS (__imag__ x) > M_MIN)
 	    {
-	      sinhix = __ieee754_sinh (__imag__ x);
-	      coshix = __ieee754_cosh (__imag__ x);
+	      sinhix = M_SINH (__imag__ x);
+	      coshix = M_COSH (__imag__ x);
 	    }
 	  else
 	    {
 	      sinhix = __imag__ x;
-	      coshix = 1.0;
+	      coshix = 1;
 	    }
 
-	  if (fabs (sinhix) > fabs (cosrx) * DBL_EPSILON)
+	  if (M_FABS (sinhix) > M_FABS (cosrx) * M_EPSILON)
 	    den = cosrx * cosrx + sinhix * sinhix;
 	  else
 	    den = cosrx * cosrx;
@@ -122,8 +122,9 @@ __ctan (__complex__ double x)
 
   return res;
 }
-weak_alias (__ctan, ctan)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__ctan, __ctanl)
-weak_alias (__ctan, ctanl)
+
+declare_mgen_alias (__ctan, ctan)
+
+#if M_LIBM_NEED_COMPAT (ctan)
+declare_mgen_libm_compat (__ctan, ctan)
 #endif
diff --git a/math/s_ctanf.c b/math/s_ctanf.c
deleted file mode 100644
index 0db2c90..0000000
--- a/math/s_ctanf.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* Complex tangent 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
-__ctanf (__complex__ float x)
-{
-  __complex__ float res;
-
-  if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x)))
-    {
-      if (isinf (__imag__ x))
-	{
-	  if (isfinite (__real__ x) && fabsf (__real__ x) > 1.0f)
-	    {
-	      float sinrx, cosrx;
-	      __sincosf (__real__ x, &sinrx, &cosrx);
-	      __real__ res = __copysignf (0.0f, sinrx * cosrx);
-	    }
-	  else
-	    __real__ res = __copysignf (0.0, __real__ x);
-	  __imag__ res = __copysignf (1.0, __imag__ x);
-	}
-      else if (__real__ x == 0.0)
-	{
-	  res = x;
-	}
-      else
-	{
-	  __real__ res = __nanf ("");
-	  __imag__ res = __nanf ("");
-
-	  if (isinf (__real__ x))
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else
-    {
-      float sinrx, cosrx;
-      float den;
-      const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2 / 2);
-
-      /* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y))
-	 = (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */
-
-      if (__glibc_likely (fabsf (__real__ x) > FLT_MIN))
-	{
-	  __sincosf (__real__ x, &sinrx, &cosrx);
-	}
-      else
-	{
-	  sinrx = __real__ x;
-	  cosrx = 1.0f;
-	}
-
-      if (fabsf (__imag__ x) > t)
-	{
-	  /* Avoid intermediate overflow when the real part of the
-	     result may be subnormal.  Ignoring negligible terms, the
-	     imaginary part is +/- 1, the real part is
-	     sin(x)*cos(x)/sinh(y)^2 = 4*sin(x)*cos(x)/exp(2y).  */
-	  float exp_2t = __ieee754_expf (2 * t);
-
-	  __imag__ res = __copysignf (1.0, __imag__ x);
-	  __real__ res = 4 * sinrx * cosrx;
-	  __imag__ x = fabsf (__imag__ x);
-	  __imag__ x -= t;
-	  __real__ res /= exp_2t;
-	  if (__imag__ x > t)
-	    {
-	      /* Underflow (original imaginary part of x has absolute
-		 value > 2t).  */
-	      __real__ res /= exp_2t;
-	    }
-	  else
-	    __real__ res /= __ieee754_expf (2 * __imag__ x);
-	}
-      else
-	{
-	  float sinhix, coshix;
-	  if (fabsf (__imag__ x) > FLT_MIN)
-	    {
-	      sinhix = __ieee754_sinhf (__imag__ x);
-	      coshix = __ieee754_coshf (__imag__ x);
-	    }
-	  else
-	    {
-	      sinhix = __imag__ x;
-	      coshix = 1.0f;
-	    }
-
-	  if (fabsf (sinhix) > fabsf (cosrx) * FLT_EPSILON)
-	    den = cosrx * cosrx + sinhix * sinhix;
-	  else
-	    den = cosrx * cosrx;
-	  __real__ res = sinrx * cosrx / den;
-	  __imag__ res = sinhix * coshix / den;
-	}
-      math_check_force_underflow_complex (res);
-    }
-
-  return res;
-}
-#ifndef __ctanf
-weak_alias (__ctanf, ctanf)
-#endif
diff --git a/math/s_ctanh.c b/math/s_ctanh.c
deleted file mode 100644
index 2d18875..0000000
--- a/math/s_ctanh.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Complex hyperbole tangent 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
-__ctanh (__complex__ double x)
-{
-  __complex__ double res;
-
-  if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x)))
-    {
-      if (isinf (__real__ x))
-	{
-	  __real__ res = __copysign (1.0, __real__ x);
-	  if (isfinite (__imag__ x) && fabs (__imag__ x) > 1.0)
-	    {
-	      double sinix, cosix;
-	      __sincos (__imag__ x, &sinix, &cosix);
-	      __imag__ res = __copysign (0.0, sinix * cosix);
-	    }
-	  else
-	    __imag__ res = __copysign (0.0, __imag__ x);
-	}
-      else if (__imag__ x == 0.0)
-	{
-	  res = x;
-	}
-      else
-	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
-
-	  if (isinf (__imag__ x))
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else
-    {
-      double sinix, cosix;
-      double den;
-      const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2 / 2);
-
-      /* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y))
-	 = (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2).  */
-
-      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)
-	{
-	  /* Avoid intermediate overflow when the imaginary part of
-	     the result may be subnormal.  Ignoring negligible terms,
-	     the real part is +/- 1, the imaginary part is
-	     sin(y)*cos(y)/sinh(x)^2 = 4*sin(y)*cos(y)/exp(2x).  */
-	  double exp_2t = __ieee754_exp (2 * t);
-
-	  __real__ res = __copysign (1.0, __real__ x);
-	  __imag__ res = 4 * sinix * cosix;
-	  __real__ x = fabs (__real__ x);
-	  __real__ x -= t;
-	  __imag__ res /= exp_2t;
-	  if (__real__ x > t)
-	    {
-	      /* Underflow (original real part of x has absolute value
-		 > 2t).  */
-	      __imag__ res /= exp_2t;
-	    }
-	  else
-	    __imag__ res /= __ieee754_exp (2 * __real__ x);
-	}
-      else
-	{
-	  double sinhrx, coshrx;
-	  if (fabs (__real__ x) > DBL_MIN)
-	    {
-	      sinhrx = __ieee754_sinh (__real__ x);
-	      coshrx = __ieee754_cosh (__real__ x);
-	    }
-	  else
-	    {
-	      sinhrx = __real__ x;
-	      coshrx = 1.0;
-	    }
-
-	  if (fabs (sinhrx) > fabs (cosix) * DBL_EPSILON)
-	    den = sinhrx * sinhrx + cosix * cosix;
-	  else
-	    den = cosix * cosix;
-	  __real__ res = sinhrx * coshrx / den;
-	  __imag__ res = sinix * cosix / den;
-	}
-      math_check_force_underflow_complex (res);
-    }
-
-  return res;
-}
-weak_alias (__ctanh, ctanh)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__ctanh, __ctanhl)
-weak_alias (__ctanh, ctanhl)
-#endif
diff --git a/math/s_ctanh_template.c b/math/s_ctanh_template.c
index 2d18875..a7b7ebc 100644
--- a/math/s_ctanh_template.c
+++ b/math/s_ctanh_template.c
@@ -1,4 +1,4 @@
-/* Complex hyperbole tangent for double.
+/* Complex hyperbolic tangent 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,33 +23,33 @@
 #include <math_private.h>
 #include <float.h>
 
-__complex__ double
-__ctanh (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__ctanh) (CFLOAT x)
 {
-  __complex__ double res;
+  CFLOAT res;
 
   if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x)))
     {
       if (isinf (__real__ x))
 	{
-	  __real__ res = __copysign (1.0, __real__ x);
-	  if (isfinite (__imag__ x) && fabs (__imag__ x) > 1.0)
+	  __real__ res = M_COPYSIGN (1, __real__ x);
+	  if (isfinite (__imag__ x) && M_FABS (__imag__ x) > 1)
 	    {
-	      double sinix, cosix;
-	      __sincos (__imag__ x, &sinix, &cosix);
-	      __imag__ res = __copysign (0.0, sinix * cosix);
+	      FLOAT sinix, cosix;
+	      M_SINCOS (__imag__ x, &sinix, &cosix);
+	      __imag__ res = M_COPYSIGN (0, sinix * cosix);
 	    }
 	  else
-	    __imag__ res = __copysign (0.0, __imag__ x);
+	    __imag__ res = M_COPYSIGN (0, __imag__ x);
 	}
-      else if (__imag__ x == 0.0)
+      else if (__imag__ x == 0)
 	{
 	  res = x;
 	}
       else
 	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
+	  __real__ res = M_NAN;
+	  __imag__ res = M_NAN;
 
 	  if (isinf (__imag__ x))
 	    feraiseexcept (FE_INVALID);
@@ -57,34 +57,34 @@ __ctanh (__complex__ double x)
     }
   else
     {
-      double sinix, cosix;
-      double den;
-      const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2 / 2);
+      FLOAT sinix, cosix;
+      FLOAT den;
+      const int t = (int) ((M_MAX_EXP - 1) * M_MLIT (M_LN2) / 2);
 
       /* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y))
 	 = (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2).  */
 
-      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)
 	{
 	  /* Avoid intermediate overflow when the imaginary part of
 	     the result may be subnormal.  Ignoring negligible terms,
 	     the real part is +/- 1, the imaginary part is
 	     sin(y)*cos(y)/sinh(x)^2 = 4*sin(y)*cos(y)/exp(2x).  */
-	  double exp_2t = __ieee754_exp (2 * t);
+	  FLOAT exp_2t = M_EXP (2 * t);
 
-	  __real__ res = __copysign (1.0, __real__ x);
+	  __real__ res = M_COPYSIGN (1, __real__ x);
 	  __imag__ res = 4 * sinix * cosix;
-	  __real__ x = fabs (__real__ x);
+	  __real__ x = M_FABS (__real__ x);
 	  __real__ x -= t;
 	  __imag__ res /= exp_2t;
 	  if (__real__ x > t)
@@ -94,23 +94,23 @@ __ctanh (__complex__ double x)
 	      __imag__ res /= exp_2t;
 	    }
 	  else
-	    __imag__ res /= __ieee754_exp (2 * __real__ x);
+	    __imag__ res /= M_EXP (2 * __real__ x);
 	}
       else
 	{
-	  double sinhrx, coshrx;
-	  if (fabs (__real__ x) > DBL_MIN)
+	  FLOAT sinhrx, coshrx;
+	  if (M_FABS (__real__ x) > M_MIN)
 	    {
-	      sinhrx = __ieee754_sinh (__real__ x);
-	      coshrx = __ieee754_cosh (__real__ x);
+	      sinhrx = M_SINH (__real__ x);
+	      coshrx = M_COSH (__real__ x);
 	    }
 	  else
 	    {
 	      sinhrx = __real__ x;
-	      coshrx = 1.0;
+	      coshrx = 1;
 	    }
 
-	  if (fabs (sinhrx) > fabs (cosix) * DBL_EPSILON)
+	  if (M_FABS (sinhrx) > M_FABS (cosix) * M_EPSILON)
 	    den = sinhrx * sinhrx + cosix * cosix;
 	  else
 	    den = cosix * cosix;
@@ -122,8 +122,9 @@ __ctanh (__complex__ double x)
 
   return res;
 }
-weak_alias (__ctanh, ctanh)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__ctanh, __ctanhl)
-weak_alias (__ctanh, ctanhl)
+
+declare_mgen_alias (__ctanh, ctanh)
+
+#if M_LIBM_NEED_COMPAT (ctanh)
+declare_mgen_libm_compat (__ctanh, ctanh)
 #endif
diff --git a/math/s_ctanhf.c b/math/s_ctanhf.c
deleted file mode 100644
index ffe95f6..0000000
--- a/math/s_ctanhf.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* Complex hyperbole tangent 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
-__ctanhf (__complex__ float x)
-{
-  __complex__ float res;
-
-  if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x)))
-    {
-      if (isinf (__real__ x))
-	{
-	  __real__ res = __copysignf (1.0, __real__ x);
-	  if (isfinite (__imag__ x) && fabsf (__imag__ x) > 1.0f)
-	    {
-	      float sinix, cosix;
-	      __sincosf (__imag__ x, &sinix, &cosix);
-	      __imag__ res = __copysignf (0.0f, sinix * cosix);
-	    }
-	  else
-	    __imag__ res = __copysignf (0.0, __imag__ x);
-	}
-      else if (__imag__ x == 0.0)
-	{
-	  res = x;
-	}
-      else
-	{
-	  __real__ res = __nanf ("");
-	  __imag__ res = __nanf ("");
-
-	  if (isinf (__imag__ x))
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else
-    {
-      float sinix, cosix;
-      float den;
-      const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2 / 2);
-
-      /* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y))
-	 = (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2).  */
-
-      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)
-	{
-	  /* Avoid intermediate overflow when the imaginary part of
-	     the result may be subnormal.  Ignoring negligible terms,
-	     the real part is +/- 1, the imaginary part is
-	     sin(y)*cos(y)/sinh(x)^2 = 4*sin(y)*cos(y)/exp(2x).  */
-	  float exp_2t = __ieee754_expf (2 * t);
-
-	  __real__ res = __copysignf (1.0, __real__ x);
-	  __imag__ res = 4 * sinix * cosix;
-	  __real__ x = fabsf (__real__ x);
-	  __real__ x -= t;
-	  __imag__ res /= exp_2t;
-	  if (__real__ x > t)
-	    {
-	      /* Underflow (original real part of x has absolute value
-		 > 2t).  */
-	      __imag__ res /= exp_2t;
-	    }
-	  else
-	    __imag__ res /= __ieee754_expf (2 * __real__ x);
-	}
-      else
-	{
-	  float sinhrx, coshrx;
-	  if (fabsf (__real__ x) > FLT_MIN)
-	    {
-	      sinhrx = __ieee754_sinhf (__real__ x);
-	      coshrx = __ieee754_coshf (__real__ x);
-	    }
-	  else
-	    {
-	      sinhrx = __real__ x;
-	      coshrx = 1.0f;
-	    }
-
-	  if (fabsf (sinhrx) > fabsf (cosix) * FLT_EPSILON)
-	    den = sinhrx * sinhrx + cosix * cosix;
-	  else
-	    den = cosix * cosix;
-	  __real__ res = sinhrx * coshrx / den;
-	  __imag__ res = sinix * cosix / den;
-	}
-      math_check_force_underflow_complex (res);
-    }
-
-  return res;
-}
-#ifndef __ctanhf
-weak_alias (__ctanhf, ctanhf)
-#endif
diff --git a/math/s_ctanhl.c b/math/s_ctanhl.c
deleted file mode 100644
index 3404d06..0000000
--- a/math/s_ctanhl.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/* Complex hyperbole tangent 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>
-
-/* To avoid spurious underflows, use this definition to treat IBM long
-   double as approximating an IEEE-style format.  */
-#if LDBL_MANT_DIG == 106
-# undef LDBL_EPSILON
-# define LDBL_EPSILON 0x1p-106L
-#endif
-
-__complex__ long double
-__ctanhl (__complex__ long double x)
-{
-  __complex__ long double res;
-
-  if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x)))
-    {
-      if (isinf (__real__ x))
-	{
-	  __real__ res = __copysignl (1.0, __real__ x);
-	  if (isfinite (__imag__ x) && fabsl (__imag__ x) > 1.0L)
-	    {
-	      long double sinix, cosix;
-	      __sincosl (__imag__ x, &sinix, &cosix);
-	      __imag__ res = __copysignl (0.0L, sinix * cosix);
-	    }
-	  else
-	    __imag__ res = __copysignl (0.0, __imag__ x);
-	}
-      else if (__imag__ x == 0.0)
-	{
-	  res = x;
-	}
-      else
-	{
-	  __real__ res = __nanl ("");
-	  __imag__ res = __nanl ("");
-
-	  if (isinf (__imag__ x))
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else
-    {
-      long double sinix, cosix;
-      long double den;
-      const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2);
-
-      /* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y))
-	 = (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2).  */
-
-      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)
-	{
-	  /* Avoid intermediate overflow when the imaginary part of
-	     the result may be subnormal.  Ignoring negligible terms,
-	     the real part is +/- 1, the imaginary part is
-	     sin(y)*cos(y)/sinh(x)^2 = 4*sin(y)*cos(y)/exp(2x).  */
-	  long double exp_2t = __ieee754_expl (2 * t);
-
-	  __real__ res = __copysignl (1.0, __real__ x);
-	  __imag__ res = 4 * sinix * cosix;
-	  __real__ x = fabsl (__real__ x);
-	  __real__ x -= t;
-	  __imag__ res /= exp_2t;
-	  if (__real__ x > t)
-	    {
-	      /* Underflow (original real part of x has absolute value
-		 > 2t).  */
-	      __imag__ res /= exp_2t;
-	    }
-	  else
-	    __imag__ res /= __ieee754_expl (2 * __real__ x);
-	}
-      else
-	{
-	  long double sinhrx, coshrx;
-	  if (fabsl (__real__ x) > LDBL_MIN)
-	    {
-	      sinhrx = __ieee754_sinhl (__real__ x);
-	      coshrx = __ieee754_coshl (__real__ x);
-	    }
-	  else
-	    {
-	      sinhrx = __real__ x;
-	      coshrx = 1.0L;
-	    }
-
-	  if (fabsl (sinhrx) > fabsl (cosix) * LDBL_EPSILON)
-	    den = sinhrx * sinhrx + cosix * cosix;
-	  else
-	    den = cosix * cosix;
-	  __real__ res = sinhrx * coshrx / den;
-	  __imag__ res = sinix * cosix / den;
-	}
-      math_check_force_underflow_complex (res);
-    }
-
-  return res;
-}
-weak_alias (__ctanhl, ctanhl)
diff --git a/math/s_ctanl.c b/math/s_ctanl.c
deleted file mode 100644
index d6be22d..0000000
--- a/math/s_ctanl.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/* Complex tangent 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>
-
-/* To avoid spurious underflows, use this definition to treat IBM long
-   double as approximating an IEEE-style format.  */
-#if LDBL_MANT_DIG == 106
-# undef LDBL_EPSILON
-# define LDBL_EPSILON 0x1p-106L
-#endif
-
-__complex__ long double
-__ctanl (__complex__ long double x)
-{
-  __complex__ long double res;
-
-  if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x)))
-    {
-      if (isinf (__imag__ x))
-	{
-	  if (isfinite (__real__ x) &&  fabsl (__real__ x) > 1.0L)
-	    {
-	      long double sinrx, cosrx;
-	      __sincosl (__real__ x, &sinrx, &cosrx);
-	      __real__ res = __copysignl (0.0L, sinrx * cosrx);
-	    }
-	  else
-	    __real__ res = __copysignl (0.0, __real__ x);
-	  __imag__ res = __copysignl (1.0, __imag__ x);
-	}
-      else if (__real__ x == 0.0)
-	{
-	  res = x;
-	}
-      else
-	{
-	  __real__ res = __nanl ("");
-	  __imag__ res = __nanl ("");
-
-	  if (isinf (__real__ x))
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else
-    {
-      long double sinrx, cosrx;
-      long double den;
-      const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2);
-
-      /* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y))
-	 = (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */
-
-      if (__glibc_likely (fabsl (__real__ x) > LDBL_MIN))
-	{
-	  __sincosl (__real__ x, &sinrx, &cosrx);
-	}
-      else
-	{
-	  sinrx = __real__ x;
-	  cosrx = 1.0;
-	}
-
-      if (fabsl (__imag__ x) > t)
-	{
-	  /* Avoid intermediate overflow when the real part of the
-	     result may be subnormal.  Ignoring negligible terms, the
-	     imaginary part is +/- 1, the real part is
-	     sin(x)*cos(x)/sinh(y)^2 = 4*sin(x)*cos(x)/exp(2y).  */
-	  long double exp_2t = __ieee754_expl (2 * t);
-
-	  __imag__ res = __copysignl (1.0, __imag__ x);
-	  __real__ res = 4 * sinrx * cosrx;
-	  __imag__ x = fabsl (__imag__ x);
-	  __imag__ x -= t;
-	  __real__ res /= exp_2t;
-	  if (__imag__ x > t)
-	    {
-	      /* Underflow (original imaginary part of x has absolute
-		 value > 2t).  */
-	      __real__ res /= exp_2t;
-	    }
-	  else
-	    __real__ res /= __ieee754_expl (2 * __imag__ x);
-	}
-      else
-	{
-	  long double sinhix, coshix;
-	  if (fabsl (__imag__ x) > LDBL_MIN)
-	    {
-	      sinhix = __ieee754_sinhl (__imag__ x);
-	      coshix = __ieee754_coshl (__imag__ x);
-	    }
-	  else
-	    {
-	      sinhix = __imag__ x;
-	      coshix = 1.0L;
-	    }
-
-	  if (fabsl (sinhix) > fabsl (cosrx) * LDBL_EPSILON)
-	    den = cosrx * cosrx + sinhix * sinhix;
-	  else
-	    den = cosrx * cosrx;
-	  __real__ res = sinrx * cosrx / den;
-	  __imag__ res = sinhix * coshix / den;
-	}
-      math_check_force_underflow_complex (res);
-    }
-
-  return res;
-}
-weak_alias (__ctanl, ctanl)
diff --git a/sysdeps/alpha/fpu/s_catanf.c b/sysdeps/alpha/fpu/s_catanf.c
index 76c1718..ee2443d 100644
--- a/sysdeps/alpha/fpu/s_catanf.c
+++ b/sysdeps/alpha/fpu/s_catanf.c
@@ -24,14 +24,18 @@
 
 #undef __catanf
 #undef catanf
-#define __catanf internal_catanf
 
 static _Complex float internal_catanf (_Complex float x);
 
-#include <math/s_catanf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_catanf
+#include <math-type-macros-float.h>
 
-#undef __catanf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_catan_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_catanf (c1_cfloat_decl (x))
diff --git a/sysdeps/alpha/fpu/s_catanhf.c b/sysdeps/alpha/fpu/s_catanhf.c
index 18148dd..d9f2d21 100644
--- a/sysdeps/alpha/fpu/s_catanhf.c
+++ b/sysdeps/alpha/fpu/s_catanhf.c
@@ -24,14 +24,18 @@
 
 #undef __catanhf
 #undef catanhf
-#define __catanhf internal_catanhf
 
 static _Complex float internal_catanhf (_Complex float x);
 
-#include <math/s_catanhf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_catanhf
+#include <math-type-macros-float.h>
 
-#undef __catanhf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_catanh_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_catanhf (c1_cfloat_decl (x))
diff --git a/sysdeps/alpha/fpu/s_ctanf.c b/sysdeps/alpha/fpu/s_ctanf.c
index ee02f31..cd5dd91 100644
--- a/sysdeps/alpha/fpu/s_ctanf.c
+++ b/sysdeps/alpha/fpu/s_ctanf.c
@@ -24,14 +24,18 @@
 
 #undef __ctanf
 #undef ctanf
-#define __ctanf internal_ctanf
 
 static _Complex float internal_ctanf (_Complex float x);
 
-#include <math/s_ctanf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_ctanf
+#include <math-type-macros-float.h>
 
-#undef __ctanf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_ctan_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_ctanf (c1_cfloat_decl (x))
diff --git a/sysdeps/alpha/fpu/s_ctanhf.c b/sysdeps/alpha/fpu/s_ctanhf.c
index cb99279..359f053 100644
--- a/sysdeps/alpha/fpu/s_ctanhf.c
+++ b/sysdeps/alpha/fpu/s_ctanhf.c
@@ -24,14 +24,18 @@
 
 #undef __ctanhf
 #undef ctanhf
-#define __ctanhf internal_ctanhf
 
 static _Complex float internal_ctanhf (_Complex float x);
 
-#include <math/s_ctanhf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_ctanhf
+#include <math-type-macros-float.h>
 
-#undef __ctanhf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_ctanh_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_ctanhf (c1_cfloat_decl (x))
diff --git a/sysdeps/ieee754/ldbl-opt/s_catan.c b/sysdeps/ieee754/ldbl-opt/s_catan.c
deleted file mode 100644
index 19f6173..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_catan.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_catan.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __catan, catanl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_catanh.c b/sysdeps/ieee754/ldbl-opt/s_catanh.c
deleted file mode 100644
index cff7861..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_catanh.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_catanh.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __catanh, catanhl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_catanhl.c b/sysdeps/ieee754/ldbl-opt/s_catanhl.c
deleted file mode 100644
index e956282..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_catanhl.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_catanhl.c>
-long_double_symbol (libm, __catanhl, catanhl);
diff --git a/sysdeps/ieee754/ldbl-opt/s_catanl.c b/sysdeps/ieee754/ldbl-opt/s_catanl.c
deleted file mode 100644
index ee2fdf5..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_catanl.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_catanl.c>
-long_double_symbol (libm, __catanl, catanl);
diff --git a/sysdeps/ieee754/ldbl-opt/s_ctan.c b/sysdeps/ieee754/ldbl-opt/s_ctan.c
deleted file mode 100644
index a6a21f9..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_ctan.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_ctan.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __ctan, ctanl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_ctanh.c b/sysdeps/ieee754/ldbl-opt/s_ctanh.c
deleted file mode 100644
index fd4be12..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_ctanh.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_ctanh.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __ctanh, ctanhl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_ctanhl.c b/sysdeps/ieee754/ldbl-opt/s_ctanhl.c
deleted file mode 100644
index f159373..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_ctanhl.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_ctanhl.c>
-long_double_symbol (libm, __ctanhl, ctanhl);
diff --git a/sysdeps/ieee754/ldbl-opt/s_ctanl.c b/sysdeps/ieee754/ldbl-opt/s_ctanl.c
deleted file mode 100644
index 0c2d94c..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_ctanl.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_ctanl.c>
-long_double_symbol (libm, __ctanl, ctanl);
-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCHv4 4/8] Convert _Complex sine functions to generated code
  2016-08-18 22:35 [PATCHv4 1/8] Prepare to convert _Complex cosine functions Paul E. Murphy
  2016-08-18 22:35 ` [PATCHv4 5/8] Prepare to convert _Complex tangent functions Paul E. Murphy
  2016-08-18 22:35 ` [PATCHv4 3/8] Prepare to convert _Complex sine functions Paul E. Murphy
@ 2016-08-18 22:35 ` Paul E. Murphy
  2016-08-19 17:29   ` Joseph Myers
  2016-08-18 22:35 ` [PATCHv4 2/8] Convert _Complex cosine " Paul E. Murphy
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 20+ messages in thread
From: Paul E. Murphy @ 2016-08-18 22:35 UTC (permalink / raw)
  To: libc-alpha

Refactor s_c{,a}sin{,h}{f,,l} into a single templated
macro.

	* math/Makefile (gen-libm-calls): Move
	casin, casinh, csin, csinh here.
	(libm-calls): Remove the above.

	* math/s_casin_template.c: Update using type-generic macros.
	* math/s_casinh_template.c: Likewise.
	* math/s_csin_template.c: Likewise.
	* math/s_csinh_template.c: Likewise.
	* math/k_casinh_template.c: Likewise.

	* math/s_casinf.c: Removed.
	* math/s_casin.c: Removed.
	* math/s_casinl.c: Removed.
	* math/s_casinh.c: Removed.
	* math/s_casinhf.c: Removed.
	* math/s_casinhl.c: Removed.
	* math/s_csin.c: Removed.
	* math/s_csinf.c: Removed.
	* math/s_csinl.c: Removed.
	* math/s_csinh.c: Removed.
	* math/s_csinhf.c: Removed.
	* math/s_csinhl.c: Removed.
	* math/k_casinh.c: Removed.
	* math/k_casinhf.c: Removed.
	* math/k_casinhl.c: Removed.

	* sysdeps/alpha/fpu/s_casinf.c: Refactor using templated version.
	* sysdeps/alpha/fpu/s_casinhf.c: Likewise.
	* sysdeps/alpha/fpu/s_csinf.c: Likewise.
	* sysdeps/alpha/fpu/s_csinhf.c: Likewise.

	* sysdeps/ieee754/ldbl-opt/s_casin.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_casinh.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_casinhl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_casinl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_csin.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_csinh.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_csinhl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_csinl.c: Removed.

	* sysdeps/m68k/m680x0/fpu/s_csin.c: Refactor into ...
	* sysdeps/m68k/m680x0/fpu/s_csin_template.c: New file.
	* sysdeps/m68k/m680x0/fpu/s_csinf.c: Removed.
	* sysdeps/m68k/m680x0/fpu/s_csinl.c: Removed.

	* sysdeps/m68k/m680x0/fpu/s_csinh.c: Refactor into.
	* sysdeps/m68k/m680x0/fpu/s_csinh_template.c: New file.
	* sysdeps/m68k/m680x0/fpu/s_csinhf.c: Removed.
	* sysdeps/m68k/m680x0/fpu/s_csinhl.c: Removed.
---
 math/Makefile                                      |  13 +-
 math/k_casinh.c                                    | 210 --------------------
 math/k_casinh_template.c                           | 182 +++++++++--------
 math/k_casinhf.c                                   | 212 --------------------
 math/k_casinhl.c                                   | 219 ---------------------
 math/s_casin.c                                     |  66 -------
 math/s_casin_template.c                            |  31 +--
 math/s_casinf.c                                    |  64 ------
 math/s_casinh.c                                    |  73 -------
 math/s_casinh_template.c                           |  34 ++--
 math/s_casinhf.c                                   |  71 -------
 math/s_casinhl.c                                   |  69 -------
 math/s_casinl.c                                    |  62 ------
 math/s_csin.c                                      | 171 ----------------
 math/s_csin_template.c                             |  79 ++++----
 math/s_csinf.c                                     | 169 ----------------
 math/s_csinh.c                                     | 166 ----------------
 math/s_csinh_template.c                            |  79 ++++----
 math/s_csinhf.c                                    | 164 ---------------
 math/s_csinhl.c                                    | 162 ---------------
 math/s_csinl.c                                     | 167 ----------------
 sysdeps/alpha/fpu/s_casinf.c                       |  12 +-
 sysdeps/alpha/fpu/s_casinhf.c                      |  12 +-
 sysdeps/alpha/fpu/s_csinf.c                        |  12 +-
 sysdeps/alpha/fpu/s_csinhf.c                       |  12 +-
 sysdeps/ieee754/ldbl-opt/s_casin.c                 |   6 -
 sysdeps/ieee754/ldbl-opt/s_casinh.c                |   6 -
 sysdeps/ieee754/ldbl-opt/s_casinhl.c               |   6 -
 sysdeps/ieee754/ldbl-opt/s_casinl.c                |   6 -
 sysdeps/ieee754/ldbl-opt/s_csin.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/s_csinh.c                 |   6 -
 sysdeps/ieee754/ldbl-opt/s_csinhl.c                |   6 -
 sysdeps/ieee754/ldbl-opt/s_csinl.c                 |   6 -
 .../m680x0/fpu/{s_csin.c => s_csin_template.c}     |  18 +-
 sysdeps/m68k/m680x0/fpu/s_csinf.c                  |   3 -
 .../m680x0/fpu/{s_csinh.c => s_csinh_template.c}   |  17 +-
 sysdeps/m68k/m680x0/fpu/s_csinhf.c                 |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinhl.c                 |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinl.c                  |   3 -
 39 files changed, 252 insertions(+), 2354 deletions(-)
 delete mode 100644 math/k_casinh.c
 delete mode 100644 math/k_casinhf.c
 delete mode 100644 math/k_casinhl.c
 delete mode 100644 math/s_casin.c
 delete mode 100644 math/s_casinf.c
 delete mode 100644 math/s_casinh.c
 delete mode 100644 math/s_casinhf.c
 delete mode 100644 math/s_casinhl.c
 delete mode 100644 math/s_casinl.c
 delete mode 100644 math/s_csin.c
 delete mode 100644 math/s_csinf.c
 delete mode 100644 math/s_csinh.c
 delete mode 100644 math/s_csinhf.c
 delete mode 100644 math/s_csinhl.c
 delete mode 100644 math/s_csinl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_casin.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_casinh.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_casinhl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_casinl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csin.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csinh.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csinhl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csinl.c
 rename sysdeps/m68k/m680x0/fpu/{s_csin.c => s_csin_template.c} (86%)
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinf.c
 rename sysdeps/m68k/m680x0/fpu/{s_csinh.c => s_csinh_template.c} (88%)
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinhf.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinhl.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinl.c

diff --git a/math/Makefile b/math/Makefile
index e02b430..8873a9e 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -45,8 +45,9 @@ 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 s_cacosF \
-	         s_cacoshF s_ccosF s_ccoshF
+gen-libm-calls = cargF conjF cimagF crealF cabsF s_cacosF		  \
+	         s_cacoshF s_ccosF s_ccoshF s_casinF s_csinF s_casinhF	  \
+		 k_casinhF s_csinhF
 
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
@@ -64,11 +65,11 @@ 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_clogF				  	  \
-	s_catanF s_casinF s_csinF s_ctanF s_ctanhF			  \
-	s_casinhF s_catanhF s_csqrtF s_cpowF s_cprojF s_clog10F 	  \
+	s_cexpF s_clogF							  \
+	s_catanF s_ctanF s_ctanhF					  \
+	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		  \
+	s_issignalingF $(calls:s_%=m_%) x2y2m1F				  \
 	gamma_productF lgamma_negF lgamma_productF			  \
 	s_nextupF s_nextdownF $(gen-libm-calls)
 
diff --git a/math/k_casinh.c b/math/k_casinh.c
deleted file mode 100644
index 354dde1..0000000
--- a/math/k_casinh.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/* Return arc hyperbole sine for double value, with the imaginary part
-   of the result possibly adjusted for use in computing other
-   functions.
-   Copyright (C) 1997-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 <complex.h>
-#include <math.h>
-#include <math_private.h>
-#include <float.h>
-
-/* Return the complex inverse hyperbolic sine of finite nonzero Z,
-   with the imaginary part of the result subtracted from pi/2 if ADJ
-   is nonzero.  */
-
-__complex__ double
-__kernel_casinh (__complex__ double x, int adj)
-{
-  __complex__ double res;
-  double rx, ix;
-  __complex__ double y;
-
-  /* Avoid cancellation by reducing to the first quadrant.  */
-  rx = fabs (__real__ x);
-  ix = fabs (__imag__ x);
-
-  if (rx >= 1.0 / DBL_EPSILON || ix >= 1.0 / DBL_EPSILON)
-    {
-      /* For large x in the first quadrant, x + csqrt (1 + x * x)
-	 is sufficiently close to 2 * x to make no significant
-	 difference to the result; avoid possible overflow from
-	 the squaring and addition.  */
-      __real__ y = rx;
-      __imag__ y = ix;
-
-      if (adj)
-	{
-	  double t = __real__ y;
-	  __real__ y = __copysign (__imag__ y, __imag__ x);
-	  __imag__ y = t;
-	}
-
-      res = __clog (y);
-      __real__ res += M_LN2;
-    }
-  else if (rx >= 0.5 && ix < DBL_EPSILON / 8.0)
-    {
-      double s = __ieee754_hypot (1.0, rx);
-
-      __real__ res = __ieee754_log (rx + s);
-      if (adj)
-	__imag__ res = __ieee754_atan2 (s, __imag__ x);
-      else
-	__imag__ res = __ieee754_atan2 (ix, s);
-    }
-  else if (rx < DBL_EPSILON / 8.0 && ix >= 1.5)
-    {
-      double s = __ieee754_sqrt ((ix + 1.0) * (ix - 1.0));
-
-      __real__ res = __ieee754_log (ix + s);
-      if (adj)
-	__imag__ res = __ieee754_atan2 (rx, __copysign (s, __imag__ x));
-      else
-	__imag__ res = __ieee754_atan2 (s, rx);
-    }
-  else if (ix > 1.0 && ix < 1.5 && rx < 0.5)
-    {
-      if (rx < DBL_EPSILON * DBL_EPSILON)
-	{
-	  double ix2m1 = (ix + 1.0) * (ix - 1.0);
-	  double s = __ieee754_sqrt (ix2m1);
-
-	  __real__ res = __log1p (2.0 * (ix2m1 + ix * s)) / 2.0;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2 (rx, __copysign (s, __imag__ x));
-	  else
-	    __imag__ res = __ieee754_atan2 (s, rx);
-	}
-      else
-	{
-	  double ix2m1 = (ix + 1.0) * (ix - 1.0);
-	  double rx2 = rx * rx;
-	  double f = rx2 * (2.0 + rx2 + 2.0 * ix * ix);
-	  double d = __ieee754_sqrt (ix2m1 * ix2m1 + f);
-	  double dp = d + ix2m1;
-	  double dm = f / dp;
-	  double r1 = __ieee754_sqrt ((dm + rx2) / 2.0);
-	  double r2 = rx * ix / r1;
-
-	  __real__ res = __log1p (rx2 + dp + 2.0 * (rx * r1 + ix * r2)) / 2.0;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2 (rx + r1, __copysign (ix + r2,
-								 __imag__ x));
-	  else
-	    __imag__ res = __ieee754_atan2 (ix + r2, rx + r1);
-	}
-    }
-  else if (ix == 1.0 && rx < 0.5)
-    {
-      if (rx < DBL_EPSILON / 8.0)
-	{
-	  __real__ res = __log1p (2.0 * (rx + __ieee754_sqrt (rx))) / 2.0;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2 (__ieee754_sqrt (rx),
-					    __copysign (1.0, __imag__ x));
-	  else
-	    __imag__ res = __ieee754_atan2 (1.0, __ieee754_sqrt (rx));
-	}
-      else
-	{
-	  double d = rx * __ieee754_sqrt (4.0 + rx * rx);
-	  double s1 = __ieee754_sqrt ((d + rx * rx) / 2.0);
-	  double s2 = __ieee754_sqrt ((d - rx * rx) / 2.0);
-
-	  __real__ res = __log1p (rx * rx + d + 2.0 * (rx * s1 + s2)) / 2.0;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2 (rx + s1, __copysign (1.0 + s2,
-								 __imag__ x));
-	  else
-	    __imag__ res = __ieee754_atan2 (1.0 + s2, rx + s1);
-	}
-    }
-  else if (ix < 1.0 && rx < 0.5)
-    {
-      if (ix >= DBL_EPSILON)
-	{
-	  if (rx < DBL_EPSILON * DBL_EPSILON)
-	    {
-	      double onemix2 = (1.0 + ix) * (1.0 - ix);
-	      double s = __ieee754_sqrt (onemix2);
-
-	      __real__ res = __log1p (2.0 * rx / s) / 2.0;
-	      if (adj)
-		__imag__ res = __ieee754_atan2 (s, __imag__ x);
-	      else
-		__imag__ res = __ieee754_atan2 (ix, s);
-	    }
-	  else
-	    {
-	      double onemix2 = (1.0 + ix) * (1.0 - ix);
-	      double rx2 = rx * rx;
-	      double f = rx2 * (2.0 + rx2 + 2.0 * ix * ix);
-	      double d = __ieee754_sqrt (onemix2 * onemix2 + f);
-	      double dp = d + onemix2;
-	      double dm = f / dp;
-	      double r1 = __ieee754_sqrt ((dp + rx2) / 2.0);
-	      double r2 = rx * ix / r1;
-
-	      __real__ res
-		= __log1p (rx2 + dm + 2.0 * (rx * r1 + ix * r2)) / 2.0;
-	      if (adj)
-		__imag__ res = __ieee754_atan2 (rx + r1,
-						__copysign (ix + r2,
-							    __imag__ x));
-	      else
-		__imag__ res = __ieee754_atan2 (ix + r2, rx + r1);
-	    }
-	}
-      else
-	{
-	  double s = __ieee754_hypot (1.0, rx);
-
-	  __real__ res = __log1p (2.0 * rx * (rx + s)) / 2.0;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2 (s, __imag__ x);
-	  else
-	    __imag__ res = __ieee754_atan2 (ix, s);
-	}
-      math_check_force_underflow_nonneg (__real__ res);
-    }
-  else
-    {
-      __real__ y = (rx - ix) * (rx + ix) + 1.0;
-      __imag__ y = 2.0 * rx * ix;
-
-      y = __csqrt (y);
-
-      __real__ y += rx;
-      __imag__ y += ix;
-
-      if (adj)
-	{
-	  double t = __real__ y;
-	  __real__ y = __copysign (__imag__ y, __imag__ x);
-	  __imag__ y = t;
-	}
-
-      res = __clog (y);
-    }
-
-  /* Give results the correct sign for the original argument.  */
-  __real__ res = __copysign (__real__ res, __real__ x);
-  __imag__ res = __copysign (__imag__ res, (adj ? 1.0 : __imag__ x));
-
-  return res;
-}
diff --git a/math/k_casinh_template.c b/math/k_casinh_template.c
index 354dde1..0b29e6a 100644
--- a/math/k_casinh_template.c
+++ b/math/k_casinh_template.c
@@ -1,6 +1,6 @@
-/* Return arc hyperbole sine for double value, with the imaginary part
-   of the result possibly adjusted for use in computing other
-   functions.
+/* Return arc hyperbolic sine for a complex float type, with the
+   imaginary part of the result possibly adjusted for use in
+   computing other functions.
    Copyright (C) 1997-2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -27,18 +27,18 @@
    with the imaginary part of the result subtracted from pi/2 if ADJ
    is nonzero.  */
 
-__complex__ double
-__kernel_casinh (__complex__ double x, int adj)
+CFLOAT
+M_DECL_FUNC (__kernel_casinh) (CFLOAT x, int adj)
 {
-  __complex__ double res;
-  double rx, ix;
-  __complex__ double y;
+  CFLOAT res;
+  FLOAT rx, ix;
+  CFLOAT y;
 
   /* Avoid cancellation by reducing to the first quadrant.  */
-  rx = fabs (__real__ x);
-  ix = fabs (__imag__ x);
+  rx = M_FABS (__real__ x);
+  ix = M_FABS (__imag__ x);
 
-  if (rx >= 1.0 / DBL_EPSILON || ix >= 1.0 / DBL_EPSILON)
+  if (rx >= 1 / M_EPSILON || ix >= 1 / M_EPSILON)
     {
       /* For large x in the first quadrant, x + csqrt (1 + x * x)
 	 is sufficiently close to 2 * x to make no significant
@@ -49,162 +49,158 @@ __kernel_casinh (__complex__ double x, int adj)
 
       if (adj)
 	{
-	  double t = __real__ y;
-	  __real__ y = __copysign (__imag__ y, __imag__ x);
+	  FLOAT t = __real__ y;
+	  __real__ y = M_COPYSIGN (__imag__ y, __imag__ x);
 	  __imag__ y = t;
 	}
 
-      res = __clog (y);
-      __real__ res += M_LN2;
+      res = M_SUF (__clog) (y);
+      __real__ res += (FLOAT) M_MLIT (M_LN2);
     }
-  else if (rx >= 0.5 && ix < DBL_EPSILON / 8.0)
+  else if (rx >= M_LIT (0.5) && ix < M_EPSILON / 8)
     {
-      double s = __ieee754_hypot (1.0, rx);
+      FLOAT s = M_HYPOT (1, rx);
 
-      __real__ res = __ieee754_log (rx + s);
+      __real__ res = M_LOG (rx + s);
       if (adj)
-	__imag__ res = __ieee754_atan2 (s, __imag__ x);
+	__imag__ res = M_ATAN2 (s, __imag__ x);
       else
-	__imag__ res = __ieee754_atan2 (ix, s);
+	__imag__ res = M_ATAN2 (ix, s);
     }
-  else if (rx < DBL_EPSILON / 8.0 && ix >= 1.5)
+  else if (rx < M_EPSILON / 8 && ix >= M_LIT (1.5))
     {
-      double s = __ieee754_sqrt ((ix + 1.0) * (ix - 1.0));
+      FLOAT s = M_SQRT ((ix + 1) * (ix - 1));
 
-      __real__ res = __ieee754_log (ix + s);
+      __real__ res = M_LOG (ix + s);
       if (adj)
-	__imag__ res = __ieee754_atan2 (rx, __copysign (s, __imag__ x));
+	__imag__ res = M_ATAN2 (rx, M_COPYSIGN (s, __imag__ x));
       else
-	__imag__ res = __ieee754_atan2 (s, rx);
+	__imag__ res = M_ATAN2 (s, rx);
     }
-  else if (ix > 1.0 && ix < 1.5 && rx < 0.5)
+  else if (ix > 1 && ix < M_LIT (1.5) && rx < M_LIT (0.5))
     {
-      if (rx < DBL_EPSILON * DBL_EPSILON)
+      if (rx < M_EPSILON * M_EPSILON)
 	{
-	  double ix2m1 = (ix + 1.0) * (ix - 1.0);
-	  double s = __ieee754_sqrt (ix2m1);
+	  FLOAT ix2m1 = (ix + 1) * (ix - 1);
+	  FLOAT s = M_SQRT (ix2m1);
 
-	  __real__ res = __log1p (2.0 * (ix2m1 + ix * s)) / 2.0;
+	  __real__ res = M_LOG1P (2 * (ix2m1 + ix * s)) / 2;
 	  if (adj)
-	    __imag__ res = __ieee754_atan2 (rx, __copysign (s, __imag__ x));
+	    __imag__ res = M_ATAN2 (rx, M_COPYSIGN (s, __imag__ x));
 	  else
-	    __imag__ res = __ieee754_atan2 (s, rx);
+	    __imag__ res = M_ATAN2 (s, rx);
 	}
       else
 	{
-	  double ix2m1 = (ix + 1.0) * (ix - 1.0);
-	  double rx2 = rx * rx;
-	  double f = rx2 * (2.0 + rx2 + 2.0 * ix * ix);
-	  double d = __ieee754_sqrt (ix2m1 * ix2m1 + f);
-	  double dp = d + ix2m1;
-	  double dm = f / dp;
-	  double r1 = __ieee754_sqrt ((dm + rx2) / 2.0);
-	  double r2 = rx * ix / r1;
-
-	  __real__ res = __log1p (rx2 + dp + 2.0 * (rx * r1 + ix * r2)) / 2.0;
+	  FLOAT ix2m1 = (ix + 1) * (ix - 1);
+	  FLOAT rx2 = rx * rx;
+	  FLOAT f = rx2 * (2 + rx2 + 2 * ix * ix);
+	  FLOAT d = M_SQRT (ix2m1 * ix2m1 + f);
+	  FLOAT dp = d + ix2m1;
+	  FLOAT dm = f / dp;
+	  FLOAT r1 = M_SQRT ((dm + rx2) / 2);
+	  FLOAT r2 = rx * ix / r1;
+
+	  __real__ res = M_LOG1P (rx2 + dp + 2 * (rx * r1 + ix * r2)) / 2;
 	  if (adj)
-	    __imag__ res = __ieee754_atan2 (rx + r1, __copysign (ix + r2,
-								 __imag__ x));
+	    __imag__ res = M_ATAN2 (rx + r1, M_COPYSIGN (ix + r2, __imag__ x));
 	  else
-	    __imag__ res = __ieee754_atan2 (ix + r2, rx + r1);
+	    __imag__ res = M_ATAN2 (ix + r2, rx + r1);
 	}
     }
-  else if (ix == 1.0 && rx < 0.5)
+  else if (ix == 1 && rx < M_LIT (0.5))
     {
-      if (rx < DBL_EPSILON / 8.0)
+      if (rx < M_EPSILON / 8)
 	{
-	  __real__ res = __log1p (2.0 * (rx + __ieee754_sqrt (rx))) / 2.0;
+	  __real__ res = M_LOG1P (2 * (rx + M_SQRT (rx))) / 2;
 	  if (adj)
-	    __imag__ res = __ieee754_atan2 (__ieee754_sqrt (rx),
-					    __copysign (1.0, __imag__ x));
+	    __imag__ res = M_ATAN2 (M_SQRT (rx), M_COPYSIGN (1, __imag__ x));
 	  else
-	    __imag__ res = __ieee754_atan2 (1.0, __ieee754_sqrt (rx));
+	    __imag__ res = M_ATAN2 (1, M_SQRT (rx));
 	}
       else
 	{
-	  double d = rx * __ieee754_sqrt (4.0 + rx * rx);
-	  double s1 = __ieee754_sqrt ((d + rx * rx) / 2.0);
-	  double s2 = __ieee754_sqrt ((d - rx * rx) / 2.0);
+	  FLOAT d = rx * M_SQRT (4 + rx * rx);
+	  FLOAT s1 = M_SQRT ((d + rx * rx) / 2);
+	  FLOAT s2 = M_SQRT ((d - rx * rx) / 2);
 
-	  __real__ res = __log1p (rx * rx + d + 2.0 * (rx * s1 + s2)) / 2.0;
+	  __real__ res = M_LOG1P (rx * rx + d + 2 * (rx * s1 + s2)) / 2;
 	  if (adj)
-	    __imag__ res = __ieee754_atan2 (rx + s1, __copysign (1.0 + s2,
-								 __imag__ x));
+	    __imag__ res = M_ATAN2 (rx + s1, M_COPYSIGN (1 + s2, __imag__ x));
 	  else
-	    __imag__ res = __ieee754_atan2 (1.0 + s2, rx + s1);
+	    __imag__ res = M_ATAN2 (1 + s2, rx + s1);
 	}
     }
-  else if (ix < 1.0 && rx < 0.5)
+  else if (ix < 1 && rx < M_LIT (0.5))
     {
-      if (ix >= DBL_EPSILON)
+      if (ix >= M_EPSILON)
 	{
-	  if (rx < DBL_EPSILON * DBL_EPSILON)
+	  if (rx < M_EPSILON * M_EPSILON)
 	    {
-	      double onemix2 = (1.0 + ix) * (1.0 - ix);
-	      double s = __ieee754_sqrt (onemix2);
+	      FLOAT onemix2 = (1 + ix) * (1 - ix);
+	      FLOAT s = M_SQRT (onemix2);
 
-	      __real__ res = __log1p (2.0 * rx / s) / 2.0;
+	      __real__ res = M_LOG1P (2 * rx / s) / 2;
 	      if (adj)
-		__imag__ res = __ieee754_atan2 (s, __imag__ x);
+		__imag__ res = M_ATAN2 (s, __imag__ x);
 	      else
-		__imag__ res = __ieee754_atan2 (ix, s);
+		__imag__ res = M_ATAN2 (ix, s);
 	    }
 	  else
 	    {
-	      double onemix2 = (1.0 + ix) * (1.0 - ix);
-	      double rx2 = rx * rx;
-	      double f = rx2 * (2.0 + rx2 + 2.0 * ix * ix);
-	      double d = __ieee754_sqrt (onemix2 * onemix2 + f);
-	      double dp = d + onemix2;
-	      double dm = f / dp;
-	      double r1 = __ieee754_sqrt ((dp + rx2) / 2.0);
-	      double r2 = rx * ix / r1;
-
-	      __real__ res
-		= __log1p (rx2 + dm + 2.0 * (rx * r1 + ix * r2)) / 2.0;
+	      FLOAT onemix2 = (1 + ix) * (1 - ix);
+	      FLOAT rx2 = rx * rx;
+	      FLOAT f = rx2 * (2 + rx2 + 2 * ix * ix);
+	      FLOAT d = M_SQRT (onemix2 * onemix2 + f);
+	      FLOAT dp = d + onemix2;
+	      FLOAT dm = f / dp;
+	      FLOAT r1 = M_SQRT ((dp + rx2) / 2);
+	      FLOAT r2 = rx * ix / r1;
+
+	      __real__ res = M_LOG1P (rx2 + dm + 2
+				      * (rx * r1 + ix * r2)) / 2;
 	      if (adj)
-		__imag__ res = __ieee754_atan2 (rx + r1,
-						__copysign (ix + r2,
-							    __imag__ x));
+		__imag__ res = M_ATAN2 (rx + r1, M_COPYSIGN (ix + r2,
+							     __imag__ x));
 	      else
-		__imag__ res = __ieee754_atan2 (ix + r2, rx + r1);
+		__imag__ res = M_ATAN2 (ix + r2, rx + r1);
 	    }
 	}
       else
 	{
-	  double s = __ieee754_hypot (1.0, rx);
+	  FLOAT s = M_HYPOT (1, rx);
 
-	  __real__ res = __log1p (2.0 * rx * (rx + s)) / 2.0;
+	  __real__ res = M_LOG1P (2 * rx * (rx + s)) / 2;
 	  if (adj)
-	    __imag__ res = __ieee754_atan2 (s, __imag__ x);
+	    __imag__ res = M_ATAN2 (s, __imag__ x);
 	  else
-	    __imag__ res = __ieee754_atan2 (ix, s);
+	    __imag__ res = M_ATAN2 (ix, s);
 	}
       math_check_force_underflow_nonneg (__real__ res);
     }
   else
     {
-      __real__ y = (rx - ix) * (rx + ix) + 1.0;
-      __imag__ y = 2.0 * rx * ix;
+      __real__ y = (rx - ix) * (rx + ix) + 1;
+      __imag__ y = 2 * rx * ix;
 
-      y = __csqrt (y);
+      y = M_SUF (__csqrt) (y);
 
       __real__ y += rx;
       __imag__ y += ix;
 
       if (adj)
 	{
-	  double t = __real__ y;
-	  __real__ y = __copysign (__imag__ y, __imag__ x);
+	  FLOAT t = __real__ y;
+	  __real__ y = M_COPYSIGN (__imag__ y, __imag__ x);
 	  __imag__ y = t;
 	}
 
-      res = __clog (y);
+      res = M_SUF (__clog) (y);
     }
 
   /* Give results the correct sign for the original argument.  */
-  __real__ res = __copysign (__real__ res, __real__ x);
-  __imag__ res = __copysign (__imag__ res, (adj ? 1.0 : __imag__ x));
+  __real__ res = M_COPYSIGN (__real__ res, __real__ x);
+  __imag__ res = M_COPYSIGN (__imag__ res, (adj ? 1 : __imag__ x));
 
   return res;
 }
diff --git a/math/k_casinhf.c b/math/k_casinhf.c
deleted file mode 100644
index 7697f31..0000000
--- a/math/k_casinhf.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/* Return arc hyperbole sine for float value, with the imaginary part
-   of the result possibly adjusted for use in computing other
-   functions.
-   Copyright (C) 1997-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 <complex.h>
-#include <math.h>
-#include <math_private.h>
-#include <float.h>
-
-/* Return the complex inverse hyperbolic sine of finite nonzero Z,
-   with the imaginary part of the result subtracted from pi/2 if ADJ
-   is nonzero.  */
-
-__complex__ float
-__kernel_casinhf (__complex__ float x, int adj)
-{
-  __complex__ float res;
-  float rx, ix;
-  __complex__ float y;
-
-  /* Avoid cancellation by reducing to the first quadrant.  */
-  rx = fabsf (__real__ x);
-  ix = fabsf (__imag__ x);
-
-  if (rx >= 1.0f / FLT_EPSILON || ix >= 1.0f / FLT_EPSILON)
-    {
-      /* For large x in the first quadrant, x + csqrt (1 + x * x)
-	 is sufficiently close to 2 * x to make no significant
-	 difference to the result; avoid possible overflow from
-	 the squaring and addition.  */
-      __real__ y = rx;
-      __imag__ y = ix;
-
-      if (adj)
-	{
-	  float t = __real__ y;
-	  __real__ y = __copysignf (__imag__ y, __imag__ x);
-	  __imag__ y = t;
-	}
-
-      res = __clogf (y);
-      __real__ res += (float) M_LN2;
-    }
-  else if (rx >= 0.5f && ix < FLT_EPSILON / 8.0f)
-    {
-      float s = __ieee754_hypotf (1.0f, rx);
-
-      __real__ res = __ieee754_logf (rx + s);
-      if (adj)
-	__imag__ res = __ieee754_atan2f (s, __imag__ x);
-      else
-	__imag__ res = __ieee754_atan2f (ix, s);
-    }
-  else if (rx < FLT_EPSILON / 8.0f && ix >= 1.5f)
-    {
-      float s = __ieee754_sqrtf ((ix + 1.0f) * (ix - 1.0f));
-
-      __real__ res = __ieee754_logf (ix + s);
-      if (adj)
-	__imag__ res = __ieee754_atan2f (rx, __copysignf (s, __imag__ x));
-      else
-	__imag__ res = __ieee754_atan2f (s, rx);
-    }
-  else if (ix > 1.0f && ix < 1.5f && rx < 0.5f)
-    {
-      if (rx < FLT_EPSILON * FLT_EPSILON)
-	{
-	  float ix2m1 = (ix + 1.0f) * (ix - 1.0f);
-	  float s = __ieee754_sqrtf (ix2m1);
-
-	  __real__ res = __log1pf (2.0f * (ix2m1 + ix * s)) / 2.0f;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2f (rx, __copysignf (s, __imag__ x));
-	  else
-	    __imag__ res = __ieee754_atan2f (s, rx);
-	}
-      else
-	{
-	  float ix2m1 = (ix + 1.0f) * (ix - 1.0f);
-	  float rx2 = rx * rx;
-	  float f = rx2 * (2.0f + rx2 + 2.0f * ix * ix);
-	  float d = __ieee754_sqrtf (ix2m1 * ix2m1 + f);
-	  float dp = d + ix2m1;
-	  float dm = f / dp;
-	  float r1 = __ieee754_sqrtf ((dm + rx2) / 2.0f);
-	  float r2 = rx * ix / r1;
-
-	  __real__ res
-	    = __log1pf (rx2 + dp + 2.0f * (rx * r1 + ix * r2)) / 2.0f;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2f (rx + r1, __copysignf (ix + r2,
-								   __imag__ x));
-	  else
-	    __imag__ res = __ieee754_atan2f (ix + r2, rx + r1);
-	}
-    }
-  else if (ix == 1.0f && rx < 0.5f)
-    {
-      if (rx < FLT_EPSILON / 8.0f)
-	{
-	  __real__ res = __log1pf (2.0f * (rx + __ieee754_sqrtf (rx))) / 2.0f;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2f (__ieee754_sqrtf (rx),
-					     __copysignf (1.0f, __imag__ x));
-	  else
-	    __imag__ res = __ieee754_atan2f (1.0f, __ieee754_sqrtf (rx));
-	}
-      else
-	{
-	  float d = rx * __ieee754_sqrtf (4.0f + rx * rx);
-	  float s1 = __ieee754_sqrtf ((d + rx * rx) / 2.0f);
-	  float s2 = __ieee754_sqrtf ((d - rx * rx) / 2.0f);
-
-	  __real__ res = __log1pf (rx * rx + d + 2.0f * (rx * s1 + s2)) / 2.0f;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2f (rx + s1,
-					     __copysignf (1.0f + s2,
-							  __imag__ x));
-	  else
-	    __imag__ res = __ieee754_atan2f (1.0f + s2, rx + s1);
-	}
-    }
-  else if (ix < 1.0f && rx < 0.5f)
-    {
-      if (ix >= FLT_EPSILON)
-	{
-	  if (rx < FLT_EPSILON * FLT_EPSILON)
-	    {
-	      float onemix2 = (1.0f + ix) * (1.0f - ix);
-	      float s = __ieee754_sqrtf (onemix2);
-
-	      __real__ res = __log1pf (2.0f * rx / s) / 2.0f;
-	      if (adj)
-		__imag__ res = __ieee754_atan2f (s, __imag__ x);
-	      else
-		__imag__ res = __ieee754_atan2f (ix, s);
-	    }
-	  else
-	    {
-	      float onemix2 = (1.0f + ix) * (1.0f - ix);
-	      float rx2 = rx * rx;
-	      float f = rx2 * (2.0f + rx2 + 2.0f * ix * ix);
-	      float d = __ieee754_sqrtf (onemix2 * onemix2 + f);
-	      float dp = d + onemix2;
-	      float dm = f / dp;
-	      float r1 = __ieee754_sqrtf ((dp + rx2) / 2.0f);
-	      float r2 = rx * ix / r1;
-
-	      __real__ res
-		= __log1pf (rx2 + dm + 2.0f * (rx * r1 + ix * r2)) / 2.0f;
-	      if (adj)
-		__imag__ res = __ieee754_atan2f (rx + r1,
-						 __copysignf (ix + r2,
-							      __imag__ x));
-	      else
-		__imag__ res = __ieee754_atan2f (ix + r2, rx + r1);
-	    }
-	}
-      else
-	{
-	  float s = __ieee754_hypotf (1.0f, rx);
-
-	  __real__ res = __log1pf (2.0f * rx * (rx + s)) / 2.0f;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2f (s, __imag__ x);
-	  else
-	    __imag__ res = __ieee754_atan2f (ix, s);
-	}
-      math_check_force_underflow_nonneg (__real__ res);
-    }
-  else
-    {
-      __real__ y = (rx - ix) * (rx + ix) + 1.0f;
-      __imag__ y = 2.0f * rx * ix;
-
-      y = __csqrtf (y);
-
-      __real__ y += rx;
-      __imag__ y += ix;
-
-      if (adj)
-	{
-	  float t = __real__ y;
-	  __real__ y = __copysignf (__imag__ y, __imag__ x);
-	  __imag__ y = t;
-	}
-
-      res = __clogf (y);
-    }
-
-  /* Give results the correct sign for the original argument.  */
-  __real__ res = __copysignf (__real__ res, __real__ x);
-  __imag__ res = __copysignf (__imag__ res, (adj ? 1.0f : __imag__ x));
-
-  return res;
-}
diff --git a/math/k_casinhl.c b/math/k_casinhl.c
deleted file mode 100644
index 7c4b9c3..0000000
--- a/math/k_casinhl.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/* Return arc hyperbole sine for long double value, with the imaginary
-   part of the result possibly adjusted for use in computing other
-   functions.
-   Copyright (C) 1997-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 <complex.h>
-#include <math.h>
-#include <math_private.h>
-#include <float.h>
-
-/* To avoid spurious overflows, use this definition to treat IBM long
-   double as approximating an IEEE-style format.  */
-#if LDBL_MANT_DIG == 106
-# undef LDBL_EPSILON
-# define LDBL_EPSILON 0x1p-106L
-#endif
-
-/* Return the complex inverse hyperbolic sine of finite nonzero Z,
-   with the imaginary part of the result subtracted from pi/2 if ADJ
-   is nonzero.  */
-
-__complex__ long double
-__kernel_casinhl (__complex__ long double x, int adj)
-{
-  __complex__ long double res;
-  long double rx, ix;
-  __complex__ long double y;
-
-  /* Avoid cancellation by reducing to the first quadrant.  */
-  rx = fabsl (__real__ x);
-  ix = fabsl (__imag__ x);
-
-  if (rx >= 1.0L / LDBL_EPSILON || ix >= 1.0L / LDBL_EPSILON)
-    {
-      /* For large x in the first quadrant, x + csqrt (1 + x * x)
-	 is sufficiently close to 2 * x to make no significant
-	 difference to the result; avoid possible overflow from
-	 the squaring and addition.  */
-      __real__ y = rx;
-      __imag__ y = ix;
-
-      if (adj)
-	{
-	  long double t = __real__ y;
-	  __real__ y = __copysignl (__imag__ y, __imag__ x);
-	  __imag__ y = t;
-	}
-
-      res = __clogl (y);
-      __real__ res += M_LN2l;
-    }
-  else if (rx >= 0.5L && ix < LDBL_EPSILON / 8.0L)
-    {
-      long double s = __ieee754_hypotl (1.0L, rx);
-
-      __real__ res = __ieee754_logl (rx + s);
-      if (adj)
-	__imag__ res = __ieee754_atan2l (s, __imag__ x);
-      else
-	__imag__ res = __ieee754_atan2l (ix, s);
-    }
-  else if (rx < LDBL_EPSILON / 8.0L && ix >= 1.5L)
-    {
-      long double s = __ieee754_sqrtl ((ix + 1.0L) * (ix - 1.0L));
-
-      __real__ res = __ieee754_logl (ix + s);
-      if (adj)
-	__imag__ res = __ieee754_atan2l (rx, __copysignl (s, __imag__ x));
-      else
-	__imag__ res = __ieee754_atan2l (s, rx);
-    }
-  else if (ix > 1.0L && ix < 1.5L && rx < 0.5L)
-    {
-      if (rx < LDBL_EPSILON * LDBL_EPSILON)
-	{
-	  long double ix2m1 = (ix + 1.0L) * (ix - 1.0L);
-	  long double s = __ieee754_sqrtl (ix2m1);
-
-	  __real__ res = __log1pl (2.0L * (ix2m1 + ix * s)) / 2.0L;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2l (rx, __copysignl (s, __imag__ x));
-	  else
-	    __imag__ res = __ieee754_atan2l (s, rx);
-	}
-      else
-	{
-	  long double ix2m1 = (ix + 1.0L) * (ix - 1.0L);
-	  long double rx2 = rx * rx;
-	  long double f = rx2 * (2.0L + rx2 + 2.0L * ix * ix);
-	  long double d = __ieee754_sqrtl (ix2m1 * ix2m1 + f);
-	  long double dp = d + ix2m1;
-	  long double dm = f / dp;
-	  long double r1 = __ieee754_sqrtl ((dm + rx2) / 2.0L);
-	  long double r2 = rx * ix / r1;
-
-	  __real__ res
-	    = __log1pl (rx2 + dp + 2.0L * (rx * r1 + ix * r2)) / 2.0L;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2l (rx + r1, __copysignl (ix + r2,
-								   __imag__ x));
-	  else
-	    __imag__ res = __ieee754_atan2l (ix + r2, rx + r1);
-	}
-    }
-  else if (ix == 1.0L && rx < 0.5L)
-    {
-      if (rx < LDBL_EPSILON / 8.0L)
-	{
-	  __real__ res = __log1pl (2.0L * (rx + __ieee754_sqrtl (rx))) / 2.0L;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2l (__ieee754_sqrtl (rx),
-					     __copysignl (1.0L, __imag__ x));
-	  else
-	    __imag__ res = __ieee754_atan2l (1.0L, __ieee754_sqrtl (rx));
-	}
-      else
-	{
-	  long double d = rx * __ieee754_sqrtl (4.0L + rx * rx);
-	  long double s1 = __ieee754_sqrtl ((d + rx * rx) / 2.0L);
-	  long double s2 = __ieee754_sqrtl ((d - rx * rx) / 2.0L);
-
-	  __real__ res = __log1pl (rx * rx + d + 2.0L * (rx * s1 + s2)) / 2.0L;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2l (rx + s1,
-					     __copysignl (1.0L + s2,
-							  __imag__ x));
-	  else
-	    __imag__ res = __ieee754_atan2l (1.0L + s2, rx + s1);
-	}
-    }
-  else if (ix < 1.0L && rx < 0.5L)
-    {
-      if (ix >= LDBL_EPSILON)
-	{
-	  if (rx < LDBL_EPSILON * LDBL_EPSILON)
-	    {
-	      long double onemix2 = (1.0L + ix) * (1.0L - ix);
-	      long double s = __ieee754_sqrtl (onemix2);
-
-	      __real__ res = __log1pl (2.0L * rx / s) / 2.0L;
-	      if (adj)
-		__imag__ res = __ieee754_atan2l (s, __imag__ x);
-	      else
-		__imag__ res = __ieee754_atan2l (ix, s);
-	    }
-	  else
-	    {
-	      long double onemix2 = (1.0L + ix) * (1.0L - ix);
-	      long double rx2 = rx * rx;
-	      long double f = rx2 * (2.0L + rx2 + 2.0L * ix * ix);
-	      long double d = __ieee754_sqrtl (onemix2 * onemix2 + f);
-	      long double dp = d + onemix2;
-	      long double dm = f / dp;
-	      long double r1 = __ieee754_sqrtl ((dp + rx2) / 2.0L);
-	      long double r2 = rx * ix / r1;
-
-	      __real__ res
-		= __log1pl (rx2 + dm + 2.0L * (rx * r1 + ix * r2)) / 2.0L;
-	      if (adj)
-		__imag__ res = __ieee754_atan2l (rx + r1,
-						 __copysignl (ix + r2,
-							      __imag__ x));
-	      else
-		__imag__ res = __ieee754_atan2l (ix + r2, rx + r1);
-	    }
-	}
-      else
-	{
-	  long double s = __ieee754_hypotl (1.0L, rx);
-
-	  __real__ res = __log1pl (2.0L * rx * (rx + s)) / 2.0L;
-	  if (adj)
-	    __imag__ res = __ieee754_atan2l (s, __imag__ x);
-	  else
-	    __imag__ res = __ieee754_atan2l (ix, s);
-	}
-      math_check_force_underflow_nonneg (__real__ res);
-    }
-  else
-    {
-      __real__ y = (rx - ix) * (rx + ix) + 1.0L;
-      __imag__ y = 2.0L * rx * ix;
-
-      y = __csqrtl (y);
-
-      __real__ y += rx;
-      __imag__ y += ix;
-
-      if (adj)
-	{
-	  long double t = __real__ y;
-	  __real__ y = __copysignl (__imag__ y, __imag__ x);
-	  __imag__ y = t;
-	}
-
-      res = __clogl (y);
-    }
-
-  /* Give results the correct sign for the original argument.  */
-  __real__ res = __copysignl (__real__ res, __real__ x);
-  __imag__ res = __copysignl (__imag__ res, (adj ? 1.0L : __imag__ x));
-
-  return res;
-}
diff --git a/math/s_casin.c b/math/s_casin.c
deleted file mode 100644
index a37933b..0000000
--- a/math/s_casin.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Return arc sine 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>
-#include <math_private.h>
-
-
-__complex__ double
-__casin (__complex__ double x)
-{
-  __complex__ double res;
-
-  if (isnan (__real__ x) || isnan (__imag__ x))
-    {
-      if (__real__ x == 0.0)
-	{
-	  res = x;
-	}
-      else if (isinf (__real__ x) || isinf (__imag__ x))
-	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __copysign (HUGE_VAL, __imag__ x);
-	}
-      else
-	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
-	}
-    }
-  else
-    {
-      __complex__ double y;
-
-      __real__ y = -__imag__ x;
-      __imag__ y = __real__ x;
-
-      y = __casinh (y);
-
-      __real__ res = __imag__ y;
-      __imag__ res = -__real__ y;
-    }
-
-  return res;
-}
-weak_alias (__casin, casin)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__casin, __casinl)
-weak_alias (__casin, casinl)
-#endif
diff --git a/math/s_casin_template.c b/math/s_casin_template.c
index a37933b..5b1e979 100644
--- a/math/s_casin_template.c
+++ b/math/s_casin_template.c
@@ -1,4 +1,4 @@
-/* Return arc sine of complex double value.
+/* Return arc sine of a 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,36 +22,36 @@
 #include <math_private.h>
 
 
-__complex__ double
-__casin (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__casin) (CFLOAT x)
 {
-  __complex__ double res;
+  CFLOAT res;
 
   if (isnan (__real__ x) || isnan (__imag__ x))
     {
-      if (__real__ x == 0.0)
+      if (__real__ x == 0)
 	{
 	  res = x;
 	}
       else if (isinf (__real__ x) || isinf (__imag__ x))
 	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __copysign (HUGE_VAL, __imag__ x);
+	  __real__ res = M_NAN;
+	  __imag__ res = M_COPYSIGN (M_HUGE_VAL, __imag__ x);
 	}
       else
 	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
+	  __real__ res = M_NAN;
+	  __imag__ res = M_NAN;
 	}
     }
   else
     {
-      __complex__ double y;
+      CFLOAT y;
 
       __real__ y = -__imag__ x;
       __imag__ y = __real__ x;
 
-      y = __casinh (y);
+      y = M_SUF (__casinh) (y);
 
       __real__ res = __imag__ y;
       __imag__ res = -__real__ y;
@@ -59,8 +59,9 @@ __casin (__complex__ double x)
 
   return res;
 }
-weak_alias (__casin, casin)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__casin, __casinl)
-weak_alias (__casin, casinl)
+
+declare_mgen_alias (__casin, casin)
+
+#if M_LIBM_NEED_COMPAT (casin)
+declare_mgen_libm_compat (__casin, casin)
 #endif
diff --git a/math/s_casinf.c b/math/s_casinf.c
deleted file mode 100644
index ccb5766..0000000
--- a/math/s_casinf.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Return arc sine 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>
-#include <math_private.h>
-
-
-__complex__ float
-__casinf (__complex__ float x)
-{
-  __complex__ float res;
-
-  if (isnan (__real__ x) || isnan (__imag__ x))
-    {
-      if (__real__ x == 0.0)
-	{
-	  res = x;
-	}
-      else if (isinf (__real__ x) || isinf (__imag__ x))
-	{
-	  __real__ res = __nanf ("");
-	  __imag__ res = __copysignf (HUGE_VALF, __imag__ x);
-	}
-      else
-	{
-	  __real__ res = __nanf ("");
-	  __imag__ res = __nanf ("");
-	}
-    }
-  else
-    {
-      __complex__ float y;
-
-      __real__ y = -__imag__ x;
-      __imag__ y = __real__ x;
-
-      y = __casinhf (y);
-
-      __real__ res = __imag__ y;
-      __imag__ res = -__real__ y;
-    }
-
-  return res;
-}
-#ifndef __casinf
-weak_alias (__casinf, casinf)
-#endif
diff --git a/math/s_casinh.c b/math/s_casinh.c
deleted file mode 100644
index 32cbc13..0000000
--- a/math/s_casinh.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Return arc hyperbole sine 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
-__casinh (__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 = __copysign (HUGE_VAL, __real__ x);
-
-	  if (rcls == FP_NAN)
-	    __imag__ res = __nan ("");
-	  else
-	    __imag__ res = __copysign (rcls >= FP_ZERO ? M_PI_2 : M_PI_4,
-				       __imag__ x);
-	}
-      else if (rcls <= FP_INFINITE)
-	{
-	  __real__ res = __real__ x;
-	  if ((rcls == FP_INFINITE && icls >= FP_ZERO)
-	      || (rcls == FP_NAN && icls == FP_ZERO))
-	    __imag__ res = __copysign (0.0, __imag__ x);
-	  else
-	    __imag__ res = __nan ("");
-	}
-      else
-	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
-	}
-    }
-  else if (rcls == FP_ZERO && icls == FP_ZERO)
-    {
-      res = x;
-    }
-  else
-    {
-      res = __kernel_casinh (x, 0);
-    }
-
-  return res;
-}
-weak_alias (__casinh, casinh)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__casinh, __casinhl)
-weak_alias (__casinh, casinhl)
-#endif
diff --git a/math/s_casinh_template.c b/math/s_casinh_template.c
index 32cbc13..fd29e63 100644
--- a/math/s_casinh_template.c
+++ b/math/s_casinh_template.c
@@ -1,4 +1,4 @@
-/* Return arc hyperbole sine for double value.
+/* Return arc hyperbolic sine for a 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.
@@ -21,10 +21,10 @@
 #include <math.h>
 #include <math_private.h>
 
-__complex__ double
-__casinh (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__casinh) (CFLOAT x)
 {
-  __complex__ double res;
+  CFLOAT res;
   int rcls = fpclassify (__real__ x);
   int icls = fpclassify (__imag__ x);
 
@@ -32,12 +32,13 @@ __casinh (__complex__ double x)
     {
       if (icls == FP_INFINITE)
 	{
-	  __real__ res = __copysign (HUGE_VAL, __real__ x);
+	  __real__ res = M_COPYSIGN (M_HUGE_VAL, __real__ x);
 
 	  if (rcls == FP_NAN)
-	    __imag__ res = __nan ("");
+	    __imag__ res = M_NAN;
 	  else
-	    __imag__ res = __copysign (rcls >= FP_ZERO ? M_PI_2 : M_PI_4,
+	    __imag__ res = M_COPYSIGN ((rcls >= FP_ZERO
+				        ? M_MLIT (M_PI_2) : M_MLIT (M_PI_4)),
 				       __imag__ x);
 	}
       else if (rcls <= FP_INFINITE)
@@ -45,14 +46,14 @@ __casinh (__complex__ double x)
 	  __real__ res = __real__ x;
 	  if ((rcls == FP_INFINITE && icls >= FP_ZERO)
 	      || (rcls == FP_NAN && icls == FP_ZERO))
-	    __imag__ res = __copysign (0.0, __imag__ x);
+	    __imag__ res = M_COPYSIGN (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)
@@ -61,13 +62,14 @@ __casinh (__complex__ double x)
     }
   else
     {
-      res = __kernel_casinh (x, 0);
+      res = M_SUF (__kernel_casinh) (x, 0);
     }
 
   return res;
 }
-weak_alias (__casinh, casinh)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__casinh, __casinhl)
-weak_alias (__casinh, casinhl)
+
+declare_mgen_alias (__casinh, casinh)
+
+#if M_LIBM_NEED_COMPAT (casinh)
+declare_mgen_libm_compat (__casinh, casinh)
 #endif
diff --git a/math/s_casinhf.c b/math/s_casinhf.c
deleted file mode 100644
index 8d08b4b..0000000
--- a/math/s_casinhf.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Return arc hyperbole sine 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
-__casinhf (__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 = __copysignf (HUGE_VALF, __real__ x);
-
-	  if (rcls == FP_NAN)
-	    __imag__ res = __nanf ("");
-	  else
-	    __imag__ res = __copysignf (rcls >= FP_ZERO ? M_PI_2 : M_PI_4,
-					__imag__ x);
-	}
-      else if (rcls <= FP_INFINITE)
-	{
-	  __real__ res = __real__ x;
-	  if ((rcls == FP_INFINITE && icls >= FP_ZERO)
-	      || (rcls == FP_NAN && icls == FP_ZERO))
-	    __imag__ res = __copysignf (0.0, __imag__ x);
-	  else
-	    __imag__ res = __nanf ("");
-	}
-      else
-	{
-	  __real__ res = __nanf ("");
-	  __imag__ res = __nanf ("");
-	}
-    }
-  else if (rcls == FP_ZERO && icls == FP_ZERO)
-    {
-      res = x;
-    }
-  else
-    {
-      res = __kernel_casinhf (x, 0);
-    }
-
-  return res;
-}
-#ifndef __casinhf
-weak_alias (__casinhf, casinhf)
-#endif
diff --git a/math/s_casinhl.c b/math/s_casinhl.c
deleted file mode 100644
index 81d888e..0000000
--- a/math/s_casinhl.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Return arc hyperbole sine 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
-__casinhl (__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 = __copysignl (HUGE_VALL, __real__ x);
-
-	  if (rcls == FP_NAN)
-	    __imag__ res = __nanl ("");
-	  else
-	    __imag__ res = __copysignl (rcls >= FP_ZERO ? M_PI_2l : M_PI_4l,
-					__imag__ x);
-	}
-      else if (rcls <= FP_INFINITE)
-	{
-	  __real__ res = __real__ x;
-	  if ((rcls == FP_INFINITE && icls >= FP_ZERO)
-	      || (rcls == FP_NAN && icls == FP_ZERO))
-	    __imag__ res = __copysignl (0.0, __imag__ x);
-	  else
-	    __imag__ res = __nanl ("");
-	}
-      else
-	{
-	  __real__ res = __nanl ("");
-	  __imag__ res = __nanl ("");
-	}
-    }
-  else if (rcls == FP_ZERO && icls == FP_ZERO)
-    {
-      res = x;
-    }
-  else
-    {
-      res = __kernel_casinhl (x, 0);
-    }
-
-  return res;
-}
-weak_alias (__casinhl, casinhl)
diff --git a/math/s_casinl.c b/math/s_casinl.c
deleted file mode 100644
index 95f25bb..0000000
--- a/math/s_casinl.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Return arc sine 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>
-#include <math_private.h>
-
-
-__complex__ long double
-__casinl (__complex__ long double x)
-{
-  __complex__ long double res;
-
-  if (isnan (__real__ x) || isnan (__imag__ x))
-    {
-      if (__real__ x == 0.0)
-	{
-	  res = x;
-	}
-      else if (isinf (__real__ x) || isinf (__imag__ x))
-	{
-	  __real__ res = __nanl ("");
-	  __imag__ res = __copysignl (HUGE_VALL, __imag__ x);
-	}
-      else
-	{
-	  __real__ res = __nanl ("");
-	  __imag__ res = __nanl ("");
-	}
-    }
-  else
-    {
-      __complex__ long double y;
-
-      __real__ y = -__imag__ x;
-      __imag__ y = __real__ x;
-
-      y = __casinhl (y);
-
-      __real__ res = __imag__ y;
-      __imag__ res = -__real__ y;
-    }
-
-  return res;
-}
-weak_alias (__casinl, casinl)
diff --git a/math/s_csin.c b/math/s_csin.c
deleted file mode 100644
index e071aa6..0000000
--- a/math/s_csin.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/* Complex sine 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
-__csin (__complex__ double x)
-{
-  __complex__ double retval;
-  int negate = signbit (__real__ x);
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  __real__ x = fabs (__real__ x);
-
-  if (__glibc_likely (icls >= FP_ZERO))
-    {
-      /* Imaginary part is finite.  */
-      if (__glibc_likely (rcls >= FP_ZERO))
-	{
-	  /* Real part is finite.  */
-	  const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2);
-	  double sinix, cosix;
-
-	  if (__glibc_likely (__real__ x > DBL_MIN))
-	    {
-	      __sincos (__real__ x, &sinix, &cosix);
-	    }
-	  else
-	    {
-	      sinix = __real__ x;
-	      cosix = 1.0;
-	    }
-
-	  if (negate)
-	    sinix = -sinix;
-
-	  if (fabs (__imag__ x) > t)
-	    {
-	      double exp_t = __ieee754_exp (t);
-	      double ix = fabs (__imag__ x);
-	      if (signbit (__imag__ x))
-		cosix = -cosix;
-	      ix -= t;
-	      sinix *= exp_t / 2.0;
-	      cosix *= exp_t / 2.0;
-	      if (ix > t)
-		{
-		  ix -= t;
-		  sinix *= exp_t;
-		  cosix *= exp_t;
-		}
-	      if (ix > t)
-		{
-		  /* Overflow (original imaginary part of x > 3t).  */
-		  __real__ retval = DBL_MAX * sinix;
-		  __imag__ retval = DBL_MAX * cosix;
-		}
-	      else
-		{
-		  double exp_val = __ieee754_exp (ix);
-		  __real__ retval = exp_val * sinix;
-		  __imag__ retval = exp_val * cosix;
-		}
-	    }
-	  else
-	    {
-	      __real__ retval = __ieee754_cosh (__imag__ x) * sinix;
-	      __imag__ retval = __ieee754_sinh (__imag__ x) * cosix;
-	    }
-
-	  math_check_force_underflow_complex (retval);
-	}
-      else
-	{
-	  if (icls == FP_ZERO)
-	    {
-	      /* Imaginary part is 0.0.  */
-	      __real__ retval = __nan ("");
-	      __imag__ retval = __imag__ x;
-
-	      if (rcls == FP_INFINITE)
-		feraiseexcept (FE_INVALID);
-	    }
-	  else
-	    {
-	      __real__ retval = __nan ("");
-	      __imag__ retval = __nan ("");
-
-	      feraiseexcept (FE_INVALID);
-	    }
-	}
-    }
-  else if (icls == FP_INFINITE)
-    {
-      /* Imaginary part is infinite.  */
-      if (rcls == FP_ZERO)
-	{
-	  /* Real part is 0.0.  */
-	  __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
-	  __imag__ retval = __imag__ x;
-	}
-      else if (rcls > FP_ZERO)
-	{
-	  /* Real part is finite.  */
-	  double sinix, cosix;
-
-	  if (__glibc_likely (__real__ x > DBL_MIN))
-	    {
-	      __sincos (__real__ x, &sinix, &cosix);
-	    }
-	  else
-	    {
-	      sinix = __real__ x;
-	      cosix = 1.0;
-	    }
-
-	  __real__ retval = __copysign (HUGE_VAL, sinix);
-	  __imag__ retval = __copysign (HUGE_VAL, cosix);
-
-	  if (negate)
-	    __real__ retval = -__real__ retval;
-	  if (signbit (__imag__ x))
-	    __imag__ retval = -__imag__ retval;
-	}
-      else
-	{
-	  /* The addition raises the invalid exception.  */
-	  __real__ retval = __nan ("");
-	  __imag__ retval = HUGE_VAL;
-
-	  if (rcls == FP_INFINITE)
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else
-    {
-      if (rcls == FP_ZERO)
-	__real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
-      else
-	__real__ retval = __nan ("");
-      __imag__ retval = __nan ("");
-    }
-
-  return retval;
-}
-weak_alias (__csin, csin)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__csin, __csinl)
-weak_alias (__csin, csinl)
-#endif
diff --git a/math/s_csin_template.c b/math/s_csin_template.c
index e071aa6..59d8876 100644
--- a/math/s_csin_template.c
+++ b/math/s_csin_template.c
@@ -1,4 +1,4 @@
-/* Complex sine function for double.
+/* Complex sine 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,15 +23,15 @@
 #include <math_private.h>
 #include <float.h>
 
-__complex__ double
-__csin (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__csin) (CFLOAT x)
 {
-  __complex__ double retval;
+  CFLOAT retval;
   int negate = signbit (__real__ x);
   int rcls = fpclassify (__real__ x);
   int icls = fpclassify (__imag__ x);
 
-  __real__ x = fabs (__real__ x);
+  __real__ x = M_FABS (__real__ x);
 
   if (__glibc_likely (icls >= FP_ZERO))
     {
@@ -39,31 +39,31 @@ __csin (__complex__ double x)
       if (__glibc_likely (rcls >= FP_ZERO))
 	{
 	  /* Real 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 (__real__ x > DBL_MIN))
+	  if (__glibc_likely (__real__ x > M_MIN))
 	    {
-	      __sincos (__real__ x, &sinix, &cosix);
+	      M_SINCOS (__real__ x, &sinix, &cosix);
 	    }
 	  else
 	    {
 	      sinix = __real__ x;
-	      cosix = 1.0;
+	      cosix = 1;
 	    }
 
 	  if (negate)
 	    sinix = -sinix;
 
-	  if (fabs (__imag__ x) > t)
+	  if (M_FABS (__imag__ x) > t)
 	    {
-	      double exp_t = __ieee754_exp (t);
-	      double ix = fabs (__imag__ x);
+	      FLOAT exp_t = M_EXP (t);
+	      FLOAT ix = M_FABS (__imag__ x);
 	      if (signbit (__imag__ x))
 		cosix = -cosix;
 	      ix -= t;
-	      sinix *= exp_t / 2.0;
-	      cosix *= exp_t / 2.0;
+	      sinix *= exp_t / 2;
+	      cosix *= exp_t / 2;
 	      if (ix > t)
 		{
 		  ix -= t;
@@ -73,20 +73,20 @@ __csin (__complex__ double x)
 	      if (ix > t)
 		{
 		  /* Overflow (original imaginary part of x > 3t).  */
-		  __real__ retval = DBL_MAX * sinix;
-		  __imag__ retval = DBL_MAX * cosix;
+		  __real__ retval = M_MAX * sinix;
+		  __imag__ retval = M_MAX * cosix;
 		}
 	      else
 		{
-		  double exp_val = __ieee754_exp (ix);
+		  FLOAT exp_val = M_EXP (ix);
 		  __real__ retval = exp_val * sinix;
 		  __imag__ retval = exp_val * cosix;
 		}
 	    }
 	  else
 	    {
-	      __real__ retval = __ieee754_cosh (__imag__ x) * sinix;
-	      __imag__ retval = __ieee754_sinh (__imag__ x) * cosix;
+	      __real__ retval = M_COSH (__imag__ x) * sinix;
+	      __imag__ retval = M_SINH (__imag__ x) * cosix;
 	    }
 
 	  math_check_force_underflow_complex (retval);
@@ -96,7 +96,7 @@ __csin (__complex__ double x)
 	  if (icls == FP_ZERO)
 	    {
 	      /* Imaginary part is 0.0.  */
-	      __real__ retval = __nan ("");
+	      __real__ retval = M_NAN;
 	      __imag__ retval = __imag__ x;
 
 	      if (rcls == FP_INFINITE)
@@ -104,8 +104,8 @@ __csin (__complex__ double x)
 	    }
 	  else
 	    {
-	      __real__ retval = __nan ("");
-	      __imag__ retval = __nan ("");
+	      __real__ retval = M_NAN;
+	      __imag__ retval = M_NAN;
 
 	      feraiseexcept (FE_INVALID);
 	    }
@@ -117,26 +117,26 @@ __csin (__complex__ double x)
       if (rcls == FP_ZERO)
 	{
 	  /* Real part is 0.0.  */
-	  __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
+	  __real__ retval = M_COPYSIGN (0, negate ? -1 : 1);
 	  __imag__ retval = __imag__ x;
 	}
       else if (rcls > FP_ZERO)
 	{
 	  /* Real part is finite.  */
-	  double sinix, cosix;
+	  FLOAT sinix, cosix;
 
-	  if (__glibc_likely (__real__ x > DBL_MIN))
+	  if (__glibc_likely (__real__ x > M_MIN))
 	    {
-	      __sincos (__real__ x, &sinix, &cosix);
+	      M_SINCOS (__real__ x, &sinix, &cosix);
 	    }
 	  else
 	    {
 	      sinix = __real__ x;
-	      cosix = 1.0;
+	      cosix = 1;
 	    }
 
-	  __real__ retval = __copysign (HUGE_VAL, sinix);
-	  __imag__ retval = __copysign (HUGE_VAL, cosix);
+	  __real__ retval = M_COPYSIGN (M_HUGE_VAL, sinix);
+	  __imag__ retval = M_COPYSIGN (M_HUGE_VAL, cosix);
 
 	  if (negate)
 	    __real__ retval = -__real__ retval;
@@ -146,8 +146,8 @@ __csin (__complex__ double x)
       else
 	{
 	  /* The addition raises the invalid exception.  */
-	  __real__ retval = __nan ("");
-	  __imag__ retval = HUGE_VAL;
+	  __real__ retval = M_NAN;
+	  __imag__ retval = M_HUGE_VAL;
 
 	  if (rcls == FP_INFINITE)
 	    feraiseexcept (FE_INVALID);
@@ -156,16 +156,17 @@ __csin (__complex__ double x)
   else
     {
       if (rcls == FP_ZERO)
-	__real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
+	__real__ retval = M_COPYSIGN (0, negate ? -1 : 1);
       else
-	__real__ retval = __nan ("");
-      __imag__ retval = __nan ("");
+	__real__ retval = M_NAN;
+      __imag__ retval = M_NAN;
     }
 
   return retval;
 }
-weak_alias (__csin, csin)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__csin, __csinl)
-weak_alias (__csin, csinl)
+
+declare_mgen_alias (__csin, csin)
+
+#if M_LIBM_NEED_COMPAT (csin)
+declare_mgen_libm_compat (__csin, csin)
 #endif
diff --git a/math/s_csinf.c b/math/s_csinf.c
deleted file mode 100644
index 1256abc..0000000
--- a/math/s_csinf.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/* Complex sine 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
-__csinf (__complex__ float x)
-{
-  __complex__ float retval;
-  int negate = signbit (__real__ x);
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  __real__ x = fabsf (__real__ x);
-
-  if (__glibc_likely (icls >= FP_ZERO))
-    {
-      /* Imaginary part is finite.  */
-      if (__glibc_likely (rcls >= FP_ZERO))
-	{
-	  /* Real part is finite.  */
-	  const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2);
-	  float sinix, cosix;
-
-	  if (__glibc_likely (__real__ x > FLT_MIN))
-	    {
-	      __sincosf (__real__ x, &sinix, &cosix);
-	    }
-	  else
-	    {
-	      sinix = __real__ x;
-	      cosix = 1.0f;
-	    }
-
-	  if (negate)
-	    sinix = -sinix;
-
-	  if (fabsf (__imag__ x) > t)
-	    {
-	      float exp_t = __ieee754_expf (t);
-	      float ix = fabsf (__imag__ x);
-	      if (signbit (__imag__ x))
-		cosix = -cosix;
-	      ix -= t;
-	      sinix *= exp_t / 2.0f;
-	      cosix *= exp_t / 2.0f;
-	      if (ix > t)
-		{
-		  ix -= t;
-		  sinix *= exp_t;
-		  cosix *= exp_t;
-		}
-	      if (ix > t)
-		{
-		  /* Overflow (original imaginary part of x > 3t).  */
-		  __real__ retval = FLT_MAX * sinix;
-		  __imag__ retval = FLT_MAX * cosix;
-		}
-	      else
-		{
-		  float exp_val = __ieee754_expf (ix);
-		  __real__ retval = exp_val * sinix;
-		  __imag__ retval = exp_val * cosix;
-		}
-	    }
-	  else
-	    {
-	      __real__ retval = __ieee754_coshf (__imag__ x) * sinix;
-	      __imag__ retval = __ieee754_sinhf (__imag__ x) * cosix;
-	    }
-
-	  math_check_force_underflow_complex (retval);
-	}
-      else
-	{
-	  if (icls == FP_ZERO)
-	    {
-	      /* Imaginary part is 0.0.  */
-	      __real__ retval = __nanf ("");
-	      __imag__ retval = __imag__ x;
-
-	      if (rcls == FP_INFINITE)
-		feraiseexcept (FE_INVALID);
-	    }
-	  else
-	    {
-	      __real__ retval = __nanf ("");
-	      __imag__ retval = __nanf ("");
-
-	      feraiseexcept (FE_INVALID);
-	    }
-	}
-    }
-  else if (icls == FP_INFINITE)
-    {
-      /* Imaginary part is infinite.  */
-      if (rcls == FP_ZERO)
-	{
-	  /* Real part is 0.0.  */
-	  __real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0);
-	  __imag__ retval = __imag__ x;
-	}
-      else if (rcls > FP_ZERO)
-	{
-	  /* Real part is finite.  */
-	  float sinix, cosix;
-
-	  if (__glibc_likely (__real__ x > FLT_MIN))
-	    {
-	      __sincosf (__real__ x, &sinix, &cosix);
-	    }
-	  else
-	    {
-	      sinix = __real__ x;
-	      cosix = 1.0f;
-	    }
-
-	  __real__ retval = __copysignf (HUGE_VALF, sinix);
-	  __imag__ retval = __copysignf (HUGE_VALF, cosix);
-
-	  if (negate)
-	    __real__ retval = -__real__ retval;
-	  if (signbit (__imag__ x))
-	    __imag__ retval = -__imag__ retval;
-	}
-      else
-	{
-	  /* The addition raises the invalid exception.  */
-	  __real__ retval = __nanf ("");
-	  __imag__ retval = HUGE_VALF;
-
-	  if (rcls == FP_INFINITE)
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else
-    {
-      if (rcls == FP_ZERO)
-	__real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0);
-      else
-	__real__ retval = __nanf ("");
-      __imag__ retval = __nanf ("");
-    }
-
-  return retval;
-}
-#ifndef __csinf
-weak_alias (__csinf, csinf)
-#endif
diff --git a/math/s_csinh.c b/math/s_csinh.c
deleted file mode 100644
index 5fb60ed..0000000
--- a/math/s_csinh.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/* Complex sine 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
-__csinh (__complex__ double x)
-{
-  __complex__ double retval;
-  int negate = signbit (__real__ x);
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  __real__ x = fabs (__real__ 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 (negate)
-	    cosix = -cosix;
-
-	  if (fabs (__real__ x) > t)
-	    {
-	      double exp_t = __ieee754_exp (t);
-	      double rx = fabs (__real__ x);
-	      if (signbit (__real__ x))
-		cosix = -cosix;
-	      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_sinh (__real__ x) * cosix;
-	      __imag__ retval = __ieee754_cosh (__real__ x) * sinix;
-	    }
-
-	  math_check_force_underflow_complex (retval);
-	}
-      else
-	{
-	  if (rcls == FP_ZERO)
-	    {
-	      /* Real part is 0.0.  */
-	      __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
-	      __imag__ retval = __nan ("") + __nan ("");
-
-	      if (icls == FP_INFINITE)
-		feraiseexcept (FE_INVALID);
-	    }
-	  else
-	    {
-	      __real__ retval = __nan ("");
-	      __imag__ retval = __nan ("");
-
-	      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);
-
-	  if (negate)
-	    __real__ retval = -__real__ retval;
-	}
-      else if (icls == FP_ZERO)
-	{
-	  /* Imaginary part is 0.0.  */
-	  __real__ retval = negate ? -HUGE_VAL : HUGE_VAL;
-	  __imag__ retval = __imag__ 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 (__csinh, csinh)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__csinh, __csinhl)
-weak_alias (__csinh, csinhl)
-#endif
diff --git a/math/s_csinh_template.c b/math/s_csinh_template.c
index 5fb60ed..22c0c31 100644
--- a/math/s_csinh_template.c
+++ b/math/s_csinh_template.c
@@ -1,4 +1,4 @@
-/* Complex sine hyperbole function for double.
+/* Complex sine hyperbole 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,15 +23,15 @@
 #include <math_private.h>
 #include <float.h>
 
-__complex__ double
-__csinh (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__csinh) (CFLOAT x)
 {
-  __complex__ double retval;
+  CFLOAT retval;
   int negate = signbit (__real__ x);
   int rcls = fpclassify (__real__ x);
   int icls = fpclassify (__imag__ x);
 
-  __real__ x = fabs (__real__ x);
+  __real__ x = M_FABS (__real__ x);
 
   if (__glibc_likely (rcls >= FP_ZERO))
     {
@@ -39,31 +39,31 @@ __csinh (__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 (negate)
 	    cosix = -cosix;
 
-	  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))
 		cosix = -cosix;
 	      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;
@@ -73,20 +73,20 @@ __csinh (__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_sinh (__real__ x) * cosix;
-	      __imag__ retval = __ieee754_cosh (__real__ x) * sinix;
+	      __real__ retval = M_SINH (__real__ x) * cosix;
+	      __imag__ retval = M_COSH (__real__ x) * sinix;
 	    }
 
 	  math_check_force_underflow_complex (retval);
@@ -96,16 +96,16 @@ __csinh (__complex__ double x)
 	  if (rcls == FP_ZERO)
 	    {
 	      /* Real part is 0.0.  */
-	      __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
-	      __imag__ retval = __nan ("") + __nan ("");
+	      __real__ retval = M_COPYSIGN (0, negate ? -1 : 1);
+	      __imag__ retval = M_NAN + M_NAN;
 
 	      if (icls == FP_INFINITE)
 		feraiseexcept (FE_INVALID);
 	    }
 	  else
 	    {
-	      __real__ retval = __nan ("");
-	      __imag__ retval = __nan ("");
+	      __real__ retval = M_NAN;
+	      __imag__ retval = M_NAN;
 
 	      feraiseexcept (FE_INVALID);
 	    }
@@ -117,20 +117,20 @@ __csinh (__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);
+	  __real__ retval = M_COPYSIGN (M_HUGE_VAL, cosix);
+	  __imag__ retval = M_COPYSIGN (M_HUGE_VAL, sinix);
 
 	  if (negate)
 	    __real__ retval = -__real__ retval;
@@ -138,14 +138,14 @@ __csinh (__complex__ double x)
       else if (icls == FP_ZERO)
 	{
 	  /* Imaginary part is 0.0.  */
-	  __real__ retval = negate ? -HUGE_VAL : HUGE_VAL;
+	  __real__ retval = negate ? -M_HUGE_VAL : M_HUGE_VAL;
 	  __imag__ retval = __imag__ 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);
@@ -153,14 +153,15 @@ __csinh (__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 (__csinh, csinh)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__csinh, __csinhl)
-weak_alias (__csinh, csinhl)
+
+declare_mgen_alias (__csinh, csinh)
+
+#if M_LIBM_NEED_COMPAT (csinh)
+declare_mgen_libm_compat (__csinh, csinh)
 #endif
diff --git a/math/s_csinhf.c b/math/s_csinhf.c
deleted file mode 100644
index 36b42ca..0000000
--- a/math/s_csinhf.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/* Complex sine 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
-__csinhf (__complex__ float x)
-{
-  __complex__ float retval;
-  int negate = signbit (__real__ x);
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  __real__ x = fabsf (__real__ 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 (negate)
-	    cosix = -cosix;
-
-	  if (fabsf (__real__ x) > t)
-	    {
-	      float exp_t = __ieee754_expf (t);
-	      float rx = fabsf (__real__ x);
-	      if (signbit (__real__ x))
-		cosix = -cosix;
-	      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_sinhf (__real__ x) * cosix;
-	      __imag__ retval = __ieee754_coshf (__real__ x) * sinix;
-	    }
-
-	  math_check_force_underflow_complex (retval);
-	}
-      else
-	{
-	  if (rcls == FP_ZERO)
-	    {
-	      /* Real part is 0.0.  */
-	      __real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0);
-	      __imag__ retval = __nanf ("") + __nanf ("");
-
-	      if (icls == FP_INFINITE)
-		feraiseexcept (FE_INVALID);
-	    }
-	  else
-	    {
-	      __real__ retval = __nanf ("");
-	      __imag__ retval = __nanf ("");
-
-	      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);
-
-	  if (negate)
-	    __real__ retval = -__real__ retval;
-	}
-      else if (icls == FP_ZERO)
-	{
-	  /* Imaginary part is 0.0.  */
-	  __real__ retval = negate ? -HUGE_VALF : HUGE_VALF;
-	  __imag__ retval = __imag__ 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 __csinhf
-weak_alias (__csinhf, csinhf)
-#endif
diff --git a/math/s_csinhl.c b/math/s_csinhl.c
deleted file mode 100644
index c231d7b..0000000
--- a/math/s_csinhl.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/* Complex sine 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
-__csinhl (__complex__ long double x)
-{
-  __complex__ long double retval;
-  int negate = signbit (__real__ x);
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  __real__ x = fabsl (__real__ 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 (negate)
-	    cosix = -cosix;
-
-	  if (fabsl (__real__ x) > t)
-	    {
-	      long double exp_t = __ieee754_expl (t);
-	      long double rx = fabsl (__real__ x);
-	      if (signbit (__real__ x))
-		cosix = -cosix;
-	      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_sinhl (__real__ x) * cosix;
-	      __imag__ retval = __ieee754_coshl (__real__ x) * sinix;
-	    }
-
-	  math_check_force_underflow_complex (retval);
-	}
-      else
-	{
-	  if (rcls == FP_ZERO)
-	    {
-	      /* Real part is 0.0.  */
-	      __real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0);
-	      __imag__ retval = __nanl ("") + __nanl ("");
-
-	      if (icls == FP_INFINITE)
-		feraiseexcept (FE_INVALID);
-	    }
-	  else
-	    {
-	      __real__ retval = __nanl ("");
-	      __imag__ retval = __nanl ("");
-
-	      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);
-
-	  if (negate)
-	    __real__ retval = -__real__ retval;
-	}
-      else if (icls == FP_ZERO)
-	{
-	  /* Imaginary part is 0.0.  */
-	  __real__ retval = negate ? -HUGE_VALL : HUGE_VALL;
-	  __imag__ retval = __imag__ 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 (__csinhl, csinhl)
diff --git a/math/s_csinl.c b/math/s_csinl.c
deleted file mode 100644
index 9742a31..0000000
--- a/math/s_csinl.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/* Complex sine 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
-__csinl (__complex__ long double x)
-{
-  __complex__ long double retval;
-  int negate = signbit (__real__ x);
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  __real__ x = fabsl (__real__ x);
-
-  if (__glibc_likely (icls >= FP_ZERO))
-    {
-      /* Imaginary part is finite.  */
-      if (__glibc_likely (rcls >= FP_ZERO))
-	{
-	  /* Real part is finite.  */
-	  const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l);
-	  long double sinix, cosix;
-
-	  if (__glibc_likely (__real__ x > LDBL_MIN))
-	    {
-	      __sincosl (__real__ x, &sinix, &cosix);
-	    }
-	  else
-	    {
-	      sinix = __real__ x;
-	      cosix = 1.0;
-	    }
-
-	  if (negate)
-	    sinix = -sinix;
-
-	  if (fabsl (__imag__ x) > t)
-	    {
-	      long double exp_t = __ieee754_expl (t);
-	      long double ix = fabsl (__imag__ x);
-	      if (signbit (__imag__ x))
-		cosix = -cosix;
-	      ix -= t;
-	      sinix *= exp_t / 2.0L;
-	      cosix *= exp_t / 2.0L;
-	      if (ix > t)
-		{
-		  ix -= t;
-		  sinix *= exp_t;
-		  cosix *= exp_t;
-		}
-	      if (ix > t)
-		{
-		  /* Overflow (original imaginary part of x > 3t).  */
-		  __real__ retval = LDBL_MAX * sinix;
-		  __imag__ retval = LDBL_MAX * cosix;
-		}
-	      else
-		{
-		  long double exp_val = __ieee754_expl (ix);
-		  __real__ retval = exp_val * sinix;
-		  __imag__ retval = exp_val * cosix;
-		}
-	    }
-	  else
-	    {
-	      __real__ retval = __ieee754_coshl (__imag__ x) * sinix;
-	      __imag__ retval = __ieee754_sinhl (__imag__ x) * cosix;
-	    }
-
-	  math_check_force_underflow_complex (retval);
-	}
-      else
-	{
-	  if (icls == FP_ZERO)
-	    {
-	      /* Imaginary part is 0.0.  */
-	      __real__ retval = __nanl ("");
-	      __imag__ retval = __imag__ x;
-
-	      if (rcls == FP_INFINITE)
-		feraiseexcept (FE_INVALID);
-	    }
-	  else
-	    {
-	      __real__ retval = __nanl ("");
-	      __imag__ retval = __nanl ("");
-
-	      feraiseexcept (FE_INVALID);
-	    }
-	}
-    }
-  else if (icls == FP_INFINITE)
-    {
-      /* Imaginary part is infinite.  */
-      if (rcls == FP_ZERO)
-	{
-	  /* Real part is 0.0.  */
-	  __real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0);
-	  __imag__ retval = __imag__ x;
-	}
-      else if (rcls > FP_ZERO)
-	{
-	  /* Real part is finite.  */
-	  long double sinix, cosix;
-
-	  if (__glibc_likely (__real__ x > LDBL_MIN))
-	    {
-	      __sincosl (__real__ x, &sinix, &cosix);
-	    }
-	  else
-	    {
-	      sinix = __real__ x;
-	      cosix = 1.0;
-	    }
-
-	  __real__ retval = __copysignl (HUGE_VALL, sinix);
-	  __imag__ retval = __copysignl (HUGE_VALL, cosix);
-
-	  if (negate)
-	    __real__ retval = -__real__ retval;
-	  if (signbit (__imag__ x))
-	    __imag__ retval = -__imag__ retval;
-	}
-      else
-	{
-	  /* The addition raises the invalid exception.  */
-	  __real__ retval = __nanl ("");
-	  __imag__ retval = HUGE_VALL;
-
-	  if (rcls == FP_INFINITE)
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-  else
-    {
-      if (rcls == FP_ZERO)
-	__real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0);
-      else
-	__real__ retval = __nanl ("");
-      __imag__ retval = __nanl ("");
-    }
-
-  return retval;
-}
-weak_alias (__csinl, csinl)
diff --git a/sysdeps/alpha/fpu/s_casinf.c b/sysdeps/alpha/fpu/s_casinf.c
index f85f524..08d0a6d 100644
--- a/sysdeps/alpha/fpu/s_casinf.c
+++ b/sysdeps/alpha/fpu/s_casinf.c
@@ -24,14 +24,18 @@
 
 #undef __casinf
 #undef casinf
-#define __casinf internal_casinf
 
 static _Complex float internal_casinf (_Complex float x);
 
-#include <math/s_casinf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_casinf
+#include <math-type-macros-float.h>
 
-#undef __casinf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_casin_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_casinf (c1_cfloat_decl (x))
diff --git a/sysdeps/alpha/fpu/s_casinhf.c b/sysdeps/alpha/fpu/s_casinhf.c
index 720294e..11faf9a 100644
--- a/sysdeps/alpha/fpu/s_casinhf.c
+++ b/sysdeps/alpha/fpu/s_casinhf.c
@@ -24,14 +24,18 @@
 
 #undef __casinhf
 #undef casinhf
-#define __casinhf internal_casinhf
 
 static _Complex float internal_casinhf (_Complex float x);
 
-#include <math/s_casinhf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_casinhf
+#include <math-type-macros-float.h>
 
-#undef __casinhf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_casinh_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_casinhf (c1_cfloat_decl (x))
diff --git a/sysdeps/alpha/fpu/s_csinf.c b/sysdeps/alpha/fpu/s_csinf.c
index abe2d3a..fc49244 100644
--- a/sysdeps/alpha/fpu/s_csinf.c
+++ b/sysdeps/alpha/fpu/s_csinf.c
@@ -24,14 +24,18 @@
 
 #undef __csinf
 #undef csinf
-#define __csinf internal_csinf
 
 static _Complex float internal_csinf (_Complex float x);
 
-#include <math/s_csinf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_csinf
+#include <math-type-macros-float.h>
 
-#undef __csinf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_csin_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_csinf (c1_cfloat_decl (x))
diff --git a/sysdeps/alpha/fpu/s_csinhf.c b/sysdeps/alpha/fpu/s_csinhf.c
index a6d470a..6263cd0 100644
--- a/sysdeps/alpha/fpu/s_csinhf.c
+++ b/sysdeps/alpha/fpu/s_csinhf.c
@@ -24,14 +24,18 @@
 
 #undef __csinhf
 #undef csinhf
-#define __csinhf internal_csinhf
 
 static _Complex float internal_csinhf (_Complex float x);
 
-#include <math/s_csinhf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_csinhf
+#include <math-type-macros-float.h>
 
-#undef __csinhf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_csinh_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_csinhf (c1_cfloat_decl (x))
diff --git a/sysdeps/ieee754/ldbl-opt/s_casin.c b/sysdeps/ieee754/ldbl-opt/s_casin.c
deleted file mode 100644
index 04c47ca..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_casin.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_casin.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __casin, casinl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_casinh.c b/sysdeps/ieee754/ldbl-opt/s_casinh.c
deleted file mode 100644
index 19c4fa3..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_casinh.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_casinh.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __casinh, casinhl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_casinhl.c b/sysdeps/ieee754/ldbl-opt/s_casinhl.c
deleted file mode 100644
index 976fa8e..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_casinhl.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_casinhl.c>
-long_double_symbol (libm, __casinhl, casinhl);
diff --git a/sysdeps/ieee754/ldbl-opt/s_casinl.c b/sysdeps/ieee754/ldbl-opt/s_casinl.c
deleted file mode 100644
index 7afb77c..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_casinl.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_casinl.c>
-long_double_symbol (libm, __casinl, casinl);
diff --git a/sysdeps/ieee754/ldbl-opt/s_csin.c b/sysdeps/ieee754/ldbl-opt/s_csin.c
deleted file mode 100644
index 7017c95..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_csin.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_csin.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __csin, csinl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_csinh.c b/sysdeps/ieee754/ldbl-opt/s_csinh.c
deleted file mode 100644
index a1fa667..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_csinh.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_csinh.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __csinh, csinhl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_csinhl.c b/sysdeps/ieee754/ldbl-opt/s_csinhl.c
deleted file mode 100644
index 484d466..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_csinhl.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_csinhl.c>
-long_double_symbol (libm, __csinhl, csinhl);
diff --git a/sysdeps/ieee754/ldbl-opt/s_csinl.c b/sysdeps/ieee754/ldbl-opt/s_csinl.c
deleted file mode 100644
index f71642e..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_csinl.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_csinl.c>
-long_double_symbol (libm, __csinl, csinl);
diff --git a/sysdeps/m68k/m680x0/fpu/s_csin.c b/sysdeps/m68k/m680x0/fpu/s_csin_template.c
similarity index 86%
rename from sysdeps/m68k/m680x0/fpu/s_csin.c
rename to sysdeps/m68k/m680x0/fpu/s_csin_template.c
index b8419be..628d0d5 100644
--- a/sysdeps/m68k/m680x0/fpu/s_csin.c
+++ b/sysdeps/m68k/m680x0/fpu/s_csin_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(__csin) (__complex__ float_type x)
+CFLOAT
+s(__csin) (CFLOAT x)
 {
-  __complex__ float_type retval;
+  CFLOAT retval;
   unsigned long rx_cond = __m81_test (__real__ x);
 
   if ((rx_cond & (__M81_COND_INF|__M81_COND_NAN)) == 0)
     {
       /* Real part is finite.  */
-      float_type sin_rx, cos_rx;
+      FLOAT sin_rx, cos_rx;
 
       __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_rx), "=f" (cos_rx)
 	     : "f" (__real__ x));
diff --git a/sysdeps/m68k/m680x0/fpu/s_csinf.c b/sysdeps/m68k/m680x0/fpu/s_csinf.c
deleted file mode 100644
index b760e19..0000000
--- a/sysdeps/m68k/m680x0/fpu/s_csinf.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define SUFF f
-#define float_type float
-#include <s_csin.c>
diff --git a/sysdeps/m68k/m680x0/fpu/s_csinh.c b/sysdeps/m68k/m680x0/fpu/s_csinh_template.c
similarity index 88%
rename from sysdeps/m68k/m680x0/fpu/s_csinh.c
rename to sysdeps/m68k/m680x0/fpu/s_csinh_template.c
index c633cd8..56f3bab 100644
--- a/sysdeps/m68k/m680x0/fpu/s_csinh.c
+++ b/sysdeps/m68k/m680x0/fpu/s_csinh_template.c
@@ -21,21 +21,14 @@
 #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(__csinh) (__complex__ float_type x)
+CFLOAT
+s(__csinh) (CFLOAT x)
 {
-  __complex__ float_type retval;
+  CFLOAT retval;
   unsigned long ix_cond;
 
   ix_cond = __m81_test (__imag__ x);
@@ -43,7 +36,7 @@ s(__csinh) (__complex__ float_type 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_csinhf.c b/sysdeps/m68k/m680x0/fpu/s_csinhf.c
deleted file mode 100644
index 2f7a43e..0000000
--- a/sysdeps/m68k/m680x0/fpu/s_csinhf.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define SUFF f
-#define float_type float
-#include <s_csinh.c>
diff --git a/sysdeps/m68k/m680x0/fpu/s_csinhl.c b/sysdeps/m68k/m680x0/fpu/s_csinhl.c
deleted file mode 100644
index 026a20e..0000000
--- a/sysdeps/m68k/m680x0/fpu/s_csinhl.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define SUFF l
-#define float_type long double
-#include <s_csinh.c>
diff --git a/sysdeps/m68k/m680x0/fpu/s_csinl.c b/sysdeps/m68k/m680x0/fpu/s_csinl.c
deleted file mode 100644
index ea2dad0..0000000
--- a/sysdeps/m68k/m680x0/fpu/s_csinl.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define SUFF l
-#define float_type long double
-#include <s_csin.c>
-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCHv4 5/8] Prepare to convert _Complex tangent functions
  2016-08-18 22:35 [PATCHv4 1/8] Prepare to convert _Complex cosine functions Paul E. Murphy
@ 2016-08-18 22:35 ` Paul E. Murphy
  2016-08-18 22:35 ` [PATCHv4 3/8] Prepare to convert _Complex sine functions Paul E. Murphy
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Paul E. Murphy @ 2016-08-18 22:35 UTC (permalink / raw)
  To: libc-alpha

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.

	* s_catan_template.c: Copy of s_catan.c.
	* s_catanh_template.c: Copy of s_catanh.c.
	* s_ctan_template.c: Copy of s_ctan.c.
	* s_ctanh_template.c: Copy of s_ctanh.c.
---
 math/{s_catan.c => s_catan_template.c}   | 0
 math/{s_catanh.c => s_catanh_template.c} | 0
 math/{s_ctan.c => s_ctan_template.c}     | 0
 math/{s_ctanh.c => s_ctanh_template.c}   | 0
 4 files changed, 0 insertions(+), 0 deletions(-)
 copy math/{s_catan.c => s_catan_template.c} (100%)
 copy math/{s_catanh.c => s_catanh_template.c} (100%)
 copy math/{s_ctan.c => s_ctan_template.c} (100%)
 copy math/{s_ctanh.c => s_ctanh_template.c} (100%)

diff --git a/math/s_catan.c b/math/s_catan_template.c
similarity index 100%
copy from math/s_catan.c
copy to math/s_catan_template.c
diff --git a/math/s_catanh.c b/math/s_catanh_template.c
similarity index 100%
copy from math/s_catanh.c
copy to math/s_catanh_template.c
diff --git a/math/s_ctan.c b/math/s_ctan_template.c
similarity index 100%
copy from math/s_ctan.c
copy to math/s_ctan_template.c
diff --git a/math/s_ctanh.c b/math/s_ctanh_template.c
similarity index 100%
copy from math/s_ctanh.c
copy to math/s_ctanh_template.c
-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCHv4 2/8] Convert _Complex cosine functions to generated code
  2016-08-18 22:35 [PATCHv4 1/8] Prepare to convert _Complex cosine functions Paul E. Murphy
                   ` (2 preceding siblings ...)
  2016-08-18 22:35 ` [PATCHv4 4/8] Convert _Complex sine functions to generated code Paul E. Murphy
@ 2016-08-18 22:35 ` Paul E. Murphy
  2016-08-19 14:57   ` Joseph Myers
  2016-08-18 22:35 ` [PATCHv4 6/8] Convert _Complex tangent " Paul E. Murphy
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 20+ messages in thread
From: Paul E. Murphy @ 2016-08-18 22:35 UTC (permalink / raw)
  To: libc-alpha

This is fairly straight fowards.  m68k overrides are
updated to use the framework, and thus are simplified
a bit.

	* 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.
---
 math/Makefile                                      |   9 +-
 math/s_cacos.c                                     |  58 --------
 math/s_cacos_template.c                            |  29 ++--
 math/s_cacosf.c                                    |  56 --------
 math/s_cacosh.c                                    |  94 -------------
 math/s_cacosh_template.c                           |  50 +++----
 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                             |  20 +--
 math/s_ccosf.c                                     |  38 ------
 math/s_ccosh.c                                     | 147 ---------------------
 math/s_ccosh_template.c                            |  77 +++++------
 math/s_ccoshf.c                                    | 145 --------------------
 math/s_ccoshl.c                                    | 143 --------------------
 math/s_ccosl.c                                     |  36 -----
 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/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 -
 .../m680x0/fpu/{s_ccosh.c => s_ccosh_template.c}   |  18 +--
 sysdeps/m68k/m680x0/fpu/s_ccoshf.c                 |   3 -
 sysdeps/m68k/m680x0/fpu/s_ccoshl.c                 |   3 -
 32 files changed, 133 insertions(+), 1162 deletions(-)
 delete mode 100644 math/s_cacos.c
 delete mode 100644 math/s_cacosf.c
 delete mode 100644 math/s_cacosh.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
 delete mode 100644 math/s_ccosf.c
 delete mode 100644 math/s_ccosh.c
 delete mode 100644 math/s_ccoshf.c
 delete mode 100644 math/s_ccoshl.c
 delete mode 100644 math/s_ccosl.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
 rename sysdeps/m68k/m680x0/fpu/{s_ccosh.c => s_ccosh_template.c} (87%)
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_ccoshf.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_ccoshl.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>
-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCHv4 8/8] Convert remaining complex function to generated files
  2016-08-18 22:35 [PATCHv4 1/8] Prepare to convert _Complex cosine functions Paul E. Murphy
                   ` (5 preceding siblings ...)
  2016-08-18 22:35 ` [PATCHv4 7/8] Prepare to convert remaining _Complex functions Paul E. Murphy
@ 2016-08-18 22:35 ` Paul E. Murphy
  2016-08-19 20:46   ` Joseph Myers
  6 siblings, 1 reply; 20+ messages in thread
From: Paul E. Murphy @ 2016-08-18 22:35 UTC (permalink / raw)
  To: libc-alpha

Convert cpow, clog, clog10, cexp, csqrt, and cproj functions
into generated templates.  Note, ldbl-opt still retains
s_clog10l.c as the aliasing rules are non-trivial.

	* math/Makefile (libm-gen-calls): Add cpow, clog, clog10, cexp, cproj.
	(libm-calls): Remove the above.

	* math/s_cexp_template.c: Update using type-generic macros.
	* math/s_clog10_template.c: Likewise.
	* math/s_cpow_template.c: Likewise.
	* math/s_clog_template.c: Likewise.
	* math/s_cproj_template.c: Likewise.
	* math/s_csqrt_template.c: Likewise.

	* math/s_cexp.c: Removed.
	* math/s_cexpf.c: Removed.
	* math/s_cexpl.c: Removed.
	* math/s_clog10.c: Removed.
	* math/s_clog10f.c: Removed.
	* math/s_clog10l.c: Removed.
	* math/s_cpow.c: Removed.
	* math/s_cpowf.c: Removed.
	* math/s_cpowl.c: Removed.
	* math/s_clog.c: Removed.
	* math/s_clogf.c: Removed.
	* math/s_clogl.c: Removed.
	* math/s_cproj.c: Removed.
	* math/s_cprojf.c: Removed.
	* math/s_cprojl.c: Removed.
	* math/s_csqrt.c: Removed.
	* math/s_csqrtf.c: Removed.
	* math/s_csqrtl.c: Removed.

	* sysdeps/alpha/fpu/s_cexpf.c: Update using templated version.
	* sysdeps/alpha/fpu/s_clog10f.c: Update using templated version.
	* sysdeps/alpha/fpu/s_clogf.c: Update using templated version.
	* sysdeps/alpha/fpu/s_cpowf.c: Update using templated version.
	* sysdeps/alpha/fpu/s_cprojf.c: Update using templated version.
	* sysdeps/alpha/fpu/s_csqrtf.c: Update using templated version.

	* sysdeps/ieee754/ldbl-opt/s_cexp.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_cexpl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_clog.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_clog10.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_clog10l.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_cpow.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_cpowl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_cproj.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_cprojl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_csqrt.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_csqrtl.c: Removed.

	* sysdeps/ieee754/ldbl-opt/s_clogl.c: Update using templated
	version.

	* sysdeps/m68k/m680x0/fpu/s_cexp.c: Refactor into.
	* sysdeps/m68k/m680x0/fpu/s_cexp_template.c: New file.
	* sysdeps/m68k/m680x0/fpu/s_cexpf.c: Removed.
	* sysdeps/m68k/m680x0/fpu/s_cexpl.c: Removed.
---
 math/Makefile                                      |   5 +-
 math/s_cexp.c                                      | 157 --------------------
 math/s_cexp_template.c                             |  64 ++++----
 math/s_cexpf.c                                     | 155 -------------------
 math/s_cexpl.c                                     | 153 -------------------
 math/s_clog.c                                      | 118 ---------------
 math/s_clog10.c                                    | 124 ----------------
 math/s_clog10_template.c                           |  90 +++++------
 math/s_clog10f.c                                   | 122 ---------------
 math/s_clog10l.c                                   | 127 ----------------
 math/s_clog_template.c                             |  83 ++++++-----
 math/s_clogf.c                                     | 116 ---------------
 math/s_clogl.c                                     | 121 ---------------
 math/s_cpow.c                                      |  33 -----
 math/s_cpow_template.c                             |  18 +--
 math/s_cpowf.c                                     |  31 ----
 math/s_cpowl.c                                     |  29 ----
 math/s_cproj.c                                     |  44 ------
 math/s_cproj_template.c                            |  19 +--
 math/s_cprojf.c                                    |  42 ------
 math/s_cprojl.c                                    |  40 -----
 math/s_csqrt.c                                     | 165 ---------------------
 math/s_csqrt_template.c                            | 105 +++++++------
 math/s_csqrtf.c                                    | 163 --------------------
 math/s_csqrtl.c                                    | 161 --------------------
 sysdeps/alpha/fpu/s_cexpf.c                        |  12 +-
 sysdeps/alpha/fpu/s_clog10f.c                      |  12 +-
 sysdeps/alpha/fpu/s_clogf.c                        |  12 +-
 sysdeps/alpha/fpu/s_cpowf.c                        |  12 +-
 sysdeps/alpha/fpu/s_cprojf.c                       |  12 +-
 sysdeps/alpha/fpu/s_csqrtf.c                       |  12 +-
 sysdeps/ieee754/ldbl-opt/s_cexp.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/s_cexpl.c                 |   6 -
 sysdeps/ieee754/ldbl-opt/s_clog.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/s_clog10.c                |   7 -
 sysdeps/ieee754/ldbl-opt/s_clog10l.c               |  36 ++++-
 sysdeps/ieee754/ldbl-opt/s_clogl.c                 |   6 -
 sysdeps/ieee754/ldbl-opt/s_cpow.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/s_cpowl.c                 |   6 -
 sysdeps/ieee754/ldbl-opt/s_cproj.c                 |   6 -
 sysdeps/ieee754/ldbl-opt/s_cprojl.c                |   6 -
 sysdeps/ieee754/ldbl-opt/s_csqrt.c                 |   6 -
 sysdeps/ieee754/ldbl-opt/s_csqrtl.c                |   6 -
 .../m680x0/fpu/{s_cexp.c => s_cexp_template.c}     |  15 +-
 sysdeps/m68k/m680x0/fpu/s_cexpf.c                  |   3 -
 sysdeps/m68k/m680x0/fpu/s_cexpl.c                  |   3 -
 46 files changed, 275 insertions(+), 2206 deletions(-)
 delete mode 100644 math/s_cexp.c
 delete mode 100644 math/s_cexpf.c
 delete mode 100644 math/s_cexpl.c
 delete mode 100644 math/s_clog.c
 delete mode 100644 math/s_clog10.c
 delete mode 100644 math/s_clog10f.c
 delete mode 100644 math/s_clog10l.c
 delete mode 100644 math/s_clogf.c
 delete mode 100644 math/s_clogl.c
 delete mode 100644 math/s_cpow.c
 delete mode 100644 math/s_cpowf.c
 delete mode 100644 math/s_cpowl.c
 delete mode 100644 math/s_cproj.c
 delete mode 100644 math/s_cprojf.c
 delete mode 100644 math/s_cprojl.c
 delete mode 100644 math/s_csqrt.c
 delete mode 100644 math/s_csqrtf.c
 delete mode 100644 math/s_csqrtl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_cexp.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_cexpl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_clog.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_clog10.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_clogl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_cpow.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_cpowl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_cproj.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_cprojl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csqrt.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csqrtl.c
 rename sysdeps/m68k/m680x0/fpu/{s_cexp.c => s_cexp_template.c} (94%)
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_cexpf.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_cexpl.c

diff --git a/math/Makefile b/math/Makefile
index 03cbd1d..65a6ad8 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -48,7 +48,8 @@ libm-support = s_lib_version s_matherr s_signgam			\
 gen-libm-calls = cargF conjF cimagF crealF cabsF s_cacosF		  \
 	         s_cacoshF s_ccosF s_ccoshF s_casinF s_csinF s_casinhF	  \
 		 k_casinhF s_csinhF k_casinhF s_csinhF s_catanhF s_catanF \
-		 s_ctanF s_ctanhF
+		 s_ctanF s_ctanhF s_cexpF s_clogF s_cprojF s_csqrtF	  \
+		 s_cpowF s_clog10F					  \
 
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
@@ -66,8 +67,6 @@ 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_clogF							  \
-	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				  \
 	gamma_productF lgamma_negF lgamma_productF			  \
diff --git a/math/s_cexp.c b/math/s_cexp.c
deleted file mode 100644
index 3a476bd..0000000
--- a/math/s_cexp.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/* Return value of complex exponential function for double complex 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>
-#include <float.h>
-
-__complex__ double
-__cexp (__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 (__real__ x > t)
-	    {
-	      double exp_t = __ieee754_exp (t);
-	      __real__ x -= t;
-	      sinix *= exp_t;
-	      cosix *= exp_t;
-	      if (__real__ x > t)
-		{
-		  __real__ x -= t;
-		  sinix *= exp_t;
-		  cosix *= exp_t;
-		}
-	    }
-	  if (__real__ x > t)
-	    {
-	      /* Overflow (original real part of x > 3t).  */
-	      __real__ retval = DBL_MAX * cosix;
-	      __imag__ retval = DBL_MAX * sinix;
-	    }
-	  else
-	    {
-	      double exp_val = __ieee754_exp (__real__ x);
-	      __real__ retval = exp_val * cosix;
-	      __imag__ retval = exp_val * sinix;
-	    }
-	  math_check_force_underflow_complex (retval);
-	}
-      else
-	{
-	  /* If the imaginary part is +-inf or NaN and the real part
-	     is not +-inf the result is NaN + iNaN.  */
-	  __real__ retval = __nan ("");
-	  __imag__ retval = __nan ("");
-
-	  feraiseexcept (FE_INVALID);
-	}
-    }
-  else if (__glibc_likely (rcls == FP_INFINITE))
-    {
-      /* Real part is infinite.  */
-      if (__glibc_likely (icls >= FP_ZERO))
-	{
-	  /* Imaginary part is finite.  */
-	  double value = signbit (__real__ x) ? 0.0 : HUGE_VAL;
-
-	  if (icls == FP_ZERO)
-	    {
-	      /* Imaginary part is 0.0.  */
-	      __real__ retval = value;
-	      __imag__ retval = __imag__ x;
-	    }
-	  else
-	    {
-	      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 (value, cosix);
-	      __imag__ retval = __copysign (value, sinix);
-	    }
-	}
-      else if (signbit (__real__ x) == 0)
-	{
-	  __real__ retval = HUGE_VAL;
-	  __imag__ retval = __nan ("");
-
-	  if (icls == FP_INFINITE)
-	    feraiseexcept (FE_INVALID);
-	}
-      else
-	{
-	  __real__ retval = 0.0;
-	  __imag__ retval = __copysign (0.0, __imag__ x);
-	}
-    }
-  else
-    {
-      /* If the real part is NaN the result is NaN + iNaN unless the
-	 imaginary part is zero.  */
-      __real__ retval = __nan ("");
-      if (icls == FP_ZERO)
-	__imag__ retval = __imag__ x;
-      else
-	{
-	  __imag__ retval = __nan ("");
-
-	  if (rcls != FP_NAN || icls != FP_NAN)
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-
-  return retval;
-}
-weak_alias (__cexp, cexp)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cexp, __cexpl)
-weak_alias (__cexp, cexpl)
-#endif
diff --git a/math/s_cexp_template.c b/math/s_cexp_template.c
index 3a476bd..a60afe0 100644
--- a/math/s_cexp_template.c
+++ b/math/s_cexp_template.c
@@ -1,4 +1,4 @@
-/* Return value of complex exponential function for double complex value.
+/* Return value of complex exponential function for a 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.
@@ -23,10 +23,10 @@
 #include <math_private.h>
 #include <float.h>
 
-__complex__ double
-__cexp (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__cexp) (CFLOAT x)
 {
-  __complex__ double retval;
+  CFLOAT retval;
   int rcls = fpclassify (__real__ x);
   int icls = fpclassify (__imag__ x);
 
@@ -36,22 +36,22 @@ __cexp (__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 (__real__ x > t)
 	    {
-	      double exp_t = __ieee754_exp (t);
+	      FLOAT exp_t = M_EXP (t);
 	      __real__ x -= t;
 	      sinix *= exp_t;
 	      cosix *= exp_t;
@@ -65,12 +65,12 @@ __cexp (__complex__ double x)
 	  if (__real__ x > 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 (__real__ x);
+	      FLOAT exp_val = M_EXP (__real__ x);
 	      __real__ retval = exp_val * cosix;
 	      __imag__ retval = exp_val * sinix;
 	    }
@@ -80,8 +80,8 @@ __cexp (__complex__ double x)
 	{
 	  /* If the imaginary part is +-inf or NaN and the real part
 	     is not +-inf the result is NaN + iNaN.  */
-	  __real__ retval = __nan ("");
-	  __imag__ retval = __nan ("");
+	  __real__ retval = M_NAN;
+	  __imag__ retval = M_NAN;
 
 	  feraiseexcept (FE_INVALID);
 	}
@@ -92,7 +92,7 @@ __cexp (__complex__ double x)
       if (__glibc_likely (icls >= FP_ZERO))
 	{
 	  /* Imaginary part is finite.  */
-	  double value = signbit (__real__ x) ? 0.0 : HUGE_VAL;
+	  FLOAT value = signbit (__real__ x) ? 0 : M_HUGE_VAL;
 
 	  if (icls == FP_ZERO)
 	    {
@@ -102,46 +102,46 @@ __cexp (__complex__ double x)
 	    }
 	  else
 	    {
-	      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 (value, cosix);
-	      __imag__ retval = __copysign (value, sinix);
+	      __real__ retval = M_COPYSIGN (value, cosix);
+	      __imag__ retval = M_COPYSIGN (value, sinix);
 	    }
 	}
       else if (signbit (__real__ x) == 0)
 	{
-	  __real__ retval = HUGE_VAL;
-	  __imag__ retval = __nan ("");
+	  __real__ retval = M_HUGE_VAL;
+	  __imag__ retval = M_NAN;
 
 	  if (icls == FP_INFINITE)
 	    feraiseexcept (FE_INVALID);
 	}
       else
 	{
-	  __real__ retval = 0.0;
-	  __imag__ retval = __copysign (0.0, __imag__ x);
+	  __real__ retval = 0;
+	  __imag__ retval = M_COPYSIGN (0, __imag__ x);
 	}
     }
   else
     {
       /* If the real part is NaN the result is NaN + iNaN unless the
 	 imaginary part is zero.  */
-      __real__ retval = __nan ("");
+      __real__ retval = M_NAN;
       if (icls == FP_ZERO)
 	__imag__ retval = __imag__ x;
       else
 	{
-	  __imag__ retval = __nan ("");
+	  __imag__ retval = M_NAN;
 
 	  if (rcls != FP_NAN || icls != FP_NAN)
 	    feraiseexcept (FE_INVALID);
@@ -150,8 +150,8 @@ __cexp (__complex__ double x)
 
   return retval;
 }
-weak_alias (__cexp, cexp)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cexp, __cexpl)
-weak_alias (__cexp, cexpl)
+declare_mgen_alias (__cexp, cexp)
+
+#if M_LIBM_NEED_COMPAT (cexp)
+declare_mgen_libm_compat (__cexp, cexp)
 #endif
diff --git a/math/s_cexpf.c b/math/s_cexpf.c
deleted file mode 100644
index 001fec2..0000000
--- a/math/s_cexpf.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/* Return value of complex exponential function for float complex 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>
-#include <float.h>
-
-__complex__ float
-__cexpf (__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 (__real__ x > t)
-	    {
-	      float exp_t = __ieee754_expf (t);
-	      __real__ x -= t;
-	      sinix *= exp_t;
-	      cosix *= exp_t;
-	      if (__real__ x > t)
-		{
-		  __real__ x -= t;
-		  sinix *= exp_t;
-		  cosix *= exp_t;
-		}
-	    }
-	  if (__real__ x > t)
-	    {
-	      /* Overflow (original real part of x > 3t).  */
-	      __real__ retval = FLT_MAX * cosix;
-	      __imag__ retval = FLT_MAX * sinix;
-	    }
-	  else
-	    {
-	      float exp_val = __ieee754_expf (__real__ x);
-	      __real__ retval = exp_val * cosix;
-	      __imag__ retval = exp_val * sinix;
-	    }
-	  math_check_force_underflow_complex (retval);
-	}
-      else
-	{
-	  /* If the imaginary part is +-inf or NaN and the real part
-	     is not +-inf the result is NaN + iNaN.  */
-	  __real__ retval = __nanf ("");
-	  __imag__ retval = __nanf ("");
-
-	  feraiseexcept (FE_INVALID);
-	}
-    }
-  else if (__glibc_likely (rcls == FP_INFINITE))
-    {
-      /* Real part is infinite.  */
-      if (__glibc_likely (icls >= FP_ZERO))
-	{
-	  /* Imaginary part is finite.  */
-	  float value = signbit (__real__ x) ? 0.0 : HUGE_VALF;
-
-	  if (icls == FP_ZERO)
-	    {
-	      /* Imaginary part is 0.0.  */
-	      __real__ retval = value;
-	      __imag__ retval = __imag__ x;
-	    }
-	  else
-	    {
-	      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 (value, cosix);
-	      __imag__ retval = __copysignf (value, sinix);
-	    }
-	}
-      else if (signbit (__real__ x) == 0)
-	{
-	  __real__ retval = HUGE_VALF;
-	  __imag__ retval = __nanf ("");
-
-	  if (icls == FP_INFINITE)
-	    feraiseexcept (FE_INVALID);
-	}
-      else
-	{
-	  __real__ retval = 0.0;
-	  __imag__ retval = __copysignf (0.0, __imag__ x);
-	}
-    }
-  else
-    {
-      /* If the real part is NaN the result is NaN + iNaN unless the
-	 imaginary part is zero.  */
-      __real__ retval = __nanf ("");
-      if (icls == FP_ZERO)
-	__imag__ retval = __imag__ x;
-      else
-	{
-	  __imag__ retval = __nanf ("");
-
-	  if (rcls != FP_NAN || icls != FP_NAN)
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-
-  return retval;
-}
-#ifndef __cexpf
-weak_alias (__cexpf, cexpf)
-#endif
diff --git a/math/s_cexpl.c b/math/s_cexpl.c
deleted file mode 100644
index 9ab566c..0000000
--- a/math/s_cexpl.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/* Return value of complex exponential function for long double complex 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>
-#include <float.h>
-
-__complex__ long double
-__cexpl (__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 (__real__ x > t)
-	    {
-	      long double exp_t = __ieee754_expl (t);
-	      __real__ x -= t;
-	      sinix *= exp_t;
-	      cosix *= exp_t;
-	      if (__real__ x > t)
-		{
-		  __real__ x -= t;
-		  sinix *= exp_t;
-		  cosix *= exp_t;
-		}
-	    }
-	  if (__real__ x > 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 (__real__ x);
-	      __real__ retval = exp_val * cosix;
-	      __imag__ retval = exp_val * sinix;
-	    }
-	  math_check_force_underflow_complex (retval);
-	}
-      else
-	{
-	  /* If the imaginary part is +-inf or NaN and the real part
-	     is not +-inf the result is NaN + iNaN.  */
-	  __real__ retval = __nanl ("");
-	  __imag__ retval = __nanl ("");
-
-	  feraiseexcept (FE_INVALID);
-	}
-    }
-  else if (__glibc_likely (rcls == FP_INFINITE))
-    {
-      /* Real part is infinite.  */
-      if (__glibc_likely (icls >= FP_ZERO))
-	{
-	  /* Imaginary part is finite.  */
-	  long double value = signbit (__real__ x) ? 0.0 : HUGE_VALL;
-
-	  if (icls == FP_ZERO)
-	    {
-	      /* Imaginary part is 0.0.  */
-	      __real__ retval = value;
-	      __imag__ retval = __imag__ x;
-	    }
-	  else
-	    {
-	      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 (value, cosix);
-	      __imag__ retval = __copysignl (value, sinix);
-	    }
-	}
-      else if (signbit (__real__ x) == 0)
-	{
-	  __real__ retval = HUGE_VALL;
-	  __imag__ retval = __nanl ("");
-
-	  if (icls == FP_INFINITE)
-	    feraiseexcept (FE_INVALID);
-	}
-      else
-	{
-	  __real__ retval = 0.0;
-	  __imag__ retval = __copysignl (0.0, __imag__ x);
-	}
-    }
-  else
-    {
-      /* If the real part is NaN the result is NaN + iNaN unless the
-	 imaginary part is zero.  */
-      __real__ retval = __nanl ("");
-      if (icls == FP_ZERO)
-	__imag__ retval = __imag__ x;
-      else
-	{
-	  __imag__ retval = __nanl ("");
-
-	  if (rcls != FP_NAN || icls != FP_NAN)
-	    feraiseexcept (FE_INVALID);
-	}
-    }
-
-  return retval;
-}
-weak_alias (__cexpl, cexpl)
diff --git a/math/s_clog.c b/math/s_clog.c
deleted file mode 100644
index b546030..0000000
--- a/math/s_clog.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Compute complex natural logarithm.
-   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>
-#include <float.h>
-
-__complex__ double
-__clog (__complex__ double x)
-{
-  __complex__ double result;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      /* Real and imaginary part are 0.0.  */
-      __imag__ result = signbit (__real__ x) ? M_PI : 0.0;
-      __imag__ result = __copysign (__imag__ result, __imag__ x);
-      /* Yes, the following line raises an exception.  */
-      __real__ result = -1.0 / fabs (__real__ x);
-    }
-  else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN))
-    {
-      /* Neither real nor imaginary part is NaN.  */
-      double absx = fabs (__real__ x), absy = fabs (__imag__ x);
-      int scale = 0;
-
-      if (absx < absy)
-	{
-	  double t = absx;
-	  absx = absy;
-	  absy = t;
-	}
-
-      if (absx > DBL_MAX / 2.0)
-	{
-	  scale = -1;
-	  absx = __scalbn (absx, scale);
-	  absy = (absy >= DBL_MIN * 2.0 ? __scalbn (absy, scale) : 0.0);
-	}
-      else if (absx < DBL_MIN && absy < DBL_MIN)
-	{
-	  scale = DBL_MANT_DIG;
-	  absx = __scalbn (absx, scale);
-	  absy = __scalbn (absy, scale);
-	}
-
-      if (absx == 1.0 && scale == 0)
-	{
-	  __real__ result = __log1p (absy * absy) / 2.0;
-	  math_check_force_underflow_nonneg (__real__ result);
-	}
-      else if (absx > 1.0 && absx < 2.0 && absy < 1.0 && scale == 0)
-	{
-	  double d2m1 = (absx - 1.0) * (absx + 1.0);
-	  if (absy >= DBL_EPSILON)
-	    d2m1 += absy * absy;
-	  __real__ result = __log1p (d2m1) / 2.0;
-	}
-      else if (absx < 1.0
-	       && absx >= 0.5
-	       && absy < DBL_EPSILON / 2.0
-	       && scale == 0)
-	{
-	  double d2m1 = (absx - 1.0) * (absx + 1.0);
-	  __real__ result = __log1p (d2m1) / 2.0;
-	}
-      else if (absx < 1.0
-	       && absx >= 0.5
-	       && scale == 0
-	       && absx * absx + absy * absy >= 0.5)
-	{
-	  double d2m1 = __x2y2m1 (absx, absy);
-	  __real__ result = __log1p (d2m1) / 2.0;
-	}
-      else
-	{
-	  double d = __ieee754_hypot (absx, absy);
-	  __real__ result = __ieee754_log (d) - scale * M_LN2;
-	}
-
-      __imag__ result = __ieee754_atan2 (__imag__ x, __real__ x);
-    }
-  else
-    {
-      __imag__ result = __nan ("");
-      if (rcls == FP_INFINITE || icls == FP_INFINITE)
-	/* Real or imaginary part is infinite.  */
-	__real__ result = HUGE_VAL;
-      else
-	__real__ result = __nan ("");
-    }
-
-  return result;
-}
-weak_alias (__clog, clog)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__clog, __clogl)
-weak_alias (__clog, clogl)
-#endif
diff --git a/math/s_clog10.c b/math/s_clog10.c
deleted file mode 100644
index 8d9245b..0000000
--- a/math/s_clog10.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* Compute complex base 10 logarithm.
-   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>
-#include <float.h>
-
-/* log_10 (2).  */
-#define M_LOG10_2 0.3010299956639811952137388947244930267682
-
-/* pi * log10 (e).  */
-#define M_PI_LOG10E 1.364376353841841347485783625431355770210
-
-__complex__ double
-__clog10 (__complex__ double x)
-{
-  __complex__ double result;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      /* Real and imaginary part are 0.0.  */
-      __imag__ result = signbit (__real__ x) ? M_PI_LOG10E : 0.0;
-      __imag__ result = __copysign (__imag__ result, __imag__ x);
-      /* Yes, the following line raises an exception.  */
-      __real__ result = -1.0 / fabs (__real__ x);
-    }
-  else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN))
-    {
-      /* Neither real nor imaginary part is NaN.  */
-      double absx = fabs (__real__ x), absy = fabs (__imag__ x);
-      int scale = 0;
-
-      if (absx < absy)
-	{
-	  double t = absx;
-	  absx = absy;
-	  absy = t;
-	}
-
-      if (absx > DBL_MAX / 2.0)
-	{
-	  scale = -1;
-	  absx = __scalbn (absx, scale);
-	  absy = (absy >= DBL_MIN * 2.0 ? __scalbn (absy, scale) : 0.0);
-	}
-      else if (absx < DBL_MIN && absy < DBL_MIN)
-	{
-	  scale = DBL_MANT_DIG;
-	  absx = __scalbn (absx, scale);
-	  absy = __scalbn (absy, scale);
-	}
-
-      if (absx == 1.0 && scale == 0)
-	{
-	  __real__ result = __log1p (absy * absy) * (M_LOG10E / 2.0);
-	  math_check_force_underflow_nonneg (__real__ result);
-	}
-      else if (absx > 1.0 && absx < 2.0 && absy < 1.0 && scale == 0)
-	{
-	  double d2m1 = (absx - 1.0) * (absx + 1.0);
-	  if (absy >= DBL_EPSILON)
-	    d2m1 += absy * absy;
-	  __real__ result = __log1p (d2m1) * (M_LOG10E / 2.0);
-	}
-      else if (absx < 1.0
-	       && absx >= 0.5
-	       && absy < DBL_EPSILON / 2.0
-	       && scale == 0)
-	{
-	  double d2m1 = (absx - 1.0) * (absx + 1.0);
-	  __real__ result = __log1p (d2m1) * (M_LOG10E / 2.0);
-	}
-      else if (absx < 1.0
-	       && absx >= 0.5
-	       && scale == 0
-	       && absx * absx + absy * absy >= 0.5)
-	{
-	  double d2m1 = __x2y2m1 (absx, absy);
-	  __real__ result = __log1p (d2m1) * (M_LOG10E / 2.0);
-	}
-      else
-	{
-	  double d = __ieee754_hypot (absx, absy);
-	  __real__ result = __ieee754_log10 (d) - scale * M_LOG10_2;
-	}
-
-      __imag__ result = M_LOG10E * __ieee754_atan2 (__imag__ x, __real__ x);
-    }
-  else
-    {
-      __imag__ result = __nan ("");
-      if (rcls == FP_INFINITE || icls == FP_INFINITE)
-	/* Real or imaginary part is infinite.  */
-	__real__ result = HUGE_VAL;
-      else
-	__real__ result = __nan ("");
-    }
-
-  return result;
-}
-weak_alias (__clog10, clog10)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__clog10, __clog10l)
-weak_alias (__clog10, clog10l)
-#endif
diff --git a/math/s_clog10_template.c b/math/s_clog10_template.c
index 8d9245b..497478a 100644
--- a/math/s_clog10_template.c
+++ b/math/s_clog10_template.c
@@ -23,102 +23,106 @@
 #include <float.h>
 
 /* log_10 (2).  */
-#define M_LOG10_2 0.3010299956639811952137388947244930267682
+#define LOG10_2 M_LIT (0.3010299956639811952137388947244930267682)
 
 /* pi * log10 (e).  */
-#define M_PI_LOG10E 1.364376353841841347485783625431355770210
+#define PI_LOG10E M_LIT (1.364376353841841347485783625431355770210)
 
-__complex__ double
-__clog10 (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__clog10) (CFLOAT x)
 {
-  __complex__ double result;
+  CFLOAT result;
   int rcls = fpclassify (__real__ x);
   int icls = fpclassify (__imag__ x);
 
   if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
     {
       /* Real and imaginary part are 0.0.  */
-      __imag__ result = signbit (__real__ x) ? M_PI_LOG10E : 0.0;
-      __imag__ result = __copysign (__imag__ result, __imag__ x);
+      __imag__ result = signbit (__real__ x) ? PI_LOG10E : 0;
+      __imag__ result = M_COPYSIGN (__imag__ result, __imag__ x);
       /* Yes, the following line raises an exception.  */
-      __real__ result = -1.0 / fabs (__real__ x);
+      __real__ result = -1 / M_FABS (__real__ x);
     }
   else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN))
     {
       /* Neither real nor imaginary part is NaN.  */
-      double absx = fabs (__real__ x), absy = fabs (__imag__ x);
+      FLOAT absx = M_FABS (__real__ x), absy = M_FABS (__imag__ x);
       int scale = 0;
 
       if (absx < absy)
 	{
-	  double t = absx;
+	  FLOAT t = absx;
 	  absx = absy;
 	  absy = t;
 	}
 
-      if (absx > DBL_MAX / 2.0)
+      if (absx > M_MAX / 2)
 	{
 	  scale = -1;
-	  absx = __scalbn (absx, scale);
-	  absy = (absy >= DBL_MIN * 2.0 ? __scalbn (absy, scale) : 0.0);
+	  absx = M_SCALBN (absx, scale);
+	  absy = (absy >= M_MIN * 2 ? M_SCALBN (absy, scale) : 0);
 	}
-      else if (absx < DBL_MIN && absy < DBL_MIN)
+      else if (absx < M_MIN && absy < M_MIN)
 	{
-	  scale = DBL_MANT_DIG;
-	  absx = __scalbn (absx, scale);
-	  absy = __scalbn (absy, scale);
+	  scale = M_MANT_DIG;
+	  absx = M_SCALBN (absx, scale);
+	  absy = M_SCALBN (absy, scale);
 	}
 
-      if (absx == 1.0 && scale == 0)
+      if (absx == 1 && scale == 0)
 	{
-	  __real__ result = __log1p (absy * absy) * (M_LOG10E / 2.0);
+	  __real__ result = (M_LOG1P (absy * absy)
+			     * ((FLOAT) M_MLIT (M_LOG10E) / 2));
 	  math_check_force_underflow_nonneg (__real__ result);
 	}
-      else if (absx > 1.0 && absx < 2.0 && absy < 1.0 && scale == 0)
+      else if (absx > 1 && absx < 2 && absy < 1 && scale == 0)
 	{
-	  double d2m1 = (absx - 1.0) * (absx + 1.0);
-	  if (absy >= DBL_EPSILON)
+	  FLOAT d2m1 = (absx - 1) * (absx + 1);
+	  if (absy >= M_EPSILON)
 	    d2m1 += absy * absy;
-	  __real__ result = __log1p (d2m1) * (M_LOG10E / 2.0);
+	  __real__ result = M_LOG1P (d2m1) * ((FLOAT) M_MLIT (M_LOG10E) / 2);
 	}
-      else if (absx < 1.0
-	       && absx >= 0.5
-	       && absy < DBL_EPSILON / 2.0
+      else if (absx < 1
+	       && absx >= M_LIT (0.5)
+	       && absy < M_EPSILON / 2
 	       && scale == 0)
 	{
-	  double d2m1 = (absx - 1.0) * (absx + 1.0);
-	  __real__ result = __log1p (d2m1) * (M_LOG10E / 2.0);
+	  FLOAT d2m1 = (absx - 1) * (absx + 1);
+	  __real__ result = M_LOG1P (d2m1) * ((FLOAT) M_MLIT (M_LOG10E) / 2);
 	}
-      else if (absx < 1.0
-	       && absx >= 0.5
+      else if (absx < 1
+	       && absx >= M_LIT (0.5)
 	       && scale == 0
-	       && absx * absx + absy * absy >= 0.5)
+	       && absx * absx + absy * absy >= M_LIT (0.5))
 	{
-	  double d2m1 = __x2y2m1 (absx, absy);
-	  __real__ result = __log1p (d2m1) * (M_LOG10E / 2.0);
+	  FLOAT d2m1 = M_SUF (__x2y2m1) (absx, absy);
+	  __real__ result = M_LOG1P (d2m1) * ((FLOAT) M_MLIT (M_LOG10E) / 2);
 	}
       else
 	{
-	  double d = __ieee754_hypot (absx, absy);
-	  __real__ result = __ieee754_log10 (d) - scale * M_LOG10_2;
+	  FLOAT d = M_HYPOT (absx, absy);
+	  __real__ result = M_SUF (__ieee754_log10) (d) - scale * LOG10_2;
 	}
 
-      __imag__ result = M_LOG10E * __ieee754_atan2 (__imag__ x, __real__ x);
+      __imag__ result = M_MLIT (M_LOG10E) * M_ATAN2 (__imag__ x, __real__ x);
     }
   else
     {
-      __imag__ result = __nan ("");
+      __imag__ result = M_NAN;
       if (rcls == FP_INFINITE || icls == FP_INFINITE)
 	/* Real or imaginary part is infinite.  */
-	__real__ result = HUGE_VAL;
+	__real__ result = M_HUGE_VAL;
       else
-	__real__ result = __nan ("");
+	__real__ result = M_NAN;
     }
 
   return result;
 }
-weak_alias (__clog10, clog10)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__clog10, __clog10l)
-weak_alias (__clog10, clog10l)
+
+declare_mgen_alias (__clog10, clog10)
+
+#if M_LIBM_NEED_COMPAT (clog10)
+  /* __clog10 was accidentally exported in past versions.  */
+declare_mgen_libm_compat (__clog10, __clog10)
+declare_mgen_libm_compat (clog10, clog10)
 #endif
diff --git a/math/s_clog10f.c b/math/s_clog10f.c
deleted file mode 100644
index 485625e..0000000
--- a/math/s_clog10f.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/* Compute complex base 10 logarithm.
-   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>
-#include <float.h>
-
-/* log_10 (2).  */
-#define M_LOG10_2f 0.3010299956639811952137388947244930267682f
-
-/* pi * log10 (e).  */
-#define M_PI_LOG10Ef 1.364376353841841347485783625431355770210f
-
-__complex__ float
-__clog10f (__complex__ float x)
-{
-  __complex__ float result;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      /* Real and imaginary part are 0.0.  */
-      __imag__ result = signbit (__real__ x) ? M_PI_LOG10Ef : 0.0;
-      __imag__ result = __copysignf (__imag__ result, __imag__ x);
-      /* Yes, the following line raises an exception.  */
-      __real__ result = -1.0 / fabsf (__real__ x);
-    }
-  else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN))
-    {
-      /* Neither real nor imaginary part is NaN.  */
-      float absx = fabsf (__real__ x), absy = fabsf (__imag__ x);
-      int scale = 0;
-
-      if (absx < absy)
-	{
-	  float t = absx;
-	  absx = absy;
-	  absy = t;
-	}
-
-      if (absx > FLT_MAX / 2.0f)
-	{
-	  scale = -1;
-	  absx = __scalbnf (absx, scale);
-	  absy = (absy >= FLT_MIN * 2.0f ? __scalbnf (absy, scale) : 0.0f);
-	}
-      else if (absx < FLT_MIN && absy < FLT_MIN)
-	{
-	  scale = FLT_MANT_DIG;
-	  absx = __scalbnf (absx, scale);
-	  absy = __scalbnf (absy, scale);
-	}
-
-      if (absx == 1.0f && scale == 0)
-	{
-	  __real__ result = __log1pf (absy * absy) * ((float) M_LOG10E / 2.0f);
-	  math_check_force_underflow_nonneg (__real__ result);
-	}
-      else if (absx > 1.0f && absx < 2.0f && absy < 1.0f && scale == 0)
-	{
-	  float d2m1 = (absx - 1.0f) * (absx + 1.0f);
-	  if (absy >= FLT_EPSILON)
-	    d2m1 += absy * absy;
-	  __real__ result = __log1pf (d2m1) * ((float) M_LOG10E / 2.0f);
-	}
-      else if (absx < 1.0f
-	       && absx >= 0.5f
-	       && absy < FLT_EPSILON / 2.0f
-	       && scale == 0)
-	{
-	  float d2m1 = (absx - 1.0f) * (absx + 1.0f);
-	  __real__ result = __log1pf (d2m1) * ((float) M_LOG10E / 2.0f);
-	}
-      else if (absx < 1.0f
-	       && absx >= 0.5f
-	       && scale == 0
-	       && absx * absx + absy * absy >= 0.5f)
-	{
-	  float d2m1 = __x2y2m1f (absx, absy);
-	  __real__ result = __log1pf (d2m1) * ((float) M_LOG10E / 2.0f);
-	}
-      else
-	{
-	  float d = __ieee754_hypotf (absx, absy);
-	  __real__ result = __ieee754_log10f (d) - scale * M_LOG10_2f;
-	}
-
-      __imag__ result = M_LOG10E * __ieee754_atan2f (__imag__ x, __real__ x);
-    }
-  else
-    {
-      __imag__ result = __nanf ("");
-      if (rcls == FP_INFINITE || icls == FP_INFINITE)
-	/* Real or imaginary part is infinite.  */
-	__real__ result = HUGE_VALF;
-      else
-	__real__ result = __nanf ("");
-    }
-
-  return result;
-}
-#ifndef __clog10f
-weak_alias (__clog10f, clog10f)
-#endif
diff --git a/math/s_clog10l.c b/math/s_clog10l.c
deleted file mode 100644
index da40477..0000000
--- a/math/s_clog10l.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* Compute complex base 10 logarithm.
-   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>
-#include <float.h>
-
-/* To avoid spurious underflows, use this definition to treat IBM long
-   double as approximating an IEEE-style format.  */
-#if LDBL_MANT_DIG == 106
-# undef LDBL_EPSILON
-# define LDBL_EPSILON 0x1p-106L
-#endif
-
-/* log_10 (2).  */
-#define M_LOG10_2l 0.3010299956639811952137388947244930267682L
-
-/* pi * log10 (e).  */
-#define M_PI_LOG10El 1.364376353841841347485783625431355770210L
-
-__complex__ long double
-__clog10l (__complex__ long double x)
-{
-  __complex__ long double result;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      /* Real and imaginary part are 0.0.  */
-      __imag__ result = signbit (__real__ x) ? M_PI_LOG10El : 0.0;
-      __imag__ result = __copysignl (__imag__ result, __imag__ x);
-      /* Yes, the following line raises an exception.  */
-      __real__ result = -1.0 / fabsl (__real__ x);
-    }
-  else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN))
-    {
-      /* Neither real nor imaginary part is NaN.  */
-      long double absx = fabsl (__real__ x), absy = fabsl (__imag__ x);
-      int scale = 0;
-
-      if (absx < absy)
-	{
-	  long double t = absx;
-	  absx = absy;
-	  absy = t;
-	}
-
-      if (absx > LDBL_MAX / 2.0L)
-	{
-	  scale = -1;
-	  absx = __scalbnl (absx, scale);
-	  absy = (absy >= LDBL_MIN * 2.0L ? __scalbnl (absy, scale) : 0.0L);
-	}
-      else if (absx < LDBL_MIN && absy < LDBL_MIN)
-	{
-	  scale = LDBL_MANT_DIG;
-	  absx = __scalbnl (absx, scale);
-	  absy = __scalbnl (absy, scale);
-	}
-
-      if (absx == 1.0L && scale == 0)
-	{
-	  __real__ result = __log1pl (absy * absy) * (M_LOG10El / 2.0L);
-	  math_check_force_underflow_nonneg (__real__ result);
-	}
-      else if (absx > 1.0L && absx < 2.0L && absy < 1.0L && scale == 0)
-	{
-	  long double d2m1 = (absx - 1.0L) * (absx + 1.0L);
-	  if (absy >= LDBL_EPSILON)
-	    d2m1 += absy * absy;
-	  __real__ result = __log1pl (d2m1) * (M_LOG10El / 2.0L);
-	}
-      else if (absx < 1.0L
-	       && absx >= 0.5L
-	       && absy < LDBL_EPSILON / 2.0L
-	       && scale == 0)
-	{
-	  long double d2m1 = (absx - 1.0L) * (absx + 1.0L);
-	  __real__ result = __log1pl (d2m1) * (M_LOG10El / 2.0L);
-	}
-      else if (absx < 1.0L
-	       && absx >= 0.5L
-	       && scale == 0
-	       && absx * absx + absy * absy >= 0.5L)
-	{
-	  long double d2m1 = __x2y2m1l (absx, absy);
-	  __real__ result = __log1pl (d2m1) * (M_LOG10El / 2.0L);
-	}
-      else
-	{
-	  long double d = __ieee754_hypotl (absx, absy);
-	  __real__ result = __ieee754_log10l (d) - scale * M_LOG10_2l;
-	}
-
-      __imag__ result = M_LOG10El * __ieee754_atan2l (__imag__ x, __real__ x);
-    }
-  else
-    {
-      __imag__ result = __nanl ("");
-      if (rcls == FP_INFINITE || icls == FP_INFINITE)
-	/* Real or imaginary part is infinite.  */
-	__real__ result = HUGE_VALL;
-      else
-	__real__ result = __nanl ("");
-    }
-
-  return result;
-}
-weak_alias (__clog10l, clog10l)
diff --git a/math/s_clog_template.c b/math/s_clog_template.c
index b546030..047ac03 100644
--- a/math/s_clog_template.c
+++ b/math/s_clog_template.c
@@ -22,97 +22,98 @@
 #include <math_private.h>
 #include <float.h>
 
-__complex__ double
-__clog (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__clog) (CFLOAT x)
 {
-  __complex__ double result;
+  CFLOAT result;
   int rcls = fpclassify (__real__ x);
   int icls = fpclassify (__imag__ x);
 
   if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
     {
       /* Real and imaginary part are 0.0.  */
-      __imag__ result = signbit (__real__ x) ? M_PI : 0.0;
-      __imag__ result = __copysign (__imag__ result, __imag__ x);
+      __imag__ result = signbit (__real__ x) ? (FLOAT) M_MLIT (M_PI) : 0;
+      __imag__ result = M_COPYSIGN (__imag__ result, __imag__ x);
       /* Yes, the following line raises an exception.  */
-      __real__ result = -1.0 / fabs (__real__ x);
+      __real__ result = -1 / M_FABS (__real__ x);
     }
   else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN))
     {
       /* Neither real nor imaginary part is NaN.  */
-      double absx = fabs (__real__ x), absy = fabs (__imag__ x);
+      FLOAT absx = M_FABS (__real__ x), absy = M_FABS (__imag__ x);
       int scale = 0;
 
       if (absx < absy)
 	{
-	  double t = absx;
+	  FLOAT t = absx;
 	  absx = absy;
 	  absy = t;
 	}
 
-      if (absx > DBL_MAX / 2.0)
+      if (absx > M_MAX / 2)
 	{
 	  scale = -1;
-	  absx = __scalbn (absx, scale);
-	  absy = (absy >= DBL_MIN * 2.0 ? __scalbn (absy, scale) : 0.0);
+	  absx = M_SCALBN (absx, scale);
+	  absy = (absy >= M_MIN * 2 ? M_SCALBN (absy, scale) : 0);
 	}
-      else if (absx < DBL_MIN && absy < DBL_MIN)
+      else if (absx < M_MIN && absy < M_MIN)
 	{
-	  scale = DBL_MANT_DIG;
-	  absx = __scalbn (absx, scale);
-	  absy = __scalbn (absy, scale);
+	  scale = M_MANT_DIG;
+	  absx = M_SCALBN (absx, scale);
+	  absy = M_SCALBN (absy, scale);
 	}
 
-      if (absx == 1.0 && scale == 0)
+      if (absx == 1 && scale == 0)
 	{
-	  __real__ result = __log1p (absy * absy) / 2.0;
+	  __real__ result = M_LOG1P (absy * absy) / 2;
 	  math_check_force_underflow_nonneg (__real__ result);
 	}
-      else if (absx > 1.0 && absx < 2.0 && absy < 1.0 && scale == 0)
+      else if (absx > 1 && absx < 2 && absy < 1 && scale == 0)
 	{
-	  double d2m1 = (absx - 1.0) * (absx + 1.0);
-	  if (absy >= DBL_EPSILON)
+	  FLOAT d2m1 = (absx - 1) * (absx + 1);
+	  if (absy >= M_EPSILON)
 	    d2m1 += absy * absy;
-	  __real__ result = __log1p (d2m1) / 2.0;
+	  __real__ result = M_LOG1P (d2m1) / 2;
 	}
-      else if (absx < 1.0
-	       && absx >= 0.5
-	       && absy < DBL_EPSILON / 2.0
+      else if (absx < 1
+	       && absx >= M_LIT (0.5)
+	       && absy < M_EPSILON / 2
 	       && scale == 0)
 	{
-	  double d2m1 = (absx - 1.0) * (absx + 1.0);
-	  __real__ result = __log1p (d2m1) / 2.0;
+	  FLOAT d2m1 = (absx - 1) * (absx + 1);
+	  __real__ result = M_LOG1P (d2m1) / 2;
 	}
-      else if (absx < 1.0
-	       && absx >= 0.5
+      else if (absx < 1
+	       && absx >= M_LIT (0.5)
 	       && scale == 0
-	       && absx * absx + absy * absy >= 0.5)
+	       && absx * absx + absy * absy >= M_LIT (0.5))
 	{
-	  double d2m1 = __x2y2m1 (absx, absy);
-	  __real__ result = __log1p (d2m1) / 2.0;
+	  FLOAT d2m1 = M_SUF (__x2y2m1) (absx, absy);
+	  __real__ result = M_LOG1P (d2m1) / 2;
 	}
       else
 	{
-	  double d = __ieee754_hypot (absx, absy);
-	  __real__ result = __ieee754_log (d) - scale * M_LN2;
+	  FLOAT d = M_HYPOT (absx, absy);
+	  __real__ result = M_LOG (d) - scale * (FLOAT) M_MLIT (M_LN2);
 	}
 
-      __imag__ result = __ieee754_atan2 (__imag__ x, __real__ x);
+      __imag__ result = M_ATAN2 (__imag__ x, __real__ x);
     }
   else
     {
-      __imag__ result = __nan ("");
+      __imag__ result = M_NAN;
       if (rcls == FP_INFINITE || icls == FP_INFINITE)
 	/* Real or imaginary part is infinite.  */
-	__real__ result = HUGE_VAL;
+	__real__ result = M_HUGE_VAL;
       else
-	__real__ result = __nan ("");
+	__real__ result = M_NAN;
     }
 
   return result;
 }
-weak_alias (__clog, clog)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__clog, __clogl)
-weak_alias (__clog, clogl)
+
+declare_mgen_alias (__clog, clog)
+
+#if M_LIBM_NEED_COMPAT (clog)
+declare_mgen_libm_compat (__clog, clog)
 #endif
diff --git a/math/s_clogf.c b/math/s_clogf.c
deleted file mode 100644
index cc56539..0000000
--- a/math/s_clogf.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/* Compute complex natural logarithm.
-   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>
-#include <float.h>
-
-__complex__ float
-__clogf (__complex__ float x)
-{
-  __complex__ float result;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      /* Real and imaginary part are 0.0.  */
-      __imag__ result = signbit (__real__ x) ? M_PI : 0.0;
-      __imag__ result = __copysignf (__imag__ result, __imag__ x);
-      /* Yes, the following line raises an exception.  */
-      __real__ result = -1.0 / fabsf (__real__ x);
-    }
-  else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN))
-    {
-      /* Neither real nor imaginary part is NaN.  */
-      float absx = fabsf (__real__ x), absy = fabsf (__imag__ x);
-      int scale = 0;
-
-      if (absx < absy)
-	{
-	  float t = absx;
-	  absx = absy;
-	  absy = t;
-	}
-
-      if (absx > FLT_MAX / 2.0f)
-	{
-	  scale = -1;
-	  absx = __scalbnf (absx, scale);
-	  absy = (absy >= FLT_MIN * 2.0f ? __scalbnf (absy, scale) : 0.0f);
-	}
-      else if (absx < FLT_MIN && absy < FLT_MIN)
-	{
-	  scale = FLT_MANT_DIG;
-	  absx = __scalbnf (absx, scale);
-	  absy = __scalbnf (absy, scale);
-	}
-
-      if (absx == 1.0f && scale == 0)
-	{
-	  __real__ result = __log1pf (absy * absy) / 2.0f;
-	  math_check_force_underflow_nonneg (__real__ result);
-	}
-      else if (absx > 1.0f && absx < 2.0f && absy < 1.0f && scale == 0)
-	{
-	  float d2m1 = (absx - 1.0f) * (absx + 1.0f);
-	  if (absy >= FLT_EPSILON)
-	    d2m1 += absy * absy;
-	  __real__ result = __log1pf (d2m1) / 2.0f;
-	}
-      else if (absx < 1.0f
-	       && absx >= 0.5f
-	       && absy < FLT_EPSILON / 2.0f
-	       && scale == 0)
-	{
-	  float d2m1 = (absx - 1.0f) * (absx + 1.0f);
-	  __real__ result = __log1pf (d2m1) / 2.0f;
-	}
-      else if (absx < 1.0f
-	       && absx >= 0.5f
-	       && scale == 0
-	       && absx * absx + absy * absy >= 0.5f)
-	{
-	  float d2m1 = __x2y2m1f (absx, absy);
-	  __real__ result = __log1pf (d2m1) / 2.0f;
-	}
-      else
-	{
-	  float d = __ieee754_hypotf (absx, absy);
-	  __real__ result = __ieee754_logf (d) - scale * (float) M_LN2;
-	}
-
-      __imag__ result = __ieee754_atan2f (__imag__ x, __real__ x);
-    }
-  else
-    {
-      __imag__ result = __nanf ("");
-      if (rcls == FP_INFINITE || icls == FP_INFINITE)
-	/* Real or imaginary part is infinite.  */
-	__real__ result = HUGE_VALF;
-      else
-	__real__ result = __nanf ("");
-    }
-
-  return result;
-}
-#ifndef __clogf
-weak_alias (__clogf, clogf)
-#endif
diff --git a/math/s_clogl.c b/math/s_clogl.c
deleted file mode 100644
index 6db59b7..0000000
--- a/math/s_clogl.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/* Compute complex natural logarithm.
-   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>
-#include <float.h>
-
-/* To avoid spurious underflows, use this definition to treat IBM long
-   double as approximating an IEEE-style format.  */
-#if LDBL_MANT_DIG == 106
-# undef LDBL_EPSILON
-# define LDBL_EPSILON 0x1p-106L
-#endif
-
-__complex__ long double
-__clogl (__complex__ long double x)
-{
-  __complex__ long double result;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
-    {
-      /* Real and imaginary part are 0.0.  */
-      __imag__ result = signbit (__real__ x) ? M_PIl : 0.0;
-      __imag__ result = __copysignl (__imag__ result, __imag__ x);
-      /* Yes, the following line raises an exception.  */
-      __real__ result = -1.0 / fabsl (__real__ x);
-    }
-  else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN))
-    {
-      /* Neither real nor imaginary part is NaN.  */
-      long double absx = fabsl (__real__ x), absy = fabsl (__imag__ x);
-      int scale = 0;
-
-      if (absx < absy)
-	{
-	  long double t = absx;
-	  absx = absy;
-	  absy = t;
-	}
-
-      if (absx > LDBL_MAX / 2.0L)
-	{
-	  scale = -1;
-	  absx = __scalbnl (absx, scale);
-	  absy = (absy >= LDBL_MIN * 2.0L ? __scalbnl (absy, scale) : 0.0L);
-	}
-      else if (absx < LDBL_MIN && absy < LDBL_MIN)
-	{
-	  scale = LDBL_MANT_DIG;
-	  absx = __scalbnl (absx, scale);
-	  absy = __scalbnl (absy, scale);
-	}
-
-      if (absx == 1.0L && scale == 0)
-	{
-	  __real__ result = __log1pl (absy * absy) / 2.0L;
-	  math_check_force_underflow_nonneg (__real__ result);
-	}
-      else if (absx > 1.0L && absx < 2.0L && absy < 1.0L && scale == 0)
-	{
-	  long double d2m1 = (absx - 1.0L) * (absx + 1.0L);
-	  if (absy >= LDBL_EPSILON)
-	    d2m1 += absy * absy;
-	  __real__ result = __log1pl (d2m1) / 2.0L;
-	}
-      else if (absx < 1.0L
-	       && absx >= 0.5L
-	       && absy < LDBL_EPSILON / 2.0L
-	       && scale == 0)
-	{
-	  long double d2m1 = (absx - 1.0L) * (absx + 1.0L);
-	  __real__ result = __log1pl (d2m1) / 2.0L;
-	}
-      else if (absx < 1.0L
-	       && absx >= 0.5L
-	       && scale == 0
-	       && absx * absx + absy * absy >= 0.5L)
-	{
-	  long double d2m1 = __x2y2m1l (absx, absy);
-	  __real__ result = __log1pl (d2m1) / 2.0L;
-	}
-      else
-	{
-	  long double d = __ieee754_hypotl (absx, absy);
-	  __real__ result = __ieee754_logl (d) - scale * M_LN2l;
-	}
-
-      __imag__ result = __ieee754_atan2l (__imag__ x, __real__ x);
-    }
-  else
-    {
-      __imag__ result = __nanl ("");
-      if (rcls == FP_INFINITE || icls == FP_INFINITE)
-	/* Real or imaginary part is infinite.  */
-	__real__ result = HUGE_VALL;
-      else
-	__real__ result = __nanl ("");
-    }
-
-  return result;
-}
-weak_alias (__clogl, clogl)
diff --git a/math/s_cpow.c b/math/s_cpow.c
deleted file mode 100644
index 037e575..0000000
--- a/math/s_cpow.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Complex power of double values.
-   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
-__cpow (__complex__ double x, __complex__ double c)
-{
-  return __cexp (c * __clog (x));
-}
-weak_alias (__cpow, cpow)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cpow, __cpowl)
-weak_alias (__cpow, cpowl)
-#endif
diff --git a/math/s_cpow_template.c b/math/s_cpow_template.c
index 037e575..12dfc92 100644
--- a/math/s_cpow_template.c
+++ b/math/s_cpow_template.c
@@ -1,4 +1,4 @@
-/* Complex power of double values.
+/* Complex power of 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.
@@ -20,14 +20,14 @@
 #include <complex.h>
 #include <math.h>
 
-
-__complex__ double
-__cpow (__complex__ double x, __complex__ double c)
+CFLOAT
+M_DECL_FUNC (__cpow) (CFLOAT x, CFLOAT c)
 {
-  return __cexp (c * __clog (x));
+  return M_SUF (__cexp) (c * M_SUF (__clog) (x));
 }
-weak_alias (__cpow, cpow)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cpow, __cpowl)
-weak_alias (__cpow, cpowl)
+
+declare_mgen_alias (__cpow, cpow)
+
+#if M_LIBM_NEED_COMPAT (cpow)
+declare_mgen_libm_compat (__cpow, cpow)
 #endif
diff --git a/math/s_cpowf.c b/math/s_cpowf.c
deleted file mode 100644
index 2b0b5b2..0000000
--- a/math/s_cpowf.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Complex power of float values.
-   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
-__cpowf (__complex__ float x, __complex__ float c)
-{
-  return __cexpf (c * __clogf (x));
-}
-#ifndef __cpowf
-weak_alias (__cpowf, cpowf)
-#endif
diff --git a/math/s_cpowl.c b/math/s_cpowl.c
deleted file mode 100644
index 963e03a..0000000
--- a/math/s_cpowl.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Complex power of long double values.
-   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
-__cpowl (__complex__ long double x, __complex__ long double c)
-{
-  return __cexpl (c * __clogl (x));
-}
-weak_alias (__cpowl, cpowl)
diff --git a/math/s_cproj.c b/math/s_cproj.c
deleted file mode 100644
index d47f009..0000000
--- a/math/s_cproj.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Compute projection of complex double value to Riemann sphere.
-   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
-__cproj (__complex__ double x)
-{
-  if (isinf (__real__ x) || isinf (__imag__ x))
-    {
-      __complex__ double res;
-
-      __real__ res = INFINITY;
-      __imag__ res = __copysign (0.0, __imag__ x);
-
-      return res;
-    }
-
-  return x;
-}
-weak_alias (__cproj, cproj)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cproj, __cprojl)
-weak_alias (__cproj, cprojl)
-#endif
diff --git a/math/s_cproj_template.c b/math/s_cproj_template.c
index d47f009..e274e4c 100644
--- a/math/s_cproj_template.c
+++ b/math/s_cproj_template.c
@@ -1,4 +1,4 @@
-/* Compute projection of complex double value to Riemann sphere.
+/* Compute projection of complex float type value to Riemann sphere.
    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,23 +22,24 @@
 #include <math_private.h>
 
 
-__complex__ double
-__cproj (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__cproj) (CFLOAT x)
 {
   if (isinf (__real__ x) || isinf (__imag__ x))
     {
-      __complex__ double res;
+      CFLOAT res;
 
       __real__ res = INFINITY;
-      __imag__ res = __copysign (0.0, __imag__ x);
+      __imag__ res = M_COPYSIGN (0, __imag__ x);
 
       return res;
     }
 
   return x;
 }
-weak_alias (__cproj, cproj)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cproj, __cprojl)
-weak_alias (__cproj, cprojl)
+
+declare_mgen_alias (__cproj, cproj)
+
+#if M_LIBM_NEED_COMPAT (cproj)
+declare_mgen_libm_compat (__cproj, cproj)
 #endif
diff --git a/math/s_cprojf.c b/math/s_cprojf.c
deleted file mode 100644
index 8a0d873..0000000
--- a/math/s_cprojf.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Compute projection of complex float value to Riemann sphere.
-   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
-__cprojf (__complex__ float x)
-{
-  if (isinf (__real__ x) || isinf (__imag__ x))
-    {
-      __complex__ float res;
-
-      __real__ res = INFINITY;
-      __imag__ res = __copysignf (0.0, __imag__ x);
-
-      return res;
-    }
-
-  return x;
-}
-#ifndef __cprojf
-weak_alias (__cprojf, cprojf)
-#endif
diff --git a/math/s_cprojl.c b/math/s_cprojl.c
deleted file mode 100644
index 213b733..0000000
--- a/math/s_cprojl.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Compute projection of complex long double value to Riemann sphere.
-   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
-__cprojl (__complex__ long double x)
-{
-  if (isinf (__real__ x) || isinf (__imag__ x))
-    {
-      __complex__ long double res;
-
-      __real__ res = INFINITY;
-      __imag__ res = __copysignl (0.0, __imag__ x);
-
-      return res;
-    }
-
-  return x;
-}
-weak_alias (__cprojl, cprojl)
diff --git a/math/s_csqrt.c b/math/s_csqrt.c
deleted file mode 100644
index 1f073e7..0000000
--- a/math/s_csqrt.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/* Complex square root of double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Based on an algorithm by Stephen L. Moshier <moshier@world.std.com>.
-   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>
-#include <float.h>
-
-__complex__ double
-__csqrt (__complex__ double x)
-{
-  __complex__ double res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE))
-    {
-      if (icls == FP_INFINITE)
-	{
-	  __real__ res = HUGE_VAL;
-	  __imag__ res = __imag__ x;
-	}
-      else if (rcls == FP_INFINITE)
-	{
-	  if (__real__ x < 0.0)
-	    {
-	      __real__ res = icls == FP_NAN ? __nan ("") : 0;
-	      __imag__ res = __copysign (HUGE_VAL, __imag__ x);
-	    }
-	  else
-	    {
-	      __real__ res = __real__ x;
-	      __imag__ res = (icls == FP_NAN
-			      ? __nan ("") : __copysign (0.0, __imag__ x));
-	    }
-	}
-      else
-	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
-	}
-    }
-  else
-    {
-      if (__glibc_unlikely (icls == FP_ZERO))
-	{
-	  if (__real__ x < 0.0)
-	    {
-	      __real__ res = 0.0;
-	      __imag__ res = __copysign (__ieee754_sqrt (-__real__ x),
-					 __imag__ x);
-	    }
-	  else
-	    {
-	      __real__ res = fabs (__ieee754_sqrt (__real__ x));
-	      __imag__ res = __copysign (0.0, __imag__ x);
-	    }
-	}
-      else if (__glibc_unlikely (rcls == FP_ZERO))
-	{
-	  double r;
-	  if (fabs (__imag__ x) >= 2.0 * DBL_MIN)
-	    r = __ieee754_sqrt (0.5 * fabs (__imag__ x));
-	  else
-	    r = 0.5 * __ieee754_sqrt (2.0 * fabs (__imag__ x));
-
-	  __real__ res = r;
-	  __imag__ res = __copysign (r, __imag__ x);
-	}
-      else
-	{
-	  double d, r, s;
-	  int scale = 0;
-
-	  if (fabs (__real__ x) > DBL_MAX / 4.0)
-	    {
-	      scale = 1;
-	      __real__ x = __scalbn (__real__ x, -2 * scale);
-	      __imag__ x = __scalbn (__imag__ x, -2 * scale);
-	    }
-	  else if (fabs (__imag__ x) > DBL_MAX / 4.0)
-	    {
-	      scale = 1;
-	      if (fabs (__real__ x) >= 4.0 * DBL_MIN)
-		__real__ x = __scalbn (__real__ x, -2 * scale);
-	      else
-		__real__ x = 0.0;
-	      __imag__ x = __scalbn (__imag__ x, -2 * scale);
-	    }
-	  else if (fabs (__real__ x) < 2.0 * DBL_MIN
-		   && fabs (__imag__ x) < 2.0 * DBL_MIN)
-	    {
-	      scale = -((DBL_MANT_DIG + 1) / 2);
-	      __real__ x = __scalbn (__real__ x, -2 * scale);
-	      __imag__ x = __scalbn (__imag__ x, -2 * scale);
-	    }
-
-	  d = __ieee754_hypot (__real__ x, __imag__ x);
-	  /* Use the identity   2  Re res  Im res = Im x
-	     to avoid cancellation error in  d +/- Re x.  */
-	  if (__real__ x > 0)
-	    {
-	      r = __ieee754_sqrt (0.5 * (d + __real__ x));
-	      if (scale == 1 && fabs (__imag__ x) < 1.0)
-		{
-		  /* Avoid possible intermediate underflow.  */
-		  s = __imag__ x / r;
-		  r = __scalbn (r, scale);
-		  scale = 0;
-		}
-	      else
-		s = 0.5 * (__imag__ x / r);
-	    }
-	  else
-	    {
-	      s = __ieee754_sqrt (0.5 * (d - __real__ x));
-	      if (scale == 1 && fabs (__imag__ x) < 1.0)
-		{
-		  /* Avoid possible intermediate underflow.  */
-		  r = fabs (__imag__ x / s);
-		  s = __scalbn (s, scale);
-		  scale = 0;
-		}
-	      else
-		r = fabs (0.5 * (__imag__ x / s));
-	    }
-
-	  if (scale)
-	    {
-	      r = __scalbn (r, scale);
-	      s = __scalbn (s, scale);
-	    }
-
-	  math_check_force_underflow (r);
-	  math_check_force_underflow (s);
-
-	  __real__ res = r;
-	  __imag__ res = __copysign (s, __imag__ x);
-	}
-    }
-
-  return res;
-}
-weak_alias (__csqrt, csqrt)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__csqrt, __csqrtl)
-weak_alias (__csqrt, csqrtl)
-#endif
diff --git a/math/s_csqrt_template.c b/math/s_csqrt_template.c
index 1f073e7..22af083 100644
--- a/math/s_csqrt_template.c
+++ b/math/s_csqrt_template.c
@@ -1,4 +1,4 @@
-/* Complex square root of double value.
+/* Complex square root of a float type.
    Copyright (C) 1997-2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Based on an algorithm by Stephen L. Moshier <moshier@world.std.com>.
@@ -23,10 +23,10 @@
 #include <math_private.h>
 #include <float.h>
 
-__complex__ double
-__csqrt (__complex__ double x)
+CFLOAT
+M_DECL_FUNC (__csqrt) (CFLOAT x)
 {
-  __complex__ double res;
+  CFLOAT res;
   int rcls = fpclassify (__real__ x);
   int icls = fpclassify (__imag__ x);
 
@@ -34,132 +34,131 @@ __csqrt (__complex__ double x)
     {
       if (icls == FP_INFINITE)
 	{
-	  __real__ res = HUGE_VAL;
+	  __real__ res = M_HUGE_VAL;
 	  __imag__ res = __imag__ x;
 	}
       else if (rcls == FP_INFINITE)
 	{
-	  if (__real__ x < 0.0)
+	  if (__real__ x < 0)
 	    {
-	      __real__ res = icls == FP_NAN ? __nan ("") : 0;
-	      __imag__ res = __copysign (HUGE_VAL, __imag__ x);
+	      __real__ res = icls == FP_NAN ? M_NAN : 0;
+	      __imag__ res = M_COPYSIGN (M_HUGE_VAL, __imag__ x);
 	    }
 	  else
 	    {
 	      __real__ res = __real__ x;
 	      __imag__ res = (icls == FP_NAN
-			      ? __nan ("") : __copysign (0.0, __imag__ x));
+			      ? M_NAN : M_COPYSIGN (0, __imag__ x));
 	    }
 	}
       else
 	{
-	  __real__ res = __nan ("");
-	  __imag__ res = __nan ("");
+	  __real__ res = M_NAN;
+	  __imag__ res = M_NAN;
 	}
     }
   else
     {
       if (__glibc_unlikely (icls == FP_ZERO))
 	{
-	  if (__real__ x < 0.0)
+	  if (__real__ x < 0)
 	    {
-	      __real__ res = 0.0;
-	      __imag__ res = __copysign (__ieee754_sqrt (-__real__ x),
-					 __imag__ x);
+	      __real__ res = 0;
+	      __imag__ res = M_COPYSIGN (M_SQRT (-__real__ x), __imag__ x);
 	    }
 	  else
 	    {
-	      __real__ res = fabs (__ieee754_sqrt (__real__ x));
-	      __imag__ res = __copysign (0.0, __imag__ x);
+	      __real__ res = M_FABS (M_SQRT (__real__ x));
+	      __imag__ res = M_COPYSIGN (0, __imag__ x);
 	    }
 	}
       else if (__glibc_unlikely (rcls == FP_ZERO))
 	{
-	  double r;
-	  if (fabs (__imag__ x) >= 2.0 * DBL_MIN)
-	    r = __ieee754_sqrt (0.5 * fabs (__imag__ x));
+	  FLOAT r;
+	  if (M_FABS (__imag__ x) >= 2 * M_MIN)
+	    r = M_SQRT (M_LIT (0.5) * M_FABS (__imag__ x));
 	  else
-	    r = 0.5 * __ieee754_sqrt (2.0 * fabs (__imag__ x));
+	    r = M_LIT (0.5) * M_SQRT (2 * M_FABS (__imag__ x));
 
 	  __real__ res = r;
-	  __imag__ res = __copysign (r, __imag__ x);
+	  __imag__ res = M_COPYSIGN (r, __imag__ x);
 	}
       else
 	{
-	  double d, r, s;
+	  FLOAT d, r, s;
 	  int scale = 0;
 
-	  if (fabs (__real__ x) > DBL_MAX / 4.0)
+	  if (M_FABS (__real__ x) > M_MAX / 4)
 	    {
 	      scale = 1;
-	      __real__ x = __scalbn (__real__ x, -2 * scale);
-	      __imag__ x = __scalbn (__imag__ x, -2 * scale);
+	      __real__ x = M_SCALBN (__real__ x, -2 * scale);
+	      __imag__ x = M_SCALBN (__imag__ x, -2 * scale);
 	    }
-	  else if (fabs (__imag__ x) > DBL_MAX / 4.0)
+	  else if (M_FABS (__imag__ x) > M_MAX / 4)
 	    {
 	      scale = 1;
-	      if (fabs (__real__ x) >= 4.0 * DBL_MIN)
-		__real__ x = __scalbn (__real__ x, -2 * scale);
+	      if (M_FABS (__real__ x) >= 4 * M_MIN)
+		__real__ x = M_SCALBN (__real__ x, -2 * scale);
 	      else
-		__real__ x = 0.0;
-	      __imag__ x = __scalbn (__imag__ x, -2 * scale);
+		__real__ x = 0;
+	      __imag__ x = M_SCALBN (__imag__ x, -2 * scale);
 	    }
-	  else if (fabs (__real__ x) < 2.0 * DBL_MIN
-		   && fabs (__imag__ x) < 2.0 * DBL_MIN)
+	  else if (M_FABS (__real__ x) < 2 * M_MIN
+		   && M_FABS (__imag__ x) < 2 * M_MIN)
 	    {
-	      scale = -((DBL_MANT_DIG + 1) / 2);
-	      __real__ x = __scalbn (__real__ x, -2 * scale);
-	      __imag__ x = __scalbn (__imag__ x, -2 * scale);
+	      scale = -((M_MANT_DIG + 1) / 2);
+	      __real__ x = M_SCALBN (__real__ x, -2 * scale);
+	      __imag__ x = M_SCALBN (__imag__ x, -2 * scale);
 	    }
 
-	  d = __ieee754_hypot (__real__ x, __imag__ x);
+	  d = M_HYPOT (__real__ x, __imag__ x);
 	  /* Use the identity   2  Re res  Im res = Im x
 	     to avoid cancellation error in  d +/- Re x.  */
 	  if (__real__ x > 0)
 	    {
-	      r = __ieee754_sqrt (0.5 * (d + __real__ x));
-	      if (scale == 1 && fabs (__imag__ x) < 1.0)
+	      r = M_SQRT (M_LIT (0.5) * (d + __real__ x));
+	      if (scale == 1 && M_FABS (__imag__ x) < 1)
 		{
 		  /* Avoid possible intermediate underflow.  */
 		  s = __imag__ x / r;
-		  r = __scalbn (r, scale);
+		  r = M_SCALBN (r, scale);
 		  scale = 0;
 		}
 	      else
-		s = 0.5 * (__imag__ x / r);
+		s = M_LIT (0.5) * (__imag__ x / r);
 	    }
 	  else
 	    {
-	      s = __ieee754_sqrt (0.5 * (d - __real__ x));
-	      if (scale == 1 && fabs (__imag__ x) < 1.0)
+	      s = M_SQRT (M_LIT (0.5) * (d - __real__ x));
+	      if (scale == 1 && M_FABS (__imag__ x) < 1)
 		{
 		  /* Avoid possible intermediate underflow.  */
-		  r = fabs (__imag__ x / s);
-		  s = __scalbn (s, scale);
+		  r = M_FABS (__imag__ x / s);
+		  s = M_SCALBN (s, scale);
 		  scale = 0;
 		}
 	      else
-		r = fabs (0.5 * (__imag__ x / s));
+		r = M_FABS (M_LIT (0.5) * (__imag__ x / s));
 	    }
 
 	  if (scale)
 	    {
-	      r = __scalbn (r, scale);
-	      s = __scalbn (s, scale);
+	      r = M_SCALBN (r, scale);
+	      s = M_SCALBN (s, scale);
 	    }
 
 	  math_check_force_underflow (r);
 	  math_check_force_underflow (s);
 
 	  __real__ res = r;
-	  __imag__ res = __copysign (s, __imag__ x);
+	  __imag__ res = M_COPYSIGN (s, __imag__ x);
 	}
     }
 
   return res;
 }
-weak_alias (__csqrt, csqrt)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__csqrt, __csqrtl)
-weak_alias (__csqrt, csqrtl)
+declare_mgen_alias (__csqrt, csqrt)
+
+#if M_LIBM_NEED_COMPAT (csqrt)
+declare_mgen_libm_compat (__csqrt, csqrt)
 #endif
diff --git a/math/s_csqrtf.c b/math/s_csqrtf.c
deleted file mode 100644
index b30af06..0000000
--- a/math/s_csqrtf.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/* Complex square root of float value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Based on an algorithm by Stephen L. Moshier <moshier@world.std.com>.
-   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>
-#include <float.h>
-
-__complex__ float
-__csqrtf (__complex__ float x)
-{
-  __complex__ float res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE))
-    {
-      if (icls == FP_INFINITE)
-	{
-	  __real__ res = HUGE_VALF;
-	  __imag__ res = __imag__ x;
-	}
-      else if (rcls == FP_INFINITE)
-	{
-	  if (__real__ x < 0.0)
-	    {
-	      __real__ res = icls == FP_NAN ? __nanf ("") : 0;
-	      __imag__ res = __copysignf (HUGE_VALF, __imag__ x);
-	    }
-	  else
-	    {
-	      __real__ res = __real__ x;
-	      __imag__ res = (icls == FP_NAN
-			      ? __nanf ("") : __copysignf (0.0, __imag__ x));
-	    }
-	}
-      else
-	{
-	  __real__ res = __nanf ("");
-	  __imag__ res = __nanf ("");
-	}
-    }
-  else
-    {
-      if (__glibc_unlikely (icls == FP_ZERO))
-	{
-	  if (__real__ x < 0.0)
-	    {
-	      __real__ res = 0.0;
-	      __imag__ res = __copysignf (__ieee754_sqrtf (-__real__ x),
-					  __imag__ x);
-	    }
-	  else
-	    {
-	      __real__ res = fabsf (__ieee754_sqrtf (__real__ x));
-	      __imag__ res = __copysignf (0.0, __imag__ x);
-	    }
-	}
-      else if (__glibc_unlikely (rcls == FP_ZERO))
-	{
-	  float r;
-	  if (fabsf (__imag__ x) >= 2.0f * FLT_MIN)
-	    r = __ieee754_sqrtf (0.5f * fabsf (__imag__ x));
-	  else
-	    r = 0.5f * __ieee754_sqrtf (2.0f * fabsf (__imag__ x));
-
-	  __real__ res = r;
-	  __imag__ res = __copysignf (r, __imag__ x);
-	}
-      else
-	{
-	  float d, r, s;
-	  int scale = 0;
-
-	  if (fabsf (__real__ x) > FLT_MAX / 4.0f)
-	    {
-	      scale = 1;
-	      __real__ x = __scalbnf (__real__ x, -2 * scale);
-	      __imag__ x = __scalbnf (__imag__ x, -2 * scale);
-	    }
-	  else if (fabsf (__imag__ x) > FLT_MAX / 4.0f)
-	    {
-	      scale = 1;
-	      if (fabsf (__real__ x) >= 4.0f * FLT_MIN)
-		__real__ x = __scalbnf (__real__ x, -2 * scale);
-	      else
-		__real__ x = 0.0f;
-	      __imag__ x = __scalbnf (__imag__ x, -2 * scale);
-	    }
-	  else if (fabsf (__real__ x) < 2.0f * FLT_MIN
-		   && fabsf (__imag__ x) < 2.0f * FLT_MIN)
-	    {
-	      scale = -((FLT_MANT_DIG + 1) / 2);
-	      __real__ x = __scalbnf (__real__ x, -2 * scale);
-	      __imag__ x = __scalbnf (__imag__ x, -2 * scale);
-	    }
-
-	  d = __ieee754_hypotf (__real__ x, __imag__ x);
-	  /* Use the identity   2  Re res  Im res = Im x
-	     to avoid cancellation error in  d +/- Re x.  */
-	  if (__real__ x > 0)
-	    {
-	      r = __ieee754_sqrtf (0.5f * (d + __real__ x));
-	      if (scale == 1 && fabsf (__imag__ x) < 1.0f)
-		{
-		  /* Avoid possible intermediate underflow.  */
-		  s = __imag__ x / r;
-		  r = __scalbnf (r, scale);
-		  scale = 0;
-		}
-	      else
-		s = 0.5f * (__imag__ x / r);
-	    }
-	  else
-	    {
-	      s = __ieee754_sqrtf (0.5f * (d - __real__ x));
-	      if (scale == 1 && fabsf (__imag__ x) < 1.0f)
-		{
-		  /* Avoid possible intermediate underflow.  */
-		  r = fabsf (__imag__ x / s);
-		  s = __scalbnf (s, scale);
-		  scale = 0;
-		}
-	      else
-		r = fabsf (0.5f * (__imag__ x / s));
-	    }
-
-	  if (scale)
-	    {
-	      r = __scalbnf (r, scale);
-	      s = __scalbnf (s, scale);
-	    }
-
-	  math_check_force_underflow (r);
-	  math_check_force_underflow (s);
-
-	  __real__ res = r;
-	  __imag__ res = __copysignf (s, __imag__ x);
-	}
-    }
-
-  return res;
-}
-#ifndef __csqrtf
-weak_alias (__csqrtf, csqrtf)
-#endif
diff --git a/math/s_csqrtl.c b/math/s_csqrtl.c
deleted file mode 100644
index b0b52a5..0000000
--- a/math/s_csqrtl.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* Complex square root of long double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Based on an algorithm by Stephen L. Moshier <moshier@world.std.com>.
-   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>
-#include <float.h>
-
-__complex__ long double
-__csqrtl (__complex__ long double x)
-{
-  __complex__ long double res;
-  int rcls = fpclassify (__real__ x);
-  int icls = fpclassify (__imag__ x);
-
-  if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE))
-    {
-      if (icls == FP_INFINITE)
-	{
-	  __real__ res = HUGE_VALL;
-	  __imag__ res = __imag__ x;
-	}
-      else if (rcls == FP_INFINITE)
-	{
-	  if (__real__ x < 0.0)
-	    {
-	      __real__ res = icls == FP_NAN ? __nanl ("") : 0;
-	      __imag__ res = __copysignl (HUGE_VALL, __imag__ x);
-	    }
-	  else
-	    {
-	      __real__ res = __real__ x;
-	      __imag__ res = (icls == FP_NAN
-			      ? __nanl ("") : __copysignl (0.0, __imag__ x));
-	    }
-	}
-      else
-	{
-	  __real__ res = __nanl ("");
-	  __imag__ res = __nanl ("");
-	}
-    }
-  else
-    {
-      if (__glibc_unlikely (icls == FP_ZERO))
-	{
-	  if (__real__ x < 0.0)
-	    {
-	      __real__ res = 0.0;
-	      __imag__ res = __copysignl (__ieee754_sqrtl (-__real__ x),
-					  __imag__ x);
-	    }
-	  else
-	    {
-	      __real__ res = fabsl (__ieee754_sqrtl (__real__ x));
-	      __imag__ res = __copysignl (0.0, __imag__ x);
-	    }
-	}
-      else if (__glibc_unlikely (rcls == FP_ZERO))
-	{
-	  long double r;
-	  if (fabsl (__imag__ x) >= 2.0L * LDBL_MIN)
-	    r = __ieee754_sqrtl (0.5L * fabsl (__imag__ x));
-	  else
-	    r = 0.5L * __ieee754_sqrtl (2.0L * fabsl (__imag__ x));
-
-	  __real__ res = r;
-	  __imag__ res = __copysignl (r, __imag__ x);
-	}
-      else
-	{
-	  long double d, r, s;
-	  int scale = 0;
-
-	  if (fabsl (__real__ x) > LDBL_MAX / 4.0L)
-	    {
-	      scale = 1;
-	      __real__ x = __scalbnl (__real__ x, -2 * scale);
-	      __imag__ x = __scalbnl (__imag__ x, -2 * scale);
-	    }
-	  else if (fabsl (__imag__ x) > LDBL_MAX / 4.0L)
-	    {
-	      scale = 1;
-	      if (fabsl (__real__ x) >= 4.0L * LDBL_MIN)
-		__real__ x = __scalbnl (__real__ x, -2 * scale);
-	      else
-		__real__ x = 0.0L;
-	      __imag__ x = __scalbnl (__imag__ x, -2 * scale);
-	    }
-	  else if (fabsl (__real__ x) < 2.0L * LDBL_MIN
-		   && fabsl (__imag__ x) < 2.0L * LDBL_MIN)
-	    {
-	      scale = -((LDBL_MANT_DIG + 1) / 2);
-	      __real__ x = __scalbnl (__real__ x, -2 * scale);
-	      __imag__ x = __scalbnl (__imag__ x, -2 * scale);
-	    }
-
-	  d = __ieee754_hypotl (__real__ x, __imag__ x);
-	  /* Use the identity   2  Re res  Im res = Im x
-	     to avoid cancellation error in  d +/- Re x.  */
-	  if (__real__ x > 0)
-	    {
-	      r = __ieee754_sqrtl (0.5L * (d + __real__ x));
-	      if (scale == 1 && fabsl (__imag__ x) < 1.0L)
-		{
-		  /* Avoid possible intermediate underflow.  */
-		  s = __imag__ x / r;
-		  r = __scalbnl (r, scale);
-		  scale = 0;
-		}
-	      else
-		s = 0.5L * (__imag__ x / r);
-	    }
-	  else
-	    {
-	      s = __ieee754_sqrtl (0.5L * (d - __real__ x));
-	      if (scale == 1 && fabsl (__imag__ x) < 1.0L)
-		{
-		  /* Avoid possible intermediate underflow.  */
-		  r = fabsl (__imag__ x / s);
-		  s = __scalbnl (s, scale);
-		  scale = 0;
-		}
-	      else
-		r = fabsl (0.5L * (__imag__ x / s));
-	    }
-
-	  if (scale)
-	    {
-	      r = __scalbnl (r, scale);
-	      s = __scalbnl (s, scale);
-	    }
-
-	  math_check_force_underflow (r);
-	  math_check_force_underflow (s);
-
-	  __real__ res = r;
-	  __imag__ res = __copysignl (s, __imag__ x);
-	}
-    }
-
-  return res;
-}
-weak_alias (__csqrtl, csqrtl)
diff --git a/sysdeps/alpha/fpu/s_cexpf.c b/sysdeps/alpha/fpu/s_cexpf.c
index 2ae519c..d5b53eb 100644
--- a/sysdeps/alpha/fpu/s_cexpf.c
+++ b/sysdeps/alpha/fpu/s_cexpf.c
@@ -24,14 +24,18 @@
 
 #undef __cexpf
 #undef cexpf
-#define __cexpf internal_cexpf
 
 static _Complex float internal_cexpf (_Complex float x);
 
-#include <math/s_cexpf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_cexpf
+#include <math-type-macros-float.h>
 
-#undef __cexpf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_cexp_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_cexpf (c1_cfloat_decl (x))
diff --git a/sysdeps/alpha/fpu/s_clog10f.c b/sysdeps/alpha/fpu/s_clog10f.c
index 1ab0730..c46f288 100644
--- a/sysdeps/alpha/fpu/s_clog10f.c
+++ b/sysdeps/alpha/fpu/s_clog10f.c
@@ -24,14 +24,18 @@
 
 #undef __clog10f
 #undef clog10f
-#define __clog10f internal_clog10f
 
 static _Complex float internal_clog10f (_Complex float x);
 
-#include <math/s_clog10f.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_clog10f
+#include <math-type-macros-float.h>
 
-#undef __clog10f
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_clog10_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_clog10f (c1_cfloat_decl (x))
diff --git a/sysdeps/alpha/fpu/s_clogf.c b/sysdeps/alpha/fpu/s_clogf.c
index 185948f..492a305 100644
--- a/sysdeps/alpha/fpu/s_clogf.c
+++ b/sysdeps/alpha/fpu/s_clogf.c
@@ -24,14 +24,18 @@
 
 #undef __clogf
 #undef clogf
-#define __clogf internal_clogf
 
 static _Complex float internal_clogf (_Complex float x);
 
-#include <math/s_clogf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_clogf
+#include <math-type-macros-float.h>
 
-#undef __clogf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_clog_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_clogf (c1_cfloat_decl (x))
diff --git a/sysdeps/alpha/fpu/s_cpowf.c b/sysdeps/alpha/fpu/s_cpowf.c
index 686c397..4235fe2 100644
--- a/sysdeps/alpha/fpu/s_cpowf.c
+++ b/sysdeps/alpha/fpu/s_cpowf.c
@@ -24,14 +24,18 @@
 
 #undef __cpowf
 #undef cpowf
-#define __cpowf internal_cpowf
 
 static _Complex float internal_cpowf (_Complex float x, _Complex float c);
 
-#include <math/s_cpowf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_cpowf
+#include <math-type-macros-float.h>
 
-#undef __cpowf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_cpow_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_cpowf (c1_cfloat_decl (x), c1_cfloat_decl (c))
diff --git a/sysdeps/alpha/fpu/s_cprojf.c b/sysdeps/alpha/fpu/s_cprojf.c
index 30a24a8..3c4e9e9 100644
--- a/sysdeps/alpha/fpu/s_cprojf.c
+++ b/sysdeps/alpha/fpu/s_cprojf.c
@@ -24,14 +24,18 @@
 
 #undef __cprojf
 #undef cprojf
-#define __cprojf internal_cprojf
 
 static _Complex float internal_cprojf (_Complex float x);
 
-#include <math/s_cprojf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_cprojf
+#include <math-type-macros-float.h>
 
-#undef __cprojf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_cproj_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_cprojf (c1_cfloat_decl (x))
diff --git a/sysdeps/alpha/fpu/s_csqrtf.c b/sysdeps/alpha/fpu/s_csqrtf.c
index c7a18d7..d2f32b9 100644
--- a/sysdeps/alpha/fpu/s_csqrtf.c
+++ b/sysdeps/alpha/fpu/s_csqrtf.c
@@ -24,14 +24,18 @@
 
 #undef __csqrtf
 #undef csqrtf
-#define __csqrtf internal_csqrtf
 
 static _Complex float internal_csqrtf (_Complex float x);
 
-#include <math/s_csqrtf.c>
-#include "cfloat-compat.h"
+#define M_DECL_FUNC(f) internal_csqrtf
+#include <math-type-macros-float.h>
 
-#undef __csqrtf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/s_csqrt_template.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_csqrtf (c1_cfloat_decl (x))
diff --git a/sysdeps/ieee754/ldbl-opt/s_cexp.c b/sysdeps/ieee754/ldbl-opt/s_cexp.c
deleted file mode 100644
index d983c96..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_cexp.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_cexp.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cexp, cexpl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_cexpl.c b/sysdeps/ieee754/ldbl-opt/s_cexpl.c
deleted file mode 100644
index d5ae1fc..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_cexpl.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_cexpl.c>
-long_double_symbol (libm, __cexpl, cexpl);
diff --git a/sysdeps/ieee754/ldbl-opt/s_clog.c b/sysdeps/ieee754/ldbl-opt/s_clog.c
deleted file mode 100644
index 3e0e90c..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_clog.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_clog.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __clog, clogl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_clog10.c b/sysdeps/ieee754/ldbl-opt/s_clog10.c
deleted file mode 100644
index ac3f4a3..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_clog10.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_clog10.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __clog10, __clog10l, GLIBC_2_1);
-compat_symbol (libm, clog10, clog10l, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_clog10l.c b/sysdeps/ieee754/ldbl-opt/s_clog10l.c
index 954f680..91521ea 100644
--- a/sysdeps/ieee754/ldbl-opt/s_clog10l.c
+++ b/sysdeps/ieee754/ldbl-opt/s_clog10l.c
@@ -1,10 +1,32 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#undef weak_alias
-#define weak_alias(n,a)
-#define __clog10l __clog10l_internal
-#include <math/s_clog10l.c>
-#undef __clog10l
+/* clog10l alias overrides for platforms where long double
+   was previously not unique.
+   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/>.  */
+
+#define M_DECL_FUNC(x) __clog10l_internal
+#include <math-type-macros-ldouble.h>
+
+#undef declare_mgen_alias
+#define declare_mgen_alias(from, to)
+
+#include <s_clog10_template.c>
+
+/* The aliasing for long double is a bit more complicated
+   since some private symbols leaked out in the past.  */
 strong_alias (__clog10l_internal, __clog10l__internal)
 long_double_symbol (libm, __clog10l_internal, __clog10l);
 long_double_symbol (libm, __clog10l__internal, clog10l);
diff --git a/sysdeps/ieee754/ldbl-opt/s_clogl.c b/sysdeps/ieee754/ldbl-opt/s_clogl.c
deleted file mode 100644
index 75126c8..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_clogl.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_clogl.c>
-long_double_symbol (libm, __clogl, clogl);
diff --git a/sysdeps/ieee754/ldbl-opt/s_cpow.c b/sysdeps/ieee754/ldbl-opt/s_cpow.c
deleted file mode 100644
index 4801d7c..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_cpow.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_cpow.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cpow, cpowl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_cpowl.c b/sysdeps/ieee754/ldbl-opt/s_cpowl.c
deleted file mode 100644
index 61840e3..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_cpowl.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_cpowl.c>
-long_double_symbol (libm, __cpowl, cpowl);
diff --git a/sysdeps/ieee754/ldbl-opt/s_cproj.c b/sysdeps/ieee754/ldbl-opt/s_cproj.c
deleted file mode 100644
index f298c37..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_cproj.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_cproj.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cproj, cprojl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_cprojl.c b/sysdeps/ieee754/ldbl-opt/s_cprojl.c
deleted file mode 100644
index 1cc0580..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_cprojl.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_cprojl.c>
-long_double_symbol (libm, __cprojl, cprojl);
diff --git a/sysdeps/ieee754/ldbl-opt/s_csqrt.c b/sysdeps/ieee754/ldbl-opt/s_csqrt.c
deleted file mode 100644
index 2b6dcfe..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_csqrt.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/s_csqrt.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __csqrt, csqrtl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_csqrtl.c b/sysdeps/ieee754/ldbl-opt/s_csqrtl.c
deleted file mode 100644
index 045ff93..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_csqrtl.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_csqrtl.c>
-long_double_symbol (libm, __csqrtl, csqrtl);
diff --git a/sysdeps/m68k/m680x0/fpu/s_cexp.c b/sysdeps/m68k/m680x0/fpu/s_cexp_template.c
similarity index 94%
rename from sysdeps/m68k/m680x0/fpu/s_cexp.c
rename to sysdeps/m68k/m680x0/fpu/s_cexp_template.c
index f715b77..828ac6c 100644
--- a/sysdeps/m68k/m680x0/fpu/s_cexp.c
+++ b/sysdeps/m68k/m680x0/fpu/s_cexp_template.c
@@ -22,21 +22,14 @@
 #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(__cexp) (__complex__ float_type x)
+CFLOAT
+s(__cexp) (CFLOAT x)
 {
-  __complex__ float_type retval;
+  CFLOAT retval;
   unsigned long ix_cond;
 
   ix_cond = __m81_test (__imag__ x);
diff --git a/sysdeps/m68k/m680x0/fpu/s_cexpf.c b/sysdeps/m68k/m680x0/fpu/s_cexpf.c
deleted file mode 100644
index 177a360..0000000
--- a/sysdeps/m68k/m680x0/fpu/s_cexpf.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define SUFF f
-#define float_type float
-#include <s_cexp.c>
diff --git a/sysdeps/m68k/m680x0/fpu/s_cexpl.c b/sysdeps/m68k/m680x0/fpu/s_cexpl.c
deleted file mode 100644
index bbda4ba..0000000
--- a/sysdeps/m68k/m680x0/fpu/s_cexpl.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define SUFF l
-#define float_type long double
-#include <s_cexp.c>
-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCHv4 1/8] Prepare to convert _Complex cosine functions
@ 2016-08-18 22:35 Paul E. Murphy
  2016-08-18 22:35 ` [PATCHv4 5/8] Prepare to convert _Complex tangent functions Paul E. Murphy
                   ` (6 more replies)
  0 siblings, 7 replies; 20+ messages in thread
From: Paul E. Murphy @ 2016-08-18 22:35 UTC (permalink / raw)
  To: libc-alpha

This updates the set with minor formatting changes.

---8<---

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.

	* 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.
---
 math/{s_cacos.c => s_cacos_template.c}   | 0
 math/{s_cacosh.c => s_cacosh_template.c} | 0
 math/{s_ccos.c => s_ccos_template.c}     | 0
 math/{s_ccosh.c => s_ccosh_template.c}   | 0
 4 files changed, 0 insertions(+), 0 deletions(-)
 copy math/{s_cacos.c => s_cacos_template.c} (100%)
 copy math/{s_cacosh.c => s_cacosh_template.c} (100%)
 copy math/{s_ccos.c => s_ccos_template.c} (100%)
 copy math/{s_ccosh.c => s_ccosh_template.c} (100%)

diff --git a/math/s_cacos.c b/math/s_cacos_template.c
similarity index 100%
copy from math/s_cacos.c
copy to math/s_cacos_template.c
diff --git a/math/s_cacosh.c b/math/s_cacosh_template.c
similarity index 100%
copy from math/s_cacosh.c
copy to math/s_cacosh_template.c
diff --git a/math/s_ccos.c b/math/s_ccos_template.c
similarity index 100%
copy from math/s_ccos.c
copy to math/s_ccos_template.c
diff --git a/math/s_ccosh.c b/math/s_ccosh_template.c
similarity index 100%
copy from math/s_ccosh.c
copy to math/s_ccosh_template.c
-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCHv4 3/8] Prepare to convert _Complex sine functions
  2016-08-18 22:35 [PATCHv4 1/8] Prepare to convert _Complex cosine functions Paul E. Murphy
  2016-08-18 22:35 ` [PATCHv4 5/8] Prepare to convert _Complex tangent functions Paul E. Murphy
@ 2016-08-18 22:35 ` Paul E. Murphy
  2016-08-18 22:35 ` [PATCHv4 4/8] Convert _Complex sine functions to generated code Paul E. Murphy
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Paul E. Murphy @ 2016-08-18 22:35 UTC (permalink / raw)
  To: libc-alpha

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.

	* s_casin_template.c: Copy of s_casin.c.
	* s_casinh_template.c: Copy of s_casinh.c.
	* s_csin_template.c: Copy of s_csin.c.
	* s_csinh_template.c: Copy of s_csinh.c.
	* k_casinh_template.c: Copy of k_casinh.c.
---
 math/{k_casinh.c => k_casinh_template.c} | 0
 math/{s_casin.c => s_casin_template.c}   | 0
 math/{s_casinh.c => s_casinh_template.c} | 0
 math/{s_csin.c => s_csin_template.c}     | 0
 math/{s_csinh.c => s_csinh_template.c}   | 0
 5 files changed, 0 insertions(+), 0 deletions(-)
 copy math/{k_casinh.c => k_casinh_template.c} (100%)
 copy math/{s_casin.c => s_casin_template.c} (100%)
 copy math/{s_casinh.c => s_casinh_template.c} (100%)
 copy math/{s_csin.c => s_csin_template.c} (100%)
 copy math/{s_csinh.c => s_csinh_template.c} (100%)

diff --git a/math/k_casinh.c b/math/k_casinh_template.c
similarity index 100%
copy from math/k_casinh.c
copy to math/k_casinh_template.c
diff --git a/math/s_casin.c b/math/s_casin_template.c
similarity index 100%
copy from math/s_casin.c
copy to math/s_casin_template.c
diff --git a/math/s_casinh.c b/math/s_casinh_template.c
similarity index 100%
copy from math/s_casinh.c
copy to math/s_casinh_template.c
diff --git a/math/s_csin.c b/math/s_csin_template.c
similarity index 100%
copy from math/s_csin.c
copy to math/s_csin_template.c
diff --git a/math/s_csinh.c b/math/s_csinh_template.c
similarity index 100%
copy from math/s_csinh.c
copy to math/s_csinh_template.c
-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCHv4 7/8] Prepare to convert remaining _Complex functions
  2016-08-18 22:35 [PATCHv4 1/8] Prepare to convert _Complex cosine functions Paul E. Murphy
                   ` (4 preceding siblings ...)
  2016-08-18 22:35 ` [PATCHv4 6/8] Convert _Complex tangent " Paul E. Murphy
@ 2016-08-18 22:35 ` Paul E. Murphy
  2016-08-18 22:35 ` [PATCHv4 8/8] Convert remaining complex function to generated files Paul E. Murphy
  6 siblings, 0 replies; 20+ messages in thread
From: Paul E. Murphy @ 2016-08-18 22:35 UTC (permalink / raw)
  To: libc-alpha

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.

	* s_cexp_template.c: Copy of s_cexp.c.
	* s_clog_template.c: Copy of s_clog.c.
	* s_clog10_template.c: Copy of s_clog10.c.
	* s_cpow_template.c: Copy of s_cpow.c.
	* s_cproj_template.c: Copy of s_cproj.c.
	* s_csqrt_template.c: Copy of s_csqrt.c.
---
 math/{s_cexp.c => s_cexp_template.c}     | 0
 math/{s_clog10.c => s_clog10_template.c} | 0
 math/{s_clog.c => s_clog_template.c}     | 0
 math/{s_cpow.c => s_cpow_template.c}     | 0
 math/{s_cproj.c => s_cproj_template.c}   | 0
 math/{s_csqrt.c => s_csqrt_template.c}   | 0
 6 files changed, 0 insertions(+), 0 deletions(-)
 copy math/{s_cexp.c => s_cexp_template.c} (100%)
 copy math/{s_clog10.c => s_clog10_template.c} (100%)
 copy math/{s_clog.c => s_clog_template.c} (100%)
 copy math/{s_cpow.c => s_cpow_template.c} (100%)
 copy math/{s_cproj.c => s_cproj_template.c} (100%)
 copy math/{s_csqrt.c => s_csqrt_template.c} (100%)

diff --git a/math/s_cexp.c b/math/s_cexp_template.c
similarity index 100%
copy from math/s_cexp.c
copy to math/s_cexp_template.c
diff --git a/math/s_clog10.c b/math/s_clog10_template.c
similarity index 100%
copy from math/s_clog10.c
copy to math/s_clog10_template.c
diff --git a/math/s_clog.c b/math/s_clog_template.c
similarity index 100%
copy from math/s_clog.c
copy to math/s_clog_template.c
diff --git a/math/s_cpow.c b/math/s_cpow_template.c
similarity index 100%
copy from math/s_cpow.c
copy to math/s_cpow_template.c
diff --git a/math/s_cproj.c b/math/s_cproj_template.c
similarity index 100%
copy from math/s_cproj.c
copy to math/s_cproj_template.c
diff --git a/math/s_csqrt.c b/math/s_csqrt_template.c
similarity index 100%
copy from math/s_csqrt.c
copy to math/s_csqrt_template.c
-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 2/8] Convert _Complex cosine functions to generated code
  2016-08-18 22:35 ` [PATCHv4 2/8] Convert _Complex cosine " Paul E. Murphy
@ 2016-08-19 14:57   ` Joseph Myers
  2016-08-19 17:00     ` Paul E. Murphy
  0 siblings, 1 reply; 20+ messages in thread
From: Joseph Myers @ 2016-08-19 14:57 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha

On Thu, 18 Aug 2016, Paul E. Murphy wrote:

> This is fairly straight fowards.  m68k overrides are
> updated to use the framework, and thus are simplified
> a bit.

Patches 1 and 2 are OK.  (m68k maintainers might wish to do further 
cleanups, although we know there are issues with the m68k versions anyway 
as discussed in bugs 13742 and 16290.)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 2/8] Convert _Complex cosine functions to generated code
  2016-08-19 14:57   ` Joseph Myers
@ 2016-08-19 17:00     ` Paul E. Murphy
  0 siblings, 0 replies; 20+ messages in thread
From: Paul E. Murphy @ 2016-08-19 17:00 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 08/19/2016 09:56 AM, Joseph Myers wrote:
> On Thu, 18 Aug 2016, Paul E. Murphy wrote:
> 
>> This is fairly straight fowards.  m68k overrides are
>> updated to use the framework, and thus are simplified
>> a bit.
> 
> Patches 1 and 2 are OK.  (m68k maintainers might wish to do further 
> cleanups, although we know there are issues with the m68k versions anyway 
> as discussed in bugs 13742 and 16290.)
> 

Committed as 281f507, and 01ee387.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 4/8] Convert _Complex sine functions to generated code
  2016-08-18 22:35 ` [PATCHv4 4/8] Convert _Complex sine functions to generated code Paul E. Murphy
@ 2016-08-19 17:29   ` Joseph Myers
  2016-08-19 19:23     ` Paul E. Murphy
  0 siblings, 1 reply; 20+ messages in thread
From: Joseph Myers @ 2016-08-19 17:29 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha

On Thu, 18 Aug 2016, Paul E. Murphy wrote:

> +	      __real__ res = M_LOG1P (rx2 + dm + 2
> +				      * (rx * r1 + ix * r2)) / 2;

I don't like this choice of position for a line break, since the '*' at 
the start of the second line only applies to the 2 on the line above, not 
to the whole of "rx2 + dm + 2" which the split makes it look like it 
should apply to.

Patches 3 and 4 are OK with that fixed (for example, to have the second 
line start "+ 2 * (rx...").  The same comments as before apply about scope 
for m68k maintainers to make further cleanups.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 4/8] Convert _Complex sine functions to generated code
  2016-08-19 17:29   ` Joseph Myers
@ 2016-08-19 19:23     ` Paul E. Murphy
  2016-08-19 20:05       ` Joseph Myers
  0 siblings, 1 reply; 20+ messages in thread
From: Paul E. Murphy @ 2016-08-19 19:23 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 08/19/2016 12:28 PM, Joseph Myers wrote:
> On Thu, 18 Aug 2016, Paul E. Murphy wrote:
> 
>> +	      __real__ res = M_LOG1P (rx2 + dm + 2
>> +				      * (rx * r1 + ix * r2)) / 2;
> 
> I don't like this choice of position for a line break, since the '*' at 
> the start of the second line only applies to the 2 on the line above, not 
> to the whole of "rx2 + dm + 2" which the split makes it look like it 
> should apply to.
> 
> Patches 3 and 4 are OK with that fixed (for example, to have the second 
> line start "+ 2 * (rx...").  The same comments as before apply about scope 
> for m68k maintainers to make further cleanups.
> 

Looking closer, the break is not needed. It fits in 78 columns.  Pending no
objection, I will commit with the following change:

diff --git a/math/k_casinh_template.c b/math/k_casinh_template.c
index 0b29e6a..74626b1 100644
--- a/math/k_casinh_template.c
+++ b/math/k_casinh_template.c
@@ -157,8 +157,7 @@ M_DECL_FUNC (__kernel_casinh) (CFLOAT x, int adj)
              FLOAT r1 = M_SQRT ((dp + rx2) / 2);
              FLOAT r2 = rx * ix / r1;
 
-             __real__ res = M_LOG1P (rx2 + dm + 2
-                                     * (rx * r1 + ix * r2)) / 2;
+             __real__ res = M_LOG1P (rx2 + dm + 2 * (rx * r1 + ix * r2)) / 2;
              if (adj)
                __imag__ res = M_ATAN2 (rx + r1, M_COPYSIGN (ix + r2,
                                                             __imag__ x));

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 4/8] Convert _Complex sine functions to generated code
  2016-08-19 19:23     ` Paul E. Murphy
@ 2016-08-19 20:05       ` Joseph Myers
  2016-08-19 21:52         ` Paul E. Murphy
  0 siblings, 1 reply; 20+ messages in thread
From: Joseph Myers @ 2016-08-19 20:05 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha

On Fri, 19 Aug 2016, Paul E. Murphy wrote:

> Looking closer, the break is not needed. It fits in 78 columns.  Pending no
> objection, I will commit with the following change:

That version is fine.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 6/8] Convert _Complex tangent functions to generated code
  2016-08-18 22:35 ` [PATCHv4 6/8] Convert _Complex tangent " Paul E. Murphy
@ 2016-08-19 20:18   ` Joseph Myers
  2016-08-19 21:52     ` Paul E. Murphy
  0 siblings, 1 reply; 20+ messages in thread
From: Joseph Myers @ 2016-08-19 20:18 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha

On Thu, 18 Aug 2016, Paul E. Murphy wrote:

> This is fairly straight fowards.  m68k overrides are
> updated to use the framework, and thus are simplified
> a bit.

There are no m68k overrides for these functions, so this description is 
incorrect, as is the ChangeLog entry:

> 	* sysdeps/m68k/m680x0/fpu/s_ctanh.c: Refactor into ...
> 	* sysdeps/m68k/m680x0/fpu/s_ctanh_template.c: New file.
> 	* sysdeps/m68k/m680x0/fpu/s_ctanhf.c: Removed.
> 	* sysdeps/m68k/m680x0/fpu/s_ctanhl.c: Removed.

> -	      den = (1.0 - absx) * (1.0 + absx);
> -	      if (den == -0.0)
> -		den = 0.0;
> +	      den = (1 - absx) * (1 + absx);
> +	      if (den == -0)
> +		den = 0;

Saying -0 as an integer is fairly nonsensical, since there is no such 
integer as distinct from 0.

Saying == 0, as is done in cacos, is fine here; it's clear enough that 
this code is converting -0 to +0 (and tests == -0.0 and == 0.0 mean the 
same thing anyway).  Then catan and catanh should be consistent, so change 
catanh as well

> +	      den = (1 - absx) * (1 + absx);
> +	      if (den == M_LIT (-0.0))
> +		den = 0;

so it also uses == 0 in the comparison.

Patches 5 and 6 are OK with those changes.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 8/8] Convert remaining complex function to generated files
  2016-08-18 22:35 ` [PATCHv4 8/8] Convert remaining complex function to generated files Paul E. Murphy
@ 2016-08-19 20:46   ` Joseph Myers
  2016-08-19 20:57     ` Paul E. Murphy
  0 siblings, 1 reply; 20+ messages in thread
From: Joseph Myers @ 2016-08-19 20:46 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha

On Thu, 18 Aug 2016, Paul E. Murphy wrote:

> +#if M_LIBM_NEED_COMPAT (clog10)
> +  /* __clog10 was accidentally exported in past versions.  */

I'm not sure that comment is accurate.  __clog10 is used in tgmath.h to 
provide support for type-generic log10 for complex arguments.  That looks 
fairly deliberate to me as a public ABI.  One could argue that tgmath.h 
should actually use clog10 not __clog10 there, since it's inside a 
conditional on __USE_GNU, but one could also argue that __clog10 should be 
exported for use by the C++ standard library which has to provide log10 
for complex numbers (libstdc++ doesn't currently use clog10 or __clog10 
for this, but could, and logically it should be __clog10 for namespace 
reasons; cf past discussions about providing more __* exports to eliminate 
the need for g++ to define _GNU_SOURCE by default).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 8/8] Convert remaining complex function to generated files
  2016-08-19 20:46   ` Joseph Myers
@ 2016-08-19 20:57     ` Paul E. Murphy
  2016-08-26 21:22       ` Joseph Myers
  0 siblings, 1 reply; 20+ messages in thread
From: Paul E. Murphy @ 2016-08-19 20:57 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 08/19/2016 03:45 PM, Joseph Myers wrote:
> On Thu, 18 Aug 2016, Paul E. Murphy wrote:
> 
>> +#if M_LIBM_NEED_COMPAT (clog10)
>> +  /* __clog10 was accidentally exported in past versions.  */
> 
> I'm not sure that comment is accurate.  __clog10 is used in tgmath.h to 
> provide support for type-generic log10 for complex arguments.  That looks 
> fairly deliberate to me as a public ABI.  One could argue that tgmath.h 
> should actually use clog10 not __clog10 there, since it's inside a 
> conditional on __USE_GNU, but one could also argue that __clog10 should be 
> exported for use by the C++ standard library which has to provide log10 
> for complex numbers (libstdc++ doesn't currently use clog10 or __clog10 
> for this, but could, and logically it should be __clog10 for namespace 
> reasons; cf past discussions about providing more __* exports to eliminate 
> the need for g++ to define _GNU_SOURCE by default).
> 

How about changing it to:

+  /* __clog10 is also a public symbol.  */

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 4/8] Convert _Complex sine functions to generated code
  2016-08-19 20:05       ` Joseph Myers
@ 2016-08-19 21:52         ` Paul E. Murphy
  0 siblings, 0 replies; 20+ messages in thread
From: Paul E. Murphy @ 2016-08-19 21:52 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 08/19/2016 03:05 PM, Joseph Myers wrote:
> On Fri, 19 Aug 2016, Paul E. Murphy wrote:
> 
>> Looking closer, the break is not needed. It fits in 78 columns.  Pending no
>> objection, I will commit with the following change:
> 
> That version is fine.


Committed with the fixed comments as ffb84f5 and c50eee1.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 6/8] Convert _Complex tangent functions to generated code
  2016-08-19 20:18   ` Joseph Myers
@ 2016-08-19 21:52     ` Paul E. Murphy
  0 siblings, 0 replies; 20+ messages in thread
From: Paul E. Murphy @ 2016-08-19 21:52 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 08/19/2016 03:18 PM, Joseph Myers wrote:
> On Thu, 18 Aug 2016, Paul E. Murphy wrote:
> 
>> This is fairly straight fowards.  m68k overrides are
>> updated to use the framework, and thus are simplified
>> a bit.
> 
> There are no m68k overrides for these functions, so this description is 
> incorrect, as is the ChangeLog entry:
> 
>> 	* sysdeps/m68k/m680x0/fpu/s_ctanh.c: Refactor into ...
>> 	* sysdeps/m68k/m680x0/fpu/s_ctanh_template.c: New file.
>> 	* sysdeps/m68k/m680x0/fpu/s_ctanhf.c: Removed.
>> 	* sysdeps/m68k/m680x0/fpu/s_ctanhl.c: Removed.

I've removed both sections from the commit and ChangeLog.


>> -	      den = (1.0 - absx) * (1.0 + absx);
>> -	      if (den == -0.0)
>> -		den = 0.0;
>> +	      den = (1 - absx) * (1 + absx);
>> +	      if (den == -0)
>> +		den = 0;
> 
> Saying -0 as an integer is fairly nonsensical, since there is no such 
> integer as distinct from 0.
> 
> Saying == 0, as is done in cacos, is fine here; it's clear enough that 
> this code is converting -0 to +0 (and tests == -0.0 and == 0.0 mean the 
> same thing anyway).  Then catan and catanh should be consistent, so change 
> catanh as well
> 
>> +	      den = (1 - absx) * (1 + absx);
>> +	      if (den == M_LIT (-0.0))
>> +		den = 0;
> 
> so it also uses == 0 in the comparison.
> 
> Patches 5 and 6 are OK with those changes.

I have update both comparisons to "== 0".

Committed as f6d3a72 and d5602ce.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 8/8] Convert remaining complex function to generated files
  2016-08-19 20:57     ` Paul E. Murphy
@ 2016-08-26 21:22       ` Joseph Myers
  2016-08-29 18:31         ` Paul E. Murphy
  0 siblings, 1 reply; 20+ messages in thread
From: Joseph Myers @ 2016-08-26 21:22 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha

On Fri, 19 Aug 2016, Paul E. Murphy wrote:

> On 08/19/2016 03:45 PM, Joseph Myers wrote:
> > On Thu, 18 Aug 2016, Paul E. Murphy wrote:
> > 
> >> +#if M_LIBM_NEED_COMPAT (clog10)
> >> +  /* __clog10 was accidentally exported in past versions.  */
> > 
> > I'm not sure that comment is accurate.  __clog10 is used in tgmath.h to 
> > provide support for type-generic log10 for complex arguments.  That looks 
> > fairly deliberate to me as a public ABI.  One could argue that tgmath.h 
> > should actually use clog10 not __clog10 there, since it's inside a 
> > conditional on __USE_GNU, but one could also argue that __clog10 should be 
> > exported for use by the C++ standard library which has to provide log10 
> > for complex numbers (libstdc++ doesn't currently use clog10 or __clog10 
> > for this, but could, and logically it should be __clog10 for namespace 
> > reasons; cf past discussions about providing more __* exports to eliminate 
> > the need for g++ to define _GNU_SOURCE by default).
> > 
> 
> How about changing it to:
> 
> +  /* __clog10 is also a public symbol.  */

Patches 7 and 8 are OK with that wording and with the wording in 
sysdeps/ieee754/ldbl-opt/s_clog10l.c

> +/* The aliasing for long double is a bit more complicated
> +   since some private symbols leaked out in the past.  */

also fixed similarly since this may not be a leakage of private symbols.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 8/8] Convert remaining complex function to generated files
  2016-08-26 21:22       ` Joseph Myers
@ 2016-08-29 18:31         ` Paul E. Murphy
  0 siblings, 0 replies; 20+ messages in thread
From: Paul E. Murphy @ 2016-08-29 18:31 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 08/26/2016 04:22 PM, Joseph Myers wrote:
> On Fri, 19 Aug 2016, Paul E. Murphy wrote:
> 
>> On 08/19/2016 03:45 PM, Joseph Myers wrote:
>>> On Thu, 18 Aug 2016, Paul E. Murphy wrote:
>>>
>>>> +#if M_LIBM_NEED_COMPAT (clog10)
>>>> +  /* __clog10 was accidentally exported in past versions.  */
>>>
>>> I'm not sure that comment is accurate.  __clog10 is used in tgmath.h to 
>>> provide support for type-generic log10 for complex arguments.  That looks 
>>> fairly deliberate to me as a public ABI.  One could argue that tgmath.h 
>>> should actually use clog10 not __clog10 there, since it's inside a 
>>> conditional on __USE_GNU, but one could also argue that __clog10 should be 
>>> exported for use by the C++ standard library which has to provide log10 
>>> for complex numbers (libstdc++ doesn't currently use clog10 or __clog10 
>>> for this, but could, and logically it should be __clog10 for namespace 
>>> reasons; cf past discussions about providing more __* exports to eliminate 
>>> the need for g++ to define _GNU_SOURCE by default).
>>>
>>
>> How about changing it to:
>>
>> +  /* __clog10 is also a public symbol.  */
> 
> Patches 7 and 8 are OK with that wording and with the wording in 
> sysdeps/ieee754/ldbl-opt/s_clog10l.c
> 
>> +/* The aliasing for long double is a bit more complicated
>> +   since some private symbols leaked out in the past.  */
> 
> also fixed similarly since this may not be a leakage of private symbols.
>

Comments in both math/s_clog10_template.c and ldbl-opt/s_clog10l.c
rewritten as such.

Committed as 1dbc54f and feb62dd.

Thanks for your patience and detail reviewing these.

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2016-08-29 18:31 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-18 22:35 [PATCHv4 1/8] Prepare to convert _Complex cosine functions Paul E. Murphy
2016-08-18 22:35 ` [PATCHv4 5/8] Prepare to convert _Complex tangent functions Paul E. Murphy
2016-08-18 22:35 ` [PATCHv4 3/8] Prepare to convert _Complex sine functions Paul E. Murphy
2016-08-18 22:35 ` [PATCHv4 4/8] Convert _Complex sine functions to generated code Paul E. Murphy
2016-08-19 17:29   ` Joseph Myers
2016-08-19 19:23     ` Paul E. Murphy
2016-08-19 20:05       ` Joseph Myers
2016-08-19 21:52         ` Paul E. Murphy
2016-08-18 22:35 ` [PATCHv4 2/8] Convert _Complex cosine " Paul E. Murphy
2016-08-19 14:57   ` Joseph Myers
2016-08-19 17:00     ` Paul E. Murphy
2016-08-18 22:35 ` [PATCHv4 6/8] Convert _Complex tangent " Paul E. Murphy
2016-08-19 20:18   ` Joseph Myers
2016-08-19 21:52     ` Paul E. Murphy
2016-08-18 22:35 ` [PATCHv4 7/8] Prepare to convert remaining _Complex functions Paul E. Murphy
2016-08-18 22:35 ` [PATCHv4 8/8] Convert remaining complex function to generated files Paul E. Murphy
2016-08-19 20:46   ` Joseph Myers
2016-08-19 20:57     ` Paul E. Murphy
2016-08-26 21:22       ` Joseph Myers
2016-08-29 18:31         ` Paul E. Murphy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).