[3/6] Convert _Complex cosine functions to generated code

Message ID 429c0afaf57df188108f8be094ebbca2fa25db4e.1467323999.git.murphyp@linux.vnet.ibm.com
State Superseded
Delegated to: Joseph Myers
Headers

Commit Message

Paul E. Murphy June 30, 2016, 10:20 p.m. UTC
  This is fairly straight fowards.  m68k overrides are
updated to use the framework, and thus are simplified
a bit.

Note, ccosh has had a little drift.  For my sanity,
I have preserved the behavior of each variant as
it does alter code generation.

	* math/Makefile (libm-gen-calls): Add
	cacos, cacosh, ccos, ccosh
	(libm-calls): Remove the above

	* math/s_cacos.c: Refactor into b_cacos.c
	* math/s_cacosh.c: Refactor into b_cacosh.c
	* math/s_ccos.c: Refactor into b_ccos.c
	* math/s_ccosh.c: Refactor into b_ccosh.c
	* sysdeps/m68k/m680x0/fpu/s_ccosh.c: Refactor into ../b_ccosh.c

	* math/b_cacos.c: New file
	* math/b_cacosh.c: New file
	* math/b_ccos.c: New file
	* math/b_ccosh.c: New file

	* 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_ccoshf.c: Removed
	* sysdeps/m68k/m680x0/fpu/s_ccoshl.c: Removed

	* sysdeps/alpha/fpu/Makefile: Update to use template file
	* sysdeps/alpha/fpu/s_cacosf.c: Update to use template file
	* sysdeps/alpha/fpu/s_cacoshf.c: Update to use template file
	* sysdeps/alpha/fpu/s_ccosf.c: Update to use template file
	* sysdeps/alpha/fpu/s_ccoshf.c: Update to use template file

	* sysdeps/ieee754/ldbl-opt/math-type-macros.h: Add compat
	versions.
---
 math/Makefile                               |   9 +-
 math/b_cacos.c                              |  59 +++++++++++
 math/b_cacosh.c                             |  97 ++++++++++++++++++
 math/b_ccos.c                               |  40 ++++++++
 math/b_ccosh.c                              | 154 ++++++++++++++++++++++++++++
 math/s_cacos.c                              |  58 -----------
 math/s_cacosf.c                             |  56 ----------
 math/s_cacosh.c                             |  94 -----------------
 math/s_cacoshf.c                            |  92 -----------------
 math/s_cacoshl.c                            |  90 ----------------
 math/s_cacosl.c                             |  54 ----------
 math/s_ccos.c                               |  40 --------
 math/s_ccosf.c                              |  38 -------
 math/s_ccosh.c                              | 147 --------------------------
 math/s_ccoshf.c                             | 147 --------------------------
 math/s_ccoshl.c                             | 143 --------------------------
 math/s_ccosl.c                              |  36 -------
 sysdeps/alpha/fpu/Makefile                  |   6 +-
 sysdeps/alpha/fpu/s_cacosf.c                |  12 ++-
 sysdeps/alpha/fpu/s_cacoshf.c               |  11 +-
 sysdeps/alpha/fpu/s_ccosf.c                 |  13 ++-
 sysdeps/alpha/fpu/s_ccoshf.c                |  13 ++-
 sysdeps/ieee754/ldbl-opt/math-type-macros.h |   4 +
 sysdeps/ieee754/ldbl-opt/s_cacos.c          |   6 --
 sysdeps/ieee754/ldbl-opt/s_cacosh.c         |   6 --
 sysdeps/ieee754/ldbl-opt/s_cacoshl.c        |   6 --
 sysdeps/ieee754/ldbl-opt/s_cacosl.c         |   6 --
 sysdeps/ieee754/ldbl-opt/s_ccos.c           |   6 --
 sysdeps/ieee754/ldbl-opt/s_ccosh.c          |   6 --
 sysdeps/ieee754/ldbl-opt/s_ccoshl.c         |   6 --
 sysdeps/ieee754/ldbl-opt/s_ccosl.c          |   6 --
 sysdeps/m68k/m680x0/fpu/b_ccosh.c           |  68 ++++++++++++
 sysdeps/m68k/m680x0/fpu/s_ccosh.c           |  76 --------------
 sysdeps/m68k/m680x0/fpu/s_ccoshf.c          |   3 -
 sysdeps/m68k/m680x0/fpu/s_ccoshl.c          |   3 -
 35 files changed, 468 insertions(+), 1143 deletions(-)
 create mode 100644 math/b_cacos.c
 create mode 100644 math/b_cacosh.c
 create mode 100644 math/b_ccos.c
 create mode 100644 math/b_ccosh.c
 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
 create mode 100644 sysdeps/m68k/m680x0/fpu/b_ccosh.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_ccosh.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_ccoshf.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_ccoshl.c
  

Comments

Joseph Myers June 30, 2016, 10:36 p.m. UTC | #1
On Thu, 30 Jun 2016, Paul E. Murphy wrote:

> +      if (__real__ res == M_LIT (0.0))

As a general principle for all such changes:

Macroization makes the code less readable, so should be avoided where not 
necessary.  In particular, where implicit conversions from integers to 
floating point will suffice to give the right floating-point value with 
the right type, use integers, so use integer 0 here, and make similar 
changes throughout this patch series whenever the floating-point constant 
has a small value (not -0) representable in int.  (Of course, explicit 
-0.0 does need to use a floating-point constant, not an integer constant.)
  
Paul E. Murphy July 1, 2016, 2:08 a.m. UTC | #2
On 06/30/2016 05:36 PM, Joseph Myers wrote:
> On Thu, 30 Jun 2016, Paul E. Murphy wrote:
> 
>> +      if (__real__ res == M_LIT (0.0))
> 
> As a general principle for all such changes:
> 
> Macroization makes the code less readable, so should be avoided where not 
> necessary.  In particular, where implicit conversions from integers to 
> floating point will suffice to give the right floating-point value with 
> the right type, use integers, so use integer 0 here, and make similar 
> changes throughout this patch series whenever the floating-point constant 
> has a small value (not -0) representable in int.  (Of course, explicit 
> -0.0 does need to use a floating-point constant, not an integer constant.)

Ok, I'll bite.  It's a trivial change to apply, and does not alter
code generation on the 5 platforms I'm testing with.  C11/TS 18661
guarantee these constants should always be correctly promoted.
  
Adhemerval Zanella Aug. 3, 2016, 8:12 p.m. UTC | #3
\
> diff --git a/math/b_cacos.c b/math/b_cacos.c
> new file mode 100644
> index 0000000..5fa006e
> --- /dev/null
> +++ b/math/b_cacos.c
> @@ -0,0 +1,59 @@
> +/* 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.

As for previous patch, I think we can use just current year and drop the
'Contributed by' on new files.
  
Joseph Myers Aug. 3, 2016, 9:18 p.m. UTC | #4
On Wed, 3 Aug 2016, Adhemerval Zanella wrote:

> > diff --git a/math/b_cacos.c b/math/b_cacos.c
> > new file mode 100644
> > index 0000000..5fa006e
> > --- /dev/null
> > +++ b/math/b_cacos.c
> > @@ -0,0 +1,59 @@
> > +/* 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.
> 
> As for previous patch, I think we can use just current year and drop the

I don't think we should just use the current year.  Many of these have 
complicated code that is substantially unchanged from the previous code.
  

Patch

diff --git a/math/Makefile b/math/Makefile
index 14f8f42..b621996 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -53,7 +53,8 @@  libm-support = s_lib_version s_matherr s_signgam			\
 # defines libm-gen-calls-override and lists each function which should
 # not use the default version. If declared, it is assumed the target
 # will match the name s_<func><type suffix>
-gen-libm-calls = g_carg_F g_conj_F g_cimag_F g_creal_F g_cabs_F
+gen-libm-calls = g_carg_F g_conj_F g_cimag_F g_creal_F g_cabs_F g_cacos_F \
+	g_cacosh_F g_ccos_F g_ccosh_F
 
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
@@ -71,9 +72,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/b_cacos.c b/math/b_cacos.c
new file mode 100644
index 0000000..5fa006e
--- /dev/null
+++ b/math/b_cacos.c
@@ -0,0 +1,59 @@ 
+/* 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.
+
+   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>
+
+CFLOAT
+M_DECL_FUNC (__cacos) (CFLOAT x)
+{
+  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 = M_FUNC (__casin) (x);
+
+      __real__ res = (FLOAT) M_MLIT (M_PI_2) - __real__ y;
+      if (__real__ res == M_LIT (0.0))
+	__real__ res = M_LIT (0.0);
+      __imag__ res = -__imag__ y;
+    }
+  else
+    {
+      __real__ y = -__imag__ x;
+      __imag__ y = __real__ x;
+
+      y = M_FUNC (__kernel_casinh) (y, 1);
+
+      __real__ res = __imag__ y;
+      __imag__ res = __real__ y;
+    }
+
+  return res;
+}
+
+declare_mgen_alias (__cacos, cacos);
+
+#if M_LIBM_NEED_COMPAT (carg)
+  declare_mgen_libm_compat (__cacos, cacos)
+#endif
diff --git a/math/b_cacosh.c b/math/b_cacosh.c
new file mode 100644
index 0000000..1b53d56
--- /dev/null
+++ b/math/b_cacosh.c
@@ -0,0 +1,97 @@ 
+/* 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.
+
+   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>
+
+
+CFLOAT
+M_DECL_FUNC (__cacosh) (CFLOAT x)
+{
+  CFLOAT res;
+  int rcls = fpclassify (__real__ x);
+  int icls = fpclassify (__imag__ x);
+
+  if (rcls <= FP_INFINITE || icls <= FP_INFINITE)
+    {
+      if (icls == FP_INFINITE)
+	{
+	  __real__ res = M_HUGE_VAL;
+
+	  if (rcls == FP_NAN)
+	    __imag__ res = M_NAN;
+	  else
+	    __imag__ res = M_COPYSIGN ((rcls == FP_INFINITE
+					? (__real__ x < M_LIT (0.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 = M_HUGE_VAL;
+
+	  if (icls >= FP_ZERO)
+	    __imag__ res = M_COPYSIGN
+	      (signbit (__real__ x) ? M_MLIT (M_PI) : M_LIT (0.0),
+		__imag__ x);
+	  else
+	    __imag__ res = M_NAN;
+	}
+      else
+	{
+	  __real__ res = M_NAN;
+	  __imag__ res = M_NAN;
+	}
+    }
+  else if (rcls == FP_ZERO && icls == FP_ZERO)
+    {
+      __real__ res = M_LIT (0.0);
+      __imag__ res = M_COPYSIGN (M_MLIT (M_PI_2), __imag__ x);
+    }
+  else
+    {
+      CFLOAT y;
+
+      __real__ y = -__imag__ x;
+      __imag__ y = __real__ x;
+
+      y = M_FUNC (__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;
+}
+
+declare_mgen_alias (__cacosh, cacosh)
+
+#if M_LIBM_NEED_COMPAT (cacosh)
+  declare_mgen_libm_compat (__cacosh, cacosh)
+#endif
diff --git a/math/b_ccos.c b/math/b_ccos.c
new file mode 100644
index 0000000..16bd04a
--- /dev/null
+++ b/math/b_ccos.c
@@ -0,0 +1,40 @@ 
+/* 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.
+
+   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>
+
+CFLOAT
+M_DECL_FUNC (__ccos) (CFLOAT x)
+{
+  CFLOAT y;
+
+  __real__ y = -__imag__ x;
+  __imag__ y = __real__ x;
+
+  return M_FUNC (__ccosh) (y);
+}
+
+declare_mgen_alias (__ccos, ccos);
+
+#if M_LIBM_NEED_COMPAT (carg)
+  declare_mgen_libm_compat (__ccos, ccos)
+#endif
diff --git a/math/b_ccosh.c b/math/b_ccosh.c
new file mode 100644
index 0000000..84de208
--- /dev/null
+++ b/math/b_ccosh.c
@@ -0,0 +1,154 @@ 
+/* 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.
+
+   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>
+
+CFLOAT
+M_DECL_FUNC (__ccosh) (CFLOAT x)
+{
+  CFLOAT 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) ((M_MAX_EXP - 1) * M_MLIT (M_LN2));
+	  FLOAT sinix, cosix;
+
+	  if (__glibc_likely (M_FABS (__imag__ x) > M_MIN))
+	    {
+	      M_SINCOS (__imag__ x, &sinix, &cosix);
+	    }
+	  else
+	    {
+	      sinix = __imag__ x;
+	      cosix = M_LIT (1.0);
+	    }
+
+	  if (M_FABS (__real__ x) > t)
+	    {
+	      FLOAT exp_t = M_EXP (t);
+	      FLOAT rx = M_FABS (__real__ x);
+	      if (signbit (__real__ x))
+		sinix = -sinix;
+	      rx -= t;
+	      sinix *= exp_t / M_LIT (2.0);
+	      cosix *= exp_t / M_LIT (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 = M_MAX * cosix;
+		  __imag__ retval = M_MAX * sinix;
+		}
+	      else
+		{
+		  FLOAT exp_val = M_EXP (rx);
+		  __real__ retval = exp_val * cosix;
+		  __imag__ retval = exp_val * sinix;
+		}
+	    }
+	  else
+	    {
+	      __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 == M_LIT (0.0) ? M_LIT (0.0) : M_NAN;
+	  __real__ retval = M_NAN + M_NAN;
+
+	  if (icls == FP_INFINITE)
+	    feraiseexcept (FE_INVALID);
+	}
+    }
+#if M_TYPE == M_DOUBLE
+  else if (rcls == FP_INFINITE)
+#else
+  else if (__glibc_likely (rcls == FP_INFINITE))
+#endif
+    {
+      /* Real part is infinite.  */
+      if (__glibc_likely (icls > FP_ZERO))
+	{
+	  /* Imaginary part is finite.  */
+	  FLOAT sinix, cosix;
+
+	  if (__glibc_likely (M_FABS (__imag__ x) > M_MIN))
+	    {
+	      M_SINCOS (__imag__ x, &sinix, &cosix);
+	    }
+	  else
+	    {
+	      sinix = __imag__ x;
+	      cosix = M_LIT (1.0);
+	    }
+
+	  __real__ retval = M_COPYSIGN (M_HUGE_VAL, cosix);
+	  __imag__ retval = (M_COPYSIGN (M_HUGE_VAL, sinix)
+			     * M_COPYSIGN (M_LIT (1.0), __real__ x));
+	}
+      else if (icls == FP_ZERO)
+	{
+	  /* Imaginary part is 0.0.  */
+	  __real__ retval = M_HUGE_VAL;
+	  __imag__ retval = __imag__ x * M_COPYSIGN (M_LIT (1.0), __real__ x);
+	}
+      else
+	{
+	  /* The addition raises the invalid exception.  */
+	  __real__ retval = M_HUGE_VAL;
+	  __imag__ retval = M_NAN + M_NAN;
+
+#if M_TYPE != M_FLOAT || defined (FE_INVALID)
+	  if (icls == FP_INFINITE)
+	    feraiseexcept (FE_INVALID);
+#endif
+	}
+    }
+  else
+    {
+      __real__ retval = M_NAN;
+      __imag__ retval = __imag__ x == M_LIT (0.0) ? __imag__ x : M_NAN;
+    }
+
+  return retval;
+}
+
+declare_mgen_alias (__ccosh, ccosh);
+
+#if M_LIBM_NEED_COMPAT (carg)
+  declare_mgen_libm_compat (__ccosh, ccosh)
+#endif
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_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_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_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_ccoshf.c b/math/s_ccoshf.c
deleted file mode 100644
index 610a749..0000000
--- a/math/s_ccoshf.c
+++ /dev/null
@@ -1,147 +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 (__glibc_likely (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 ("");
-
-#ifdef FE_INVALID
-	  if (icls == FP_INFINITE)
-	    feraiseexcept (FE_INVALID);
-#endif
-	}
-    }
-  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 680da3a..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 (__glibc_likely (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/Makefile b/sysdeps/alpha/fpu/Makefile
index c49c302..ddd86ba 100644
--- a/sysdeps/alpha/fpu/Makefile
+++ b/sysdeps/alpha/fpu/Makefile
@@ -1,4 +1,6 @@ 
 # Inhibit generation of these math files as they are supplied via
 # the respectic s_*.c versions here.
-libm-gen-calls-override = g_cabs_f g_carg_f g_cimag_f g_creal_f g_conj_f
-libm-gen-replacement-calls = cabsf cargf cimagf crealf conjf
+libm-gen-calls-override = g_cabs_f g_carg_f g_cimag_f g_creal_f g_conj_f \
+	g_cacos_f g_cacosh_f g_ccos_f g_ccosh_f
+libm-gen-replacement-calls = cabsf cargf cimagf crealf conjf \
+	s_cacosf s_cacoshf s_ccosf s_ccoshf
diff --git a/sysdeps/alpha/fpu/s_cacosf.c b/sysdeps/alpha/fpu/s_cacosf.c
index 25e21bb..791495f 100644
--- a/sysdeps/alpha/fpu/s_cacosf.c
+++ b/sysdeps/alpha/fpu/s_cacosf.c
@@ -24,11 +24,19 @@ 
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
+
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_cacos.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..bf907db 100644
--- a/sysdeps/alpha/fpu/s_cacoshf.c
+++ b/sysdeps/alpha/fpu/s_cacoshf.c
@@ -24,11 +24,18 @@ 
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
+
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_cacosh.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..bbfd3d7 100644
--- a/sysdeps/alpha/fpu/s_ccosf.c
+++ b/sysdeps/alpha/fpu/s_ccosf.c
@@ -24,14 +24,19 @@ 
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __ccosf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_ccos.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..b3018c9 100644
--- a/sysdeps/alpha/fpu/s_ccoshf.c
+++ b/sysdeps/alpha/fpu/s_ccoshf.c
@@ -24,14 +24,19 @@ 
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __ccoshf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_ccosh.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_ccoshf (c1_cfloat_decl (x))
diff --git a/sysdeps/ieee754/ldbl-opt/math-type-macros.h b/sysdeps/ieee754/ldbl-opt/math-type-macros.h
index f963f77..3e3b9f7 100644
--- a/sysdeps/ieee754/ldbl-opt/math-type-macros.h
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros.h
@@ -7,5 +7,9 @@ 
 #define LDOUBLE_cimagl_libm_version GLIBC_2_1
 #define LDOUBLE_conjl_libm_version GLIBC_2_1
 #define LDOUBLE_creall_libm_version GLIBC_2_1
+#define LDOUBLE_cacosl_libm_version GLIBC_2_1
+#define LDOUBLE_cacoshl_libm_version GLIBC_2_1
+#define LDOUBLE_ccosl_libm_version GLIBC_2_1
+#define LDOUBLE_ccoshl_libm_version GLIBC_2_1
 
 #include_next <math-type-macros.h>
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/b_ccosh.c b/sysdeps/m68k/m680x0/fpu/b_ccosh.c
new file mode 100644
index 0000000..6f3de62
--- /dev/null
+++ b/sysdeps/m68k/m680x0/fpu/b_ccosh.c
@@ -0,0 +1,68 @@ 
+/* Complex cosine hyperbole function.  m68k fpu version
+   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>.
+
+   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 "mathimpl.h"
+
+#define s(name) M_FUNC (name)
+#define m81(func) __m81_u(s(func))
+
+CFLOAT
+s(__ccosh) (CFLOAT x)
+{
+  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 sin_ix, cos_ix;
+
+      __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_ix), "=f" (cos_ix)
+	     : "f" (__imag__ x));
+      __real__ retval = cos_ix * m81(__ieee754_cosh) (__real__ x);
+      if (ix_cond & __M81_COND_ZERO)
+	__imag__ retval = (signbit (__real__ x)
+			   ? -__imag__ x : __imag__ x);
+      else
+	__imag__ retval = sin_ix * m81(__ieee754_sinh) (__real__ x);
+    }
+  else
+    {
+      unsigned long rx_cond = __m81_test (__real__ x);
+
+      if (rx_cond & __M81_COND_ZERO)
+	{
+	  __real__ retval = __imag__ x - __imag__ x;
+	  __imag__ retval = __real__ x;
+	}
+      else
+	{
+	  if (rx_cond & __M81_COND_INF)
+	    __real__ retval = s(fabs) (__real__ x);
+	  else
+	    __real__ retval = s(__nan) ("");
+	  __imag__ retval = __imag__ x - __imag__ x;
+	}
+    }
+
+  return retval;
+}
+weak_alias (s(__ccosh), s(ccosh))
diff --git a/sysdeps/m68k/m680x0/fpu/s_ccosh.c b/sysdeps/m68k/m680x0/fpu/s_ccosh.c
deleted file mode 100644
index 47a4fb0..0000000
--- a/sysdeps/m68k/m680x0/fpu/s_ccosh.c
+++ /dev/null
@@ -1,76 +0,0 @@ 
-/* Complex cosine hyperbole function.  m68k fpu version
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>.
-
-   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 "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 m81(func) __m81_u(s(func))
-
-__complex__ float_type
-s(__ccosh) (__complex__ float_type x)
-{
-  __complex__ float_type 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;
-
-      __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_ix), "=f" (cos_ix)
-	     : "f" (__imag__ x));
-      __real__ retval = cos_ix * m81(__ieee754_cosh) (__real__ x);
-      if (ix_cond & __M81_COND_ZERO)
-	__imag__ retval = (signbit (__real__ x)
-			   ? -__imag__ x : __imag__ x);
-      else
-	__imag__ retval = sin_ix * m81(__ieee754_sinh) (__real__ x);
-    }
-  else
-    {
-      unsigned long rx_cond = __m81_test (__real__ x);
-
-      if (rx_cond & __M81_COND_ZERO)
-	{
-	  __real__ retval = __imag__ x - __imag__ x;
-	  __imag__ retval = __real__ x;
-	}
-      else
-	{
-	  if (rx_cond & __M81_COND_INF)
-	    __real__ retval = s(fabs) (__real__ x);
-	  else
-	    __real__ retval = s(__nan) ("");
-	  __imag__ retval = __imag__ x - __imag__ x;
-	}
-    }
-
-  return retval;
-}
-weak_alias (s(__ccosh), s(ccosh))
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>