public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/6] Generate Complex functions from a common template.
@ 2016-06-30 22:20 ` Paul E. Murphy
  2016-06-30 22:21   ` [PATCH 5/6] Convert _Complex tangent functions to generated code Paul E. Murphy
                     ` (18 more replies)
  0 siblings, 19 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-06-30 22:20 UTC (permalink / raw)
  To: libc-alpha

This consolidates two patches floating around here.
https://sourceware.org/ml/libc-alpha/2016-06/msg01003.html
and
https://sourceware.org/ml/libc-alpha/2016-06/msg00991.html
into a single patch set, with some minor updates to fix
issues uncovered while testing.

Given that the freeze starts in less than a day.  I do
not oppose holding off until 2.25 development opens.


The intent is to more rapidly support additional float
types, while minimizing the large amount of duplication
which comes from the current build structure.

The first patch simplifies the math/Makefile to more
readily support new types while adding some simple
hooks to start refactoring the large number of files
supporting the _Complex float abi.

The second patch introduces basic template files which
can be overridden via sysdeps, or individually overridden
as is the case when supporting the old alpha ABI. The
trivial complex functions are converted (cabs, carj,
cimag, creal, conj).

The third patch converts the complex sine functions.

The fourth patch converts the complex cosine functions.

The fifth patch converts the complex tangent functions.

The sixth patch converts the remaining 6 complex functions.


Of note is the interactions of NO_LONG_DOUBLE, ldbl-opt,
m68k, alpha, and some minor drift in few functions.

I have run build tests on arm, alpha, ppc64, m68k, and
x86_64 to verify the changes have neither altered
the generated, nor altered the symbols.  I think this
is sufficient to cover all valid configurations still
work and have not changed.

math-type-macros.h hides much of the complexity of the
aliasing for the common case, with cpow10 beings the
exception.  Likewise, some heavily used functions
(i.e more than 5 instances) have a dedicated macro
to minimize the verbosity these patches add.

m68k and alpha override certain files to support
dedicated FP hardware, or old _Complex float ABI.
Appropriate measures are taken to simplify and
minimize redundancy.

Finally, a few functions have some very minor drift
between the float, double, and ldouble variants. I
have preserved these in order to keep my sanity
when validating the generated code has not changed
meaningifully.

Paul E. Murphy (6):
  Refactor part of math Makefile
  Support for type-generic libm function implementations libm
  Convert _Complex cosine functions to generated code
  Convert _Complex sine functions to generated code
  Convert _Complex tangent functions to generated code
  Convert remaining complex function to generated files

 Makeconfig                                  |   2 +-
 math/Makefile                               | 176 +++++++++++++++-------
 math/b_cabs.c                               |  33 +++++
 math/b_cacos.c                              |  59 ++++++++
 math/b_cacosh.c                             |  97 ++++++++++++
 math/b_carg.c                               |  33 +++++
 math/b_casin.c                              |  67 +++++++++
 math/b_casinh.c                             |  76 ++++++++++
 math/b_catan.c                              | 146 +++++++++++++++++++
 math/b_catanh.c                             | 140 ++++++++++++++++++
 math/b_ccos.c                               |  40 +++++
 math/b_ccosh.c                              | 154 +++++++++++++++++++
 math/b_cexp.c                               | 157 ++++++++++++++++++++
 math/b_cimag.c                              |  32 ++++
 math/b_clog.c                               | 122 ++++++++++++++++
 math/b_clog10.c                             | 146 +++++++++++++++++++
 math/b_conj.c                               |  32 ++++
 math/b_cpow.c                               |  33 +++++
 math/b_cproj.c                              |  45 ++++++
 math/b_creal.c                              |  32 ++++
 math/b_csin.c                               | 172 ++++++++++++++++++++++
 math/b_csinh.c                              | 173 ++++++++++++++++++++++
 math/b_csqrt.c                              | 165 +++++++++++++++++++++
 math/b_ctan.c                               | 130 +++++++++++++++++
 math/b_ctanh.c                              | 130 +++++++++++++++++
 math/b_k_casinh.c                           | 213 +++++++++++++++++++++++++++
 math/cabs.c                                 |  32 ----
 math/cabsf.c                                |  28 ----
 math/cabsl.c                                |  28 ----
 math/carg.c                                 |  32 ----
 math/cargf.c                                |  28 ----
 math/cargl.c                                |  28 ----
 math/cimag.c                                |  31 ----
 math/cimagf.c                               |  27 ----
 math/cimagl.c                               |  27 ----
 math/conj.c                                 |  31 ----
 math/conjf.c                                |  27 ----
 math/conjl.c                                |  27 ----
 math/creal.c                                |  31 ----
 math/crealf.c                               |  27 ----
 math/creall.c                               |  27 ----
 math/k_casinh.c                             | 210 --------------------------
 math/k_casinhf.c                            | 212 ---------------------------
 math/k_casinhl.c                            | 219 ----------------------------
 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_casin.c                              |  66 ---------
 math/s_casinf.c                             |  64 --------
 math/s_casinh.c                             |  73 ----------
 math/s_casinhf.c                            |  71 ---------
 math/s_casinhl.c                            |  69 ---------
 math/s_casinl.c                             |  62 --------
 math/s_catan.c                              | 143 ------------------
 math/s_catanf.c                             | 143 ------------------
 math/s_catanh.c                             | 137 -----------------
 math/s_catanhf.c                            | 137 -----------------
 math/s_catanhl.c                            | 141 ------------------
 math/s_catanl.c                             | 147 -------------------
 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 -----
 math/s_cexp.c                               | 157 --------------------
 math/s_cexpf.c                              | 155 --------------------
 math/s_cexpl.c                              | 153 -------------------
 math/s_clog.c                               | 118 ---------------
 math/s_clog10.c                             | 124 ----------------
 math/s_clog10f.c                            | 122 ----------------
 math/s_clog10l.c                            | 127 ----------------
 math/s_clogf.c                              | 116 ---------------
 math/s_clogl.c                              | 121 ---------------
 math/s_cpow.c                               |  33 -----
 math/s_cpowf.c                              |  31 ----
 math/s_cpowl.c                              |  29 ----
 math/s_cproj.c                              |  44 ------
 math/s_cprojf.c                             |  42 ------
 math/s_cprojl.c                             |  40 -----
 math/s_csin.c                               | 171 ----------------------
 math/s_csinf.c                              | 169 ---------------------
 math/s_csinh.c                              | 166 ---------------------
 math/s_csinhf.c                             | 166 ---------------------
 math/s_csinhl.c                             | 164 ---------------------
 math/s_csinl.c                              | 167 ---------------------
 math/s_csqrt.c                              | 165 ---------------------
 math/s_csqrtf.c                             | 163 ---------------------
 math/s_csqrtl.c                             | 161 --------------------
 math/s_ctan.c                               | 129 ----------------
 math/s_ctanf.c                              | 127 ----------------
 math/s_ctanh.c                              | 129 ----------------
 math/s_ctanhf.c                             | 127 ----------------
 math/s_ctanhl.c                             | 132 -----------------
 math/s_ctanl.c                              | 132 -----------------
 math/test-ildoubl.c                         |  25 ----
 math/test-ildouble.c                        |  25 ++++
 scripts/sysd-rules.awk                      |   5 +-
 sysdeps/alpha/fpu/Makefile                  |  10 ++
 sysdeps/alpha/fpu/s_cacosf.c                |  12 +-
 sysdeps/alpha/fpu/s_cacoshf.c               |  11 +-
 sysdeps/alpha/fpu/s_casinf.c                |  13 +-
 sysdeps/alpha/fpu/s_casinhf.c               |  13 +-
 sysdeps/alpha/fpu/s_catanf.c                |  13 +-
 sysdeps/alpha/fpu/s_catanhf.c               |  13 +-
 sysdeps/alpha/fpu/s_ccosf.c                 |  13 +-
 sysdeps/alpha/fpu/s_ccoshf.c                |  13 +-
 sysdeps/alpha/fpu/s_cexpf.c                 |  13 +-
 sysdeps/alpha/fpu/s_clog10f.c               |  15 +-
 sysdeps/alpha/fpu/s_clogf.c                 |  13 +-
 sysdeps/alpha/fpu/s_cpowf.c                 |  13 +-
 sysdeps/alpha/fpu/s_cprojf.c                |  13 +-
 sysdeps/alpha/fpu/s_csinf.c                 |  13 +-
 sysdeps/alpha/fpu/s_csinhf.c                |  13 +-
 sysdeps/alpha/fpu/s_csqrtf.c                |  13 +-
 sysdeps/alpha/fpu/s_ctanf.c                 |  13 +-
 sysdeps/alpha/fpu/s_ctanhf.c                |  13 +-
 sysdeps/generic/math-type-macros.h          | 159 ++++++++++++++++++++
 sysdeps/ieee754/Makeconfig                  |   6 +
 sysdeps/ieee754/ldbl-opt/cabs.c             |   6 -
 sysdeps/ieee754/ldbl-opt/cabsl.c            |   6 -
 sysdeps/ieee754/ldbl-opt/carg.c             |   6 -
 sysdeps/ieee754/ldbl-opt/cargl.c            |   6 -
 sysdeps/ieee754/ldbl-opt/cimag.c            |   6 -
 sysdeps/ieee754/ldbl-opt/cimagl.c           |   6 -
 sysdeps/ieee754/ldbl-opt/conj.c             |   6 -
 sysdeps/ieee754/ldbl-opt/conjl.c            |   6 -
 sysdeps/ieee754/ldbl-opt/creal.c            |   6 -
 sysdeps/ieee754/ldbl-opt/creall.c           |   6 -
 sysdeps/ieee754/ldbl-opt/math-type-macros.h |  30 ++++
 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_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_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_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/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        |  10 --
 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_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 -
 sysdeps/ieee754/ldbl-opt/s_csqrt.c          |   6 -
 sysdeps/ieee754/ldbl-opt/s_csqrtl.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 -
 sysdeps/m68k/m680x0/fpu/b_ccosh.c           |  68 +++++++++
 sysdeps/m68k/m680x0/fpu/b_cexp.c            | 129 ++++++++++++++++
 sysdeps/m68k/m680x0/fpu/b_csin.c            |  59 ++++++++
 sysdeps/m68k/m680x0/fpu/b_csinh.c           |  62 ++++++++
 sysdeps/m68k/m680x0/fpu/s_ccosh.c           |  76 ----------
 sysdeps/m68k/m680x0/fpu/s_ccoshf.c          |   3 -
 sysdeps/m68k/m680x0/fpu/s_ccoshl.c          |   3 -
 sysdeps/m68k/m680x0/fpu/s_cexp.c            | 136 -----------------
 sysdeps/m68k/m680x0/fpu/s_cexpf.c           |   3 -
 sysdeps/m68k/m680x0/fpu/s_cexpl.c           |   3 -
 sysdeps/m68k/m680x0/fpu/s_csin.c            |  67 ---------
 sysdeps/m68k/m680x0/fpu/s_csinf.c           |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinh.c           |  69 ---------
 sysdeps/m68k/m680x0/fpu/s_csinhf.c          |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinhl.c          |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinl.c           |   3 -
 185 files changed, 3265 insertions(+), 7804 deletions(-)
 create mode 100644 math/b_cabs.c
 create mode 100644 math/b_cacos.c
 create mode 100644 math/b_cacosh.c
 create mode 100644 math/b_carg.c
 create mode 100644 math/b_casin.c
 create mode 100644 math/b_casinh.c
 create mode 100644 math/b_catan.c
 create mode 100644 math/b_catanh.c
 create mode 100644 math/b_ccos.c
 create mode 100644 math/b_ccosh.c
 create mode 100644 math/b_cexp.c
 create mode 100644 math/b_cimag.c
 create mode 100644 math/b_clog.c
 create mode 100644 math/b_clog10.c
 create mode 100644 math/b_conj.c
 create mode 100644 math/b_cpow.c
 create mode 100644 math/b_cproj.c
 create mode 100644 math/b_creal.c
 create mode 100644 math/b_csin.c
 create mode 100644 math/b_csinh.c
 create mode 100644 math/b_csqrt.c
 create mode 100644 math/b_ctan.c
 create mode 100644 math/b_ctanh.c
 create mode 100644 math/b_k_casinh.c
 delete mode 100644 math/cabs.c
 delete mode 100644 math/cabsf.c
 delete mode 100644 math/cabsl.c
 delete mode 100644 math/carg.c
 delete mode 100644 math/cargf.c
 delete mode 100644 math/cargl.c
 delete mode 100644 math/cimag.c
 delete mode 100644 math/cimagf.c
 delete mode 100644 math/cimagl.c
 delete mode 100644 math/conj.c
 delete mode 100644 math/conjf.c
 delete mode 100644 math/conjl.c
 delete mode 100644 math/creal.c
 delete mode 100644 math/crealf.c
 delete mode 100644 math/creall.c
 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_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_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_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_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 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_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 math/s_csqrt.c
 delete mode 100644 math/s_csqrtf.c
 delete mode 100644 math/s_csqrtl.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 math/test-ildoubl.c
 create mode 100644 math/test-ildouble.c
 create mode 100644 sysdeps/alpha/fpu/Makefile
 create mode 100644 sysdeps/generic/math-type-macros.h
 create mode 100644 sysdeps/ieee754/Makeconfig
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabs.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabsl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/carg.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cargl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimag.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimagl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conj.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conjl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creal.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creall.c
 create mode 100644 sysdeps/ieee754/ldbl-opt/math-type-macros.h
 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_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_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_ccos.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ccosh.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ccoshl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ccosl.c
 delete mode 100644 sysdeps/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_clog10l.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_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
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csqrt.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csqrtl.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
 create mode 100644 sysdeps/m68k/m680x0/fpu/b_ccosh.c
 create mode 100644 sysdeps/m68k/m680x0/fpu/b_cexp.c
 create mode 100644 sysdeps/m68k/m680x0/fpu/b_csin.c
 create mode 100644 sysdeps/m68k/m680x0/fpu/b_csinh.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
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_cexp.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_cexpf.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_cexpl.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csin.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinf.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinh.c
 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

-- 
2.4.11

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

* [PATCH 5/6] Convert _Complex tangent functions to generated code
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
@ 2016-06-30 22:21   ` Paul E. Murphy
  2016-06-30 22:21   ` [PATCH 3/6] Convert _Complex cosine " Paul E. Murphy
                     ` (17 subsequent siblings)
  18 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-06-30 22:21 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 b_c{,a}tan{,h}.c with the exception
of alpha.

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

	* math/s_catan.c: Refactor into b_catan.c
	* math/s_catanh.c: Refactor into b_catanh.c
	* math/s_ctan.c: Refactor into b_ctan.c
	* math/s_ctanh.c: Refactor into b_ctanh.c
	* sysdeps/m68k/m680x0/fpu/s_ctanh.c: Refactor into ../b_ctanh.c

	* math/b_catan.c: New file
	* math/b_catanh.c: New file
	* math/b_ctan.c: New file
	* math/b_ctanh.c: New file

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

	* sysdeps/alpha/fpu/Makefile: Update to use template file
	* sysdeps/alpha/fpu/s_catanf.c: Update to use template file
	* sysdeps/alpha/fpu/s_catanhf.c: Update to use template file
	* sysdeps/alpha/fpu/s_ctanf.c: Update to use template file
	* sysdeps/alpha/fpu/s_ctanhf.c: Update to use template file

	* sysdeps/ieee754/ldbl-opt/math-type-macros.h: Add compat
	versions.
---
 math/Makefile                               |   5 +-
 math/b_catan.c                              | 146 +++++++++++++++++++++++++++
 math/b_catanh.c                             | 140 ++++++++++++++++++++++++++
 math/b_ctan.c                               | 130 ++++++++++++++++++++++++
 math/b_ctanh.c                              | 130 ++++++++++++++++++++++++
 math/s_catan.c                              | 143 ---------------------------
 math/s_catanf.c                             | 143 ---------------------------
 math/s_catanh.c                             | 137 --------------------------
 math/s_catanhf.c                            | 137 --------------------------
 math/s_catanhl.c                            | 141 --------------------------
 math/s_catanl.c                             | 147 ----------------------------
 math/s_ctan.c                               | 129 ------------------------
 math/s_ctanf.c                              | 127 ------------------------
 math/s_ctanh.c                              | 129 ------------------------
 math/s_ctanhf.c                             | 127 ------------------------
 math/s_ctanhl.c                             | 132 -------------------------
 math/s_ctanl.c                              | 132 -------------------------
 sysdeps/alpha/fpu/Makefile                  |   8 +-
 sysdeps/alpha/fpu/s_catanf.c                |  13 ++-
 sysdeps/alpha/fpu/s_catanhf.c               |  13 ++-
 sysdeps/alpha/fpu/s_ctanf.c                 |  13 ++-
 sysdeps/alpha/fpu/s_ctanhf.c                |  13 ++-
 sysdeps/ieee754/ldbl-opt/math-type-macros.h |   4 +
 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 --
 31 files changed, 592 insertions(+), 1695 deletions(-)
 create mode 100644 math/b_catan.c
 create mode 100644 math/b_catanh.c
 create mode 100644 math/b_ctan.c
 create mode 100644 math/b_ctanh.c
 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 ac91a84..63a385d 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -55,7 +55,7 @@ libm-support = s_lib_version s_matherr s_signgam			\
 # 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 g_cacos_F \
 	g_cacosh_F g_ccos_F g_ccosh_F g_casin_F g_csin_F g_casinh_F	  \
-	g_k_casinh_F g_csinh_F
+	g_k_casinh_F g_csinh_F g_catanh_F g_catan_F g_ctan_F g_ctanh_F
 
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
@@ -74,8 +74,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/b_catan.c b/math/b_catan.c
new file mode 100644
index 0000000..64179b7
--- /dev/null
+++ b/math/b_catan.c
@@ -0,0 +1,146 @@
+/* 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 M_LIT (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>
+
+CFLOAT
+M_DECL_FUNC (__catan) (CFLOAT x)
+{
+  CFLOAT 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 = M_COPYSIGN (M_MLIT (M_PI_2), __real__ x);
+	  __imag__ res = M_COPYSIGN (M_LIT (0.0), __imag__ x);
+	}
+      else if (icls == FP_INFINITE)
+	{
+	  if (rcls >= FP_ZERO)
+	    __real__ res = M_COPYSIGN (M_MLIT (M_PI_2), __real__ x);
+	  else
+	    __real__ res = M_NAN;
+	  __imag__ res = M_COPYSIGN (M_LIT (0.0), __imag__ x);
+	}
+      else if (icls == FP_ZERO || icls == FP_INFINITE)
+	{
+	  __real__ res = M_NAN;
+	  __imag__ res = M_COPYSIGN (M_LIT (0.0), __imag__ x);
+	}
+      else
+	{
+	  __real__ res = M_NAN;
+	  __imag__ res = M_NAN;
+	}
+    }
+  else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
+    {
+      res = x;
+    }
+  else
+    {
+      if (M_FABS (__real__ x) >= M_LIT (16.0) / M_EPSILON
+	  || M_FABS (__imag__ x) >= M_LIT (16.0) / M_EPSILON)
+	{
+	  __real__ res = M_COPYSIGN (M_MLIT (M_PI_2), __real__ x);
+	  if (M_FABS (__real__ x) <= M_LIT (1.0))
+	    __imag__ res = M_LIT (1.0) / __imag__ x;
+	  else if (M_FABS (__imag__ x) <= M_LIT (1.0))
+	    __imag__ res = __imag__ x / __real__ x / __real__ x;
+	  else
+	    {
+	      FLOAT h = M_HYPOT (__real__ x / M_LIT (2.0),
+				 __imag__ x / M_LIT (2.0));
+	      __imag__ res = __imag__ x / h / h / M_LIT (4.0);
+	    }
+	}
+      else
+	{
+	  FLOAT den, absx, absy;
+
+	  absx = M_FABS (__real__ x);
+	  absy = M_FABS (__imag__ x);
+	  if (absx < absy)
+	    {
+	      FLOAT t = absx;
+	      absx = absy;
+	      absy = t;
+	    }
+
+	  if (absy < M_EPSILON / M_LIT (2.0))
+	    {
+	      den = (M_LIT (1.0) - absx) * (M_LIT (1.0) + absx);
+	      if (den == -M_LIT (0.0))
+		den = M_LIT (0.0);
+	    }
+	  else if (absx >= M_LIT (1.0))
+	    den = (M_LIT (1.0) - absx) * (M_LIT (1.0) + absx) - absy * absy;
+	  else if (absx >= M_LIT (0.75) || absy >= M_LIT (0.5))
+	    den = -M_FUNC (__x2y2m1) (absx, absy);
+	  else
+	    den = (M_LIT (1.0) - absx) * (M_LIT (1.0) + absx) - absy * absy;
+
+	  __real__ res = M_LIT (0.5) * M_ATAN2 (M_LIT (2.0) * __real__ x, den);
+
+	  if (M_FABS (__imag__ x) == M_LIT (1.0)
+	      && 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
+	    {
+	      FLOAT r2 = M_LIT (0.0), num, f;
+
+	      if (M_FABS (__real__ x) >= M_EPSILON * M_EPSILON)
+		r2 = __real__ x * __real__ x;
+
+	      num = __imag__ x + M_LIT (1.0);
+	      num = r2 + num * num;
+
+	      den = __imag__ x - M_LIT (1.0);
+	      den = r2 + den * den;
+
+	      f = num / den;
+	      if (f < M_LIT (0.5))
+		__imag__ res = M_LIT (0.25) * M_LOG (f);
+	      else
+		{
+		  num = M_LIT (4.0) * __imag__ x;
+		  __imag__ res = M_LIT (0.25) * M_LOG1P (num / den);
+		}
+	    }
+	}
+
+      math_check_force_underflow_complex (res);
+    }
+
+  return res;
+}
+
+declare_mgen_alias (__catan, catan)
+
+#if M_LIBM_NEED_COMPAT (catan)
+  declare_mgen_libm_compat (__catan, catan)
+#endif
diff --git a/math/b_catanh.c b/math/b_catanh.c
new file mode 100644
index 0000000..5795272
--- /dev/null
+++ b/math/b_catanh.c
@@ -0,0 +1,140 @@
+/* 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 M_LIT (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>
+
+CFLOAT
+M_DECL_FUNC (__catanh) (CFLOAT x)
+{
+  CFLOAT 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 = M_COPYSIGN (M_LIT (0.0), __real__ x);
+	  __imag__ res = M_COPYSIGN (M_MLIT (M_PI_2), __imag__ x);
+	}
+      else if (rcls == FP_INFINITE || rcls == FP_ZERO)
+	{
+	  __real__ res = M_COPYSIGN (M_LIT (0.0), __real__ x);
+	  if (icls >= FP_ZERO)
+	    __imag__ res = M_COPYSIGN (M_MLIT (M_PI_2), __imag__ x);
+	  else
+	    __imag__ res = M_NAN;
+	}
+      else
+	{
+	  __real__ res = M_NAN;
+	  __imag__ res = M_NAN;
+	}
+    }
+  else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO))
+    {
+      res = x;
+    }
+  else
+    {
+      if (M_FABS (__real__ x) >= M_LIT (16.0) / M_EPSILON
+	  || M_FABS (__imag__ x) >= M_LIT (16.0) / M_EPSILON)
+	{
+	  __imag__ res = M_COPYSIGN (M_MLIT (M_PI_2), __imag__ x);
+	  if (M_FABS (__imag__ x) <= M_LIT (1.0))
+	    __real__ res = M_LIT (1.0) / __real__ x;
+	  else if (M_FABS (__real__ x) <= M_LIT (1.0))
+	    __real__ res = __real__ x / __imag__ x / __imag__ x;
+	  else
+	    {
+	      FLOAT h = M_HYPOT (__real__ x / M_LIT (2.0),
+				 __imag__ x / M_LIT (2.0));
+	      __real__ res = __real__ x / h / h / M_LIT (4.0);
+	    }
+	}
+      else
+	{
+	  if (M_FABS (__real__ x) == M_LIT (1.0)
+	      && 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
+	    {
+	      FLOAT i2 = M_LIT (0.0);
+	      if (M_FABS (__imag__ x) >= M_EPSILON * M_EPSILON)
+		i2 = __imag__ x * __imag__ x;
+
+	      FLOAT num = M_LIT (1.0) + __real__ x;
+	      num = i2 + num * num;
+
+	      FLOAT den = M_LIT (1.0) - __real__ x;
+	      den = i2 + den * den;
+
+	      FLOAT f = num / den;
+	      if (f < M_LIT (0.5))
+		__real__ res = M_LIT (0.25) * M_LOG (f);
+	      else
+		{
+		  num = M_LIT (4.0) * __real__ x;
+		  __real__ res = M_LIT (0.25) * M_LOG1P (num / den);
+		}
+	    }
+
+	  FLOAT absx, absy, den;
+
+	  absx = M_FABS (__real__ x);
+	  absy = M_FABS (__imag__ x);
+	  if (absx < absy)
+	    {
+	      FLOAT t = absx;
+	      absx = absy;
+	      absy = t;
+	    }
+
+	  if (absy < M_EPSILON / M_LIT (2.0))
+	    {
+	      den = (M_LIT (1.0) - absx) * (M_LIT (1.0) + absx);
+	      if (den == -M_LIT (0.0))
+		den = M_LIT (0.0);
+	    }
+	  else if (absx >= M_LIT (1.0))
+	    den = (M_LIT (1.0) - absx) * (M_LIT (1.0) + absx) - absy * absy;
+	  else if (absx >= M_LIT (0.75) || absy >= M_LIT (0.5))
+	    den = -M_FUNC (__x2y2m1) (absx, absy);
+	  else
+	    den = (M_LIT (1.0) - absx) * (M_LIT (1.0) + absx) - absy * absy;
+
+	  __imag__ res = M_LIT (0.5) * M_ATAN2 (M_LIT (2.0) * __imag__ x, den);
+	}
+
+      math_check_force_underflow_complex (res);
+    }
+
+  return res;
+}
+
+declare_mgen_alias (__catanh, catanh)
+
+#if M_LIBM_NEED_COMPAT (catanh)
+  declare_mgen_libm_compat (__catanh, catanh)
+#endif
diff --git a/math/b_ctan.c b/math/b_ctan.c
new file mode 100644
index 0000000..a83a9a5
--- /dev/null
+++ b/math/b_ctan.c
@@ -0,0 +1,130 @@
+/* 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 M_LIT (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 (__ctan) (CFLOAT x)
+{
+  CFLOAT res;
+
+  if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x)))
+    {
+      if (isinf (__imag__ x))
+	{
+	  if (isfinite (__real__ x) && M_FABS (__real__ x) > M_LIT (1.0))
+	    {
+	      FLOAT sinrx, cosrx;
+	      M_SINCOS (__real__ x, &sinrx, &cosrx);
+	      __real__ res = M_COPYSIGN (M_LIT (0.0), sinrx * cosrx);
+	    }
+	  else
+	    __real__ res = M_COPYSIGN (M_LIT (0.0), __real__ x);
+	  __imag__ res = M_COPYSIGN (M_LIT (1.0), __imag__ x);
+	}
+      else if (__real__ x == M_LIT (0.0))
+	{
+	  res = x;
+	}
+      else
+	{
+	  __real__ res = M_NAN;
+	  __imag__ res = M_NAN;
+
+	  if (isinf (__real__ x))
+	    feraiseexcept (FE_INVALID);
+	}
+    }
+  else
+    {
+      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 (M_FABS (__real__ x) > M_MIN))
+	{
+	  M_SINCOS (__real__ x, &sinrx, &cosrx);
+	}
+      else
+	{
+	  sinrx = __real__ x;
+	  cosrx = M_LIT (1.0);
+	}
+
+      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).  */
+	  FLOAT exp_2t = M_EXP (2 * t);
+
+	  __imag__ res = M_COPYSIGN (M_LIT (1.0), __imag__ x);
+	  __real__ res = 4 * sinrx * cosrx;
+	  __imag__ x = M_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 /= M_EXP (2 * __imag__ x);
+	}
+      else
+	{
+	  FLOAT sinhix, coshix;
+	  if (M_FABS (__imag__ x) > M_MIN)
+	    {
+	      sinhix = M_SINH (__imag__ x);
+	      coshix = M_COSH (__imag__ x);
+	    }
+	  else
+	    {
+	      sinhix = __imag__ x;
+	      coshix = M_LIT (1.0);
+	    }
+
+	  if (M_FABS (sinhix) > M_FABS (cosrx) * M_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;
+}
+
+declare_mgen_alias (__ctan, ctan)
+
+#if M_LIBM_NEED_COMPAT (ctan)
+  declare_mgen_libm_compat (__ctan, ctan)
+#endif
diff --git a/math/b_ctanh.c b/math/b_ctanh.c
new file mode 100644
index 0000000..7038162
--- /dev/null
+++ b/math/b_ctanh.c
@@ -0,0 +1,130 @@
+/* Complex hyperbole tangent for complex 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 M_LIT (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 (__ctanh) (CFLOAT x)
+{
+  CFLOAT res;
+
+  if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x)))
+    {
+      if (isinf (__real__ x))
+	{
+	  __real__ res = M_COPYSIGN (M_LIT (1.0), __real__ x);
+	  if (isfinite (__imag__ x) && M_FABS (__imag__ x) > M_LIT (1.0))
+	    {
+	      FLOAT sinix, cosix;
+	      M_SINCOS (__imag__ x, &sinix, &cosix);
+	      __imag__ res = M_COPYSIGN (M_LIT (0.0), sinix * cosix);
+	    }
+	  else
+	    __imag__ res = M_COPYSIGN (M_LIT (0.0), __imag__ x);
+	}
+      else if (__imag__ x == M_LIT (0.0))
+	{
+	  res = x;
+	}
+      else
+	{
+	  __real__ res = M_NAN;
+	  __imag__ res = M_NAN;
+
+	  if (isinf (__imag__ x))
+	    feraiseexcept (FE_INVALID);
+	}
+    }
+  else
+    {
+      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 (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)
+	{
+	  /* 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 = M_EXP (2 * t);
+
+	  __real__ res = M_COPYSIGN (M_LIT (1.0), __real__ x);
+	  __imag__ res = 4 * sinix * cosix;
+	  __real__ x = M_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 /= M_EXP (2 * __real__ x);
+	}
+      else
+	{
+	  FLOAT sinhrx, coshrx;
+	  if (M_FABS (__real__ x) > M_MIN)
+	    {
+	      sinhrx = M_SINH (__real__ x);
+	      coshrx = M_COSH (__real__ x);
+	    }
+	  else
+	    {
+	      sinhrx = __real__ x;
+	      coshrx = M_LIT (1.0);
+	    }
+
+	  if (M_FABS (sinhrx) > M_FABS (cosix) * M_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;
+}
+
+declare_mgen_alias (__ctanh, ctanh)
+
+#if M_LIBM_NEED_COMPAT (ctanh)
+  declare_mgen_libm_compat (__ctanh, ctanh)
+#endif
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_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_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_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_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/Makefile b/sysdeps/alpha/fpu/Makefile
index 3ae1451..d8ccf86 100644
--- a/sysdeps/alpha/fpu/Makefile
+++ b/sysdeps/alpha/fpu/Makefile
@@ -2,7 +2,7 @@
 # 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 \
 	g_cacos_f g_cacosh_f g_ccos_f g_ccosh_f g_casin_f g_csin_f	 \
-	g_casinh_f g_csinh_f
-libm-gen-replacement-calls = cabsf cargf cimagf crealf conjf \
-	s_cacosf s_cacoshf s_ccosf s_ccoshf s_casinf s_csinf \
-	s_casinhf s_csinhf
+	g_casinh_f g_csinh_f g_catan_f g_catanh_f g_ctan_f g_ctanh_f
+libm-gen-replacement-calls = cabsf cargf cimagf crealf conjf	\
+	s_cacosf s_cacoshf s_ccosf s_ccoshf s_casinf s_csinf	\
+	s_casinhf s_csinhf s_catanf s_catanhf s_ctanf s_ctanhf
diff --git a/sysdeps/alpha/fpu/s_catanf.c b/sysdeps/alpha/fpu/s_catanf.c
index 76c1718..bc2b7eb 100644
--- a/sysdeps/alpha/fpu/s_catanf.c
+++ b/sysdeps/alpha/fpu/s_catanf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __catanf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_catan.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..46b73b6 100644
--- a/sysdeps/alpha/fpu/s_catanhf.c
+++ b/sysdeps/alpha/fpu/s_catanhf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __catanhf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_catanh.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..fe9b619 100644
--- a/sysdeps/alpha/fpu/s_ctanf.c
+++ b/sysdeps/alpha/fpu/s_ctanf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __ctanf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_ctan.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..0d6e0dc 100644
--- a/sysdeps/alpha/fpu/s_ctanhf.c
+++ b/sysdeps/alpha/fpu/s_ctanhf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __ctanhf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_ctanh.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_ctanhf (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 061ba33..646489e 100644
--- a/sysdeps/ieee754/ldbl-opt/math-type-macros.h
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros.h
@@ -15,5 +15,9 @@
 #define LDOUBLE_csinl_libm_version GLIBC_2_1
 #define LDOUBLE_casinhl_libm_version GLIBC_2_1
 #define LDOUBLE_csinhl_libm_version GLIBC_2_1
+#define LDOUBLE_catanl_libm_version GLIBC_2_1
+#define LDOUBLE_catanhl_libm_version GLIBC_2_1
+#define LDOUBLE_ctanl_libm_version GLIBC_2_1
+#define LDOUBLE_ctanhl_libm_version GLIBC_2_1
 
 #include_next <math-type-macros.h>
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] 53+ messages in thread

* [PATCH 6/6] Convert remaining complex function to generated files
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (3 preceding siblings ...)
  2016-06-30 22:21   ` [PATCH 2/6] Support for type-generic libm function implementations libm Paul E. Murphy
@ 2016-06-30 22:21   ` Paul E. Murphy
  2016-06-30 22:21   ` [PATCH 4/6] Convert _Complex sine functions to generated code Paul E. Murphy
                     ` (13 subsequent siblings)
  18 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-06-30 22:21 UTC (permalink / raw)
  To: libc-alpha

Convert cpow, clog, clog10, cexp, csqrt, and cproj functions
into generated templates.  With the exception of clog10, the
transformation is identical to the previous patches.  clog10
needs some extra hackery as the __clog10* symbol was exposed
in days past, and thus required some extra hackery to
preserve this.

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

	* math/s_cexp.c: Refactor into
	* math/b_cexp.c: New file
	* math/s_cexpf.c: Removed
	* math/s_cexpl.c: Removed

	* math/s_clog10.c: Refactor into
	* math/b_clog10.c: New file
	* math/s_clog10f.c: Removed
	* math/s_clog10l.c: Removed

	* math/s_cpow.c: Refactor into
	* math/b_cpow.c: New file
	* math/s_cpowf.c: Removed
	* math/s_cpowl.c: Removed

	* math/s_clog.c: Refactor into
	* math/b_clog.c: New file
	* math/s_clogf.c: Removed
	* math/s_clogl.c: Removed

	* math/s_cproj.c: Refactor into
	* math/b_cproj.c: New file
	* math/s_cprojf.c: Removed
	* math/s_cprojl.c: Removed

	* math/s_csqrt.c: Refactor into
	* math/b_csqrt.c: New file
	* math/s_csqrtf.c: Removed
	* math/s_csqrtl.c: Removed

	* sysdeps/alpha/fpu/Makefile: Add overrides for _Complex
	float functions.
	* sysdeps/alpha/fpu/s_cexpf.c: Update to use tempated version.
	* sysdeps/alpha/fpu/s_clog10f.c: Update to use tempated version.
	* sysdeps/alpha/fpu/s_clogf.c: Update to use tempated version.
	* sysdeps/alpha/fpu/s_cpowf.c: Update to use tempated version.
	* sysdeps/alpha/fpu/s_cprojf.c: Update to use tempated version.
	* sysdeps/alpha/fpu/s_csqrtf.c: Update to use tempated version.

	* sysdeps/ieee754/ldbl-opt/math-type-macros.h: Add versioning
	information for newly refactored functions.

	* 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_clogl.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/m68k/m680x0/fpu/s_cexp.c: Refactor into
	* sysdeps/m68k/m680x0/fpu/b_cexp.c: New file
	* sysdeps/m68k/m680x0/fpu/s_cexpf.c: Removed
	* sysdeps/m68k/m680x0/fpu/s_cexpl.c: Removed
---
 math/Makefile                               |   5 +-
 math/b_cexp.c                               | 157 ++++++++++++++++++++++++++
 math/b_clog.c                               | 122 ++++++++++++++++++++
 math/b_clog10.c                             | 146 ++++++++++++++++++++++++
 math/b_cpow.c                               |  33 ++++++
 math/b_cproj.c                              |  45 ++++++++
 math/b_csqrt.c                              | 165 ++++++++++++++++++++++++++++
 math/s_cexp.c                               | 157 --------------------------
 math/s_cexpf.c                              | 155 --------------------------
 math/s_cexpl.c                              | 153 --------------------------
 math/s_clog.c                               | 118 --------------------
 math/s_clog10.c                             | 124 ---------------------
 math/s_clog10f.c                            | 122 --------------------
 math/s_clog10l.c                            | 127 ---------------------
 math/s_clogf.c                              | 116 -------------------
 math/s_clogl.c                              | 121 --------------------
 math/s_cpow.c                               |  33 ------
 math/s_cpowf.c                              |  31 ------
 math/s_cpowl.c                              |  29 -----
 math/s_cproj.c                              |  44 --------
 math/s_cprojf.c                             |  42 -------
 math/s_cprojl.c                             |  40 -------
 math/s_csqrt.c                              | 165 ----------------------------
 math/s_csqrtf.c                             | 163 ---------------------------
 math/s_csqrtl.c                             | 161 ---------------------------
 sysdeps/alpha/fpu/Makefile                  |   6 +-
 sysdeps/alpha/fpu/s_cexpf.c                 |  13 ++-
 sysdeps/alpha/fpu/s_clog10f.c               |  15 ++-
 sysdeps/alpha/fpu/s_clogf.c                 |  13 ++-
 sysdeps/alpha/fpu/s_cpowf.c                 |  13 ++-
 sysdeps/alpha/fpu/s_cprojf.c                |  13 ++-
 sysdeps/alpha/fpu/s_csqrtf.c                |  13 ++-
 sysdeps/ieee754/ldbl-opt/math-type-macros.h |   7 ++
 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        |  10 --
 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 -
 sysdeps/m68k/m680x0/fpu/b_cexp.c            | 129 ++++++++++++++++++++++
 sysdeps/m68k/m680x0/fpu/s_cexp.c            | 136 -----------------------
 sysdeps/m68k/m680x0/fpu/s_cexpf.c           |   3 -
 sysdeps/m68k/m680x0/fpu/s_cexpl.c           |   3 -
 49 files changed, 866 insertions(+), 2149 deletions(-)
 create mode 100644 math/b_cexp.c
 create mode 100644 math/b_clog.c
 create mode 100644 math/b_clog10.c
 create mode 100644 math/b_cpow.c
 create mode 100644 math/b_cproj.c
 create mode 100644 math/b_csqrt.c
 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_clog10l.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
 create mode 100644 sysdeps/m68k/m680x0/fpu/b_cexp.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_cexp.c
 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 63a385d..b230eb4 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -55,7 +55,8 @@ libm-support = s_lib_version s_matherr s_signgam			\
 # 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 g_cacos_F \
 	g_cacosh_F g_ccos_F g_ccosh_F g_casin_F g_csin_F g_casinh_F	  \
-	g_k_casinh_F g_csinh_F g_catanh_F g_catan_F g_ctan_F g_ctanh_F
+	g_k_casinh_F g_csinh_F g_catanh_F g_catan_F g_ctan_F g_ctanh_F	  \
+	g_cexp_F g_clog_F g_cproj_F g_csqrt_F g_cpow_F g_clog10_F
 
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
@@ -73,8 +74,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/b_cexp.c b/math/b_cexp.c
new file mode 100644
index 0000000..6d02bc0
--- /dev/null
+++ b/math/b_cexp.c
@@ -0,0 +1,157 @@
+/* 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.
+
+   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 M_LIT (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 (__cexp) (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 (__real__ x > t)
+	    {
+	      FLOAT exp_t = M_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 = M_MAX * cosix;
+	      __imag__ retval = M_MAX * sinix;
+	    }
+	  else
+	    {
+	      FLOAT exp_val = M_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 = M_NAN;
+	  __imag__ retval = M_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.  */
+	  FLOAT value = signbit (__real__ x) ? M_LIT (0.0) : M_HUGE_VAL;
+
+	  if (icls == FP_ZERO)
+	    {
+	      /* Imaginary part is M_LIT (0.0).  */
+	      __real__ retval = value;
+	      __imag__ retval = __imag__ x;
+	    }
+	  else
+	    {
+	      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 (value, cosix);
+	      __imag__ retval = M_COPYSIGN (value, sinix);
+	    }
+	}
+      else if (signbit (__real__ x) == 0)
+	{
+	  __real__ retval = M_HUGE_VAL;
+	  __imag__ retval = M_NAN;
+
+	  if (icls == FP_INFINITE)
+	    feraiseexcept (FE_INVALID);
+	}
+      else
+	{
+	  __real__ retval = M_LIT (0.0);
+	  __imag__ retval = M_COPYSIGN (M_LIT (0.0), __imag__ x);
+	}
+    }
+  else
+    {
+      /* If the real part is NaN the result is NaN + iNaN unless the
+	 imaginary part is zero.  */
+      __real__ retval = M_NAN;
+      if (icls == FP_ZERO)
+	__imag__ retval = __imag__ x;
+      else
+	{
+	  __imag__ retval = M_NAN;
+
+	  if (rcls != FP_NAN || icls != FP_NAN)
+	    feraiseexcept (FE_INVALID);
+	}
+    }
+
+  return retval;
+}
+declare_mgen_alias (__cexp, cexp)
+
+#if M_LIBM_NEED_COMPAT (cexp)
+  declare_mgen_libm_compat (__cexp, cexp)
+#endif
diff --git a/math/b_clog.c b/math/b_clog.c
new file mode 100644
index 0000000..d8479f6
--- /dev/null
+++ b/math/b_clog.c
@@ -0,0 +1,122 @@
+/* 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 M_LIT (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>
+
+CFLOAT
+M_DECL_FUNC (__clog) (CFLOAT x)
+{
+  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 M_LIT (0.0).  */
+      __imag__ result = signbit (__real__ x) ? (FLOAT) M_MLIT (M_PI)
+					     : M_LIT (0.0);
+      __imag__ result = M_COPYSIGN (__imag__ result, __imag__ x);
+      /* Yes, the following line raises an exception.  */
+      __real__ result = -M_LIT (1.0) / M_FABS (__real__ x);
+    }
+  else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN))
+    {
+      /* Neither real nor imaginary part is NaN.  */
+      FLOAT absx = M_FABS (__real__ x), absy = M_FABS (__imag__ x);
+      int scale = 0;
+
+      if (absx < absy)
+	{
+	  FLOAT t = absx;
+	  absx = absy;
+	  absy = t;
+	}
+
+      if (absx > M_MAX / M_LIT (2.0))
+	{
+	  scale = -1;
+	  absx = M_SCALBN (absx, scale);
+	  absy = (absy >= M_MIN * M_LIT (2.0) ? M_SCALBN (absy, scale)
+					      : M_LIT (0.0));
+	}
+      else if (absx < M_MIN && absy < M_MIN)
+	{
+	  scale = M_MANT_DIG;
+	  absx = M_SCALBN (absx, scale);
+	  absy = M_SCALBN (absy, scale);
+	}
+
+      if (absx == M_LIT (1.0) && scale == 0)
+	{
+	  __real__ result = M_LOG1P (absy * absy) / M_LIT (2.0);
+	  math_check_force_underflow_nonneg (__real__ result);
+	}
+      else if (absx > M_LIT (1.0) && absx < M_LIT (2.0)
+	       && absy < M_LIT (1.0) && scale == 0)
+	{
+	  FLOAT d2m1 = (absx - M_LIT (1.0)) * (absx + M_LIT (1.0));
+	  if (absy >= M_EPSILON)
+	    d2m1 += absy * absy;
+	  __real__ result = M_LOG1P (d2m1) / M_LIT (2.0);
+	}
+      else if (absx < M_LIT (1.0)
+	       && absx >= M_LIT (0.5)
+	       && absy < M_EPSILON / M_LIT (2.0)
+	       && scale == 0)
+	{
+	  FLOAT d2m1 = (absx - M_LIT (1.0)) * (absx + M_LIT (1.0));
+	  __real__ result = M_LOG1P (d2m1) / M_LIT (2.0);
+	}
+      else if (absx < M_LIT (1.0)
+	       && absx >= M_LIT (0.5)
+	       && scale == 0
+	       && absx * absx + absy * absy >= M_LIT (0.5))
+	{
+	  FLOAT d2m1 = M_FUNC (__x2y2m1) (absx, absy);
+	  __real__ result = M_LOG1P (d2m1) / M_LIT (2.0);
+	}
+      else
+	{
+	  FLOAT d = M_HYPOT (absx, absy);
+	  __real__ result = M_LOG (d) - scale * (FLOAT) M_MLIT (M_LN2);
+	}
+
+      __imag__ result = M_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;
+}
+
+declare_mgen_alias (__clog, clog)
+
+#if M_LIBM_NEED_COMPAT (clog)
+  declare_mgen_libm_compat (__clog, clog)
+#endif
diff --git a/math/b_clog10.c b/math/b_clog10.c
new file mode 100644
index 0000000..eeb2d65
--- /dev/null
+++ b/math/b_clog10.c
@@ -0,0 +1,146 @@
+/* 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 M_LIT (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 LOG10_2 M_LIT (0.3010299956639811952137388947244930267682)
+
+/* pi * log10 (e).  */
+#define PI_LOG10E M_LIT (1.364376353841841347485783625431355770210)
+
+#if !defined (M_DISABLE_ALIASING) \
+    && defined (LONG_DOUBLE_COMPAT_VERSION) && M_TYPE == M_LDOUBLE
+# undef M_DECL_FUNC
+# define M_DECL_FUNC(x) __clog10l_internal
+#endif
+
+CFLOAT
+M_DECL_FUNC (__clog10) (CFLOAT x)
+{
+  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) ? PI_LOG10E : M_LIT (0.0);
+      __imag__ result = M_COPYSIGN (__imag__ result, __imag__ x);
+      /* Yes, the following line raises an exception.  */
+      __real__ result = -M_LIT (1.0) / M_FABS (__real__ x);
+    }
+  else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN))
+    {
+      /* Neither real nor imaginary part is NaN.  */
+      FLOAT absx = M_FABS (__real__ x), absy = M_FABS (__imag__ x);
+      int scale = 0;
+
+      if (absx < absy)
+	{
+	  FLOAT t = absx;
+	  absx = absy;
+	  absy = t;
+	}
+
+      if (absx > M_MAX / M_LIT (2.0))
+	{
+	  scale = -1;
+	  absx = M_SCALBN (absx, scale);
+	  absy = (absy >= M_MIN * M_LIT (2.0) ? M_SCALBN (absy, scale)
+					      : M_LIT (0.0));
+	}
+      else if (absx < M_MIN && absy < M_MIN)
+	{
+	  scale = M_MANT_DIG;
+	  absx = M_SCALBN (absx, scale);
+	  absy = M_SCALBN (absy, scale);
+	}
+
+      if (absx == M_LIT (1.0) && scale == 0)
+	{
+	  __real__ result = M_LOG1P (absy * absy) *
+			      ((FLOAT) M_MLIT (M_LOG10E) / M_LIT (2.0));
+	  math_check_force_underflow_nonneg (__real__ result);
+	}
+      else if (absx > M_LIT (1.0) && absx < M_LIT (2.0)
+	       && absy < M_LIT (1.0) && scale == 0)
+	{
+	  FLOAT d2m1 = (absx - M_LIT (1.0)) * (absx + M_LIT (1.0));
+	  if (absy >= M_EPSILON)
+	    d2m1 += absy * absy;
+	  __real__ result = M_LOG1P (d2m1)
+			    * ((FLOAT) M_MLIT (M_LOG10E) / M_LIT (2.0));
+	}
+      else if (absx < M_LIT (1.0)
+	       && absx >= M_LIT (0.5)
+	       && absy < M_EPSILON / M_LIT (2.0)
+	       && scale == 0)
+	{
+	  FLOAT d2m1 = (absx - M_LIT (1.0)) * (absx + M_LIT (1.0));
+	  __real__ result = M_LOG1P (d2m1)
+			    * ((FLOAT) M_MLIT (M_LOG10E) / M_LIT (2.0));
+	}
+      else if (absx < M_LIT (1.0)
+	       && absx >= M_LIT (0.5)
+	       && scale == 0
+	       && absx * absx + absy * absy >= M_LIT (0.5))
+	{
+	  FLOAT d2m1 = M_FUNC (__x2y2m1) (absx, absy);
+	  __real__ result = M_LOG1P (d2m1)
+			    * ((FLOAT) M_MLIT (M_LOG10E) / M_LIT (2.0));
+	}
+      else
+	{
+	  FLOAT d = M_HYPOT (absx, absy);
+	  __real__ result = M_FUNC (__ieee754_log10) (d) - scale * LOG10_2;
+	}
+
+      __imag__ result = M_MLIT (M_LOG10E) * M_ATAN2 (__imag__ x, __real__ x);
+    }
+  else
+    {
+      __imag__ result = M_NAN;
+      if (rcls == FP_INFINITE || icls == FP_INFINITE)
+	/* Real or imaginary part is infinite.  */
+	__real__ result = M_HUGE_VAL;
+      else
+	__real__ result = M_NAN;
+    }
+
+  return result;
+}
+
+/* The aliasing for long double is a bit more complicated
+   since some private symbols leaked out in the past.  */
+#if defined (LONG_DOUBLE_COMPAT_VERSION) && M_TYPE == M_LDOUBLE	\
+    && !defined (M_INHIBIT_ALIASING)
+  strong_alias (__clog10l_internal, __clog10l__internal)
+  long_double_symbol (libm, __clog10l_internal, __clog10l);
+  long_double_symbol (libm, __clog10l__internal, clog10l);
+#else
+  declare_mgen_alias (__clog10, clog10)
+#endif
+
+#if M_LIBM_NEED_COMPAT (clog10)
+  declare_mgen_libm_compat (__clog10, __clog10)
+  declare_mgen_libm_compat (clog10, clog10)
+#endif
diff --git a/math/b_cpow.c b/math/b_cpow.c
new file mode 100644
index 0000000..c259b27
--- /dev/null
+++ b/math/b_cpow.c
@@ -0,0 +1,33 @@
+/* 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.
+
+   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 M_LIT (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 (__cpow) (CFLOAT x, CFLOAT c)
+{
+  return M_FUNC (__cexp) (c * M_FUNC (__clog) (x));
+}
+
+declare_mgen_alias (__cpow, cpow)
+
+#if M_LIBM_NEED_COMPAT (cpow)
+  declare_mgen_libm_compat (__cpow, cpow)
+#endif
diff --git a/math/b_cproj.c b/math/b_cproj.c
new file mode 100644
index 0000000..1e19c3d
--- /dev/null
+++ b/math/b_cproj.c
@@ -0,0 +1,45 @@
+/* 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.
+
+   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 M_LIT (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 (__cproj) (CFLOAT x)
+{
+  if (isinf (__real__ x) || isinf (__imag__ x))
+    {
+      CFLOAT res;
+
+      __real__ res = INFINITY;
+      __imag__ res = M_COPYSIGN (M_LIT (0.0), __imag__ x);
+
+      return res;
+    }
+
+  return x;
+}
+
+declare_mgen_alias (__cproj, cproj)
+
+#if M_LIBM_NEED_COMPAT (cproj)
+  declare_mgen_libm_compat (__cproj, cproj)
+#endif
diff --git a/math/b_csqrt.c b/math/b_csqrt.c
new file mode 100644
index 0000000..87ca00d
--- /dev/null
+++ b/math/b_csqrt.c
@@ -0,0 +1,165 @@
+/* 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>.
+   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 M_LIT (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>
+
+CFLOAT
+M_DECL_FUNC (__csqrt) (CFLOAT x)
+{
+  CFLOAT 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 = M_HUGE_VAL;
+	  __imag__ res = __imag__ x;
+	}
+      else if (rcls == FP_INFINITE)
+	{
+	  if (__real__ x < M_LIT (0.0))
+	    {
+	      __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
+			      ? M_NAN : M_COPYSIGN (M_LIT (0.0), __imag__ x));
+	    }
+	}
+      else
+	{
+	  __real__ res = M_NAN;
+	  __imag__ res = M_NAN;
+	}
+    }
+  else
+    {
+      if (__glibc_unlikely (icls == FP_ZERO))
+	{
+	  if (__real__ x < M_LIT (0.0))
+	    {
+	      __real__ res = M_LIT (0.0);
+	      __imag__ res = M_COPYSIGN (M_SQRT (-__real__ x),
+					 __imag__ x);
+	    }
+	  else
+	    {
+	      __real__ res = M_FABS (M_SQRT (__real__ x));
+	      __imag__ res = M_COPYSIGN (M_LIT (0.0), __imag__ x);
+	    }
+	}
+      else if (__glibc_unlikely (rcls == FP_ZERO))
+	{
+	  FLOAT r;
+	  if (M_FABS (__imag__ x) >= M_LIT (2.0) * M_MIN)
+	    r = M_SQRT (M_LIT (0.5) * M_FABS (__imag__ x));
+	  else
+	    r = M_LIT (0.5) * M_SQRT (M_LIT (2.0) * M_FABS (__imag__ x));
+
+	  __real__ res = r;
+	  __imag__ res = M_COPYSIGN (r, __imag__ x);
+	}
+      else
+	{
+	  FLOAT d, r, s;
+	  int scale = 0;
+
+	  if (M_FABS (__real__ x) > M_MAX / M_LIT (4.0))
+	    {
+	      scale = 1;
+	      __real__ x = M_SCALBN (__real__ x, -2 * scale);
+	      __imag__ x = M_SCALBN (__imag__ x, -2 * scale);
+	    }
+	  else if (M_FABS (__imag__ x) > M_MAX / M_LIT (4.0))
+	    {
+	      scale = 1;
+	      if (M_FABS (__real__ x) >= M_LIT (4.0) * M_MIN)
+		__real__ x = M_SCALBN (__real__ x, -2 * scale);
+	      else
+		__real__ x = M_LIT (0.0);
+	      __imag__ x = M_SCALBN (__imag__ x, -2 * scale);
+	    }
+	  else if (M_FABS (__real__ x) < M_LIT (2.0) * M_MIN
+		   && M_FABS (__imag__ x) < M_LIT (2.0) * M_MIN)
+	    {
+	      scale = -((M_MANT_DIG + 1) / 2);
+	      __real__ x = M_SCALBN (__real__ x, -2 * scale);
+	      __imag__ x = M_SCALBN (__imag__ x, -2 * scale);
+	    }
+
+	  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 > M_LIT (0.0))
+	    {
+	      r = M_SQRT (M_LIT (0.5) * (d + __real__ x));
+	      if (scale == 1 && M_FABS (__imag__ x) < M_LIT (1.0))
+		{
+		  /* Avoid possible intermediate underflow.  */
+		  s = __imag__ x / r;
+		  r = M_SCALBN (r, scale);
+		  scale = 0;
+		}
+	      else
+		s = M_LIT (0.5) * (__imag__ x / r);
+	    }
+	  else
+	    {
+	      s = M_SQRT (M_LIT (0.5) * (d - __real__ x));
+	      if (scale == 1 && M_FABS (__imag__ x) < M_LIT (1.0))
+		{
+		  /* Avoid possible intermediate underflow.  */
+		  r = M_FABS (__imag__ x / s);
+		  s = M_SCALBN (s, scale);
+		  scale = 0;
+		}
+	      else
+		r = M_FABS (M_LIT (0.5) * (__imag__ x / s));
+	    }
+
+	  if (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 = M_COPYSIGN (s, __imag__ x);
+	}
+    }
+
+  return res;
+}
+declare_mgen_alias (__csqrt, csqrt)
+
+#if M_LIBM_NEED_COMPAT (csqrt)
+  declare_mgen_libm_compat (__csqrt, csqrt)
+#endif
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_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_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_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_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_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_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/Makefile b/sysdeps/alpha/fpu/Makefile
index d8ccf86..7c7a1ec 100644
--- a/sysdeps/alpha/fpu/Makefile
+++ b/sysdeps/alpha/fpu/Makefile
@@ -2,7 +2,9 @@
 # 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 \
 	g_cacos_f g_cacosh_f g_ccos_f g_ccosh_f g_casin_f g_csin_f	 \
-	g_casinh_f g_csinh_f g_catan_f g_catanh_f g_ctan_f g_ctanh_f
+	g_casinh_f g_csinh_f g_catan_f g_catanh_f g_ctan_f g_ctanh_f	 \
+	g_cexp_f g_clog_f g_cproj_f g_csqrt_f g_cpow_f g_clog10_f
 libm-gen-replacement-calls = cabsf cargf cimagf crealf conjf	\
 	s_cacosf s_cacoshf s_ccosf s_ccoshf s_casinf s_csinf	\
-	s_casinhf s_csinhf s_catanf s_catanhf s_ctanf s_ctanhf
+	s_casinhf s_csinhf s_catanf s_catanhf s_ctanf s_ctanhf	\
+	s_cexpf s_clogf s_cprojf s_csqrtf s_cpowf s_clog10f
diff --git a/sysdeps/alpha/fpu/s_cexpf.c b/sysdeps/alpha/fpu/s_cexpf.c
index 2ae519c..f2e2474 100644
--- a/sysdeps/alpha/fpu/s_cexpf.c
+++ b/sysdeps/alpha/fpu/s_cexpf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __cexpf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_cexp.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..3fa06ee 100644
--- a/sysdeps/alpha/fpu/s_clog10f.c
+++ b/sysdeps/alpha/fpu/s_clog10f.c
@@ -24,14 +24,21 @@
 
 #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
+#define M_TYPE M_FLOAT
+/* Disable any non-standard aliasing.  */
+#define M_INHIBIT_ALIASING 1
+#include <math-type-macros.h>
 
-#undef __clog10f
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_clog10.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..168d3ef 100644
--- a/sysdeps/alpha/fpu/s_clogf.c
+++ b/sysdeps/alpha/fpu/s_clogf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __clogf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_clog.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..d16589a 100644
--- a/sysdeps/alpha/fpu/s_cpowf.c
+++ b/sysdeps/alpha/fpu/s_cpowf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __cpowf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_cpow.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..c48c2e1 100644
--- a/sysdeps/alpha/fpu/s_cprojf.c
+++ b/sysdeps/alpha/fpu/s_cprojf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __cprojf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_cproj.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..b8731d3 100644
--- a/sysdeps/alpha/fpu/s_csqrtf.c
+++ b/sysdeps/alpha/fpu/s_csqrtf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __csqrtf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_csqrt.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_csqrtf (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 646489e..5e61eb2 100644
--- a/sysdeps/ieee754/ldbl-opt/math-type-macros.h
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros.h
@@ -19,5 +19,12 @@
 #define LDOUBLE_catanhl_libm_version GLIBC_2_1
 #define LDOUBLE_ctanl_libm_version GLIBC_2_1
 #define LDOUBLE_ctanhl_libm_version GLIBC_2_1
+#define LDOUBLE_cexpl_libm_version GLIBC_2_1
+#define LDOUBLE_clogl_libm_version GLIBC_2_1
+#define LDOUBLE_cprojl_libm_version GLIBC_2_1
+#define LDOUBLE_csqrtl_libm_version GLIBC_2_1
+#define LDOUBLE_cpowl_libm_version GLIBC_2_1
+#define LDOUBLE_clog10l_libm_version GLIBC_2_1
+#define LDOUBLE___clog10l_libm_version GLIBC_2_1
 
 #include_next <math-type-macros.h>
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
deleted file mode 100644
index 954f680..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_clog10l.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#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
-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/b_cexp.c b/sysdeps/m68k/m680x0/fpu/b_cexp.c
new file mode 100644
index 0000000..4667f08
--- /dev/null
+++ b/sysdeps/m68k/m680x0/fpu/b_cexp.c
@@ -0,0 +1,129 @@
+/* Complex exponential 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 <float.h>
+#include <complex.h>
+#include <math.h>
+#include "mathimpl.h"
+
+#define CONCATX(a,b) __CONCAT(a,b)
+#define s(name) M_FUNC (name)
+#define m81(func) __m81_u(s(func))
+
+CFLOAT
+s(__cexp) (CFLOAT x)
+{
+  CFLOAT retval;
+  unsigned long ix_cond;
+
+  ix_cond = __m81_test (__imag__ x);
+
+  if ((ix_cond & (__M81_COND_NAN|__M81_COND_INF)) == 0)
+    {
+      /* Imaginary part is finite.  */
+      unsigned long rx_cond = __m81_test (__real__ x);
+
+      if ((rx_cond & (__M81_COND_NAN|__M81_COND_INF)) == 0)
+	{
+	  const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l);
+	  long double sin_ix, cos_ix, exp_val;
+
+	  __m81_u (__sincosl) (__imag__ x, &sin_ix, &cos_ix);
+
+	  if (__real__ x > t)
+	    {
+	      long double exp_t = __m81_u(__ieee754_expl) (t);
+	      __real__ x -= t;
+	      sin_ix *= exp_t;
+	      cos_ix *= exp_t;
+	      if (__real__ x > t)
+		{
+		  __real__ x -= t;
+		  sin_ix *= exp_t;
+		  cos_ix *= exp_t;
+		}
+	    }
+
+	  exp_val = __m81_u(__ieee754_expl) (__real__ x);
+	  __real__ retval = exp_val * cos_ix;
+	  if (ix_cond & __M81_COND_ZERO)
+	    __imag__ retval = __imag__ x;
+	  else
+	    __imag__ retval = exp_val * sin_ix;
+	}
+      else
+	{
+	  /* Compute the sign of the result.  */
+	  long double remainder, pi_2;
+	  int quadrant;
+
+	  if ((rx_cond & (__M81_COND_NAN|__M81_COND_NEG)) == __M81_COND_NEG)
+	    __real__ retval = __imag__ retval = 0.0;
+	  else
+	    __real__ retval = __imag__ retval = __real__ x;
+	  __asm ("fmovecr %#0,%0\n\tfscale%.w %#-1,%0" : "=f" (pi_2));
+	  __asm ("fmod%.x %2,%0\n\tfmove%.l %/fpsr,%1"
+		 : "=f" (remainder), "=dm" (quadrant)
+		 : "f" (pi_2), "0" (__imag__ x));
+	  quadrant = (quadrant >> 16) & 0x83;
+	  if (quadrant & 0x80)
+	    quadrant ^= 0x83;
+	  switch (quadrant)
+	    {
+	    default:
+	      break;
+	    case 1:
+	      __real__ retval = -__real__ retval;
+	      break;
+	    case 2:
+	      __real__ retval = -__real__ retval;
+	    case 3:
+	      __imag__ retval = -__imag__ retval;
+	      break;
+	    }
+	  if (ix_cond & __M81_COND_ZERO && (rx_cond & __M81_COND_NAN) == 0)
+	    __imag__ retval = __imag__ x;
+	}
+    }
+  else
+    {
+      unsigned long rx_cond = __m81_test (__real__ x);
+
+      if (rx_cond & __M81_COND_INF)
+	{
+	  /* Real part is infinite.  */
+	  if (rx_cond & __M81_COND_NEG)
+	    {
+	      __real__ retval = __imag__ retval = 0.0;
+	      if (ix_cond & __M81_COND_NEG)
+		__imag__ retval = -__imag__ retval;
+	    }
+	  else
+	    {
+	      __real__ retval = __real__ x;
+	      __imag__ retval = __imag__ x - __imag__ x;
+	    }
+	}
+      else
+	__real__ retval = __imag__ retval = __imag__ x - __imag__ x;
+    }
+
+  return retval;
+}
+weak_alias (s(__cexp), s(cexp))
diff --git a/sysdeps/m68k/m680x0/fpu/s_cexp.c b/sysdeps/m68k/m680x0/fpu/s_cexp.c
deleted file mode 100644
index f715b77..0000000
--- a/sysdeps/m68k/m680x0/fpu/s_cexp.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Complex exponential 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 <float.h>
-#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(__cexp) (__complex__ float_type x)
-{
-  __complex__ float_type retval;
-  unsigned long ix_cond;
-
-  ix_cond = __m81_test (__imag__ x);
-
-  if ((ix_cond & (__M81_COND_NAN|__M81_COND_INF)) == 0)
-    {
-      /* Imaginary part is finite.  */
-      unsigned long rx_cond = __m81_test (__real__ x);
-
-      if ((rx_cond & (__M81_COND_NAN|__M81_COND_INF)) == 0)
-	{
-	  const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l);
-	  long double sin_ix, cos_ix, exp_val;
-
-	  __m81_u (__sincosl) (__imag__ x, &sin_ix, &cos_ix);
-
-	  if (__real__ x > t)
-	    {
-	      long double exp_t = __m81_u(__ieee754_expl) (t);
-	      __real__ x -= t;
-	      sin_ix *= exp_t;
-	      cos_ix *= exp_t;
-	      if (__real__ x > t)
-		{
-		  __real__ x -= t;
-		  sin_ix *= exp_t;
-		  cos_ix *= exp_t;
-		}
-	    }
-
-	  exp_val = __m81_u(__ieee754_expl) (__real__ x);
-	  __real__ retval = exp_val * cos_ix;
-	  if (ix_cond & __M81_COND_ZERO)
-	    __imag__ retval = __imag__ x;
-	  else
-	    __imag__ retval = exp_val * sin_ix;
-	}
-      else
-	{
-	  /* Compute the sign of the result.  */
-	  long double remainder, pi_2;
-	  int quadrant;
-
-	  if ((rx_cond & (__M81_COND_NAN|__M81_COND_NEG)) == __M81_COND_NEG)
-	    __real__ retval = __imag__ retval = 0.0;
-	  else
-	    __real__ retval = __imag__ retval = __real__ x;
-	  __asm ("fmovecr %#0,%0\n\tfscale%.w %#-1,%0" : "=f" (pi_2));
-	  __asm ("fmod%.x %2,%0\n\tfmove%.l %/fpsr,%1"
-		 : "=f" (remainder), "=dm" (quadrant)
-		 : "f" (pi_2), "0" (__imag__ x));
-	  quadrant = (quadrant >> 16) & 0x83;
-	  if (quadrant & 0x80)
-	    quadrant ^= 0x83;
-	  switch (quadrant)
-	    {
-	    default:
-	      break;
-	    case 1:
-	      __real__ retval = -__real__ retval;
-	      break;
-	    case 2:
-	      __real__ retval = -__real__ retval;
-	    case 3:
-	      __imag__ retval = -__imag__ retval;
-	      break;
-	    }
-	  if (ix_cond & __M81_COND_ZERO && (rx_cond & __M81_COND_NAN) == 0)
-	    __imag__ retval = __imag__ x;
-	}
-    }
-  else
-    {
-      unsigned long rx_cond = __m81_test (__real__ x);
-
-      if (rx_cond & __M81_COND_INF)
-	{
-	  /* Real part is infinite.  */
-	  if (rx_cond & __M81_COND_NEG)
-	    {
-	      __real__ retval = __imag__ retval = 0.0;
-	      if (ix_cond & __M81_COND_NEG)
-		__imag__ retval = -__imag__ retval;
-	    }
-	  else
-	    {
-	      __real__ retval = __real__ x;
-	      __imag__ retval = __imag__ x - __imag__ x;
-	    }
-	}
-      else
-	__real__ retval = __imag__ retval = __imag__ x - __imag__ x;
-    }
-
-  return retval;
-}
-weak_alias (s(__cexp), s(cexp))
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] 53+ messages in thread

* [PATCH 3/6] Convert _Complex cosine functions to generated code
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
  2016-06-30 22:21   ` [PATCH 5/6] Convert _Complex tangent functions to generated code Paul E. Murphy
@ 2016-06-30 22:21   ` Paul E. Murphy
  2016-06-30 22:36     ` Joseph Myers
  2016-08-03 20:12     ` Adhemerval Zanella
  2016-06-30 22:21   ` [PATCH 1/6] Refactor part of math Makefile Paul E. Murphy
                     ` (16 subsequent siblings)
  18 siblings, 2 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-06-30 22:21 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.

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

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>
-- 
2.4.11

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

* [PATCH 4/6] Convert _Complex sine functions to generated code
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (4 preceding siblings ...)
  2016-06-30 22:21   ` [PATCH 6/6] Convert remaining complex function to generated files Paul E. Murphy
@ 2016-06-30 22:21   ` Paul E. Murphy
  2016-06-30 22:32   ` [PATCH 0/6] Generate Complex functions from a common template Joseph Myers
                     ` (12 subsequent siblings)
  18 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-06-30 22:21 UTC (permalink / raw)
  To: libc-alpha

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

Note, the csinh variants have also drifted slightly.
I have preserved the existing behavior, otherwise
the code generation changes.

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

	* math/s_casin.c: Refactor into
	* math/b_casin.c: New file
	* math/s_casinf.c: Removed
	* math/s_casinl.c: Removed

	* math/s_casinh.c: Refactor into
	* math/b_casinh.c: New file
	* math/s_casinhf.c: Removed
	* math/s_casinhl.c: Removed

	* math/s_csin.c: Refactor into
	* math/b_csin.c: New file
	* math/s_csinf.c: Removed
	* math/s_csinl.c: Removed

	* math/s_csinh.c: Refactor into
	* math/b_csinh.c: New file
	* math/s_csinhf.c: Removed
	* math/s_csinhl.c: Removed

	* math/k_casinh.c: Refactor into
	* math/b_k_casinh.c: New file
	* math/k_casinhf.c: Removed
	* math/k_casinhl.c: Removed

	* sysdeps/alpha/fpu/Makefile: Add overrides for _Complex float
	variants.
	* 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/math-type-macros.h: Add versioning
	info for compat symbols.

	* 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/b_csin.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/b_csinh.c: New file
	* sysdeps/m68k/m680x0/fpu/s_csinhf.c: Removed
	* sysdeps/m68k/m680x0/fpu/s_csinhl.c: Removed
---
 math/Makefile                               |  11 +-
 math/b_casin.c                              |  67 +++++++++
 math/b_casinh.c                             |  76 ++++++++++
 math/b_csin.c                               | 172 ++++++++++++++++++++++
 math/b_csinh.c                              | 173 ++++++++++++++++++++++
 math/b_k_casinh.c                           | 213 +++++++++++++++++++++++++++
 math/k_casinh.c                             | 210 --------------------------
 math/k_casinhf.c                            | 212 ---------------------------
 math/k_casinhl.c                            | 219 ----------------------------
 math/s_casin.c                              |  66 ---------
 math/s_casinf.c                             |  64 --------
 math/s_casinh.c                             |  73 ----------
 math/s_casinhf.c                            |  71 ---------
 math/s_casinhl.c                            |  69 ---------
 math/s_casinl.c                             |  62 --------
 math/s_csin.c                               | 171 ----------------------
 math/s_csinf.c                              | 169 ---------------------
 math/s_csinh.c                              | 166 ---------------------
 math/s_csinhf.c                             | 166 ---------------------
 math/s_csinhl.c                             | 164 ---------------------
 math/s_csinl.c                              | 167 ---------------------
 sysdeps/alpha/fpu/Makefile                  |   6 +-
 sysdeps/alpha/fpu/s_casinf.c                |  13 +-
 sysdeps/alpha/fpu/s_casinhf.c               |  13 +-
 sysdeps/alpha/fpu/s_csinf.c                 |  13 +-
 sysdeps/alpha/fpu/s_csinhf.c                |  13 +-
 sysdeps/ieee754/ldbl-opt/math-type-macros.h |   4 +
 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 -
 sysdeps/m68k/m680x0/fpu/b_csin.c            |  59 ++++++++
 sysdeps/m68k/m680x0/fpu/b_csinh.c           |  62 ++++++++
 sysdeps/m68k/m680x0/fpu/s_csin.c            |  67 ---------
 sysdeps/m68k/m680x0/fpu/s_csinf.c           |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinh.c           |  69 ---------
 sysdeps/m68k/m680x0/fpu/s_csinhf.c          |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinhl.c          |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinl.c           |   3 -
 43 files changed, 872 insertions(+), 2268 deletions(-)
 create mode 100644 math/b_casin.c
 create mode 100644 math/b_casinh.c
 create mode 100644 math/b_csin.c
 create mode 100644 math/b_csinh.c
 create mode 100644 math/b_k_casinh.c
 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
 create mode 100644 sysdeps/m68k/m680x0/fpu/b_csin.c
 create mode 100644 sysdeps/m68k/m680x0/fpu/b_csinh.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csin.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinf.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinh.c
 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 b621996..ac91a84 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -54,7 +54,8 @@ libm-support = s_lib_version s_matherr s_signgam			\
 # 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 g_cacos_F \
-	g_cacosh_F g_ccos_F g_ccosh_F
+	g_cacosh_F g_ccos_F g_ccosh_F g_casin_F g_csin_F g_casinh_F	  \
+	g_k_casinh_F g_csinh_F
 
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
@@ -72,11 +73,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/b_casin.c b/math/b_casin.c
new file mode 100644
index 0000000..a03f414
--- /dev/null
+++ b/math/b_casin.c
@@ -0,0 +1,67 @@
+/* Return arc sine 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 <math.h>
+#include <math_private.h>
+
+
+CFLOAT
+M_DECL_FUNC (__casin) (CFLOAT x)
+{
+  CFLOAT 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 = M_NAN;
+	  __imag__ res = M_COPYSIGN (M_HUGE_VAL, __imag__ x);
+	}
+      else
+	{
+	  __real__ res = M_NAN;
+	  __imag__ res = M_NAN;
+	}
+    }
+  else
+    {
+      CFLOAT y;
+
+      __real__ y = -__imag__ x;
+      __imag__ y = __real__ x;
+
+      y = M_FUNC (__casinh) (y);
+
+      __real__ res = __imag__ y;
+      __imag__ res = -__real__ y;
+    }
+
+  return res;
+}
+
+declare_mgen_alias (__casin, casin)
+
+#if M_LIBM_NEED_COMPAT (casin)
+  declare_mgen_libm_compat (__casin, casin)
+#endif
diff --git a/math/b_casinh.c b/math/b_casinh.c
new file mode 100644
index 0000000..3863147
--- /dev/null
+++ b/math/b_casinh.c
@@ -0,0 +1,76 @@
+/* Return arc hyperbole sine 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.
+
+   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 (__casinh) (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_COPYSIGN (M_HUGE_VAL, __real__ x);
+
+	  if (rcls == FP_NAN)
+	    __imag__ res = M_NAN;
+	  else
+	    __imag__ res = M_COPYSIGN (rcls >= FP_ZERO
+						? M_MLIT (M_PI_2)
+					        : M_MLIT (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 = M_COPYSIGN (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)
+    {
+      res = x;
+    }
+  else
+    {
+      res = M_FUNC (__kernel_casinh) (x, 0);
+    }
+
+  return res;
+}
+
+declare_mgen_alias (__casinh, casinh)
+
+#if M_LIBM_NEED_COMPAT (casinh)
+  declare_mgen_libm_compat (__casinh, casinh)
+#endif
diff --git a/math/b_csin.c b/math/b_csin.c
new file mode 100644
index 0000000..d8387fd
--- /dev/null
+++ b/math/b_csin.c
@@ -0,0 +1,172 @@
+/* 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>
+
+CFLOAT
+M_DECL_FUNC (__csin) (CFLOAT x)
+{
+  CFLOAT retval;
+  int negate = signbit (__real__ x);
+  int rcls = fpclassify (__real__ x);
+  int icls = fpclassify (__imag__ x);
+
+  __real__ x = M_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) ((M_MAX_EXP - 1) * M_MLIT (M_LN2));
+	  FLOAT sinix, cosix;
+
+	  if (__glibc_likely (__real__ x > M_MIN))
+	    {
+	      M_SINCOS (__real__ x, &sinix, &cosix);
+	    }
+	  else
+	    {
+	      sinix = __real__ x;
+	      cosix = 1.0;
+	    }
+
+	  if (negate)
+	    sinix = -sinix;
+
+	  if (M_FABS (__imag__ x) > t)
+	    {
+	      FLOAT exp_t = M_EXP (t);
+	      FLOAT ix = M_FABS (__imag__ x);
+	      if (signbit (__imag__ x))
+		cosix = -cosix;
+	      ix -= t;
+	      sinix *= exp_t / M_LIT (2.0);
+	      cosix *= exp_t / M_LIT (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 = M_MAX * sinix;
+		  __imag__ retval = M_MAX * cosix;
+		}
+	      else
+		{
+		  FLOAT exp_val = M_EXP (ix);
+		  __real__ retval = exp_val * sinix;
+		  __imag__ retval = exp_val * cosix;
+		}
+	    }
+	  else
+	    {
+	      __real__ retval = M_COSH (__imag__ x) * sinix;
+	      __imag__ retval = M_SINH (__imag__ x) * cosix;
+	    }
+
+	  math_check_force_underflow_complex (retval);
+	}
+      else
+	{
+	  if (icls == FP_ZERO)
+	    {
+	      /* Imaginary part is 0.0.  */
+	      __real__ retval = M_NAN;
+	      __imag__ retval = __imag__ x;
+
+	      if (rcls == FP_INFINITE)
+		feraiseexcept (FE_INVALID);
+	    }
+	  else
+	    {
+	      __real__ retval = M_NAN;
+	      __imag__ retval = M_NAN;
+
+	      feraiseexcept (FE_INVALID);
+	    }
+	}
+    }
+  else if (icls == FP_INFINITE)
+    {
+      /* Imaginary part is infinite.  */
+      if (rcls == FP_ZERO)
+	{
+	  /* Real part is 0.0.  */
+	  __real__ retval = M_COPYSIGN (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 > M_MIN))
+	    {
+	      M_SINCOS (__real__ x, &sinix, &cosix);
+	    }
+	  else
+	    {
+	      sinix = __real__ x;
+	      cosix = 1.0;
+	    }
+
+	  __real__ retval = M_COPYSIGN (M_HUGE_VAL, sinix);
+	  __imag__ retval = M_COPYSIGN (M_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 = M_NAN;
+	  __imag__ retval = M_HUGE_VAL;
+
+	  if (rcls == FP_INFINITE)
+	    feraiseexcept (FE_INVALID);
+	}
+    }
+  else
+    {
+      if (rcls == FP_ZERO)
+	__real__ retval = M_COPYSIGN (0.0, negate ? -1.0 : 1.0);
+      else
+	__real__ retval = M_NAN;
+      __imag__ retval = M_NAN;
+    }
+
+  return retval;
+}
+
+declare_mgen_alias (__csin, csin)
+
+#if M_LIBM_NEED_COMPAT (csin)
+  declare_mgen_libm_compat (__csin, csin)
+#endif
diff --git a/math/b_csinh.c b/math/b_csinh.c
new file mode 100644
index 0000000..4837e48
--- /dev/null
+++ b/math/b_csinh.c
@@ -0,0 +1,173 @@
+/* Complex sine hyperbole function for 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>
+#include <float.h>
+
+CFLOAT
+M_DECL_FUNC (__csinh) (CFLOAT x)
+{
+  CFLOAT retval;
+  int negate = signbit (__real__ x);
+  int rcls = fpclassify (__real__ x);
+  int icls = fpclassify (__imag__ x);
+
+  __real__ x = M_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) ((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 = 1.0;
+	    }
+
+	  if (negate)
+	    cosix = -cosix;
+
+	  if (M_FABS (__real__ x) > t)
+	    {
+	      FLOAT exp_t = M_EXP (t);
+	      FLOAT rx = M_FABS (__real__ x);
+	      if (signbit (__real__ x))
+		cosix = -cosix;
+	      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_SINH (__real__ x) * cosix;
+	      __imag__ retval = M_COSH (__real__ x) * sinix;
+	    }
+
+	  math_check_force_underflow_complex (retval);
+	}
+      else
+	{
+	  if (rcls == FP_ZERO)
+	    {
+	      /* Real part is 0.0.  */
+	      __real__ retval = M_COPYSIGN (0.0, negate ? -1.0 : 1.0);
+	      __imag__ retval = M_NAN + M_NAN;
+
+	      if (icls == FP_INFINITE)
+		feraiseexcept (FE_INVALID);
+	    }
+	  else
+	    {
+	      __real__ retval = M_NAN;
+	      __imag__ retval = M_NAN;
+
+	      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 = 1.0;
+	    }
+
+	  __real__ retval = M_COPYSIGN (M_HUGE_VAL, cosix);
+	  __imag__ retval = M_COPYSIGN (M_HUGE_VAL, sinix);
+
+	  if (negate)
+	    __real__ retval = -__real__ retval;
+	}
+      else if (icls == FP_ZERO)
+	{
+	  /* Imaginary part is 0.0.  */
+	  __real__ retval = negate ? -M_HUGE_VAL : M_HUGE_VAL;
+	  __imag__ retval = __imag__ 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 == 0.0 ? __imag__ x : M_NAN;
+    }
+
+  return retval;
+}
+
+declare_mgen_alias (__csinh, csinh)
+
+#if M_LIBM_NEED_COMPAT (csinh)
+  declare_mgen_libm_compat (__csinh, csinh)
+#endif
diff --git a/math/b_k_casinh.c b/math/b_k_casinh.c
new file mode 100644
index 0000000..51b57a4
--- /dev/null
+++ b/math/b_k_casinh.c
@@ -0,0 +1,213 @@
+/* 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.  */
+
+CFLOAT
+M_DECL_FUNC (__kernel_casinh) (CFLOAT x, int adj)
+{
+  CFLOAT res;
+  FLOAT rx, ix;
+  CFLOAT y;
+
+  /* Avoid cancellation by reducing to the first quadrant.  */
+  rx = M_FABS (__real__ x);
+  ix = M_FABS (__imag__ x);
+
+  if (rx >= M_LIT (1.0) / M_EPSILON || ix >= M_LIT (1.0) / M_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 = M_COPYSIGN (__imag__ y, __imag__ x);
+	  __imag__ y = t;
+	}
+
+      res = M_FUNC (__clog) (y);
+      __real__ res += (FLOAT) M_MLIT (M_LN2);
+    }
+  else if (rx >= M_LIT (0.5) && ix < M_EPSILON / M_LIT (8.0))
+    {
+      FLOAT s = M_HYPOT (1.0, rx);
+
+      __real__ res = M_LOG (rx + s);
+      if (adj)
+	__imag__ res = M_ATAN2 (s, __imag__ x);
+      else
+	__imag__ res = M_ATAN2 (ix, s);
+    }
+  else if (rx < M_EPSILON / M_LIT (8.0) && ix >= M_LIT (1.5))
+    {
+      FLOAT s = M_SQRT ((ix + M_LIT (1.0)) * (ix - M_LIT (1.0)));
+
+      __real__ res = M_LOG (ix + s);
+      if (adj)
+	__imag__ res = M_ATAN2
+	    (rx, M_COPYSIGN (s, __imag__ x));
+      else
+	__imag__ res = M_ATAN2 (s, rx);
+    }
+  else if (ix > M_LIT (1.0) && ix < M_LIT (1.5) && rx < M_LIT (0.5))
+    {
+      if (rx < M_EPSILON * M_EPSILON)
+	{
+	  FLOAT ix2m1 = (ix + M_LIT (1.0)) * (ix - M_LIT (1.0));
+	  FLOAT s = M_SQRT (ix2m1);
+
+	  __real__ res = M_LOG1P (2.0 * (ix2m1 + ix * s)) / M_LIT (2.0);
+	  if (adj)
+	    __imag__ res = M_ATAN2
+		(rx, M_COPYSIGN (s, __imag__ x));
+	  else
+	    __imag__ res = M_ATAN2 (s, rx);
+	}
+      else
+	{
+	  FLOAT ix2m1 = (ix + M_LIT (1.0)) * (ix - M_LIT (1.0));
+	  FLOAT rx2 = rx * rx;
+	  FLOAT f = rx2 * (M_LIT (2.0) + rx2 + M_LIT (2.0) * ix * ix);
+	  FLOAT d = M_SQRT (ix2m1 * ix2m1 + f);
+	  FLOAT dp = d + ix2m1;
+	  FLOAT dm = f / dp;
+	  FLOAT r1 = M_SQRT ((dm + rx2) / M_LIT (2.0));
+	  FLOAT r2 = rx * ix / r1;
+
+	  __real__ res = M_LOG1P
+	      (rx2 + dp + M_LIT (2.0) * (rx * r1 + ix * r2)) / M_LIT (2.0);
+	  if (adj)
+	    __imag__ res = M_ATAN2
+	      (rx + r1, M_COPYSIGN (ix + r2, __imag__ x));
+	  else
+	    __imag__ res = M_ATAN2 (ix + r2, rx + r1);
+	}
+    }
+  else if (ix == M_LIT (1.0) && rx < M_LIT (0.5))
+    {
+      if (rx < M_EPSILON / M_LIT (8.0))
+	{
+	  __real__ res = M_LOG1P
+	    (M_LIT (2.0) * (rx + M_SQRT (rx))) / M_LIT (2.0);
+	  if (adj)
+	    __imag__ res = M_ATAN2 (M_SQRT (rx), M_COPYSIGN (1.0, __imag__ x));
+	  else
+	    __imag__ res = M_ATAN2 (1.0, M_SQRT (rx));
+	}
+      else
+	{
+	  FLOAT d = rx * M_SQRT (M_LIT (4.0) + rx * rx);
+	  FLOAT s1 = M_SQRT ((d + rx * rx) / M_LIT (2.0));
+	  FLOAT s2 = M_SQRT ((d - rx * rx) / M_LIT (2.0));
+
+	  __real__ res = M_LOG1P (rx * rx + d + M_LIT (2.0) * (rx * s1 + s2))
+			  / M_LIT (2.0);
+	  if (adj)
+	    __imag__ res = M_ATAN2 (rx + s1, M_COPYSIGN (M_LIT (1.0) + s2,
+								 __imag__ x));
+	  else
+	    __imag__ res = M_ATAN2 (M_LIT (1.0) + s2, rx + s1);
+	}
+    }
+  else if (ix < M_LIT (1.0) && rx < M_LIT (0.5))
+    {
+      if (ix >= M_EPSILON)
+	{
+	  if (rx < M_EPSILON * M_EPSILON)
+	    {
+	      FLOAT onemix2 = (M_LIT (1.0) + ix) * (M_LIT (1.0) - ix);
+	      FLOAT s = M_SQRT (onemix2);
+
+	      __real__ res = M_LOG1P (M_LIT (2.0) * rx / s) / M_LIT (2.0);
+	      if (adj)
+		__imag__ res = M_ATAN2 (s, __imag__ x);
+	      else
+		__imag__ res = M_ATAN2 (ix, s);
+	    }
+	  else
+	    {
+	      FLOAT onemix2 = (M_LIT (1.0) + ix) * (M_LIT (1.0) - ix);
+	      FLOAT rx2 = rx * rx;
+	      FLOAT f = rx2 * (M_LIT (2.0) + rx2 + M_LIT (2.0) * ix * ix);
+	      FLOAT d = M_SQRT (onemix2 * onemix2 + f);
+	      FLOAT dp = d + onemix2;
+	      FLOAT dm = f / dp;
+	      FLOAT r1 = M_SQRT ((dp + rx2) / M_LIT (2.0));
+	      FLOAT r2 = rx * ix / r1;
+
+	      __real__ res = M_LOG1P (rx2 + dm + M_LIT (2.0)
+				      * (rx * r1 + ix * r2)) / M_LIT (2.0);
+	      if (adj)
+		__imag__ res = M_ATAN2 (rx + r1, M_COPYSIGN (ix + r2,
+							    __imag__ x));
+	      else
+		__imag__ res = M_ATAN2 (ix + r2, rx + r1);
+	    }
+	}
+      else
+	{
+	  FLOAT s = M_HYPOT (1.0, rx);
+
+	  __real__ res = M_LOG1P (M_LIT (2.0) * rx * (rx + s)) / M_LIT (2.0);
+	  if (adj)
+	    __imag__ res = M_ATAN2 (s, __imag__ x);
+	  else
+	    __imag__ res = M_ATAN2 (ix, s);
+	}
+      math_check_force_underflow_nonneg (__real__ res);
+    }
+  else
+    {
+      __real__ y = (rx - ix) * (rx + ix) + M_LIT (1.0);
+      __imag__ y = M_LIT (2.0) * rx * ix;
+
+      y = M_FUNC (__csqrt) (y);
+
+      __real__ y += rx;
+      __imag__ y += ix;
+
+      if (adj)
+	{
+	  FLOAT t = __real__ y;
+	  __real__ y = M_COPYSIGN (__imag__ y, __imag__ x);
+	  __imag__ y = t;
+	}
+
+      res = M_FUNC (__clog) (y);
+    }
+
+  /* Give results the correct sign for the original argument.  */
+  __real__ res = M_COPYSIGN (__real__ res, __real__ x);
+  __imag__ res = M_COPYSIGN (__imag__ res, (adj ? 1.0 : __imag__ x));
+
+  return res;
+}
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_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_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_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_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_csinhf.c b/math/s_csinhf.c
deleted file mode 100644
index a0458cf..0000000
--- a/math/s_csinhf.c
+++ /dev/null
@@ -1,166 +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 (__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);
-
-	  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 ("");
-
-#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 __csinhf
-weak_alias (__csinhf, csinhf)
-#endif
diff --git a/math/s_csinhl.c b/math/s_csinhl.c
deleted file mode 100644
index d7f03fa..0000000
--- a/math/s_csinhl.c
+++ /dev/null
@@ -1,164 +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 (__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);
-
-	  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 ("");
-
-#ifdef FE_INVALID
-	  if (icls == FP_INFINITE)
-	    feraiseexcept (FE_INVALID);
-#endif
-	}
-    }
-  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/Makefile b/sysdeps/alpha/fpu/Makefile
index ddd86ba..3ae1451 100644
--- a/sysdeps/alpha/fpu/Makefile
+++ b/sysdeps/alpha/fpu/Makefile
@@ -1,6 +1,8 @@
 # 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 \
-	g_cacos_f g_cacosh_f g_ccos_f g_ccosh_f
+	g_cacos_f g_cacosh_f g_ccos_f g_ccosh_f g_casin_f g_csin_f	 \
+	g_casinh_f g_csinh_f
 libm-gen-replacement-calls = cabsf cargf cimagf crealf conjf \
-	s_cacosf s_cacoshf s_ccosf s_ccoshf
+	s_cacosf s_cacoshf s_ccosf s_ccoshf s_casinf s_csinf \
+	s_casinhf s_csinhf
diff --git a/sysdeps/alpha/fpu/s_casinf.c b/sysdeps/alpha/fpu/s_casinf.c
index f85f524..396c0a1 100644
--- a/sysdeps/alpha/fpu/s_casinf.c
+++ b/sysdeps/alpha/fpu/s_casinf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __casinf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_casin.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..045fcb4 100644
--- a/sysdeps/alpha/fpu/s_casinhf.c
+++ b/sysdeps/alpha/fpu/s_casinhf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __casinhf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_casinh.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..d836db8 100644
--- a/sysdeps/alpha/fpu/s_csinf.c
+++ b/sysdeps/alpha/fpu/s_csinf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __csinf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_csin.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..d845ad9 100644
--- a/sysdeps/alpha/fpu/s_csinhf.c
+++ b/sysdeps/alpha/fpu/s_csinhf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __csinhf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_csinh.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_csinhf (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 3e3b9f7..061ba33 100644
--- a/sysdeps/ieee754/ldbl-opt/math-type-macros.h
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros.h
@@ -11,5 +11,9 @@
 #define LDOUBLE_cacoshl_libm_version GLIBC_2_1
 #define LDOUBLE_ccosl_libm_version GLIBC_2_1
 #define LDOUBLE_ccoshl_libm_version GLIBC_2_1
+#define LDOUBLE_casinl_libm_version GLIBC_2_1
+#define LDOUBLE_csinl_libm_version GLIBC_2_1
+#define LDOUBLE_casinhl_libm_version GLIBC_2_1
+#define LDOUBLE_csinhl_libm_version GLIBC_2_1
 
 #include_next <math-type-macros.h>
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/b_csin.c b/sysdeps/m68k/m680x0/fpu/b_csin.c
new file mode 100644
index 0000000..42499f6
--- /dev/null
+++ b/sysdeps/m68k/m680x0/fpu/b_csin.c
@@ -0,0 +1,59 @@
+/* Complex sine 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(__csin) (CFLOAT x)
+{
+  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 sin_rx, cos_rx;
+
+      __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_rx), "=f" (cos_rx)
+	     : "f" (__real__ x));
+      if (rx_cond & __M81_COND_ZERO)
+	__real__ retval = __real__ x;
+      else
+	__real__ retval = sin_rx * m81(__ieee754_cosh) (__imag__ x);
+      __imag__ retval = cos_rx * m81(__ieee754_sinh) (__imag__ x);
+    }
+  else
+    {
+      unsigned long ix_cond = __m81_test (__imag__ x);
+
+      __real__ retval = __real__ x - __real__ x;
+      if (ix_cond & (__M81_COND_ZERO|__M81_COND_INF|__M81_COND_NAN))
+	__imag__ retval = __imag__ x;
+      else
+	__imag__ retval = __real__ retval;
+    }
+
+  return retval;
+}
+weak_alias (s(__csin), s(csin))
diff --git a/sysdeps/m68k/m680x0/fpu/b_csinh.c b/sysdeps/m68k/m680x0/fpu/b_csinh.c
new file mode 100644
index 0000000..1903882
--- /dev/null
+++ b/sysdeps/m68k/m680x0/fpu/b_csinh.c
@@ -0,0 +1,62 @@
+/* Complex sine 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 CONCATX(a,b) __CONCAT(a,b)
+#define s(name) M_FUNC (name)
+#define m81(func) __m81_u(s(func))
+
+CFLOAT
+s(__csinh) (CFLOAT x)
+{
+  CFLOAT retval;
+  unsigned long ix_cond;
+
+  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_sinh) (__real__ x);
+      if (ix_cond & __M81_COND_ZERO)
+	__imag__ retval = __imag__ x;
+      else
+	__imag__ retval = sin_ix * m81(__ieee754_cosh) (__real__ x);
+    }
+  else
+    {
+      unsigned long rx_cond = __m81_test (__real__ x);
+
+      __imag__ retval = __imag__ x - __imag__ x;
+      if (rx_cond & (__M81_COND_ZERO|__M81_COND_INF|__M81_COND_NAN))
+	__real__ retval = __real__ x;
+      else
+	__real__ retval = __imag__ retval;
+    }
+
+  return retval;
+}
+weak_alias (s(__csinh), s(csinh))
diff --git a/sysdeps/m68k/m680x0/fpu/s_csin.c b/sysdeps/m68k/m680x0/fpu/s_csin.c
deleted file mode 100644
index b8419be..0000000
--- a/sysdeps/m68k/m680x0/fpu/s_csin.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Complex sine 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(__csin) (__complex__ float_type x)
-{
-  __complex__ float_type 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;
-
-      __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_rx), "=f" (cos_rx)
-	     : "f" (__real__ x));
-      if (rx_cond & __M81_COND_ZERO)
-	__real__ retval = __real__ x;
-      else
-	__real__ retval = sin_rx * m81(__ieee754_cosh) (__imag__ x);
-      __imag__ retval = cos_rx * m81(__ieee754_sinh) (__imag__ x);
-    }
-  else
-    {
-      unsigned long ix_cond = __m81_test (__imag__ x);
-
-      __real__ retval = __real__ x - __real__ x;
-      if (ix_cond & (__M81_COND_ZERO|__M81_COND_INF|__M81_COND_NAN))
-	__imag__ retval = __imag__ x;
-      else
-	__imag__ retval = __real__ retval;
-    }
-
-  return retval;
-}
-weak_alias (s(__csin), s(csin))
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.c
deleted file mode 100644
index c633cd8..0000000
--- a/sysdeps/m68k/m680x0/fpu/s_csinh.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Complex sine 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(__csinh) (__complex__ float_type x)
-{
-  __complex__ float_type retval;
-  unsigned long ix_cond;
-
-  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_sinh) (__real__ x);
-      if (ix_cond & __M81_COND_ZERO)
-	__imag__ retval = __imag__ x;
-      else
-	__imag__ retval = sin_ix * m81(__ieee754_cosh) (__real__ x);
-    }
-  else
-    {
-      unsigned long rx_cond = __m81_test (__real__ x);
-
-      __imag__ retval = __imag__ x - __imag__ x;
-      if (rx_cond & (__M81_COND_ZERO|__M81_COND_INF|__M81_COND_NAN))
-	__real__ retval = __real__ x;
-      else
-	__real__ retval = __imag__ retval;
-    }
-
-  return retval;
-}
-weak_alias (s(__csinh), s(csinh))
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] 53+ messages in thread

* [PATCH 1/6] Refactor part of math Makefile
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
  2016-06-30 22:21   ` [PATCH 5/6] Convert _Complex tangent functions to generated code Paul E. Murphy
  2016-06-30 22:21   ` [PATCH 3/6] Convert _Complex cosine " Paul E. Murphy
@ 2016-06-30 22:21   ` Paul E. Murphy
  2016-06-30 22:21   ` [PATCH 2/6] Support for type-generic libm function implementations libm Paul E. Murphy
                     ` (15 subsequent siblings)
  18 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-06-30 22:21 UTC (permalink / raw)
  To: libc-alpha

In order to support more types, the Makefile needs a few bits
shuffled.

F is explictly used as a placeholder to substitute for the
appropriate type suffix.  This removes the need to demangle
_r suffixed objects.

The variable libm-compat-calls is added to house any objects which
are only built to provide compat symbols within libm.  That is,
no newly added type should ever attempt building these.  Note,
k_standard* files have been added there.  By consensus they are
deprecated; in practice, we haven't gotten there yet.

New types would be added as noted in the comments preceding
type-TYPE-{suffix,routines,yes} variables.  However, some manual
additions will still need to be done to add appropriate flags
when building the various variants of libm-test.c for a new type.

Likewise, test-ildoubl is renamed test-ildouble for consistency's
sake.

	* math/Makefile (libm-calls): Insert F placeholder into
	object names.  Move w_lgamma_compat* routines into
	(libm-compat-calls): New variable.
	(libm-compat-calls-ldouble-yes): New variable.
	(calls): Insert F placeholder.
	(generated): Redefine using new type-foreach macro call.
	(routines): Likewise.

	(types): New variable to hold a list of symbolic names
	for each type supported by the target machine.
	(libm-routines): Redefine using new types variable.
	(type-foreach): macro to replace fooF with the
	appropriately suffixed foo for each types.

	(type-ldouble-suffix): New variable.
	(type-ldouble-routines): Likewise.
	(type-ldouble-yes): Likewise.
	(type-double-suffix): Likewise.
	(type-double-routines): Likewise.
	(type-float-suffix): Likewise.
	(type-float-routines): Likewise.

	(dbl-only-routines): Remove.
	(long-c-yes): Likewise.
	(long-m-routines): Likewise.
	(long-m-support): Likewise.
	(long-m-yes): Likewise.
	(test-longdouble-yes): Likewise.

	(test-float.o): Simplify by increasing the scope of the
	recipe which adds libm-test.stmp to the vector types.
	(test-ifloat.o): Likewise.
	(test-float-finite.o): Likewise.
	(test-double.o): Likewise
	(test-idouble.o): Likewise.
	(test-double-finite.o): Likewise.
	(test-ldouble.o): Likewise
	(test-ildoubl.o): Likewise.
	(test-ldouble-finite.o): Likewise.

	(libm-tests): Redefine type tests using foreach and the
	list of types in types.

	(CPPFLAGS-test-ildoubl.c): Rename to
	(CPPFLAGS-test-ildouble.c): New variable

	* math/test-ildoubl.c: Rename to
	* math/test-ildouble.c: New file.
---
 math/Makefile        | 131 +++++++++++++++++++++++++++++----------------------
 math/test-ildoubl.c  |  25 ----------
 math/test-ildouble.c |  25 ++++++++++
 3 files changed, 100 insertions(+), 81 deletions(-)
 delete mode 100644 math/test-ildoubl.c
 create mode 100644 math/test-ildouble.c

diff --git a/math/Makefile b/math/Makefile
index 4f14181..89002a8 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -42,50 +42,81 @@ libm-support = s_lib_version s_matherr s_signgam			\
 	       ftestexcept fegetround fesetround fegetenv feholdexcpt	\
 	       fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt	\
 	       fegetexcept
-libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod	\
-	     e_hypot e_j0 e_j1 e_jn e_lgamma_r e_log e_log10 e_pow	\
-	     e_rem_pio2 e_remainder e_scalb e_sinh e_sqrt e_gamma_r	\
-	     e_ilogb							\
-	     k_cos k_rem_pio2 k_sin k_tan s_asinh s_atan s_cbrt		\
-	     s_ceil s_cos s_erf s_expm1 s_fabs				\
-	     s_floor s_log1p w_log1p s_logb				\
-	     s_nextafter s_nexttoward s_rint s_scalbln w_scalbln	\
-	     s_significand s_sin s_tan s_tanh w_acos w_acosh w_asin	\
-	     w_atan2 w_atanh w_cosh w_exp w_exp2 w_exp10 w_fmod		\
-	     w_tgamma w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r	\
-	     w_log w_log10 w_pow w_remainder w_scalb w_sinh w_sqrt	\
-	     w_ilogb							\
-	     s_fpclassify s_fmax s_fmin s_fdim s_nan s_trunc		\
-	     s_remquo e_log2 e_exp2 s_round s_nearbyint s_sincos	\
-	     conj cimag creal cabs carg s_cexp s_csinh s_ccosh s_clog	\
-	     s_catan s_casin s_ccos s_csin s_ctan s_ctanh s_cacos	\
-	     s_casinh s_cacosh s_catanh s_csqrt s_cpow s_cproj s_clog10 \
-	     s_fma s_lrint s_llrint s_lround s_llround e_exp10 w_log2	\
-	     s_issignaling $(calls:s_%=m_%) x2y2m1 k_casinh	\
-	     gamma_product k_standard lgamma_neg lgamma_product		\
-	     w_lgamma_compat s_nextup s_nextdown
-
-dbl-only-routines := branred doasin dosincos halfulp mpa mpatan2	\
-		     mpatan mpexp mplog mpsqrt mptan sincos32 slowexp	\
-		     slowpow sincostab
-libm-routines = $(strip $(libm-support) $(libm-calls) \
-			$(patsubst %_rf,%f_r,$(libm-calls:=f))	\
-			$(long-m-$(long-double-fcts))) \
-		$(dbl-only-routines)
-long-m-routines = $(patsubst %_rl,%l_r,$(libm-calls:=l))
-long-m-support = t_sincosl k_sincosl
-long-m-yes = $(long-m-routines) $(long-m-support)
+
+libm-calls =								  \
+	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
+	e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF	  \
+	e_rem_pio2F e_remainderF e_scalbF e_sinhF e_sqrtF e_gammaF_r	  \
+	e_ilogbF							  \
+	k_cosF k_rem_pio2F k_sinF k_tanF s_asinhF s_atanF s_cbrtF	  \
+	s_ceilF s_cosF s_erfF s_expm1F s_fabsF				  \
+	s_floorF s_log1pF w_log1pF s_logbF				  \
+	s_nextafterF s_nexttowardF s_rintF s_scalblnF w_scalblnF	  \
+	s_significandF s_sinF s_tanF s_tanhF w_acosF w_acoshF w_asinF	  \
+	w_atan2F w_atanhF w_coshF w_expF w_exp2F w_exp10F w_fmodF	  \
+	w_tgammaF w_hypotF w_j0F w_j1F w_jnF w_lgammaF w_lgammaF_r	  \
+	w_logF w_log10F w_powF w_remainderF w_scalbF w_sinhF w_sqrtF	  \
+	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	  \
+	conjF cimagF crealF cabsF cargF 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_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			  \
+	s_nextupF s_nextdownF
+
+libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl
+libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
+	$(libm-compat-calls-ldouble-$(long-double-fcts))
+
+
+# Type specific routine support.
+#
+# The following three variables control what is included for each type:
+#
+# type-floatN-suffix = The suffix of the type
+# type-floatN-routines = Type specific support objects
+# type-floatN-yes = If the type is supported, evaluates to floatN
+#
+# Finally, note that types is an intentionally recursive variable.
+# We only know the full set of supported types for the target machine
+# after the Rules makefile has been parsed.
+types = $(type-ldouble-$(long-double-fcts)) double float
+
+# long double support
+type-ldouble-suffix := l
+type-ldouble-routines := t_sincosl k_sincosl
+type-ldouble-yes := ldouble
+
+# double support
+type-double-suffix :=
+type-double-routines := branred doasin dosincos halfulp mpa mpatan2	\
+		       mpatan mpexp mplog mpsqrt mptan sincos32 slowexp	\
+		       slowpow sincostab
+
+# float support
+type-float-suffix := f
+type-float-routines :=
+
+
+# Apply suffix to each type in arg 1
+type-foreach = $(foreach t,$(types),$(subst F,$(type-$(t)-suffix),$(1)))
+
+libm-routines = $(strip $(libm-support) $(libm-compat-calls)		\
+			$(call type-foreach, $(libm-calls))		\
+			$(foreach t, $(types), $(type-$(t)-routines))) 	\
 
 # These functions are in libc instead of libm because __printf_fp
 # calls them, so any program using printf will need them linked in,
 # and we don't want to have to link every program with -lm.
 # In libm-calls (above), list m_foo in place of s_foo for any
 # routine that should be compiled separately for its libc and libm versions.
-calls = s_isinf s_isnan s_finite s_copysign s_modf s_scalbn s_frexp s_ldexp \
-	s_signbit
-generated += $(foreach s,.c .S l.c l.S f.c f.S,$(calls:s_%=m_%$s))
-routines = $(calls) $(calls:=f) $(long-c-$(long-double-fcts))
-long-c-yes = $(calls:=l)
+calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \
+	s_ldexpF s_signbitF
+generated += $(foreach s,.c .S,$(call type-foreach, $(calls:s_%=m_%$(s))))
+routines = $(call type-foreach, $(calls))
 
 ifeq ($(build-mathvec),yes)
 # We need to install libm.so as linker script
@@ -120,9 +151,6 @@ tests-static = test-fpucw-static test-fpucw-ieee-static \
 	       test-signgam-uchar-static test-signgam-uchar-init-static \
 	       test-signgam-uint-static test-signgam-uint-init-static \
 	       test-signgam-ullong-static test-signgam-ullong-init-static
-# We do the `long double' tests only if this data type is available and
-# distinct from `double'.
-test-longdouble-yes = test-ldouble test-ildoubl test-ldouble-finite
 
 ifneq (,$(CXX))
 tests += test-math-isinff
@@ -130,9 +158,10 @@ endif
 
 ifneq (no,$(PERL))
 libm-vec-tests = $(addprefix test-,$(libmvec-tests))
-libm-tests = test-float test-double $(test-longdouble-$(long-double-fcts)) \
-	test-ifloat test-idouble test-float-finite test-double-finite \
-	$(libm-vec-tests)
+
+libm-tests = $(foreach t,$(types),test-$(t) test-$(t)-finite test-i$(t)) \
+	     $(libm-vec-tests)
+
 libm-tests.o = $(addsuffix .o,$(libm-tests))
 
 tests += $(libm-tests)
@@ -155,16 +184,6 @@ $(objpfx)libm-test.stmp: $(ulps-file) libm-test.inc gen-libm-test.pl \
 	$(PERL) gen-libm-test.pl -u $< -o "$(objpfx)"
 	$(SHELL) gen-libm-have-vector-test.sh > $(objpfx)libm-have-vector-test.h
 	@echo > $@
-
-$(objpfx)test-float.o: $(objpfx)libm-test.stmp
-$(objpfx)test-ifloat.o: $(objpfx)libm-test.stmp
-$(objpfx)test-float-finite.o: $(objpfx)libm-test.stmp
-$(objpfx)test-double.o: $(objpfx)libm-test.stmp
-$(objpfx)test-idouble.o: $(objpfx)libm-test.stmp
-$(objpfx)test-double-finite.o: $(objpfx)libm-test.stmp
-$(objpfx)test-ldouble.o: $(objpfx)libm-test.stmp
-$(objpfx)test-ildoubl.o: $(objpfx)libm-test.stmp
-$(objpfx)test-ldouble-finite.o: $(objpfx)libm-test.stmp
 endif
 
 libm-test-fast-math-cflags = -fno-builtin -D__FAST_MATH__ -DTEST_FAST_MATH
@@ -216,7 +235,7 @@ CPPFLAGS-test-ifloat.c = -U__LIBC_INTERNAL_MATH_INLINES \
 			 $(libm-test-fast-math-cflags)
 CPPFLAGS-test-idouble.c = -U__LIBC_INTERNAL_MATH_INLINES \
 			  $(libm-test-fast-math-cflags)
-CPPFLAGS-test-ildoubl.c = -U__LIBC_INTERNAL_MATH_INLINES \
+CPPFLAGS-test-ildouble.c = -U__LIBC_INTERNAL_MATH_INLINES \
 			  $(libm-test-fast-math-cflags)
 
 CFLAGS-test-signgam-finite.c = -ffinite-math-only
@@ -247,7 +266,7 @@ include ../Rules
 
 ifneq (no,$(PERL))
 # This must come after the inclusion of sysdeps Makefiles via Rules.
-$(addprefix $(objpfx), $(addsuffix .o, $(libm-vec-tests))): $(objpfx)libm-test.stmp
+$(addprefix $(objpfx), $(libm-tests.o)): $(objpfx)libm-test.stmp
 
 # Run the math programs to automatically generate ULPs files.
 .PHONY: regen-ulps
diff --git a/math/test-ildoubl.c b/math/test-ildoubl.c
deleted file mode 100644
index dc0efaa..0000000
--- a/math/test-ildoubl.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Andreas Jaeger <aj@suse.de>, 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 "test-ldouble.h"
-#include "test-math-inline.h"
-#include "test-math-scalar.h"
-
-#define TEST_MSG "testing long double (inline functions)\n"
-
-#include "libm-test.c"
diff --git a/math/test-ildouble.c b/math/test-ildouble.c
new file mode 100644
index 0000000..dc0efaa
--- /dev/null
+++ b/math/test-ildouble.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>, 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 "test-ldouble.h"
+#include "test-math-inline.h"
+#include "test-math-scalar.h"
+
+#define TEST_MSG "testing long double (inline functions)\n"
+
+#include "libm-test.c"
-- 
2.4.11

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

* [PATCH 2/6] Support for type-generic libm function implementations libm
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (2 preceding siblings ...)
  2016-06-30 22:21   ` [PATCH 1/6] Refactor part of math Makefile Paul E. Murphy
@ 2016-06-30 22:21   ` Paul E. Murphy
  2016-08-03 20:10     ` Adhemerval Zanella
  2016-06-30 22:21   ` [PATCH 6/6] Convert remaining complex function to generated files Paul E. Murphy
                     ` (14 subsequent siblings)
  18 siblings, 1 reply; 53+ messages in thread
From: Paul E. Murphy @ 2016-06-30 22:21 UTC (permalink / raw)
  To: libc-alpha

This defines two new classes of libm objects.  g for
generated objects, and b for basic templates to
generate those objects.  The end result should be
much less duplication, and no function changes,
other than potential shuffling of the code within
libm.

As a simple example, the trivial complex functions
are converted to use the new infrastructure.

This uses some makefile hackery to generate g_*
objects from from the base b_*.c.  The intent is to
convert most or all of the complex function wrappers,
possibly even the wrappers for the e functions.

Hooks are added to enable a platform to override a
subset of generated files and replace them with a
platform supplied list of files via the
libm-gen-replacement-calls variable.  This is a
little kludgy as the set of files being moved
to this will likely include both unprefixed and
w_ prefixed files.  The intent is to minimize
awkward file renames.

Likewise, the alias for platforms which previously
didn't have long double support in glibc is handled
for trivial cases.  The more complex cases are left
to be handled individually.

I have verified the built objects for ppc64, x86_64,
alpha, arm, and m68k do not change in any meaningful
way with these changes using the Fedora cross toolchains.
I have verified the x86_64 and ppc64 changes still
run.

Verification is done by checking the objdump of
the g_*.{o,os} files with their equivalent s_
object prior to the patch.  Additionally nm is
used to verify the same set of symbols are
exported.

	* math/Makefile: Add support for routines generated
	via a macroed template file.
	(gen-libm-calls): New variable.
	(libm-calls-compat): Likewise.
	(gen-suffixes): Likewise.
	(g_CPPFLAGS): Likewise.
	(g__CPPFLAGS): Likewise.
	(g__fCPPFLAGS): Likewise.
	(g__lCPPFLAGS): Likewise.

	* sysdeps/generic/math-type-macros.h: New file.
	* sysdeps/ieee754/ldbl-opt/math-type-macros.h: Likewise.

	* math/cabs.c: Refactor into
	* math/b_cabs.c: new file.
	* math/cabsf.c: Removed.
	* math/cabsl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cabsf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cabsl.c: Removed.

	* math/carg.c: Refactor into
	* math/b_carg.c: new file.
	* math/cargf.c: Removed.
	* math/cargl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cargf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cargl.c: Removed.

	* math/conj.c: Refactor into
	* math/b_conj.c: new file.
	* math/conjf.c: Removed.
	* math/conjl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/conjf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/conjl.c: Removed.

	* math/cimag.c: Refactor into
	* math/b_cimag.c: new file.
	* math/cimagf.c: Removed.
	* math/cimagl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.

	* math/cimag.c: Refactor into
	* math/b_cimag.c: new file.
	* math/cimagf.c: Removed.
	* math/cimagl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.

	* sysdeps/ieee754/Makeconfig: New file.
	* Makeconfig: Move m_% sysd pattern rule into above.

	* scripts/sysd-rules.awk: Handle multiple rules
	with same DEP length correctly.

Fix intial generated code patch.
---
 Makeconfig                                  |   2 +-
 math/Makefile                               |  51 ++++++++-
 math/b_cabs.c                               |  33 ++++++
 math/b_carg.c                               |  33 ++++++
 math/b_cimag.c                              |  32 ++++++
 math/b_conj.c                               |  32 ++++++
 math/b_creal.c                              |  32 ++++++
 math/cabs.c                                 |  32 ------
 math/cabsf.c                                |  28 -----
 math/cabsl.c                                |  28 -----
 math/carg.c                                 |  32 ------
 math/cargf.c                                |  28 -----
 math/cargl.c                                |  28 -----
 math/cimag.c                                |  31 ------
 math/cimagf.c                               |  27 -----
 math/cimagl.c                               |  27 -----
 math/conj.c                                 |  31 ------
 math/conjf.c                                |  27 -----
 math/conjl.c                                |  27 -----
 math/creal.c                                |  31 ------
 math/crealf.c                               |  27 -----
 math/creall.c                               |  27 -----
 scripts/sysd-rules.awk                      |   5 +-
 sysdeps/alpha/fpu/Makefile                  |   4 +
 sysdeps/generic/math-type-macros.h          | 159 ++++++++++++++++++++++++++++
 sysdeps/ieee754/Makeconfig                  |   6 ++
 sysdeps/ieee754/ldbl-opt/cabs.c             |   6 --
 sysdeps/ieee754/ldbl-opt/cabsl.c            |   6 --
 sysdeps/ieee754/ldbl-opt/carg.c             |   6 --
 sysdeps/ieee754/ldbl-opt/cargl.c            |   6 --
 sysdeps/ieee754/ldbl-opt/cimag.c            |   6 --
 sysdeps/ieee754/ldbl-opt/cimagl.c           |   6 --
 sysdeps/ieee754/ldbl-opt/conj.c             |   6 --
 sysdeps/ieee754/ldbl-opt/conjl.c            |   6 --
 sysdeps/ieee754/ldbl-opt/creal.c            |   6 --
 sysdeps/ieee754/ldbl-opt/creall.c           |   6 --
 sysdeps/ieee754/ldbl-opt/math-type-macros.h |  11 ++
 37 files changed, 395 insertions(+), 496 deletions(-)
 create mode 100644 math/b_cabs.c
 create mode 100644 math/b_carg.c
 create mode 100644 math/b_cimag.c
 create mode 100644 math/b_conj.c
 create mode 100644 math/b_creal.c
 delete mode 100644 math/cabs.c
 delete mode 100644 math/cabsf.c
 delete mode 100644 math/cabsl.c
 delete mode 100644 math/carg.c
 delete mode 100644 math/cargf.c
 delete mode 100644 math/cargl.c
 delete mode 100644 math/cimag.c
 delete mode 100644 math/cimagf.c
 delete mode 100644 math/cimagl.c
 delete mode 100644 math/conj.c
 delete mode 100644 math/conjf.c
 delete mode 100644 math/conjl.c
 delete mode 100644 math/creal.c
 delete mode 100644 math/crealf.c
 delete mode 100644 math/creall.c
 create mode 100644 sysdeps/alpha/fpu/Makefile
 create mode 100644 sysdeps/generic/math-type-macros.h
 create mode 100644 sysdeps/ieee754/Makeconfig
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabs.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabsl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/carg.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cargl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimag.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimagl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conj.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conjl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creal.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creall.c
 create mode 100644 sysdeps/ieee754/ldbl-opt/math-type-macros.h

diff --git a/Makeconfig b/Makeconfig
index 901e253..8a7b5f2 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1124,7 +1124,7 @@ endif
 # emitted into sysd-rules.  A sysdeps Makeconfig fragment can
 # add its own special object file prefix to this list with e.g. foo-%:%
 # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
-sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
+sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:%
 
 # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
 sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
diff --git a/math/Makefile b/math/Makefile
index 89002a8..14f8f42 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -43,6 +43,18 @@ libm-support = s_lib_version s_matherr s_signgam			\
 	       fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt	\
 	       fegetexcept
 
+# These functions are generated from a common source with a select macros
+# for each type they built for.  There is an explicit underscore between
+# the function name and the type suffix to simplify matching to the
+# rule used to build it.  These all build from a common b_func.c file.
+#
+# Similarly, a platform can override any of these generated functions
+# (after type suffix substitution occurs) by adding a fragment which
+# 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
+
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
 	e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF	  \
@@ -59,13 +71,13 @@ 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	  \
-	conjF cimagF crealF cabsF cargF s_cexpF s_csinhF s_ccoshF s_clogF \
+	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_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			  \
-	s_nextupF s_nextdownF
+	s_nextupF s_nextdownF $(gen-libm-calls)
 
 libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl
 libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
@@ -105,7 +117,9 @@ type-float-routines :=
 type-foreach = $(foreach t,$(types),$(subst F,$(type-$(t)-suffix),$(1)))
 
 libm-routines = $(strip $(libm-support) $(libm-compat-calls)		\
-			$(call type-foreach, $(libm-calls))		\
+			$(filter-out $(libm-gen-calls-override),	\
+				$(call type-foreach, $(libm-calls)))	\
+			$(libm-gen-replacement-calls)			\
 			$(foreach t, $(types), $(type-$(t)-routines))) 	\
 
 # These functions are in libc instead of libm because __printf_fp
@@ -118,6 +132,9 @@ calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \
 generated += $(foreach s,.c .S,$(call type-foreach, $(calls:s_%=m_%$(s))))
 routines = $(call type-foreach, $(calls))
 
+# Wrappers and what not are generated per type to keep the noise down.
+generated += $(foreach s,.c .S,$(call type-foreach,$(gen-libm-calls:%=%$(s))))
+
 ifeq ($(build-mathvec),yes)
 # We need to install libm.so as linker script
 # for more comfortable use of vector math library.
@@ -303,6 +320,34 @@ endef
 object-suffixes-left := $(all-object-suffixes)
 include $(o-iterator)
 
+# Generated per-type files.
+#
+# Suffixes for each generated file.  This hackery makes it possible
+# to correctly identify name of the templated file.
+gen-suffixes := $(foreach s,$(all-object-suffixes), \
+                       $(foreach t,$(types),_$(type-$(t)-suffix)$s))
+
+# Add special flags to control how the templated functions
+# are built.
+g_CPPFLAGS = -include math-type-macros.h
+g__fCPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_FLOAT
+g__CPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_DOUBLE
+g__lCPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_LDOUBLE
+
+# Like m_% above, this builds the generic sources.  Makeconfig
+# enumerates the sysd-rules for overriding.
+define o-iterator-doit
+$(objpfx)g_%$o: b_%.c $(before-compile); $$(compile-command.c)
+endef
+object-suffixes-left := $(gen-suffixes)
+include $(o-iterator)
+
+# Tack on the appropriate CPPFLAGS to match sysd-rules
+define o-iterator-doit
+$(objpfx)g_%$o: CPPFLAGS += $(g_$(basename $o)CPPFLAGS)
+endef
+object-suffixes-left := $(gen-suffixes)
+include $(o-iterator)
 
 # This file defines the default _LIB_VERSION variable that controls
 # the error return conventions for the math functions.
diff --git a/math/b_cabs.c b/math/b_cabs.c
new file mode 100644
index 0000000..64265f1
--- /dev/null
+++ b/math/b_cabs.c
@@ -0,0 +1,33 @@
+/* Return the complex absolute value 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 <math.h>
+
+FLOAT
+M_SUF (__cabs) (CFLOAT z)
+{
+  return M_SUF (__hypot) (__real__ z, __imag__ z);
+}
+
+declare_mgen_alias (__cabs, cabs)
+
+#if M_LIBM_NEED_COMPAT (cabs)
+  declare_mgen_libm_compat (__cabs, cabs)
+#endif
diff --git a/math/b_carg.c b/math/b_carg.c
new file mode 100644
index 0000000..004e14d
--- /dev/null
+++ b/math/b_carg.c
@@ -0,0 +1,33 @@
+/* Compute argument 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 <math.h>
+
+FLOAT
+M_SUF (__carg) (CFLOAT x)
+{
+  return M_SUF (__atan2) (__imag__ x, __real__ x);
+}
+
+declare_mgen_alias (__carg, carg)
+
+#if M_LIBM_NEED_COMPAT (carg)
+  declare_mgen_libm_compat (__carg, carg)
+#endif
diff --git a/math/b_cimag.c b/math/b_cimag.c
new file mode 100644
index 0000000..73450f3
--- /dev/null
+++ b/math/b_cimag.c
@@ -0,0 +1,32 @@
+/* Return imaginary part 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>
+
+FLOAT
+M_SUF (__cimag) (CFLOAT z)
+{
+  return __imag__ z;
+}
+
+declare_mgen_alias (__cimag, cimag)
+
+#if M_LIBM_NEED_COMPAT (cimag)
+  declare_mgen_libm_compat (__cimag, cimag)
+#endif
diff --git a/math/b_conj.c b/math/b_conj.c
new file mode 100644
index 0000000..979a759
--- /dev/null
+++ b/math/b_conj.c
@@ -0,0 +1,32 @@
+/* Return complex conjugate 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>
+
+CFLOAT
+M_SUF (__conj) (CFLOAT z)
+{
+  return ~z;
+}
+
+declare_mgen_alias (__conj, conj)
+
+#if M_LIBM_NEED_COMPAT (conj)
+  declare_mgen_libm_compat (__conj, conj)
+#endif
diff --git a/math/b_creal.c b/math/b_creal.c
new file mode 100644
index 0000000..b92e0a3
--- /dev/null
+++ b/math/b_creal.c
@@ -0,0 +1,32 @@
+/* Return real part 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>
+
+FLOAT
+M_SUF (__creal) (CFLOAT z)
+{
+  return __real__ z;
+}
+
+declare_mgen_alias (__creal, creal)
+
+#if M_LIBM_NEED_COMPAT (creal)
+  declare_mgen_libm_compat (__creal, creal)
+#endif
diff --git a/math/cabs.c b/math/cabs.c
deleted file mode 100644
index d7e0665..0000000
--- a/math/cabs.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-double
-__cabs (double _Complex z)
-{
-  return __hypot (__real__ z, __imag__ z);
-}
-weak_alias (__cabs, cabs)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cabs, __cabsl)
-weak_alias (__cabs, cabsl)
-#endif
diff --git a/math/cabsf.c b/math/cabsf.c
deleted file mode 100644
index 431a244..0000000
--- a/math/cabsf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-float
-__cabsf (float _Complex z)
-{
-  return __hypotf (__real__ z, __imag__ z);
-}
-weak_alias (__cabsf, cabsf)
diff --git a/math/cabsl.c b/math/cabsl.c
deleted file mode 100644
index d87e3a2..0000000
--- a/math/cabsl.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-long double
-__cabsl (long double _Complex z)
-{
-  return __hypotl (__real__ z, __imag__ z);
-}
-weak_alias (__cabsl, cabsl)
diff --git a/math/carg.c b/math/carg.c
deleted file mode 100644
index 61f1e0d..0000000
--- a/math/carg.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Compute argument 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>
-
-double
-__carg (__complex__ double x)
-{
-  return __atan2 (__imag__ x, __real__ x);
-}
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
-#endif
diff --git a/math/cargf.c b/math/cargf.c
deleted file mode 100644
index 620db3e..0000000
--- a/math/cargf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Compute argument 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>
-
-float
-__cargf (__complex__ float x)
-{
-  return __atan2f (__imag__ x, __real__ x);
-}
-weak_alias (__cargf, cargf)
diff --git a/math/cargl.c b/math/cargl.c
deleted file mode 100644
index 31b7292..0000000
--- a/math/cargl.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Compute argument 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>
-
-long double
-__cargl (__complex__ long double x)
-{
-  return __atan2l (__imag__ x, __real__ x);
-}
-weak_alias (__cargl, cargl)
diff --git a/math/cimag.c b/math/cimag.c
deleted file mode 100644
index 1807ac2..0000000
--- a/math/cimag.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Return imaginary part 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>
-
-double
-__cimag (double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
-#endif
diff --git a/math/cimagf.c b/math/cimagf.c
deleted file mode 100644
index 67c37f4..0000000
--- a/math/cimagf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return imaginary part 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>
-
-float
-__cimagf (float _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimagf, cimagf)
diff --git a/math/cimagl.c b/math/cimagl.c
deleted file mode 100644
index c1d0910..0000000
--- a/math/cimagl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return imaginary part 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>
-
-long double
-__cimagl (long double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimagl, cimagl)
diff --git a/math/conj.c b/math/conj.c
deleted file mode 100644
index d282985..0000000
--- a/math/conj.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Return complex conjugate 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>
-
-double _Complex
-__conj (double _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conj, conj)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__conj, __conjl)
-weak_alias (__conj, conjl)
-#endif
diff --git a/math/conjf.c b/math/conjf.c
deleted file mode 100644
index 3587c94..0000000
--- a/math/conjf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return complex conjugate 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>
-
-float _Complex
-__conjf (float _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conjf, conjf)
diff --git a/math/conjl.c b/math/conjl.c
deleted file mode 100644
index 55bb393..0000000
--- a/math/conjl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return complex conjugate 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>
-
-long double _Complex
-__conjl (long double _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conjl, conjl)
diff --git a/math/creal.c b/math/creal.c
deleted file mode 100644
index 231d3b0..0000000
--- a/math/creal.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Return real part 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>
-
-double
-__creal (double _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__creal, creal)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__creal, __creall)
-weak_alias (__creal, creall)
-#endif
diff --git a/math/crealf.c b/math/crealf.c
deleted file mode 100644
index 5883849..0000000
--- a/math/crealf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return real part 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>
-
-float
-__crealf (float _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__crealf, crealf)
diff --git a/math/creall.c b/math/creall.c
deleted file mode 100644
index 4a31557..0000000
--- a/math/creall.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return real part 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>
-
-long double
-__creall (long double _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__creall, creall)
diff --git a/scripts/sysd-rules.awk b/scripts/sysd-rules.awk
index 69af400..ccf1dff 100644
--- a/scripts/sysd-rules.awk
+++ b/scripts/sysd-rules.awk
@@ -18,6 +18,9 @@ BEGIN {
   # They are no in particular order.  We need to sort them so that
   # the longest TARGET is first, and, among elements with the same
   # TARGET, the longest DEP is first.
+  #
+  # If two TARGETs have the same length DEP, the first TARGET is
+  # always listed first.
   for (i = 1; i <= npatterns; ++i) {
     if (split(patterns[i], td, ":") != 2) {
       msg = "bad sysd-rules-patterns element '" patterns[i] "'";
@@ -25,7 +28,7 @@ BEGIN {
       exit 2;
     }
     target_order = sprintf("%09d", npatterns + 1 - length(td[1]));
-    dep_order = sprintf("%09d", npatterns - length(td[2]));
+    dep_order = sprintf("%09d%03d", npatterns - length(td[2]), i);
     sort_patterns[target_order SUBSEP dep_order] = patterns[i];
   }
   asorti(sort_patterns, map_patterns);
diff --git a/sysdeps/alpha/fpu/Makefile b/sysdeps/alpha/fpu/Makefile
new file mode 100644
index 0000000..c49c302
--- /dev/null
+++ b/sysdeps/alpha/fpu/Makefile
@@ -0,0 +1,4 @@
+# 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
diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
new file mode 100644
index 0000000..3befde1
--- /dev/null
+++ b/sysdeps/generic/math-type-macros.h
@@ -0,0 +1,159 @@
+/* Helper macros for type generic function implementations within libm.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS
+#define _MATH_TYPE_MACROS
+
+#define M_FLOAT 1
+#define M_DOUBLE 2
+#define M_LDOUBLE 3
+
+#if M_TYPE == M_FLOAT
+# define M_PFX FLT
+# define M_LIT(c) c ## f
+/* Use the double version instead.  */
+# define M_MLIT(c) c
+# define M_SUF(c) c ## f
+# define M_FUNC(c) c ## f
+# define FLOAT float
+# define CFLOAT __complex__ float
+# define M_HUGE_VAL HUGE_VALF
+#elif M_TYPE == M_DOUBLE
+# define M_PFX DBL
+# define M_LIT(c) c
+# define M_MLIT(c) c
+# define M_SUF(c) c
+# define M_FUNC(c) c
+# define FLOAT double
+# define CFLOAT __complex__ double
+# define M_HUGE_VAL HUGE_VAL
+#elif M_TYPE == M_LDOUBLE
+# define M_PFX LDBL
+# define M_LIT(c) c ## L
+# define M_MLIT(c) c ## l
+# define M_SUF(c) c ## l
+# define M_FUNC(c) c ## l
+# define FLOAT long double
+# define CFLOAT __complex__ long double
+# define M_HUGE_VAL HUGE_VALL
+#else
+# error Error: M_TYPE is not a known floating point type
+#endif
+
+#define __M_CONCAT(a,b) a ## b
+#define __M_CONCATX(a,b) __M_CONCAT(a,b)
+
+#define M_NAN M_FUNC (__nan) ("")
+#define M_MAX_EXP __M_CONCATX (M_PFX, _MAX_EXP)
+#define M_MIN __M_CONCATX (M_PFX, _MIN)
+#define M_MAX __M_CONCATX (M_PFX, _MAX)
+#define M_MANT_DIG __M_CONCATX (M_PFX, _MANT_DIG)
+
+/* Helper macros for commonly used functions.  */
+#define M_COPYSIGN M_FUNC (__copysign)
+#define M_FABS M_FUNC (fabs)
+#define M_SINCOS M_FUNC (__sincos)
+#define M_SCALBN M_FUNC (__scalbn)
+#define M_LOG1P M_FUNC (__log1p)
+
+#define M_ATAN2 M_FUNC (__ieee754_atan2)
+#define M_COSH M_FUNC (__ieee754_cosh)
+#define M_EXP M_FUNC (__ieee754_exp)
+#define M_HYPOT M_FUNC (__ieee754_hypot)
+#define M_LOG M_FUNC (__ieee754_log)
+#define M_SINH M_FUNC (__ieee754_sinh)
+#define M_SQRT M_FUNC (__ieee754_sqrt)
+
+/* Needed to evaluate M_MANT_DIG below.  */
+#include <float.h>
+
+/* Use a special epsilon value for IBM long double
+   to avoid spurious overflows.  */
+#if M_MANT_DIG != 106
+# define M_EPSILON __M_CONCATX (M_PFX, _EPSILON)
+#else
+# define M_EPSILON 0x1p-106L
+#endif
+
+/* Enable overloading of function name to assist
+   reuse.  */
+#ifndef M_DECL_FUNC
+# define M_DECL_FUNC(f) M_FUNC(f)
+#endif
+
+/* Rules for aliasing the currently generated math files.  */
+
+/* Aliasing rules for float are straight forward.  */
+#if M_TYPE == M_FLOAT
+# define declare_mgen_alias(from, to) weak_alias (M_SUF (from), M_SUF (to))
+#endif
+
+/* Aliasing rules for double are sightly more
+   complicated.
+   1. long double == double.
+   2. long double used to be double.
+   3. double has always been unique. */
+#if M_TYPE == M_DOUBLE
+# if defined NO_LONG_DOUBLE
+#  define declare_mgen_alias(from, to)	    \
+    weak_alias (from, to)		    \
+    strong_alias (from, from ## l)	    \
+    weak_alias (from, to ## l)
+# else
+#  define declare_mgen_alias(from, to)	    \
+    weak_alias (M_SUF (from), M_SUF (to))
+# endif
+#endif
+
+/* Slightly simpler for long double.
+   1. long double used to be double.
+   2. long double has always been unique.  */
+#if M_TYPE == M_LDOUBLE
+# if defined LONG_DOUBLE_COMPAT_VERSION
+#  define declare_mgen_alias(from, to)		  \
+    long_double_symbol (libm, from ## l, to ## l);
+# else
+#  define declare_mgen_alias(from, to)	    \
+    weak_alias (M_SUF (from), M_SUF (to))
+# endif
+#endif
+
+#if ! defined declare_mgen_alias
+# error Alias rules not defined for M_TYPE
+#endif
+
+/* From case 2 for double, we may need to declare compat
+   aliases for double symbols mapping to long double.
+
+   This suffices for the majority of the complex functions.
+   More interesting cases need to be handled on a case by
+   case basis.  */
+#if M_TYPE == M_DOUBLE && defined LONG_DOUBLE_COMPAT_VERSION
+# define M_LIBM_NEED_COMPAT(f)				      \
+  LONG_DOUBLE_COMPAT (libm, LDOUBLE_ ## f ## l_libm_version)
+# define declare_mgen_libm_compat(from, to)	      \
+    compat_symbol (libm,			      \
+		   from,			      \
+		   to ## l,			      \
+		   LDOUBLE_ ## to ## l_libm_version);
+#else
+# define M_LIBM_NEED_COMPAT(func) 0
+# define declare_mgen_libm_compat(from, to)
+#endif
+
+#endif /* _MATH_TYPE_MACROS */
diff --git a/sysdeps/ieee754/Makeconfig b/sysdeps/ieee754/Makeconfig
new file mode 100644
index 0000000..15fd238
--- /dev/null
+++ b/sysdeps/ieee754/Makeconfig
@@ -0,0 +1,6 @@
+# Add the rules for generated math files in sysdeps
+# Not the perfect place, but close enough.
+#
+# Each type supported by libm should have a g_%_SUFFIX
+# pattern to match its suffix.
+sysd-rules-patterns += m_%:s_% g_%_f:b_% g_%_l:b_% g_%_:b_%
diff --git a/sysdeps/ieee754/ldbl-opt/cabs.c b/sysdeps/ieee754/ldbl-opt/cabs.c
deleted file mode 100644
index a181de2..0000000
--- a/sysdeps/ieee754/ldbl-opt/cabs.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/cabs.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cabs, cabsl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cabsl.c b/sysdeps/ieee754/ldbl-opt/cabsl.c
deleted file mode 100644
index b861633..0000000
--- a/sysdeps/ieee754/ldbl-opt/cabsl.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/cabsl.c>
-long_double_symbol (libm, __cabsl, cabsl);
diff --git a/sysdeps/ieee754/ldbl-opt/carg.c b/sysdeps/ieee754/ldbl-opt/carg.c
deleted file mode 100644
index 2ed3581..0000000
--- a/sysdeps/ieee754/ldbl-opt/carg.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/carg.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __carg, cargl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cargl.c b/sysdeps/ieee754/ldbl-opt/cargl.c
deleted file mode 100644
index 952dc60..0000000
--- a/sysdeps/ieee754/ldbl-opt/cargl.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/cargl.c>
-long_double_symbol (libm, __cargl, cargl);
diff --git a/sysdeps/ieee754/ldbl-opt/cimag.c b/sysdeps/ieee754/ldbl-opt/cimag.c
deleted file mode 100644
index f805258..0000000
--- a/sysdeps/ieee754/ldbl-opt/cimag.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/cimag.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cimag, cimagl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cimagl.c b/sysdeps/ieee754/ldbl-opt/cimagl.c
deleted file mode 100644
index 112365e..0000000
--- a/sysdeps/ieee754/ldbl-opt/cimagl.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/cimagl.c>
-long_double_symbol (libm, __cimagl, cimagl);
diff --git a/sysdeps/ieee754/ldbl-opt/conj.c b/sysdeps/ieee754/ldbl-opt/conj.c
deleted file mode 100644
index e4edade..0000000
--- a/sysdeps/ieee754/ldbl-opt/conj.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/conj.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __conj, conjl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/conjl.c b/sysdeps/ieee754/ldbl-opt/conjl.c
deleted file mode 100644
index c98e0ed..0000000
--- a/sysdeps/ieee754/ldbl-opt/conjl.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/conjl.c>
-long_double_symbol (libm, __conjl, conjl);
diff --git a/sysdeps/ieee754/ldbl-opt/creal.c b/sysdeps/ieee754/ldbl-opt/creal.c
deleted file mode 100644
index 0d1c93e..0000000
--- a/sysdeps/ieee754/ldbl-opt/creal.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/creal.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __creal, creall, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/creall.c b/sysdeps/ieee754/ldbl-opt/creall.c
deleted file mode 100644
index 68fedd4..0000000
--- a/sysdeps/ieee754/ldbl-opt/creall.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/creall.c>
-long_double_symbol (libm, __creall, creall);
diff --git a/sysdeps/ieee754/ldbl-opt/math-type-macros.h b/sysdeps/ieee754/ldbl-opt/math-type-macros.h
new file mode 100644
index 0000000..f963f77
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros.h
@@ -0,0 +1,11 @@
+/* Include the long double compatability support for generated math files.  */
+#include <math_ldbl_opt.h>
+
+/* Declare compat versions for generated functions.  */
+#define LDOUBLE_cabsl_libm_version GLIBC_2_1
+#define LDOUBLE_cargl_libm_version GLIBC_2_1
+#define LDOUBLE_cimagl_libm_version GLIBC_2_1
+#define LDOUBLE_conjl_libm_version GLIBC_2_1
+#define LDOUBLE_creall_libm_version GLIBC_2_1
+
+#include_next <math-type-macros.h>
-- 
2.4.11

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

* Re: [PATCH 0/6] Generate Complex functions from a common template.
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (5 preceding siblings ...)
  2016-06-30 22:21   ` [PATCH 4/6] Convert _Complex sine functions to generated code Paul E. Murphy
@ 2016-06-30 22:32   ` Joseph Myers
  2016-07-01  3:43     ` Paul E. Murphy
  2016-07-01  9:58   ` Pedro Alves
                     ` (11 subsequent siblings)
  18 siblings, 1 reply; 53+ messages in thread
From: Joseph Myers @ 2016-06-30 22:32 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha

On Thu, 30 Jun 2016, Paul E. Murphy wrote:

> math-type-macros.h hides much of the complexity of the
> aliasing for the common case, with cpow10 beings the
> exception.  Likewise, some heavily used functions

There's no such function as cpow10.

> Finally, a few functions have some very minor drift
> between the float, double, and ldouble variants. I
> have preserved these in order to keep my sanity
> when validating the generated code has not changed
> meaningifully.

In such cases, the right thing to do is to have preliminary patches that 
only address the drift, so that the comparison is clean in the subsequent 
stages.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 3/6] Convert _Complex cosine functions to generated code
  2016-06-30 22:21   ` [PATCH 3/6] Convert _Complex cosine " Paul E. Murphy
@ 2016-06-30 22:36     ` Joseph Myers
  2016-07-01  4:39       ` Paul E. Murphy
  2016-08-03 20:12     ` Adhemerval Zanella
  1 sibling, 1 reply; 53+ messages in thread
From: Joseph Myers @ 2016-06-30 22:36 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha

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.)

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 0/6] Generate Complex functions from a common template.
  2016-06-30 22:32   ` [PATCH 0/6] Generate Complex functions from a common template Joseph Myers
@ 2016-07-01  3:43     ` Paul E. Murphy
  2016-07-01 16:14       ` Joseph Myers
  0 siblings, 1 reply; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01  3:43 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 06/30/2016 05:32 PM, Joseph Myers wrote:
> On Thu, 30 Jun 2016, Paul E. Murphy wrote:
> 
>> math-type-macros.h hides much of the complexity of the
>> aliasing for the common case, with cpow10 beings the
>> exception.  Likewise, some heavily used functions
> 
> There's no such function as cpow10.

Whoops, that should read clog10.

> 
>> Finally, a few functions have some very minor drift
>> between the float, double, and ldouble variants. I
>> have preserved these in order to keep my sanity
>> when validating the generated code has not changed
>> meaningifully.
> 
> In such cases, the right thing to do is to have preliminary patches that 
> only address the drift, so that the comparison is clean in the subsequent 
> stages.

I believe there are only 4 such cases, and are very limited.
Spurious usage of glibc_likely in two cases, and two cases
of testing for FE_INVALID macro before trying to raise it.

The behavior is exclusive to s_ccosh*.c and s_csinh*.c.

The diff isn't much obfuscated by either.  If you can
tell me which is the desired behavior, I can propose
and submit those patches independently.

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

* Re: [PATCH 3/6] Convert _Complex cosine functions to generated code
  2016-06-30 22:36     ` Joseph Myers
@ 2016-07-01  4:39       ` Paul E. Murphy
  0 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01  4:39 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



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.

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

* Re: [PATCH 0/6] Generate Complex functions from a common template.
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (6 preceding siblings ...)
  2016-06-30 22:32   ` [PATCH 0/6] Generate Complex functions from a common template Joseph Myers
@ 2016-07-01  9:58   ` Pedro Alves
  2016-07-01 15:11     ` Paul E. Murphy
  2016-07-01 20:14   ` [PATCHv2 09/11] Convert _Complex tangent functions to generated code Paul E. Murphy
                     ` (10 subsequent siblings)
  18 siblings, 1 reply; 53+ messages in thread
From: Pedro Alves @ 2016-07-01  9:58 UTC (permalink / raw)
  To: Paul E. Murphy, libc-alpha

I got curious here and used "git diff -B -M30%" to (much) more
clearly see the real differences in the patches that mostly do
conversion to generated code, and spotted this funny change:

similarity index 37%
rename from math/s_clog10f.c
rename to math/b_clog10.c
index 485625e..eeb2d65 100644
--- c/math/s_clog10f.c
+++ w/math/b_clog10.c
@@ -6,9 +6,8 @@
    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,
+   version M_LIT (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.

:-)

(there are likely others, I stopped looking here.)

(I'd suggest considering posting the next revision of the series
with -M30% or some such threshold that catches all renames, to
ease review, but that's up to Joseph).

Thanks,
Pedro Alves

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

* Re: [PATCH 0/6] Generate Complex functions from a common template.
  2016-07-01  9:58   ` Pedro Alves
@ 2016-07-01 15:11     ` Paul E. Murphy
  2016-07-01 15:15       ` Zack Weinberg
  0 siblings, 1 reply; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01 15:11 UTC (permalink / raw)
  To: Pedro Alves, libc-alpha



On 07/01/2016 04:58 AM, Pedro Alves wrote:
> I got curious here and used "git diff -B -M30%" to (much) more
> clearly see the real differences in the patches that mostly do
> conversion to generated code, and spotted this funny change:
> 
> similarity index 37%
> rename from math/s_clog10f.c
> rename to math/b_clog10.c
> index 485625e..eeb2d65 100644
> --- c/math/s_clog10f.c
> +++ w/math/b_clog10.c
> @@ -6,9 +6,8 @@
>     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,
> +   version M_LIT (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.
> 
> :-)

Ah, some of the sausage making process spills out.  I've fixed those,
and improved (or fixed) the first line comments on most of the files
too.  Likewise, I fixed an M_LIT (0.0) translation inside another
comment after Joseph's suggestion for patch 3.

> 
> (there are likely others, I stopped looking here.)
> 
> (I'd suggest considering posting the next revision of the series
> with -M30% or some such threshold that catches all renames, to
> ease review, but that's up to Joseph).

I toyed around with various levels and options, none seem to
a good job of handling the renames.  I'm not sure there is a
one size fits all solution to getting a good, concise patch.

A thorough review might involve diffing the b_*.c file with
the equivalent real type file pre-patch.


Thanks,
Paul

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

* Re: [PATCH 0/6] Generate Complex functions from a common template.
  2016-07-01 15:11     ` Paul E. Murphy
@ 2016-07-01 15:15       ` Zack Weinberg
  2016-07-01 15:47         ` Paul E. Murphy
  0 siblings, 1 reply; 53+ messages in thread
From: Zack Weinberg @ 2016-07-01 15:15 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: Pedro Alves, GNU C Library

On Fri, Jul 1, 2016 at 11:11 AM, Paul E. Murphy
<murphyp@linux.vnet.ibm.com> wrote:
>
> I toyed around with various levels and options, none seem to
> a good job of handling the renames.  I'm not sure there is a
> one size fits all solution to getting a good, concise patch.
>
> A thorough review might involve diffing the b_*.c file with
> the equivalent real type file pre-patch.

Is it feasible for you to divide each patch that renames files into
one chunk that _just_ performs renames, and another that makes content
changes?  Obviously they would need to be squashed back together on
landing, otherwise the tree would be broken in the
renamed-but-not-edited changeset, but it would make it much easier to
review.  And I realize this might be a huge amount of tedious manual
work.

zw

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

* Re: [PATCH 0/6] Generate Complex functions from a common template.
  2016-07-01 15:15       ` Zack Weinberg
@ 2016-07-01 15:47         ` Paul E. Murphy
  0 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01 15:47 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: Pedro Alves, GNU C Library



On 07/01/2016 10:15 AM, Zack Weinberg wrote:
> On Fri, Jul 1, 2016 at 11:11 AM, Paul E. Murphy
> <murphyp@linux.vnet.ibm.com> wrote:
>>
>> I toyed around with various levels and options, none seem to
>> a good job of handling the renames.  I'm not sure there is a
>> one size fits all solution to getting a good, concise patch.
>>
>> A thorough review might involve diffing the b_*.c file with
>> the equivalent real type file pre-patch.
> 
> Is it feasible for you to divide each patch that renames files into
> one chunk that _just_ performs renames, and another that makes content
> changes?  Obviously they would need to be squashed back together on
> landing, otherwise the tree would be broken in the
> renamed-but-not-edited changeset, but it would make it much easier to
> review.  And I realize this might be a huge amount of tedious manual
> work.

That's a substantial amount of shuffling.  Let me twist that
idea a bit further.

I think an acceptable workaround is to prepend the latter four
patches with a patch to copy the double version to the b_ prefixed
file.  It won't break anything intermittently, and preserve the
changes in git rather than the mailing list.

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

* Re: [PATCH 0/6] Generate Complex functions from a common template.
  2016-07-01  3:43     ` Paul E. Murphy
@ 2016-07-01 16:14       ` Joseph Myers
  0 siblings, 0 replies; 53+ messages in thread
From: Joseph Myers @ 2016-07-01 16:14 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha

On Thu, 30 Jun 2016, Paul E. Murphy wrote:

> > In such cases, the right thing to do is to have preliminary patches that 
> > only address the drift, so that the comparison is clean in the subsequent 
> > stages.
> 
> I believe there are only 4 such cases, and are very limited.
> Spurious usage of glibc_likely in two cases, and two cases
> of testing for FE_INVALID macro before trying to raise it.
> 
> The behavior is exclusive to s_ccosh*.c and s_csinh*.c.
> 
> The diff isn't much obfuscated by either.  If you can
> tell me which is the desired behavior, I can propose
> and submit those patches independently.

Remove the #ifdef FE_INVALID.  Architectures not defining FE_* exceptions 
also have math_private.h defining feraiseexcept to do nothing.

Do not use __glibc_likely on rcls == FP_INFINITE.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* [PATCHv2 09/11] Convert _Complex tangent functions to generated code
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (7 preceding siblings ...)
  2016-07-01  9:58   ` Pedro Alves
@ 2016-07-01 20:14   ` Paul E. Murphy
  2016-07-01 20:14   ` [PATCHv2 02/11] Unify drift between _Complex function type variants Paul E. Murphy
                     ` (9 subsequent siblings)
  18 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01 20:14 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 b_c{,a}tan{,h}.c with the exception
of alpha.

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

	* math/s_catan.c: Refactor into b_catan.c
	* math/s_catanh.c: Refactor into b_catanh.c
	* math/s_ctan.c: Refactor into b_ctan.c
	* math/s_ctanh.c: Refactor into b_ctanh.c

	* math/b_catan.c: New file
	* math/b_catanh.c: New file
	* math/b_ctan.c: New file
	* math/b_ctanh.c: New file

	* 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/b_ctanh.c: New file
	* sysdeps/m68k/m680x0/fpu/s_ctanhf.c: Removed
	* sysdeps/m68k/m680x0/fpu/s_ctanhl.c: Removed

	* sysdeps/alpha/fpu/Makefile: Update to use template file
	* sysdeps/alpha/fpu/s_catanf.c: Update to use template file
	* sysdeps/alpha/fpu/s_catanhf.c: Update to use template file
	* sysdeps/alpha/fpu/s_ctanf.c: Update to use template file
	* sysdeps/alpha/fpu/s_ctanhf.c: Update to use template file

	* sysdeps/ieee754/ldbl-opt/math-type-macros.h: Add compat
	versions.
---
 math/Makefile                               |   5 +-
 math/b_catan.c                              | 104 ++++++++++----------
 math/b_catanh.c                             | 103 +++++++++----------
 math/b_ctan.c                               |  69 ++++++-------
 math/b_ctanh.c                              |  69 ++++++-------
 math/s_catan.c                              | 143 ---------------------------
 math/s_catanf.c                             | 143 ---------------------------
 math/s_catanh.c                             | 137 --------------------------
 math/s_catanhf.c                            | 137 --------------------------
 math/s_catanhl.c                            | 141 --------------------------
 math/s_catanl.c                             | 147 ----------------------------
 math/s_ctan.c                               | 129 ------------------------
 math/s_ctanf.c                              | 127 ------------------------
 math/s_ctanh.c                              | 129 ------------------------
 math/s_ctanhf.c                             | 127 ------------------------
 math/s_ctanhl.c                             | 132 -------------------------
 math/s_ctanl.c                              | 132 -------------------------
 sysdeps/alpha/fpu/Makefile                  |   8 +-
 sysdeps/alpha/fpu/s_catanf.c                |  13 ++-
 sysdeps/alpha/fpu/s_catanhf.c               |  13 ++-
 sysdeps/alpha/fpu/s_ctanf.c                 |  13 ++-
 sysdeps/alpha/fpu/s_ctanhf.c                |  13 ++-
 sysdeps/ieee754/ldbl-opt/math-type-macros.h |   4 +
 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 --
 31 files changed, 222 insertions(+), 1864 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 ac91a84..63a385d 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -55,7 +55,7 @@ libm-support = s_lib_version s_matherr s_signgam			\
 # 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 g_cacos_F \
 	g_cacosh_F g_ccos_F g_ccosh_F g_casin_F g_csin_F g_casinh_F	  \
-	g_k_casinh_F g_csinh_F
+	g_k_casinh_F g_csinh_F g_catanh_F g_catan_F g_ctan_F g_ctanh_F
 
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
@@ -74,8 +74,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/b_catan.c b/math/b_catan.c
index 5ab4c0d..3a7afc1 100644
--- a/math/b_catan.c
+++ b/math/b_catan.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_FUNC (__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/b_catanh.c b/math/b_catanh.c
index 11ea062..27e3856 100644
--- a/math/b_catanh.c
+++ b/math/b_catanh.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,75 @@ __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 == -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_FUNC (__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 +132,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/b_ctan.c b/math/b_ctan.c
index 8e8bf2e..712614d 100644
--- a/math/b_ctan.c
+++ b/math/b_ctan.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/b_ctanh.c b/math/b_ctanh.c
index 2d18875..692ebe4 100644
--- a/math/b_ctanh.c
+++ b/math/b_ctanh.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_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_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_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_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_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/Makefile b/sysdeps/alpha/fpu/Makefile
index 3ae1451..d8ccf86 100644
--- a/sysdeps/alpha/fpu/Makefile
+++ b/sysdeps/alpha/fpu/Makefile
@@ -2,7 +2,7 @@
 # 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 \
 	g_cacos_f g_cacosh_f g_ccos_f g_ccosh_f g_casin_f g_csin_f	 \
-	g_casinh_f g_csinh_f
-libm-gen-replacement-calls = cabsf cargf cimagf crealf conjf \
-	s_cacosf s_cacoshf s_ccosf s_ccoshf s_casinf s_csinf \
-	s_casinhf s_csinhf
+	g_casinh_f g_csinh_f g_catan_f g_catanh_f g_ctan_f g_ctanh_f
+libm-gen-replacement-calls = cabsf cargf cimagf crealf conjf	\
+	s_cacosf s_cacoshf s_ccosf s_ccoshf s_casinf s_csinf	\
+	s_casinhf s_csinhf s_catanf s_catanhf s_ctanf s_ctanhf
diff --git a/sysdeps/alpha/fpu/s_catanf.c b/sysdeps/alpha/fpu/s_catanf.c
index 76c1718..bc2b7eb 100644
--- a/sysdeps/alpha/fpu/s_catanf.c
+++ b/sysdeps/alpha/fpu/s_catanf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __catanf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_catan.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..46b73b6 100644
--- a/sysdeps/alpha/fpu/s_catanhf.c
+++ b/sysdeps/alpha/fpu/s_catanhf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __catanhf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_catanh.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..fe9b619 100644
--- a/sysdeps/alpha/fpu/s_ctanf.c
+++ b/sysdeps/alpha/fpu/s_ctanf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __ctanf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_ctan.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..0d6e0dc 100644
--- a/sysdeps/alpha/fpu/s_ctanhf.c
+++ b/sysdeps/alpha/fpu/s_ctanhf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __ctanhf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_ctanh.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_ctanhf (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 061ba33..646489e 100644
--- a/sysdeps/ieee754/ldbl-opt/math-type-macros.h
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros.h
@@ -15,5 +15,9 @@
 #define LDOUBLE_csinl_libm_version GLIBC_2_1
 #define LDOUBLE_casinhl_libm_version GLIBC_2_1
 #define LDOUBLE_csinhl_libm_version GLIBC_2_1
+#define LDOUBLE_catanl_libm_version GLIBC_2_1
+#define LDOUBLE_catanhl_libm_version GLIBC_2_1
+#define LDOUBLE_ctanl_libm_version GLIBC_2_1
+#define LDOUBLE_ctanhl_libm_version GLIBC_2_1
 
 #include_next <math-type-macros.h>
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] 53+ messages in thread

* [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (15 preceding siblings ...)
  2016-07-01 20:14   ` [PATCHv2 10/11] Prepare to convert remaining _Complex functions Paul E. Murphy
@ 2016-07-01 20:14   ` Paul E. Murphy
  2016-08-02 21:53     ` Joseph Myers
  2016-07-01 20:15   ` [PATCHv2 11/11] Convert remaining complex function to generated files Paul E. Murphy
  2016-07-01 20:15   ` [PATCHv2 04/11] Prepare to convert _Complex cosine functions Paul E. Murphy
  18 siblings, 1 reply; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01 20:14 UTC (permalink / raw)
  To: libc-alpha

This defines two new classes of libm objects.  g for
generated objects, and b for basic templates to
generate those objects.  The end result should be
much less duplication, and no function changes,
other than potential shuffling of the code within
libm.

As a simple example, the trivial complex functions
are converted to use the new infrastructure.

This uses some makefile hackery to generate g_*
objects from from the base b_*.c.  The intent is to
convert most or all of the complex function wrappers,
possibly even the wrappers for the e functions.

Hooks are added to enable a platform to override a
subset of generated files and replace them with a
platform supplied list of files via the
libm-gen-replacement-calls variable.  This is a
little kludgy as the set of files being moved
to this will likely include both unprefixed and
w_ prefixed files.  The intent is to minimize
awkward file renames.

Likewise, the alias for platforms which previously
didn't have long double support in glibc is handled
for trivial cases.  The more complex cases are left
to be handled individually.

I have verified the built objects for ppc64, x86_64,
alpha, arm, and m68k do not change in any meaningful
way with these changes using the Fedora cross toolchains.
I have verified the x86_64 and ppc64 changes still run.

Verification is done by checking the objdump of
the g_*.{o,os} files with their equivalent s_
object prior to the patch.  Additionally nm is
used to verify the same set of symbols are
exported.

	* math/Makefile: Add support for routines generated
	via a macroed template file.
	(gen-libm-calls): New variable.
	(libm-calls-compat): Likewise.
	(gen-suffixes): Likewise.
	(g_CPPFLAGS): Likewise.
	(g__CPPFLAGS): Likewise.
	(g__fCPPFLAGS): Likewise.
	(g__lCPPFLAGS): Likewise.

	* sysdeps/generic/math-type-macros.h: New file.
	* sysdeps/ieee754/ldbl-opt/math-type-macros.h: Likewise.

	* math/cabs.c: Refactor into
	* math/b_cabs.c: new file.
	* math/cabsf.c: Removed.
	* math/cabsl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cabsf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cabsl.c: Removed.

	* math/carg.c: Refactor into
	* math/b_carg.c: new file.
	* math/cargf.c: Removed.
	* math/cargl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cargf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cargl.c: Removed.

	* math/conj.c: Refactor into
	* math/b_conj.c: new file.
	* math/conjf.c: Removed.
	* math/conjl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/conjf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/conjl.c: Removed.

	* math/cimag.c: Refactor into
	* math/b_cimag.c: new file.
	* math/cimagf.c: Removed.
	* math/cimagl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.

	* math/cimag.c: Refactor into
	* math/b_cimag.c: new file.
	* math/cimagf.c: Removed.
	* math/cimagl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.

	* sysdeps/ieee754/Makeconfig: New file.
	* Makeconfig: Move m_% sysd pattern rule into above.

	* scripts/sysd-rules.awk: Handle multiple rules
	with same DEP length correctly.

Fix intial generated code patch.
---
 Makeconfig                                  |   2 +-
 math/Makefile                               |  51 ++++++++-
 math/{cabs.c => b_cabs.c}                   |  17 +--
 math/{carg.c => b_carg.c}                   |  17 +--
 math/{cimag.c => b_cimag.c}                 |  15 +--
 math/{conjf.c => b_conj.c}                  |  13 ++-
 math/{creal.c => b_creal.c}                 |  15 +--
 math/cabsf.c                                |  28 -----
 math/cabsl.c                                |  28 -----
 math/cargf.c                                |  28 -----
 math/cargl.c                                |  28 -----
 math/cimagf.c                               |  27 -----
 math/cimagl.c                               |  27 -----
 math/conj.c                                 |  31 ------
 math/conjl.c                                |  27 -----
 math/crealf.c                               |  27 -----
 math/creall.c                               |  27 -----
 scripts/sysd-rules.awk                      |   5 +-
 sysdeps/alpha/fpu/Makefile                  |   4 +
 sysdeps/generic/math-type-macros.h          | 159 ++++++++++++++++++++++++++++
 sysdeps/ieee754/Makeconfig                  |   6 ++
 sysdeps/ieee754/ldbl-opt/cabs.c             |   6 --
 sysdeps/ieee754/ldbl-opt/cabsl.c            |   6 --
 sysdeps/ieee754/ldbl-opt/carg.c             |   6 --
 sysdeps/ieee754/ldbl-opt/cargl.c            |   6 --
 sysdeps/ieee754/ldbl-opt/cimag.c            |   6 --
 sysdeps/ieee754/ldbl-opt/cimagl.c           |   6 --
 sysdeps/ieee754/ldbl-opt/conj.c             |   6 --
 sysdeps/ieee754/ldbl-opt/conjl.c            |   6 --
 sysdeps/ieee754/ldbl-opt/creal.c            |   6 --
 sysdeps/ieee754/ldbl-opt/creall.c           |   6 --
 sysdeps/ieee754/ldbl-opt/math-type-macros.h |  11 ++
 32 files changed, 276 insertions(+), 377 deletions(-)
 rename math/{cabs.c => b_cabs.c} (78%)
 rename math/{carg.c => b_carg.c} (79%)
 rename math/{cimag.c => b_cimag.c} (82%)
 rename math/{conjf.c => b_conj.c} (81%)
 rename math/{creal.c => b_creal.c} (82%)
 delete mode 100644 math/cabsf.c
 delete mode 100644 math/cabsl.c
 delete mode 100644 math/cargf.c
 delete mode 100644 math/cargl.c
 delete mode 100644 math/cimagf.c
 delete mode 100644 math/cimagl.c
 delete mode 100644 math/conj.c
 delete mode 100644 math/conjl.c
 delete mode 100644 math/crealf.c
 delete mode 100644 math/creall.c
 create mode 100644 sysdeps/alpha/fpu/Makefile
 create mode 100644 sysdeps/generic/math-type-macros.h
 create mode 100644 sysdeps/ieee754/Makeconfig
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabs.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabsl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/carg.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cargl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimag.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimagl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conj.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conjl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creal.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creall.c
 create mode 100644 sysdeps/ieee754/ldbl-opt/math-type-macros.h

diff --git a/Makeconfig b/Makeconfig
index 901e253..8a7b5f2 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1124,7 +1124,7 @@ endif
 # emitted into sysd-rules.  A sysdeps Makeconfig fragment can
 # add its own special object file prefix to this list with e.g. foo-%:%
 # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
-sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
+sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:%
 
 # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
 sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
diff --git a/math/Makefile b/math/Makefile
index 89002a8..14f8f42 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -43,6 +43,18 @@ libm-support = s_lib_version s_matherr s_signgam			\
 	       fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt	\
 	       fegetexcept
 
+# These functions are generated from a common source with a select macros
+# for each type they built for.  There is an explicit underscore between
+# the function name and the type suffix to simplify matching to the
+# rule used to build it.  These all build from a common b_func.c file.
+#
+# Similarly, a platform can override any of these generated functions
+# (after type suffix substitution occurs) by adding a fragment which
+# 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
+
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
 	e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF	  \
@@ -59,13 +71,13 @@ 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	  \
-	conjF cimagF crealF cabsF cargF s_cexpF s_csinhF s_ccoshF s_clogF \
+	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_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			  \
-	s_nextupF s_nextdownF
+	s_nextupF s_nextdownF $(gen-libm-calls)
 
 libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl
 libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
@@ -105,7 +117,9 @@ type-float-routines :=
 type-foreach = $(foreach t,$(types),$(subst F,$(type-$(t)-suffix),$(1)))
 
 libm-routines = $(strip $(libm-support) $(libm-compat-calls)		\
-			$(call type-foreach, $(libm-calls))		\
+			$(filter-out $(libm-gen-calls-override),	\
+				$(call type-foreach, $(libm-calls)))	\
+			$(libm-gen-replacement-calls)			\
 			$(foreach t, $(types), $(type-$(t)-routines))) 	\
 
 # These functions are in libc instead of libm because __printf_fp
@@ -118,6 +132,9 @@ calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \
 generated += $(foreach s,.c .S,$(call type-foreach, $(calls:s_%=m_%$(s))))
 routines = $(call type-foreach, $(calls))
 
+# Wrappers and what not are generated per type to keep the noise down.
+generated += $(foreach s,.c .S,$(call type-foreach,$(gen-libm-calls:%=%$(s))))
+
 ifeq ($(build-mathvec),yes)
 # We need to install libm.so as linker script
 # for more comfortable use of vector math library.
@@ -303,6 +320,34 @@ endef
 object-suffixes-left := $(all-object-suffixes)
 include $(o-iterator)
 
+# Generated per-type files.
+#
+# Suffixes for each generated file.  This hackery makes it possible
+# to correctly identify name of the templated file.
+gen-suffixes := $(foreach s,$(all-object-suffixes), \
+                       $(foreach t,$(types),_$(type-$(t)-suffix)$s))
+
+# Add special flags to control how the templated functions
+# are built.
+g_CPPFLAGS = -include math-type-macros.h
+g__fCPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_FLOAT
+g__CPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_DOUBLE
+g__lCPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_LDOUBLE
+
+# Like m_% above, this builds the generic sources.  Makeconfig
+# enumerates the sysd-rules for overriding.
+define o-iterator-doit
+$(objpfx)g_%$o: b_%.c $(before-compile); $$(compile-command.c)
+endef
+object-suffixes-left := $(gen-suffixes)
+include $(o-iterator)
+
+# Tack on the appropriate CPPFLAGS to match sysd-rules
+define o-iterator-doit
+$(objpfx)g_%$o: CPPFLAGS += $(g_$(basename $o)CPPFLAGS)
+endef
+object-suffixes-left := $(gen-suffixes)
+include $(o-iterator)
 
 # This file defines the default _LIB_VERSION variable that controls
 # the error return conventions for the math functions.
diff --git a/math/cabs.c b/math/b_cabs.c
similarity index 78%
rename from math/cabs.c
rename to math/b_cabs.c
index d7e0665..64265f1 100644
--- a/math/cabs.c
+++ b/math/b_cabs.c
@@ -1,4 +1,4 @@
-/* Return the complex absolute value of double complex value.
+/* Return the complex absolute value 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.
@@ -20,13 +20,14 @@
 #include <complex.h>
 #include <math.h>
 
-double
-__cabs (double _Complex z)
+FLOAT
+M_SUF (__cabs) (CFLOAT z)
 {
-  return __hypot (__real__ z, __imag__ z);
+  return M_SUF (__hypot) (__real__ z, __imag__ z);
 }
-weak_alias (__cabs, cabs)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cabs, __cabsl)
-weak_alias (__cabs, cabsl)
+
+declare_mgen_alias (__cabs, cabs)
+
+#if M_LIBM_NEED_COMPAT (cabs)
+  declare_mgen_libm_compat (__cabs, cabs)
 #endif
diff --git a/math/carg.c b/math/b_carg.c
similarity index 79%
rename from math/carg.c
rename to math/b_carg.c
index 61f1e0d..004e14d 100644
--- a/math/carg.c
+++ b/math/b_carg.c
@@ -1,4 +1,4 @@
-/* Compute argument of complex double value.
+/* Compute argument 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.
@@ -20,13 +20,14 @@
 #include <complex.h>
 #include <math.h>
 
-double
-__carg (__complex__ double x)
+FLOAT
+M_SUF (__carg) (CFLOAT x)
 {
-  return __atan2 (__imag__ x, __real__ x);
+  return M_SUF (__atan2) (__imag__ x, __real__ x);
 }
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
+
+declare_mgen_alias (__carg, carg)
+
+#if M_LIBM_NEED_COMPAT (carg)
+  declare_mgen_libm_compat (__carg, carg)
 #endif
diff --git a/math/cimag.c b/math/b_cimag.c
similarity index 82%
rename from math/cimag.c
rename to math/b_cimag.c
index 1807ac2..73450f3 100644
--- a/math/cimag.c
+++ b/math/b_cimag.c
@@ -1,4 +1,4 @@
-/* Return imaginary part of complex double value.
+/* Return imaginary part 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double
-__cimag (double _Complex z)
+FLOAT
+M_SUF (__cimag) (CFLOAT z)
 {
   return __imag__ z;
 }
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
+
+declare_mgen_alias (__cimag, cimag)
+
+#if M_LIBM_NEED_COMPAT (cimag)
+  declare_mgen_libm_compat (__cimag, cimag)
 #endif
diff --git a/math/conjf.c b/math/b_conj.c
similarity index 81%
rename from math/conjf.c
rename to math/b_conj.c
index 3587c94..979a759 100644
--- a/math/conjf.c
+++ b/math/b_conj.c
@@ -1,4 +1,4 @@
-/* Return complex conjugate of complex float value.
+/* Return complex conjugate 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.
@@ -19,9 +19,14 @@
 
 #include <complex.h>
 
-float _Complex
-__conjf (float _Complex z)
+CFLOAT
+M_SUF (__conj) (CFLOAT z)
 {
   return ~z;
 }
-weak_alias (__conjf, conjf)
+
+declare_mgen_alias (__conj, conj)
+
+#if M_LIBM_NEED_COMPAT (conj)
+  declare_mgen_libm_compat (__conj, conj)
+#endif
diff --git a/math/creal.c b/math/b_creal.c
similarity index 82%
rename from math/creal.c
rename to math/b_creal.c
index 231d3b0..b92e0a3 100644
--- a/math/creal.c
+++ b/math/b_creal.c
@@ -1,4 +1,4 @@
-/* Return real part of complex double value.
+/* Return real part 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double
-__creal (double _Complex z)
+FLOAT
+M_SUF (__creal) (CFLOAT z)
 {
   return __real__ z;
 }
-weak_alias (__creal, creal)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__creal, __creall)
-weak_alias (__creal, creall)
+
+declare_mgen_alias (__creal, creal)
+
+#if M_LIBM_NEED_COMPAT (creal)
+  declare_mgen_libm_compat (__creal, creal)
 #endif
diff --git a/math/cabsf.c b/math/cabsf.c
deleted file mode 100644
index 431a244..0000000
--- a/math/cabsf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-float
-__cabsf (float _Complex z)
-{
-  return __hypotf (__real__ z, __imag__ z);
-}
-weak_alias (__cabsf, cabsf)
diff --git a/math/cabsl.c b/math/cabsl.c
deleted file mode 100644
index d87e3a2..0000000
--- a/math/cabsl.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-long double
-__cabsl (long double _Complex z)
-{
-  return __hypotl (__real__ z, __imag__ z);
-}
-weak_alias (__cabsl, cabsl)
diff --git a/math/cargf.c b/math/cargf.c
deleted file mode 100644
index 620db3e..0000000
--- a/math/cargf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Compute argument 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>
-
-float
-__cargf (__complex__ float x)
-{
-  return __atan2f (__imag__ x, __real__ x);
-}
-weak_alias (__cargf, cargf)
diff --git a/math/cargl.c b/math/cargl.c
deleted file mode 100644
index 31b7292..0000000
--- a/math/cargl.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Compute argument 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>
-
-long double
-__cargl (__complex__ long double x)
-{
-  return __atan2l (__imag__ x, __real__ x);
-}
-weak_alias (__cargl, cargl)
diff --git a/math/cimagf.c b/math/cimagf.c
deleted file mode 100644
index 67c37f4..0000000
--- a/math/cimagf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return imaginary part 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>
-
-float
-__cimagf (float _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimagf, cimagf)
diff --git a/math/cimagl.c b/math/cimagl.c
deleted file mode 100644
index c1d0910..0000000
--- a/math/cimagl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return imaginary part 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>
-
-long double
-__cimagl (long double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimagl, cimagl)
diff --git a/math/conj.c b/math/conj.c
deleted file mode 100644
index d282985..0000000
--- a/math/conj.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Return complex conjugate 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>
-
-double _Complex
-__conj (double _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conj, conj)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__conj, __conjl)
-weak_alias (__conj, conjl)
-#endif
diff --git a/math/conjl.c b/math/conjl.c
deleted file mode 100644
index 55bb393..0000000
--- a/math/conjl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return complex conjugate 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>
-
-long double _Complex
-__conjl (long double _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conjl, conjl)
diff --git a/math/crealf.c b/math/crealf.c
deleted file mode 100644
index 5883849..0000000
--- a/math/crealf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return real part 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>
-
-float
-__crealf (float _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__crealf, crealf)
diff --git a/math/creall.c b/math/creall.c
deleted file mode 100644
index 4a31557..0000000
--- a/math/creall.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return real part 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>
-
-long double
-__creall (long double _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__creall, creall)
diff --git a/scripts/sysd-rules.awk b/scripts/sysd-rules.awk
index 69af400..ccf1dff 100644
--- a/scripts/sysd-rules.awk
+++ b/scripts/sysd-rules.awk
@@ -18,6 +18,9 @@ BEGIN {
   # They are no in particular order.  We need to sort them so that
   # the longest TARGET is first, and, among elements with the same
   # TARGET, the longest DEP is first.
+  #
+  # If two TARGETs have the same length DEP, the first TARGET is
+  # always listed first.
   for (i = 1; i <= npatterns; ++i) {
     if (split(patterns[i], td, ":") != 2) {
       msg = "bad sysd-rules-patterns element '" patterns[i] "'";
@@ -25,7 +28,7 @@ BEGIN {
       exit 2;
     }
     target_order = sprintf("%09d", npatterns + 1 - length(td[1]));
-    dep_order = sprintf("%09d", npatterns - length(td[2]));
+    dep_order = sprintf("%09d%03d", npatterns - length(td[2]), i);
     sort_patterns[target_order SUBSEP dep_order] = patterns[i];
   }
   asorti(sort_patterns, map_patterns);
diff --git a/sysdeps/alpha/fpu/Makefile b/sysdeps/alpha/fpu/Makefile
new file mode 100644
index 0000000..c49c302
--- /dev/null
+++ b/sysdeps/alpha/fpu/Makefile
@@ -0,0 +1,4 @@
+# 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
diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
new file mode 100644
index 0000000..3befde1
--- /dev/null
+++ b/sysdeps/generic/math-type-macros.h
@@ -0,0 +1,159 @@
+/* Helper macros for type generic function implementations within libm.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS
+#define _MATH_TYPE_MACROS
+
+#define M_FLOAT 1
+#define M_DOUBLE 2
+#define M_LDOUBLE 3
+
+#if M_TYPE == M_FLOAT
+# define M_PFX FLT
+# define M_LIT(c) c ## f
+/* Use the double version instead.  */
+# define M_MLIT(c) c
+# define M_SUF(c) c ## f
+# define M_FUNC(c) c ## f
+# define FLOAT float
+# define CFLOAT __complex__ float
+# define M_HUGE_VAL HUGE_VALF
+#elif M_TYPE == M_DOUBLE
+# define M_PFX DBL
+# define M_LIT(c) c
+# define M_MLIT(c) c
+# define M_SUF(c) c
+# define M_FUNC(c) c
+# define FLOAT double
+# define CFLOAT __complex__ double
+# define M_HUGE_VAL HUGE_VAL
+#elif M_TYPE == M_LDOUBLE
+# define M_PFX LDBL
+# define M_LIT(c) c ## L
+# define M_MLIT(c) c ## l
+# define M_SUF(c) c ## l
+# define M_FUNC(c) c ## l
+# define FLOAT long double
+# define CFLOAT __complex__ long double
+# define M_HUGE_VAL HUGE_VALL
+#else
+# error Error: M_TYPE is not a known floating point type
+#endif
+
+#define __M_CONCAT(a,b) a ## b
+#define __M_CONCATX(a,b) __M_CONCAT(a,b)
+
+#define M_NAN M_FUNC (__nan) ("")
+#define M_MAX_EXP __M_CONCATX (M_PFX, _MAX_EXP)
+#define M_MIN __M_CONCATX (M_PFX, _MIN)
+#define M_MAX __M_CONCATX (M_PFX, _MAX)
+#define M_MANT_DIG __M_CONCATX (M_PFX, _MANT_DIG)
+
+/* Helper macros for commonly used functions.  */
+#define M_COPYSIGN M_FUNC (__copysign)
+#define M_FABS M_FUNC (fabs)
+#define M_SINCOS M_FUNC (__sincos)
+#define M_SCALBN M_FUNC (__scalbn)
+#define M_LOG1P M_FUNC (__log1p)
+
+#define M_ATAN2 M_FUNC (__ieee754_atan2)
+#define M_COSH M_FUNC (__ieee754_cosh)
+#define M_EXP M_FUNC (__ieee754_exp)
+#define M_HYPOT M_FUNC (__ieee754_hypot)
+#define M_LOG M_FUNC (__ieee754_log)
+#define M_SINH M_FUNC (__ieee754_sinh)
+#define M_SQRT M_FUNC (__ieee754_sqrt)
+
+/* Needed to evaluate M_MANT_DIG below.  */
+#include <float.h>
+
+/* Use a special epsilon value for IBM long double
+   to avoid spurious overflows.  */
+#if M_MANT_DIG != 106
+# define M_EPSILON __M_CONCATX (M_PFX, _EPSILON)
+#else
+# define M_EPSILON 0x1p-106L
+#endif
+
+/* Enable overloading of function name to assist
+   reuse.  */
+#ifndef M_DECL_FUNC
+# define M_DECL_FUNC(f) M_FUNC(f)
+#endif
+
+/* Rules for aliasing the currently generated math files.  */
+
+/* Aliasing rules for float are straight forward.  */
+#if M_TYPE == M_FLOAT
+# define declare_mgen_alias(from, to) weak_alias (M_SUF (from), M_SUF (to))
+#endif
+
+/* Aliasing rules for double are sightly more
+   complicated.
+   1. long double == double.
+   2. long double used to be double.
+   3. double has always been unique. */
+#if M_TYPE == M_DOUBLE
+# if defined NO_LONG_DOUBLE
+#  define declare_mgen_alias(from, to)	    \
+    weak_alias (from, to)		    \
+    strong_alias (from, from ## l)	    \
+    weak_alias (from, to ## l)
+# else
+#  define declare_mgen_alias(from, to)	    \
+    weak_alias (M_SUF (from), M_SUF (to))
+# endif
+#endif
+
+/* Slightly simpler for long double.
+   1. long double used to be double.
+   2. long double has always been unique.  */
+#if M_TYPE == M_LDOUBLE
+# if defined LONG_DOUBLE_COMPAT_VERSION
+#  define declare_mgen_alias(from, to)		  \
+    long_double_symbol (libm, from ## l, to ## l);
+# else
+#  define declare_mgen_alias(from, to)	    \
+    weak_alias (M_SUF (from), M_SUF (to))
+# endif
+#endif
+
+#if ! defined declare_mgen_alias
+# error Alias rules not defined for M_TYPE
+#endif
+
+/* From case 2 for double, we may need to declare compat
+   aliases for double symbols mapping to long double.
+
+   This suffices for the majority of the complex functions.
+   More interesting cases need to be handled on a case by
+   case basis.  */
+#if M_TYPE == M_DOUBLE && defined LONG_DOUBLE_COMPAT_VERSION
+# define M_LIBM_NEED_COMPAT(f)				      \
+  LONG_DOUBLE_COMPAT (libm, LDOUBLE_ ## f ## l_libm_version)
+# define declare_mgen_libm_compat(from, to)	      \
+    compat_symbol (libm,			      \
+		   from,			      \
+		   to ## l,			      \
+		   LDOUBLE_ ## to ## l_libm_version);
+#else
+# define M_LIBM_NEED_COMPAT(func) 0
+# define declare_mgen_libm_compat(from, to)
+#endif
+
+#endif /* _MATH_TYPE_MACROS */
diff --git a/sysdeps/ieee754/Makeconfig b/sysdeps/ieee754/Makeconfig
new file mode 100644
index 0000000..15fd238
--- /dev/null
+++ b/sysdeps/ieee754/Makeconfig
@@ -0,0 +1,6 @@
+# Add the rules for generated math files in sysdeps
+# Not the perfect place, but close enough.
+#
+# Each type supported by libm should have a g_%_SUFFIX
+# pattern to match its suffix.
+sysd-rules-patterns += m_%:s_% g_%_f:b_% g_%_l:b_% g_%_:b_%
diff --git a/sysdeps/ieee754/ldbl-opt/cabs.c b/sysdeps/ieee754/ldbl-opt/cabs.c
deleted file mode 100644
index a181de2..0000000
--- a/sysdeps/ieee754/ldbl-opt/cabs.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/cabs.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cabs, cabsl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cabsl.c b/sysdeps/ieee754/ldbl-opt/cabsl.c
deleted file mode 100644
index b861633..0000000
--- a/sysdeps/ieee754/ldbl-opt/cabsl.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/cabsl.c>
-long_double_symbol (libm, __cabsl, cabsl);
diff --git a/sysdeps/ieee754/ldbl-opt/carg.c b/sysdeps/ieee754/ldbl-opt/carg.c
deleted file mode 100644
index 2ed3581..0000000
--- a/sysdeps/ieee754/ldbl-opt/carg.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/carg.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __carg, cargl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cargl.c b/sysdeps/ieee754/ldbl-opt/cargl.c
deleted file mode 100644
index 952dc60..0000000
--- a/sysdeps/ieee754/ldbl-opt/cargl.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/cargl.c>
-long_double_symbol (libm, __cargl, cargl);
diff --git a/sysdeps/ieee754/ldbl-opt/cimag.c b/sysdeps/ieee754/ldbl-opt/cimag.c
deleted file mode 100644
index f805258..0000000
--- a/sysdeps/ieee754/ldbl-opt/cimag.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/cimag.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cimag, cimagl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cimagl.c b/sysdeps/ieee754/ldbl-opt/cimagl.c
deleted file mode 100644
index 112365e..0000000
--- a/sysdeps/ieee754/ldbl-opt/cimagl.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/cimagl.c>
-long_double_symbol (libm, __cimagl, cimagl);
diff --git a/sysdeps/ieee754/ldbl-opt/conj.c b/sysdeps/ieee754/ldbl-opt/conj.c
deleted file mode 100644
index e4edade..0000000
--- a/sysdeps/ieee754/ldbl-opt/conj.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/conj.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __conj, conjl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/conjl.c b/sysdeps/ieee754/ldbl-opt/conjl.c
deleted file mode 100644
index c98e0ed..0000000
--- a/sysdeps/ieee754/ldbl-opt/conjl.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/conjl.c>
-long_double_symbol (libm, __conjl, conjl);
diff --git a/sysdeps/ieee754/ldbl-opt/creal.c b/sysdeps/ieee754/ldbl-opt/creal.c
deleted file mode 100644
index 0d1c93e..0000000
--- a/sysdeps/ieee754/ldbl-opt/creal.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/creal.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __creal, creall, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/creall.c b/sysdeps/ieee754/ldbl-opt/creall.c
deleted file mode 100644
index 68fedd4..0000000
--- a/sysdeps/ieee754/ldbl-opt/creall.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/creall.c>
-long_double_symbol (libm, __creall, creall);
diff --git a/sysdeps/ieee754/ldbl-opt/math-type-macros.h b/sysdeps/ieee754/ldbl-opt/math-type-macros.h
new file mode 100644
index 0000000..f963f77
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros.h
@@ -0,0 +1,11 @@
+/* Include the long double compatability support for generated math files.  */
+#include <math_ldbl_opt.h>
+
+/* Declare compat versions for generated functions.  */
+#define LDOUBLE_cabsl_libm_version GLIBC_2_1
+#define LDOUBLE_cargl_libm_version GLIBC_2_1
+#define LDOUBLE_cimagl_libm_version GLIBC_2_1
+#define LDOUBLE_conjl_libm_version GLIBC_2_1
+#define LDOUBLE_creall_libm_version GLIBC_2_1
+
+#include_next <math-type-macros.h>
-- 
2.4.11

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

* [PATCHv2 01/11] Refactor part of math Makefile
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (13 preceding siblings ...)
  2016-07-01 20:14   ` [PATCHv2 05/11] Convert _Complex cosine functions to generated code Paul E. Murphy
@ 2016-07-01 20:14   ` Paul E. Murphy
  2016-08-02 21:34     ` Joseph Myers
  2016-07-01 20:14   ` [PATCHv2 10/11] Prepare to convert remaining _Complex functions Paul E. Murphy
                     ` (3 subsequent siblings)
  18 siblings, 1 reply; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01 20:14 UTC (permalink / raw)
  To: libc-alpha

In order to support more types, the Makefile needs a few bits
shuffled.

F is explictly used as a placeholder to substitute for the
appropriate type suffix.  This removes the need to demangle
_r suffixed objects.

The variable libm-compat-calls is added to house any objects which
are only built to provide compat symbols within libm.  That is,
no newly added type should ever attempt building these.  Note,
k_standard* files have been added there.  By consensus they are
deprecated; in practice, we haven't gotten there yet.

New types would be added as noted in the comments preceding
type-TYPE-{suffix,routines,yes} variables.  However, some manual
additions will still need to be done to add appropriate flags
when building the various variants of libm-test.c for a new type.

Likewise, test-ildoubl is renamed test-ildouble for consistency's
sake.

	* math/Makefile (libm-calls): Insert F placeholder into
	object names.  Move w_lgamma_compat* routines into
	(libm-compat-calls): New variable.
	(libm-compat-calls-ldouble-yes): New variable.
	(calls): Insert F placeholder.
	(generated): Redefine using new type-foreach macro call.
	(routines): Likewise.

	(types): New variable to hold a list of symbolic names
	for each type supported by the target machine.
	(libm-routines): Redefine using new types variable.
	(type-foreach): macro to replace fooF with the
	appropriately suffixed foo for each types.

	(type-ldouble-suffix): New variable.
	(type-ldouble-routines): Likewise.
	(type-ldouble-yes): Likewise.
	(type-double-suffix): Likewise.
	(type-double-routines): Likewise.
	(type-float-suffix): Likewise.
	(type-float-routines): Likewise.

	(dbl-only-routines): Remove.
	(long-c-yes): Likewise.
	(long-m-routines): Likewise.
	(long-m-support): Likewise.
	(long-m-yes): Likewise.
	(test-longdouble-yes): Likewise.

	(test-float.o): Simplify by increasing the scope of the
	recipe which adds libm-test.stmp to the vector types.
	(test-ifloat.o): Likewise.
	(test-float-finite.o): Likewise.
	(test-double.o): Likewise
	(test-idouble.o): Likewise.
	(test-double-finite.o): Likewise.
	(test-ldouble.o): Likewise
	(test-ildoubl.o): Likewise.
	(test-ldouble-finite.o): Likewise.

	(libm-tests): Redefine type tests using foreach and the
	list of types in types.

	(CPPFLAGS-test-ildoubl.c): Rename to
	(CPPFLAGS-test-ildouble.c): New variable

	* math/test-ildoubl.c: Rename to
	* math/test-ildouble.c: New file.
---
 math/Makefile                            | 131 ++++++++++++++++++-------------
 math/{test-ildoubl.c => test-ildouble.c} |   0
 2 files changed, 75 insertions(+), 56 deletions(-)
 rename math/{test-ildoubl.c => test-ildouble.c} (100%)

diff --git a/math/Makefile b/math/Makefile
index 4f14181..89002a8 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -42,50 +42,81 @@ libm-support = s_lib_version s_matherr s_signgam			\
 	       ftestexcept fegetround fesetround fegetenv feholdexcpt	\
 	       fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt	\
 	       fegetexcept
-libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod	\
-	     e_hypot e_j0 e_j1 e_jn e_lgamma_r e_log e_log10 e_pow	\
-	     e_rem_pio2 e_remainder e_scalb e_sinh e_sqrt e_gamma_r	\
-	     e_ilogb							\
-	     k_cos k_rem_pio2 k_sin k_tan s_asinh s_atan s_cbrt		\
-	     s_ceil s_cos s_erf s_expm1 s_fabs				\
-	     s_floor s_log1p w_log1p s_logb				\
-	     s_nextafter s_nexttoward s_rint s_scalbln w_scalbln	\
-	     s_significand s_sin s_tan s_tanh w_acos w_acosh w_asin	\
-	     w_atan2 w_atanh w_cosh w_exp w_exp2 w_exp10 w_fmod		\
-	     w_tgamma w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r	\
-	     w_log w_log10 w_pow w_remainder w_scalb w_sinh w_sqrt	\
-	     w_ilogb							\
-	     s_fpclassify s_fmax s_fmin s_fdim s_nan s_trunc		\
-	     s_remquo e_log2 e_exp2 s_round s_nearbyint s_sincos	\
-	     conj cimag creal cabs carg s_cexp s_csinh s_ccosh s_clog	\
-	     s_catan s_casin s_ccos s_csin s_ctan s_ctanh s_cacos	\
-	     s_casinh s_cacosh s_catanh s_csqrt s_cpow s_cproj s_clog10 \
-	     s_fma s_lrint s_llrint s_lround s_llround e_exp10 w_log2	\
-	     s_issignaling $(calls:s_%=m_%) x2y2m1 k_casinh	\
-	     gamma_product k_standard lgamma_neg lgamma_product		\
-	     w_lgamma_compat s_nextup s_nextdown
-
-dbl-only-routines := branred doasin dosincos halfulp mpa mpatan2	\
-		     mpatan mpexp mplog mpsqrt mptan sincos32 slowexp	\
-		     slowpow sincostab
-libm-routines = $(strip $(libm-support) $(libm-calls) \
-			$(patsubst %_rf,%f_r,$(libm-calls:=f))	\
-			$(long-m-$(long-double-fcts))) \
-		$(dbl-only-routines)
-long-m-routines = $(patsubst %_rl,%l_r,$(libm-calls:=l))
-long-m-support = t_sincosl k_sincosl
-long-m-yes = $(long-m-routines) $(long-m-support)
+
+libm-calls =								  \
+	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
+	e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF	  \
+	e_rem_pio2F e_remainderF e_scalbF e_sinhF e_sqrtF e_gammaF_r	  \
+	e_ilogbF							  \
+	k_cosF k_rem_pio2F k_sinF k_tanF s_asinhF s_atanF s_cbrtF	  \
+	s_ceilF s_cosF s_erfF s_expm1F s_fabsF				  \
+	s_floorF s_log1pF w_log1pF s_logbF				  \
+	s_nextafterF s_nexttowardF s_rintF s_scalblnF w_scalblnF	  \
+	s_significandF s_sinF s_tanF s_tanhF w_acosF w_acoshF w_asinF	  \
+	w_atan2F w_atanhF w_coshF w_expF w_exp2F w_exp10F w_fmodF	  \
+	w_tgammaF w_hypotF w_j0F w_j1F w_jnF w_lgammaF w_lgammaF_r	  \
+	w_logF w_log10F w_powF w_remainderF w_scalbF w_sinhF w_sqrtF	  \
+	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	  \
+	conjF cimagF crealF cabsF cargF 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_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			  \
+	s_nextupF s_nextdownF
+
+libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl
+libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
+	$(libm-compat-calls-ldouble-$(long-double-fcts))
+
+
+# Type specific routine support.
+#
+# The following three variables control what is included for each type:
+#
+# type-floatN-suffix = The suffix of the type
+# type-floatN-routines = Type specific support objects
+# type-floatN-yes = If the type is supported, evaluates to floatN
+#
+# Finally, note that types is an intentionally recursive variable.
+# We only know the full set of supported types for the target machine
+# after the Rules makefile has been parsed.
+types = $(type-ldouble-$(long-double-fcts)) double float
+
+# long double support
+type-ldouble-suffix := l
+type-ldouble-routines := t_sincosl k_sincosl
+type-ldouble-yes := ldouble
+
+# double support
+type-double-suffix :=
+type-double-routines := branred doasin dosincos halfulp mpa mpatan2	\
+		       mpatan mpexp mplog mpsqrt mptan sincos32 slowexp	\
+		       slowpow sincostab
+
+# float support
+type-float-suffix := f
+type-float-routines :=
+
+
+# Apply suffix to each type in arg 1
+type-foreach = $(foreach t,$(types),$(subst F,$(type-$(t)-suffix),$(1)))
+
+libm-routines = $(strip $(libm-support) $(libm-compat-calls)		\
+			$(call type-foreach, $(libm-calls))		\
+			$(foreach t, $(types), $(type-$(t)-routines))) 	\
 
 # These functions are in libc instead of libm because __printf_fp
 # calls them, so any program using printf will need them linked in,
 # and we don't want to have to link every program with -lm.
 # In libm-calls (above), list m_foo in place of s_foo for any
 # routine that should be compiled separately for its libc and libm versions.
-calls = s_isinf s_isnan s_finite s_copysign s_modf s_scalbn s_frexp s_ldexp \
-	s_signbit
-generated += $(foreach s,.c .S l.c l.S f.c f.S,$(calls:s_%=m_%$s))
-routines = $(calls) $(calls:=f) $(long-c-$(long-double-fcts))
-long-c-yes = $(calls:=l)
+calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \
+	s_ldexpF s_signbitF
+generated += $(foreach s,.c .S,$(call type-foreach, $(calls:s_%=m_%$(s))))
+routines = $(call type-foreach, $(calls))
 
 ifeq ($(build-mathvec),yes)
 # We need to install libm.so as linker script
@@ -120,9 +151,6 @@ tests-static = test-fpucw-static test-fpucw-ieee-static \
 	       test-signgam-uchar-static test-signgam-uchar-init-static \
 	       test-signgam-uint-static test-signgam-uint-init-static \
 	       test-signgam-ullong-static test-signgam-ullong-init-static
-# We do the `long double' tests only if this data type is available and
-# distinct from `double'.
-test-longdouble-yes = test-ldouble test-ildoubl test-ldouble-finite
 
 ifneq (,$(CXX))
 tests += test-math-isinff
@@ -130,9 +158,10 @@ endif
 
 ifneq (no,$(PERL))
 libm-vec-tests = $(addprefix test-,$(libmvec-tests))
-libm-tests = test-float test-double $(test-longdouble-$(long-double-fcts)) \
-	test-ifloat test-idouble test-float-finite test-double-finite \
-	$(libm-vec-tests)
+
+libm-tests = $(foreach t,$(types),test-$(t) test-$(t)-finite test-i$(t)) \
+	     $(libm-vec-tests)
+
 libm-tests.o = $(addsuffix .o,$(libm-tests))
 
 tests += $(libm-tests)
@@ -155,16 +184,6 @@ $(objpfx)libm-test.stmp: $(ulps-file) libm-test.inc gen-libm-test.pl \
 	$(PERL) gen-libm-test.pl -u $< -o "$(objpfx)"
 	$(SHELL) gen-libm-have-vector-test.sh > $(objpfx)libm-have-vector-test.h
 	@echo > $@
-
-$(objpfx)test-float.o: $(objpfx)libm-test.stmp
-$(objpfx)test-ifloat.o: $(objpfx)libm-test.stmp
-$(objpfx)test-float-finite.o: $(objpfx)libm-test.stmp
-$(objpfx)test-double.o: $(objpfx)libm-test.stmp
-$(objpfx)test-idouble.o: $(objpfx)libm-test.stmp
-$(objpfx)test-double-finite.o: $(objpfx)libm-test.stmp
-$(objpfx)test-ldouble.o: $(objpfx)libm-test.stmp
-$(objpfx)test-ildoubl.o: $(objpfx)libm-test.stmp
-$(objpfx)test-ldouble-finite.o: $(objpfx)libm-test.stmp
 endif
 
 libm-test-fast-math-cflags = -fno-builtin -D__FAST_MATH__ -DTEST_FAST_MATH
@@ -216,7 +235,7 @@ CPPFLAGS-test-ifloat.c = -U__LIBC_INTERNAL_MATH_INLINES \
 			 $(libm-test-fast-math-cflags)
 CPPFLAGS-test-idouble.c = -U__LIBC_INTERNAL_MATH_INLINES \
 			  $(libm-test-fast-math-cflags)
-CPPFLAGS-test-ildoubl.c = -U__LIBC_INTERNAL_MATH_INLINES \
+CPPFLAGS-test-ildouble.c = -U__LIBC_INTERNAL_MATH_INLINES \
 			  $(libm-test-fast-math-cflags)
 
 CFLAGS-test-signgam-finite.c = -ffinite-math-only
@@ -247,7 +266,7 @@ include ../Rules
 
 ifneq (no,$(PERL))
 # This must come after the inclusion of sysdeps Makefiles via Rules.
-$(addprefix $(objpfx), $(addsuffix .o, $(libm-vec-tests))): $(objpfx)libm-test.stmp
+$(addprefix $(objpfx), $(libm-tests.o)): $(objpfx)libm-test.stmp
 
 # Run the math programs to automatically generate ULPs files.
 .PHONY: regen-ulps
diff --git a/math/test-ildoubl.c b/math/test-ildouble.c
similarity index 100%
rename from math/test-ildoubl.c
rename to math/test-ildouble.c
-- 
2.4.11

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

* [PATCHv2 02/11] Unify drift between _Complex function type variants
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (8 preceding siblings ...)
  2016-07-01 20:14   ` [PATCHv2 09/11] Convert _Complex tangent functions to generated code Paul E. Murphy
@ 2016-07-01 20:14   ` Paul E. Murphy
  2016-08-02 21:34     ` Joseph Myers
  2016-08-03 17:14     ` Paul E. Murphy
  2016-07-01 20:14   ` [PATCHv2 07/11] Convert _Complex sine functions to generated code Paul E. Murphy
                     ` (8 subsequent siblings)
  18 siblings, 2 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01 20:14 UTC (permalink / raw)
  To: libc-alpha

While trying to convert the _Complex function wrappers
into a single generic implementation, a few minor
variations between identical versions emerged.

	* s_ccoshf.c (__ccoshf): Remove FE_INVALID
	check, and remove __glibc_likely hint
	from FP_INFINITE check.
	* s_csinhf.c (__csinhf): Likewise.

	* s_ccoshl.c (__ccoshl): Remove __glibc_likely
	hint from FP_INFINITE check.
	* s_csinhl.c (__csinhl): Likewise.
---
 math/s_ccoshf.c | 4 +---
 math/s_ccoshl.c | 2 +-
 math/s_csinhf.c | 4 +---
 math/s_csinhl.c | 4 +---
 4 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/math/s_ccoshf.c b/math/s_ccoshf.c
index 610a749..d572b76 100644
--- a/math/s_ccoshf.c
+++ b/math/s_ccoshf.c
@@ -94,7 +94,7 @@ __ccoshf (__complex__ float x)
 	    feraiseexcept (FE_INVALID);
 	}
     }
-  else if (__glibc_likely (rcls == FP_INFINITE))
+  else if (rcls == FP_INFINITE)
     {
       /* Real part is infinite.  */
       if (__glibc_likely (icls > FP_ZERO))
@@ -128,10 +128,8 @@ __ccoshf (__complex__ float x)
 	  __real__ retval = HUGE_VALF;
 	  __imag__ retval = __nanf ("") + __nanf ("");
 
-#ifdef FE_INVALID
 	  if (icls == FP_INFINITE)
 	    feraiseexcept (FE_INVALID);
-#endif
 	}
     }
   else
diff --git a/math/s_ccoshl.c b/math/s_ccoshl.c
index 680da3a..d38f0aa 100644
--- a/math/s_ccoshl.c
+++ b/math/s_ccoshl.c
@@ -94,7 +94,7 @@ __ccoshl (__complex__ long double x)
 	    feraiseexcept (FE_INVALID);
 	}
     }
-  else if (__glibc_likely (rcls == FP_INFINITE))
+  else if (rcls == FP_INFINITE)
     {
       /* Real part is infinite.  */
       if (__glibc_likely (icls > FP_ZERO))
diff --git a/math/s_csinhf.c b/math/s_csinhf.c
index a0458cf..36b42ca 100644
--- a/math/s_csinhf.c
+++ b/math/s_csinhf.c
@@ -111,7 +111,7 @@ __csinhf (__complex__ float x)
 	    }
 	}
     }
-  else if (__glibc_likely (rcls == FP_INFINITE))
+  else if (rcls == FP_INFINITE)
     {
       /* Real part is infinite.  */
       if (__glibc_likely (icls > FP_ZERO))
@@ -147,10 +147,8 @@ __csinhf (__complex__ float x)
 	  __real__ retval = HUGE_VALF;
 	  __imag__ retval = __nanf ("") + __nanf ("");
 
-#ifdef FE_INVALID
 	  if (icls == FP_INFINITE)
 	    feraiseexcept (FE_INVALID);
-#endif
 	}
     }
   else
diff --git a/math/s_csinhl.c b/math/s_csinhl.c
index d7f03fa..c231d7b 100644
--- a/math/s_csinhl.c
+++ b/math/s_csinhl.c
@@ -111,7 +111,7 @@ __csinhl (__complex__ long double x)
 	    }
 	}
     }
-  else if (__glibc_likely (rcls == FP_INFINITE))
+  else if (rcls == FP_INFINITE)
     {
       /* Real part is infinite.  */
       if (__glibc_likely (icls > FP_ZERO))
@@ -147,10 +147,8 @@ __csinhl (__complex__ long double x)
 	  __real__ retval = HUGE_VALL;
 	  __imag__ retval = __nanl ("") + __nanl ("");
 
-#ifdef FE_INVALID
 	  if (icls == FP_INFINITE)
 	    feraiseexcept (FE_INVALID);
-#endif
 	}
     }
   else
-- 
2.4.11

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

* [PATCHv2 10/11] Prepare to convert remaining _Complex functions
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (14 preceding siblings ...)
  2016-07-01 20:14   ` [PATCHv2 01/11] Refactor part of math Makefile Paul E. Murphy
@ 2016-07-01 20:14   ` Paul E. Murphy
  2016-07-01 20:14   ` [PATCHv2 03/11] Support for type-generic libm function implementations libm Paul E. Murphy
                     ` (2 subsequent siblings)
  18 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01 20:14 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.

	* b_cexp.c: Copy of s_cexp.c.
	* b_clog.c: Copy of s_clog.c.
	* b_clog10.c: Copy of s_clog10.c.
	* b_cpow.c: Copy of s_cpow.c.
	* b_cproj.c: Copy of s_cproj.c.
	* b_csqrt.c: Copy of s_csqrt.c.
---
 math/{s_cexp.c => b_cexp.c}     | 0
 math/{s_clog.c => b_clog.c}     | 0
 math/{s_clog10.c => b_clog10.c} | 0
 math/{s_cpow.c => b_cpow.c}     | 0
 math/{s_cproj.c => b_cproj.c}   | 0
 math/{s_csqrt.c => b_csqrt.c}   | 0
 6 files changed, 0 insertions(+), 0 deletions(-)
 copy math/{s_cexp.c => b_cexp.c} (100%)
 copy math/{s_clog.c => b_clog.c} (100%)
 copy math/{s_clog10.c => b_clog10.c} (100%)
 copy math/{s_cpow.c => b_cpow.c} (100%)
 copy math/{s_cproj.c => b_cproj.c} (100%)
 copy math/{s_csqrt.c => b_csqrt.c} (100%)

diff --git a/math/s_cexp.c b/math/b_cexp.c
similarity index 100%
copy from math/s_cexp.c
copy to math/b_cexp.c
diff --git a/math/s_clog.c b/math/b_clog.c
similarity index 100%
copy from math/s_clog.c
copy to math/b_clog.c
diff --git a/math/s_clog10.c b/math/b_clog10.c
similarity index 100%
copy from math/s_clog10.c
copy to math/b_clog10.c
diff --git a/math/s_cpow.c b/math/b_cpow.c
similarity index 100%
copy from math/s_cpow.c
copy to math/b_cpow.c
diff --git a/math/s_cproj.c b/math/b_cproj.c
similarity index 100%
copy from math/s_cproj.c
copy to math/b_cproj.c
diff --git a/math/s_csqrt.c b/math/b_csqrt.c
similarity index 100%
copy from math/s_csqrt.c
copy to math/b_csqrt.c
-- 
2.4.11

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

* [PATCHv2 05/11] Convert _Complex cosine functions to generated code
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (12 preceding siblings ...)
  2016-07-01 20:14   ` [PATCHv2 08/11] Prepare to convert _Complex tangent functions Paul E. Murphy
@ 2016-07-01 20:14   ` Paul E. Murphy
  2016-07-01 20:14   ` [PATCHv2 01/11] Refactor part of math Makefile Paul E. Murphy
                     ` (4 subsequent siblings)
  18 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01 20:14 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): 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

	* 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_ccosh.c: Refactor into
	* sysdeps/m68k/m680x0/fpu/b_ccosh.c: New file.
	* 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                                   |  29 ++---
 math/b_cacosh.c                                  |  50 ++++----
 math/b_ccos.c                                    |  20 +--
 math/b_ccosh.c                                   |  77 ++++++------
 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                                  | 145 ----------------------
 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/{s_ccosh.c => b_ccosh.c} |  18 +--
 sysdeps/m68k/m680x0/fpu/s_ccoshf.c               |   3 -
 sysdeps/m68k/m680x0/fpu/s_ccoshl.c               |   3 -
 34 files changed, 145 insertions(+), 1164 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 => b_ccosh.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 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
index 234b122..793833f 100644
--- a/math/b_cacos.c
+++ b/math/b_cacos.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_FUNC (__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_FUNC (__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/b_cacosh.c b/math/b_cacosh.c
index 20bf215..664575b 100644
--- a/math/b_cacosh.c
+++ b/math/b_cacosh.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_FUNC (__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/b_ccos.c b/math/b_ccos.c
index e484551..16bd04a 100644
--- a/math/b_ccos.c
+++ b/math/b_ccos.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_FUNC (__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/b_ccosh.c b/math/b_ccosh.c
index 4c2f300..82d25ff 100644
--- a/math/b_ccosh.c
+++ b/math/b_ccosh.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_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 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/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/s_ccosh.c b/sysdeps/m68k/m680x0/fpu/b_ccosh.c
similarity index 87%
rename from sysdeps/m68k/m680x0/fpu/s_ccosh.c
rename to sysdeps/m68k/m680x0/fpu/b_ccosh.c
index 47a4fb0..6f3de62 100644
--- a/sysdeps/m68k/m680x0/fpu/s_ccosh.c
+++ b/sysdeps/m68k/m680x0/fpu/b_ccosh.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_FUNC (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] 53+ messages in thread

* [PATCHv2 08/11] Prepare to convert _Complex tangent functions
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (11 preceding siblings ...)
  2016-07-01 20:14   ` [PATCHv2 06/11] Prepare to convert _Complex sine functions Paul E. Murphy
@ 2016-07-01 20:14   ` Paul E. Murphy
  2016-07-01 20:14   ` [PATCHv2 05/11] Convert _Complex cosine functions to generated code Paul E. Murphy
                     ` (5 subsequent siblings)
  18 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01 20:14 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.

	* b_catan.c: Copy of s_catan.c.
	* b_catanh.c: Copy of s_catanh.c.
	* b_ctan.c: Copy of s_ctan.c.
	* b_ctanh.c: Copy of s_ctanh.c.
---
 math/{s_catan.c => b_catan.c}   | 0
 math/{s_catanh.c => b_catanh.c} | 0
 math/{s_ctan.c => b_ctan.c}     | 0
 math/{s_ctanh.c => b_ctanh.c}   | 0
 4 files changed, 0 insertions(+), 0 deletions(-)
 copy math/{s_catan.c => b_catan.c} (100%)
 copy math/{s_catanh.c => b_catanh.c} (100%)
 copy math/{s_ctan.c => b_ctan.c} (100%)
 copy math/{s_ctanh.c => b_ctanh.c} (100%)

diff --git a/math/s_catan.c b/math/b_catan.c
similarity index 100%
copy from math/s_catan.c
copy to math/b_catan.c
diff --git a/math/s_catanh.c b/math/b_catanh.c
similarity index 100%
copy from math/s_catanh.c
copy to math/b_catanh.c
diff --git a/math/s_ctan.c b/math/b_ctan.c
similarity index 100%
copy from math/s_ctan.c
copy to math/b_ctan.c
diff --git a/math/s_ctanh.c b/math/b_ctanh.c
similarity index 100%
copy from math/s_ctanh.c
copy to math/b_ctanh.c
-- 
2.4.11

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

* [PATCHv2 07/11] Convert _Complex sine functions to generated code
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (9 preceding siblings ...)
  2016-07-01 20:14   ` [PATCHv2 02/11] Unify drift between _Complex function type variants Paul E. Murphy
@ 2016-07-01 20:14   ` Paul E. Murphy
  2016-07-01 20:14   ` [PATCHv2 06/11] Prepare to convert _Complex sine functions Paul E. Murphy
                     ` (7 subsequent siblings)
  18 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01 20:14 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.c: Refactor into
	* math/b_casin.c: New file
	* math/s_casinf.c: Removed
	* math/s_casinl.c: Removed

	* math/s_casinh.c: Refactor into
	* math/b_casinh.c: New file
	* math/s_casinhf.c: Removed
	* math/s_casinhl.c: Removed

	* math/s_csin.c: Refactor into
	* math/b_csin.c: New file
	* math/s_csinf.c: Removed
	* math/s_csinl.c: Removed

	* math/s_csinh.c: Refactor into
	* math/b_csinh.c: New file
	* math/s_csinhf.c: Removed
	* math/s_csinhl.c: Removed

	* math/k_casinh.c: Refactor into
	* math/b_k_casinh.c: New file
	* math/k_casinhf.c: Removed
	* math/k_casinhl.c: Removed

	* sysdeps/alpha/fpu/Makefile: Add overrides for _Complex float
	variants.
	* 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/math-type-macros.h: Add versioning
	info for compat symbols.

	* 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/b_csin.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/b_csinh.c: New file
	* sysdeps/m68k/m680x0/fpu/s_csinhf.c: Removed
	* sysdeps/m68k/m680x0/fpu/s_csinhl.c: Removed
---
 math/Makefile                                    |  11 +-
 math/b_casin.c                                   |  31 ++--
 math/b_casinh.c                                  |  37 ++--
 math/b_csin.c                                    |  79 ++++----
 math/b_csinh.c                                   |  79 ++++----
 math/b_k_casinh.c                                | 187 +++++++++----------
 math/k_casinh.c                                  | 210 ----------------------
 math/k_casinhf.c                                 | 212 ----------------------
 math/k_casinhl.c                                 | 219 -----------------------
 math/s_casin.c                                   |  66 -------
 math/s_casinf.c                                  |  64 -------
 math/s_casinh.c                                  |  73 --------
 math/s_casinhf.c                                 |  71 --------
 math/s_casinhl.c                                 |  69 -------
 math/s_casinl.c                                  |  62 -------
 math/s_csin.c                                    | 171 ------------------
 math/s_csinf.c                                   | 169 -----------------
 math/s_csinh.c                                   | 166 -----------------
 math/s_csinhf.c                                  | 164 -----------------
 math/s_csinhl.c                                  | 162 -----------------
 math/s_csinl.c                                   | 167 -----------------
 sysdeps/alpha/fpu/Makefile                       |   6 +-
 sysdeps/alpha/fpu/s_casinf.c                     |  13 +-
 sysdeps/alpha/fpu/s_casinhf.c                    |  13 +-
 sysdeps/alpha/fpu/s_csinf.c                      |  13 +-
 sysdeps/alpha/fpu/s_csinhf.c                     |  13 +-
 sysdeps/ieee754/ldbl-opt/math-type-macros.h      |   4 +
 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 -
 sysdeps/m68k/m680x0/fpu/{s_csin.c => b_csin.c}   |  18 +-
 sysdeps/m68k/m680x0/fpu/{s_csinh.c => b_csinh.c} |  17 +-
 sysdeps/m68k/m680x0/fpu/s_csinf.c                |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinhf.c               |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinhl.c               |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinl.c                |   3 -
 41 files changed, 270 insertions(+), 2356 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 => b_csin.c} (86%)
 rename sysdeps/m68k/m680x0/fpu/{s_csinh.c => b_csinh.c} (88%)
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinf.c
 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 b621996..ac91a84 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -54,7 +54,8 @@ libm-support = s_lib_version s_matherr s_signgam			\
 # 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 g_cacos_F \
-	g_cacosh_F g_ccos_F g_ccosh_F
+	g_cacosh_F g_ccos_F g_ccosh_F g_casin_F g_csin_F g_casinh_F	  \
+	g_k_casinh_F g_csinh_F
 
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
@@ -72,11 +73,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/b_casin.c b/math/b_casin.c
index a37933b..b1569b3 100644
--- a/math/b_casin.c
+++ b/math/b_casin.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_FUNC (__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/b_casinh.c b/math/b_casinh.c
index 32cbc13..50f9a1f 100644
--- a/math/b_casinh.c
+++ b/math/b_casinh.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,27 +32,29 @@ __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__ x);
+	    __imag__ res = M_COPYSIGN (rcls >= FP_ZERO
+						? M_MLIT (M_PI_2)
+					        : M_MLIT (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);
+	    __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 +63,14 @@ __casinh (__complex__ double x)
     }
   else
     {
-      res = __kernel_casinh (x, 0);
+      res = M_FUNC (__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/b_csin.c b/math/b_csin.c
index e071aa6..2bcb874 100644
--- a/math/b_csin.c
+++ b/math/b_csin.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/b_csinh.c b/math/b_csinh.c
index 5fb60ed..37fd4d4 100644
--- a/math/b_csinh.c
+++ b/math/b_csinh.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/b_k_casinh.c b/math/b_k_casinh.c
index 354dde1..8b329b0 100644
--- a/math/b_k_casinh.c
+++ b/math/b_k_casinh.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,163 @@ __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_FUNC (__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_FUNC (__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_FUNC (__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_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_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_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_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_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_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/Makefile b/sysdeps/alpha/fpu/Makefile
index ddd86ba..3ae1451 100644
--- a/sysdeps/alpha/fpu/Makefile
+++ b/sysdeps/alpha/fpu/Makefile
@@ -1,6 +1,8 @@
 # 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 \
-	g_cacos_f g_cacosh_f g_ccos_f g_ccosh_f
+	g_cacos_f g_cacosh_f g_ccos_f g_ccosh_f g_casin_f g_csin_f	 \
+	g_casinh_f g_csinh_f
 libm-gen-replacement-calls = cabsf cargf cimagf crealf conjf \
-	s_cacosf s_cacoshf s_ccosf s_ccoshf
+	s_cacosf s_cacoshf s_ccosf s_ccoshf s_casinf s_csinf \
+	s_casinhf s_csinhf
diff --git a/sysdeps/alpha/fpu/s_casinf.c b/sysdeps/alpha/fpu/s_casinf.c
index f85f524..396c0a1 100644
--- a/sysdeps/alpha/fpu/s_casinf.c
+++ b/sysdeps/alpha/fpu/s_casinf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __casinf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_casin.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..045fcb4 100644
--- a/sysdeps/alpha/fpu/s_casinhf.c
+++ b/sysdeps/alpha/fpu/s_casinhf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __casinhf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_casinh.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..d836db8 100644
--- a/sysdeps/alpha/fpu/s_csinf.c
+++ b/sysdeps/alpha/fpu/s_csinf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __csinf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_csin.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..d845ad9 100644
--- a/sysdeps/alpha/fpu/s_csinhf.c
+++ b/sysdeps/alpha/fpu/s_csinhf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __csinhf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_csinh.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_csinhf (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 3e3b9f7..061ba33 100644
--- a/sysdeps/ieee754/ldbl-opt/math-type-macros.h
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros.h
@@ -11,5 +11,9 @@
 #define LDOUBLE_cacoshl_libm_version GLIBC_2_1
 #define LDOUBLE_ccosl_libm_version GLIBC_2_1
 #define LDOUBLE_ccoshl_libm_version GLIBC_2_1
+#define LDOUBLE_casinl_libm_version GLIBC_2_1
+#define LDOUBLE_csinl_libm_version GLIBC_2_1
+#define LDOUBLE_casinhl_libm_version GLIBC_2_1
+#define LDOUBLE_csinhl_libm_version GLIBC_2_1
 
 #include_next <math-type-macros.h>
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/b_csin.c
similarity index 86%
rename from sysdeps/m68k/m680x0/fpu/s_csin.c
rename to sysdeps/m68k/m680x0/fpu/b_csin.c
index b8419be..42499f6 100644
--- a/sysdeps/m68k/m680x0/fpu/s_csin.c
+++ b/sysdeps/m68k/m680x0/fpu/b_csin.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_FUNC (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_csinh.c b/sysdeps/m68k/m680x0/fpu/b_csinh.c
similarity index 88%
rename from sysdeps/m68k/m680x0/fpu/s_csinh.c
rename to sysdeps/m68k/m680x0/fpu/b_csinh.c
index c633cd8..1903882 100644
--- a/sysdeps/m68k/m680x0/fpu/s_csinh.c
+++ b/sysdeps/m68k/m680x0/fpu/b_csinh.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_FUNC (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_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_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] 53+ messages in thread

* [PATCHv2 06/11] Prepare to convert _Complex sine functions
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (10 preceding siblings ...)
  2016-07-01 20:14   ` [PATCHv2 07/11] Convert _Complex sine functions to generated code Paul E. Murphy
@ 2016-07-01 20:14   ` Paul E. Murphy
  2016-07-01 20:14   ` [PATCHv2 08/11] Prepare to convert _Complex tangent functions Paul E. Murphy
                     ` (6 subsequent siblings)
  18 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01 20:14 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.

	* b_casin.c: Copy of s_casin.c.
	* b_casinh.c: Copy of s_casinh.c.
	* b_csin.c: Copy of s_csin.c.
	* b_csinh.c: Copy of s_csinh.c.
	* b_k_casinh.c: Copy of k_casinh.c.
---
 math/{s_casin.c => b_casin.c}     | 0
 math/{s_casinh.c => b_casinh.c}   | 0
 math/{s_csin.c => b_csin.c}       | 0
 math/{s_csinh.c => b_csinh.c}     | 0
 math/{k_casinh.c => b_k_casinh.c} | 0
 5 files changed, 0 insertions(+), 0 deletions(-)
 copy math/{s_casin.c => b_casin.c} (100%)
 copy math/{s_casinh.c => b_casinh.c} (100%)
 copy math/{s_csin.c => b_csin.c} (100%)
 copy math/{s_csinh.c => b_csinh.c} (100%)
 copy math/{k_casinh.c => b_k_casinh.c} (100%)

diff --git a/math/s_casin.c b/math/b_casin.c
similarity index 100%
copy from math/s_casin.c
copy to math/b_casin.c
diff --git a/math/s_casinh.c b/math/b_casinh.c
similarity index 100%
copy from math/s_casinh.c
copy to math/b_casinh.c
diff --git a/math/s_csin.c b/math/b_csin.c
similarity index 100%
copy from math/s_csin.c
copy to math/b_csin.c
diff --git a/math/s_csinh.c b/math/b_csinh.c
similarity index 100%
copy from math/s_csinh.c
copy to math/b_csinh.c
diff --git a/math/k_casinh.c b/math/b_k_casinh.c
similarity index 100%
copy from math/k_casinh.c
copy to math/b_k_casinh.c
-- 
2.4.11

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

* [PATCHv2 00/11] Generate Complex functions from a common template.
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
@ 2016-07-01 20:14 Paul E. Murphy
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
  2016-08-02 14:37 ` [Ping] [PATCHv2 00/11] Generate Complex functions from a common template Paul E. Murphy
  18 siblings, 2 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01 20:14 UTC (permalink / raw)
  To: libc-alpha

This is the second spin of the patch set based on
feedback.

Primarily, it is cleanup to remove M_LIT (X.0) where
X is a small integer, and use integer constants when
possible.  Likewise, fixing comments mangled when
converted.

Secondly, I have inserted a patch to unify the drift
between the ccosh* and csinh* variants as suggested
by Joseph.

Finally, I have inserted an extra patch before each
major refactoring to explicitly copy the file which
will be transformed into the template.  These changes
do not break anything, but simplify the diff in the
patch following them.

Again, I have run each patch through arm, alpha,
x86-64, ppc64, and m68k builds.  I have compared the
objdump and nm output of new object files with their
replacements to verify no changes to code generation
have occured after each patch, using the unification
patch as the base.

The diffstat is a bit more accurate about the amount
of cleanup occuring with this patchset.


Paul E. Murphy (11):
  Refactor part of math Makefile
  Unify drift between _Complex function type variants
  Support for type-generic libm function implementations libm
  Prepare to convert _Complex cosine functions
  Convert _Complex cosine functions to generated code
  Prepare to convert _Complex sine functions
  Convert _Complex sine functions to generated code
  Prepare to convert _Complex tangent functions
  Convert _Complex tangent functions to generated code
  Prepare to convert remaining _Complex functions
  Convert remaining complex function to generated files

 Makeconfig                                       |   2 +-
 math/Makefile                                    | 176 ++++++++++++------
 math/{s_cpow.c => b_cabs.c}                      |  18 +-
 math/{s_cacosf.c => b_cacos.c}                   |  27 +--
 math/{s_cacosh.c => b_cacosh.c}                  |  50 +++---
 math/{s_cpowf.c => b_carg.c}                     |  16 +-
 math/{s_casinf.c => b_casin.c}                   |  29 +--
 math/{s_casinhf.c => b_casinh.c}                 |  35 ++--
 math/b_catan.c                                   | 145 +++++++++++++++
 math/b_catanh.c                                  | 140 +++++++++++++++
 math/{s_ccosf.c => b_ccos.c}                     |  18 +-
 math/{s_ccosh.c => b_ccosh.c}                    |  77 ++++----
 math/{s_cexpf.c => b_cexp.c}                     |  64 +++----
 math/{cimag.c => b_cimag.c}                      |  15 +-
 math/{s_clogf.c => b_clog.c}                     |  83 ++++-----
 math/b_clog10.c                                  | 143 +++++++++++++++
 math/{conjf.c => b_conj.c}                       |  13 +-
 math/{carg.c => b_cpow.c}                        |  17 +-
 math/{s_cprojf.c => b_cproj.c}                   |  17 +-
 math/{creal.c => b_creal.c}                      |  15 +-
 math/{s_csinf.c => b_csin.c}                     |  77 ++++----
 math/{s_csinh.c => b_csinh.c}                    |  79 ++++----
 math/{s_csqrtf.c => b_csqrt.c}                   | 103 +++++------
 math/{s_ctanf.c => b_ctan.c}                     |  67 +++----
 math/{s_ctanhf.c => b_ctanh.c}                   |  67 +++----
 math/b_k_casinh.c                                | 211 ++++++++++++++++++++++
 math/cabs.c                                      |  32 ----
 math/cabsf.c                                     |  28 ---
 math/cabsl.c                                     |  28 ---
 math/cargf.c                                     |  28 ---
 math/cargl.c                                     |  28 ---
 math/cimagf.c                                    |  27 ---
 math/cimagl.c                                    |  27 ---
 math/conj.c                                      |  31 ----
 math/conjl.c                                     |  27 ---
 math/crealf.c                                    |  27 ---
 math/creall.c                                    |  27 ---
 math/k_casinh.c                                  | 210 ----------------------
 math/k_casinhf.c                                 | 212 ----------------------
 math/k_casinhl.c                                 | 219 -----------------------
 math/s_cacos.c                                   |  58 ------
 math/s_cacoshf.c                                 |  92 ----------
 math/s_cacoshl.c                                 |  90 ----------
 math/s_cacosl.c                                  |  54 ------
 math/s_casin.c                                   |  66 -------
 math/s_casinh.c                                  |  73 --------
 math/s_casinhl.c                                 |  69 -------
 math/s_casinl.c                                  |  62 -------
 math/s_catan.c                                   | 143 ---------------
 math/s_catanf.c                                  | 143 ---------------
 math/s_catanh.c                                  | 137 --------------
 math/s_catanhf.c                                 | 137 --------------
 math/s_catanhl.c                                 | 141 ---------------
 math/s_catanl.c                                  | 147 ---------------
 math/s_ccos.c                                    |  40 -----
 math/s_ccoshf.c                                  | 147 ---------------
 math/s_ccoshl.c                                  | 143 ---------------
 math/s_ccosl.c                                   |  36 ----
 math/s_cexp.c                                    | 157 ----------------
 math/s_cexpl.c                                   | 153 ----------------
 math/s_clog.c                                    | 118 ------------
 math/s_clog10.c                                  | 124 -------------
 math/s_clog10f.c                                 | 122 -------------
 math/s_clog10l.c                                 | 127 -------------
 math/s_clogl.c                                   | 121 -------------
 math/s_cpowl.c                                   |  29 ---
 math/s_cproj.c                                   |  44 -----
 math/s_cprojl.c                                  |  40 -----
 math/s_csin.c                                    | 171 ------------------
 math/s_csinhf.c                                  | 166 -----------------
 math/s_csinhl.c                                  | 164 -----------------
 math/s_csinl.c                                   | 167 -----------------
 math/s_csqrt.c                                   | 165 -----------------
 math/s_csqrtl.c                                  | 161 -----------------
 math/s_ctan.c                                    | 129 -------------
 math/s_ctanh.c                                   | 129 -------------
 math/s_ctanhl.c                                  | 132 --------------
 math/s_ctanl.c                                   | 132 --------------
 math/{test-ildoubl.c => test-ildouble.c}         |   0
 scripts/sysd-rules.awk                           |   5 +-
 sysdeps/alpha/fpu/Makefile                       |  10 ++
 sysdeps/alpha/fpu/s_cacosf.c                     |  12 +-
 sysdeps/alpha/fpu/s_cacoshf.c                    |  11 +-
 sysdeps/alpha/fpu/s_casinf.c                     |  13 +-
 sysdeps/alpha/fpu/s_casinhf.c                    |  13 +-
 sysdeps/alpha/fpu/s_catanf.c                     |  13 +-
 sysdeps/alpha/fpu/s_catanhf.c                    |  13 +-
 sysdeps/alpha/fpu/s_ccosf.c                      |  13 +-
 sysdeps/alpha/fpu/s_ccoshf.c                     |  13 +-
 sysdeps/alpha/fpu/s_cexpf.c                      |  13 +-
 sysdeps/alpha/fpu/s_clog10f.c                    |  15 +-
 sysdeps/alpha/fpu/s_clogf.c                      |  13 +-
 sysdeps/alpha/fpu/s_cpowf.c                      |  13 +-
 sysdeps/alpha/fpu/s_cprojf.c                     |  13 +-
 sysdeps/alpha/fpu/s_csinf.c                      |  13 +-
 sysdeps/alpha/fpu/s_csinhf.c                     |  13 +-
 sysdeps/alpha/fpu/s_csqrtf.c                     |  13 +-
 sysdeps/alpha/fpu/s_ctanf.c                      |  13 +-
 sysdeps/alpha/fpu/s_ctanhf.c                     |  13 +-
 sysdeps/generic/math-type-macros.h               | 159 ++++++++++++++++
 sysdeps/ieee754/Makeconfig                       |   6 +
 sysdeps/ieee754/ldbl-opt/cabs.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/cabsl.c                 |   6 -
 sysdeps/ieee754/ldbl-opt/carg.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/cargl.c                 |   6 -
 sysdeps/ieee754/ldbl-opt/cimag.c                 |   6 -
 sysdeps/ieee754/ldbl-opt/cimagl.c                |   6 -
 sysdeps/ieee754/ldbl-opt/conj.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/conjl.c                 |   6 -
 sysdeps/ieee754/ldbl-opt/creal.c                 |   6 -
 sysdeps/ieee754/ldbl-opt/creall.c                |   6 -
 sysdeps/ieee754/ldbl-opt/math-type-macros.h      |  30 ++++
 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_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_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_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/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             |  10 --
 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_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 -
 sysdeps/ieee754/ldbl-opt/s_csqrt.c               |   6 -
 sysdeps/ieee754/ldbl-opt/s_csqrtl.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 -
 sysdeps/m68k/m680x0/fpu/{s_ccosh.c => b_ccosh.c} |  18 +-
 sysdeps/m68k/m680x0/fpu/{s_cexp.c => b_cexp.c}   |  15 +-
 sysdeps/m68k/m680x0/fpu/{s_csin.c => b_csin.c}   |  18 +-
 sysdeps/m68k/m680x0/fpu/{s_csinh.c => b_csinh.c} |  17 +-
 sysdeps/m68k/m680x0/fpu/s_ccoshf.c               |   3 -
 sysdeps/m68k/m680x0/fpu/s_ccoshl.c               |   3 -
 sysdeps/m68k/m680x0/fpu/s_cexpf.c                |   3 -
 sysdeps/m68k/m680x0/fpu/s_cexpl.c                |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinf.c                |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinhf.c               |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinhl.c               |   3 -
 sysdeps/m68k/m680x0/fpu/s_csinl.c                |   3 -
 160 files changed, 1619 insertions(+), 6181 deletions(-)
 rename math/{s_cpow.c => b_cabs.c} (78%)
 rename math/{s_cacosf.c => b_cacos.c} (76%)
 rename math/{s_cacosh.c => b_cacosh.c} (65%)
 rename math/{s_cpowf.c => b_carg.c} (79%)
 rename math/{s_casinf.c => b_casin.c} (75%)
 rename math/{s_casinhf.c => b_casinh.c} (70%)
 create mode 100644 math/b_catan.c
 create mode 100644 math/b_catanh.c
 rename math/{s_ccosf.c => b_ccos.c} (81%)
 rename math/{s_ccosh.c => b_ccosh.c} (59%)
 rename math/{s_cexpf.c => b_cexp.c} (69%)
 rename math/{cimag.c => b_cimag.c} (82%)
 rename math/{s_clogf.c => b_clog.c} (51%)
 create mode 100644 math/b_clog10.c
 rename math/{conjf.c => b_conj.c} (81%)
 rename math/{carg.c => b_cpow.c} (78%)
 rename math/{s_cprojf.c => b_cproj.c} (78%)
 rename math/{creal.c => b_creal.c} (82%)
 rename math/{s_csinf.c => b_csin.c} (65%)
 rename math/{s_csinh.c => b_csinh.c} (62%)
 rename math/{s_csqrtf.c => b_csqrt.c} (51%)
 rename math/{s_ctanf.c => b_ctan.c} (64%)
 rename math/{s_ctanhf.c => b_ctanh.c} (64%)
 create mode 100644 math/b_k_casinh.c
 delete mode 100644 math/cabs.c
 delete mode 100644 math/cabsf.c
 delete mode 100644 math/cabsl.c
 delete mode 100644 math/cargf.c
 delete mode 100644 math/cargl.c
 delete mode 100644 math/cimagf.c
 delete mode 100644 math/cimagl.c
 delete mode 100644 math/conj.c
 delete mode 100644 math/conjl.c
 delete mode 100644 math/crealf.c
 delete mode 100644 math/creall.c
 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_cacos.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_casin.c
 delete mode 100644 math/s_casinh.c
 delete mode 100644 math/s_casinhl.c
 delete mode 100644 math/s_casinl.c
 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_ccos.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 math/s_cexp.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_clogl.c
 delete mode 100644 math/s_cpowl.c
 delete mode 100644 math/s_cproj.c
 delete mode 100644 math/s_cprojl.c
 delete mode 100644 math/s_csin.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 math/s_csqrt.c
 delete mode 100644 math/s_csqrtl.c
 delete mode 100644 math/s_ctan.c
 delete mode 100644 math/s_ctanh.c
 delete mode 100644 math/s_ctanhl.c
 delete mode 100644 math/s_ctanl.c
 rename math/{test-ildoubl.c => test-ildouble.c} (100%)
 create mode 100644 sysdeps/alpha/fpu/Makefile
 create mode 100644 sysdeps/generic/math-type-macros.h
 create mode 100644 sysdeps/ieee754/Makeconfig
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabs.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabsl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/carg.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cargl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimag.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimagl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conj.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conjl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creal.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creall.c
 create mode 100644 sysdeps/ieee754/ldbl-opt/math-type-macros.h
 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_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_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_ccos.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ccosh.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ccoshl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ccosl.c
 delete mode 100644 sysdeps/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_clog10l.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_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
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csqrt.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csqrtl.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
 rename sysdeps/m68k/m680x0/fpu/{s_ccosh.c => b_ccosh.c} (87%)
 rename sysdeps/m68k/m680x0/fpu/{s_cexp.c => b_cexp.c} (94%)
 rename sysdeps/m68k/m680x0/fpu/{s_csin.c => b_csin.c} (86%)
 rename sysdeps/m68k/m680x0/fpu/{s_csinh.c => b_csinh.c} (88%)
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_ccoshf.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_ccoshl.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_cexpf.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_cexpl.c
 delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinf.c
 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

-- 
2.4.11

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

* [PATCHv2 04/11] Prepare to convert _Complex cosine functions
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (17 preceding siblings ...)
  2016-07-01 20:15   ` [PATCHv2 11/11] Convert remaining complex function to generated files Paul E. Murphy
@ 2016-07-01 20:15   ` Paul E. Murphy
  18 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01 20:15 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.

	* b_cacos.c: Copy of s_cacos.c.
	* b_cacosh.c: Copy of s_cacosh.c.
	* b_ccos.c: Copy of s_ccos.c.
	* b_ccosh.c: Copy of s_ccosh.c.
---
 math/{s_cacos.c => b_cacos.c}   | 0
 math/{s_cacosh.c => b_cacosh.c} | 0
 math/{s_ccos.c => b_ccos.c}     | 0
 math/{s_ccosh.c => b_ccosh.c}   | 0
 4 files changed, 0 insertions(+), 0 deletions(-)
 copy math/{s_cacos.c => b_cacos.c} (100%)
 copy math/{s_cacosh.c => b_cacosh.c} (100%)
 copy math/{s_ccos.c => b_ccos.c} (100%)
 copy math/{s_ccosh.c => b_ccosh.c} (100%)

diff --git a/math/s_cacos.c b/math/b_cacos.c
similarity index 100%
copy from math/s_cacos.c
copy to math/b_cacos.c
diff --git a/math/s_cacosh.c b/math/b_cacosh.c
similarity index 100%
copy from math/s_cacosh.c
copy to math/b_cacosh.c
diff --git a/math/s_ccos.c b/math/b_ccos.c
similarity index 100%
copy from math/s_ccos.c
copy to math/b_ccos.c
diff --git a/math/s_ccosh.c b/math/b_ccosh.c
similarity index 100%
copy from math/s_ccosh.c
copy to math/b_ccosh.c
-- 
2.4.11

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

* [PATCHv2 11/11] Convert remaining complex function to generated files
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
                     ` (16 preceding siblings ...)
  2016-07-01 20:14   ` [PATCHv2 03/11] Support for type-generic libm function implementations libm Paul E. Murphy
@ 2016-07-01 20:15   ` Paul E. Murphy
  2016-07-01 20:15   ` [PATCHv2 04/11] Prepare to convert _Complex cosine functions Paul E. Murphy
  18 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-07-01 20:15 UTC (permalink / raw)
  To: libc-alpha

Convert cpow, clog, clog10, cexp, csqrt, and cproj functions
into generated templates.  With the exception of clog10, the
transformation is identical to the previous patches.  clog10
needs some extra hackery as the __clog10* symbol was exposed
in days past, and thus required some extra hackery to
preserve this.

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

	* math/s_cexp.c: Refactor into
	* math/b_cexp.c: New file
	* math/s_cexpf.c: Removed
	* math/s_cexpl.c: Removed

	* math/s_clog10.c: Refactor into
	* math/b_clog10.c: New file
	* math/s_clog10f.c: Removed
	* math/s_clog10l.c: Removed

	* math/s_cpow.c: Refactor into
	* math/b_cpow.c: New file
	* math/s_cpowf.c: Removed
	* math/s_cpowl.c: Removed

	* math/s_clog.c: Refactor into
	* math/b_clog.c: New file
	* math/s_clogf.c: Removed
	* math/s_clogl.c: Removed

	* math/s_cproj.c: Refactor into
	* math/b_cproj.c: New file
	* math/s_cprojf.c: Removed
	* math/s_cprojl.c: Removed

	* math/s_csqrt.c: Refactor into
	* math/b_csqrt.c: New file
	* math/s_csqrtf.c: Removed
	* math/s_csqrtl.c: Removed

	* sysdeps/alpha/fpu/Makefile: Add overrides for _Complex
	float functions.
	* sysdeps/alpha/fpu/s_cexpf.c: Update to use tempated version.
	* sysdeps/alpha/fpu/s_clog10f.c: Update to use tempated version.
	* sysdeps/alpha/fpu/s_clogf.c: Update to use tempated version.
	* sysdeps/alpha/fpu/s_cpowf.c: Update to use tempated version.
	* sysdeps/alpha/fpu/s_cprojf.c: Update to use tempated version.
	* sysdeps/alpha/fpu/s_csqrtf.c: Update to use tempated version.

	* sysdeps/ieee754/ldbl-opt/math-type-macros.h: Add versioning
	information for newly refactored functions.

	* 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_clogl.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/m68k/m680x0/fpu/s_cexp.c: Refactor into
	* sysdeps/m68k/m680x0/fpu/b_cexp.c: New file
	* sysdeps/m68k/m680x0/fpu/s_cexpf.c: Removed
	* sysdeps/m68k/m680x0/fpu/s_cexpl.c: Removed
---
 math/Makefile                                  |   5 +-
 math/b_cexp.c                                  |  66 +++++-----
 math/b_clog.c                                  |  85 ++++++-------
 math/b_clog10.c                                | 105 +++++++++-------
 math/b_cpow.c                                  |  18 +--
 math/b_cproj.c                                 |  19 +--
 math/b_csqrt.c                                 | 105 ++++++++--------
 math/s_cexp.c                                  | 157 -----------------------
 math/s_cexpf.c                                 | 155 -----------------------
 math/s_cexpl.c                                 | 153 -----------------------
 math/s_clog.c                                  | 118 ------------------
 math/s_clog10.c                                | 124 -------------------
 math/s_clog10f.c                               | 122 ------------------
 math/s_clog10l.c                               | 127 -------------------
 math/s_clogf.c                                 | 116 -----------------
 math/s_clogl.c                                 | 121 ------------------
 math/s_cpow.c                                  |  33 -----
 math/s_cpowf.c                                 |  31 -----
 math/s_cpowl.c                                 |  29 -----
 math/s_cproj.c                                 |  44 -------
 math/s_cprojf.c                                |  42 -------
 math/s_cprojl.c                                |  40 ------
 math/s_csqrt.c                                 | 165 -------------------------
 math/s_csqrtf.c                                | 163 ------------------------
 math/s_csqrtl.c                                | 161 ------------------------
 sysdeps/alpha/fpu/Makefile                     |   6 +-
 sysdeps/alpha/fpu/s_cexpf.c                    |  13 +-
 sysdeps/alpha/fpu/s_clog10f.c                  |  15 ++-
 sysdeps/alpha/fpu/s_clogf.c                    |  13 +-
 sysdeps/alpha/fpu/s_cpowf.c                    |  13 +-
 sysdeps/alpha/fpu/s_cprojf.c                   |  13 +-
 sysdeps/alpha/fpu/s_csqrtf.c                   |  13 +-
 sysdeps/ieee754/ldbl-opt/math-type-macros.h    |   7 ++
 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           |  10 --
 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 -
 sysdeps/m68k/m680x0/fpu/{s_cexp.c => b_cexp.c} |  15 +--
 sysdeps/m68k/m680x0/fpu/s_cexpf.c              |   3 -
 sysdeps/m68k/m680x0/fpu/s_cexpl.c              |   3 -
 48 files changed, 282 insertions(+), 2213 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_clog10l.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 => b_cexp.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 63a385d..b230eb4 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -55,7 +55,8 @@ libm-support = s_lib_version s_matherr s_signgam			\
 # 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 g_cacos_F \
 	g_cacosh_F g_ccos_F g_ccosh_F g_casin_F g_csin_F g_casinh_F	  \
-	g_k_casinh_F g_csinh_F g_catanh_F g_catan_F g_ctan_F g_ctanh_F
+	g_k_casinh_F g_csinh_F g_catanh_F g_catan_F g_ctan_F g_ctanh_F	  \
+	g_cexp_F g_clog_F g_cproj_F g_csqrt_F g_cpow_F g_clog10_F
 
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
@@ -73,8 +74,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/b_cexp.c b/math/b_cexp.c
index 3a476bd..a84a472 100644
--- a/math/b_cexp.c
+++ b/math/b_cexp.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,56 +92,56 @@ __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)
 	    {
-	      /* Imaginary part is 0.0.  */
+	      /* Imaginary part is 0.  */
 	      __real__ retval = value;
 	      __imag__ retval = __imag__ 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/b_clog.c b/math/b_clog.c
index b546030..f42003f 100644
--- a/math/b_clog.c
+++ b/math/b_clog.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);
+      /* Real and imaginary part are 0.  */
+      __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_FUNC (__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/b_clog10.c b/math/b_clog10.c
index 8d9245b..ff38ffe 100644
--- a/math/b_clog10.c
+++ b/math/b_clog10.c
@@ -23,102 +23,121 @@
 #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)
+#if !defined (M_DISABLE_ALIASING) \
+    && defined (LONG_DOUBLE_COMPAT_VERSION) && M_TYPE == M_LDOUBLE
+# undef M_DECL_FUNC
+# define M_DECL_FUNC(x) __clog10l_internal
+#endif
+
+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_FUNC (__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_FUNC (__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)
+
+/* The aliasing for long double is a bit more complicated
+   since some private symbols leaked out in the past.  */
+#if defined (LONG_DOUBLE_COMPAT_VERSION) && M_TYPE == M_LDOUBLE	\
+    && !defined (M_INHIBIT_ALIASING)
+  strong_alias (__clog10l_internal, __clog10l__internal)
+  long_double_symbol (libm, __clog10l_internal, __clog10l);
+  long_double_symbol (libm, __clog10l__internal, clog10l);
+#else
+  declare_mgen_alias (__clog10, clog10)
+#endif
+
+#if M_LIBM_NEED_COMPAT (clog10)
+  declare_mgen_libm_compat (__clog10, __clog10)
+  declare_mgen_libm_compat (clog10, clog10)
 #endif
diff --git a/math/b_cpow.c b/math/b_cpow.c
index 037e575..c4862aa 100644
--- a/math/b_cpow.c
+++ b/math/b_cpow.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_FUNC (__cexp) (c * M_FUNC (__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/b_cproj.c b/math/b_cproj.c
index d47f009..35b8ba2 100644
--- a/math/b_cproj.c
+++ b/math/b_cproj.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/b_csqrt.c b/math/b_csqrt.c
index 1f073e7..07bb901 100644
--- a/math/b_csqrt.c
+++ b/math/b_csqrt.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_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_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_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_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_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_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_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/Makefile b/sysdeps/alpha/fpu/Makefile
index d8ccf86..7c7a1ec 100644
--- a/sysdeps/alpha/fpu/Makefile
+++ b/sysdeps/alpha/fpu/Makefile
@@ -2,7 +2,9 @@
 # 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 \
 	g_cacos_f g_cacosh_f g_ccos_f g_ccosh_f g_casin_f g_csin_f	 \
-	g_casinh_f g_csinh_f g_catan_f g_catanh_f g_ctan_f g_ctanh_f
+	g_casinh_f g_csinh_f g_catan_f g_catanh_f g_ctan_f g_ctanh_f	 \
+	g_cexp_f g_clog_f g_cproj_f g_csqrt_f g_cpow_f g_clog10_f
 libm-gen-replacement-calls = cabsf cargf cimagf crealf conjf	\
 	s_cacosf s_cacoshf s_ccosf s_ccoshf s_casinf s_csinf	\
-	s_casinhf s_csinhf s_catanf s_catanhf s_ctanf s_ctanhf
+	s_casinhf s_csinhf s_catanf s_catanhf s_ctanf s_ctanhf	\
+	s_cexpf s_clogf s_cprojf s_csqrtf s_cpowf s_clog10f
diff --git a/sysdeps/alpha/fpu/s_cexpf.c b/sysdeps/alpha/fpu/s_cexpf.c
index 2ae519c..f2e2474 100644
--- a/sysdeps/alpha/fpu/s_cexpf.c
+++ b/sysdeps/alpha/fpu/s_cexpf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __cexpf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_cexp.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..3fa06ee 100644
--- a/sysdeps/alpha/fpu/s_clog10f.c
+++ b/sysdeps/alpha/fpu/s_clog10f.c
@@ -24,14 +24,21 @@
 
 #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
+#define M_TYPE M_FLOAT
+/* Disable any non-standard aliasing.  */
+#define M_INHIBIT_ALIASING 1
+#include <math-type-macros.h>
 
-#undef __clog10f
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_clog10.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..168d3ef 100644
--- a/sysdeps/alpha/fpu/s_clogf.c
+++ b/sysdeps/alpha/fpu/s_clogf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __clogf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_clog.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..d16589a 100644
--- a/sysdeps/alpha/fpu/s_cpowf.c
+++ b/sysdeps/alpha/fpu/s_cpowf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __cpowf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_cpow.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..c48c2e1 100644
--- a/sysdeps/alpha/fpu/s_cprojf.c
+++ b/sysdeps/alpha/fpu/s_cprojf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __cprojf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_cproj.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..b8731d3 100644
--- a/sysdeps/alpha/fpu/s_csqrtf.c
+++ b/sysdeps/alpha/fpu/s_csqrtf.c
@@ -24,14 +24,19 @@
 
 #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
+#define M_TYPE M_FLOAT
+#include <math-type-macros.h>
 
-#undef __csqrtf
+/* Disable any aliasing from base template.  */
+#undef declare_mgen_alias
+#define declare_mgen_alias(__to, __from)
+
+#include <math/b_csqrt.c>
+#include "cfloat-compat.h"
 
 c1_cfloat_rettype
 __c1_csqrtf (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 646489e..5e61eb2 100644
--- a/sysdeps/ieee754/ldbl-opt/math-type-macros.h
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros.h
@@ -19,5 +19,12 @@
 #define LDOUBLE_catanhl_libm_version GLIBC_2_1
 #define LDOUBLE_ctanl_libm_version GLIBC_2_1
 #define LDOUBLE_ctanhl_libm_version GLIBC_2_1
+#define LDOUBLE_cexpl_libm_version GLIBC_2_1
+#define LDOUBLE_clogl_libm_version GLIBC_2_1
+#define LDOUBLE_cprojl_libm_version GLIBC_2_1
+#define LDOUBLE_csqrtl_libm_version GLIBC_2_1
+#define LDOUBLE_cpowl_libm_version GLIBC_2_1
+#define LDOUBLE_clog10l_libm_version GLIBC_2_1
+#define LDOUBLE___clog10l_libm_version GLIBC_2_1
 
 #include_next <math-type-macros.h>
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
deleted file mode 100644
index 954f680..0000000
--- a/sysdeps/ieee754/ldbl-opt/s_clog10l.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#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
-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/b_cexp.c
similarity index 94%
rename from sysdeps/m68k/m680x0/fpu/s_cexp.c
rename to sysdeps/m68k/m680x0/fpu/b_cexp.c
index f715b77..4667f08 100644
--- a/sysdeps/m68k/m680x0/fpu/s_cexp.c
+++ b/sysdeps/m68k/m680x0/fpu/b_cexp.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_FUNC (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] 53+ messages in thread

* Re: [Ping] [PATCHv2 00/11] Generate Complex functions from a common template.
  2016-07-01 20:14 [PATCHv2 00/11] Generate Complex functions from a common template Paul E. Murphy
  2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
@ 2016-08-02 14:37 ` Paul E. Murphy
  1 sibling, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-08-02 14:37 UTC (permalink / raw)
  To: libc-alpha

Ping.

On 07/01/2016 03:13 PM, Paul E. Murphy wrote:
> This is the second spin of the patch set based on
> feedback.
> 
> Primarily, it is cleanup to remove M_LIT (X.0) where
> X is a small integer, and use integer constants when
> possible.  Likewise, fixing comments mangled when
> converted.
> 
> Secondly, I have inserted a patch to unify the drift
> between the ccosh* and csinh* variants as suggested
> by Joseph.
> 
> Finally, I have inserted an extra patch before each
> major refactoring to explicitly copy the file which
> will be transformed into the template.  These changes
> do not break anything, but simplify the diff in the
> patch following them.
> 
> Again, I have run each patch through arm, alpha,
> x86-64, ppc64, and m68k builds.  I have compared the
> objdump and nm output of new object files with their
> replacements to verify no changes to code generation
> have occured after each patch, using the unification
> patch as the base.
> 
> The diffstat is a bit more accurate about the amount
> of cleanup occuring with this patchset.
> 
> 
> Paul E. Murphy (11):
>   Refactor part of math Makefile
>   Unify drift between _Complex function type variants
>   Support for type-generic libm function implementations libm
>   Prepare to convert _Complex cosine functions
>   Convert _Complex cosine functions to generated code
>   Prepare to convert _Complex sine functions
>   Convert _Complex sine functions to generated code
>   Prepare to convert _Complex tangent functions
>   Convert _Complex tangent functions to generated code
>   Prepare to convert remaining _Complex functions
>   Convert remaining complex function to generated files
> 
>  Makeconfig                                       |   2 +-
>  math/Makefile                                    | 176 ++++++++++++------
>  math/{s_cpow.c => b_cabs.c}                      |  18 +-
>  math/{s_cacosf.c => b_cacos.c}                   |  27 +--
>  math/{s_cacosh.c => b_cacosh.c}                  |  50 +++---
>  math/{s_cpowf.c => b_carg.c}                     |  16 +-
>  math/{s_casinf.c => b_casin.c}                   |  29 +--
>  math/{s_casinhf.c => b_casinh.c}                 |  35 ++--
>  math/b_catan.c                                   | 145 +++++++++++++++
>  math/b_catanh.c                                  | 140 +++++++++++++++
>  math/{s_ccosf.c => b_ccos.c}                     |  18 +-
>  math/{s_ccosh.c => b_ccosh.c}                    |  77 ++++----
>  math/{s_cexpf.c => b_cexp.c}                     |  64 +++----
>  math/{cimag.c => b_cimag.c}                      |  15 +-
>  math/{s_clogf.c => b_clog.c}                     |  83 ++++-----
>  math/b_clog10.c                                  | 143 +++++++++++++++
>  math/{conjf.c => b_conj.c}                       |  13 +-
>  math/{carg.c => b_cpow.c}                        |  17 +-
>  math/{s_cprojf.c => b_cproj.c}                   |  17 +-
>  math/{creal.c => b_creal.c}                      |  15 +-
>  math/{s_csinf.c => b_csin.c}                     |  77 ++++----
>  math/{s_csinh.c => b_csinh.c}                    |  79 ++++----
>  math/{s_csqrtf.c => b_csqrt.c}                   | 103 +++++------
>  math/{s_ctanf.c => b_ctan.c}                     |  67 +++----
>  math/{s_ctanhf.c => b_ctanh.c}                   |  67 +++----
>  math/b_k_casinh.c                                | 211 ++++++++++++++++++++++
>  math/cabs.c                                      |  32 ----
>  math/cabsf.c                                     |  28 ---
>  math/cabsl.c                                     |  28 ---
>  math/cargf.c                                     |  28 ---
>  math/cargl.c                                     |  28 ---
>  math/cimagf.c                                    |  27 ---
>  math/cimagl.c                                    |  27 ---
>  math/conj.c                                      |  31 ----
>  math/conjl.c                                     |  27 ---
>  math/crealf.c                                    |  27 ---
>  math/creall.c                                    |  27 ---
>  math/k_casinh.c                                  | 210 ----------------------
>  math/k_casinhf.c                                 | 212 ----------------------
>  math/k_casinhl.c                                 | 219 -----------------------
>  math/s_cacos.c                                   |  58 ------
>  math/s_cacoshf.c                                 |  92 ----------
>  math/s_cacoshl.c                                 |  90 ----------
>  math/s_cacosl.c                                  |  54 ------
>  math/s_casin.c                                   |  66 -------
>  math/s_casinh.c                                  |  73 --------
>  math/s_casinhl.c                                 |  69 -------
>  math/s_casinl.c                                  |  62 -------
>  math/s_catan.c                                   | 143 ---------------
>  math/s_catanf.c                                  | 143 ---------------
>  math/s_catanh.c                                  | 137 --------------
>  math/s_catanhf.c                                 | 137 --------------
>  math/s_catanhl.c                                 | 141 ---------------
>  math/s_catanl.c                                  | 147 ---------------
>  math/s_ccos.c                                    |  40 -----
>  math/s_ccoshf.c                                  | 147 ---------------
>  math/s_ccoshl.c                                  | 143 ---------------
>  math/s_ccosl.c                                   |  36 ----
>  math/s_cexp.c                                    | 157 ----------------
>  math/s_cexpl.c                                   | 153 ----------------
>  math/s_clog.c                                    | 118 ------------
>  math/s_clog10.c                                  | 124 -------------
>  math/s_clog10f.c                                 | 122 -------------
>  math/s_clog10l.c                                 | 127 -------------
>  math/s_clogl.c                                   | 121 -------------
>  math/s_cpowl.c                                   |  29 ---
>  math/s_cproj.c                                   |  44 -----
>  math/s_cprojl.c                                  |  40 -----
>  math/s_csin.c                                    | 171 ------------------
>  math/s_csinhf.c                                  | 166 -----------------
>  math/s_csinhl.c                                  | 164 -----------------
>  math/s_csinl.c                                   | 167 -----------------
>  math/s_csqrt.c                                   | 165 -----------------
>  math/s_csqrtl.c                                  | 161 -----------------
>  math/s_ctan.c                                    | 129 -------------
>  math/s_ctanh.c                                   | 129 -------------
>  math/s_ctanhl.c                                  | 132 --------------
>  math/s_ctanl.c                                   | 132 --------------
>  math/{test-ildoubl.c => test-ildouble.c}         |   0
>  scripts/sysd-rules.awk                           |   5 +-
>  sysdeps/alpha/fpu/Makefile                       |  10 ++
>  sysdeps/alpha/fpu/s_cacosf.c                     |  12 +-
>  sysdeps/alpha/fpu/s_cacoshf.c                    |  11 +-
>  sysdeps/alpha/fpu/s_casinf.c                     |  13 +-
>  sysdeps/alpha/fpu/s_casinhf.c                    |  13 +-
>  sysdeps/alpha/fpu/s_catanf.c                     |  13 +-
>  sysdeps/alpha/fpu/s_catanhf.c                    |  13 +-
>  sysdeps/alpha/fpu/s_ccosf.c                      |  13 +-
>  sysdeps/alpha/fpu/s_ccoshf.c                     |  13 +-
>  sysdeps/alpha/fpu/s_cexpf.c                      |  13 +-
>  sysdeps/alpha/fpu/s_clog10f.c                    |  15 +-
>  sysdeps/alpha/fpu/s_clogf.c                      |  13 +-
>  sysdeps/alpha/fpu/s_cpowf.c                      |  13 +-
>  sysdeps/alpha/fpu/s_cprojf.c                     |  13 +-
>  sysdeps/alpha/fpu/s_csinf.c                      |  13 +-
>  sysdeps/alpha/fpu/s_csinhf.c                     |  13 +-
>  sysdeps/alpha/fpu/s_csqrtf.c                     |  13 +-
>  sysdeps/alpha/fpu/s_ctanf.c                      |  13 +-
>  sysdeps/alpha/fpu/s_ctanhf.c                     |  13 +-
>  sysdeps/generic/math-type-macros.h               | 159 ++++++++++++++++
>  sysdeps/ieee754/Makeconfig                       |   6 +
>  sysdeps/ieee754/ldbl-opt/cabs.c                  |   6 -
>  sysdeps/ieee754/ldbl-opt/cabsl.c                 |   6 -
>  sysdeps/ieee754/ldbl-opt/carg.c                  |   6 -
>  sysdeps/ieee754/ldbl-opt/cargl.c                 |   6 -
>  sysdeps/ieee754/ldbl-opt/cimag.c                 |   6 -
>  sysdeps/ieee754/ldbl-opt/cimagl.c                |   6 -
>  sysdeps/ieee754/ldbl-opt/conj.c                  |   6 -
>  sysdeps/ieee754/ldbl-opt/conjl.c                 |   6 -
>  sysdeps/ieee754/ldbl-opt/creal.c                 |   6 -
>  sysdeps/ieee754/ldbl-opt/creall.c                |   6 -
>  sysdeps/ieee754/ldbl-opt/math-type-macros.h      |  30 ++++
>  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_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_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_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/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             |  10 --
>  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_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 -
>  sysdeps/ieee754/ldbl-opt/s_csqrt.c               |   6 -
>  sysdeps/ieee754/ldbl-opt/s_csqrtl.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 -
>  sysdeps/m68k/m680x0/fpu/{s_ccosh.c => b_ccosh.c} |  18 +-
>  sysdeps/m68k/m680x0/fpu/{s_cexp.c => b_cexp.c}   |  15 +-
>  sysdeps/m68k/m680x0/fpu/{s_csin.c => b_csin.c}   |  18 +-
>  sysdeps/m68k/m680x0/fpu/{s_csinh.c => b_csinh.c} |  17 +-
>  sysdeps/m68k/m680x0/fpu/s_ccoshf.c               |   3 -
>  sysdeps/m68k/m680x0/fpu/s_ccoshl.c               |   3 -
>  sysdeps/m68k/m680x0/fpu/s_cexpf.c                |   3 -
>  sysdeps/m68k/m680x0/fpu/s_cexpl.c                |   3 -
>  sysdeps/m68k/m680x0/fpu/s_csinf.c                |   3 -
>  sysdeps/m68k/m680x0/fpu/s_csinhf.c               |   3 -
>  sysdeps/m68k/m680x0/fpu/s_csinhl.c               |   3 -
>  sysdeps/m68k/m680x0/fpu/s_csinl.c                |   3 -
>  160 files changed, 1619 insertions(+), 6181 deletions(-)
>  rename math/{s_cpow.c => b_cabs.c} (78%)
>  rename math/{s_cacosf.c => b_cacos.c} (76%)
>  rename math/{s_cacosh.c => b_cacosh.c} (65%)
>  rename math/{s_cpowf.c => b_carg.c} (79%)
>  rename math/{s_casinf.c => b_casin.c} (75%)
>  rename math/{s_casinhf.c => b_casinh.c} (70%)
>  create mode 100644 math/b_catan.c
>  create mode 100644 math/b_catanh.c
>  rename math/{s_ccosf.c => b_ccos.c} (81%)
>  rename math/{s_ccosh.c => b_ccosh.c} (59%)
>  rename math/{s_cexpf.c => b_cexp.c} (69%)
>  rename math/{cimag.c => b_cimag.c} (82%)
>  rename math/{s_clogf.c => b_clog.c} (51%)
>  create mode 100644 math/b_clog10.c
>  rename math/{conjf.c => b_conj.c} (81%)
>  rename math/{carg.c => b_cpow.c} (78%)
>  rename math/{s_cprojf.c => b_cproj.c} (78%)
>  rename math/{creal.c => b_creal.c} (82%)
>  rename math/{s_csinf.c => b_csin.c} (65%)
>  rename math/{s_csinh.c => b_csinh.c} (62%)
>  rename math/{s_csqrtf.c => b_csqrt.c} (51%)
>  rename math/{s_ctanf.c => b_ctan.c} (64%)
>  rename math/{s_ctanhf.c => b_ctanh.c} (64%)
>  create mode 100644 math/b_k_casinh.c
>  delete mode 100644 math/cabs.c
>  delete mode 100644 math/cabsf.c
>  delete mode 100644 math/cabsl.c
>  delete mode 100644 math/cargf.c
>  delete mode 100644 math/cargl.c
>  delete mode 100644 math/cimagf.c
>  delete mode 100644 math/cimagl.c
>  delete mode 100644 math/conj.c
>  delete mode 100644 math/conjl.c
>  delete mode 100644 math/crealf.c
>  delete mode 100644 math/creall.c
>  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_cacos.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_casin.c
>  delete mode 100644 math/s_casinh.c
>  delete mode 100644 math/s_casinhl.c
>  delete mode 100644 math/s_casinl.c
>  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_ccos.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 math/s_cexp.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_clogl.c
>  delete mode 100644 math/s_cpowl.c
>  delete mode 100644 math/s_cproj.c
>  delete mode 100644 math/s_cprojl.c
>  delete mode 100644 math/s_csin.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 math/s_csqrt.c
>  delete mode 100644 math/s_csqrtl.c
>  delete mode 100644 math/s_ctan.c
>  delete mode 100644 math/s_ctanh.c
>  delete mode 100644 math/s_ctanhl.c
>  delete mode 100644 math/s_ctanl.c
>  rename math/{test-ildoubl.c => test-ildouble.c} (100%)
>  create mode 100644 sysdeps/alpha/fpu/Makefile
>  create mode 100644 sysdeps/generic/math-type-macros.h
>  create mode 100644 sysdeps/ieee754/Makeconfig
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/cabs.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/cabsl.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/carg.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/cargl.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/cimag.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/cimagl.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/conj.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/conjl.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/creal.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/creall.c
>  create mode 100644 sysdeps/ieee754/ldbl-opt/math-type-macros.h
>  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_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_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_ccos.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ccosh.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ccoshl.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/s_ccosl.c
>  delete mode 100644 sysdeps/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_clog10l.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_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
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csqrt.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/s_csqrtl.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
>  rename sysdeps/m68k/m680x0/fpu/{s_ccosh.c => b_ccosh.c} (87%)
>  rename sysdeps/m68k/m680x0/fpu/{s_cexp.c => b_cexp.c} (94%)
>  rename sysdeps/m68k/m680x0/fpu/{s_csin.c => b_csin.c} (86%)
>  rename sysdeps/m68k/m680x0/fpu/{s_csinh.c => b_csinh.c} (88%)
>  delete mode 100644 sysdeps/m68k/m680x0/fpu/s_ccoshf.c
>  delete mode 100644 sysdeps/m68k/m680x0/fpu/s_ccoshl.c
>  delete mode 100644 sysdeps/m68k/m680x0/fpu/s_cexpf.c
>  delete mode 100644 sysdeps/m68k/m680x0/fpu/s_cexpl.c
>  delete mode 100644 sysdeps/m68k/m680x0/fpu/s_csinf.c
>  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
> 

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

* Re: [PATCHv2 01/11] Refactor part of math Makefile
  2016-07-01 20:14   ` [PATCHv2 01/11] Refactor part of math Makefile Paul E. Murphy
@ 2016-08-02 21:34     ` Joseph Myers
  2016-08-03 17:13       ` Paul E. Murphy
  0 siblings, 1 reply; 53+ messages in thread
From: Joseph Myers @ 2016-08-02 21:34 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha

On Fri, 1 Jul 2016, Paul E. Murphy wrote:

> +libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
> +	$(libm-compat-calls-ldouble-$(long-double-fcts))

The indentation on the second line here is wrong (should line up with the 
first non-whitespace character after the '=' on the line above, i.e. 
indent with two tabs and four spaces instead of just one tab).

This patch is OK with that fixed, provided you've verified that the sets 
of files built and tests run are the same before and after the patch, on 
platforms with and without long double having a distinct ABI from double.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCHv2 02/11] Unify drift between _Complex function type variants
  2016-07-01 20:14   ` [PATCHv2 02/11] Unify drift between _Complex function type variants Paul E. Murphy
@ 2016-08-02 21:34     ` Joseph Myers
  2016-08-03 17:14     ` Paul E. Murphy
  1 sibling, 0 replies; 53+ messages in thread
From: Joseph Myers @ 2016-08-02 21:34 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha

On Fri, 1 Jul 2016, Paul E. Murphy wrote:

> While trying to convert the _Complex function wrappers
> into a single generic implementation, a few minor
> variations between identical versions emerged.
> 
> 	* s_ccoshf.c (__ccoshf): Remove FE_INVALID
> 	check, and remove __glibc_likely hint
> 	from FP_INFINITE check.
> 	* s_csinhf.c (__csinhf): Likewise.
> 
> 	* s_ccoshl.c (__ccoshl): Remove __glibc_likely
> 	hint from FP_INFINITE check.
> 	* s_csinhl.c (__csinhl): Likewise.

This patch is OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-07-01 20:14   ` [PATCHv2 03/11] Support for type-generic libm function implementations libm Paul E. Murphy
@ 2016-08-02 21:53     ` Joseph Myers
  2016-08-02 23:13       ` Paul E. Murphy
  0 siblings, 1 reply; 53+ messages in thread
From: Joseph Myers @ 2016-08-02 21:53 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha

On Fri, 1 Jul 2016, Paul E. Murphy wrote:

> +#if M_LIBM_NEED_COMPAT (carg)
> +  declare_mgen_libm_compat (__carg, carg)
>  #endif

This sort of thing is not conventionally indented.

> diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
> new file mode 100644
> index 0000000..3befde1
> --- /dev/null
> +++ b/sysdeps/generic/math-type-macros.h

How would you envisage additional types being handled?  Overriding the 
header with a variant that duplicates its contents but with extra types 
being handled doesn't seem like a good idea.  Maybe there should actually 
be a header per type, which then includes the generic type-independent 
header, or something like that?  I think more rationale is needed for the 
design relating to this header, anyway.

> +#if M_TYPE == M_FLOAT
> +# define M_PFX FLT
> +# define M_LIT(c) c ## f
> +/* Use the double version instead.  */
> +# define M_MLIT(c) c
> +# define M_SUF(c) c ## f
> +# define M_FUNC(c) c ## f
> +# define FLOAT float
> +# define CFLOAT __complex__ float
> +# define M_HUGE_VAL HUGE_VALF

Somewhere there needs to be a comment explaining the semantics of every 
one of these macros.  Especially, I can't tell what the difference of 
intent between M_SUF and M_FUNC is (which places should use one, which 
should use the other).  In one place you call M_SUF (__atan2), in another 
you define M_ATAN2 to M_FUNC (__ieee754_atan2) - why the difference 
between M_SUF and M_FUNC there?

> +#ifndef M_DECL_FUNC
> +# define M_DECL_FUNC(f) M_FUNC(f)
> +#endif

Missing space before '(' in macro call.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-02 21:53     ` Joseph Myers
@ 2016-08-02 23:13       ` Paul E. Murphy
  2016-08-04  1:49         ` Paul E. Murphy
  0 siblings, 1 reply; 53+ messages in thread
From: Paul E. Murphy @ 2016-08-02 23:13 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 08/02/2016 04:53 PM, Joseph Myers wrote:
> On Fri, 1 Jul 2016, Paul E. Murphy wrote:
> 
>> +#if M_LIBM_NEED_COMPAT (carg)
>> +  declare_mgen_libm_compat (__carg, carg)
>>  #endif
> 
> This sort of thing is not conventionally indented.
> 
>> diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
>> new file mode 100644
>> index 0000000..3befde1
>> --- /dev/null
>> +++ b/sysdeps/generic/math-type-macros.h
> 
> How would you envisage additional types being handled?  Overriding the 
> header with a variant that duplicates its contents but with extra types 
> being handled doesn't seem like a good idea.  Maybe there should actually 
> be a header per type, which then includes the generic type-independent 
> header, or something like that?  I think more rationale is needed for the 
> design relating to this header, anyway.

diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
index 3befde1..b92a379 100644
--- a/sysdeps/generic/math-type-macros.h
+++ b/sysdeps/generic/math-type-macros.h
@@ -22,6 +22,7 @@
 #define M_FLOAT 1
 #define M_DOUBLE 2
 #define M_LDOUBLE 3
+#define M_FLOAT128 4
 
 #if M_TYPE == M_FLOAT
 # define M_PFX FLT
@@ -51,6 +52,24 @@
 # define FLOAT long double
 # define CFLOAT __complex__ long double
 # define M_HUGE_VAL HUGE_VALL
+#elif M_TYPE == M_FLOAT128
+# define M_PFX FLT128
+# define M_MLIT(c) c ## f128
+# define M_SUF(c) c ## f128
+# define M_FUNC(c) c ## f128
+# define M_HUGE_VAL HUGE_VAL_F128
+
+# include <features.h>
+# if !__GNUC_PREREQ (7, 0)
+#  define M_LIT(c) c ## q
+#  define FLOAT __float128
+#  define CFLOAT __cfloat128
+# else
+#  define M_LIT(c) c ## f128
+#  define FLOAT _Float128
+#  define CFLOAT __complex__ _Float128
+# endif
+
 #else
 # error Error: M_TYPE is not a known floating point type
 #endif
@@ -98,8 +117,8 @@
 
 /* Rules for aliasing the currently generated math files.  */
 
-/* Aliasing rules for float are straight forward.  */
-#if M_TYPE == M_FLOAT
+/* Aliasing rules for float{,128} are straight forward.  */
+#if M_TYPE == M_FLOAT || M_TYPE == M_FLOAT128
 # define declare_mgen_alias(from, to) weak_alias (M_SUF (from), M_SUF (to))
 #endif
--

Note, in this example __cfloat128 is supplied indirectly
through complex.h via a typedef in a machine specific
header.  This is another discussion once the _Float128
patches are ready for a meaningful discussion. (As
a further digression, I am able to build and test as
_Float128 and _Complex _Float128 using your _FloatN
patches for GCC without issue.)


My initial thought was a simple header which could be
compiled on any machine provided sufficient GCC support
for the requested type.  So, you would keep tacking on
patches similar to the above.  However, __float128 may
be too simple an example to generalize from.

My other assumption is long double is the only type
which will have such convoluted aliasing and versioning
requirements.

Likewise, the only reason this lives in sysdeps is to
enable ldbl-opt to inject the necessary macros to
generate correctly versioned symbols on such machines.

Maybe we get the best of both worlds if this file moves
into math/, and create headers of the form
math-type-macros-{float,double,ldouble}.h which would
exclusively define the M_* macros, and optionally
declare_mgen_alias, declare_mgen_libm_compat.
math-type-macros.h would supply default versions of
the latter two macros if none are provided by the
type.

> 
>> +#if M_TYPE == M_FLOAT
>> +# define M_PFX FLT
>> +# define M_LIT(c) c ## f
>> +/* Use the double version instead.  */
>> +# define M_MLIT(c) c
>> +# define M_SUF(c) c ## f
>> +# define M_FUNC(c) c ## f
>> +# define FLOAT float
>> +# define CFLOAT __complex__ float
>> +# define M_HUGE_VAL HUGE_VALF
> 
> Somewhere there needs to be a comment explaining the semantics of every 
> one of these macros.  Especially, I can't tell what the difference of 
> intent between M_SUF and M_FUNC is (which places should use one, which 
> should use the other).  In one place you call M_SUF (__atan2), in another 
> you define M_ATAN2 to M_FUNC (__ieee754_atan2) - why the difference 
> between M_SUF and M_FUNC there?

In hindsight, they should be merged into one to apply the correct literal
suffix, and function suffix.

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

* Re: [PATCHv2 01/11] Refactor part of math Makefile
  2016-08-02 21:34     ` Joseph Myers
@ 2016-08-03 17:13       ` Paul E. Murphy
  0 siblings, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-08-03 17:13 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 08/02/2016 04:33 PM, Joseph Myers wrote:
> On Fri, 1 Jul 2016, Paul E. Murphy wrote:
> 
>> +libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
>> +	$(libm-compat-calls-ldouble-$(long-double-fcts))
> 
> The indentation on the second line here is wrong (should line up with the 
> first non-whitespace character after the '=' on the line above, i.e. 
> indent with two tabs and four spaces instead of just one tab).

Fixed.

> This patch is OK with that fixed, provided you've verified that the sets 
> of files built and tests run are the same before and after the patch, on 
> platforms with and without long double having a distinct ABI from double.
> 

I gave this whirl on the more complete linaro cross-toolchain for arm.  The
same set of test files are generated before and after this patch.

Committed as b9e05ed.

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

* Re: [PATCHv2 02/11] Unify drift between _Complex function type variants
  2016-07-01 20:14   ` [PATCHv2 02/11] Unify drift between _Complex function type variants Paul E. Murphy
  2016-08-02 21:34     ` Joseph Myers
@ 2016-08-03 17:14     ` Paul E. Murphy
  1 sibling, 0 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-08-03 17:14 UTC (permalink / raw)
  To: libc-alpha



On 07/01/2016 03:13 PM, Paul E. Murphy wrote:
> While trying to convert the _Complex function wrappers
> into a single generic implementation, a few minor
> variations between identical versions emerged.
> 
> 	* s_ccoshf.c (__ccoshf): Remove FE_INVALID
> 	check, and remove __glibc_likely hint
> 	from FP_INFINITE check.
> 	* s_csinhf.c (__csinhf): Likewise.
> 
> 	* s_ccoshl.c (__ccoshl): Remove __glibc_likely
> 	hint from FP_INFINITE check.
> 	* s_csinhl.c (__csinhl): Likewise.
> ---

Committed as f2de695.

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

* Re: [PATCH 2/6] Support for type-generic libm function implementations libm
  2016-06-30 22:21   ` [PATCH 2/6] Support for type-generic libm function implementations libm Paul E. Murphy
@ 2016-08-03 20:10     ` Adhemerval Zanella
  0 siblings, 0 replies; 53+ messages in thread
From: Adhemerval Zanella @ 2016-08-03 20:10 UTC (permalink / raw)
  To: libc-alpha



On 30/06/2016 19:20, Paul E. Murphy wrote:
> This defines two new classes of libm objects.  g for
> generated objects, and b for basic templates to
> generate those objects.  The end result should be
> much less duplication, and no function changes,
> other than potential shuffling of the code within
> libm.
> 

I am in favor of such cleanup and it seems a good strategy to
avoid code duplication.  I do not have much experience to review
the Makefile changes requires, so below just some general remarks.

> As a simple example, the trivial complex functions
> are converted to use the new infrastructure.
> 
> This uses some makefile hackery to generate g_*
> objects from from the base b_*.c.  The intent is to
> convert most or all of the complex function wrappers,
> possibly even the wrappers for the e functions.
> 
> Hooks are added to enable a platform to override a
> subset of generated files and replace them with a
> platform supplied list of files via the
> libm-gen-replacement-calls variable.  This is a
> little kludgy as the set of files being moved
> to this will likely include both unprefixed and
> w_ prefixed files.  The intent is to minimize
> awkward file renames.
> 
> Likewise, the alias for platforms which previously
> didn't have long double support in glibc is handled
> for trivial cases.  The more complex cases are left
> to be handled individually.
> 
> I have verified the built objects for ppc64, x86_64,
> alpha, arm, and m68k do not change in any meaningful
> way with these changes using the Fedora cross toolchains.
> I have verified the x86_64 and ppc64 changes still
> run.
> 
> Verification is done by checking the objdump of
> the g_*.{o,os} files with their equivalent s_
> object prior to the patch.  Additionally nm is
> used to verify the same set of symbols are
> exported.
> 
> 	* math/Makefile: Add support for routines generated
> 	via a macroed template file.
> 	(gen-libm-calls): New variable.
> 	(libm-calls-compat): Likewise.
> 	(gen-suffixes): Likewise.
> 	(g_CPPFLAGS): Likewise.
> 	(g__CPPFLAGS): Likewise.
> 	(g__fCPPFLAGS): Likewise.
> 	(g__lCPPFLAGS): Likewise.
> 
> 	* sysdeps/generic/math-type-macros.h: New file.
> 	* sysdeps/ieee754/ldbl-opt/math-type-macros.h: Likewise.
> 
> 	* math/cabs.c: Refactor into
> 	* math/b_cabs.c: new file.
> 	* math/cabsf.c: Removed.
> 	* math/cabsl.c: Removed.
> 	* sysdeps/ieee754/ldbl-opt/cabsf.c: Removed.
> 	* sysdeps/ieee754/ldbl-opt/cabsl.c: Removed.
> 
> 	* math/carg.c: Refactor into
> 	* math/b_carg.c: new file.
> 	* math/cargf.c: Removed.
> 	* math/cargl.c: Removed.
> 	* sysdeps/ieee754/ldbl-opt/cargf.c: Removed.
> 	* sysdeps/ieee754/ldbl-opt/cargl.c: Removed.
> 
> 	* math/conj.c: Refactor into
> 	* math/b_conj.c: new file.
> 	* math/conjf.c: Removed.
> 	* math/conjl.c: Removed.
> 	* sysdeps/ieee754/ldbl-opt/conjf.c: Removed.
> 	* sysdeps/ieee754/ldbl-opt/conjl.c: Removed.
> 
> 	* math/cimag.c: Refactor into
> 	* math/b_cimag.c: new file.
> 	* math/cimagf.c: Removed.
> 	* math/cimagl.c: Removed.
> 	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
> 	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.
> 
> 	* math/cimag.c: Refactor into
> 	* math/b_cimag.c: new file.
> 	* math/cimagf.c: Removed.
> 	* math/cimagl.c: Removed.
> 	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
> 	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.
> 
> 	* sysdeps/ieee754/Makeconfig: New file.
> 	* Makeconfig: Move m_% sysd pattern rule into above.
> 
> 	* scripts/sysd-rules.awk: Handle multiple rules
> 	with same DEP length correctly.
> 
> Fix intial generated code patch.
> ---
>  Makeconfig                                  |   2 +-
>  math/Makefile                               |  51 ++++++++-
>  math/b_cabs.c                               |  33 ++++++
>  math/b_carg.c                               |  33 ++++++
>  math/b_cimag.c                              |  32 ++++++
>  math/b_conj.c                               |  32 ++++++
>  math/b_creal.c                              |  32 ++++++
>  math/cabs.c                                 |  32 ------
>  math/cabsf.c                                |  28 -----
>  math/cabsl.c                                |  28 -----
>  math/carg.c                                 |  32 ------
>  math/cargf.c                                |  28 -----
>  math/cargl.c                                |  28 -----
>  math/cimag.c                                |  31 ------
>  math/cimagf.c                               |  27 -----
>  math/cimagl.c                               |  27 -----
>  math/conj.c                                 |  31 ------
>  math/conjf.c                                |  27 -----
>  math/conjl.c                                |  27 -----
>  math/creal.c                                |  31 ------
>  math/crealf.c                               |  27 -----
>  math/creall.c                               |  27 -----
>  scripts/sysd-rules.awk                      |   5 +-
>  sysdeps/alpha/fpu/Makefile                  |   4 +
>  sysdeps/generic/math-type-macros.h          | 159 ++++++++++++++++++++++++++++
>  sysdeps/ieee754/Makeconfig                  |   6 ++
>  sysdeps/ieee754/ldbl-opt/cabs.c             |   6 --
>  sysdeps/ieee754/ldbl-opt/cabsl.c            |   6 --
>  sysdeps/ieee754/ldbl-opt/carg.c             |   6 --
>  sysdeps/ieee754/ldbl-opt/cargl.c            |   6 --
>  sysdeps/ieee754/ldbl-opt/cimag.c            |   6 --
>  sysdeps/ieee754/ldbl-opt/cimagl.c           |   6 --
>  sysdeps/ieee754/ldbl-opt/conj.c             |   6 --
>  sysdeps/ieee754/ldbl-opt/conjl.c            |   6 --
>  sysdeps/ieee754/ldbl-opt/creal.c            |   6 --
>  sysdeps/ieee754/ldbl-opt/creall.c           |   6 --
>  sysdeps/ieee754/ldbl-opt/math-type-macros.h |  11 ++
>  37 files changed, 395 insertions(+), 496 deletions(-)
>  create mode 100644 math/b_cabs.c
>  create mode 100644 math/b_carg.c
>  create mode 100644 math/b_cimag.c
>  create mode 100644 math/b_conj.c
>  create mode 100644 math/b_creal.c
>  delete mode 100644 math/cabs.c
>  delete mode 100644 math/cabsf.c
>  delete mode 100644 math/cabsl.c
>  delete mode 100644 math/carg.c
>  delete mode 100644 math/cargf.c
>  delete mode 100644 math/cargl.c
>  delete mode 100644 math/cimag.c
>  delete mode 100644 math/cimagf.c
>  delete mode 100644 math/cimagl.c
>  delete mode 100644 math/conj.c
>  delete mode 100644 math/conjf.c
>  delete mode 100644 math/conjl.c
>  delete mode 100644 math/creal.c
>  delete mode 100644 math/crealf.c
>  delete mode 100644 math/creall.c
>  create mode 100644 sysdeps/alpha/fpu/Makefile
>  create mode 100644 sysdeps/generic/math-type-macros.h
>  create mode 100644 sysdeps/ieee754/Makeconfig
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/cabs.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/cabsl.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/carg.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/cargl.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/cimag.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/cimagl.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/conj.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/conjl.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/creal.c
>  delete mode 100644 sysdeps/ieee754/ldbl-opt/creall.c
>  create mode 100644 sysdeps/ieee754/ldbl-opt/math-type-macros.h
> 
> diff --git a/Makeconfig b/Makeconfig
> index 901e253..8a7b5f2 100644
> --- a/Makeconfig
> +++ b/Makeconfig
> @@ -1124,7 +1124,7 @@ endif
>  # emitted into sysd-rules.  A sysdeps Makeconfig fragment can
>  # add its own special object file prefix to this list with e.g. foo-%:%
>  # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
> -sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
> +sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:%
>  
>  # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
>  sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
> diff --git a/math/Makefile b/math/Makefile
> index 89002a8..14f8f42 100644
> --- a/math/Makefile
> +++ b/math/Makefile
> @@ -43,6 +43,18 @@ libm-support = s_lib_version s_matherr s_signgam			\
>  	       fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt	\
>  	       fegetexcept
>  
> +# These functions are generated from a common source with a select macros
> +# for each type they built for.  There is an explicit underscore between
> +# the function name and the type suffix to simplify matching to the
> +# rule used to build it.  These all build from a common b_func.c file.
> +#
> +# Similarly, a platform can override any of these generated functions
> +# (after type suffix substitution occurs) by adding a fragment which
> +# 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
> +

It is not clear to me based on these comments how an architecture would
override a specific implementation.  After I read the alpha change it
become move evident.  So if I understood correctly, besides adding the
arch specific implementation in the sysdep folder, one must also add
two more make specific rules (libm-gen-calls-override and 
libm-gen-replacement-calls) to actually override the building?

It would be good to add some documentation on how to actually override a
symbol based on an example.

>  libm-calls =								  \
>  	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
>  	e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF	  \
> @@ -59,13 +71,13 @@ 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	  \
> -	conjF cimagF crealF cabsF cargF s_cexpF s_csinhF s_ccoshF s_clogF \
> +	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_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			  \
> -	s_nextupF s_nextdownF
> +	s_nextupF s_nextdownF $(gen-libm-calls)
>  
>  libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl
>  libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
> @@ -105,7 +117,9 @@ type-float-routines :=
>  type-foreach = $(foreach t,$(types),$(subst F,$(type-$(t)-suffix),$(1)))
>  
>  libm-routines = $(strip $(libm-support) $(libm-compat-calls)		\
> -			$(call type-foreach, $(libm-calls))		\
> +			$(filter-out $(libm-gen-calls-override),	\
> +				$(call type-foreach, $(libm-calls)))	\
> +			$(libm-gen-replacement-calls)			\
>  			$(foreach t, $(types), $(type-$(t)-routines))) 	\
>  
>  # These functions are in libc instead of libm because __printf_fp
> @@ -118,6 +132,9 @@ calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \
>  generated += $(foreach s,.c .S,$(call type-foreach, $(calls:s_%=m_%$(s))))
>  routines = $(call type-foreach, $(calls))
>  
> +# Wrappers and what not are generated per type to keep the noise down.
> +generated += $(foreach s,.c .S,$(call type-foreach,$(gen-libm-calls:%=%$(s))))
> +
>  ifeq ($(build-mathvec),yes)
>  # We need to install libm.so as linker script
>  # for more comfortable use of vector math library.
> @@ -303,6 +320,34 @@ endef
>  object-suffixes-left := $(all-object-suffixes)
>  include $(o-iterator)
>  
> +# Generated per-type files.
> +#
> +# Suffixes for each generated file.  This hackery makes it possible
> +# to correctly identify name of the templated file.
> +gen-suffixes := $(foreach s,$(all-object-suffixes), \
> +                       $(foreach t,$(types),_$(type-$(t)-suffix)$s))
> +
> +# Add special flags to control how the templated functions
> +# are built.
> +g_CPPFLAGS = -include math-type-macros.h
> +g__fCPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_FLOAT
> +g__CPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_DOUBLE
> +g__lCPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_LDOUBLE
> +
> +# Like m_% above, this builds the generic sources.  Makeconfig
> +# enumerates the sysd-rules for overriding.
> +define o-iterator-doit
> +$(objpfx)g_%$o: b_%.c $(before-compile); $$(compile-command.c)
> +endef
> +object-suffixes-left := $(gen-suffixes)
> +include $(o-iterator)
> +
> +# Tack on the appropriate CPPFLAGS to match sysd-rules
> +define o-iterator-doit
> +$(objpfx)g_%$o: CPPFLAGS += $(g_$(basename $o)CPPFLAGS)
> +endef
> +object-suffixes-left := $(gen-suffixes)
> +include $(o-iterator)
>  
>  # This file defines the default _LIB_VERSION variable that controls
>  # the error return conventions for the math functions.
> diff --git a/math/b_cabs.c b/math/b_cabs.c
> new file mode 100644
> index 0000000..64265f1
> --- /dev/null
> +++ b/math/b_cabs.c
> @@ -0,0 +1,33 @@
> +/* Return the complex absolute value 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.

As a new file I think we can use just current year and drop the old 'Contributed by'
(this happens in all b_xxxx.c new files as well).

> +
> +   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>
> +
> +FLOAT
> +M_SUF (__cabs) (CFLOAT z)
> +{
> +  return M_SUF (__hypot) (__real__ z, __imag__ z);
> +}
> +
> +declare_mgen_alias (__cabs, cabs)
> +
> +#if M_LIBM_NEED_COMPAT (cabs)
> +  declare_mgen_libm_compat (__cabs, cabs)
> +#endif
> diff --git a/math/b_carg.c b/math/b_carg.c
> new file mode 100644
> index 0000000..004e14d
> --- /dev/null
> +++ b/math/b_carg.c
> @@ -0,0 +1,33 @@
> +/* Compute argument 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 <math.h>
> +
> +FLOAT
> +M_SUF (__carg) (CFLOAT x)
> +{
> +  return M_SUF (__atan2) (__imag__ x, __real__ x);
> +}
> +
> +declare_mgen_alias (__carg, carg)
> +
> +#if M_LIBM_NEED_COMPAT (carg)
> +  declare_mgen_libm_compat (__carg, carg)
> +#endif
> diff --git a/math/b_cimag.c b/math/b_cimag.c
> new file mode 100644
> index 0000000..73450f3
> --- /dev/null
> +++ b/math/b_cimag.c
> @@ -0,0 +1,32 @@
> +/* Return imaginary part 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>
> +
> +FLOAT
> +M_SUF (__cimag) (CFLOAT z)
> +{
> +  return __imag__ z;
> +}
> +
> +declare_mgen_alias (__cimag, cimag)
> +
> +#if M_LIBM_NEED_COMPAT (cimag)
> +  declare_mgen_libm_compat (__cimag, cimag)
> +#endif
> diff --git a/math/b_conj.c b/math/b_conj.c
> new file mode 100644
> index 0000000..979a759
> --- /dev/null
> +++ b/math/b_conj.c
> @@ -0,0 +1,32 @@
> +/* Return complex conjugate 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>
> +
> +CFLOAT
> +M_SUF (__conj) (CFLOAT z)
> +{
> +  return ~z;
> +}
> +
> +declare_mgen_alias (__conj, conj)
> +
> +#if M_LIBM_NEED_COMPAT (conj)
> +  declare_mgen_libm_compat (__conj, conj)
> +#endif
> diff --git a/math/b_creal.c b/math/b_creal.c
> new file mode 100644
> index 0000000..b92e0a3
> --- /dev/null
> +++ b/math/b_creal.c
> @@ -0,0 +1,32 @@
> +/* Return real part 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>
> +
> +FLOAT
> +M_SUF (__creal) (CFLOAT z)
> +{
> +  return __real__ z;
> +}
> +
> +declare_mgen_alias (__creal, creal)
> +
> +#if M_LIBM_NEED_COMPAT (creal)
> +  declare_mgen_libm_compat (__creal, creal)
> +#endif
> diff --git a/math/cabs.c b/math/cabs.c
> deleted file mode 100644
> index d7e0665..0000000
> --- a/math/cabs.c
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -/* Return the complex absolute value of 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 <math.h>
> -
> -double
> -__cabs (double _Complex z)
> -{
> -  return __hypot (__real__ z, __imag__ z);
> -}
> -weak_alias (__cabs, cabs)
> -#ifdef NO_LONG_DOUBLE
> -strong_alias (__cabs, __cabsl)
> -weak_alias (__cabs, cabsl)
> -#endif
> diff --git a/math/cabsf.c b/math/cabsf.c
> deleted file mode 100644
> index 431a244..0000000
> --- a/math/cabsf.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Return the complex absolute value of 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 <math.h>
> -
> -float
> -__cabsf (float _Complex z)
> -{
> -  return __hypotf (__real__ z, __imag__ z);
> -}
> -weak_alias (__cabsf, cabsf)
> diff --git a/math/cabsl.c b/math/cabsl.c
> deleted file mode 100644
> index d87e3a2..0000000
> --- a/math/cabsl.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Return the complex absolute value of 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 <math.h>
> -
> -long double
> -__cabsl (long double _Complex z)
> -{
> -  return __hypotl (__real__ z, __imag__ z);
> -}
> -weak_alias (__cabsl, cabsl)
> diff --git a/math/carg.c b/math/carg.c
> deleted file mode 100644
> index 61f1e0d..0000000
> --- a/math/carg.c
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -/* Compute argument 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>
> -
> -double
> -__carg (__complex__ double x)
> -{
> -  return __atan2 (__imag__ x, __real__ x);
> -}
> -weak_alias (__carg, carg)
> -#ifdef NO_LONG_DOUBLE
> -strong_alias (__carg, __cargl)
> -weak_alias (__carg, cargl)
> -#endif
> diff --git a/math/cargf.c b/math/cargf.c
> deleted file mode 100644
> index 620db3e..0000000
> --- a/math/cargf.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Compute argument 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>
> -
> -float
> -__cargf (__complex__ float x)
> -{
> -  return __atan2f (__imag__ x, __real__ x);
> -}
> -weak_alias (__cargf, cargf)
> diff --git a/math/cargl.c b/math/cargl.c
> deleted file mode 100644
> index 31b7292..0000000
> --- a/math/cargl.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Compute argument 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>
> -
> -long double
> -__cargl (__complex__ long double x)
> -{
> -  return __atan2l (__imag__ x, __real__ x);
> -}
> -weak_alias (__cargl, cargl)
> diff --git a/math/cimag.c b/math/cimag.c
> deleted file mode 100644
> index 1807ac2..0000000
> --- a/math/cimag.c
> +++ /dev/null
> @@ -1,31 +0,0 @@
> -/* Return imaginary part 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>
> -
> -double
> -__cimag (double _Complex z)
> -{
> -  return __imag__ z;
> -}
> -weak_alias (__cimag, cimag)
> -#ifdef NO_LONG_DOUBLE
> -strong_alias (__cimag, __cimagl)
> -weak_alias (__cimag, cimagl)
> -#endif
> diff --git a/math/cimagf.c b/math/cimagf.c
> deleted file mode 100644
> index 67c37f4..0000000
> --- a/math/cimagf.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Return imaginary part 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>
> -
> -float
> -__cimagf (float _Complex z)
> -{
> -  return __imag__ z;
> -}
> -weak_alias (__cimagf, cimagf)
> diff --git a/math/cimagl.c b/math/cimagl.c
> deleted file mode 100644
> index c1d0910..0000000
> --- a/math/cimagl.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Return imaginary part 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>
> -
> -long double
> -__cimagl (long double _Complex z)
> -{
> -  return __imag__ z;
> -}
> -weak_alias (__cimagl, cimagl)
> diff --git a/math/conj.c b/math/conj.c
> deleted file mode 100644
> index d282985..0000000
> --- a/math/conj.c
> +++ /dev/null
> @@ -1,31 +0,0 @@
> -/* Return complex conjugate 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>
> -
> -double _Complex
> -__conj (double _Complex z)
> -{
> -  return ~z;
> -}
> -weak_alias (__conj, conj)
> -#ifdef NO_LONG_DOUBLE
> -strong_alias (__conj, __conjl)
> -weak_alias (__conj, conjl)
> -#endif
> diff --git a/math/conjf.c b/math/conjf.c
> deleted file mode 100644
> index 3587c94..0000000
> --- a/math/conjf.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Return complex conjugate 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>
> -
> -float _Complex
> -__conjf (float _Complex z)
> -{
> -  return ~z;
> -}
> -weak_alias (__conjf, conjf)
> diff --git a/math/conjl.c b/math/conjl.c
> deleted file mode 100644
> index 55bb393..0000000
> --- a/math/conjl.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Return complex conjugate 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>
> -
> -long double _Complex
> -__conjl (long double _Complex z)
> -{
> -  return ~z;
> -}
> -weak_alias (__conjl, conjl)
> diff --git a/math/creal.c b/math/creal.c
> deleted file mode 100644
> index 231d3b0..0000000
> --- a/math/creal.c
> +++ /dev/null
> @@ -1,31 +0,0 @@
> -/* Return real part 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>
> -
> -double
> -__creal (double _Complex z)
> -{
> -  return __real__ z;
> -}
> -weak_alias (__creal, creal)
> -#ifdef NO_LONG_DOUBLE
> -strong_alias (__creal, __creall)
> -weak_alias (__creal, creall)
> -#endif
> diff --git a/math/crealf.c b/math/crealf.c
> deleted file mode 100644
> index 5883849..0000000
> --- a/math/crealf.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Return real part 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>
> -
> -float
> -__crealf (float _Complex z)
> -{
> -  return __real__ z;
> -}
> -weak_alias (__crealf, crealf)
> diff --git a/math/creall.c b/math/creall.c
> deleted file mode 100644
> index 4a31557..0000000
> --- a/math/creall.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Return real part 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>
> -
> -long double
> -__creall (long double _Complex z)
> -{
> -  return __real__ z;
> -}
> -weak_alias (__creall, creall)
> diff --git a/scripts/sysd-rules.awk b/scripts/sysd-rules.awk
> index 69af400..ccf1dff 100644
> --- a/scripts/sysd-rules.awk
> +++ b/scripts/sysd-rules.awk
> @@ -18,6 +18,9 @@ BEGIN {
>    # They are no in particular order.  We need to sort them so that
>    # the longest TARGET is first, and, among elements with the same
>    # TARGET, the longest DEP is first.
> +  #
> +  # If two TARGETs have the same length DEP, the first TARGET is
> +  # always listed first.
>    for (i = 1; i <= npatterns; ++i) {
>      if (split(patterns[i], td, ":") != 2) {
>        msg = "bad sysd-rules-patterns element '" patterns[i] "'";
> @@ -25,7 +28,7 @@ BEGIN {
>        exit 2;
>      }
>      target_order = sprintf("%09d", npatterns + 1 - length(td[1]));
> -    dep_order = sprintf("%09d", npatterns - length(td[2]));
> +    dep_order = sprintf("%09d%03d", npatterns - length(td[2]), i);
>      sort_patterns[target_order SUBSEP dep_order] = patterns[i];
>    }
>    asorti(sort_patterns, map_patterns);
> diff --git a/sysdeps/alpha/fpu/Makefile b/sysdeps/alpha/fpu/Makefile
> new file mode 100644
> index 0000000..c49c302
> --- /dev/null
> +++ b/sysdeps/alpha/fpu/Makefile
> @@ -0,0 +1,4 @@
> +# 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
> diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
> new file mode 100644
> index 0000000..3befde1
> --- /dev/null
> +++ b/sysdeps/generic/math-type-macros.h
> @@ -0,0 +1,159 @@
> +/* Helper macros for type generic function implementations within libm.
> +   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/>.  */
> +
> +#ifndef _MATH_TYPE_MACROS
> +#define _MATH_TYPE_MACROS
> +
> +#define M_FLOAT 1
> +#define M_DOUBLE 2
> +#define M_LDOUBLE 3
> +
> +#if M_TYPE == M_FLOAT
> +# define M_PFX FLT
> +# define M_LIT(c) c ## f
> +/* Use the double version instead.  */
> +# define M_MLIT(c) c
> +# define M_SUF(c) c ## f
> +# define M_FUNC(c) c ## f
> +# define FLOAT float
> +# define CFLOAT __complex__ float
> +# define M_HUGE_VAL HUGE_VALF
> +#elif M_TYPE == M_DOUBLE
> +# define M_PFX DBL
> +# define M_LIT(c) c
> +# define M_MLIT(c) c
> +# define M_SUF(c) c
> +# define M_FUNC(c) c
> +# define FLOAT double
> +# define CFLOAT __complex__ double
> +# define M_HUGE_VAL HUGE_VAL
> +#elif M_TYPE == M_LDOUBLE
> +# define M_PFX LDBL
> +# define M_LIT(c) c ## L
> +# define M_MLIT(c) c ## l
> +# define M_SUF(c) c ## l
> +# define M_FUNC(c) c ## l
> +# define FLOAT long double
> +# define CFLOAT __complex__ long double
> +# define M_HUGE_VAL HUGE_VALL
> +#else
> +# error Error: M_TYPE is not a known floating point type
> +#endif
> +
> +#define __M_CONCAT(a,b) a ## b
> +#define __M_CONCATX(a,b) __M_CONCAT(a,b)
> +
> +#define M_NAN M_FUNC (__nan) ("")
> +#define M_MAX_EXP __M_CONCATX (M_PFX, _MAX_EXP)
> +#define M_MIN __M_CONCATX (M_PFX, _MIN)
> +#define M_MAX __M_CONCATX (M_PFX, _MAX)
> +#define M_MANT_DIG __M_CONCATX (M_PFX, _MANT_DIG)
> +
> +/* Helper macros for commonly used functions.  */
> +#define M_COPYSIGN M_FUNC (__copysign)
> +#define M_FABS M_FUNC (fabs)
> +#define M_SINCOS M_FUNC (__sincos)
> +#define M_SCALBN M_FUNC (__scalbn)
> +#define M_LOG1P M_FUNC (__log1p)
> +
> +#define M_ATAN2 M_FUNC (__ieee754_atan2)
> +#define M_COSH M_FUNC (__ieee754_cosh)
> +#define M_EXP M_FUNC (__ieee754_exp)
> +#define M_HYPOT M_FUNC (__ieee754_hypot)
> +#define M_LOG M_FUNC (__ieee754_log)
> +#define M_SINH M_FUNC (__ieee754_sinh)
> +#define M_SQRT M_FUNC (__ieee754_sqrt)
> +
> +/* Needed to evaluate M_MANT_DIG below.  */
> +#include <float.h>
> +
> +/* Use a special epsilon value for IBM long double
> +   to avoid spurious overflows.  */
> +#if M_MANT_DIG != 106
> +# define M_EPSILON __M_CONCATX (M_PFX, _EPSILON)
> +#else
> +# define M_EPSILON 0x1p-106L
> +#endif
> +
> +/* Enable overloading of function name to assist
> +   reuse.  */
> +#ifndef M_DECL_FUNC
> +# define M_DECL_FUNC(f) M_FUNC(f)
> +#endif
> +
> +/* Rules for aliasing the currently generated math files.  */
> +
> +/* Aliasing rules for float are straight forward.  */
> +#if M_TYPE == M_FLOAT
> +# define declare_mgen_alias(from, to) weak_alias (M_SUF (from), M_SUF (to))
> +#endif
> +
> +/* Aliasing rules for double are sightly more
> +   complicated.
> +   1. long double == double.
> +   2. long double used to be double.
> +   3. double has always been unique. */
> +#if M_TYPE == M_DOUBLE
> +# if defined NO_LONG_DOUBLE
> +#  define declare_mgen_alias(from, to)	    \
> +    weak_alias (from, to)		    \
> +    strong_alias (from, from ## l)	    \
> +    weak_alias (from, to ## l)
> +# else
> +#  define declare_mgen_alias(from, to)	    \
> +    weak_alias (M_SUF (from), M_SUF (to))
> +# endif
> +#endif
> +
> +/* Slightly simpler for long double.
> +   1. long double used to be double.
> +   2. long double has always been unique.  */
> +#if M_TYPE == M_LDOUBLE
> +# if defined LONG_DOUBLE_COMPAT_VERSION
> +#  define declare_mgen_alias(from, to)		  \
> +    long_double_symbol (libm, from ## l, to ## l);
> +# else
> +#  define declare_mgen_alias(from, to)	    \
> +    weak_alias (M_SUF (from), M_SUF (to))
> +# endif
> +#endif
> +
> +#if ! defined declare_mgen_alias
> +# error Alias rules not defined for M_TYPE
> +#endif
> +
> +/* From case 2 for double, we may need to declare compat
> +   aliases for double symbols mapping to long double.
> +
> +   This suffices for the majority of the complex functions.
> +   More interesting cases need to be handled on a case by
> +   case basis.  */
> +#if M_TYPE == M_DOUBLE && defined LONG_DOUBLE_COMPAT_VERSION
> +# define M_LIBM_NEED_COMPAT(f)				      \
> +  LONG_DOUBLE_COMPAT (libm, LDOUBLE_ ## f ## l_libm_version)
> +# define declare_mgen_libm_compat(from, to)	      \
> +    compat_symbol (libm,			      \
> +		   from,			      \
> +		   to ## l,			      \
> +		   LDOUBLE_ ## to ## l_libm_version);
> +#else
> +# define M_LIBM_NEED_COMPAT(func) 0
> +# define declare_mgen_libm_compat(from, to)
> +#endif
> +
> +#endif /* _MATH_TYPE_MACROS */
> diff --git a/sysdeps/ieee754/Makeconfig b/sysdeps/ieee754/Makeconfig
> new file mode 100644
> index 0000000..15fd238
> --- /dev/null
> +++ b/sysdeps/ieee754/Makeconfig
> @@ -0,0 +1,6 @@
> +# Add the rules for generated math files in sysdeps
> +# Not the perfect place, but close enough.
> +#
> +# Each type supported by libm should have a g_%_SUFFIX
> +# pattern to match its suffix.
> +sysd-rules-patterns += m_%:s_% g_%_f:b_% g_%_l:b_% g_%_:b_%
> diff --git a/sysdeps/ieee754/ldbl-opt/cabs.c b/sysdeps/ieee754/ldbl-opt/cabs.c
> deleted file mode 100644
> index a181de2..0000000
> --- a/sysdeps/ieee754/ldbl-opt/cabs.c
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -#include <complex.h>
> -#include <math_ldbl_opt.h>
> -#include <math/cabs.c>
> -#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
> -compat_symbol (libm, __cabs, cabsl, GLIBC_2_1);
> -#endif
> diff --git a/sysdeps/ieee754/ldbl-opt/cabsl.c b/sysdeps/ieee754/ldbl-opt/cabsl.c
> deleted file mode 100644
> index b861633..0000000
> --- a/sysdeps/ieee754/ldbl-opt/cabsl.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/cabsl.c>
> -long_double_symbol (libm, __cabsl, cabsl);
> diff --git a/sysdeps/ieee754/ldbl-opt/carg.c b/sysdeps/ieee754/ldbl-opt/carg.c
> deleted file mode 100644
> index 2ed3581..0000000
> --- a/sysdeps/ieee754/ldbl-opt/carg.c
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -#include <complex.h>
> -#include <math_ldbl_opt.h>
> -#include <math/carg.c>
> -#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
> -compat_symbol (libm, __carg, cargl, GLIBC_2_1);
> -#endif
> diff --git a/sysdeps/ieee754/ldbl-opt/cargl.c b/sysdeps/ieee754/ldbl-opt/cargl.c
> deleted file mode 100644
> index 952dc60..0000000
> --- a/sysdeps/ieee754/ldbl-opt/cargl.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/cargl.c>
> -long_double_symbol (libm, __cargl, cargl);
> diff --git a/sysdeps/ieee754/ldbl-opt/cimag.c b/sysdeps/ieee754/ldbl-opt/cimag.c
> deleted file mode 100644
> index f805258..0000000
> --- a/sysdeps/ieee754/ldbl-opt/cimag.c
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -#include <complex.h>
> -#include <math_ldbl_opt.h>
> -#include <math/cimag.c>
> -#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
> -compat_symbol (libm, __cimag, cimagl, GLIBC_2_1);
> -#endif
> diff --git a/sysdeps/ieee754/ldbl-opt/cimagl.c b/sysdeps/ieee754/ldbl-opt/cimagl.c
> deleted file mode 100644
> index 112365e..0000000
> --- a/sysdeps/ieee754/ldbl-opt/cimagl.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/cimagl.c>
> -long_double_symbol (libm, __cimagl, cimagl);
> diff --git a/sysdeps/ieee754/ldbl-opt/conj.c b/sysdeps/ieee754/ldbl-opt/conj.c
> deleted file mode 100644
> index e4edade..0000000
> --- a/sysdeps/ieee754/ldbl-opt/conj.c
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -#include <complex.h>
> -#include <math_ldbl_opt.h>
> -#include <math/conj.c>
> -#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
> -compat_symbol (libm, __conj, conjl, GLIBC_2_1);
> -#endif
> diff --git a/sysdeps/ieee754/ldbl-opt/conjl.c b/sysdeps/ieee754/ldbl-opt/conjl.c
> deleted file mode 100644
> index c98e0ed..0000000
> --- a/sysdeps/ieee754/ldbl-opt/conjl.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/conjl.c>
> -long_double_symbol (libm, __conjl, conjl);
> diff --git a/sysdeps/ieee754/ldbl-opt/creal.c b/sysdeps/ieee754/ldbl-opt/creal.c
> deleted file mode 100644
> index 0d1c93e..0000000
> --- a/sysdeps/ieee754/ldbl-opt/creal.c
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -#include <complex.h>
> -#include <math_ldbl_opt.h>
> -#include <math/creal.c>
> -#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
> -compat_symbol (libm, __creal, creall, GLIBC_2_1);
> -#endif
> diff --git a/sysdeps/ieee754/ldbl-opt/creall.c b/sysdeps/ieee754/ldbl-opt/creall.c
> deleted file mode 100644
> index 68fedd4..0000000
> --- a/sysdeps/ieee754/ldbl-opt/creall.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/creall.c>
> -long_double_symbol (libm, __creall, creall);
> diff --git a/sysdeps/ieee754/ldbl-opt/math-type-macros.h b/sysdeps/ieee754/ldbl-opt/math-type-macros.h
> new file mode 100644
> index 0000000..f963f77
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-opt/math-type-macros.h
> @@ -0,0 +1,11 @@
> +/* Include the long double compatability support for generated math files.  */
> +#include <math_ldbl_opt.h>
> +
> +/* Declare compat versions for generated functions.  */
> +#define LDOUBLE_cabsl_libm_version GLIBC_2_1
> +#define LDOUBLE_cargl_libm_version GLIBC_2_1
> +#define LDOUBLE_cimagl_libm_version GLIBC_2_1
> +#define LDOUBLE_conjl_libm_version GLIBC_2_1
> +#define LDOUBLE_creall_libm_version GLIBC_2_1
> +
> +#include_next <math-type-macros.h>
> 

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

* Re: [PATCH 3/6] Convert _Complex cosine functions to generated code
  2016-06-30 22:21   ` [PATCH 3/6] Convert _Complex cosine " Paul E. Murphy
  2016-06-30 22:36     ` Joseph Myers
@ 2016-08-03 20:12     ` Adhemerval Zanella
  2016-08-03 21:18       ` Joseph Myers
  1 sibling, 1 reply; 53+ messages in thread
From: Adhemerval Zanella @ 2016-08-03 20:12 UTC (permalink / raw)
  To: libc-alpha

		  \
> 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.

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

* Re: [PATCH 3/6] Convert _Complex cosine functions to generated code
  2016-08-03 20:12     ` Adhemerval Zanella
@ 2016-08-03 21:18       ` Joseph Myers
  0 siblings, 0 replies; 53+ messages in thread
From: Joseph Myers @ 2016-08-03 21:18 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

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.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-02 23:13       ` Paul E. Murphy
@ 2016-08-04  1:49         ` Paul E. Murphy
  2016-08-04 16:43           ` Joseph Myers
  2016-08-04 17:03           ` Joseph Myers
  0 siblings, 2 replies; 53+ messages in thread
From: Paul E. Murphy @ 2016-08-04  1:49 UTC (permalink / raw)
  To: libc-alpha; +Cc: Joseph Myers, Adhemerval Zanella

[-- Attachment #1: Type: text/plain, Size: 2611 bytes --]



On 08/02/2016 06:12 PM, Paul E. Murphy wrote:
> My initial thought was a simple header which could be
> compiled on any machine provided sufficient GCC support
> for the requested type.  So, you would keep tacking on
> patches similar to the above.  However, __float128 may
> be too simple an example to generalize from.
> 
> My other assumption is long double is the only type
> which will have such convoluted aliasing and versioning
> requirements.
> 
> Likewise, the only reason this lives in sysdeps is to
> enable ldbl-opt to inject the necessary macros to
> generate correctly versioned symbols on such machines.
> 
> Maybe we get the best of both worlds if this file moves
> into math/, and create headers of the form
> math-type-macros-{float,double,ldouble}.h which would
> exclusively define the M_* macros, and optionally
> declare_mgen_alias, declare_mgen_libm_compat.
> math-type-macros.h would supply default versions of
> the latter two macros if none are provided by the
> type.
> 
>>
>>> +#if M_TYPE == M_FLOAT
>>> +# define M_PFX FLT
>>> +# define M_LIT(c) c ## f
>>> +/* Use the double version instead.  */
>>> +# define M_MLIT(c) c
>>> +# define M_SUF(c) c ## f
>>> +# define M_FUNC(c) c ## f
>>> +# define FLOAT float
>>> +# define CFLOAT __complex__ float
>>> +# define M_HUGE_VAL HUGE_VALF
>>
>> Somewhere there needs to be a comment explaining the semantics of every 
>> one of these macros.  Especially, I can't tell what the difference of 
>> intent between M_SUF and M_FUNC is (which places should use one, which 
>> should use the other).  In one place you call M_SUF (__atan2), in another 
>> you define M_ATAN2 to M_FUNC (__ieee754_atan2) - why the difference 
>> between M_SUF and M_FUNC there?
> 
> In hindsight, they should be merged into one to apply the correct literal
> suffix, and function suffix.
> 

Here is a spin of the patch implementing the ideas and feedback above. I've
moved the type specific bits into math-type-macros-{float,double,ldouble.h},
and added the necessary overrides to ldbl-opt to retain proper symbol
generation.

Likewise, I've done some cleanup to consistently utilize M_DECL_FUNC when
declaring the name of a function.  This is used in later patches to support
the old alpha ABI.  And, I've updated the commentary in math/Makefile at
Adhemerval's request.

I'll spare the list the churn of respinning the dependent patches.  They
are unchanged except for changing M_FUNC to M_SUF and the moving of the
ldbl-opt versioning to exclusively this patch.

I've verified no changes to generated code on ppc64 x86_64 arm m68k alpha
and s390x targets.

[-- Attachment #2: 0001-Support-for-type-generic-libm-function-implementatio.patch --]
[-- Type: text/x-patch, Size: 48546 bytes --]

From 348931214219cf9ef065d9ac5b4a090c308607e0 Mon Sep 17 00:00:00 2001
From: "Paul E. Murphy" <murphyp@linux.vnet.ibm.com>
Date: Tue, 14 Jun 2016 11:44:14 -0500
Subject: [PATCH 1/9] Support for type-generic libm function implementations
 libm

This defines two new classes of libm objects.  g for
generated objects, and b for basic templates to
generate those objects.  The end result should be
much less duplication, and no function changes,
other than potential shuffling of the code within
libm.

As a simple example, the trivial complex functions
are converted to use the new infrastructure.

This uses some makefile hackery to generate g_*
objects from from the base b_*.c.  The intent is to
convert most or all of the complex function wrappers,
possibly even the wrappers for the e functions.

Hooks are added to enable a platform to override a
subset of generated files and replace them with a
platform supplied list of files via the
libm-gen-replacement-calls variable.  This is a
little kludgy as the set of files being moved
to this will likely include both unprefixed and
w_ prefixed files.  The intent is to minimize
awkward file renames.

Likewise, the alias for platforms which previously
didn't have long double support in glibc is handled
for trivial cases.  The more complex cases are left
to be handled individually.

I have verified the built objects for ppc64, x86_64,
alpha, arm, and m68k do not change in any meaningful
way with these changes using the Fedora cross toolchains.
I have verified the x86_64 and ppc64 changes still run.

Verification is done by checking the objdump of
the g_*.{o,os} files with their equivalent s_
object prior to the patch.  Additionally nm is
used to verify the same set of symbols are
exported.

	* math/Makefile: Add support for routines generated
	via a macroed template file.
	(gen-libm-calls): New variable.
	(libm-calls-compat): Likewise.
	(gen-suffixes): Likewise.
	(g_CPPFLAGS): Likewise.
	(g__CPPFLAGS): Likewise.
	(g__fCPPFLAGS): Likewise.
	(g__lCPPFLAGS): Likewise.

	* math/math-type-macros.h: New file.
	* sysdeps/generic/math-type-macros-float.h: Likewise.
	* sysdeps/generic/math-type-macros-double.h: Likewise.
	* sysdeps/generic/math-type-macros-ldouble.h: Likewise.
	* sysdeps/ieee754/ldbl-opt/math-type-macros-double.h: Likewise.
	* sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h: Likewise.
	* sysdeps/ieee754/ldbl-opt/math_ldbl_opt_versions.h: Likewise.

	* math/cabs.c: Refactor into
	* math/b_cabs.c: new file.
	* math/cabsf.c: Removed.
	* math/cabsl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cabsf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cabsl.c: Removed.

	* math/carg.c: Refactor into
	* math/b_carg.c: new file.
	* math/cargf.c: Removed.
	* math/cargl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cargf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cargl.c: Removed.

	* math/conj.c: Refactor into
	* math/b_conj.c: new file.
	* math/conjf.c: Removed.
	* math/conjl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/conjf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/conjl.c: Removed.

	* math/cimag.c: Refactor into
	* math/b_cimag.c: new file.
	* math/cimagf.c: Removed.
	* math/cimagl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.

	* math/cimag.c: Refactor into
	* math/b_cimag.c: new file.
	* math/cimagf.c: Removed.
	* math/cimagl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.

	* sysdeps/ieee754/Makeconfig: New file.
	* Makeconfig: Move m_% sysd pattern rule into above.

	* scripts/sysd-rules.awk: Handle multiple rules
	with same DEP length correctly.
---
 Makeconfig                                         |   2 +-
 math/Makefile                                      |  59 ++++++++++-
 math/{cabs.c => b_cabs.c}                          |  17 +--
 math/{carg.c => b_carg.c}                          |  17 +--
 math/{cimag.c => b_cimag.c}                        |  15 +--
 math/{conj.c => b_conj.c}                          |  15 +--
 math/{creal.c => b_creal.c}                        |  15 +--
 math/cabsf.c                                       |  28 -----
 math/cabsl.c                                       |  28 -----
 math/cargf.c                                       |  28 -----
 math/cargl.c                                       |  28 -----
 math/cimagf.c                                      |  27 -----
 math/cimagl.c                                      |  27 -----
 math/conjf.c                                       |  27 -----
 math/conjl.c                                       |  27 -----
 math/crealf.c                                      |  27 -----
 math/creall.c                                      |  27 -----
 scripts/sysd-rules.awk                             |   5 +-
 sysdeps/alpha/fpu/Makefile                         |   4 +
 .../generic/math-type-macros-double.h              |  38 ++++---
 .../generic/math-type-macros-float.h               |  28 ++---
 .../generic/math-type-macros-ldouble.h             |  25 +++--
 sysdeps/generic/math-type-macros.h                 | 116 +++++++++++++++++++++
 sysdeps/ieee754/Makeconfig                         |   6 ++
 sysdeps/ieee754/ldbl-opt/cabs.c                    |   6 --
 sysdeps/ieee754/ldbl-opt/cabsl.c                   |   6 --
 sysdeps/ieee754/ldbl-opt/carg.c                    |   6 --
 sysdeps/ieee754/ldbl-opt/cargl.c                   |   6 --
 sysdeps/ieee754/ldbl-opt/cimag.c                   |   6 --
 sysdeps/ieee754/ldbl-opt/cimagl.c                  |   6 --
 sysdeps/ieee754/ldbl-opt/conj.c                    |   6 --
 sysdeps/ieee754/ldbl-opt/conjl.c                   |   6 --
 sysdeps/ieee754/ldbl-opt/creal.c                   |   6 --
 sysdeps/ieee754/ldbl-opt/creall.c                  |   6 --
 .../ieee754/ldbl-opt/math-type-macros-double.h     |  31 +++---
 .../ieee754/ldbl-opt/math-type-macros-ldouble.h    |  25 +++--
 sysdeps/ieee754/ldbl-opt/math_ldbl_opt_versions.h  |  42 ++++++++
 37 files changed, 352 insertions(+), 442 deletions(-)
 rename math/{cabs.c => b_cabs.c} (77%)
 rename math/{carg.c => b_carg.c} (79%)
 copy math/{cimag.c => b_cimag.c} (82%)
 rename math/{conj.c => b_conj.c} (81%)
 rename math/{creal.c => b_creal.c} (82%)
 delete mode 100644 math/cabsf.c
 delete mode 100644 math/cabsl.c
 delete mode 100644 math/cargf.c
 delete mode 100644 math/cargl.c
 delete mode 100644 math/cimagf.c
 delete mode 100644 math/cimagl.c
 delete mode 100644 math/conjf.c
 delete mode 100644 math/conjl.c
 delete mode 100644 math/crealf.c
 delete mode 100644 math/creall.c
 create mode 100644 sysdeps/alpha/fpu/Makefile
 copy math/cimag.c => sysdeps/generic/math-type-macros-double.h (50%)
 copy math/cimag.c => sysdeps/generic/math-type-macros-float.h (61%)
 copy math/cimag.c => sysdeps/generic/math-type-macros-ldouble.h (65%)
 create mode 100644 sysdeps/generic/math-type-macros.h
 create mode 100644 sysdeps/ieee754/Makeconfig
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabs.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabsl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/carg.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cargl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimag.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimagl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conj.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conjl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creal.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creall.c
 copy math/cimag.c => sysdeps/ieee754/ldbl-opt/math-type-macros-double.h (55%)
 rename math/cimag.c => sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h (61%)
 create mode 100644 sysdeps/ieee754/ldbl-opt/math_ldbl_opt_versions.h

diff --git a/Makeconfig b/Makeconfig
index 03fd89c..8957180 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1125,7 +1125,7 @@ endif
 # emitted into sysd-rules.  A sysdeps Makeconfig fragment can
 # add its own special object file prefix to this list with e.g. foo-%:%
 # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
-sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
+sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:%
 
 # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
 sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
diff --git a/math/Makefile b/math/Makefile
index 925b8d4..483e0af 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -43,6 +43,26 @@ libm-support = s_lib_version s_matherr s_signgam			\
 	       fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt	\
 	       fegetexcept
 
+# These functions are generated from a common source with a select macros
+# for each type they built for.  There is an explicit underscore between
+# the function name and the type suffix to simplify matching to the
+# rule used to build it.  These all build from a common b_func.c file.
+#
+# A platform can override any of these generated functions.
+# Overrides are accounted for after type suffix substitution occurs, by
+# adding a makefile fragment which defines libm-gen-calls-override and
+# libm-gen-replacement-calls for each overriden function.
+#
+# i.e:
+#
+# libm-gen-calls-override = g_cimag_
+# libm-gen-replacement-calls = cimag
+#
+# Would inhibit building the double version of cimag from the the
+# template b_cimag.c, and instead look for a buildable file matching
+# the name cimag.
+gen-libm-calls = g_carg_F g_conj_F g_cimag_F g_creal_F g_cabs_F
+
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
 	e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF	  \
@@ -59,13 +79,13 @@ 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	  \
-	conjF cimagF crealF cabsF cargF s_cexpF s_csinhF s_ccoshF s_clogF \
+	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_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			  \
-	s_nextupF s_nextdownF
+	s_nextupF s_nextdownF $(gen-libm-calls)
 
 libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl
 libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
@@ -105,7 +125,9 @@ type-float-routines :=
 type-foreach = $(foreach t,$(types),$(subst F,$(type-$(t)-suffix),$(1)))
 
 libm-routines = $(strip $(libm-support) $(libm-compat-calls)		\
-			$(call type-foreach, $(libm-calls))		\
+			$(filter-out $(libm-gen-calls-override),	\
+				$(call type-foreach, $(libm-calls)))	\
+			$(libm-gen-replacement-calls)			\
 			$(foreach t, $(types), $(type-$(t)-routines))) 	\
 
 # These functions are in libc instead of libm because __printf_fp
@@ -118,6 +140,9 @@ calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \
 generated += $(foreach s,.c .S,$(call type-foreach, $(calls:s_%=m_%$(s))))
 routines = $(call type-foreach, $(calls))
 
+# Wrappers and what not are generated per type to keep the noise down.
+generated += $(foreach s,.c .S,$(call type-foreach,$(gen-libm-calls:%=%$(s))))
+
 ifeq ($(build-mathvec),yes)
 # We need to install libm.so as linker script
 # for more comfortable use of vector math library.
@@ -303,6 +328,34 @@ endef
 object-suffixes-left := $(all-object-suffixes)
 include $(o-iterator)
 
+# Generated per-type files.
+#
+# Suffixes for each generated file.  This hackery makes it possible
+# to correctly identify name of the templated file.
+gen-suffixes := $(foreach s,$(all-object-suffixes), \
+                       $(foreach t,$(types),_$(type-$(t)-suffix)$s))
+
+# Add special flags to control how the templated functions
+# are built.
+g_CPPFLAGS = -include math-type-macros.h
+g__fCPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_FLOAT
+g__CPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_DOUBLE
+g__lCPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_LDOUBLE
+
+# Like m_% above, this builds the generic sources.  Makeconfig
+# enumerates the sysd-rules for overriding.
+define o-iterator-doit
+$(objpfx)g_%$o: b_%.c $(before-compile); $$(compile-command.c)
+endef
+object-suffixes-left := $(gen-suffixes)
+include $(o-iterator)
+
+# Tack on the appropriate CPPFLAGS to match sysd-rules
+define o-iterator-doit
+$(objpfx)g_%$o: CPPFLAGS += $(g_$(basename $o)CPPFLAGS)
+endef
+object-suffixes-left := $(gen-suffixes)
+include $(o-iterator)
 
 # This file defines the default _LIB_VERSION variable that controls
 # the error return conventions for the math functions.
diff --git a/math/cabs.c b/math/b_cabs.c
similarity index 77%
rename from math/cabs.c
rename to math/b_cabs.c
index d7e0665..5eff1b2 100644
--- a/math/cabs.c
+++ b/math/b_cabs.c
@@ -1,4 +1,4 @@
-/* Return the complex absolute value of double complex value.
+/* Return the complex absolute value 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.
@@ -20,13 +20,14 @@
 #include <complex.h>
 #include <math.h>
 
-double
-__cabs (double _Complex z)
+FLOAT
+M_DECL_FUNC (__cabs) (CFLOAT z)
 {
-  return __hypot (__real__ z, __imag__ z);
+  return M_SUF (__hypot) (__real__ z, __imag__ z);
 }
-weak_alias (__cabs, cabs)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cabs, __cabsl)
-weak_alias (__cabs, cabsl)
+
+declare_mgen_alias (__cabs, cabs)
+
+#if M_LIBM_NEED_COMPAT (cabs)
+declare_mgen_libm_compat (__cabs, cabs)
 #endif
diff --git a/math/carg.c b/math/b_carg.c
similarity index 79%
rename from math/carg.c
rename to math/b_carg.c
index 61f1e0d..6205be8 100644
--- a/math/carg.c
+++ b/math/b_carg.c
@@ -1,4 +1,4 @@
-/* Compute argument of complex double value.
+/* Compute argument 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.
@@ -20,13 +20,14 @@
 #include <complex.h>
 #include <math.h>
 
-double
-__carg (__complex__ double x)
+FLOAT
+M_DECL_FUNC (__carg) (CFLOAT x)
 {
-  return __atan2 (__imag__ x, __real__ x);
+  return M_SUF (__atan2) (__imag__ x, __real__ x);
 }
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
+
+declare_mgen_alias (__carg, carg)
+
+#if M_LIBM_NEED_COMPAT (carg)
+declare_mgen_libm_compat (__carg, carg)
 #endif
diff --git a/math/cimag.c b/math/b_cimag.c
similarity index 82%
copy from math/cimag.c
copy to math/b_cimag.c
index 1807ac2..582147d 100644
--- a/math/cimag.c
+++ b/math/b_cimag.c
@@ -1,4 +1,4 @@
-/* Return imaginary part of complex double value.
+/* Return imaginary part 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double
-__cimag (double _Complex z)
+FLOAT
+M_DECL_FUNC (__cimag) (CFLOAT z)
 {
   return __imag__ z;
 }
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
+
+declare_mgen_alias (__cimag, cimag)
+
+#if M_LIBM_NEED_COMPAT (cimag)
+declare_mgen_libm_compat (__cimag, cimag)
 #endif
diff --git a/math/conj.c b/math/b_conj.c
similarity index 81%
rename from math/conj.c
rename to math/b_conj.c
index d282985..72d1236 100644
--- a/math/conj.c
+++ b/math/b_conj.c
@@ -1,4 +1,4 @@
-/* Return complex conjugate of complex double value.
+/* Return complex conjugate 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double _Complex
-__conj (double _Complex z)
+CFLOAT
+M_DECL_FUNC (__conj) (CFLOAT z)
 {
   return ~z;
 }
-weak_alias (__conj, conj)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__conj, __conjl)
-weak_alias (__conj, conjl)
+
+declare_mgen_alias (__conj, conj)
+
+#if M_LIBM_NEED_COMPAT (conj)
+declare_mgen_libm_compat (__conj, conj)
 #endif
diff --git a/math/creal.c b/math/b_creal.c
similarity index 82%
rename from math/creal.c
rename to math/b_creal.c
index 231d3b0..f840f43 100644
--- a/math/creal.c
+++ b/math/b_creal.c
@@ -1,4 +1,4 @@
-/* Return real part of complex double value.
+/* Return real part 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double
-__creal (double _Complex z)
+FLOAT
+M_DECL_FUNC (__creal) (CFLOAT z)
 {
   return __real__ z;
 }
-weak_alias (__creal, creal)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__creal, __creall)
-weak_alias (__creal, creall)
+
+declare_mgen_alias (__creal, creal)
+
+#if M_LIBM_NEED_COMPAT (creal)
+declare_mgen_libm_compat (__creal, creal)
 #endif
diff --git a/math/cabsf.c b/math/cabsf.c
deleted file mode 100644
index 431a244..0000000
--- a/math/cabsf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-float
-__cabsf (float _Complex z)
-{
-  return __hypotf (__real__ z, __imag__ z);
-}
-weak_alias (__cabsf, cabsf)
diff --git a/math/cabsl.c b/math/cabsl.c
deleted file mode 100644
index d87e3a2..0000000
--- a/math/cabsl.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-long double
-__cabsl (long double _Complex z)
-{
-  return __hypotl (__real__ z, __imag__ z);
-}
-weak_alias (__cabsl, cabsl)
diff --git a/math/cargf.c b/math/cargf.c
deleted file mode 100644
index 620db3e..0000000
--- a/math/cargf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Compute argument 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>
-
-float
-__cargf (__complex__ float x)
-{
-  return __atan2f (__imag__ x, __real__ x);
-}
-weak_alias (__cargf, cargf)
diff --git a/math/cargl.c b/math/cargl.c
deleted file mode 100644
index 31b7292..0000000
--- a/math/cargl.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Compute argument 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>
-
-long double
-__cargl (__complex__ long double x)
-{
-  return __atan2l (__imag__ x, __real__ x);
-}
-weak_alias (__cargl, cargl)
diff --git a/math/cimagf.c b/math/cimagf.c
deleted file mode 100644
index 67c37f4..0000000
--- a/math/cimagf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return imaginary part 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>
-
-float
-__cimagf (float _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimagf, cimagf)
diff --git a/math/cimagl.c b/math/cimagl.c
deleted file mode 100644
index c1d0910..0000000
--- a/math/cimagl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return imaginary part 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>
-
-long double
-__cimagl (long double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimagl, cimagl)
diff --git a/math/conjf.c b/math/conjf.c
deleted file mode 100644
index 3587c94..0000000
--- a/math/conjf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return complex conjugate 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>
-
-float _Complex
-__conjf (float _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conjf, conjf)
diff --git a/math/conjl.c b/math/conjl.c
deleted file mode 100644
index 55bb393..0000000
--- a/math/conjl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return complex conjugate 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>
-
-long double _Complex
-__conjl (long double _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conjl, conjl)
diff --git a/math/crealf.c b/math/crealf.c
deleted file mode 100644
index 5883849..0000000
--- a/math/crealf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return real part 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>
-
-float
-__crealf (float _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__crealf, crealf)
diff --git a/math/creall.c b/math/creall.c
deleted file mode 100644
index 4a31557..0000000
--- a/math/creall.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return real part 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>
-
-long double
-__creall (long double _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__creall, creall)
diff --git a/scripts/sysd-rules.awk b/scripts/sysd-rules.awk
index 69af400..ccf1dff 100644
--- a/scripts/sysd-rules.awk
+++ b/scripts/sysd-rules.awk
@@ -18,6 +18,9 @@ BEGIN {
   # They are no in particular order.  We need to sort them so that
   # the longest TARGET is first, and, among elements with the same
   # TARGET, the longest DEP is first.
+  #
+  # If two TARGETs have the same length DEP, the first TARGET is
+  # always listed first.
   for (i = 1; i <= npatterns; ++i) {
     if (split(patterns[i], td, ":") != 2) {
       msg = "bad sysd-rules-patterns element '" patterns[i] "'";
@@ -25,7 +28,7 @@ BEGIN {
       exit 2;
     }
     target_order = sprintf("%09d", npatterns + 1 - length(td[1]));
-    dep_order = sprintf("%09d", npatterns - length(td[2]));
+    dep_order = sprintf("%09d%03d", npatterns - length(td[2]), i);
     sort_patterns[target_order SUBSEP dep_order] = patterns[i];
   }
   asorti(sort_patterns, map_patterns);
diff --git a/sysdeps/alpha/fpu/Makefile b/sysdeps/alpha/fpu/Makefile
new file mode 100644
index 0000000..c49c302
--- /dev/null
+++ b/sysdeps/alpha/fpu/Makefile
@@ -0,0 +1,4 @@
+# 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
diff --git a/math/cimag.c b/sysdeps/generic/math-type-macros-double.h
similarity index 50%
copy from math/cimag.c
copy to sysdeps/generic/math-type-macros-double.h
index 1807ac2..5d5077d 100644
--- a/math/cimag.c
+++ b/sysdeps/generic/math-type-macros-double.h
@@ -1,7 +1,6 @@
-/* Return imaginary part of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Helper macros for double variants of type generic functions of libm.
+   Copyright (C) 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
@@ -17,15 +16,28 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
+#ifndef _MATH_TYPE_MACROS_DOUBLE
+#define _MATH_TYPE_MACROS_DOUBLE
+
+#define M_PFX DBL
+#define M_LIT(c) c
+#define M_MLIT(c) c
+#define M_SUF(c) c
+#define FLOAT double
+#define CFLOAT __complex__ double
+#define M_HUGE_VAL HUGE_VAL
+
+/* Machines without a distinct long double type
+   alias long double functions to their double
+   equivalent.  */
+#if defined NO_LONG_DOUBLE
+# define declare_mgen_alias(from, to)	    \
+   weak_alias (from, to)		    \
+   strong_alias (from, from ## l)	    \
+   weak_alias (from, to ## l)
+#else
+# define declare_mgen_alias(from, to)	    \
+   weak_alias (M_SUF (from), M_SUF (to))
+#endif
 
-double
-__cimag (double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
 #endif
diff --git a/math/cimag.c b/sysdeps/generic/math-type-macros-float.h
similarity index 61%
copy from math/cimag.c
copy to sysdeps/generic/math-type-macros-float.h
index 1807ac2..d9c887b 100644
--- a/math/cimag.c
+++ b/sysdeps/generic/math-type-macros-float.h
@@ -1,7 +1,6 @@
-/* Return imaginary part of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Helper macros for float variants of type generic functions of libm.
+   Copyright (C) 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
@@ -17,15 +16,18 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
+#ifndef _MATH_TYPE_MACROS_FLOAT
+#define _MATH_TYPE_MACROS_FLOAT
+
+#define M_PFX FLT
+#define M_LIT(c) c ## f
+#define M_SUF(c) c ## f
+#define FLOAT float
+#define CFLOAT __complex__ float
+#define M_HUGE_VAL HUGE_VALF
+
+/* Standard/GNU macro literals do not exist for the float type.  Use
+   the double macro constants.  */
+#define M_MLIT(c) c
 
-double
-__cimag (double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
 #endif
diff --git a/math/cimag.c b/sysdeps/generic/math-type-macros-ldouble.h
similarity index 65%
copy from math/cimag.c
copy to sysdeps/generic/math-type-macros-ldouble.h
index 1807ac2..35f3cb8 100644
--- a/math/cimag.c
+++ b/sysdeps/generic/math-type-macros-ldouble.h
@@ -1,7 +1,6 @@
-/* Return imaginary part of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Helper macros for long double variants of type generic functions of libm.
+   Copyright (C) 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
@@ -17,15 +16,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
+#ifndef _MATH_TYPE_MACROS_LDOUBLE
+#define _MATH_TYPE_MACROS_LDOUBLE
+
+#define M_PFX LDBL
+#define M_LIT(c) c ## L
+#define M_MLIT(c) c ## l
+#define M_SUF(c) c ## l
+#define FLOAT long double
+#define CFLOAT __complex__ long double
+#define M_HUGE_VAL HUGE_VALL
 
-double
-__cimag (double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
 #endif
diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
new file mode 100644
index 0000000..1451485
--- /dev/null
+++ b/sysdeps/generic/math-type-macros.h
@@ -0,0 +1,116 @@
+/* Helper macros for type generic function implementations within libm.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS
+#define _MATH_TYPE_MACROS
+
+#define M_FLOAT 1
+#define M_DOUBLE 2
+#define M_LDOUBLE 3
+
+/* Each type imports a header which is expected to
+   define:
+
+   M_PFX      - The prefixed used by float.h macros like FLT_MANT_DIG.
+   M_LIT(x)   - Paste the type specific suffix onto the constant x.
+   M_MLIT(x)  - Paste the type specific suffix used by the macro
+		constants in math.h, i.e M_PI or M_PIl.
+   M_SUF(x)   - Paste the the type specific suffix used by functions
+		i.e expf expl exp.
+   FLOAT      - Resolves to the C typename of M_TYPE.
+   CFLOAT     - Resolves to the complex typename of M_TYPE.
+   M_HUGE_VAL - Resolves to the type-specific variant of HUGE_VAL
+
+  Optionally, these headers may inject a non-standard
+  definition for the following:
+
+  declare_mgen_alias(from,to)
+      This exposes the appropriate symbol(s) for a
+      function f of type FLOAT.
+
+  M_LIBM_NEED_COMPAT(func)
+      This is utilized in macro context to indicate
+      whether func should declare compat symbols.
+
+  declare_mgen_libm_compat(from,to)
+      This is used in conjunction with the above macro
+      outside of macro context to paste whatever is
+      required to generate a compat symbol. */
+
+#if M_TYPE == M_FLOAT
+# include <math-type-macros-float.h>
+#elif M_TYPE == M_DOUBLE
+# include <math-type-macros-double.h>
+#elif M_TYPE == M_LDOUBLE
+# include <math-type-macros-ldouble.h>
+#else
+# error Error: M_TYPE is not a known floating point type
+#endif
+
+#define __M_CONCAT(a,b) a ## b
+#define __M_CONCATX(a,b) __M_CONCAT(a,b)
+
+#define M_NAN M_SUF (__nan) ("")
+#define M_MAX_EXP __M_CONCATX (M_PFX, _MAX_EXP)
+#define M_MIN __M_CONCATX (M_PFX, _MIN)
+#define M_MAX __M_CONCATX (M_PFX, _MAX)
+#define M_MANT_DIG __M_CONCATX (M_PFX, _MANT_DIG)
+
+/* Helper macros for commonly used functions.  */
+#define M_COPYSIGN M_SUF (__copysign)
+#define M_FABS M_SUF (fabs)
+#define M_SINCOS M_SUF (__sincos)
+#define M_SCALBN M_SUF (__scalbn)
+#define M_LOG1P M_SUF (__log1p)
+
+#define M_ATAN2 M_SUF (__ieee754_atan2)
+#define M_COSH M_SUF (__ieee754_cosh)
+#define M_EXP M_SUF (__ieee754_exp)
+#define M_HYPOT M_SUF (__ieee754_hypot)
+#define M_LOG M_SUF (__ieee754_log)
+#define M_SINH M_SUF (__ieee754_sinh)
+#define M_SQRT M_SUF (__ieee754_sqrt)
+
+/* Needed to evaluate M_MANT_DIG below.  */
+#include <float.h>
+
+/* Use a special epsilon value for IBM long double
+   to avoid spurious overflows.  */
+#if M_MANT_DIG != 106
+# define M_EPSILON __M_CONCATX (M_PFX, _EPSILON)
+#else
+# define M_EPSILON M_LIT (0x1p-106)
+#endif
+
+/* Enable overloading of function name to assist reuse.  */
+#ifndef M_DECL_FUNC
+# define M_DECL_FUNC(f) M_SUF (f)
+#endif
+
+/* If the type does not declare special aliasing, use the default.  */
+#ifndef declare_mgen_alias
+# define declare_mgen_alias(from, to) weak_alias (M_SUF (from), M_SUF (to))
+#endif
+
+/* Do not generate anything for compat symbols by default.  */
+#ifndef M_LIBM_NEED_COMPAT
+# define M_LIBM_NEED_COMPAT(func) 0
+# define declare_mgen_libm_compat(from, to)
+#endif
+
+#endif /* _MATH_TYPE_MACROS */
diff --git a/sysdeps/ieee754/Makeconfig b/sysdeps/ieee754/Makeconfig
new file mode 100644
index 0000000..15fd238
--- /dev/null
+++ b/sysdeps/ieee754/Makeconfig
@@ -0,0 +1,6 @@
+# Add the rules for generated math files in sysdeps
+# Not the perfect place, but close enough.
+#
+# Each type supported by libm should have a g_%_SUFFIX
+# pattern to match its suffix.
+sysd-rules-patterns += m_%:s_% g_%_f:b_% g_%_l:b_% g_%_:b_%
diff --git a/sysdeps/ieee754/ldbl-opt/cabs.c b/sysdeps/ieee754/ldbl-opt/cabs.c
deleted file mode 100644
index a181de2..0000000
--- a/sysdeps/ieee754/ldbl-opt/cabs.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/cabs.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cabs, cabsl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cabsl.c b/sysdeps/ieee754/ldbl-opt/cabsl.c
deleted file mode 100644
index b861633..0000000
--- a/sysdeps/ieee754/ldbl-opt/cabsl.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/cabsl.c>
-long_double_symbol (libm, __cabsl, cabsl);
diff --git a/sysdeps/ieee754/ldbl-opt/carg.c b/sysdeps/ieee754/ldbl-opt/carg.c
deleted file mode 100644
index 2ed3581..0000000
--- a/sysdeps/ieee754/ldbl-opt/carg.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/carg.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __carg, cargl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cargl.c b/sysdeps/ieee754/ldbl-opt/cargl.c
deleted file mode 100644
index 952dc60..0000000
--- a/sysdeps/ieee754/ldbl-opt/cargl.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/cargl.c>
-long_double_symbol (libm, __cargl, cargl);
diff --git a/sysdeps/ieee754/ldbl-opt/cimag.c b/sysdeps/ieee754/ldbl-opt/cimag.c
deleted file mode 100644
index f805258..0000000
--- a/sysdeps/ieee754/ldbl-opt/cimag.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/cimag.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cimag, cimagl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cimagl.c b/sysdeps/ieee754/ldbl-opt/cimagl.c
deleted file mode 100644
index 112365e..0000000
--- a/sysdeps/ieee754/ldbl-opt/cimagl.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/cimagl.c>
-long_double_symbol (libm, __cimagl, cimagl);
diff --git a/sysdeps/ieee754/ldbl-opt/conj.c b/sysdeps/ieee754/ldbl-opt/conj.c
deleted file mode 100644
index e4edade..0000000
--- a/sysdeps/ieee754/ldbl-opt/conj.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/conj.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __conj, conjl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/conjl.c b/sysdeps/ieee754/ldbl-opt/conjl.c
deleted file mode 100644
index c98e0ed..0000000
--- a/sysdeps/ieee754/ldbl-opt/conjl.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/conjl.c>
-long_double_symbol (libm, __conjl, conjl);
diff --git a/sysdeps/ieee754/ldbl-opt/creal.c b/sysdeps/ieee754/ldbl-opt/creal.c
deleted file mode 100644
index 0d1c93e..0000000
--- a/sysdeps/ieee754/ldbl-opt/creal.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/creal.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __creal, creall, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/creall.c b/sysdeps/ieee754/ldbl-opt/creall.c
deleted file mode 100644
index 68fedd4..0000000
--- a/sysdeps/ieee754/ldbl-opt/creall.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/creall.c>
-long_double_symbol (libm, __creall, creall);
diff --git a/math/cimag.c b/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
similarity index 55%
copy from math/cimag.c
copy to sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
index 1807ac2..e180cc0 100644
--- a/math/cimag.c
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
@@ -1,7 +1,6 @@
-/* Return imaginary part of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Overrides for ldbl-opt versioning for double types.
+   Copyright (C) 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
@@ -17,15 +16,19 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
-
-double
-__cimag (double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
+#ifndef _MATH_TYPE_MACROS_DOUBLE
+
+#include <math_ldbl_opt.h>
+#include <math_ldbl_opt_versions.h>
+
+/* Define compat symbols for long double on platforms
+   where it was not always a distinct type.  */
+#define M_LIBM_NEED_COMPAT(f) \
+  LONG_DOUBLE_COMPAT (libm, LDOUBLE_ ## f ## l_libm_version)
+
+#define declare_mgen_libm_compat(from, to)	      \
+    compat_symbol (libm, from, to ## l,		      \
+		   LDOUBLE_ ## to ## l_libm_version);
+
+#include_next <math-type-macros-double.h>
 #endif
diff --git a/math/cimag.c b/sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
similarity index 61%
rename from math/cimag.c
rename to sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
index 1807ac2..f59d174 100644
--- a/math/cimag.c
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
@@ -1,7 +1,6 @@
-/* Return imaginary part of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Overrides for ldbl-opt versioning for long double types.
+   Copyright (C) 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
@@ -17,15 +16,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
+#ifndef _MATH_TYPE_MACROS_LDOUBLE
 
-double
-__cimag (double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
+#include <math_ldbl_opt.h>
+#include <math_ldbl_opt_versions.h>
+
+/* Use properly versioned symbols for long double on platforms where
+   it was not always a distinct type.  */
+# define declare_mgen_alias(from, to) \
+   long_double_symbol (libm, from ## l, to ## l);
+
+#include_next <math-type-macros-ldouble.h>
 #endif
diff --git a/sysdeps/ieee754/ldbl-opt/math_ldbl_opt_versions.h b/sysdeps/ieee754/ldbl-opt/math_ldbl_opt_versions.h
new file mode 100644
index 0000000..4a059ca
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/math_ldbl_opt_versions.h
@@ -0,0 +1,42 @@
+/* ldbl-opt versioning for generated long double functions.
+   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 LDOUBLE_cabsl_libm_version GLIBC_2_1
+#define LDOUBLE_cargl_libm_version GLIBC_2_1
+#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
+#define LDOUBLE_casinl_libm_version GLIBC_2_1
+#define LDOUBLE_csinl_libm_version GLIBC_2_1
+#define LDOUBLE_casinhl_libm_version GLIBC_2_1
+#define LDOUBLE_csinhl_libm_version GLIBC_2_1
+#define LDOUBLE_catanl_libm_version GLIBC_2_1
+#define LDOUBLE_catanhl_libm_version GLIBC_2_1
+#define LDOUBLE_ctanl_libm_version GLIBC_2_1
+#define LDOUBLE_ctanhl_libm_version GLIBC_2_1
+#define LDOUBLE_cexpl_libm_version GLIBC_2_1
+#define LDOUBLE_clogl_libm_version GLIBC_2_1
+#define LDOUBLE_cprojl_libm_version GLIBC_2_1
+#define LDOUBLE_csqrtl_libm_version GLIBC_2_1
+#define LDOUBLE_cpowl_libm_version GLIBC_2_1
+#define LDOUBLE_clog10l_libm_version GLIBC_2_1
+#define LDOUBLE___clog10l_libm_version GLIBC_2_1
-- 
2.4.11


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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-04  1:49         ` Paul E. Murphy
@ 2016-08-04 16:43           ` Joseph Myers
  2016-08-05 14:43             ` Paul E. Murphy
  2016-08-04 17:03           ` Joseph Myers
  1 sibling, 1 reply; 53+ messages in thread
From: Joseph Myers @ 2016-08-04 16:43 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha, Adhemerval Zanella

On Wed, 3 Aug 2016, Paul E. Murphy wrote:

> +# Add special flags to control how the templated functions
> +# are built.
> +g_CPPFLAGS = -include math-type-macros.h
> +g__fCPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_FLOAT
> +g__CPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_DOUBLE
> +g__lCPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_LDOUBLE

Once you've got a separate header for each type, I wonder if you actually 
need this M_FLOAT etc. enumeration, or if it would be better to -include a 
per-type header (either before -include math-type-macros.h, or a header 
which in turn #includes <math-type-macros.h>) and so avoid M_TYPE, M_FLOAT 
etc.

> +#define CFLOAT __complex__ double

I think _Complex should be preferred over __complex__ for new code 
(existing code is inconsistent).

> +   M_HUGE_VAL - Resolves to the type-specific variant of HUGE_VAL

You could just use (M_SUF (__builtin_huge_val) ()) rather than needing 
type-specific headers to define this macro.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-04  1:49         ` Paul E. Murphy
  2016-08-04 16:43           ` Joseph Myers
@ 2016-08-04 17:03           ` Joseph Myers
  1 sibling, 0 replies; 53+ messages in thread
From: Joseph Myers @ 2016-08-04 17:03 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha, Adhemerval Zanella

On Wed, 3 Aug 2016, Paul E. Murphy wrote:

> I'll spare the list the churn of respinning the dependent patches.  They
> are unchanged except for changing M_FUNC to M_SUF and the moving of the
> ldbl-opt versioning to exclusively this patch.

Note that once a version of this patch has passed review and is in, I'd 
like to see the dependent patches reposted in their latest versions for 
review.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-04 16:43           ` Joseph Myers
@ 2016-08-05 14:43             ` Paul E. Murphy
  2016-08-10 15:54               ` Joseph Myers
  0 siblings, 1 reply; 53+ messages in thread
From: Paul E. Murphy @ 2016-08-05 14:43 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, Adhemerval Zanella

[-- Attachment #1: Type: text/plain, Size: 1756 bytes --]



On 08/04/2016 11:42 AM, Joseph Myers wrote:
> On Wed, 3 Aug 2016, Paul E. Murphy wrote:
> 
>> +# Add special flags to control how the templated functions
>> +# are built.
>> +g_CPPFLAGS = -include math-type-macros.h
>> +g__fCPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_FLOAT
>> +g__CPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_DOUBLE
>> +g__lCPPFLAGS = $(g_CPPFLAGS) -DM_TYPE=M_LDOUBLE
> 
> Once you've got a separate header for each type, I wonder if you actually 
> need this M_FLOAT etc. enumeration, or if it would be better to -include a 
> per-type header (either before -include math-type-macros.h, or a header 
> which in turn #includes <math-type-macros.h>) and so avoid M_TYPE, M_FLOAT 
> etc.

The attached patch directly includes math-type-macros-<type>.h and removes
the M_<TYPE> macros.  Likewise, I've tried improve the math/Makefile
readability.

The only hiccup this caused was a simplification of b_clog10.c in a later
patch.  My original hope was this could be used to remove all ldbl-opt
overrides for generated functions.  Such is not feasible with the
current patches.  This is resolved by overriding and building s_clog10l.c
to maintain symbol and binary compatibility similar to what is done
now.

>> +#define CFLOAT __complex__ double
> 
> I think _Complex should be preferred over __complex__ for new code 
> (existing code is inconsistent).
> 
>> +   M_HUGE_VAL - Resolves to the type-specific variant of HUGE_VAL
> 
> You could just use (M_SUF (__builtin_huge_val) ()) rather than needing 
> type-specific headers to define this macro.
> 

Ok.

As requested earlier, I will hold off submission until we have
consensus on the entire patch series.  Likewise, once we reach
tentative agreement on this, I'll post updates to the remaining
patches.

[-- Attachment #2: 0001-Support-for-type-generic-libm-function-implementatio.patch --]
[-- Type: text/x-patch, Size: 47367 bytes --]

From 34567fc42c53ab6b126d46b5a41520dd34d69180 Mon Sep 17 00:00:00 2001
From: "Paul E. Murphy" <murphyp@linux.vnet.ibm.com>
Date: Tue, 14 Jun 2016 11:44:14 -0500
Subject: [PATCH 1/9] Support for type-generic libm function implementations
 libm

This defines two new classes of libm objects.  g for
generated objects, and b for basic templates to
generate those objects.  The end result should be
much less duplication, and no function changes,
other than potential shuffling of the code within
libm.

As a simple example, the trivial complex functions
are converted to use the new infrastructure.

This uses some makefile hackery to generate g_*
objects from from the base b_*.c.  The intent is to
convert most or all of the complex function wrappers,
possibly even the wrappers for the e functions.

Hooks are added to enable a platform to override a
subset of generated files and replace them with a
platform supplied list of files via the
libm-gen-replacement-calls variable.  This is a
little kludgy as the set of files being moved
to this will likely include both unprefixed and
w_ prefixed files.  The intent is to minimize
awkward file renames.

Likewise, the alias for platforms which previously
didn't have long double support in glibc is handled
for trivial cases.  The more complex cases are left
to be handled individually.

I have verified the built objects for ppc64, x86_64,
alpha, arm, and m68k do not change in any meaningful
way with these changes using the Fedora cross toolchains.
I have verified the x86_64 and ppc64 changes still run.

Verification is done by checking the objdump of
the g_*.{o,os} files with their equivalent s_
object prior to the patch.  Additionally nm is
used to verify the same set of symbols are
exported.

	* math/Makefile: Add support for routines generated
	via a macroed template file.
	(gen-libm-calls): New variable.
	(libm-calls-compat): Likewise.
	(gen-suffixes): Likewise.
	(g__CPPFLAGS): Likewise.
	(g__fCPPFLAGS): Likewise.
	(g__lCPPFLAGS): Likewise.

	* sysdeps/generic/math-type-macros.h: New file.
	* sysdeps/generic/math-type-macros-float.h: Likewise.
	* sysdeps/generic/math-type-macros-double.h: Likewise.
	* sysdeps/generic/math-type-macros-ldouble.h: Likewise.
	* sysdeps/ieee754/ldbl-opt/math-type-macros-double.h: Likewise.
	* sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h: Likewise.

	* math/cabs.c: Refactor into
	* math/b_cabs.c: new file.
	* math/cabsf.c: Removed.
	* math/cabsl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cabsf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cabsl.c: Removed.

	* math/carg.c: Refactor into
	* math/b_carg.c: new file.
	* math/cargf.c: Removed.
	* math/cargl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cargf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cargl.c: Removed.

	* math/conj.c: Refactor into
	* math/b_conj.c: new file.
	* math/conjf.c: Removed.
	* math/conjl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/conjf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/conjl.c: Removed.

	* math/cimag.c: Refactor into
	* math/b_cimag.c: new file.
	* math/cimagf.c: Removed.
	* math/cimagl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.

	* math/cimag.c: Refactor into
	* math/b_cimag.c: new file.
	* math/cimagf.c: Removed.
	* math/cimagl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.

	* sysdeps/ieee754/Makeconfig: New file.
	* Makeconfig: Move m_% sysd pattern rule into above.

	* scripts/sysd-rules.awk: Handle multiple rules
	with same DEP length correctly.
---
 Makeconfig                                         |   2 +-
 math/Makefile                                      |  62 ++++++++++-
 math/{cabs.c => b_cabs.c}                          |  17 +--
 math/{carg.c => b_carg.c}                          |  17 +--
 math/{cimag.c => b_cimag.c}                        |  15 +--
 math/{conj.c => b_conj.c}                          |  15 +--
 math/{creal.c => b_creal.c}                        |  15 +--
 math/cabsf.c                                       |  28 -----
 math/cabsl.c                                       |  28 -----
 math/cargf.c                                       |  28 -----
 math/cargl.c                                       |  28 -----
 math/cimagf.c                                      |  27 -----
 math/cimagl.c                                      |  27 -----
 math/conjf.c                                       |  27 -----
 math/conjl.c                                       |  27 -----
 math/crealf.c                                      |  27 -----
 math/creall.c                                      |  27 -----
 scripts/sysd-rules.awk                             |   5 +-
 sysdeps/alpha/fpu/Makefile                         |   4 +
 sysdeps/generic/math-type-macros-double.h          |  45 ++++++++
 .../generic/math-type-macros-float.h               |  32 +++---
 .../generic/math-type-macros-ldouble.h             |  27 ++---
 sysdeps/generic/math-type-macros.h                 | 121 +++++++++++++++++++++
 sysdeps/ieee754/Makeconfig                         |   6 +
 sysdeps/ieee754/ldbl-opt/cabs.c                    |   6 -
 sysdeps/ieee754/ldbl-opt/cabsl.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/carg.c                    |   6 -
 sysdeps/ieee754/ldbl-opt/cargl.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/cimag.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/cimagl.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/conj.c                    |   6 -
 sysdeps/ieee754/ldbl-opt/conjl.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/creal.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/creall.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/math-type-macros-double.h |  58 ++++++++++
 .../ieee754/ldbl-opt/math-type-macros-ldouble.h    |  24 ++--
 36 files changed, 383 insertions(+), 416 deletions(-)
 rename math/{cabs.c => b_cabs.c} (77%)
 rename math/{carg.c => b_carg.c} (79%)
 copy math/{cimag.c => b_cimag.c} (82%)
 rename math/{conj.c => b_conj.c} (81%)
 rename math/{creal.c => b_creal.c} (82%)
 delete mode 100644 math/cabsf.c
 delete mode 100644 math/cabsl.c
 delete mode 100644 math/cargf.c
 delete mode 100644 math/cargl.c
 delete mode 100644 math/cimagf.c
 delete mode 100644 math/cimagl.c
 delete mode 100644 math/conjf.c
 delete mode 100644 math/conjl.c
 delete mode 100644 math/crealf.c
 delete mode 100644 math/creall.c
 create mode 100644 sysdeps/alpha/fpu/Makefile
 create mode 100644 sysdeps/generic/math-type-macros-double.h
 copy math/cimag.c => sysdeps/generic/math-type-macros-float.h (59%)
 copy math/cimag.c => sysdeps/generic/math-type-macros-ldouble.h (63%)
 create mode 100644 sysdeps/generic/math-type-macros.h
 create mode 100644 sysdeps/ieee754/Makeconfig
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabs.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabsl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/carg.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cargl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimag.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimagl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conj.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conjl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creal.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creall.c
 create mode 100644 sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
 rename math/cimag.c => sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h (63%)

diff --git a/Makeconfig b/Makeconfig
index 03fd89c..8957180 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1125,7 +1125,7 @@ endif
 # emitted into sysd-rules.  A sysdeps Makeconfig fragment can
 # add its own special object file prefix to this list with e.g. foo-%:%
 # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
-sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
+sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:%
 
 # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
 sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
diff --git a/math/Makefile b/math/Makefile
index 925b8d4..01586ff 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -43,6 +43,30 @@ libm-support = s_lib_version s_matherr s_signgam			\
 	       fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt	\
 	       fegetexcept
 
+# These functions are generated from a common source file using a
+# header file math-type-macros-<type>.h to supply implementations
+# for the type-generic macros.  These build from a common file
+# matching the name b_<func>.<source suffix>.
+#
+# Note, there is an explicit underscore between the function name
+# and the type suffix to simplify matching the rule used to build
+# the type specific variant.
+#
+# A platform can override any of these generated functions.
+# Overrides are accounted for after type suffix substitution occurs,
+# by adding a makefile fragment which defines libm-gen-calls-override
+# and libm-gen-replacement-calls for each overriden function.
+#
+# i.e:
+#
+# libm-gen-calls-override += g_cimag_
+# libm-gen-replacement-calls += cimag
+#
+# Would inhibit building the double version of cimag from the the
+# template b_cimag.c, and instead look for a buildable file matching
+# the name cimag.
+gen-libm-calls = g_carg_F g_conj_F g_cimag_F g_creal_F g_cabs_F
+
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
 	e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF	  \
@@ -59,13 +83,13 @@ 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	  \
-	conjF cimagF crealF cabsF cargF s_cexpF s_csinhF s_ccoshF s_clogF \
+	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_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			  \
-	s_nextupF s_nextdownF
+	s_nextupF s_nextdownF $(gen-libm-calls)
 
 libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl
 libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
@@ -105,7 +129,9 @@ type-float-routines :=
 type-foreach = $(foreach t,$(types),$(subst F,$(type-$(t)-suffix),$(1)))
 
 libm-routines = $(strip $(libm-support) $(libm-compat-calls)		\
-			$(call type-foreach, $(libm-calls))		\
+			$(filter-out $(libm-gen-calls-override),	\
+				$(call type-foreach, $(libm-calls)))	\
+			$(libm-gen-replacement-calls)			\
 			$(foreach t, $(types), $(type-$(t)-routines))) 	\
 
 # These functions are in libc instead of libm because __printf_fp
@@ -118,6 +144,9 @@ calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \
 generated += $(foreach s,.c .S,$(call type-foreach, $(calls:s_%=m_%$(s))))
 routines = $(call type-foreach, $(calls))
 
+# Functions built through generic templates declared in gen-libm-calls
+generated += $(foreach s,.c .S,$(call type-foreach,$(gen-libm-calls:%=%$(s))))
+
 ifeq ($(build-mathvec),yes)
 # We need to install libm.so as linker script
 # for more comfortable use of vector math library.
@@ -303,6 +332,33 @@ endef
 object-suffixes-left := $(all-object-suffixes)
 include $(o-iterator)
 
+# Generated per-type files.
+#
+# Suffixes for each generated file.  This hackery makes it possible
+# to correctly identify name of the templated file.
+gen-suffixes := $(foreach s,$(all-object-suffixes), \
+                       $(foreach t,$(types),_$(type-$(t)-suffix)$s))
+
+# Add special flags to control how the templated functions
+# are built.
+g__fCPPFLAGS = -include math-type-macros-float.h
+g__CPPFLAGS = -include math-type-macros-double.h
+g__lCPPFLAGS = -include math-type-macros-ldouble.h
+
+# Like m_% above, this builds the generic sources.  Makeconfig
+# enumerates the sysd-rules for overriding.
+define o-iterator-doit
+$(objpfx)g_%$o: b_%.c $(before-compile); $$(compile-command.c)
+endef
+object-suffixes-left := $(gen-suffixes)
+include $(o-iterator)
+
+# Tack on the appropriate CPPFLAGS to match sysd-rules
+define o-iterator-doit
+$(objpfx)g_%$o: CPPFLAGS += $(g_$(basename $o)CPPFLAGS)
+endef
+object-suffixes-left := $(gen-suffixes)
+include $(o-iterator)
 
 # This file defines the default _LIB_VERSION variable that controls
 # the error return conventions for the math functions.
diff --git a/math/cabs.c b/math/b_cabs.c
similarity index 77%
rename from math/cabs.c
rename to math/b_cabs.c
index d7e0665..5eff1b2 100644
--- a/math/cabs.c
+++ b/math/b_cabs.c
@@ -1,4 +1,4 @@
-/* Return the complex absolute value of double complex value.
+/* Return the complex absolute value 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.
@@ -20,13 +20,14 @@
 #include <complex.h>
 #include <math.h>
 
-double
-__cabs (double _Complex z)
+FLOAT
+M_DECL_FUNC (__cabs) (CFLOAT z)
 {
-  return __hypot (__real__ z, __imag__ z);
+  return M_SUF (__hypot) (__real__ z, __imag__ z);
 }
-weak_alias (__cabs, cabs)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cabs, __cabsl)
-weak_alias (__cabs, cabsl)
+
+declare_mgen_alias (__cabs, cabs)
+
+#if M_LIBM_NEED_COMPAT (cabs)
+declare_mgen_libm_compat (__cabs, cabs)
 #endif
diff --git a/math/carg.c b/math/b_carg.c
similarity index 79%
rename from math/carg.c
rename to math/b_carg.c
index 61f1e0d..6205be8 100644
--- a/math/carg.c
+++ b/math/b_carg.c
@@ -1,4 +1,4 @@
-/* Compute argument of complex double value.
+/* Compute argument 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.
@@ -20,13 +20,14 @@
 #include <complex.h>
 #include <math.h>
 
-double
-__carg (__complex__ double x)
+FLOAT
+M_DECL_FUNC (__carg) (CFLOAT x)
 {
-  return __atan2 (__imag__ x, __real__ x);
+  return M_SUF (__atan2) (__imag__ x, __real__ x);
 }
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
+
+declare_mgen_alias (__carg, carg)
+
+#if M_LIBM_NEED_COMPAT (carg)
+declare_mgen_libm_compat (__carg, carg)
 #endif
diff --git a/math/cimag.c b/math/b_cimag.c
similarity index 82%
copy from math/cimag.c
copy to math/b_cimag.c
index 1807ac2..582147d 100644
--- a/math/cimag.c
+++ b/math/b_cimag.c
@@ -1,4 +1,4 @@
-/* Return imaginary part of complex double value.
+/* Return imaginary part 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double
-__cimag (double _Complex z)
+FLOAT
+M_DECL_FUNC (__cimag) (CFLOAT z)
 {
   return __imag__ z;
 }
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
+
+declare_mgen_alias (__cimag, cimag)
+
+#if M_LIBM_NEED_COMPAT (cimag)
+declare_mgen_libm_compat (__cimag, cimag)
 #endif
diff --git a/math/conj.c b/math/b_conj.c
similarity index 81%
rename from math/conj.c
rename to math/b_conj.c
index d282985..72d1236 100644
--- a/math/conj.c
+++ b/math/b_conj.c
@@ -1,4 +1,4 @@
-/* Return complex conjugate of complex double value.
+/* Return complex conjugate 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double _Complex
-__conj (double _Complex z)
+CFLOAT
+M_DECL_FUNC (__conj) (CFLOAT z)
 {
   return ~z;
 }
-weak_alias (__conj, conj)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__conj, __conjl)
-weak_alias (__conj, conjl)
+
+declare_mgen_alias (__conj, conj)
+
+#if M_LIBM_NEED_COMPAT (conj)
+declare_mgen_libm_compat (__conj, conj)
 #endif
diff --git a/math/creal.c b/math/b_creal.c
similarity index 82%
rename from math/creal.c
rename to math/b_creal.c
index 231d3b0..f840f43 100644
--- a/math/creal.c
+++ b/math/b_creal.c
@@ -1,4 +1,4 @@
-/* Return real part of complex double value.
+/* Return real part 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double
-__creal (double _Complex z)
+FLOAT
+M_DECL_FUNC (__creal) (CFLOAT z)
 {
   return __real__ z;
 }
-weak_alias (__creal, creal)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__creal, __creall)
-weak_alias (__creal, creall)
+
+declare_mgen_alias (__creal, creal)
+
+#if M_LIBM_NEED_COMPAT (creal)
+declare_mgen_libm_compat (__creal, creal)
 #endif
diff --git a/math/cabsf.c b/math/cabsf.c
deleted file mode 100644
index 431a244..0000000
--- a/math/cabsf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-float
-__cabsf (float _Complex z)
-{
-  return __hypotf (__real__ z, __imag__ z);
-}
-weak_alias (__cabsf, cabsf)
diff --git a/math/cabsl.c b/math/cabsl.c
deleted file mode 100644
index d87e3a2..0000000
--- a/math/cabsl.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-long double
-__cabsl (long double _Complex z)
-{
-  return __hypotl (__real__ z, __imag__ z);
-}
-weak_alias (__cabsl, cabsl)
diff --git a/math/cargf.c b/math/cargf.c
deleted file mode 100644
index 620db3e..0000000
--- a/math/cargf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Compute argument 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>
-
-float
-__cargf (__complex__ float x)
-{
-  return __atan2f (__imag__ x, __real__ x);
-}
-weak_alias (__cargf, cargf)
diff --git a/math/cargl.c b/math/cargl.c
deleted file mode 100644
index 31b7292..0000000
--- a/math/cargl.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Compute argument 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>
-
-long double
-__cargl (__complex__ long double x)
-{
-  return __atan2l (__imag__ x, __real__ x);
-}
-weak_alias (__cargl, cargl)
diff --git a/math/cimagf.c b/math/cimagf.c
deleted file mode 100644
index 67c37f4..0000000
--- a/math/cimagf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return imaginary part 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>
-
-float
-__cimagf (float _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimagf, cimagf)
diff --git a/math/cimagl.c b/math/cimagl.c
deleted file mode 100644
index c1d0910..0000000
--- a/math/cimagl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return imaginary part 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>
-
-long double
-__cimagl (long double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimagl, cimagl)
diff --git a/math/conjf.c b/math/conjf.c
deleted file mode 100644
index 3587c94..0000000
--- a/math/conjf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return complex conjugate 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>
-
-float _Complex
-__conjf (float _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conjf, conjf)
diff --git a/math/conjl.c b/math/conjl.c
deleted file mode 100644
index 55bb393..0000000
--- a/math/conjl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return complex conjugate 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>
-
-long double _Complex
-__conjl (long double _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conjl, conjl)
diff --git a/math/crealf.c b/math/crealf.c
deleted file mode 100644
index 5883849..0000000
--- a/math/crealf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return real part 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>
-
-float
-__crealf (float _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__crealf, crealf)
diff --git a/math/creall.c b/math/creall.c
deleted file mode 100644
index 4a31557..0000000
--- a/math/creall.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return real part 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>
-
-long double
-__creall (long double _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__creall, creall)
diff --git a/scripts/sysd-rules.awk b/scripts/sysd-rules.awk
index 69af400..ccf1dff 100644
--- a/scripts/sysd-rules.awk
+++ b/scripts/sysd-rules.awk
@@ -18,6 +18,9 @@ BEGIN {
   # They are no in particular order.  We need to sort them so that
   # the longest TARGET is first, and, among elements with the same
   # TARGET, the longest DEP is first.
+  #
+  # If two TARGETs have the same length DEP, the first TARGET is
+  # always listed first.
   for (i = 1; i <= npatterns; ++i) {
     if (split(patterns[i], td, ":") != 2) {
       msg = "bad sysd-rules-patterns element '" patterns[i] "'";
@@ -25,7 +28,7 @@ BEGIN {
       exit 2;
     }
     target_order = sprintf("%09d", npatterns + 1 - length(td[1]));
-    dep_order = sprintf("%09d", npatterns - length(td[2]));
+    dep_order = sprintf("%09d%03d", npatterns - length(td[2]), i);
     sort_patterns[target_order SUBSEP dep_order] = patterns[i];
   }
   asorti(sort_patterns, map_patterns);
diff --git a/sysdeps/alpha/fpu/Makefile b/sysdeps/alpha/fpu/Makefile
new file mode 100644
index 0000000..afdd620
--- /dev/null
+++ b/sysdeps/alpha/fpu/Makefile
@@ -0,0 +1,4 @@
+# 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
diff --git a/sysdeps/generic/math-type-macros-double.h b/sysdeps/generic/math-type-macros-double.h
new file mode 100644
index 0000000..4149b39
--- /dev/null
+++ b/sysdeps/generic/math-type-macros-double.h
@@ -0,0 +1,45 @@
+/* Helper macros for double variants of type generic functions of libm.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS_DOUBLE
+#define _MATH_TYPE_MACROS_DOUBLE
+
+#define M_LIT(c) c
+#define M_MLIT(c) c
+#define M_PFX DBL
+#define M_SUF(c) c
+#define FLOAT double
+#define CFLOAT _Complex double
+
+/* Machines without a distinct long double type
+   alias long double functions to their double
+   equivalent.  */
+#if defined NO_LONG_DOUBLE
+# define declare_mgen_alias(from, to)	    \
+   weak_alias (from, to)		    \
+   strong_alias (from, from ## l)	    \
+   weak_alias (from, to ## l)
+#else
+# define declare_mgen_alias(from, to)	    \
+   weak_alias (M_SUF (from), M_SUF (to))
+#endif
+
+/* Supply the generic macros.  */
+#include <math-type-macros.h>
+
+#endif
diff --git a/math/cimag.c b/sysdeps/generic/math-type-macros-float.h
similarity index 59%
copy from math/cimag.c
copy to sysdeps/generic/math-type-macros-float.h
index 1807ac2..aab88fd 100644
--- a/math/cimag.c
+++ b/sysdeps/generic/math-type-macros-float.h
@@ -1,7 +1,6 @@
-/* Return imaginary part of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Helper macros for float variants of type generic functions of libm.
+   Copyright (C) 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
@@ -17,15 +16,20 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
-
-double
-__cimag (double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
+#ifndef _MATH_TYPE_MACROS_FLOAT
+#define _MATH_TYPE_MACROS_FLOAT
+
+#define M_LIT(c) c ## f
+#define M_PFX FLT
+#define M_SUF(c) c ## f
+#define FLOAT float
+#define CFLOAT _Complex float
+
+/* Standard/GNU macro literals do not exist for the float type.  Use
+   the double macro constants.  */
+#define M_MLIT(c) c
+
+/* Supply the generic macros.  */
+#include <math-type-macros.h>
+
 #endif
diff --git a/math/cimag.c b/sysdeps/generic/math-type-macros-ldouble.h
similarity index 63%
copy from math/cimag.c
copy to sysdeps/generic/math-type-macros-ldouble.h
index 1807ac2..90773fa 100644
--- a/math/cimag.c
+++ b/sysdeps/generic/math-type-macros-ldouble.h
@@ -1,7 +1,6 @@
-/* Return imaginary part of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Helper macros for long double variants of type generic functions of libm.
+   Copyright (C) 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
@@ -17,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
+#ifndef _MATH_TYPE_MACROS_LDOUBLE
+#define _MATH_TYPE_MACROS_LDOUBLE
+
+#define M_LIT(c) c ## L
+#define M_MLIT(c) c ## l
+#define M_PFX LDBL
+#define M_SUF(c) c ## l
+#define FLOAT long double
+#define CFLOAT _Complex long double
+
+/* Supply the generic macros.  */
+#include <math-type-macros.h>
 
-double
-__cimag (double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
 #endif
diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
new file mode 100644
index 0000000..91394ba
--- /dev/null
+++ b/sysdeps/generic/math-type-macros.h
@@ -0,0 +1,121 @@
+/* Helper macros for type generic function implementations within libm.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS
+#define _MATH_TYPE_MACROS
+
+/* Each type imports a header which is expected to
+   define:
+
+   M_LIT(x)   - Paste the type specific suffix onto the constant x.
+   M_MLIT(x)  - Paste the type specific suffix used by the macro
+		constants in math.h, i.e M_PI or M_PIl.
+   M_PFX      - The prefixed used by float.h macros like FLT_MANT_DIG.
+   M_SUF(x)   - Paste the the type specific suffix used by functions
+		i.e expf expl exp.
+   FLOAT      - Resolves to the C typename of M_TYPE.
+   CFLOAT     - Resolves to the complex typename of M_TYPE.
+
+  Optionally, these headers may inject a non-standard
+  definition for the following:
+
+  declare_mgen_alias(from,to)
+      This exposes the appropriate symbol(s) for a
+      function f of type FLOAT.
+
+  M_LIBM_NEED_COMPAT(func)
+      This is utilized in macro context to indicate
+      whether func should declare compat symbols.
+
+  declare_mgen_libm_compat(from,to)
+      This is used in conjunction with the above macro
+      outside of macro context to paste whatever is
+      required to generate a compat symbol. */
+
+#ifndef M_PFX
+# error "M_PFX must be defined."
+#endif
+#ifndef M_LIT
+# error "M_LIT must be defined."
+#endif
+#ifndef M_MLIT
+# error "M_MLIT must be defined."
+#endif
+#ifndef M_SUF
+# error "M_SUF must be defined."
+#endif
+#ifndef FLOAT
+# error "FLOAT must be defined."
+#endif
+#ifndef CFLOAT
+# error "CFLOAT must be defined."
+#endif
+
+#define __M_CONCAT(a,b) a ## b
+#define __M_CONCATX(a,b) __M_CONCAT(a,b)
+
+#define M_NAN M_SUF (__nan) ("")
+#define M_MAX_EXP __M_CONCATX (M_PFX, _MAX_EXP)
+#define M_MIN __M_CONCATX (M_PFX, _MIN)
+#define M_MAX __M_CONCATX (M_PFX, _MAX)
+#define M_MANT_DIG __M_CONCATX (M_PFX, _MANT_DIG)
+#define M_HUGE_VAL (M_SUF (__builtin_huge_val) ())
+
+/* Helper macros for commonly used functions.  */
+#define M_COPYSIGN M_SUF (__copysign)
+#define M_FABS M_SUF (fabs)
+#define M_SINCOS M_SUF (__sincos)
+#define M_SCALBN M_SUF (__scalbn)
+#define M_LOG1P M_SUF (__log1p)
+
+#define M_ATAN2 M_SUF (__ieee754_atan2)
+#define M_COSH M_SUF (__ieee754_cosh)
+#define M_EXP M_SUF (__ieee754_exp)
+#define M_HYPOT M_SUF (__ieee754_hypot)
+#define M_LOG M_SUF (__ieee754_log)
+#define M_SINH M_SUF (__ieee754_sinh)
+#define M_SQRT M_SUF (__ieee754_sqrt)
+
+/* Needed to evaluate M_MANT_DIG below.  */
+#include <float.h>
+
+/* Use a special epsilon value for IBM long double
+   to avoid spurious overflows.  */
+#if M_MANT_DIG != 106
+# define M_EPSILON __M_CONCATX (M_PFX, _EPSILON)
+#else
+# define M_EPSILON M_LIT (0x1p-106)
+#endif
+
+/* Enable overloading of function name to assist reuse.  */
+#ifndef M_DECL_FUNC
+# define M_DECL_FUNC(f) M_SUF (f)
+#endif
+
+/* If the type does not declare special aliasing, use the default.  */
+#ifndef declare_mgen_alias
+# define declare_mgen_alias(from, to) weak_alias (M_SUF (from), M_SUF (to))
+#endif
+
+/* Do not generate anything for compat symbols by default.  */
+#ifndef M_LIBM_NEED_COMPAT
+# define M_LIBM_NEED_COMPAT(func) 0
+# define declare_mgen_libm_compat(from, to)
+#endif
+
+#endif /* _MATH_TYPE_MACROS */
diff --git a/sysdeps/ieee754/Makeconfig b/sysdeps/ieee754/Makeconfig
new file mode 100644
index 0000000..15fd238
--- /dev/null
+++ b/sysdeps/ieee754/Makeconfig
@@ -0,0 +1,6 @@
+# Add the rules for generated math files in sysdeps
+# Not the perfect place, but close enough.
+#
+# Each type supported by libm should have a g_%_SUFFIX
+# pattern to match its suffix.
+sysd-rules-patterns += m_%:s_% g_%_f:b_% g_%_l:b_% g_%_:b_%
diff --git a/sysdeps/ieee754/ldbl-opt/cabs.c b/sysdeps/ieee754/ldbl-opt/cabs.c
deleted file mode 100644
index a181de2..0000000
--- a/sysdeps/ieee754/ldbl-opt/cabs.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/cabs.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cabs, cabsl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cabsl.c b/sysdeps/ieee754/ldbl-opt/cabsl.c
deleted file mode 100644
index b861633..0000000
--- a/sysdeps/ieee754/ldbl-opt/cabsl.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/cabsl.c>
-long_double_symbol (libm, __cabsl, cabsl);
diff --git a/sysdeps/ieee754/ldbl-opt/carg.c b/sysdeps/ieee754/ldbl-opt/carg.c
deleted file mode 100644
index 2ed3581..0000000
--- a/sysdeps/ieee754/ldbl-opt/carg.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/carg.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __carg, cargl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cargl.c b/sysdeps/ieee754/ldbl-opt/cargl.c
deleted file mode 100644
index 952dc60..0000000
--- a/sysdeps/ieee754/ldbl-opt/cargl.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/cargl.c>
-long_double_symbol (libm, __cargl, cargl);
diff --git a/sysdeps/ieee754/ldbl-opt/cimag.c b/sysdeps/ieee754/ldbl-opt/cimag.c
deleted file mode 100644
index f805258..0000000
--- a/sysdeps/ieee754/ldbl-opt/cimag.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/cimag.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cimag, cimagl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cimagl.c b/sysdeps/ieee754/ldbl-opt/cimagl.c
deleted file mode 100644
index 112365e..0000000
--- a/sysdeps/ieee754/ldbl-opt/cimagl.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/cimagl.c>
-long_double_symbol (libm, __cimagl, cimagl);
diff --git a/sysdeps/ieee754/ldbl-opt/conj.c b/sysdeps/ieee754/ldbl-opt/conj.c
deleted file mode 100644
index e4edade..0000000
--- a/sysdeps/ieee754/ldbl-opt/conj.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/conj.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __conj, conjl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/conjl.c b/sysdeps/ieee754/ldbl-opt/conjl.c
deleted file mode 100644
index c98e0ed..0000000
--- a/sysdeps/ieee754/ldbl-opt/conjl.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/conjl.c>
-long_double_symbol (libm, __conjl, conjl);
diff --git a/sysdeps/ieee754/ldbl-opt/creal.c b/sysdeps/ieee754/ldbl-opt/creal.c
deleted file mode 100644
index 0d1c93e..0000000
--- a/sysdeps/ieee754/ldbl-opt/creal.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/creal.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __creal, creall, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/creall.c b/sysdeps/ieee754/ldbl-opt/creall.c
deleted file mode 100644
index 68fedd4..0000000
--- a/sysdeps/ieee754/ldbl-opt/creall.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/creall.c>
-long_double_symbol (libm, __creall, creall);
diff --git a/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h b/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
new file mode 100644
index 0000000..8cb5694
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
@@ -0,0 +1,58 @@
+/* Overrides for ldbl-opt versioning for double types.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS_DOUBLE
+
+#include <math_ldbl_opt.h>
+
+#define LDOUBLE_cabsl_libm_version GLIBC_2_1
+#define LDOUBLE_cargl_libm_version GLIBC_2_1
+#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
+#define LDOUBLE_casinl_libm_version GLIBC_2_1
+#define LDOUBLE_csinl_libm_version GLIBC_2_1
+#define LDOUBLE_casinhl_libm_version GLIBC_2_1
+#define LDOUBLE_csinhl_libm_version GLIBC_2_1
+#define LDOUBLE_catanl_libm_version GLIBC_2_1
+#define LDOUBLE_catanhl_libm_version GLIBC_2_1
+#define LDOUBLE_ctanl_libm_version GLIBC_2_1
+#define LDOUBLE_ctanhl_libm_version GLIBC_2_1
+#define LDOUBLE_cexpl_libm_version GLIBC_2_1
+#define LDOUBLE_clogl_libm_version GLIBC_2_1
+#define LDOUBLE_cprojl_libm_version GLIBC_2_1
+#define LDOUBLE_csqrtl_libm_version GLIBC_2_1
+#define LDOUBLE_cpowl_libm_version GLIBC_2_1
+#define LDOUBLE_clog10l_libm_version GLIBC_2_1
+#define LDOUBLE___clog10l_libm_version GLIBC_2_1
+
+/* Define compat symbols for long double on platforms
+   where it was not always a distinct type.  */
+#define M_LIBM_NEED_COMPAT(f) \
+  LONG_DOUBLE_COMPAT (libm, LDOUBLE_ ## f ## l_libm_version)
+
+#define declare_mgen_libm_compat(from, to)	      \
+  compat_symbol (libm, from, to ## l,		      \
+		 LDOUBLE_ ## to ## l_libm_version);
+
+#include_next <math-type-macros-double.h>
+#endif
diff --git a/math/cimag.c b/sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
similarity index 63%
rename from math/cimag.c
rename to sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
index 1807ac2..d2af4bb 100644
--- a/math/cimag.c
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
@@ -1,7 +1,6 @@
-/* Return imaginary part of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Overrides for ldbl-opt versioning for long double types.
+   Copyright (C) 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
@@ -17,15 +16,14 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
+#ifndef _MATH_TYPE_MACROS_LDOUBLE
 
-double
-__cimag (double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
+#include <math_ldbl_opt.h>
+
+/* Use properly versioned symbols for long double on platforms where
+   it was not always a distinct type.  */
+#define declare_mgen_alias(from, to) \
+  long_double_symbol (libm, from ## l, to ## l);
+
+#include_next <math-type-macros-ldouble.h>
 #endif
-- 
2.4.11


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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-05 14:43             ` Paul E. Murphy
@ 2016-08-10 15:54               ` Joseph Myers
  2016-08-10 16:31                 ` Paul E. Murphy
  0 siblings, 1 reply; 53+ messages in thread
From: Joseph Myers @ 2016-08-10 15:54 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha, Adhemerval Zanella

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

> +# Functions built through generic templates declared in gen-libm-calls
> +generated += $(foreach s,.c .S,$(call type-foreach,$(gen-libm-calls:%=%$(s))))

I don't see why you need to handle .S here (and so why you need the outer 
foreach at all).  These templates should only generate .c files.

> +/* Use a special epsilon value for IBM long double
> +   to avoid spurious overflows.  */

It's either overflows or underflows (or maybe both) depending on the 
function being built; the comment should reflect this rather than just 
saying overflows.

OK with those fixes unless anyone identifies any other issues within 48 
hours.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-10 15:54               ` Joseph Myers
@ 2016-08-10 16:31                 ` Paul E. Murphy
  2016-08-10 16:40                   ` Joseph Myers
  0 siblings, 1 reply; 53+ messages in thread
From: Paul E. Murphy @ 2016-08-10 16:31 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, Adhemerval Zanella



On 08/10/2016 10:54 AM, Joseph Myers wrote:
> On Fri, 5 Aug 2016, Paul E. Murphy wrote:
> 
>> +# Functions built through generic templates declared in gen-libm-calls
>> +generated += $(foreach s,.c .S,$(call type-foreach,$(gen-libm-calls:%=%$(s))))
> 
> I don't see why you need to handle .S here (and so why you need the outer 
> foreach at all).  These templates should only generate .c files.
> 
>> +/* Use a special epsilon value for IBM long double
>> +   to avoid spurious overflows.  */
> 
> It's either overflows or underflows (or maybe both) depending on the 
> function being built; the comment should reflect this rather than just 
> saying overflows.
> 
> OK with those fixes unless anyone identifies any other issues within 48 
> hours.
> 

Thinking on Carlos' comments regarding tst-wcstod-round, I am wondering if
maybe it wouldn't be better to add an extra make target which instead
generates a .c file based on existing naming conventions. E.g:

	/* This file is generated by 'make regen-libm-templates.  Do not edit.  */
	#include <math-type-macros-${type}>
	#include <${func_unsuffixed}_template.c>

This has the benefit of leaving the existing implicit override mechanism
in place, and no insane makefile hacks.  I would prefer them living in
their own directory maybe math/generated, ensuring they are always included
after sysdep targets.

This target would not run as part of the build process.  It would be invoked
periodically as libm supports new types, or changes are needed.

E.g placing them in math/:

regen-libm-templates:
       for gfunc in $(gen-libm-calls); do \
         gfunc_basefile=$${gfunc/F/}_template.c; \
         for type in $(foreach t,$(all-libm-types),$(t)__$(type-$(t)-suffix)); do \
           func=$${gfunc/F/$${type#*__}}; \
           type=$${type%__*}; \
           echo "/* This file is generated by 'make regen-libm-templates." >> $${func}.c; \
           echo "   Do not edit.  */" >> $${func}.c; \
           echo "#include <math-type-macros-${type}.h>" >> $${func}.c; \
           echo "#include \"$${gfunc_basefile}\"" >> $${func}.c; \
         done; \
       done;

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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-10 16:31                 ` Paul E. Murphy
@ 2016-08-10 16:40                   ` Joseph Myers
  2016-08-10 21:50                     ` Paul E. Murphy
  0 siblings, 1 reply; 53+ messages in thread
From: Joseph Myers @ 2016-08-10 16:40 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha, Adhemerval Zanella

On Wed, 10 Aug 2016, Paul E. Murphy wrote:

> Thinking on Carlos' comments regarding tst-wcstod-round, I am wondering if
> maybe it wouldn't be better to add an extra make target which instead
> generates a .c file based on existing naming conventions. E.g:
> 
> 	/* This file is generated by 'make regen-libm-templates.  Do not edit.  */
> 	#include <math-type-macros-${type}>
> 	#include <${func_unsuffixed}_template.c>
> 
> This has the benefit of leaving the existing implicit override mechanism
> in place, and no insane makefile hacks.  I would prefer them living in
> their own directory maybe math/generated, ensuring they are always included
> after sysdep targets.
> 
> This target would not run as part of the build process.  It would be invoked
> periodically as libm supports new types, or changes are needed.

Files with an explicit #include are fine as an alternative to generating 
special -include options.  But if you're generating them from the glibc 
build system, it would be better to generate them in the build directory 
rather than checking them in.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-10 16:40                   ` Joseph Myers
@ 2016-08-10 21:50                     ` Paul E. Murphy
  2016-08-10 22:06                       ` Joseph Myers
  0 siblings, 1 reply; 53+ messages in thread
From: Paul E. Murphy @ 2016-08-10 21:50 UTC (permalink / raw)
  To: libc-alpha; +Cc: Joseph Myers, Adhemerval Zanella

[-- Attachment #1: Type: text/plain, Size: 1901 bytes --]



On 08/10/2016 11:39 AM, Joseph Myers wrote:
> On Wed, 10 Aug 2016, Paul E. Murphy wrote:
> 
>> Thinking on Carlos' comments regarding tst-wcstod-round, I am wondering if
>> maybe it wouldn't be better to add an extra make target which instead
>> generates a .c file based on existing naming conventions. E.g:
>>
>> 	/* This file is generated by 'make regen-libm-templates.  Do not edit.  */
>> 	#include <math-type-macros-${type}>
>> 	#include <${func_unsuffixed}_template.c>
>>
>> This has the benefit of leaving the existing implicit override mechanism
>> in place, and no insane makefile hacks.  I would prefer them living in
>> their own directory maybe math/generated, ensuring they are always included
>> after sysdep targets.
>>
>> This target would not run as part of the build process.  It would be invoked
>> periodically as libm supports new types, or changes are needed.
> 
> Files with an explicit #include are fine as an alternative to generating 
> special -include options.  But if you're generating them from the glibc 
> build system, it would be better to generate them in the build directory 
> rather than checking them in.
> 

Ok, here is a patch which does all of the above.  I like this approach
much better than the previous patches.  This approach is much more
inline with the existing idioms, much easier to understand, and more
robust.

Likewise, I've passed these through same set of toolchains to verify
no changes to code generation.  I am currently running the individual
patches to verify no intermittent breakage between the patches after
this round of refactoring.

Notable changes from the last patch:

* Rename b_*.c files to *_template.c.
* Don't muck names in gen-libm-calls.
* Create a rule to generate a stub file to include
  the appropriate math-type-macros-TYPE.h and
  FUNC_template.c in the build directory.
* Remove now unnecessary override variables.

[-- Attachment #2: 0001-Support-for-type-generic-libm-function-implementatio.patch --]
[-- Type: text/x-patch, Size: 42037 bytes --]

From cc300144c8c6a42b8a659ce7ff4bfef7009aca93 Mon Sep 17 00:00:00 2001
From: "Paul E. Murphy" <murphyp@linux.vnet.ibm.com>
Date: Tue, 14 Jun 2016 11:44:14 -0500
Subject: [PATCH 1/9] Support for type-generic libm function implementations
 libm

This defines a new classes of libm objects.  The
<func>_template.c file which is used in conjunction
with the new makefile hooks to derive variants for
each type supported by the target machine.

The headers math-type-macros-TYPE.h are used to supply
macros to a common implementation of a function in
a file named FUNC_template.c and glued togethor via
a generated file matching existing naming in the
build directory.

This has the properties of preserving the existing
override mechanism and not requiring any arcane
build system twiddling.  Likewise, it enables machines
to override these files without any additional work.

I have verified the built objects for ppc64, x86_64,
alpha, arm, and m68k do not change in any meaningful
way with these changes using the Fedora cross toolchains.
I have verified the x86_64 and ppc64 changes still run.

	* math/Makefile: (gen-libm-templates.stmp): New rule.
	(libm-calls): Move carg conj cimag and cabs into ...
	(gen-libm-calls): New variable.

	* sysdeps/generic/math-type-macros.h: New file.
	* sysdeps/generic/math-type-macros-float.h: Likewise.
	* sysdeps/generic/math-type-macros-double.h: Likewise.
	* sysdeps/generic/math-type-macros-ldouble.h: Likewise.
	* sysdeps/ieee754/ldbl-opt/math-type-macros-double.h: Likewise.
	* sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h: Likewise.

	* math/cabs.c: Refactor into
	* math/cabs_template.c: new file.
	* math/cabsf.c: Removed.
	* math/cabsl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cabsf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cabsl.c: Removed.

	* math/carg.c: Refactor into
	* math/carg_template.c: new file.
	* math/cargf.c: Removed.
	* math/cargl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cargf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cargl.c: Removed.

	* math/conj.c: Refactor into
	* math/conj_template.c: new file.
	* math/conjf.c: Removed.
	* math/conjl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/conjf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/conjl.c: Removed.

	* math/cimag.c: Refactor into
	* math/cimag_template.c: new file.
	* math/cimagf.c: Removed.
	* math/cimagl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.

	* math/cimag.c: Refactor into
	* math/cimag_template.c: new file.
	* math/cimagf.c: Removed.
	* math/cimagl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.
---
 math/Makefile                                      |  30 ++++-
 math/{cabs.c => cabs_template.c}                   |  17 +--
 math/cabsf.c                                       |  28 -----
 math/cabsl.c                                       |  28 -----
 math/{carg.c => carg_template.c}                   |  17 +--
 math/cargf.c                                       |  28 -----
 math/cargl.c                                       |  28 -----
 math/{cimag.c => cimag_template.c}                 |  15 +--
 math/cimagf.c                                      |  27 -----
 math/cimagl.c                                      |  27 -----
 math/{conj.c => conj_template.c}                   |  15 +--
 math/conjf.c                                       |  27 -----
 math/conjl.c                                       |  27 -----
 math/{creal.c => creal_template.c}                 |  15 +--
 math/crealf.c                                      |  27 -----
 math/creall.c                                      |  27 -----
 sysdeps/generic/math-type-macros-double.h          |  45 ++++++++
 .../generic/math-type-macros-float.h               |  33 +++---
 .../generic/math-type-macros-ldouble.h             |  28 ++---
 sysdeps/generic/math-type-macros.h                 | 121 +++++++++++++++++++++
 sysdeps/ieee754/ldbl-opt/cabs.c                    |   6 -
 sysdeps/ieee754/ldbl-opt/cabsl.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/carg.c                    |   6 -
 sysdeps/ieee754/ldbl-opt/cargl.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/cimag.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/cimagl.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/conj.c                    |   6 -
 sysdeps/ieee754/ldbl-opt/conjl.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/creal.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/creall.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/math-type-macros-double.h |  58 ++++++++++
 .../ieee754/ldbl-opt/math-type-macros-ldouble.h    |  25 ++---
 32 files changed, 337 insertions(+), 416 deletions(-)
 rename math/{cabs.c => cabs_template.c} (77%)
 delete mode 100644 math/cabsf.c
 delete mode 100644 math/cabsl.c
 copy math/{carg.c => carg_template.c} (79%)
 delete mode 100644 math/cargf.c
 delete mode 100644 math/cargl.c
 rename math/{cimag.c => cimag_template.c} (82%)
 delete mode 100644 math/cimagf.c
 delete mode 100644 math/cimagl.c
 rename math/{conj.c => conj_template.c} (81%)
 delete mode 100644 math/conjf.c
 delete mode 100644 math/conjl.c
 rename math/{creal.c => creal_template.c} (82%)
 delete mode 100644 math/crealf.c
 delete mode 100644 math/creall.c
 create mode 100644 sysdeps/generic/math-type-macros-double.h
 copy math/carg.c => sysdeps/generic/math-type-macros-float.h (59%)
 copy math/carg.c => sysdeps/generic/math-type-macros-ldouble.h (63%)
 create mode 100644 sysdeps/generic/math-type-macros.h
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabs.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabsl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/carg.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cargl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimag.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimagl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conj.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conjl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creal.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creall.c
 create mode 100644 sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
 rename math/carg.c => sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h (63%)

diff --git a/math/Makefile b/math/Makefile
index 925b8d4..21754db 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -43,6 +43,10 @@ libm-support = s_lib_version s_matherr s_signgam			\
 	       fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt	\
 	       fegetexcept
 
+# 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
+
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
 	e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF	  \
@@ -59,13 +63,13 @@ 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	  \
-	conjF cimagF crealF cabsF cargF s_cexpF s_csinhF s_ccoshF s_clogF \
+	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_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			  \
-	s_nextupF s_nextdownF
+	s_nextupF s_nextdownF $(gen-libm-calls)
 
 libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl
 libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
@@ -264,6 +268,28 @@ extra-objs += libieee.a ieee-math.o
 
 include ../Rules
 
+generated += $(addsuffix .c,$(call type-foreach,$(gen-libm-calls:%=%$(s)))) \
+	     gen-libm-templates.stmp
+
+# Create wrappers in the math build directory.
+$(objpfx)gen-libm-templates.stmp:
+	for gfunc in $(gen-libm-calls); do 				  \
+	  gfunc_basefile=$${gfunc/F/}_template.c;			  \
+	  for type in $(foreach t,$(types),$(t)__$(type-$(t)-suffix)); do \
+	    func=$(objpfx)$${gfunc/F/$${type#*__}};			  \
+	    type=$${type%__*};						  \
+	    (								  \
+	      echo "#include <math-type-macros-$${type}.h>";		  \
+	      echo "#include <$${gfunc_basefile}>";			  \
+	    ) > $${func}.c;						  \
+	  done;								  \
+	done;								  \
+	echo > $(@)
+
+# Add dependency to ensure the generator runs prior.
+$(foreach t, $(call type-foreach, $(gen-libm-calls)), \
+             $(objpfx)$(t).c): $(objpfx)gen-libm-templates.stmp
+
 ifneq (no,$(PERL))
 # This must come after the inclusion of sysdeps Makefiles via Rules.
 $(addprefix $(objpfx), $(libm-tests.o)): $(objpfx)libm-test.stmp
diff --git a/math/cabs.c b/math/cabs_template.c
similarity index 77%
rename from math/cabs.c
rename to math/cabs_template.c
index d7e0665..5eff1b2 100644
--- a/math/cabs.c
+++ b/math/cabs_template.c
@@ -1,4 +1,4 @@
-/* Return the complex absolute value of double complex value.
+/* Return the complex absolute value 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.
@@ -20,13 +20,14 @@
 #include <complex.h>
 #include <math.h>
 
-double
-__cabs (double _Complex z)
+FLOAT
+M_DECL_FUNC (__cabs) (CFLOAT z)
 {
-  return __hypot (__real__ z, __imag__ z);
+  return M_SUF (__hypot) (__real__ z, __imag__ z);
 }
-weak_alias (__cabs, cabs)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cabs, __cabsl)
-weak_alias (__cabs, cabsl)
+
+declare_mgen_alias (__cabs, cabs)
+
+#if M_LIBM_NEED_COMPAT (cabs)
+declare_mgen_libm_compat (__cabs, cabs)
 #endif
diff --git a/math/cabsf.c b/math/cabsf.c
deleted file mode 100644
index 431a244..0000000
--- a/math/cabsf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-float
-__cabsf (float _Complex z)
-{
-  return __hypotf (__real__ z, __imag__ z);
-}
-weak_alias (__cabsf, cabsf)
diff --git a/math/cabsl.c b/math/cabsl.c
deleted file mode 100644
index d87e3a2..0000000
--- a/math/cabsl.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-long double
-__cabsl (long double _Complex z)
-{
-  return __hypotl (__real__ z, __imag__ z);
-}
-weak_alias (__cabsl, cabsl)
diff --git a/math/carg.c b/math/carg_template.c
similarity index 79%
copy from math/carg.c
copy to math/carg_template.c
index 61f1e0d..6205be8 100644
--- a/math/carg.c
+++ b/math/carg_template.c
@@ -1,4 +1,4 @@
-/* Compute argument of complex double value.
+/* Compute argument 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.
@@ -20,13 +20,14 @@
 #include <complex.h>
 #include <math.h>
 
-double
-__carg (__complex__ double x)
+FLOAT
+M_DECL_FUNC (__carg) (CFLOAT x)
 {
-  return __atan2 (__imag__ x, __real__ x);
+  return M_SUF (__atan2) (__imag__ x, __real__ x);
 }
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
+
+declare_mgen_alias (__carg, carg)
+
+#if M_LIBM_NEED_COMPAT (carg)
+declare_mgen_libm_compat (__carg, carg)
 #endif
diff --git a/math/cargf.c b/math/cargf.c
deleted file mode 100644
index 620db3e..0000000
--- a/math/cargf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Compute argument 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>
-
-float
-__cargf (__complex__ float x)
-{
-  return __atan2f (__imag__ x, __real__ x);
-}
-weak_alias (__cargf, cargf)
diff --git a/math/cargl.c b/math/cargl.c
deleted file mode 100644
index 31b7292..0000000
--- a/math/cargl.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Compute argument 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>
-
-long double
-__cargl (__complex__ long double x)
-{
-  return __atan2l (__imag__ x, __real__ x);
-}
-weak_alias (__cargl, cargl)
diff --git a/math/cimag.c b/math/cimag_template.c
similarity index 82%
rename from math/cimag.c
rename to math/cimag_template.c
index 1807ac2..582147d 100644
--- a/math/cimag.c
+++ b/math/cimag_template.c
@@ -1,4 +1,4 @@
-/* Return imaginary part of complex double value.
+/* Return imaginary part 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double
-__cimag (double _Complex z)
+FLOAT
+M_DECL_FUNC (__cimag) (CFLOAT z)
 {
   return __imag__ z;
 }
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
+
+declare_mgen_alias (__cimag, cimag)
+
+#if M_LIBM_NEED_COMPAT (cimag)
+declare_mgen_libm_compat (__cimag, cimag)
 #endif
diff --git a/math/cimagf.c b/math/cimagf.c
deleted file mode 100644
index 67c37f4..0000000
--- a/math/cimagf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return imaginary part 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>
-
-float
-__cimagf (float _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimagf, cimagf)
diff --git a/math/cimagl.c b/math/cimagl.c
deleted file mode 100644
index c1d0910..0000000
--- a/math/cimagl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return imaginary part 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>
-
-long double
-__cimagl (long double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimagl, cimagl)
diff --git a/math/conj.c b/math/conj_template.c
similarity index 81%
rename from math/conj.c
rename to math/conj_template.c
index d282985..72d1236 100644
--- a/math/conj.c
+++ b/math/conj_template.c
@@ -1,4 +1,4 @@
-/* Return complex conjugate of complex double value.
+/* Return complex conjugate 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double _Complex
-__conj (double _Complex z)
+CFLOAT
+M_DECL_FUNC (__conj) (CFLOAT z)
 {
   return ~z;
 }
-weak_alias (__conj, conj)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__conj, __conjl)
-weak_alias (__conj, conjl)
+
+declare_mgen_alias (__conj, conj)
+
+#if M_LIBM_NEED_COMPAT (conj)
+declare_mgen_libm_compat (__conj, conj)
 #endif
diff --git a/math/conjf.c b/math/conjf.c
deleted file mode 100644
index 3587c94..0000000
--- a/math/conjf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return complex conjugate 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>
-
-float _Complex
-__conjf (float _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conjf, conjf)
diff --git a/math/conjl.c b/math/conjl.c
deleted file mode 100644
index 55bb393..0000000
--- a/math/conjl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return complex conjugate 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>
-
-long double _Complex
-__conjl (long double _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conjl, conjl)
diff --git a/math/creal.c b/math/creal_template.c
similarity index 82%
rename from math/creal.c
rename to math/creal_template.c
index 231d3b0..f840f43 100644
--- a/math/creal.c
+++ b/math/creal_template.c
@@ -1,4 +1,4 @@
-/* Return real part of complex double value.
+/* Return real part 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double
-__creal (double _Complex z)
+FLOAT
+M_DECL_FUNC (__creal) (CFLOAT z)
 {
   return __real__ z;
 }
-weak_alias (__creal, creal)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__creal, __creall)
-weak_alias (__creal, creall)
+
+declare_mgen_alias (__creal, creal)
+
+#if M_LIBM_NEED_COMPAT (creal)
+declare_mgen_libm_compat (__creal, creal)
 #endif
diff --git a/math/crealf.c b/math/crealf.c
deleted file mode 100644
index 5883849..0000000
--- a/math/crealf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return real part 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>
-
-float
-__crealf (float _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__crealf, crealf)
diff --git a/math/creall.c b/math/creall.c
deleted file mode 100644
index 4a31557..0000000
--- a/math/creall.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return real part 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>
-
-long double
-__creall (long double _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__creall, creall)
diff --git a/sysdeps/generic/math-type-macros-double.h b/sysdeps/generic/math-type-macros-double.h
new file mode 100644
index 0000000..4149b39
--- /dev/null
+++ b/sysdeps/generic/math-type-macros-double.h
@@ -0,0 +1,45 @@
+/* Helper macros for double variants of type generic functions of libm.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS_DOUBLE
+#define _MATH_TYPE_MACROS_DOUBLE
+
+#define M_LIT(c) c
+#define M_MLIT(c) c
+#define M_PFX DBL
+#define M_SUF(c) c
+#define FLOAT double
+#define CFLOAT _Complex double
+
+/* Machines without a distinct long double type
+   alias long double functions to their double
+   equivalent.  */
+#if defined NO_LONG_DOUBLE
+# define declare_mgen_alias(from, to)	    \
+   weak_alias (from, to)		    \
+   strong_alias (from, from ## l)	    \
+   weak_alias (from, to ## l)
+#else
+# define declare_mgen_alias(from, to)	    \
+   weak_alias (M_SUF (from), M_SUF (to))
+#endif
+
+/* Supply the generic macros.  */
+#include <math-type-macros.h>
+
+#endif
diff --git a/math/carg.c b/sysdeps/generic/math-type-macros-float.h
similarity index 59%
copy from math/carg.c
copy to sysdeps/generic/math-type-macros-float.h
index 61f1e0d..aab88fd 100644
--- a/math/carg.c
+++ b/sysdeps/generic/math-type-macros-float.h
@@ -1,7 +1,6 @@
-/* Compute argument of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Helper macros for float variants of type generic functions of libm.
+   Copyright (C) 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
@@ -17,16 +16,20 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
-#include <math.h>
-
-double
-__carg (__complex__ double x)
-{
-  return __atan2 (__imag__ x, __real__ x);
-}
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
+#ifndef _MATH_TYPE_MACROS_FLOAT
+#define _MATH_TYPE_MACROS_FLOAT
+
+#define M_LIT(c) c ## f
+#define M_PFX FLT
+#define M_SUF(c) c ## f
+#define FLOAT float
+#define CFLOAT _Complex float
+
+/* Standard/GNU macro literals do not exist for the float type.  Use
+   the double macro constants.  */
+#define M_MLIT(c) c
+
+/* Supply the generic macros.  */
+#include <math-type-macros.h>
+
 #endif
diff --git a/math/carg.c b/sysdeps/generic/math-type-macros-ldouble.h
similarity index 63%
copy from math/carg.c
copy to sysdeps/generic/math-type-macros-ldouble.h
index 61f1e0d..90773fa 100644
--- a/math/carg.c
+++ b/sysdeps/generic/math-type-macros-ldouble.h
@@ -1,7 +1,6 @@
-/* Compute argument of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Helper macros for long double variants of type generic functions of libm.
+   Copyright (C) 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
@@ -17,16 +16,17 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
-#include <math.h>
+#ifndef _MATH_TYPE_MACROS_LDOUBLE
+#define _MATH_TYPE_MACROS_LDOUBLE
+
+#define M_LIT(c) c ## L
+#define M_MLIT(c) c ## l
+#define M_PFX LDBL
+#define M_SUF(c) c ## l
+#define FLOAT long double
+#define CFLOAT _Complex long double
+
+/* Supply the generic macros.  */
+#include <math-type-macros.h>
 
-double
-__carg (__complex__ double x)
-{
-  return __atan2 (__imag__ x, __real__ x);
-}
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
 #endif
diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
new file mode 100644
index 0000000..91394ba
--- /dev/null
+++ b/sysdeps/generic/math-type-macros.h
@@ -0,0 +1,121 @@
+/* Helper macros for type generic function implementations within libm.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS
+#define _MATH_TYPE_MACROS
+
+/* Each type imports a header which is expected to
+   define:
+
+   M_LIT(x)   - Paste the type specific suffix onto the constant x.
+   M_MLIT(x)  - Paste the type specific suffix used by the macro
+		constants in math.h, i.e M_PI or M_PIl.
+   M_PFX      - The prefixed used by float.h macros like FLT_MANT_DIG.
+   M_SUF(x)   - Paste the the type specific suffix used by functions
+		i.e expf expl exp.
+   FLOAT      - Resolves to the C typename of M_TYPE.
+   CFLOAT     - Resolves to the complex typename of M_TYPE.
+
+  Optionally, these headers may inject a non-standard
+  definition for the following:
+
+  declare_mgen_alias(from,to)
+      This exposes the appropriate symbol(s) for a
+      function f of type FLOAT.
+
+  M_LIBM_NEED_COMPAT(func)
+      This is utilized in macro context to indicate
+      whether func should declare compat symbols.
+
+  declare_mgen_libm_compat(from,to)
+      This is used in conjunction with the above macro
+      outside of macro context to paste whatever is
+      required to generate a compat symbol. */
+
+#ifndef M_PFX
+# error "M_PFX must be defined."
+#endif
+#ifndef M_LIT
+# error "M_LIT must be defined."
+#endif
+#ifndef M_MLIT
+# error "M_MLIT must be defined."
+#endif
+#ifndef M_SUF
+# error "M_SUF must be defined."
+#endif
+#ifndef FLOAT
+# error "FLOAT must be defined."
+#endif
+#ifndef CFLOAT
+# error "CFLOAT must be defined."
+#endif
+
+#define __M_CONCAT(a,b) a ## b
+#define __M_CONCATX(a,b) __M_CONCAT(a,b)
+
+#define M_NAN M_SUF (__nan) ("")
+#define M_MAX_EXP __M_CONCATX (M_PFX, _MAX_EXP)
+#define M_MIN __M_CONCATX (M_PFX, _MIN)
+#define M_MAX __M_CONCATX (M_PFX, _MAX)
+#define M_MANT_DIG __M_CONCATX (M_PFX, _MANT_DIG)
+#define M_HUGE_VAL (M_SUF (__builtin_huge_val) ())
+
+/* Helper macros for commonly used functions.  */
+#define M_COPYSIGN M_SUF (__copysign)
+#define M_FABS M_SUF (fabs)
+#define M_SINCOS M_SUF (__sincos)
+#define M_SCALBN M_SUF (__scalbn)
+#define M_LOG1P M_SUF (__log1p)
+
+#define M_ATAN2 M_SUF (__ieee754_atan2)
+#define M_COSH M_SUF (__ieee754_cosh)
+#define M_EXP M_SUF (__ieee754_exp)
+#define M_HYPOT M_SUF (__ieee754_hypot)
+#define M_LOG M_SUF (__ieee754_log)
+#define M_SINH M_SUF (__ieee754_sinh)
+#define M_SQRT M_SUF (__ieee754_sqrt)
+
+/* Needed to evaluate M_MANT_DIG below.  */
+#include <float.h>
+
+/* Use a special epsilon value for IBM long double
+   to avoid spurious overflows.  */
+#if M_MANT_DIG != 106
+# define M_EPSILON __M_CONCATX (M_PFX, _EPSILON)
+#else
+# define M_EPSILON M_LIT (0x1p-106)
+#endif
+
+/* Enable overloading of function name to assist reuse.  */
+#ifndef M_DECL_FUNC
+# define M_DECL_FUNC(f) M_SUF (f)
+#endif
+
+/* If the type does not declare special aliasing, use the default.  */
+#ifndef declare_mgen_alias
+# define declare_mgen_alias(from, to) weak_alias (M_SUF (from), M_SUF (to))
+#endif
+
+/* Do not generate anything for compat symbols by default.  */
+#ifndef M_LIBM_NEED_COMPAT
+# define M_LIBM_NEED_COMPAT(func) 0
+# define declare_mgen_libm_compat(from, to)
+#endif
+
+#endif /* _MATH_TYPE_MACROS */
diff --git a/sysdeps/ieee754/ldbl-opt/cabs.c b/sysdeps/ieee754/ldbl-opt/cabs.c
deleted file mode 100644
index a181de2..0000000
--- a/sysdeps/ieee754/ldbl-opt/cabs.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/cabs.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cabs, cabsl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cabsl.c b/sysdeps/ieee754/ldbl-opt/cabsl.c
deleted file mode 100644
index b861633..0000000
--- a/sysdeps/ieee754/ldbl-opt/cabsl.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/cabsl.c>
-long_double_symbol (libm, __cabsl, cabsl);
diff --git a/sysdeps/ieee754/ldbl-opt/carg.c b/sysdeps/ieee754/ldbl-opt/carg.c
deleted file mode 100644
index 2ed3581..0000000
--- a/sysdeps/ieee754/ldbl-opt/carg.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/carg.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __carg, cargl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cargl.c b/sysdeps/ieee754/ldbl-opt/cargl.c
deleted file mode 100644
index 952dc60..0000000
--- a/sysdeps/ieee754/ldbl-opt/cargl.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/cargl.c>
-long_double_symbol (libm, __cargl, cargl);
diff --git a/sysdeps/ieee754/ldbl-opt/cimag.c b/sysdeps/ieee754/ldbl-opt/cimag.c
deleted file mode 100644
index f805258..0000000
--- a/sysdeps/ieee754/ldbl-opt/cimag.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/cimag.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cimag, cimagl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cimagl.c b/sysdeps/ieee754/ldbl-opt/cimagl.c
deleted file mode 100644
index 112365e..0000000
--- a/sysdeps/ieee754/ldbl-opt/cimagl.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/cimagl.c>
-long_double_symbol (libm, __cimagl, cimagl);
diff --git a/sysdeps/ieee754/ldbl-opt/conj.c b/sysdeps/ieee754/ldbl-opt/conj.c
deleted file mode 100644
index e4edade..0000000
--- a/sysdeps/ieee754/ldbl-opt/conj.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/conj.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __conj, conjl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/conjl.c b/sysdeps/ieee754/ldbl-opt/conjl.c
deleted file mode 100644
index c98e0ed..0000000
--- a/sysdeps/ieee754/ldbl-opt/conjl.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/conjl.c>
-long_double_symbol (libm, __conjl, conjl);
diff --git a/sysdeps/ieee754/ldbl-opt/creal.c b/sysdeps/ieee754/ldbl-opt/creal.c
deleted file mode 100644
index 0d1c93e..0000000
--- a/sysdeps/ieee754/ldbl-opt/creal.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/creal.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __creal, creall, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/creall.c b/sysdeps/ieee754/ldbl-opt/creall.c
deleted file mode 100644
index 68fedd4..0000000
--- a/sysdeps/ieee754/ldbl-opt/creall.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/creall.c>
-long_double_symbol (libm, __creall, creall);
diff --git a/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h b/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
new file mode 100644
index 0000000..8cb5694
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
@@ -0,0 +1,58 @@
+/* Overrides for ldbl-opt versioning for double types.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS_DOUBLE
+
+#include <math_ldbl_opt.h>
+
+#define LDOUBLE_cabsl_libm_version GLIBC_2_1
+#define LDOUBLE_cargl_libm_version GLIBC_2_1
+#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
+#define LDOUBLE_casinl_libm_version GLIBC_2_1
+#define LDOUBLE_csinl_libm_version GLIBC_2_1
+#define LDOUBLE_casinhl_libm_version GLIBC_2_1
+#define LDOUBLE_csinhl_libm_version GLIBC_2_1
+#define LDOUBLE_catanl_libm_version GLIBC_2_1
+#define LDOUBLE_catanhl_libm_version GLIBC_2_1
+#define LDOUBLE_ctanl_libm_version GLIBC_2_1
+#define LDOUBLE_ctanhl_libm_version GLIBC_2_1
+#define LDOUBLE_cexpl_libm_version GLIBC_2_1
+#define LDOUBLE_clogl_libm_version GLIBC_2_1
+#define LDOUBLE_cprojl_libm_version GLIBC_2_1
+#define LDOUBLE_csqrtl_libm_version GLIBC_2_1
+#define LDOUBLE_cpowl_libm_version GLIBC_2_1
+#define LDOUBLE_clog10l_libm_version GLIBC_2_1
+#define LDOUBLE___clog10l_libm_version GLIBC_2_1
+
+/* Define compat symbols for long double on platforms
+   where it was not always a distinct type.  */
+#define M_LIBM_NEED_COMPAT(f) \
+  LONG_DOUBLE_COMPAT (libm, LDOUBLE_ ## f ## l_libm_version)
+
+#define declare_mgen_libm_compat(from, to)	      \
+  compat_symbol (libm, from, to ## l,		      \
+		 LDOUBLE_ ## to ## l_libm_version);
+
+#include_next <math-type-macros-double.h>
+#endif
diff --git a/math/carg.c b/sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
similarity index 63%
rename from math/carg.c
rename to sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
index 61f1e0d..d2af4bb 100644
--- a/math/carg.c
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
@@ -1,7 +1,6 @@
-/* Compute argument of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Overrides for ldbl-opt versioning for long double types.
+   Copyright (C) 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
@@ -17,16 +16,14 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
-#include <math.h>
+#ifndef _MATH_TYPE_MACROS_LDOUBLE
 
-double
-__carg (__complex__ double x)
-{
-  return __atan2 (__imag__ x, __real__ x);
-}
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
+#include <math_ldbl_opt.h>
+
+/* Use properly versioned symbols for long double on platforms where
+   it was not always a distinct type.  */
+#define declare_mgen_alias(from, to) \
+  long_double_symbol (libm, from ## l, to ## l);
+
+#include_next <math-type-macros-ldouble.h>
 #endif
-- 
2.4.11


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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-10 21:50                     ` Paul E. Murphy
@ 2016-08-10 22:06                       ` Joseph Myers
  2016-08-11  0:39                         ` Paul E. Murphy
  0 siblings, 1 reply; 53+ messages in thread
From: Joseph Myers @ 2016-08-10 22:06 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha, Adhemerval Zanella

On Wed, 10 Aug 2016, Paul E. Murphy wrote:

> Ok, here is a patch which does all of the above.  I like this approach
> much better than the previous patches.  This approach is much more
> inline with the existing idioms, much easier to understand, and more
> robust.

The shell code you're embedding in the makefile uses $${gfunc/F/} which is 
a bash-specific feature.  Makefile shell code is run with /bin/sh; you can 
only rely on POSIX shell features.  dash does not support this non-POSIX 
feature.

> Notable changes from the last patch:

This patch has not addressed my point that the comment about LDBL_EPSILON 
for IBM long double should refer to both underflows and overflows.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-10 22:06                       ` Joseph Myers
@ 2016-08-11  0:39                         ` Paul E. Murphy
  2016-08-11  1:23                           ` Joseph Myers
  0 siblings, 1 reply; 53+ messages in thread
From: Paul E. Murphy @ 2016-08-11  0:39 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, Adhemerval Zanella



On 08/10/2016 05:05 PM, Joseph Myers wrote:
> On Wed, 10 Aug 2016, Paul E. Murphy wrote:
> 
>> Ok, here is a patch which does all of the above.  I like this approach
>> much better than the previous patches.  This approach is much more
>> inline with the existing idioms, much easier to understand, and more
>> robust.
> 
> The shell code you're embedding in the makefile uses $${gfunc/F/} which is 
> a bash-specific feature.  Makefile shell code is run with /bin/sh; you can 
> only rely on POSIX shell features.  dash does not support this non-POSIX 
> feature.
> 
>> Notable changes from the last patch:
> 
> This patch has not addressed my point that the comment about LDBL_EPSILON 
> for IBM long double should refer to both underflows and overflows.
> 

Oops, thanks for catching those.  Both are fixed with minor changes
to the patch:


diff --git a/math/Makefile b/math/Makefile
index 567b7ed..7451e4e 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -274,7 +274,7 @@ generated += $(addsuffix .c,$(call type-foreach,$(gen-libm-calls:%=%$(s)))) \
 # Create wrappers in the math build directory.
 $(objpfx)gen-libm-templates.stmp:
        for gfunc in $(gen-libm-calls); do                                \
-         gfunc_basefile=$${gfunc/F/}_template.c;                         \
+         gfunc_basefile=$${gfunc%F*}$${gfunc#*F}_template.c;             \
          for type in $(foreach t,$(types),$(t)__$(type-$(t)-suffix)); do \
            func=$(objpfx)$${gfunc/F/$${type#*__}};                       \
            type=$${type%__*};                                            \
diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
index 91394ba..259cb94 100644
--- a/sysdeps/generic/math-type-macros.h
+++ b/sysdeps/generic/math-type-macros.h
@@ -95,7 +95,7 @@
 #include <float.h>
 
 /* Use a special epsilon value for IBM long double
-   to avoid spurious overflows.  */
+   to avoid spurious overflows/underflows.  */
 #if M_MANT_DIG != 106
 # define M_EPSILON __M_CONCATX (M_PFX, _EPSILON)
 #else

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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-11  0:39                         ` Paul E. Murphy
@ 2016-08-11  1:23                           ` Joseph Myers
  2016-08-11 14:43                             ` Paul E. Murphy
  0 siblings, 1 reply; 53+ messages in thread
From: Joseph Myers @ 2016-08-11  1:23 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha, Adhemerval Zanella

On Wed, 10 Aug 2016, Paul E. Murphy wrote:

> diff --git a/math/Makefile b/math/Makefile
> index 567b7ed..7451e4e 100644
> --- a/math/Makefile
> +++ b/math/Makefile
> @@ -274,7 +274,7 @@ generated += $(addsuffix .c,$(call type-foreach,$(gen-libm-calls:%=%$(s)))) \
>  # Create wrappers in the math build directory.
>  $(objpfx)gen-libm-templates.stmp:
>         for gfunc in $(gen-libm-calls); do                                \
> -         gfunc_basefile=$${gfunc/F/}_template.c;                         \
> +         gfunc_basefile=$${gfunc%F*}$${gfunc#*F}_template.c;             \
>           for type in $(foreach t,$(types),$(t)__$(type-$(t)-suffix)); do \
>             func=$(objpfx)$${gfunc/F/$${type#*__}};                       \

There's a further unfixed instance of this non-POSIX shell usage.

Please send a complete fixed patch.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-11  1:23                           ` Joseph Myers
@ 2016-08-11 14:43                             ` Paul E. Murphy
  2016-08-12 16:41                               ` Joseph Myers
  0 siblings, 1 reply; 53+ messages in thread
From: Paul E. Murphy @ 2016-08-11 14:43 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, Adhemerval Zanella

[-- Attachment #1: Type: text/plain, Size: 1028 bytes --]



On 08/10/2016 08:22 PM, Joseph Myers wrote:
> On Wed, 10 Aug 2016, Paul E. Murphy wrote:
> 
>> diff --git a/math/Makefile b/math/Makefile
>> index 567b7ed..7451e4e 100644
>> --- a/math/Makefile
>> +++ b/math/Makefile
>> @@ -274,7 +274,7 @@ generated += $(addsuffix .c,$(call type-foreach,$(gen-libm-calls:%=%$(s)))) \
>>  # Create wrappers in the math build directory.
>>  $(objpfx)gen-libm-templates.stmp:
>>         for gfunc in $(gen-libm-calls); do                                \
>> -         gfunc_basefile=$${gfunc/F/}_template.c;                         \
>> +         gfunc_basefile=$${gfunc%F*}$${gfunc#*F}_template.c;             \
>>           for type in $(foreach t,$(types),$(t)__$(type-$(t)-suffix)); do \
>>             func=$(objpfx)$${gfunc/F/$${type#*__}};                       \
> 
> There's a further unfixed instance of this non-POSIX shell usage.
> 
> Please send a complete fixed patch.
> 

That seems to be the last bash-ism.  I've also applied some other
cleanups intended to improve readability.

[-- Attachment #2: 0001-Support-for-type-generic-libm-function-implementatio.patch --]
[-- Type: text/x-patch, Size: 42436 bytes --]

From cbfbcc5b836741c8f018bb317274db41c3746871 Mon Sep 17 00:00:00 2001
From: "Paul E. Murphy" <murphyp@linux.vnet.ibm.com>
Date: Tue, 14 Jun 2016 11:44:14 -0500
Subject: [PATCH 1/9] Support for type-generic libm function implementations
 libm

This defines a new classes of libm objects.  The
<func>_template.c file which is used in conjunction
with the new makefile hooks to derive variants for
each type supported by the target machine.

The headers math-type-macros-TYPE.h are used to supply
macros to a common implementation of a function in
a file named FUNC_template.c and glued togethor via
a generated file matching existing naming in the
build directory.

This has the properties of preserving the existing
override mechanism and not requiring any arcane
build system twiddling.  Likewise, it enables machines
to override these files without any additional work.

I have verified the built objects for ppc64, x86_64,
alpha, arm, and m68k do not change in any meaningful
way with these changes using the Fedora cross toolchains.
I have verified the x86_64 and ppc64 changes still run.

	* math/Makefile: (gen-libm-templates.stmp): New rule.
	(libm-calls): Move carg conj cimag and cabs into ...
	(gen-libm-calls): New variable.

	* sysdeps/generic/math-type-macros.h: New file.
	* sysdeps/generic/math-type-macros-float.h: Likewise.
	* sysdeps/generic/math-type-macros-double.h: Likewise.
	* sysdeps/generic/math-type-macros-ldouble.h: Likewise.
	* sysdeps/ieee754/ldbl-opt/math-type-macros-double.h: Likewise.
	* sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h: Likewise.

	* math/cabs.c: Refactor into
	* math/cabs_template.c: new file.
	* math/cabsf.c: Removed.
	* math/cabsl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cabsf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cabsl.c: Removed.

	* math/carg.c: Refactor into
	* math/carg_template.c: new file.
	* math/cargf.c: Removed.
	* math/cargl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cargf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cargl.c: Removed.

	* math/conj.c: Refactor into
	* math/conj_template.c: new file.
	* math/conjf.c: Removed.
	* math/conjl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/conjf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/conjl.c: Removed.

	* math/cimag.c: Refactor into
	* math/cimag_template.c: new file.
	* math/cimagf.c: Removed.
	* math/cimagl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.

	* math/cimag.c: Refactor into
	* math/cimag_template.c: new file.
	* math/cimagf.c: Removed.
	* math/cimagl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.
---
 math/Makefile                                      |  31 +++++-
 math/{cabs.c => cabs_template.c}                   |  17 +--
 math/cabsf.c                                       |  28 -----
 math/cabsl.c                                       |  28 -----
 math/{carg.c => carg_template.c}                   |  17 +--
 math/cargf.c                                       |  28 -----
 math/cargl.c                                       |  28 -----
 math/{cimag.c => cimag_template.c}                 |  15 +--
 math/cimagf.c                                      |  27 -----
 math/cimagl.c                                      |  27 -----
 math/{conj.c => conj_template.c}                   |  15 +--
 math/conjf.c                                       |  27 -----
 math/conjl.c                                       |  27 -----
 math/{creal.c => creal_template.c}                 |  15 +--
 math/crealf.c                                      |  27 -----
 math/creall.c                                      |  27 -----
 sysdeps/generic/math-type-macros-double.h          |  45 ++++++++
 .../generic/math-type-macros-float.h               |  33 +++---
 .../generic/math-type-macros-ldouble.h             |  28 ++---
 sysdeps/generic/math-type-macros.h                 | 121 +++++++++++++++++++++
 sysdeps/ieee754/ldbl-opt/cabs.c                    |   6 -
 sysdeps/ieee754/ldbl-opt/cabsl.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/carg.c                    |   6 -
 sysdeps/ieee754/ldbl-opt/cargl.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/cimag.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/cimagl.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/conj.c                    |   6 -
 sysdeps/ieee754/ldbl-opt/conjl.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/creal.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/creall.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/math-type-macros-double.h |  58 ++++++++++
 .../ieee754/ldbl-opt/math-type-macros-ldouble.h    |  25 ++---
 32 files changed, 338 insertions(+), 416 deletions(-)
 rename math/{cabs.c => cabs_template.c} (77%)
 delete mode 100644 math/cabsf.c
 delete mode 100644 math/cabsl.c
 copy math/{carg.c => carg_template.c} (79%)
 delete mode 100644 math/cargf.c
 delete mode 100644 math/cargl.c
 rename math/{cimag.c => cimag_template.c} (82%)
 delete mode 100644 math/cimagf.c
 delete mode 100644 math/cimagl.c
 rename math/{conj.c => conj_template.c} (81%)
 delete mode 100644 math/conjf.c
 delete mode 100644 math/conjl.c
 rename math/{creal.c => creal_template.c} (82%)
 delete mode 100644 math/crealf.c
 delete mode 100644 math/creall.c
 create mode 100644 sysdeps/generic/math-type-macros-double.h
 copy math/carg.c => sysdeps/generic/math-type-macros-float.h (59%)
 copy math/carg.c => sysdeps/generic/math-type-macros-ldouble.h (63%)
 create mode 100644 sysdeps/generic/math-type-macros.h
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabs.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabsl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/carg.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cargl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimag.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimagl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conj.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conjl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creal.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creall.c
 create mode 100644 sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
 rename math/carg.c => sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h (63%)

diff --git a/math/Makefile b/math/Makefile
index 1da1797..bfa0c57 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -43,6 +43,10 @@ libm-support = s_lib_version s_matherr s_signgam			\
 	       fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt	\
 	       fegetexcept
 
+# 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
+
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
 	e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF	  \
@@ -59,13 +63,13 @@ 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	  \
-	conjF cimagF crealF cabsF cargF s_cexpF s_csinhF s_ccoshF s_clogF \
+	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_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			  \
-	s_nextupF s_nextdownF
+	s_nextupF s_nextdownF $(gen-libm-calls)
 
 libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl
 libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
@@ -264,6 +268,29 @@ extra-objs += libieee.a ieee-math.o
 
 include ../Rules
 
+generated += $(addsuffix .c,$(call type-foreach,$(gen-libm-calls:%=%$(s)))) \
+	     gen-libm-templates.stmp
+
+# Create wrappers in the math build directory.
+$(objpfx)gen-libm-templates.stmp:
+	for gcall in $(gen-libm-calls); do                                \
+	  func=$${gcall%F*}$${gcall#*F};                                  \
+	  for type in $(foreach t,$(types),$(t)__$(type-$(t)-suffix)); do \
+	    suff=$${type#*__};                                            \
+	    type=$${type%__*};                                            \
+	    file=$(objpfx)$${gcall%F*}$${suff}$${gcall#*F}.c;             \
+	    (                                                             \
+	      echo "#include <math-type-macros-$${type}.h>";              \
+	      echo "#include <$${func}_template.c>";                      \
+	    ) > $${file};                                                 \
+	  done;                                                           \
+	done;                                                             \
+	echo > $(@)
+
+# Add dependency to ensure the generator runs prior.
+$(foreach t, $(call type-foreach, $(gen-libm-calls)), \
+             $(objpfx)$(t).c): $(objpfx)gen-libm-templates.stmp
+
 ifneq (no,$(PERL))
 # This must come after the inclusion of sysdeps Makefiles via Rules.
 $(addprefix $(objpfx), $(libm-tests.o)): $(objpfx)libm-test.stmp
diff --git a/math/cabs.c b/math/cabs_template.c
similarity index 77%
rename from math/cabs.c
rename to math/cabs_template.c
index d7e0665..5eff1b2 100644
--- a/math/cabs.c
+++ b/math/cabs_template.c
@@ -1,4 +1,4 @@
-/* Return the complex absolute value of double complex value.
+/* Return the complex absolute value 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.
@@ -20,13 +20,14 @@
 #include <complex.h>
 #include <math.h>
 
-double
-__cabs (double _Complex z)
+FLOAT
+M_DECL_FUNC (__cabs) (CFLOAT z)
 {
-  return __hypot (__real__ z, __imag__ z);
+  return M_SUF (__hypot) (__real__ z, __imag__ z);
 }
-weak_alias (__cabs, cabs)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cabs, __cabsl)
-weak_alias (__cabs, cabsl)
+
+declare_mgen_alias (__cabs, cabs)
+
+#if M_LIBM_NEED_COMPAT (cabs)
+declare_mgen_libm_compat (__cabs, cabs)
 #endif
diff --git a/math/cabsf.c b/math/cabsf.c
deleted file mode 100644
index 431a244..0000000
--- a/math/cabsf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-float
-__cabsf (float _Complex z)
-{
-  return __hypotf (__real__ z, __imag__ z);
-}
-weak_alias (__cabsf, cabsf)
diff --git a/math/cabsl.c b/math/cabsl.c
deleted file mode 100644
index d87e3a2..0000000
--- a/math/cabsl.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-long double
-__cabsl (long double _Complex z)
-{
-  return __hypotl (__real__ z, __imag__ z);
-}
-weak_alias (__cabsl, cabsl)
diff --git a/math/carg.c b/math/carg_template.c
similarity index 79%
copy from math/carg.c
copy to math/carg_template.c
index 61f1e0d..6205be8 100644
--- a/math/carg.c
+++ b/math/carg_template.c
@@ -1,4 +1,4 @@
-/* Compute argument of complex double value.
+/* Compute argument 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.
@@ -20,13 +20,14 @@
 #include <complex.h>
 #include <math.h>
 
-double
-__carg (__complex__ double x)
+FLOAT
+M_DECL_FUNC (__carg) (CFLOAT x)
 {
-  return __atan2 (__imag__ x, __real__ x);
+  return M_SUF (__atan2) (__imag__ x, __real__ x);
 }
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
+
+declare_mgen_alias (__carg, carg)
+
+#if M_LIBM_NEED_COMPAT (carg)
+declare_mgen_libm_compat (__carg, carg)
 #endif
diff --git a/math/cargf.c b/math/cargf.c
deleted file mode 100644
index 620db3e..0000000
--- a/math/cargf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Compute argument 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>
-
-float
-__cargf (__complex__ float x)
-{
-  return __atan2f (__imag__ x, __real__ x);
-}
-weak_alias (__cargf, cargf)
diff --git a/math/cargl.c b/math/cargl.c
deleted file mode 100644
index 31b7292..0000000
--- a/math/cargl.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Compute argument 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>
-
-long double
-__cargl (__complex__ long double x)
-{
-  return __atan2l (__imag__ x, __real__ x);
-}
-weak_alias (__cargl, cargl)
diff --git a/math/cimag.c b/math/cimag_template.c
similarity index 82%
rename from math/cimag.c
rename to math/cimag_template.c
index 1807ac2..582147d 100644
--- a/math/cimag.c
+++ b/math/cimag_template.c
@@ -1,4 +1,4 @@
-/* Return imaginary part of complex double value.
+/* Return imaginary part 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double
-__cimag (double _Complex z)
+FLOAT
+M_DECL_FUNC (__cimag) (CFLOAT z)
 {
   return __imag__ z;
 }
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
+
+declare_mgen_alias (__cimag, cimag)
+
+#if M_LIBM_NEED_COMPAT (cimag)
+declare_mgen_libm_compat (__cimag, cimag)
 #endif
diff --git a/math/cimagf.c b/math/cimagf.c
deleted file mode 100644
index 67c37f4..0000000
--- a/math/cimagf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return imaginary part 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>
-
-float
-__cimagf (float _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimagf, cimagf)
diff --git a/math/cimagl.c b/math/cimagl.c
deleted file mode 100644
index c1d0910..0000000
--- a/math/cimagl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return imaginary part 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>
-
-long double
-__cimagl (long double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimagl, cimagl)
diff --git a/math/conj.c b/math/conj_template.c
similarity index 81%
rename from math/conj.c
rename to math/conj_template.c
index d282985..72d1236 100644
--- a/math/conj.c
+++ b/math/conj_template.c
@@ -1,4 +1,4 @@
-/* Return complex conjugate of complex double value.
+/* Return complex conjugate 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double _Complex
-__conj (double _Complex z)
+CFLOAT
+M_DECL_FUNC (__conj) (CFLOAT z)
 {
   return ~z;
 }
-weak_alias (__conj, conj)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__conj, __conjl)
-weak_alias (__conj, conjl)
+
+declare_mgen_alias (__conj, conj)
+
+#if M_LIBM_NEED_COMPAT (conj)
+declare_mgen_libm_compat (__conj, conj)
 #endif
diff --git a/math/conjf.c b/math/conjf.c
deleted file mode 100644
index 3587c94..0000000
--- a/math/conjf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return complex conjugate 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>
-
-float _Complex
-__conjf (float _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conjf, conjf)
diff --git a/math/conjl.c b/math/conjl.c
deleted file mode 100644
index 55bb393..0000000
--- a/math/conjl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return complex conjugate 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>
-
-long double _Complex
-__conjl (long double _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conjl, conjl)
diff --git a/math/creal.c b/math/creal_template.c
similarity index 82%
rename from math/creal.c
rename to math/creal_template.c
index 231d3b0..f840f43 100644
--- a/math/creal.c
+++ b/math/creal_template.c
@@ -1,4 +1,4 @@
-/* Return real part of complex double value.
+/* Return real part 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double
-__creal (double _Complex z)
+FLOAT
+M_DECL_FUNC (__creal) (CFLOAT z)
 {
   return __real__ z;
 }
-weak_alias (__creal, creal)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__creal, __creall)
-weak_alias (__creal, creall)
+
+declare_mgen_alias (__creal, creal)
+
+#if M_LIBM_NEED_COMPAT (creal)
+declare_mgen_libm_compat (__creal, creal)
 #endif
diff --git a/math/crealf.c b/math/crealf.c
deleted file mode 100644
index 5883849..0000000
--- a/math/crealf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return real part 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>
-
-float
-__crealf (float _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__crealf, crealf)
diff --git a/math/creall.c b/math/creall.c
deleted file mode 100644
index 4a31557..0000000
--- a/math/creall.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return real part 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>
-
-long double
-__creall (long double _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__creall, creall)
diff --git a/sysdeps/generic/math-type-macros-double.h b/sysdeps/generic/math-type-macros-double.h
new file mode 100644
index 0000000..4149b39
--- /dev/null
+++ b/sysdeps/generic/math-type-macros-double.h
@@ -0,0 +1,45 @@
+/* Helper macros for double variants of type generic functions of libm.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS_DOUBLE
+#define _MATH_TYPE_MACROS_DOUBLE
+
+#define M_LIT(c) c
+#define M_MLIT(c) c
+#define M_PFX DBL
+#define M_SUF(c) c
+#define FLOAT double
+#define CFLOAT _Complex double
+
+/* Machines without a distinct long double type
+   alias long double functions to their double
+   equivalent.  */
+#if defined NO_LONG_DOUBLE
+# define declare_mgen_alias(from, to)	    \
+   weak_alias (from, to)		    \
+   strong_alias (from, from ## l)	    \
+   weak_alias (from, to ## l)
+#else
+# define declare_mgen_alias(from, to)	    \
+   weak_alias (M_SUF (from), M_SUF (to))
+#endif
+
+/* Supply the generic macros.  */
+#include <math-type-macros.h>
+
+#endif
diff --git a/math/carg.c b/sysdeps/generic/math-type-macros-float.h
similarity index 59%
copy from math/carg.c
copy to sysdeps/generic/math-type-macros-float.h
index 61f1e0d..aab88fd 100644
--- a/math/carg.c
+++ b/sysdeps/generic/math-type-macros-float.h
@@ -1,7 +1,6 @@
-/* Compute argument of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Helper macros for float variants of type generic functions of libm.
+   Copyright (C) 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
@@ -17,16 +16,20 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
-#include <math.h>
-
-double
-__carg (__complex__ double x)
-{
-  return __atan2 (__imag__ x, __real__ x);
-}
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
+#ifndef _MATH_TYPE_MACROS_FLOAT
+#define _MATH_TYPE_MACROS_FLOAT
+
+#define M_LIT(c) c ## f
+#define M_PFX FLT
+#define M_SUF(c) c ## f
+#define FLOAT float
+#define CFLOAT _Complex float
+
+/* Standard/GNU macro literals do not exist for the float type.  Use
+   the double macro constants.  */
+#define M_MLIT(c) c
+
+/* Supply the generic macros.  */
+#include <math-type-macros.h>
+
 #endif
diff --git a/math/carg.c b/sysdeps/generic/math-type-macros-ldouble.h
similarity index 63%
copy from math/carg.c
copy to sysdeps/generic/math-type-macros-ldouble.h
index 61f1e0d..90773fa 100644
--- a/math/carg.c
+++ b/sysdeps/generic/math-type-macros-ldouble.h
@@ -1,7 +1,6 @@
-/* Compute argument of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Helper macros for long double variants of type generic functions of libm.
+   Copyright (C) 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
@@ -17,16 +16,17 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
-#include <math.h>
+#ifndef _MATH_TYPE_MACROS_LDOUBLE
+#define _MATH_TYPE_MACROS_LDOUBLE
+
+#define M_LIT(c) c ## L
+#define M_MLIT(c) c ## l
+#define M_PFX LDBL
+#define M_SUF(c) c ## l
+#define FLOAT long double
+#define CFLOAT _Complex long double
+
+/* Supply the generic macros.  */
+#include <math-type-macros.h>
 
-double
-__carg (__complex__ double x)
-{
-  return __atan2 (__imag__ x, __real__ x);
-}
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
 #endif
diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
new file mode 100644
index 0000000..259cb94
--- /dev/null
+++ b/sysdeps/generic/math-type-macros.h
@@ -0,0 +1,121 @@
+/* Helper macros for type generic function implementations within libm.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS
+#define _MATH_TYPE_MACROS
+
+/* Each type imports a header which is expected to
+   define:
+
+   M_LIT(x)   - Paste the type specific suffix onto the constant x.
+   M_MLIT(x)  - Paste the type specific suffix used by the macro
+		constants in math.h, i.e M_PI or M_PIl.
+   M_PFX      - The prefixed used by float.h macros like FLT_MANT_DIG.
+   M_SUF(x)   - Paste the the type specific suffix used by functions
+		i.e expf expl exp.
+   FLOAT      - Resolves to the C typename of M_TYPE.
+   CFLOAT     - Resolves to the complex typename of M_TYPE.
+
+  Optionally, these headers may inject a non-standard
+  definition for the following:
+
+  declare_mgen_alias(from,to)
+      This exposes the appropriate symbol(s) for a
+      function f of type FLOAT.
+
+  M_LIBM_NEED_COMPAT(func)
+      This is utilized in macro context to indicate
+      whether func should declare compat symbols.
+
+  declare_mgen_libm_compat(from,to)
+      This is used in conjunction with the above macro
+      outside of macro context to paste whatever is
+      required to generate a compat symbol. */
+
+#ifndef M_PFX
+# error "M_PFX must be defined."
+#endif
+#ifndef M_LIT
+# error "M_LIT must be defined."
+#endif
+#ifndef M_MLIT
+# error "M_MLIT must be defined."
+#endif
+#ifndef M_SUF
+# error "M_SUF must be defined."
+#endif
+#ifndef FLOAT
+# error "FLOAT must be defined."
+#endif
+#ifndef CFLOAT
+# error "CFLOAT must be defined."
+#endif
+
+#define __M_CONCAT(a,b) a ## b
+#define __M_CONCATX(a,b) __M_CONCAT(a,b)
+
+#define M_NAN M_SUF (__nan) ("")
+#define M_MAX_EXP __M_CONCATX (M_PFX, _MAX_EXP)
+#define M_MIN __M_CONCATX (M_PFX, _MIN)
+#define M_MAX __M_CONCATX (M_PFX, _MAX)
+#define M_MANT_DIG __M_CONCATX (M_PFX, _MANT_DIG)
+#define M_HUGE_VAL (M_SUF (__builtin_huge_val) ())
+
+/* Helper macros for commonly used functions.  */
+#define M_COPYSIGN M_SUF (__copysign)
+#define M_FABS M_SUF (fabs)
+#define M_SINCOS M_SUF (__sincos)
+#define M_SCALBN M_SUF (__scalbn)
+#define M_LOG1P M_SUF (__log1p)
+
+#define M_ATAN2 M_SUF (__ieee754_atan2)
+#define M_COSH M_SUF (__ieee754_cosh)
+#define M_EXP M_SUF (__ieee754_exp)
+#define M_HYPOT M_SUF (__ieee754_hypot)
+#define M_LOG M_SUF (__ieee754_log)
+#define M_SINH M_SUF (__ieee754_sinh)
+#define M_SQRT M_SUF (__ieee754_sqrt)
+
+/* Needed to evaluate M_MANT_DIG below.  */
+#include <float.h>
+
+/* Use a special epsilon value for IBM long double
+   to avoid spurious overflows/underflows.  */
+#if M_MANT_DIG != 106
+# define M_EPSILON __M_CONCATX (M_PFX, _EPSILON)
+#else
+# define M_EPSILON M_LIT (0x1p-106)
+#endif
+
+/* Enable overloading of function name to assist reuse.  */
+#ifndef M_DECL_FUNC
+# define M_DECL_FUNC(f) M_SUF (f)
+#endif
+
+/* If the type does not declare special aliasing, use the default.  */
+#ifndef declare_mgen_alias
+# define declare_mgen_alias(from, to) weak_alias (M_SUF (from), M_SUF (to))
+#endif
+
+/* Do not generate anything for compat symbols by default.  */
+#ifndef M_LIBM_NEED_COMPAT
+# define M_LIBM_NEED_COMPAT(func) 0
+# define declare_mgen_libm_compat(from, to)
+#endif
+
+#endif /* _MATH_TYPE_MACROS */
diff --git a/sysdeps/ieee754/ldbl-opt/cabs.c b/sysdeps/ieee754/ldbl-opt/cabs.c
deleted file mode 100644
index a181de2..0000000
--- a/sysdeps/ieee754/ldbl-opt/cabs.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/cabs.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cabs, cabsl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cabsl.c b/sysdeps/ieee754/ldbl-opt/cabsl.c
deleted file mode 100644
index b861633..0000000
--- a/sysdeps/ieee754/ldbl-opt/cabsl.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/cabsl.c>
-long_double_symbol (libm, __cabsl, cabsl);
diff --git a/sysdeps/ieee754/ldbl-opt/carg.c b/sysdeps/ieee754/ldbl-opt/carg.c
deleted file mode 100644
index 2ed3581..0000000
--- a/sysdeps/ieee754/ldbl-opt/carg.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/carg.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __carg, cargl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cargl.c b/sysdeps/ieee754/ldbl-opt/cargl.c
deleted file mode 100644
index 952dc60..0000000
--- a/sysdeps/ieee754/ldbl-opt/cargl.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/cargl.c>
-long_double_symbol (libm, __cargl, cargl);
diff --git a/sysdeps/ieee754/ldbl-opt/cimag.c b/sysdeps/ieee754/ldbl-opt/cimag.c
deleted file mode 100644
index f805258..0000000
--- a/sysdeps/ieee754/ldbl-opt/cimag.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/cimag.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cimag, cimagl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cimagl.c b/sysdeps/ieee754/ldbl-opt/cimagl.c
deleted file mode 100644
index 112365e..0000000
--- a/sysdeps/ieee754/ldbl-opt/cimagl.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/cimagl.c>
-long_double_symbol (libm, __cimagl, cimagl);
diff --git a/sysdeps/ieee754/ldbl-opt/conj.c b/sysdeps/ieee754/ldbl-opt/conj.c
deleted file mode 100644
index e4edade..0000000
--- a/sysdeps/ieee754/ldbl-opt/conj.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/conj.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __conj, conjl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/conjl.c b/sysdeps/ieee754/ldbl-opt/conjl.c
deleted file mode 100644
index c98e0ed..0000000
--- a/sysdeps/ieee754/ldbl-opt/conjl.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/conjl.c>
-long_double_symbol (libm, __conjl, conjl);
diff --git a/sysdeps/ieee754/ldbl-opt/creal.c b/sysdeps/ieee754/ldbl-opt/creal.c
deleted file mode 100644
index 0d1c93e..0000000
--- a/sysdeps/ieee754/ldbl-opt/creal.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/creal.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __creal, creall, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/creall.c b/sysdeps/ieee754/ldbl-opt/creall.c
deleted file mode 100644
index 68fedd4..0000000
--- a/sysdeps/ieee754/ldbl-opt/creall.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/creall.c>
-long_double_symbol (libm, __creall, creall);
diff --git a/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h b/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
new file mode 100644
index 0000000..8cb5694
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
@@ -0,0 +1,58 @@
+/* Overrides for ldbl-opt versioning for double types.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS_DOUBLE
+
+#include <math_ldbl_opt.h>
+
+#define LDOUBLE_cabsl_libm_version GLIBC_2_1
+#define LDOUBLE_cargl_libm_version GLIBC_2_1
+#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
+#define LDOUBLE_casinl_libm_version GLIBC_2_1
+#define LDOUBLE_csinl_libm_version GLIBC_2_1
+#define LDOUBLE_casinhl_libm_version GLIBC_2_1
+#define LDOUBLE_csinhl_libm_version GLIBC_2_1
+#define LDOUBLE_catanl_libm_version GLIBC_2_1
+#define LDOUBLE_catanhl_libm_version GLIBC_2_1
+#define LDOUBLE_ctanl_libm_version GLIBC_2_1
+#define LDOUBLE_ctanhl_libm_version GLIBC_2_1
+#define LDOUBLE_cexpl_libm_version GLIBC_2_1
+#define LDOUBLE_clogl_libm_version GLIBC_2_1
+#define LDOUBLE_cprojl_libm_version GLIBC_2_1
+#define LDOUBLE_csqrtl_libm_version GLIBC_2_1
+#define LDOUBLE_cpowl_libm_version GLIBC_2_1
+#define LDOUBLE_clog10l_libm_version GLIBC_2_1
+#define LDOUBLE___clog10l_libm_version GLIBC_2_1
+
+/* Define compat symbols for long double on platforms
+   where it was not always a distinct type.  */
+#define M_LIBM_NEED_COMPAT(f) \
+  LONG_DOUBLE_COMPAT (libm, LDOUBLE_ ## f ## l_libm_version)
+
+#define declare_mgen_libm_compat(from, to)	      \
+  compat_symbol (libm, from, to ## l,		      \
+		 LDOUBLE_ ## to ## l_libm_version);
+
+#include_next <math-type-macros-double.h>
+#endif
diff --git a/math/carg.c b/sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
similarity index 63%
rename from math/carg.c
rename to sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
index 61f1e0d..d2af4bb 100644
--- a/math/carg.c
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
@@ -1,7 +1,6 @@
-/* Compute argument of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Overrides for ldbl-opt versioning for long double types.
+   Copyright (C) 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
@@ -17,16 +16,14 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
-#include <math.h>
+#ifndef _MATH_TYPE_MACROS_LDOUBLE
 
-double
-__carg (__complex__ double x)
-{
-  return __atan2 (__imag__ x, __real__ x);
-}
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
+#include <math_ldbl_opt.h>
+
+/* Use properly versioned symbols for long double on platforms where
+   it was not always a distinct type.  */
+#define declare_mgen_alias(from, to) \
+  long_double_symbol (libm, from ## l, to ## l);
+
+#include_next <math-type-macros-ldouble.h>
 #endif
-- 
2.4.11


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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-11 14:43                             ` Paul E. Murphy
@ 2016-08-12 16:41                               ` Joseph Myers
  2016-08-12 17:27                                 ` Paul E. Murphy
  0 siblings, 1 reply; 53+ messages in thread
From: Joseph Myers @ 2016-08-12 16:41 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha, Adhemerval Zanella

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

> +generated += $(addsuffix .c,$(call type-foreach,$(gen-libm-calls:%=%$(s)))) \

Where does $(s) come from?

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-12 16:41                               ` Joseph Myers
@ 2016-08-12 17:27                                 ` Paul E. Murphy
  2016-08-16 18:00                                   ` Joseph Myers
  0 siblings, 1 reply; 53+ messages in thread
From: Paul E. Murphy @ 2016-08-12 17:27 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, Adhemerval Zanella

[-- Attachment #1: Type: text/plain, Size: 337 bytes --]



On 08/12/2016 11:41 AM, Joseph Myers wrote:
> On Thu, 11 Aug 2016, Paul E. Murphy wrote:
> 
>> +generated += $(addsuffix .c,$(call type-foreach,$(gen-libm-calls:%=%$(s)))) \
> 
> Where does $(s) come from?
> 


It doesn't, and is bad refactoring on my part.  Thanks for catching that.  Fixed
via removing the unnecessary substitution.

[-- Attachment #2: 0001-Support-for-type-generic-libm-function-implementatio.patch --]
[-- Type: text/x-patch, Size: 42501 bytes --]

From e69c0d48160e15b9b546686271159e375bf6a7f4 Mon Sep 17 00:00:00 2001
From: "Paul E. Murphy" <murphyp@linux.vnet.ibm.com>
Date: Tue, 14 Jun 2016 11:44:14 -0500
Subject: [PATCH 1/9] Support for type-generic libm function implementations
 libm

This defines a new classes of libm objects.  The
<func>_template.c file which is used in conjunction
with the new makefile hooks to derive variants for
each type supported by the target machine.

The headers math-type-macros-TYPE.h are used to supply
macros to a common implementation of a function in
a file named FUNC_template.c and glued togethor via
a generated file matching existing naming in the
build directory.

This has the properties of preserving the existing
override mechanism and not requiring any arcane
build system twiddling.  Likewise, it enables machines
to override these files without any additional work.

I have verified the built objects for ppc64, x86_64,
alpha, arm, and m68k do not change in any meaningful
way with these changes using the Fedora cross toolchains.
I have verified the x86_64 and ppc64 changes still run.

	* math/Makefile: (gen-libm-templates.stmp): New rule.
	(libm-calls): Move carg conj cimag and cabs into ...
	(gen-libm-calls): New variable.
	(generated): Inform Make objects from gen-libm-calls
	may be generated.

	* sysdeps/generic/math-type-macros.h: New file.
	* sysdeps/generic/math-type-macros-float.h: Likewise.
	* sysdeps/generic/math-type-macros-double.h: Likewise.
	* sysdeps/generic/math-type-macros-ldouble.h: Likewise.
	* sysdeps/ieee754/ldbl-opt/math-type-macros-double.h: Likewise.
	* sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h: Likewise.

	* math/cabs.c: Refactor into
	* math/cabs_template.c: new file.
	* math/cabsf.c: Removed.
	* math/cabsl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cabsf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cabsl.c: Removed.

	* math/carg.c: Refactor into
	* math/carg_template.c: new file.
	* math/cargf.c: Removed.
	* math/cargl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cargf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cargl.c: Removed.

	* math/conj.c: Refactor into
	* math/conj_template.c: new file.
	* math/conjf.c: Removed.
	* math/conjl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/conjf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/conjl.c: Removed.

	* math/cimag.c: Refactor into
	* math/cimag_template.c: new file.
	* math/cimagf.c: Removed.
	* math/cimagl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.

	* math/cimag.c: Refactor into
	* math/cimag_template.c: new file.
	* math/cimagf.c: Removed.
	* math/cimagl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
	* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.
---
 math/Makefile                                      |  31 +++++-
 math/{cabs.c => cabs_template.c}                   |  17 +--
 math/cabsf.c                                       |  28 -----
 math/cabsl.c                                       |  28 -----
 math/{carg.c => carg_template.c}                   |  17 +--
 math/cargf.c                                       |  28 -----
 math/cargl.c                                       |  28 -----
 math/{cimag.c => cimag_template.c}                 |  15 +--
 math/cimagf.c                                      |  27 -----
 math/cimagl.c                                      |  27 -----
 math/{conj.c => conj_template.c}                   |  15 +--
 math/conjf.c                                       |  27 -----
 math/conjl.c                                       |  27 -----
 math/{creal.c => creal_template.c}                 |  15 +--
 math/crealf.c                                      |  27 -----
 math/creall.c                                      |  27 -----
 sysdeps/generic/math-type-macros-double.h          |  45 ++++++++
 .../generic/math-type-macros-float.h               |  33 +++---
 .../generic/math-type-macros-ldouble.h             |  28 ++---
 sysdeps/generic/math-type-macros.h                 | 121 +++++++++++++++++++++
 sysdeps/ieee754/ldbl-opt/cabs.c                    |   6 -
 sysdeps/ieee754/ldbl-opt/cabsl.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/carg.c                    |   6 -
 sysdeps/ieee754/ldbl-opt/cargl.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/cimag.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/cimagl.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/conj.c                    |   6 -
 sysdeps/ieee754/ldbl-opt/conjl.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/creal.c                   |   6 -
 sysdeps/ieee754/ldbl-opt/creall.c                  |   6 -
 sysdeps/ieee754/ldbl-opt/math-type-macros-double.h |  58 ++++++++++
 .../ieee754/ldbl-opt/math-type-macros-ldouble.h    |  25 ++---
 32 files changed, 338 insertions(+), 416 deletions(-)
 rename math/{cabs.c => cabs_template.c} (77%)
 delete mode 100644 math/cabsf.c
 delete mode 100644 math/cabsl.c
 copy math/{carg.c => carg_template.c} (79%)
 delete mode 100644 math/cargf.c
 delete mode 100644 math/cargl.c
 rename math/{cimag.c => cimag_template.c} (82%)
 delete mode 100644 math/cimagf.c
 delete mode 100644 math/cimagl.c
 rename math/{conj.c => conj_template.c} (81%)
 delete mode 100644 math/conjf.c
 delete mode 100644 math/conjl.c
 rename math/{creal.c => creal_template.c} (82%)
 delete mode 100644 math/crealf.c
 delete mode 100644 math/creall.c
 create mode 100644 sysdeps/generic/math-type-macros-double.h
 copy math/carg.c => sysdeps/generic/math-type-macros-float.h (59%)
 copy math/carg.c => sysdeps/generic/math-type-macros-ldouble.h (63%)
 create mode 100644 sysdeps/generic/math-type-macros.h
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabs.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cabsl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/carg.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cargl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimag.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/cimagl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conj.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/conjl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creal.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/creall.c
 create mode 100644 sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
 rename math/carg.c => sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h (63%)

diff --git a/math/Makefile b/math/Makefile
index 1da1797..219f67d 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -43,6 +43,10 @@ libm-support = s_lib_version s_matherr s_signgam			\
 	       fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt	\
 	       fegetexcept
 
+# 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
+
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
 	e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF	  \
@@ -59,13 +63,13 @@ 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	  \
-	conjF cimagF crealF cabsF cargF s_cexpF s_csinhF s_ccoshF s_clogF \
+	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_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			  \
-	s_nextupF s_nextdownF
+	s_nextupF s_nextdownF $(gen-libm-calls)
 
 libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl
 libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
@@ -264,6 +268,29 @@ extra-objs += libieee.a ieee-math.o
 
 include ../Rules
 
+generated += $(addsuffix .c,$(call type-foreach,$(gen-libm-calls))) \
+	     gen-libm-templates.stmp
+
+# Create wrappers in the math build directory.
+$(objpfx)gen-libm-templates.stmp:
+	for gcall in $(gen-libm-calls); do                                \
+	  func=$${gcall%F*}$${gcall#*F};                                  \
+	  for type in $(foreach t,$(types),$(t)__$(type-$(t)-suffix)); do \
+	    suff=$${type#*__};                                            \
+	    type=$${type%__*};                                            \
+	    file=$(objpfx)$${gcall%F*}$${suff}$${gcall#*F}.c;             \
+	    (                                                             \
+	      echo "#include <math-type-macros-$${type}.h>";              \
+	      echo "#include <$${func}_template.c>";                      \
+	    ) > $${file};                                                 \
+	  done;                                                           \
+	done;                                                             \
+	echo > $(@)
+
+# Add dependency to ensure the generator runs prior.
+$(foreach t, $(call type-foreach, $(gen-libm-calls)), \
+             $(objpfx)$(t).c): $(objpfx)gen-libm-templates.stmp
+
 ifneq (no,$(PERL))
 # This must come after the inclusion of sysdeps Makefiles via Rules.
 $(addprefix $(objpfx), $(libm-tests.o)): $(objpfx)libm-test.stmp
diff --git a/math/cabs.c b/math/cabs_template.c
similarity index 77%
rename from math/cabs.c
rename to math/cabs_template.c
index d7e0665..5eff1b2 100644
--- a/math/cabs.c
+++ b/math/cabs_template.c
@@ -1,4 +1,4 @@
-/* Return the complex absolute value of double complex value.
+/* Return the complex absolute value 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.
@@ -20,13 +20,14 @@
 #include <complex.h>
 #include <math.h>
 
-double
-__cabs (double _Complex z)
+FLOAT
+M_DECL_FUNC (__cabs) (CFLOAT z)
 {
-  return __hypot (__real__ z, __imag__ z);
+  return M_SUF (__hypot) (__real__ z, __imag__ z);
 }
-weak_alias (__cabs, cabs)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cabs, __cabsl)
-weak_alias (__cabs, cabsl)
+
+declare_mgen_alias (__cabs, cabs)
+
+#if M_LIBM_NEED_COMPAT (cabs)
+declare_mgen_libm_compat (__cabs, cabs)
 #endif
diff --git a/math/cabsf.c b/math/cabsf.c
deleted file mode 100644
index 431a244..0000000
--- a/math/cabsf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-float
-__cabsf (float _Complex z)
-{
-  return __hypotf (__real__ z, __imag__ z);
-}
-weak_alias (__cabsf, cabsf)
diff --git a/math/cabsl.c b/math/cabsl.c
deleted file mode 100644
index d87e3a2..0000000
--- a/math/cabsl.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Return the complex absolute value of 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 <math.h>
-
-long double
-__cabsl (long double _Complex z)
-{
-  return __hypotl (__real__ z, __imag__ z);
-}
-weak_alias (__cabsl, cabsl)
diff --git a/math/carg.c b/math/carg_template.c
similarity index 79%
copy from math/carg.c
copy to math/carg_template.c
index 61f1e0d..6205be8 100644
--- a/math/carg.c
+++ b/math/carg_template.c
@@ -1,4 +1,4 @@
-/* Compute argument of complex double value.
+/* Compute argument 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.
@@ -20,13 +20,14 @@
 #include <complex.h>
 #include <math.h>
 
-double
-__carg (__complex__ double x)
+FLOAT
+M_DECL_FUNC (__carg) (CFLOAT x)
 {
-  return __atan2 (__imag__ x, __real__ x);
+  return M_SUF (__atan2) (__imag__ x, __real__ x);
 }
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
+
+declare_mgen_alias (__carg, carg)
+
+#if M_LIBM_NEED_COMPAT (carg)
+declare_mgen_libm_compat (__carg, carg)
 #endif
diff --git a/math/cargf.c b/math/cargf.c
deleted file mode 100644
index 620db3e..0000000
--- a/math/cargf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Compute argument 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>
-
-float
-__cargf (__complex__ float x)
-{
-  return __atan2f (__imag__ x, __real__ x);
-}
-weak_alias (__cargf, cargf)
diff --git a/math/cargl.c b/math/cargl.c
deleted file mode 100644
index 31b7292..0000000
--- a/math/cargl.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Compute argument 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>
-
-long double
-__cargl (__complex__ long double x)
-{
-  return __atan2l (__imag__ x, __real__ x);
-}
-weak_alias (__cargl, cargl)
diff --git a/math/cimag.c b/math/cimag_template.c
similarity index 82%
rename from math/cimag.c
rename to math/cimag_template.c
index 1807ac2..582147d 100644
--- a/math/cimag.c
+++ b/math/cimag_template.c
@@ -1,4 +1,4 @@
-/* Return imaginary part of complex double value.
+/* Return imaginary part 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double
-__cimag (double _Complex z)
+FLOAT
+M_DECL_FUNC (__cimag) (CFLOAT z)
 {
   return __imag__ z;
 }
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
+
+declare_mgen_alias (__cimag, cimag)
+
+#if M_LIBM_NEED_COMPAT (cimag)
+declare_mgen_libm_compat (__cimag, cimag)
 #endif
diff --git a/math/cimagf.c b/math/cimagf.c
deleted file mode 100644
index 67c37f4..0000000
--- a/math/cimagf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return imaginary part 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>
-
-float
-__cimagf (float _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimagf, cimagf)
diff --git a/math/cimagl.c b/math/cimagl.c
deleted file mode 100644
index c1d0910..0000000
--- a/math/cimagl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return imaginary part 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>
-
-long double
-__cimagl (long double _Complex z)
-{
-  return __imag__ z;
-}
-weak_alias (__cimagl, cimagl)
diff --git a/math/conj.c b/math/conj_template.c
similarity index 81%
rename from math/conj.c
rename to math/conj_template.c
index d282985..72d1236 100644
--- a/math/conj.c
+++ b/math/conj_template.c
@@ -1,4 +1,4 @@
-/* Return complex conjugate of complex double value.
+/* Return complex conjugate 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double _Complex
-__conj (double _Complex z)
+CFLOAT
+M_DECL_FUNC (__conj) (CFLOAT z)
 {
   return ~z;
 }
-weak_alias (__conj, conj)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__conj, __conjl)
-weak_alias (__conj, conjl)
+
+declare_mgen_alias (__conj, conj)
+
+#if M_LIBM_NEED_COMPAT (conj)
+declare_mgen_libm_compat (__conj, conj)
 #endif
diff --git a/math/conjf.c b/math/conjf.c
deleted file mode 100644
index 3587c94..0000000
--- a/math/conjf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return complex conjugate 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>
-
-float _Complex
-__conjf (float _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conjf, conjf)
diff --git a/math/conjl.c b/math/conjl.c
deleted file mode 100644
index 55bb393..0000000
--- a/math/conjl.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return complex conjugate 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>
-
-long double _Complex
-__conjl (long double _Complex z)
-{
-  return ~z;
-}
-weak_alias (__conjl, conjl)
diff --git a/math/creal.c b/math/creal_template.c
similarity index 82%
rename from math/creal.c
rename to math/creal_template.c
index 231d3b0..f840f43 100644
--- a/math/creal.c
+++ b/math/creal_template.c
@@ -1,4 +1,4 @@
-/* Return real part of complex double value.
+/* Return real part 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.
@@ -19,13 +19,14 @@
 
 #include <complex.h>
 
-double
-__creal (double _Complex z)
+FLOAT
+M_DECL_FUNC (__creal) (CFLOAT z)
 {
   return __real__ z;
 }
-weak_alias (__creal, creal)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__creal, __creall)
-weak_alias (__creal, creall)
+
+declare_mgen_alias (__creal, creal)
+
+#if M_LIBM_NEED_COMPAT (creal)
+declare_mgen_libm_compat (__creal, creal)
 #endif
diff --git a/math/crealf.c b/math/crealf.c
deleted file mode 100644
index 5883849..0000000
--- a/math/crealf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return real part 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>
-
-float
-__crealf (float _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__crealf, crealf)
diff --git a/math/creall.c b/math/creall.c
deleted file mode 100644
index 4a31557..0000000
--- a/math/creall.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Return real part 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>
-
-long double
-__creall (long double _Complex z)
-{
-  return __real__ z;
-}
-weak_alias (__creall, creall)
diff --git a/sysdeps/generic/math-type-macros-double.h b/sysdeps/generic/math-type-macros-double.h
new file mode 100644
index 0000000..4149b39
--- /dev/null
+++ b/sysdeps/generic/math-type-macros-double.h
@@ -0,0 +1,45 @@
+/* Helper macros for double variants of type generic functions of libm.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS_DOUBLE
+#define _MATH_TYPE_MACROS_DOUBLE
+
+#define M_LIT(c) c
+#define M_MLIT(c) c
+#define M_PFX DBL
+#define M_SUF(c) c
+#define FLOAT double
+#define CFLOAT _Complex double
+
+/* Machines without a distinct long double type
+   alias long double functions to their double
+   equivalent.  */
+#if defined NO_LONG_DOUBLE
+# define declare_mgen_alias(from, to)	    \
+   weak_alias (from, to)		    \
+   strong_alias (from, from ## l)	    \
+   weak_alias (from, to ## l)
+#else
+# define declare_mgen_alias(from, to)	    \
+   weak_alias (M_SUF (from), M_SUF (to))
+#endif
+
+/* Supply the generic macros.  */
+#include <math-type-macros.h>
+
+#endif
diff --git a/math/carg.c b/sysdeps/generic/math-type-macros-float.h
similarity index 59%
copy from math/carg.c
copy to sysdeps/generic/math-type-macros-float.h
index 61f1e0d..aab88fd 100644
--- a/math/carg.c
+++ b/sysdeps/generic/math-type-macros-float.h
@@ -1,7 +1,6 @@
-/* Compute argument of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Helper macros for float variants of type generic functions of libm.
+   Copyright (C) 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
@@ -17,16 +16,20 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
-#include <math.h>
-
-double
-__carg (__complex__ double x)
-{
-  return __atan2 (__imag__ x, __real__ x);
-}
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
+#ifndef _MATH_TYPE_MACROS_FLOAT
+#define _MATH_TYPE_MACROS_FLOAT
+
+#define M_LIT(c) c ## f
+#define M_PFX FLT
+#define M_SUF(c) c ## f
+#define FLOAT float
+#define CFLOAT _Complex float
+
+/* Standard/GNU macro literals do not exist for the float type.  Use
+   the double macro constants.  */
+#define M_MLIT(c) c
+
+/* Supply the generic macros.  */
+#include <math-type-macros.h>
+
 #endif
diff --git a/math/carg.c b/sysdeps/generic/math-type-macros-ldouble.h
similarity index 63%
copy from math/carg.c
copy to sysdeps/generic/math-type-macros-ldouble.h
index 61f1e0d..90773fa 100644
--- a/math/carg.c
+++ b/sysdeps/generic/math-type-macros-ldouble.h
@@ -1,7 +1,6 @@
-/* Compute argument of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Helper macros for long double variants of type generic functions of libm.
+   Copyright (C) 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
@@ -17,16 +16,17 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
-#include <math.h>
+#ifndef _MATH_TYPE_MACROS_LDOUBLE
+#define _MATH_TYPE_MACROS_LDOUBLE
+
+#define M_LIT(c) c ## L
+#define M_MLIT(c) c ## l
+#define M_PFX LDBL
+#define M_SUF(c) c ## l
+#define FLOAT long double
+#define CFLOAT _Complex long double
+
+/* Supply the generic macros.  */
+#include <math-type-macros.h>
 
-double
-__carg (__complex__ double x)
-{
-  return __atan2 (__imag__ x, __real__ x);
-}
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
 #endif
diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
new file mode 100644
index 0000000..259cb94
--- /dev/null
+++ b/sysdeps/generic/math-type-macros.h
@@ -0,0 +1,121 @@
+/* Helper macros for type generic function implementations within libm.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS
+#define _MATH_TYPE_MACROS
+
+/* Each type imports a header which is expected to
+   define:
+
+   M_LIT(x)   - Paste the type specific suffix onto the constant x.
+   M_MLIT(x)  - Paste the type specific suffix used by the macro
+		constants in math.h, i.e M_PI or M_PIl.
+   M_PFX      - The prefixed used by float.h macros like FLT_MANT_DIG.
+   M_SUF(x)   - Paste the the type specific suffix used by functions
+		i.e expf expl exp.
+   FLOAT      - Resolves to the C typename of M_TYPE.
+   CFLOAT     - Resolves to the complex typename of M_TYPE.
+
+  Optionally, these headers may inject a non-standard
+  definition for the following:
+
+  declare_mgen_alias(from,to)
+      This exposes the appropriate symbol(s) for a
+      function f of type FLOAT.
+
+  M_LIBM_NEED_COMPAT(func)
+      This is utilized in macro context to indicate
+      whether func should declare compat symbols.
+
+  declare_mgen_libm_compat(from,to)
+      This is used in conjunction with the above macro
+      outside of macro context to paste whatever is
+      required to generate a compat symbol. */
+
+#ifndef M_PFX
+# error "M_PFX must be defined."
+#endif
+#ifndef M_LIT
+# error "M_LIT must be defined."
+#endif
+#ifndef M_MLIT
+# error "M_MLIT must be defined."
+#endif
+#ifndef M_SUF
+# error "M_SUF must be defined."
+#endif
+#ifndef FLOAT
+# error "FLOAT must be defined."
+#endif
+#ifndef CFLOAT
+# error "CFLOAT must be defined."
+#endif
+
+#define __M_CONCAT(a,b) a ## b
+#define __M_CONCATX(a,b) __M_CONCAT(a,b)
+
+#define M_NAN M_SUF (__nan) ("")
+#define M_MAX_EXP __M_CONCATX (M_PFX, _MAX_EXP)
+#define M_MIN __M_CONCATX (M_PFX, _MIN)
+#define M_MAX __M_CONCATX (M_PFX, _MAX)
+#define M_MANT_DIG __M_CONCATX (M_PFX, _MANT_DIG)
+#define M_HUGE_VAL (M_SUF (__builtin_huge_val) ())
+
+/* Helper macros for commonly used functions.  */
+#define M_COPYSIGN M_SUF (__copysign)
+#define M_FABS M_SUF (fabs)
+#define M_SINCOS M_SUF (__sincos)
+#define M_SCALBN M_SUF (__scalbn)
+#define M_LOG1P M_SUF (__log1p)
+
+#define M_ATAN2 M_SUF (__ieee754_atan2)
+#define M_COSH M_SUF (__ieee754_cosh)
+#define M_EXP M_SUF (__ieee754_exp)
+#define M_HYPOT M_SUF (__ieee754_hypot)
+#define M_LOG M_SUF (__ieee754_log)
+#define M_SINH M_SUF (__ieee754_sinh)
+#define M_SQRT M_SUF (__ieee754_sqrt)
+
+/* Needed to evaluate M_MANT_DIG below.  */
+#include <float.h>
+
+/* Use a special epsilon value for IBM long double
+   to avoid spurious overflows/underflows.  */
+#if M_MANT_DIG != 106
+# define M_EPSILON __M_CONCATX (M_PFX, _EPSILON)
+#else
+# define M_EPSILON M_LIT (0x1p-106)
+#endif
+
+/* Enable overloading of function name to assist reuse.  */
+#ifndef M_DECL_FUNC
+# define M_DECL_FUNC(f) M_SUF (f)
+#endif
+
+/* If the type does not declare special aliasing, use the default.  */
+#ifndef declare_mgen_alias
+# define declare_mgen_alias(from, to) weak_alias (M_SUF (from), M_SUF (to))
+#endif
+
+/* Do not generate anything for compat symbols by default.  */
+#ifndef M_LIBM_NEED_COMPAT
+# define M_LIBM_NEED_COMPAT(func) 0
+# define declare_mgen_libm_compat(from, to)
+#endif
+
+#endif /* _MATH_TYPE_MACROS */
diff --git a/sysdeps/ieee754/ldbl-opt/cabs.c b/sysdeps/ieee754/ldbl-opt/cabs.c
deleted file mode 100644
index a181de2..0000000
--- a/sysdeps/ieee754/ldbl-opt/cabs.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/cabs.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cabs, cabsl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cabsl.c b/sysdeps/ieee754/ldbl-opt/cabsl.c
deleted file mode 100644
index b861633..0000000
--- a/sysdeps/ieee754/ldbl-opt/cabsl.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/cabsl.c>
-long_double_symbol (libm, __cabsl, cabsl);
diff --git a/sysdeps/ieee754/ldbl-opt/carg.c b/sysdeps/ieee754/ldbl-opt/carg.c
deleted file mode 100644
index 2ed3581..0000000
--- a/sysdeps/ieee754/ldbl-opt/carg.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/carg.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __carg, cargl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cargl.c b/sysdeps/ieee754/ldbl-opt/cargl.c
deleted file mode 100644
index 952dc60..0000000
--- a/sysdeps/ieee754/ldbl-opt/cargl.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/cargl.c>
-long_double_symbol (libm, __cargl, cargl);
diff --git a/sysdeps/ieee754/ldbl-opt/cimag.c b/sysdeps/ieee754/ldbl-opt/cimag.c
deleted file mode 100644
index f805258..0000000
--- a/sysdeps/ieee754/ldbl-opt/cimag.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/cimag.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __cimag, cimagl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/cimagl.c b/sysdeps/ieee754/ldbl-opt/cimagl.c
deleted file mode 100644
index 112365e..0000000
--- a/sysdeps/ieee754/ldbl-opt/cimagl.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/cimagl.c>
-long_double_symbol (libm, __cimagl, cimagl);
diff --git a/sysdeps/ieee754/ldbl-opt/conj.c b/sysdeps/ieee754/ldbl-opt/conj.c
deleted file mode 100644
index e4edade..0000000
--- a/sysdeps/ieee754/ldbl-opt/conj.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/conj.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __conj, conjl, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/conjl.c b/sysdeps/ieee754/ldbl-opt/conjl.c
deleted file mode 100644
index c98e0ed..0000000
--- a/sysdeps/ieee754/ldbl-opt/conjl.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/conjl.c>
-long_double_symbol (libm, __conjl, conjl);
diff --git a/sysdeps/ieee754/ldbl-opt/creal.c b/sysdeps/ieee754/ldbl-opt/creal.c
deleted file mode 100644
index 0d1c93e..0000000
--- a/sysdeps/ieee754/ldbl-opt/creal.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-#include <math_ldbl_opt.h>
-#include <math/creal.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __creal, creall, GLIBC_2_1);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/creall.c b/sysdeps/ieee754/ldbl-opt/creall.c
deleted file mode 100644
index 68fedd4..0000000
--- a/sysdeps/ieee754/ldbl-opt/creall.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/creall.c>
-long_double_symbol (libm, __creall, creall);
diff --git a/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h b/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
new file mode 100644
index 0000000..8cb5694
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
@@ -0,0 +1,58 @@
+/* Overrides for ldbl-opt versioning for double types.
+   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/>.  */
+
+#ifndef _MATH_TYPE_MACROS_DOUBLE
+
+#include <math_ldbl_opt.h>
+
+#define LDOUBLE_cabsl_libm_version GLIBC_2_1
+#define LDOUBLE_cargl_libm_version GLIBC_2_1
+#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
+#define LDOUBLE_casinl_libm_version GLIBC_2_1
+#define LDOUBLE_csinl_libm_version GLIBC_2_1
+#define LDOUBLE_casinhl_libm_version GLIBC_2_1
+#define LDOUBLE_csinhl_libm_version GLIBC_2_1
+#define LDOUBLE_catanl_libm_version GLIBC_2_1
+#define LDOUBLE_catanhl_libm_version GLIBC_2_1
+#define LDOUBLE_ctanl_libm_version GLIBC_2_1
+#define LDOUBLE_ctanhl_libm_version GLIBC_2_1
+#define LDOUBLE_cexpl_libm_version GLIBC_2_1
+#define LDOUBLE_clogl_libm_version GLIBC_2_1
+#define LDOUBLE_cprojl_libm_version GLIBC_2_1
+#define LDOUBLE_csqrtl_libm_version GLIBC_2_1
+#define LDOUBLE_cpowl_libm_version GLIBC_2_1
+#define LDOUBLE_clog10l_libm_version GLIBC_2_1
+#define LDOUBLE___clog10l_libm_version GLIBC_2_1
+
+/* Define compat symbols for long double on platforms
+   where it was not always a distinct type.  */
+#define M_LIBM_NEED_COMPAT(f) \
+  LONG_DOUBLE_COMPAT (libm, LDOUBLE_ ## f ## l_libm_version)
+
+#define declare_mgen_libm_compat(from, to)	      \
+  compat_symbol (libm, from, to ## l,		      \
+		 LDOUBLE_ ## to ## l_libm_version);
+
+#include_next <math-type-macros-double.h>
+#endif
diff --git a/math/carg.c b/sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
similarity index 63%
rename from math/carg.c
rename to sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
index 61f1e0d..d2af4bb 100644
--- a/math/carg.c
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
@@ -1,7 +1,6 @@
-/* Compute argument of complex double value.
-   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+/* Overrides for ldbl-opt versioning for long double types.
+   Copyright (C) 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
@@ -17,16 +16,14 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <complex.h>
-#include <math.h>
+#ifndef _MATH_TYPE_MACROS_LDOUBLE
 
-double
-__carg (__complex__ double x)
-{
-  return __atan2 (__imag__ x, __real__ x);
-}
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
+#include <math_ldbl_opt.h>
+
+/* Use properly versioned symbols for long double on platforms where
+   it was not always a distinct type.  */
+#define declare_mgen_alias(from, to) \
+  long_double_symbol (libm, from ## l, to ## l);
+
+#include_next <math-type-macros-ldouble.h>
 #endif
-- 
2.4.11


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

* Re: [PATCHv2 03/11] Support for type-generic libm function implementations libm
  2016-08-12 17:27                                 ` Paul E. Murphy
@ 2016-08-16 18:00                                   ` Joseph Myers
  0 siblings, 0 replies; 53+ messages in thread
From: Joseph Myers @ 2016-08-16 18:00 UTC (permalink / raw)
  To: Paul E. Murphy; +Cc: libc-alpha, Adhemerval Zanella

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

> On 08/12/2016 11:41 AM, Joseph Myers wrote:
> > On Thu, 11 Aug 2016, Paul E. Murphy wrote:
> > 
> >> +generated += $(addsuffix .c,$(call type-foreach,$(gen-libm-calls:%=%$(s)))) \
> > 
> > Where does $(s) come from?
> 
> It doesn't, and is bad refactoring on my part.  Thanks for catching 
> that.  Fixed via removing the unnecessary substitution.

This patch version is OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

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

Thread overview: 53+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-01 20:14 [PATCHv2 00/11] Generate Complex functions from a common template Paul E. Murphy
2016-06-30 22:20 ` [PATCH 0/6] " Paul E. Murphy
2016-06-30 22:21   ` [PATCH 5/6] Convert _Complex tangent functions to generated code Paul E. Murphy
2016-06-30 22:21   ` [PATCH 3/6] Convert _Complex cosine " Paul E. Murphy
2016-06-30 22:36     ` Joseph Myers
2016-07-01  4:39       ` Paul E. Murphy
2016-08-03 20:12     ` Adhemerval Zanella
2016-08-03 21:18       ` Joseph Myers
2016-06-30 22:21   ` [PATCH 1/6] Refactor part of math Makefile Paul E. Murphy
2016-06-30 22:21   ` [PATCH 2/6] Support for type-generic libm function implementations libm Paul E. Murphy
2016-08-03 20:10     ` Adhemerval Zanella
2016-06-30 22:21   ` [PATCH 6/6] Convert remaining complex function to generated files Paul E. Murphy
2016-06-30 22:21   ` [PATCH 4/6] Convert _Complex sine functions to generated code Paul E. Murphy
2016-06-30 22:32   ` [PATCH 0/6] Generate Complex functions from a common template Joseph Myers
2016-07-01  3:43     ` Paul E. Murphy
2016-07-01 16:14       ` Joseph Myers
2016-07-01  9:58   ` Pedro Alves
2016-07-01 15:11     ` Paul E. Murphy
2016-07-01 15:15       ` Zack Weinberg
2016-07-01 15:47         ` Paul E. Murphy
2016-07-01 20:14   ` [PATCHv2 09/11] Convert _Complex tangent functions to generated code Paul E. Murphy
2016-07-01 20:14   ` [PATCHv2 02/11] Unify drift between _Complex function type variants Paul E. Murphy
2016-08-02 21:34     ` Joseph Myers
2016-08-03 17:14     ` Paul E. Murphy
2016-07-01 20:14   ` [PATCHv2 07/11] Convert _Complex sine functions to generated code Paul E. Murphy
2016-07-01 20:14   ` [PATCHv2 06/11] Prepare to convert _Complex sine functions Paul E. Murphy
2016-07-01 20:14   ` [PATCHv2 08/11] Prepare to convert _Complex tangent functions Paul E. Murphy
2016-07-01 20:14   ` [PATCHv2 05/11] Convert _Complex cosine functions to generated code Paul E. Murphy
2016-07-01 20:14   ` [PATCHv2 01/11] Refactor part of math Makefile Paul E. Murphy
2016-08-02 21:34     ` Joseph Myers
2016-08-03 17:13       ` Paul E. Murphy
2016-07-01 20:14   ` [PATCHv2 10/11] Prepare to convert remaining _Complex functions Paul E. Murphy
2016-07-01 20:14   ` [PATCHv2 03/11] Support for type-generic libm function implementations libm Paul E. Murphy
2016-08-02 21:53     ` Joseph Myers
2016-08-02 23:13       ` Paul E. Murphy
2016-08-04  1:49         ` Paul E. Murphy
2016-08-04 16:43           ` Joseph Myers
2016-08-05 14:43             ` Paul E. Murphy
2016-08-10 15:54               ` Joseph Myers
2016-08-10 16:31                 ` Paul E. Murphy
2016-08-10 16:40                   ` Joseph Myers
2016-08-10 21:50                     ` Paul E. Murphy
2016-08-10 22:06                       ` Joseph Myers
2016-08-11  0:39                         ` Paul E. Murphy
2016-08-11  1:23                           ` Joseph Myers
2016-08-11 14:43                             ` Paul E. Murphy
2016-08-12 16:41                               ` Joseph Myers
2016-08-12 17:27                                 ` Paul E. Murphy
2016-08-16 18:00                                   ` Joseph Myers
2016-08-04 17:03           ` Joseph Myers
2016-07-01 20:15   ` [PATCHv2 11/11] Convert remaining complex function to generated files Paul E. Murphy
2016-07-01 20:15   ` [PATCHv2 04/11] Prepare to convert _Complex cosine functions Paul E. Murphy
2016-08-02 14:37 ` [Ping] [PATCHv2 00/11] Generate Complex functions from a common template 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).