[PATCHv2 00/12] Introduce ieee128 symbols and redirections

classic Classic list List threaded Threaded
41 messages Options
123
Reply | Threaded
Open this post in threaded view
|

[PATCHv2 00/12] Introduce ieee128 symbols and redirections

Tulio Magno Quites Machado Filho-2
Changes since v1:

 - Reordered the patch series: the first patches are generic, while the last
   ones affect only ldbl-128ibm-compat.
 - Added a patch to fix bug #23294.
 - Removed the symbols for __f64x*ieee128.
 - Added symbols for narrow functions __f32*ieee128 and __f64*ieee128.
 - Redirected narrow functions to __f*ieee128
 - Stopped exporting internal functions __gamma_productieee128,
   __lgamma_negieee128, __lgamma_productieee128 and __x2y2m1ieee128;
 - Splitted both patches for scalb and significad in 2: 1 patch adding just
   the template and another one with the ldbl-128ibm-compat changes.
 - Replaced all generic implementations of w_scalb, w_scalb_compat, e_scalb
   and s_significand with templates.
 - Replaced the patch for __dremieee128 and __gamaieee128 with just macros
   in math/math.h.
 - Reworked completely the math-finite.h refactoring.  It's now reusing
   math/bits/mathcalls.h.  It also identifies the fix to bug #23292.

Gabriel F. T. Gomes (1):
  ldbl-128ibm-compat: Provide nexttoward functions

Rajalakshmi Srinivasaraghavan (1):
  ldbl-128ibm-compat: Redirect complex math functions

Tulio Magno Quites Machado Filho (10):
  Undefine redirections after long double definition on __LDBL_COMPAT
    [BZ #23294]
  Move declare_mgen_finite_alias definition
  Add a generic scalb implementation
  Add a generic significand implementation
  Refactor math/bits/math-finite.h, reusing math/bits/mathcalls.h [BZ
    #23292]
  ldbl-128ibm-compat: Create libm-alias-float128.h
  ldbl-128ibm-compat: Provide a scalb implementation
  ldbl-128ibm-compat: Provide a significand implementation
  ldbl-128ibm-compat: Redirect long double functions to f128/ieee128
    functions
  ldbl-128ibm-compat: Provide ieee128 symbols to narrow functions

 include/math.h                                     |  12 +-
 math/Makefile                                      |  12 +-
 math/bits/math-finite.h                            | 160 ++----
 math/bits/mathcalls-helper-functions.h             |  18 +-
 math/bits/mathcalls.h                              |  62 +--
 math/complex.h                                     |  29 +-
 math/e_exp2_template.c                             |   7 -
 math/{e_scalb.c => e_scalb_template.c}             |  32 +-
 math/e_scalbf.c                                    |  54 --
 math/e_scalbl.c                                    |  54 --
 math/math-narrow.h                                 |  10 +
 math/math.h                                        | 548 ++++++++++++---------
 math/s_significand.c                               |  34 --
 math/s_significand_template.c                      |  33 ++
 math/s_significandf.c                              |  27 -
 math/s_significandl.c                              |  34 --
 ...{w_scalb_compat.c => w_scalb_compat_template.c} |  36 +-
 math/{w_scalbf_compat.c => w_scalb_template.c}     |  54 +-
 math/w_scalbl_compat.c                             |  81 ---
 sysdeps/generic/math-type-macros-double.h          |   1 +
 sysdeps/generic/math-type-macros-float.h           |   1 +
 sysdeps/generic/math-type-macros-ldouble.h         |   1 +
 sysdeps/generic/math-type-macros.h                 |  15 +
 sysdeps/ieee754/float128/w_scalbf128.c             |   1 +
 sysdeps/ieee754/float128/w_scalbf128_compat.c      |   1 +
 sysdeps/ieee754/ldbl-128ibm-compat/Versions        | 127 +++++
 sysdeps/ieee754/ldbl-128ibm-compat/e_scalbf128.c   |  21 +
 .../ldbl-128ibm-compat/libm-alias-float128.h       |  64 +++
 .../ieee754/ldbl-128ibm-compat/s_nextafterf128.c   |  20 +
 .../ieee754/ldbl-128ibm-compat/s_nexttowardf128.c  |  38 ++
 .../ieee754/ldbl-128ibm-compat/s_significandf128.c |  25 +
 sysdeps/ieee754/ldbl-128ibm-compat/w_scalbf128.c   |  27 +
 sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h     |   6 +-
 sysdeps/ieee754/ldbl-opt/s_significand.c           |   5 -
 sysdeps/ieee754/ldbl-opt/s_significandl.c          |   5 -
 sysdeps/ieee754/ldbl-opt/w_scalb_compat.c          |   5 -
 sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c         |   5 -
 37 files changed, 868 insertions(+), 797 deletions(-)
 rename math/{e_scalb.c => e_scalb_template.c} (64%)
 delete mode 100644 math/e_scalbf.c
 delete mode 100644 math/e_scalbl.c
 delete mode 100644 math/s_significand.c
 create mode 100644 math/s_significand_template.c
 delete mode 100644 math/s_significandf.c
 delete mode 100644 math/s_significandl.c
 rename math/{w_scalb_compat.c => w_scalb_compat_template.c} (69%)
 rename math/{w_scalbf_compat.c => w_scalb_template.c} (53%)
 delete mode 100644 math/w_scalbl_compat.c
 create mode 100644 sysdeps/ieee754/float128/w_scalbf128.c
 create mode 100644 sysdeps/ieee754/float128/w_scalbf128_compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/Versions
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/e_scalbf128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/libm-alias-float128.h
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/s_nextafterf128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/s_nexttowardf128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/s_significandf128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/w_scalbf128.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_significand.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_significandl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/w_scalb_compat.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c

--
2.14.4

Reply | Threaded
Open this post in threaded view
|

[PATCH 01/12] Undefine redirections after long double definition on __LDBL_COMPAT [BZ #23294]

Tulio Magno Quites Machado Filho-2
After defining the long double redirections to double, __MATHDECL_1 has
to be redefined to its previous state in order to avoid redirecting all
subsequent types.

2018-06-19  Tulio Magno Quites Machado Filho  <[hidden email]>

        [BZ #23294]
        * math/complex.h (__MATHDECL_1_IMPL): New macro.
        [__LDBL_COMPAT](__MATHDECL_1): Redefine as __MATHDECL_1_IMPL
        after redirection.
        * math/math.h (__MATHDECL_1_IMPL, __MATHREDIR): New macros.
        [__LDBL_COMPAT](__MATHDECL_2): Removed.
        [__LDBL_COMPAT](__MATHDECL_1): Redefine as __MATHDECL_1_IMPL
        after redirection.

Signed-off-by: Tulio Magno Quites Machado Filho <[hidden email]>
---
 math/complex.h | 10 +++++++++-
 math/math.h    | 18 +++++++++++++-----
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/math/complex.h b/math/complex.h
index 544e7acd82..40cf8e0705 100644
--- a/math/complex.h
+++ b/math/complex.h
@@ -98,8 +98,10 @@ __BEGIN_DECLS
 #define __MATHDECL(type, function, args) \
   __MATHDECL_1(type, function, args); \
   __MATHDECL_1(type, __CONCAT(__,function), args)
-#define __MATHDECL_1(type, function, args) \
+#define __MATHDECL_1_IMPL(type, function, args) \
   extern type __MATH_PRECNAME(function) args __THROW
+#define __MATHDECL_1(type, function, args) \
+  __MATHDECL_1_IMPL(type, function, args)
 
 #define _Mdouble_ double
 #define __MATH_PRECNAME(name) name
@@ -127,6 +129,11 @@ __BEGIN_DECLS
 # define _Mdouble_ long double
 # define __MATH_PRECNAME(name) name##l
 # include <bits/cmathcalls.h>
+# if defined __LDBL_COMPAT
+#  undef __MATHDECL_1
+#  define __MATHDECL_1(type, function, args) \
+  __MATHDECL_1_IMPL(type, function, args)
+# endif
 #endif
 #undef _Mdouble_
 #undef __MATH_PRECNAME
@@ -215,6 +222,7 @@ __BEGIN_DECLS
 # undef _Mdouble_complex_
 #endif
 
+#undef __MATHDECL_1_IMPL
 #undef __MATHDECL_1
 #undef __MATHDECL
 #undef __MATHCALL
diff --git a/math/math.h b/math/math.h
index ddee4e4083..998d3042c5 100644
--- a/math/math.h
+++ b/math/math.h
@@ -279,8 +279,13 @@ enum
 #define __MATHDECLX(type, function,suffix, args, attrib) \
   __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
   __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib)
-#define __MATHDECL_1(type, function,suffix, args) \
+#define __MATHDECL_1_IMPL(type, function, suffix, args) \
   extern type __MATH_PRECNAME(function,suffix) args __THROW
+#define __MATHDECL_1(type, function, suffix, args) \
+  __MATHDECL_1_IMPL(type, function, suffix, args)
+
+#define __MATHREDIR(type, function, suffix, args, to) \
+  extern type __REDIRECT_NTH (__MATH_PRECNAME (function, suffix), args, to)
 
 #define _Mdouble_ double
 #define __MATH_PRECNAME(name,r) __CONCAT(name,r)
@@ -331,11 +336,8 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #   endif
 
 #   undef __MATHDECL_1
-#   define __MATHDECL_2(type, function,suffix, args, alias) \
-  extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \
-     args, alias)
 #   define __MATHDECL_1(type, function,suffix, args) \
-  __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix))
+  __MATHREDIR(type, function, suffix, args, __CONCAT(function,suffix))
 #  endif
 
 /* Include the file of declarations again, this time using `long double'
@@ -353,6 +355,11 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #  undef __MATH_DECLARING_DOUBLE
 #  undef __MATH_DECLARING_FLOATN
 
+#  if defined __LDBL_COMPAT
+#   undef __MATHDECL_1
+#   define __MATHDECL_1(type, function, suffix, args) \
+  __MATHDECL_1_IMPL(type, function, suffix, args)
+#  endif
 # endif /* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */
 
 #endif /* Use ISO C99.  */
@@ -479,6 +486,7 @@ extern long double __REDIRECT_NTH (nexttowardl,
 # undef __MATH_DECLARING_FLOATN
 #endif /* __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC).  */
 
+#undef __MATHDECL_1_IMPL
 #undef __MATHDECL_1
 #undef __MATHDECL
 #undef __MATHCALL
--
2.14.4

Reply | Threaded
Open this post in threaded view
|

[PATCH 02/12] Move declare_mgen_finite_alias definition

Tulio Magno Quites Machado Filho-2
In reply to this post by Tulio Magno Quites Machado Filho-2
Move declare_mgen_finite_alias, declare_mgen_finite_alias_s and
declare_mgen_finite_alias_x to a shared place in order to reuse them in
other files that also declare _finite aliases.

2018-06-19  Tulio Magno Quites Machado Filho  <[hidden email]>

        * math/e_exp2_template.c (declare_mgen_finite_alias,
        declare_mgen_finite_alias_s, declare_mgen_finite_alias_x): Move to...
        * sysdeps/generic/math-type-macros.h (declare_mgen_finite_alias,
        declare_mgen_finite_alias_s, declare_mgen_finite_alias_x): ... here.

Signed-off-by: Tulio Magno Quites Machado Filho <[hidden email]>
---
 math/e_exp2_template.c             |  7 -------
 sysdeps/generic/math-type-macros.h | 15 +++++++++++++++
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/math/e_exp2_template.c b/math/e_exp2_template.c
index 30ed4af49b..19f9780b05 100644
--- a/math/e_exp2_template.c
+++ b/math/e_exp2_template.c
@@ -21,13 +21,6 @@
 #include <math-underflow.h>
 #include <float.h>
 
-#define declare_mgen_finite_alias_x(from, to) \
- strong_alias (from, to ## _finite)
-#define declare_mgen_finite_alias_s(from,to) \
- declare_mgen_finite_alias_x (from, to)
-#define declare_mgen_finite_alias(from, to) \
- declare_mgen_finite_alias_s (M_SUF (from), M_SUF (to))
-
 FLOAT
 M_DECL_FUNC (__ieee754_exp2) (FLOAT x)
 {
diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
index 0e8ef16d7a..5250815253 100644
--- a/sysdeps/generic/math-type-macros.h
+++ b/sysdeps/generic/math-type-macros.h
@@ -74,6 +74,21 @@
 # error "SET_NAN_PAYLOAD must be defined."
 #endif
 
+#ifndef declare_mgen_finite_alias_x
+#define declare_mgen_finite_alias_x(from, to) \
+  strong_alias (from, to ## _finite)
+#endif
+
+#ifndef declare_mgen_finite_alias_s
+# define declare_mgen_finite_alias_s(from,to) \
+  declare_mgen_finite_alias_x (from, to)
+#endif
+
+#ifndef declare_mgen_finite_alias
+# define declare_mgen_finite_alias(from, to) \
+  declare_mgen_finite_alias_s (M_SUF (from), M_SUF (to))
+#endif
+
 #define __M_CONCAT(a,b) a ## b
 #define __M_CONCATX(a,b) __M_CONCAT(a,b)
 
--
2.14.4

Reply | Threaded
Open this post in threaded view
|

[PATCH 03/12] Add a generic scalb implementation

Tulio Magno Quites Machado Filho-2
In reply to this post by Tulio Magno Quites Machado Filho-2
Create templates for e_scabl, w_scalb and w_scalb_compat.

2018-06-19  Tulio Magno Quites Machado Filho  <[hidden email]>

        * math/Makefile (libm-calls): Move e_scalbF to...
        (gen-libm-calls): ... here and add w_scalbF_compat.
        * math/e_scalb.c: Removed.
        * math/e_scalbf.c: Removed.
        * math/e_scalbl.c: Removed.
        * math/w_scalb_compat.c: Removed.
        * math/w_scalbf_compat.c: Removed.
        * math/e_scalb_template.c: New file.
        * math/w_scalb_compat_template.c: New file.
        * math/w_scalb_template.c: New file.
        * math/w_scalbl_compat.c: Removed.
        * sysdeps/generic/math-type-macros-double.h: Define M_K_STANDARD.
        * sysdeps/generic/math-type-macros-float.h: Likewise.
        * sysdeps/generic/math-type-macros-ldouble.h: Likewise.
        * sysdeps/ieee754/float128/w_scalbf128.c: New file without contents.
        * sysdeps/ieee754/float128/w_scalbf128_compat.c: Likewise.
        * sysdeps/ieee754/ldbl-opt/w_scalb_compat.c: Removed.
        * sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c: Removed.

Signed-off-by: Tulio Magno Quites Machado Filho <[hidden email]>
---
 math/Makefile                                      |  7 +-
 math/{e_scalb.c => e_scalb_template.c}             | 32 ++++-----
 math/e_scalbf.c                                    | 54 ---------------
 math/e_scalbl.c                                    | 54 ---------------
 ...{w_scalb_compat.c => w_scalb_compat_template.c} | 36 ++++------
 math/{w_scalbf_compat.c => w_scalb_template.c}     | 54 +++++----------
 math/w_scalbl_compat.c                             | 81 ----------------------
 sysdeps/generic/math-type-macros-double.h          |  1 +
 sysdeps/generic/math-type-macros-float.h           |  1 +
 sysdeps/generic/math-type-macros-ldouble.h         |  1 +
 sysdeps/ieee754/float128/w_scalbf128.c             |  1 +
 sysdeps/ieee754/float128/w_scalbf128_compat.c      |  1 +
 sysdeps/ieee754/ldbl-opt/w_scalb_compat.c          |  5 --
 sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c         |  5 --
 14 files changed, 56 insertions(+), 277 deletions(-)
 rename math/{e_scalb.c => e_scalb_template.c} (64%)
 delete mode 100644 math/e_scalbf.c
 delete mode 100644 math/e_scalbl.c
 rename math/{w_scalb_compat.c => w_scalb_compat_template.c} (69%)
 rename math/{w_scalbf_compat.c => w_scalb_template.c} (53%)
 delete mode 100644 math/w_scalbl_compat.c
 create mode 100644 sysdeps/ieee754/float128/w_scalbf128.c
 create mode 100644 sysdeps/ieee754/float128/w_scalbf128_compat.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/w_scalb_compat.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c

diff --git a/math/Makefile b/math/Makefile
index 335b1fb197..e5d9ab7013 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -48,7 +48,7 @@ libm-support = s_lib_version s_matherr s_signgam \
 
 # Wrappers for these functions generated per type using a file named
 # <func>_template.c and the appropriate math-type-macros-<TYPE>.h.
-gen-libm-calls = cargF conjF cimagF crealF cabsF s_cacosF  \
+gen-libm-calls = cargF conjF cimagF crealF cabsF e_scalbF s_cacosF  \
          s_cacoshF s_ccosF s_ccoshF s_casinF s_csinF s_casinhF  \
  k_casinhF s_csinhF k_casinhF s_csinhF s_catanhF s_catanF \
  s_ctanF s_ctanhF s_cexpF s_clogF s_cprojF s_csqrtF  \
@@ -57,13 +57,14 @@ gen-libm-calls = cargF conjF cimagF crealF cabsF s_cacosF  \
  w_log1pF w_scalblnF s_fmaxmagF s_fminmagF w_acosF  \
  w_acoshF w_asinF w_atan2F w_atanhF w_coshF w_exp10F  \
  w_exp2F w_fmodF w_hypotF w_j0F w_j1F w_jnF w_logF  \
- w_log10F w_log2F w_powF w_remainderF w_sinhF w_sqrtF  \
+ w_log10F w_log2F w_powF w_remainderF w_scalbF  \
+ w_scalbF_compat w_sinhF w_sqrtF  \
  w_tgammaF w_lgammaF w_lgammaF_r w_expF e_exp2F
 
 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_rem_pio2F e_remainderF e_sinhF e_sqrtF e_gammaF_r  \
  e_ilogbF  \
  k_cosF k_sinF k_tanF s_asinhF s_atanF s_cbrtF  \
  s_ceilF s_cosF s_erfF s_expm1F s_fabsF  \
diff --git a/math/e_scalb.c b/math/e_scalb_template.c
similarity index 64%
rename from math/e_scalb.c
rename to math/e_scalb_template.c
index 96c3579aad..02663424a7 100644
--- a/math/e_scalb.c
+++ b/math/e_scalb_template.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 2011-2018 Free Software Foundation, Inc.
+/* Multiply by integral power of radix.
+   Copyright (C) 2018 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <[hidden email]>, 2011.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -19,36 +19,36 @@
 #include <math.h>
 #include <math_private.h>
 
-
-static double
+static FLOAT
 __attribute__ ((noinline))
-invalid_fn (double x, double fn)
+invalid_fn (FLOAT x, FLOAT fn)
 {
-  if (__rint (fn) != fn)
+  if (M_SUF (__rint) (fn) != fn)
     return (fn - fn) / (fn - fn);
-  else if (fn > 65000.0)
-    return __scalbn (x, 65000);
+  else if (fn > M_LIT (65000.0))
+    return M_SUF (__scalbn) (x, 65000);
   else
-    return __scalbn (x,-65000);
+    return M_SUF (__scalbn) (x,-65000);
 }
 
 
-double
-__ieee754_scalb (double x, double fn)
+FLOAT
+M_DECL_FUNC (__ieee754_scalb) (FLOAT x, FLOAT fn)
 {
   if (__glibc_unlikely (isnan (x)))
     return x * fn;
   if (__glibc_unlikely (!isfinite (fn)))
     {
-      if (isnan (fn) || fn > 0.0)
+      if (isnan (fn) || fn > M_LIT (0.0))
  return x * fn;
-      if (x == 0.0)
+      if (x == M_LIT (0.0))
  return x;
       return x / -fn;
     }
-  if (__glibc_unlikely (fabs (fn) >= 0x1p31 || (double) (int) fn != fn))
+  if (__glibc_unlikely (M_FABS (fn) >= M_LIT (0x1p31)
+ || (FLOAT) (int) fn != fn))
     return invalid_fn (x, fn);
 
-  return __scalbn (x, (int) fn);
+  return M_SCALBN (x, (int) fn);
 }
-strong_alias (__ieee754_scalb, __scalb_finite)
+declare_mgen_finite_alias (__ieee754_scalb, __scalb)
diff --git a/math/e_scalbf.c b/math/e_scalbf.c
deleted file mode 100644
index 23b38a95de..0000000000
--- a/math/e_scalbf.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 2011-2018 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <[hidden email]>, 2011.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-#include <math_private.h>
-
-
-static float
-__attribute__ ((noinline))
-invalid_fn (float x, float fn)
-{
-  if (__rintf (fn) != fn)
-    return (fn - fn) / (fn - fn);
-  else if (fn > 65000.0f)
-    return __scalbnf (x, 65000);
-  else
-    return __scalbnf (x,-65000);
-}
-
-
-float
-__ieee754_scalbf (float x, float fn)
-{
-  if (__glibc_unlikely (isnan (x)))
-    return x * fn;
-  if (__glibc_unlikely (!isfinite (fn)))
-    {
-      if (isnan (fn) || fn > 0.0f)
- return x * fn;
-      if (x == 0.0f)
- return x;
-      return x / -fn;
-    }
-  if (__glibc_unlikely (fabsf (fn) >= 0x1p31f || (float) (int) fn != fn))
-    return invalid_fn (x, fn);
-
-  return __scalbnf (x, (int) fn);
-}
-strong_alias (__ieee754_scalbf, __scalbf_finite)
diff --git a/math/e_scalbl.c b/math/e_scalbl.c
deleted file mode 100644
index a677d06b9f..0000000000
--- a/math/e_scalbl.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 2011-2018 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <[hidden email]>, 2011.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-#include <math_private.h>
-
-
-static long double
-__attribute__ ((noinline))
-invalid_fn (long double x, long double fn)
-{
-  if (__rintl (fn) != fn)
-    return (fn - fn) / (fn - fn);
-  else if (fn > 65000.0L)
-    return __scalbnl (x, 65000);
-  else
-    return __scalbnl (x,-65000);
-}
-
-
-long double
-__ieee754_scalbl (long double x, long double fn)
-{
-  if (__glibc_unlikely (isnan (x)))
-    return x * fn;
-  if (__glibc_unlikely (!isfinite (fn)))
-    {
-      if (isnan (fn) || fn > 0.0L)
- return x * fn;
-      if (x == 0.0L)
- return x;
-      return x / -fn;
-    }
-  if (__glibc_unlikely (fabsl (fn) >= 0x1p31L || (long double) (int) fn != fn))
-    return invalid_fn (x, fn);
-
-  return __scalbnl (x, (int) fn);
-}
-strong_alias (__ieee754_scalbl, __scalbl_finite)
diff --git a/math/w_scalb_compat.c b/math/w_scalb_compat_template.c
similarity index 69%
rename from math/w_scalb_compat.c
rename to math/w_scalb_compat_template.c
index 5e57db4a9f..ba69aca017 100644
--- a/math/w_scalb_compat.c
+++ b/math/w_scalb_compat_template.c
@@ -1,6 +1,5 @@
-/* Copyright (C) 2011-2018 Free Software Foundation, Inc.
+/* Copyright (C) 2018 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <[hidden email]>, 2011.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -21,40 +20,37 @@
 #include <math_private.h>
 #include <math-svid-compat.h>
 
-
 #if LIBM_SVID_COMPAT
-static double
+
+static FLOAT
 __attribute__ ((noinline))
-sysv_scalb (double x, double fn)
+M_DECL_FUNC (sysv_scalb) (FLOAT x, FLOAT fn)
 {
-  double z = __ieee754_scalb (x, fn);
+  FLOAT z = M_SUF (__ieee754_scalb) (x, fn);
 
   if (__glibc_unlikely (isinf (z)))
     {
       if (isfinite (x))
- return __kernel_standard (x, fn, 32); /* scalb overflow */
+ return M_K_STANDARD (x, fn, 32); /* scalb overflow */
       else
  __set_errno (ERANGE);
     }
-  else if (__builtin_expect (z == 0.0, 0) && z != x)
-    return __kernel_standard (x, fn, 33); /* scalb underflow */
+  else if (__builtin_expect (z == M_LIT (0.0), 0) && z != x)
+    return M_K_STANDARD (x, fn, 33); /* scalb underflow */
 
   return z;
 }
-#endif
 
 
 /* Wrapper scalb */
-double
-__scalb (double x, double fn)
+FLOAT
+M_DECL_FUNC (__scalb) (FLOAT x, FLOAT fn)
 {
-#if LIBM_SVID_COMPAT
   if (__glibc_unlikely (_LIB_VERSION == _SVID_))
-    return sysv_scalb (x, fn);
+    return M_SUF (sysv_scalb) (x, fn);
   else
-#endif
     {
-      double z = __ieee754_scalb (x, fn);
+      FLOAT z = M_SUF (__ieee754_scalb) (x, fn);
 
       if (__glibc_unlikely (!isfinite (z) || z == 0.0))
  {
@@ -78,8 +74,6 @@ __scalb (double x, double fn)
       return z;
     }
 }
-weak_alias (__scalb, scalb)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__scalb, __scalbl)
-weak_alias (__scalb, scalbl)
-#endif
+declare_mgen_alias (__scalb, scalb);
+
+#endif /* __LIBM_SVID_COMPAT.  */
diff --git a/math/w_scalbf_compat.c b/math/w_scalb_template.c
similarity index 53%
rename from math/w_scalbf_compat.c
rename to math/w_scalb_template.c
index 7e35a66f43..b2aafcdf36 100644
--- a/math/w_scalbf_compat.c
+++ b/math/w_scalb_template.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 2011-2018 Free Software Foundation, Inc.
+/* Wrapper to set errno for scalb.
+   Copyright (C) 2018 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <[hidden email]>, 2011.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -16,47 +16,23 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+/* Only build wrappers from the templates for the types that define the macro
+   below.  This macro is set in math-type-macros-<type>.h in sysdeps/generic
+   for each floating-point type.  */
+#if __USE_WRAPPER_TEMPLATE
+
 #include <errno.h>
 #include <math.h>
 #include <math_private.h>
-#include <math-svid-compat.h>
-
 
-#if LIBM_SVID_COMPAT
-static float
-__attribute__ ((noinline))
-sysv_scalbf (float x, float fn)
+/* Wrapper scalb */
+FLOAT
+M_DECL_FUNC (__scalb) (FLOAT x, FLOAT fn)
 {
-  float z = __ieee754_scalbf (x, fn);
-
-  if (__glibc_unlikely (isinf (z)))
     {
-      if (isfinite (x))
- return __kernel_standard_f (x, fn, 132); /* scalb overflow */
-      else
- __set_errno (ERANGE);
-    }
-  else if (__builtin_expect (z == 0.0f, 0) && z != x)
-    return __kernel_standard_f (x, fn, 133); /* scalb underflow */
-
-  return z;
-}
-#endif
+      FLOAT z = M_SUF (__ieee754_scalb) (x, fn);
 
-
-/* Wrapper scalbf */
-float
-__scalbf (float x, float fn)
-{
-#if LIBM_SVID_COMPAT
-  if (__glibc_unlikely (_LIB_VERSION == _SVID_))
-    return sysv_scalbf (x, fn);
-  else
-#endif
-    {
-      float z = __ieee754_scalbf (x, fn);
-
-      if (__glibc_unlikely (!isfinite (z) || z == 0.0f))
+      if (__glibc_unlikely (!isfinite (z) || z == M_LIT (0.0)))
  {
   if (isnan (z))
     {
@@ -71,11 +47,13 @@ __scalbf (float x, float fn)
   else
     {
       /* z == 0.  */
-      if (x != 0.0f && !isinf (fn))
+      if (x != M_LIT (0.0) && !isinf (fn))
  __set_errno (ERANGE);
     }
  }
       return z;
     }
 }
-weak_alias (__scalbf, scalbf)
+declare_mgen_alias (__scalb, scalb);
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_scalbl_compat.c b/math/w_scalbl_compat.c
deleted file mode 100644
index 658b081f91..0000000000
--- a/math/w_scalbl_compat.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* Copyright (C) 2011-2018 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <[hidden email]>, 2011.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <math.h>
-#include <math_private.h>
-#include <math-svid-compat.h>
-
-
-#if LIBM_SVID_COMPAT
-static long double
-__attribute__ ((noinline))
-sysv_scalbl (long double x, long double fn)
-{
-  long double z = __ieee754_scalbl (x, fn);
-
-  if (__glibc_unlikely (isinf (z)))
-    {
-      if (isfinite (x))
- return __kernel_standard_l (x, fn, 232); /* scalb overflow */
-      else
- __set_errno (ERANGE);
-    }
-  else if (__builtin_expect (z == 0.0L, 0) && z != x)
-    return __kernel_standard_l (x, fn, 233); /* scalb underflow */
-
-  return z;
-}
-#endif
-
-
-/* Wrapper scalbl */
-long double
-__scalbl (long double x, long double fn)
-{
-#if LIBM_SVID_COMPAT
-  if (__glibc_unlikely (_LIB_VERSION == _SVID_))
-    return sysv_scalbl (x, fn);
-  else
-#endif
-    {
-      long double z = __ieee754_scalbl (x, fn);
-
-      if (__glibc_unlikely (!isfinite (z) || z == 0.0L))
- {
-  if (isnan (z))
-    {
-      if (!isnan (x) && !isnan (fn))
- __set_errno (EDOM);
-    }
-  else if (isinf (z))
-    {
-      if (!isinf (x) && !isinf (fn))
- __set_errno (ERANGE);
-    }
-  else
-    {
-      /* z == 0.  */
-      if (x != 0.0L && !isinf (fn))
- __set_errno (ERANGE);
-    }
- }
-      return z;
-    }
-}
-weak_alias (__scalbl, scalbl)
diff --git a/sysdeps/generic/math-type-macros-double.h b/sysdeps/generic/math-type-macros-double.h
index be5d94488f..dfd0919b71 100644
--- a/sysdeps/generic/math-type-macros-double.h
+++ b/sysdeps/generic/math-type-macros-double.h
@@ -26,6 +26,7 @@
 #define FLOAT double
 #define CFLOAT _Complex double
 #define M_STRTO_NAN __strtod_nan
+#define M_K_STANDARD __kernel_standard
 
 #include <libm-alias-double.h>
 #include <math-nan-payload-double.h>
diff --git a/sysdeps/generic/math-type-macros-float.h b/sysdeps/generic/math-type-macros-float.h
index 1f280950cd..72b30171fa 100644
--- a/sysdeps/generic/math-type-macros-float.h
+++ b/sysdeps/generic/math-type-macros-float.h
@@ -25,6 +25,7 @@
 #define FLOAT float
 #define CFLOAT _Complex float
 #define M_STRTO_NAN __strtof_nan
+#define M_K_STANDARD __kernel_standard_f
 
 /* Standard/GNU macro literals do not exist for the float type.  Use
    the double macro constants.  */
diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/sysdeps/generic/math-type-macros-ldouble.h
index 300dd18f94..ef0a1e5b99 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/sysdeps/generic/math-type-macros-ldouble.h
@@ -26,6 +26,7 @@
 #define FLOAT long double
 #define CFLOAT _Complex long double
 #define M_STRTO_NAN __strtold_nan
+#define M_K_STANDARD __kernel_standard_l
 
 #include <libm-alias-ldouble.h>
 #include <math-nan-payload-ldouble.h>
diff --git a/sysdeps/ieee754/float128/w_scalbf128.c b/sysdeps/ieee754/float128/w_scalbf128.c
new file mode 100644
index 0000000000..067b724164
--- /dev/null
+++ b/sysdeps/ieee754/float128/w_scalbf128.c
@@ -0,0 +1 @@
+/* Not defined for _FloatN types.  */
diff --git a/sysdeps/ieee754/float128/w_scalbf128_compat.c b/sysdeps/ieee754/float128/w_scalbf128_compat.c
new file mode 100644
index 0000000000..067b724164
--- /dev/null
+++ b/sysdeps/ieee754/float128/w_scalbf128_compat.c
@@ -0,0 +1 @@
+/* Not defined for _FloatN types.  */
diff --git a/sysdeps/ieee754/ldbl-opt/w_scalb_compat.c b/sysdeps/ieee754/ldbl-opt/w_scalb_compat.c
deleted file mode 100644
index f6d53a5ba5..0000000000
--- a/sysdeps/ieee754/ldbl-opt/w_scalb_compat.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <math_ldbl_opt.h>
-#include <math/w_scalb_compat.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
-compat_symbol (libm, __scalb, scalbl, GLIBC_2_0);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c b/sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c
deleted file mode 100644
index c8feb654a2..0000000000
--- a/sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <math_ldbl_opt.h>
-#undef weak_alias
-#define weak_alias(n,a)
-#include <math/w_scalbl_compat.c>
-long_double_symbol (libm, __scalbl, scalbl);
--
2.14.4

Reply | Threaded
Open this post in threaded view
|

[PATCH 04/12] Add a generic significand implementation

Tulio Magno Quites Machado Filho-2
In reply to this post by Tulio Magno Quites Machado Filho-2
Create a template for significand.

2018-06-19  Tulio Magno Quites Machado Filho  <[hidden email]>

        * math/Makefile (libm-calls): Move s_significandF to...
        (gen-libm-calls): ... here.
        * math/s_significand_template.c: New file.
        * math/s_significand.c: Removed.
        * math/s_significandf.c: Removed.
        * math/s_significandl.c: Removed.
        * sysdeps/ieee754/ldbl-opt/s_significand.c: Removed.
        * sysdeps/ieee754/ldbl-opt/s_significandl.c: Removed.

Signed-off-by: Tulio Magno Quites Machado Filho <[hidden email]>
---
 math/Makefile                             |  5 +++--
 math/s_significand.c                      | 34 -------------------------------
 math/s_significand_template.c             | 33 ++++++++++++++++++++++++++++++
 math/s_significandf.c                     | 27 ------------------------
 math/s_significandl.c                     | 34 -------------------------------
 sysdeps/ieee754/ldbl-opt/s_significand.c  |  5 -----
 sysdeps/ieee754/ldbl-opt/s_significandl.c |  5 -----
 7 files changed, 36 insertions(+), 107 deletions(-)
 delete mode 100644 math/s_significand.c
 create mode 100644 math/s_significand_template.c
 delete mode 100644 math/s_significandf.c
 delete mode 100644 math/s_significandl.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_significand.c
 delete mode 100644 sysdeps/ieee754/ldbl-opt/s_significandl.c

diff --git a/math/Makefile b/math/Makefile
index e5d9ab7013..291788b348 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -53,7 +53,8 @@ gen-libm-calls = cargF conjF cimagF crealF cabsF e_scalbF s_cacosF  \
  k_casinhF s_csinhF k_casinhF s_csinhF s_catanhF s_catanF \
  s_ctanF s_ctanhF s_cexpF s_clogF s_cprojF s_csqrtF  \
  s_cpowF s_clog10F s_fdimF s_nextdownF s_fmaxF s_fminF  \
- s_nanF s_iseqsigF s_canonicalizeF w_ilogbF w_llogbF  \
+ s_nanF s_iseqsigF s_canonicalizeF s_significandF  \
+ w_ilogbF w_llogbF  \
  w_log1pF w_scalblnF s_fmaxmagF s_fminmagF w_acosF  \
  w_acoshF w_asinF w_atan2F w_atanhF w_coshF w_exp10F  \
  w_exp2F w_fmodF w_hypotF w_j0F w_j1F w_jnF w_logF  \
@@ -70,7 +71,7 @@ libm-calls =  \
  s_ceilF s_cosF s_erfF s_expm1F s_fabsF  \
  s_floorF s_log1pF s_logbF  \
  s_nextafterF s_nexttowardF s_rintF s_scalblnF  \
- s_significandF s_sinF s_tanF s_tanhF  \
+ s_sinF s_tanF s_tanhF  \
  s_fpclassifyF s_truncF  \
  s_remquoF e_log2F s_roundF s_nearbyintF s_sincosF  \
  s_fmaF s_lrintF s_llrintF s_lroundF s_llroundF e_exp10F  \
diff --git a/math/s_significand.c b/math/s_significand.c
deleted file mode 100644
index 348bdcf6ad..0000000000
--- a/math/s_significand.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* @(#)s_signif.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_significand.c,v 1.6 1995/05/10 20:48:11 jtc Exp $";
-#endif
-
-/*
- * significand(x) computes just
- * scalb(x, (double) -ilogb(x)),
- * for exercising the fraction-part(F) IEEE 754-1985 test vector.
- */
-
-#include <math.h>
-#include <math_private.h>
-
-double __significand(double x)
-{
- return __ieee754_scalb(x,(double) -__ilogb(x));
-}
-weak_alias (__significand, significand)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__significand, __significandl)
-weak_alias (__significand, significandl)
-#endif
diff --git a/math/s_significand_template.c b/math/s_significand_template.c
new file mode 100644
index 0000000000..0c5ad8d14b
--- /dev/null
+++ b/math/s_significand_template.c
@@ -0,0 +1,33 @@
+/* Return the mantissa of a floating-point number.
+   Copyright (C) 2018 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/>.  */
+
+/*
+ * significand(x) computes just
+ * scalb(x, (FLOAT) - ilogb(x)),
+ * for exercising the fraction-part(F) IEEE 754-1985 test vector.
+ */
+
+#include <math.h>
+#include <math_private.h>
+
+FLOAT
+M_DECL_FUNC (__significand) (FLOAT x)
+{
+  return M_SUF (__ieee754_scalb) (x,(FLOAT) - M_SUF (__ilogb) (x));
+}
+declare_mgen_alias (__significand, significand)
diff --git a/math/s_significandf.c b/math/s_significandf.c
deleted file mode 100644
index 876e53932b..0000000000
--- a/math/s_significandf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* s_significandf.c -- float version of s_significand.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, [hidden email].
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_significandf.c,v 1.3 1995/05/10 20:48:13 jtc Exp $";
-#endif
-
-#include <math.h>
-#include <math_private.h>
-
-float __significandf(float x)
-{
- return __ieee754_scalbf(x,(float) -__ilogbf(x));
-}
-weak_alias (__significandf, significandf)
diff --git a/math/s_significandl.c b/math/s_significandl.c
deleted file mode 100644
index 0e3337b2fe..0000000000
--- a/math/s_significandl.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* s_significandl.c -- long double version of s_significand.c.
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, [hidden email].
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: $";
-#endif
-
-/*
- * significandl(x) computes just
- * scalbl(x, (long double) -ilogbl(x)),
- * for exercising the fraction-part(F) IEEE 754-1985 test vector.
- */
-
-#include <math.h>
-#include <math_private.h>
-
-long double __significandl(long double x)
-{
- return __ieee754_scalbl(x,(long double) -__ilogbl(x));
-}
-weak_alias (__significandl, significandl)
diff --git a/sysdeps/ieee754/ldbl-opt/s_significand.c b/sysdeps/ieee754/ldbl-opt/s_significand.c
deleted file mode 100644
index 5287c09066..0000000000
--- a/sysdeps/ieee754/ldbl-opt/s_significand.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <math_ldbl_opt.h>
-#include <math/s_significand.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
-compat_symbol (libm, __significand, significandl, GLIBC_2_0);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_significandl.c b/sysdeps/ieee754/ldbl-opt/s_significandl.c
deleted file mode 100644
index 9339b4780d..0000000000
--- a/sysdeps/ieee754/ldbl-opt/s_significandl.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <math_ldbl_opt.h>
-#undef weak_alias
-#define weak_alias(n,a)
-#include <math/s_significandl.c>
-long_double_symbol (libm, __significandl, significandl);
--
2.14.4

Reply | Threaded
Open this post in threaded view
|

[PATCH 05/12] Refactor math/bits/math-finite.h, reusing math/bits/mathcalls.h [BZ #23292]

Tulio Magno Quites Machado Filho-2
In reply to this post by Tulio Magno Quites Machado Filho-2
On a new enough compiler, redirecting the same function twice can cause
-Werror=pragmas errors.  This issue may appear when redirecting a
floating point function to a different ABI at the same time that finite
redirections are expected.

This patch removes all of the common redirections done in math-finite.h
in order to reuse mathcalls.h.  Prototypes and redirections are now
defined only once.  The finite functions are identified with macros
__MATHCALL_FINITE or __MATHCALL_VEC_FINITE.
When finite functions are not requested, the macros behave in the same
way as their non-finite peers, i.e. __MATHCALL and __MATHCALL_VEC.
However, when finite functions are requested, i.e.
__FINITE_MATH_ONLY__ > 0, they both redirect their functions via
__MATHREDIR, using __MATH_FINITE_NAME to set the name of the target
function.

In another change, math-finite.h inline functions are modified in order
to benefit from functions that have already been redirected.
Macro __REDIRTO_PUBLIC_F is used to reuse functions that are already
available in the API, e.g. lgammal is is an inline function that calls
__lgammal_r_finite, which has already been redirected via assembly to
__lgammaf128_r_finite.  The inline function could be directly redirected
to its respective f128 as it isn't guaranteed to be available in the API.

2018-06-19  Tulio Magno Quites Machado Filho  <[hidden email]>

        [BZ #23292]
        * math/bits/math-finite.h: Move most of the functions to
        bits/mathcalls.h.
        * math/bits/mathcalls.h: Use macros __MATHCALL_FINITE and
        __MATHCALL_VEC_FINITE to identify finite functions.
        * math/math.h (__MATH_FINITE_NAMEY, __MATH_FINITE_NAMEX,
        __MATH_FINITE_NAME_IMPL, __MATH_FINITE_NAME,
        __MATHCALL_VEC_FINITE, __MATHCALL_FINITE):
        New macros.
        [defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0]: Include
        bits/math-finite.h for double, float and long double earlier in
        order to use its functions from the math-finite.h of _FloatN types.

Signed-off-by: Tulio Magno Quites Machado Filho <[hidden email]>
---
 math/bits/math-finite.h | 160 ++++-------------
 math/bits/mathcalls.h   |  53 +++---
 math/math.h             | 466 +++++++++++++++++++++++++-----------------------
 3 files changed, 296 insertions(+), 383 deletions(-)

diff --git a/math/bits/math-finite.h b/math/bits/math-finite.h
index 0799fe7b29..7a23b234cc 100644
--- a/math/bits/math-finite.h
+++ b/math/bits/math-finite.h
@@ -20,96 +20,27 @@
 # error "Never use <bits/math-finite.h> directly; include <math.h> instead."
 #endif
 
-#define __REDIRFROM(...) __REDIRFROM_X(__VA_ARGS__)
+#define __REDIRFROM_F(...) __REDIRFROM_X(__VA_ARGS__)
 
-#define __REDIRTO(...) __REDIRTO_X(__VA_ARGS__)
+#define __REDIRTO_F(...) __REDIRTO_X(__VA_ARGS__)
 
-#define __MATH_REDIRCALL_X(from, args, to) \
-  extern _Mdouble_ __REDIRECT_NTH (from, args, to)
-#define __MATH_REDIRCALL(function, reentrant, args) \
-  __MATH_REDIRCALL_X \
-   (__REDIRFROM (function, reentrant), args, \
-    __REDIRTO (function, reentrant))
-#define __MATH_REDIRCALL_2(from, reentrant, args, to) \
-  __MATH_REDIRCALL_X \
-   (__REDIRFROM (from, reentrant), args, \
-    __REDIRTO (to, reentrant))
-
-#define __MATH_REDIRCALL_INTERNAL(function, reentrant, args) \
-  __MATH_REDIRCALL_X \
-   (__REDIRFROM (__CONCAT (__, function), \
- __CONCAT (reentrant, _finite)), \
-    args, __REDIRTO (function, _r))
-
-
-/* acos.  */
-__MATH_REDIRCALL (acos, , (_Mdouble_));
-
-#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
-/* acosh.  */
-__MATH_REDIRCALL (acosh, , (_Mdouble_));
-#endif
-
-/* asin.  */
-__MATH_REDIRCALL (asin, , (_Mdouble_));
-
-/* atan2.  */
-__MATH_REDIRCALL (atan2, , (_Mdouble_, _Mdouble_));
-
-#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
-/* atanh.  */
-__MATH_REDIRCALL (atanh, , (_Mdouble_));
-#endif
-
-/* cosh.  */
-__MATH_REDIRCALL (cosh, , (_Mdouble_));
-
-/* exp.  */
-__MATH_REDIRCALL (exp, , (_Mdouble_));
-
-#if __GLIBC_USE (IEC_60559_FUNCS_EXT)
-/* exp10.  */
-__MATH_REDIRCALL (exp10, , (_Mdouble_));
-#endif
-
-#ifdef __USE_ISOC99
-/* exp2.  */
-__MATH_REDIRCALL (exp2, , (_Mdouble_));
-#endif
-
-/* fmod.  */
-__MATH_REDIRCALL (fmod, , (_Mdouble_, _Mdouble_));
-
-#if defined __USE_XOPEN || defined __USE_ISOC99
-/* hypot.  */
-__MATH_REDIRCALL (hypot, , (_Mdouble_, _Mdouble_));
-#endif
+/* Redirects to a function that is part of the API.  */
+#define __REDIRTO_PUBLIC_F(...) __REDIRTO_PUBLIC_X(__VA_ARGS__)
 
-#if (__MATH_DECLARING_DOUBLE && (defined __USE_MISC || defined __USE_XOPEN)) \
-    || (!__MATH_DECLARING_DOUBLE && defined __USE_MISC)
-/* j0.  */
-__MATH_REDIRCALL (j0, , (_Mdouble_));
+#define __MATH_REDIR_X(type, from, args, to) \
+  extern type __REDIRECT_NTH (from, args, to)
 
-/* y0.  */
-__MATH_REDIRCALL (y0, , (_Mdouble_));
-
-/* j1.  */
-__MATH_REDIRCALL (j1, , (_Mdouble_));
-
-/* y1.  */
-__MATH_REDIRCALL (y1, , (_Mdouble_));
-
-/* jn.  */
-__MATH_REDIRCALL (jn, , (int, _Mdouble_));
+#define __MATH_REDIRCALL(function, reentrant, args) \
+  __MATH_REDIR_X (_Mdouble_, \
+  __REDIRFROM_F (function, reentrant), args, \
+  __REDIRTO_F (function, reentrant))
 
-/* yn.  */
-__MATH_REDIRCALL (yn, , (int, _Mdouble_));
-#endif
+#define __MATH_REDIRCALL_INTERNAL(function, reentrant, args) \
+  __MATH_REDIR_X (_Mdouble_, \
+  __REDIRFROM_F (__CONCAT (__, function), \
+ __CONCAT (reentrant, _finite)), \
+  args, __REDIRTO_F (function, _r))
 
-#ifdef __USE_MISC
-/* lgamma_r.  */
-__MATH_REDIRCALL (lgamma, _r, (_Mdouble_, int *));
-#endif
 
 /* Redirect __lgammal_r_finite to __lgamma_r_finite when __NO_LONG_DOUBLE_MATH
    is set and to itself otherwise.  It also redirects __lgamma_r_finite and
@@ -120,13 +51,13 @@ __MATH_REDIRCALL_INTERNAL (lgamma, _r, (_Mdouble_, int *));
      && defined __extern_always_inline)
 /* lgamma.  */
 __extern_always_inline _Mdouble_
-__NTH (__REDIRFROM (lgamma, ) (_Mdouble_ __d))
+__NTH (__REDIRFROM_F (lgamma, ) (_Mdouble_ __d))
 {
 # if defined __USE_MISC || defined __USE_XOPEN
-  return __REDIRTO (lgamma, _r) (__d, &signgam);
+  return __REDIRTO_PUBLIC_F (lgamma, _r) (__d, &signgam);
 # else
   int __local_signgam = 0;
-  return __REDIRTO (lgamma, _r) (__d, &__local_signgam);
+  return __REDIRTO_PUBLIC_F (lgamma, _r) (__d, &__local_signgam);
 # endif
 }
 #endif
@@ -135,63 +66,32 @@ __NTH (__REDIRFROM (lgamma, ) (_Mdouble_ __d))
      && defined __extern_always_inline) && !__MATH_DECLARING_FLOATN
 /* gamma.  */
 __extern_always_inline _Mdouble_
-__NTH (__REDIRFROM (gamma, ) (_Mdouble_ __d))
+__NTH (__REDIRFROM_F (gamma, ) (_Mdouble_ __d))
 {
-  return __REDIRTO (lgamma, _r) (__d, &signgam);
+  return __REDIRTO_PUBLIC_F (lgamma, _r) (__d, &signgam);
 }
 #endif
 
-/* log.  */
-__MATH_REDIRCALL (log, , (_Mdouble_));
-
-/* log10.  */
-__MATH_REDIRCALL (log10, , (_Mdouble_));
-
-#ifdef __USE_ISOC99
-/* log2.  */
-__MATH_REDIRCALL (log2, , (_Mdouble_));
-#endif
-
-/* pow.  */
-__MATH_REDIRCALL (pow, , (_Mdouble_, _Mdouble_));
-
-#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
-/* remainder.  */
-__MATH_REDIRCALL (remainder, , (_Mdouble_, _Mdouble_));
-#endif
-
-#if ((__MATH_DECLARING_DOUBLE \
-      && (defined __USE_MISC \
-  || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8))) \
-     || (!defined __MATH_DECLARE_LDOUBLE && defined __USE_MISC)) \
-    && !__MATH_DECLARING_FLOATN
-/* scalb.  */
-__MATH_REDIRCALL (scalb, , (_Mdouble_, _Mdouble_));
-#endif
-
-/* sinh.  */
-__MATH_REDIRCALL (sinh, , (_Mdouble_));
-
-/* sqrt.  */
-__MATH_REDIRCALL (sqrt, , (_Mdouble_));
-
 #if defined __USE_ISOC99 && defined __extern_always_inline
 /* tgamma.  */
+# if __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL
+__MATH_REDIRCALL_INTERNAL (gamma, _r, (_Mdouble_, int *));
+# else
 extern _Mdouble_
-__REDIRFROM (__gamma, _r_finite) (_Mdouble_, int *);
+__REDIRFROM_F (__gamma, _r_finite) (_Mdouble_, int *);
+# endif
 
 __extern_always_inline _Mdouble_
-__NTH (__REDIRFROM (tgamma, ) (_Mdouble_ __d))
+__NTH (__REDIRFROM_F (tgamma, ) (_Mdouble_ __d))
 {
   int __local_signgam = 0;
-  _Mdouble_ __res = __REDIRTO (gamma, _r) (__d, &__local_signgam);
+  _Mdouble_ __res = __REDIRTO_PUBLIC_F (gamma, _r) (__d, &__local_signgam);
   return __local_signgam < 0 ? -__res : __res;
 }
 #endif
 
-#undef __REDIRFROM
-#undef __REDIRTO
 #undef __MATH_REDIRCALL
-#undef __MATH_REDIRCALL_2
 #undef __MATH_REDIRCALL_INTERNAL
-#undef __MATH_REDIRCALL_X
+#undef __MATH_REDIR_X
+#undef __REDIRFROM_F
+#undef __REDIRTO_F
diff --git a/math/bits/mathcalls.h b/math/bits/mathcalls.h
index cf87313e2f..f4246a7881 100644
--- a/math/bits/mathcalls.h
+++ b/math/bits/mathcalls.h
@@ -50,13 +50,13 @@
 /* Trigonometric functions.  */
 
 /* Arc cosine of X.  */
-__MATHCALL (acos,, (_Mdouble_ __x));
+__MATHCALL_FINITE (acos,, (_Mdouble_ __x));
 /* Arc sine of X.  */
-__MATHCALL (asin,, (_Mdouble_ __x));
+__MATHCALL_FINITE (asin,, (_Mdouble_ __x));
 /* Arc tangent of X.  */
 __MATHCALL (atan,, (_Mdouble_ __x));
 /* Arc tangent of Y/X.  */
-__MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x));
+__MATHCALL_FINITE (atan2,, (_Mdouble_ __y, _Mdouble_ __x));
 
 /* Cosine of X.  */
 __MATHCALL_VEC (cos,, (_Mdouble_ __x));
@@ -68,9 +68,9 @@ __MATHCALL (tan,, (_Mdouble_ __x));
 /* Hyperbolic functions.  */
 
 /* Hyperbolic cosine of X.  */
-__MATHCALL (cosh,, (_Mdouble_ __x));
+__MATHCALL_FINITE (cosh,, (_Mdouble_ __x));
 /* Hyperbolic sine of X.  */
-__MATHCALL (sinh,, (_Mdouble_ __x));
+__MATHCALL_FINITE (sinh,, (_Mdouble_ __x));
 /* Hyperbolic tangent of X.  */
 __MATHCALL (tanh,, (_Mdouble_ __x));
 
@@ -82,17 +82,17 @@ __MATHDECL_VEC (void,sincos,,
 
 #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
 /* Hyperbolic arc cosine of X.  */
-__MATHCALL (acosh,, (_Mdouble_ __x));
+__MATHCALL_FINITE (acosh,, (_Mdouble_ __x));
 /* Hyperbolic arc sine of X.  */
 __MATHCALL (asinh,, (_Mdouble_ __x));
 /* Hyperbolic arc tangent of X.  */
-__MATHCALL (atanh,, (_Mdouble_ __x));
+__MATHCALL_FINITE (atanh,, (_Mdouble_ __x));
 #endif
 
 /* Exponential and logarithmic functions.  */
 
 /* Exponential function of X.  */
-__MATHCALL_VEC (exp,, (_Mdouble_ __x));
+__MATHCALL_VEC_FINITE (exp,, (_Mdouble_ __x));
 
 /* Break VALUE into a normalized fraction and an integral power of 2.  */
 __MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
@@ -101,17 +101,17 @@ __MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
 __MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent));
 
 /* Natural logarithm of X.  */
-__MATHCALL_VEC (log,, (_Mdouble_ __x));
+__MATHCALL_VEC_FINITE (log,, (_Mdouble_ __x));
 
 /* Base-ten logarithm of X.  */
-__MATHCALL (log10,, (_Mdouble_ __x));
+__MATHCALL_FINITE (log10,, (_Mdouble_ __x));
 
 /* Break VALUE into integral and fractional parts.  */
 __MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr)) __nonnull ((2));
 
 #if __GLIBC_USE (IEC_60559_FUNCS_EXT)
 /* Compute exponent to base ten.  */
-__MATHCALL (exp10,, (_Mdouble_ __x));
+__MATHCALL_FINITE (exp10,, (_Mdouble_ __x));
 #endif
 
 #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
@@ -127,24 +127,23 @@ __MATHCALL (logb,, (_Mdouble_ __x));
 
 #ifdef __USE_ISOC99
 /* Compute base-2 exponential of X.  */
-__MATHCALL (exp2,, (_Mdouble_ __x));
+__MATHCALL_FINITE (exp2,, (_Mdouble_ __x));
 
 /* Compute base-2 logarithm of X.  */
-__MATHCALL (log2,, (_Mdouble_ __x));
+__MATHCALL_FINITE (log2,, (_Mdouble_ __x));
 #endif
 
-
 /* Power functions.  */
 
 /* Return X to the Y power.  */
-__MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
+__MATHCALL_VEC_FINITE (pow,, (_Mdouble_ __x, _Mdouble_ __y));
 
 /* Return the square root of X.  */
-__MATHCALL (sqrt,, (_Mdouble_ __x));
+__MATHCALL_FINITE (sqrt,, (_Mdouble_ __x));
 
 #if defined __USE_XOPEN || defined __USE_ISOC99
 /* Return `sqrt(X*X + Y*Y)'.  */
-__MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
+__MATHCALL_FINITE (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
 #endif
 
 #if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
@@ -165,7 +164,7 @@ __MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
 __MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
 
 /* Floating-point modulo remainder of X/Y.  */
-__MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
+__MATHCALL_FINITE (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
 
 #ifdef __USE_MISC
 # if ((!defined __cplusplus \
@@ -214,12 +213,12 @@ __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
 
 #if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE)
 /* Bessel functions.  */
-__MATHCALL (j0,, (_Mdouble_));
-__MATHCALL (j1,, (_Mdouble_));
-__MATHCALL (jn,, (int, _Mdouble_));
-__MATHCALL (y0,, (_Mdouble_));
-__MATHCALL (y1,, (_Mdouble_));
-__MATHCALL (yn,, (int, _Mdouble_));
+__MATHCALL_FINITE (j0,, (_Mdouble_));
+__MATHCALL_FINITE (j1,, (_Mdouble_));
+__MATHCALL_FINITE (jn,, (int, _Mdouble_));
+__MATHCALL_FINITE (y0,, (_Mdouble_));
+__MATHCALL_FINITE (y1,, (_Mdouble_));
+__MATHCALL_FINITE (yn,, (int, _Mdouble_));
 #endif
 
 
@@ -246,7 +245,7 @@ __MATHCALL (gamma,, (_Mdouble_));
 /* Reentrant version of lgamma.  This function uses the global variable
    `signgam'.  The reentrant version instead takes a pointer and stores
    the value through it.  */
-__MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp));
+__MATHCALL_FINITE (lgamma,_r, (_Mdouble_, int *__signgamp));
 #endif
 
 
@@ -269,7 +268,7 @@ __MATHCALL (nextup,, (_Mdouble_ __x));
 # endif
 
 /* Return the remainder of integer divison X / Y with infinite precision.  */
-__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
+__MATHCALL_FINITE (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
 
 # ifdef __USE_ISOC99
 /* Return X times (2 to the Nth power).  */
@@ -393,5 +392,5 @@ __MATHDECL_1 (int, setpayloadsig,, (_Mdouble_ *__x, _Mdouble_ __payload));
     && !defined __USE_XOPEN2K8))  \
      && !__MATH_DECLARING_FLOATN
 /* Return X times (2 to the Nth power).  */
-__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
+__MATHCALL_FINITE (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
 #endif
diff --git a/math/math.h b/math/math.h
index 998d3042c5..c1765e4c8c 100644
--- a/math/math.h
+++ b/math/math.h
@@ -286,6 +286,28 @@ enum
 
 #define __MATHREDIR(type, function, suffix, args, to) \
   extern type __REDIRECT_NTH (__MATH_PRECNAME (function, suffix), args, to)
+#define __MATH_FINITE_NAMEY(p, f, s) \
+  p ## f ## s
+#define __MATH_FINITE_NAMEX(p, f, s) \
+  __MATH_FINITE_NAMEY (p, f, s)
+#define __MATH_FINITE_NAME_IMPL(function, suffix) \
+  __MATH_FINITE_NAMEX (__, __MATH_PRECNAME (function, suffix), _finite)
+#define __MATH_FINITE_NAME(function, suffix) \
+  __MATH_FINITE_NAME_IMPL (function, suffix)
+
+#if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+# define __MATHCALL_VEC_FINITE(function, suffix, args) \
+  __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \
+  __MATHCALL_FINITE (function, suffix, args)
+# define __MATHCALL_FINITE(function, suffix, args) \
+  __MATHREDIR (_Mdouble_, function, suffix, args, \
+       __MATH_FINITE_NAME(function, suffix))
+#else
+# define __MATHCALL_VEC_FINITE(function, suffix, args) \
+  __MATHCALL_VEC(function, suffix, args)
+# define __MATHCALL_FINITE(function, suffix, args) \
+  __MATHCALL (function, suffix, args)
+#endif
 
 #define _Mdouble_ double
 #define __MATH_PRECNAME(name,r) __CONCAT(name,r)
@@ -320,6 +342,10 @@ enum
      || defined _LIBC_TEST
 #  ifdef __LDBL_COMPAT
 
+#   undef __MATH_FINITE_NAME
+#   define __MATH_FINITE_NAME(function, suffix) \
+  __MATH_FINITE_NAMEX (__, function ## suffix, _finite)
+
 #   ifdef __USE_ISOC99
 extern float __nldbl_nexttowardf (float __x, long double __y)
   __THROW __attribute__ ((__const__));
@@ -364,8 +390,99 @@ extern long double __REDIRECT_NTH (nexttowardl,
 
 #endif /* Use ISO C99.  */
 
+#if defined __USE_MISC || defined __USE_XOPEN
+/* This variable is used by `gamma' and `lgamma'.  */
+extern int signgam;
+#endif
+
+/* Define special entry points to use when the compiler got told to
+   only expect finite results.  */
+#if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+
+/* Include bits/math-finite.h for double.  */
+# define _Mdouble_ double
+# define __MATH_DECLARING_DOUBLE 1
+# define __MATH_DECLARING_FLOATN 0
+# define __REDIRFROM_X(function, reentrant) \
+  function ## reentrant
+# define __REDIRTO_X(function, reentrant) \
+   __ ## function ## reentrant ## _finite
+# define __REDIRTO_PUBLIC_X(function, reentrant) \
+  __REDIRTO_X(function, reentrant)
+# include <bits/math-finite.h>
+# undef _Mdouble_
+# undef __MATH_DECLARING_DOUBLE
+# undef __MATH_DECLARING_FLOATN
+# undef __REDIRFROM_X
+# undef __REDIRTO_X
+# undef __REDIRTO_PUBLIC_X
+
+/* When __USE_ISOC99 is defined, include math-finite for float and
+   long double, as well.  */
+# ifdef __USE_ISOC99
+
+/* Include bits/math-finite.h for float.  */
+#  define _Mdouble_ float
+#  define __MATH_DECLARING_DOUBLE 0
+#  define __MATH_DECLARING_FLOATN 0
+#  define __REDIRFROM_X(function, reentrant) \
+  function ## f ## reentrant
+#  define __REDIRTO_X(function, reentrant) \
+   __ ## function ## f ## reentrant ## _finite
+# define __REDIRTO_PUBLIC_X(function, reentrant) \
+  __REDIRTO_X(function, reentrant)
+#  include <bits/math-finite.h>
+#  undef _Mdouble_
+#  undef __MATH_DECLARING_DOUBLE
+#  undef __MATH_DECLARING_FLOATN
+#  undef __REDIRFROM_X
+#  undef __REDIRTO_X
+#  undef __REDIRTO_PUBLIC_X
+
+/* Include bits/math-finite.h for long double.  */
+#  ifdef __MATH_DECLARE_LDOUBLE
+#   define _Mdouble_ long double
+#   define __MATH_DECLARING_DOUBLE 0
+#   define __MATH_DECLARING_FLOATN 0
+#   define __REDIRFROM_X(function, reentrant) \
+  function ## l ## reentrant
+#   ifdef __NO_LONG_DOUBLE_MATH
+#    define __REDIRTO_X(function, reentrant) \
+   __ ## function ## reentrant ## _finite
+#    define __REDIRTO_PUBLIC_X(function, reentrant) \
+   __REDIRTO_X(function, reentrant)
+#   elif __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL
+#    define __REDIRTO_X(function, reentrant) \
+   __ ## function ## f128 ## reentrant ## _finite
+#    define __REDIRTO_PUBLIC_X(function, reentrant) \
+   __ ## function ## l ## reentrant ## _finite
+#   else
+#    define __REDIRTO_X(function, reentrant) \
+   __ ## function ## l ## reentrant ## _finite
+#    define __REDIRTO_PUBLIC_X(function, reentrant) \
+   __REDIRTO_X(function, reentrant)
+#   endif
+#   include <bits/math-finite.h>
+#   undef _Mdouble_
+#   undef __MATH_DECLARING_DOUBLE
+#   undef __MATH_DECLARING_FLOATN
+#   undef __REDIRFROM_X
+#   undef __REDIRTO_X
+#   undef __REDIRTO_PUBLIC_X
+#  endif
+
+# endif /* __USE_ISOC99.  */
+#endif /* __FINITE_MATH_ONLY__ > 0.  */
+
 /* Include the file of declarations for _FloatN and _FloatNx
    types.  */
+#undef __MATH_FINITE_NAME
+#define __MATH_FINITE_NAME(function, suffix) \
+  __MATH_FINITE_NAMEX (, __REDIRTO_X (function, suffix),)
+#define __REDIRFROM_X(function, reentrant) \
+  __MATH_PRECNAME (function, reentrant)
+#define __REDIRTO_PUBLIC_X(function, reentrant) \
+  __REDIRTO_X(function, reentrant)
 
 #if __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC)
 # define _Mdouble_ _Float16
@@ -376,12 +493,27 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #  include <bits/mathcalls-helper-functions.h>
 # endif
 # if __GLIBC_USE (IEC_60559_TYPES_EXT)
+#  if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+#   if __HAVE_DISTINCT_FLOAT16
+#    define __REDIRTO_X(function, reentrant) \
+  __ ## function ## f16 ## reentrant ## _finite
+#   else
+#    error "non-distinct _Float16"
+#   endif
+#  else
+#   define __REDIRTO_X(function, reentrant) \
+  __MATH_PRECNAME (function, reentrant)
+#  endif
 #  include <bits/mathcalls.h>
+#  if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+#   include <bits/math-finite.h>
+#  endif
 # endif
 # undef _Mdouble_
 # undef __MATH_PRECNAME
 # undef __MATH_DECLARING_DOUBLE
 # undef __MATH_DECLARING_FLOATN
+# undef __REDIRTO_X
 #endif /* __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !_LIBC).  */
 
 #if __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC)
@@ -393,12 +525,28 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #  include <bits/mathcalls-helper-functions.h>
 # endif
 # if __GLIBC_USE (IEC_60559_TYPES_EXT)
+#  if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+#   if __HAVE_DISTINCT_FLOAT32
+#    define __REDIRTO_X(function, reentrant) \
+  __ ## function ## f32 ## reentrant ## _finite
+#   else
+#    define __REDIRTO_X(function, reentrant) \
+  __ ## function ## f ## reentrant ## _finite
+#   endif
+#  else
+#   define __REDIRTO_X(function, reentrant) \
+  __MATH_PRECNAME (function, reentrant)
+#  endif
 #  include <bits/mathcalls.h>
+#  if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+#   include <bits/math-finite.h>
+#  endif
 # endif
 # undef _Mdouble_
 # undef __MATH_PRECNAME
 # undef __MATH_DECLARING_DOUBLE
 # undef __MATH_DECLARING_FLOATN
+# undef __REDIRTO_X
 #endif /* __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !_LIBC).  */
 
 #if __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC)
@@ -410,12 +558,28 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #  include <bits/mathcalls-helper-functions.h>
 # endif
 # if __GLIBC_USE (IEC_60559_TYPES_EXT)
+#  if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+#   if __HAVE_DISTINCT_FLOAT64
+#    define __REDIRTO_X(function, reentrant) \
+  __ ## function ## f64 ## reentrant ## _finite
+#   else
+#    define __REDIRTO_X(function, reentrant) \
+  __ ## function ## reentrant ## _finite
+#   endif
+#  else
+#   define __REDIRTO_X(function, reentrant) \
+  __MATH_PRECNAME (function, reentrant)
+#  endif
 #  include <bits/mathcalls.h>
+#  if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+#   include <bits/math-finite.h>
+#  endif
 # endif
 # undef _Mdouble_
 # undef __MATH_PRECNAME
 # undef __MATH_DECLARING_DOUBLE
 # undef __MATH_DECLARING_FLOATN
+# undef __REDIRTO_X
 #endif /* __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !_LIBC).  */
 
 #if __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)
@@ -427,12 +591,28 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #  include <bits/mathcalls-helper-functions.h>
 # endif
 # if __GLIBC_USE (IEC_60559_TYPES_EXT)
+#  if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+#   if __HAVE_DISTINCT_FLOAT128
+#    define __REDIRTO_X(function, reentrant) \
+  __ ## function ## f128 ## reentrant ## _finite
+#   else
+#    define __REDIRTO_X(function, reentrant) \
+  __ ## function ## l ## reentrant ## _finite
+#   endif
+#  else
+#   define __REDIRTO_X(function, reentrant) \
+  __MATH_PRECNAME (function, reentrant)
+#  endif
 #  include <bits/mathcalls.h>
+#  if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+#   include <bits/math-finite.h>
+#  endif
 # endif
 # undef _Mdouble_
 # undef __MATH_PRECNAME
 # undef __MATH_DECLARING_DOUBLE
 # undef __MATH_DECLARING_FLOATN
+# undef __REDIRTO_X
 #endif /* __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !_LIBC).  */
 
 #if __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC)
@@ -444,12 +624,28 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #  include <bits/mathcalls-helper-functions.h>
 # endif
 # if __GLIBC_USE (IEC_60559_TYPES_EXT)
+#  if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+#   if __HAVE_DISTINCT_FLOAT32X
+#    define __REDIRTO_X(function, reentrant) \
+  __ ## function ## f32x ## reentrant ## _finite
+#   else
+#    define __REDIRTO_X(function, reentrant) \
+  __ ## function ## reentrant ## _finite
+#   endif
+#  else
+#   define __REDIRTO_X(function, reentrant) \
+  __MATH_PRECNAME (function, reentrant)
+#  endif
 #  include <bits/mathcalls.h>
+#  if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+#   include <bits/math-finite.h>
+#  endif
 # endif
 # undef _Mdouble_
 # undef __MATH_PRECNAME
 # undef __MATH_DECLARING_DOUBLE
 # undef __MATH_DECLARING_FLOATN
+# undef __REDIRTO_X
 #endif /* __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !_LIBC).  */
 
 #if __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC)
@@ -461,12 +657,31 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #  include <bits/mathcalls-helper-functions.h>
 # endif
 # if __GLIBC_USE (IEC_60559_TYPES_EXT)
+#  if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+#   if __HAVE_DISTINCT_FLOAT64X
+#    define __REDIRTO_X(function, reentrant) \
+  __ ## function ## f64x ## reentrant ## _finite
+#   elif __HAVE_FLOAT64X_LONG_DOUBLE
+#    define __REDIRTO_X(function, reentrant) \
+  __ ## function ## l ## reentrant ## _finite
+#   else
+#    define __REDIRTO_X(function, reentrant) \
+  __ ## function ## f128 ## reentrant ## _finite
+#   endif
+#  else
+#   define __REDIRTO_X(function, reentrant) \
+  __MATH_PRECNAME (function, reentrant)
+#  endif
 #  include <bits/mathcalls.h>
+#  if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+#   include <bits/math-finite.h>
+#  endif
 # endif
 # undef _Mdouble_
 # undef __MATH_PRECNAME
 # undef __MATH_DECLARING_DOUBLE
 # undef __MATH_DECLARING_FLOATN
+# undef __REDIRTO_X
 #endif /* __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !_LIBC).  */
 
 #if __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)
@@ -478,18 +693,43 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #  include <bits/mathcalls-helper-functions.h>
 # endif
 # if __GLIBC_USE (IEC_60559_TYPES_EXT)
+#  if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+#   if __HAVE_DISTINCT_FLOAT128X
+#    define __REDIRTO_X(function, reentrant) \
+  __ ## function ## f128x ## reentrant ## _finite
+#   else
+#    error "non-distinct _Float128x"
+#   endif
+#  else
+#   define __REDIRTO_X(function, reentrant) \
+  __MATH_PRECNAME (function, reentrant)
+#  endif
 #  include <bits/mathcalls.h>
+#  if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+#   include <bits/math-finite.h>
+#  endif
 # endif
 # undef _Mdouble_
 # undef __MATH_PRECNAME
 # undef __MATH_DECLARING_DOUBLE
 # undef __MATH_DECLARING_FLOATN
+# undef __REDIRTO_X
 #endif /* __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC).  */
 
+#undef __REDIRFROM_X
+#undef __REDIRTO_PUBLIC_X
 #undef __MATHDECL_1_IMPL
 #undef __MATHDECL_1
 #undef __MATHDECL
 #undef __MATHCALL
+#undef __MATHCALL_VEC
+#undef __MATHCALL_FINITE
+#undef __MATHCALL_VEC_FINITE
+#undef __MATHREDIR
+#undef __MATH_FINITE_NAMEY
+#undef __MATH_FINITE_NAMEX
+#undef __MATH_FINITE_NAME_IMPL
+#undef __MATH_FINITE_NAME
 
 /* Declare functions returning a narrower type.  */
 #define __MATHCALL_NARROW_ARGS_1 (_Marg_ __x)
@@ -776,11 +1016,6 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #undef __MATHCALL_NARROW_REDIR
 #undef __MATHCALL_NARROW
 
-#if defined __USE_MISC || defined __USE_XOPEN
-/* This variable is used by `gamma' and `lgamma'.  */
-extern int signgam;
-#endif
-
 #if (__HAVE_DISTINCT_FLOAT16 \
      || __HAVE_DISTINCT_FLOAT32 \
      || __HAVE_DISTINCT_FLOAT64 \
@@ -1248,227 +1483,6 @@ iszero (__T __val)
 # include <bits/mathinline.h>
 #endif
 
-/* Define special entry points to use when the compiler got told to
-   only expect finite results.  */
-#if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
-
-/* Include bits/math-finite.h for double.  */
-# define _Mdouble_ double
-# define __MATH_DECLARING_DOUBLE 1
-# define __MATH_DECLARING_FLOATN 0
-# define __REDIRFROM_X(function, reentrant) \
-  function ## reentrant
-# define __REDIRTO_X(function, reentrant) \
-   __ ## function ## reentrant ## _finite
-# include <bits/math-finite.h>
-# undef _Mdouble_
-# undef __MATH_DECLARING_DOUBLE
-# undef __MATH_DECLARING_FLOATN
-# undef __REDIRFROM_X
-# undef __REDIRTO_X
-
-/* When __USE_ISOC99 is defined, include math-finite for float and
-   long double, as well.  */
-# ifdef __USE_ISOC99
-
-/* Include bits/math-finite.h for float.  */
-#  define _Mdouble_ float
-#  define __MATH_DECLARING_DOUBLE 0
-#  define __MATH_DECLARING_FLOATN 0
-#  define __REDIRFROM_X(function, reentrant) \
-  function ## f ## reentrant
-#  define __REDIRTO_X(function, reentrant) \
-   __ ## function ## f ## reentrant ## _finite
-#  include <bits/math-finite.h>
-#  undef _Mdouble_
-#  undef __MATH_DECLARING_DOUBLE
-#  undef __MATH_DECLARING_FLOATN
-#  undef __REDIRFROM_X
-#  undef __REDIRTO_X
-
-/* Include bits/math-finite.h for long double.  */
-#  ifdef __MATH_DECLARE_LDOUBLE
-#   define _Mdouble_ long double
-#   define __MATH_DECLARING_DOUBLE 0
-#   define __MATH_DECLARING_FLOATN 0
-#   define __REDIRFROM_X(function, reentrant) \
-  function ## l ## reentrant
-#   ifdef __NO_LONG_DOUBLE_MATH
-#    define __REDIRTO_X(function, reentrant) \
-   __ ## function ## reentrant ## _finite
-#   else
-#    define __REDIRTO_X(function, reentrant) \
-   __ ## function ## l ## reentrant ## _finite
-#   endif
-#   include <bits/math-finite.h>
-#   undef _Mdouble_
-#   undef __MATH_DECLARING_DOUBLE
-#   undef __MATH_DECLARING_FLOATN
-#   undef __REDIRFROM_X
-#   undef __REDIRTO_X
-#  endif
-
-# endif /* __USE_ISOC99.  */
-
-/* Include bits/math-finite.h for _FloatN and _FloatNx.  */
-
-# if (__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC)) \
-      && __GLIBC_USE (IEC_60559_TYPES_EXT)
-#  define _Mdouble_ _Float16
-#  define __MATH_DECLARING_DOUBLE 0
-#  define __MATH_DECLARING_FLOATN 1
-#  define __REDIRFROM_X(function, reentrant) \
-  function ## f16 ## reentrant
-#  if __HAVE_DISTINCT_FLOAT16
-#   define __REDIRTO_X(function, reentrant) \
-   __ ## function ## f16 ## reentrant ## _finite
-#  else
-#   error "non-disinct _Float16"
-#  endif
-#  include <bits/math-finite.h>
-#  undef _Mdouble_
-#  undef __MATH_DECLARING_DOUBLE
-#  undef __MATH_DECLARING_FLOATN
-#  undef __REDIRFROM_X
-#  undef __REDIRTO_X
-# endif
-
-# if (__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC)) \
-      && __GLIBC_USE (IEC_60559_TYPES_EXT)
-#  define _Mdouble_ _Float32
-#  define __MATH_DECLARING_DOUBLE 0
-#  define __MATH_DECLARING_FLOATN 1
-#  define __REDIRFROM_X(function, reentrant) \
-  function ## f32 ## reentrant
-#  if __HAVE_DISTINCT_FLOAT32
-#   define __REDIRTO_X(function, reentrant) \
-   __ ## function ## f32 ## reentrant ## _finite
-#  else
-#   define __REDIRTO_X(function, reentrant) \
-   __ ## function ## f ## reentrant ## _finite
-#  endif
-#  include <bits/math-finite.h>
-#  undef _Mdouble_
-#  undef __MATH_DECLARING_DOUBLE
-#  undef __MATH_DECLARING_FLOATN
-#  undef __REDIRFROM_X
-#  undef __REDIRTO_X
-# endif
-
-# if (__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC)) \
-      && __GLIBC_USE (IEC_60559_TYPES_EXT)
-#  define _Mdouble_ _Float64
-#  define __MATH_DECLARING_DOUBLE 0
-#  define __MATH_DECLARING_FLOATN 1
-#  define __REDIRFROM_X(function, reentrant) \
-  function ## f64 ## reentrant
-#  if __HAVE_DISTINCT_FLOAT64
-#   define __REDIRTO_X(function, reentrant) \
-   __ ## function ## f64 ## reentrant ## _finite
-#  else
-#   define __REDIRTO_X(function, reentrant) \
-   __ ## function ## reentrant ## _finite
-#  endif
-#  include <bits/math-finite.h>
-#  undef _Mdouble_
-#  undef __MATH_DECLARING_DOUBLE
-#  undef __MATH_DECLARING_FLOATN
-#  undef __REDIRFROM_X
-#  undef __REDIRTO_X
-# endif
-
-# if (__HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)) \
-      && __GLIBC_USE (IEC_60559_TYPES_EXT)
-#  define _Mdouble_ _Float128
-#  define __MATH_DECLARING_DOUBLE 0
-#  define __MATH_DECLARING_FLOATN 1
-#  define __REDIRFROM_X(function, reentrant) \
-  function ## f128 ## reentrant
-#  if __HAVE_DISTINCT_FLOAT128
-#   define __REDIRTO_X(function, reentrant) \
-   __ ## function ## f128 ## reentrant ## _finite
-#  else
-#   define __REDIRTO_X(function, reentrant) \
-   __ ## function ## l ## reentrant ## _finite
-#  endif
-#  include <bits/math-finite.h>
-#  undef _Mdouble_
-#  undef __MATH_DECLARING_DOUBLE
-#  undef __MATH_DECLARING_FLOATN
-#  undef __REDIRFROM_X
-#  undef __REDIRTO_X
-# endif
-
-# if (__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC)) \
-      && __GLIBC_USE (IEC_60559_TYPES_EXT)
-#  define _Mdouble_ _Float32x
-#  define __MATH_DECLARING_DOUBLE 0
-#  define __MATH_DECLARING_FLOATN 1
-#  define __REDIRFROM_X(function, reentrant) \
-  function ## f32x ## reentrant
-#  if __HAVE_DISTINCT_FLOAT32X
-#   define __REDIRTO_X(function, reentrant) \
-   __ ## function ## f32x ## reentrant ## _finite
-#  else
-#   define __REDIRTO_X(function, reentrant) \
-   __ ## function ## reentrant ## _finite
-#  endif
-#  include <bits/math-finite.h>
-#  undef _Mdouble_
-#  undef __MATH_DECLARING_DOUBLE
-#  undef __MATH_DECLARING_FLOATN
-#  undef __REDIRFROM_X
-#  undef __REDIRTO_X
-# endif
-
-# if (__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC)) \
-      && __GLIBC_USE (IEC_60559_TYPES_EXT)
-#  define _Mdouble_ _Float64x
-#  define __MATH_DECLARING_DOUBLE 0
-#  define __MATH_DECLARING_FLOATN 1
-#  define __REDIRFROM_X(function, reentrant) \
-  function ## f64x ## reentrant
-#  if __HAVE_DISTINCT_FLOAT64X
-#   define __REDIRTO_X(function, reentrant) \
-   __ ## function ## f64x ## reentrant ## _finite
-#  elif __HAVE_FLOAT64X_LONG_DOUBLE
-#   define __REDIRTO_X(function, reentrant) \
-   __ ## function ## l ## reentrant ## _finite
-#  else
-#   define __REDIRTO_X(function, reentrant) \
-   __ ## function ## f128 ## reentrant ## _finite
-#  endif
-#  include <bits/math-finite.h>
-#  undef _Mdouble_
-#  undef __MATH_DECLARING_DOUBLE
-#  undef __MATH_DECLARING_FLOATN
-#  undef __REDIRFROM_X
-#  undef __REDIRTO_X
-# endif
-
-# if (__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)) \
-      && __GLIBC_USE (IEC_60559_TYPES_EXT)
-#  define _Mdouble_ _Float128x
-#  define __MATH_DECLARING_DOUBLE 0
-#  define __MATH_DECLARING_FLOATN 1
-#  define __REDIRFROM_X(function, reentrant) \
-  function ## f128x ## reentrant
-#  if __HAVE_DISTINCT_FLOAT128X
-#   define __REDIRTO_X(function, reentrant) \
-   __ ## function ## f128x ## reentrant ## _finite
-#  else
-#   error "non-disinct _Float128x"
-#  endif
-#  include <bits/math-finite.h>
-#  undef _Mdouble_
-#  undef __MATH_DECLARING_DOUBLE
-#  undef __MATH_DECLARING_FLOATN
-#  undef __REDIRFROM_X
-#  undef __REDIRTO_X
-# endif
-
-#endif /* __FINITE_MATH_ONLY__ > 0.  */
-
 #if __GLIBC_USE (IEC_60559_BFP_EXT)
 /* An expression whose type has the widest of the evaluation formats
    of X and Y (which are of floating-point types).  */
--
2.14.4

Reply | Threaded
Open this post in threaded view
|

[PATCH 06/12] ldbl-128ibm-compat: Create libm-alias-float128.h

Tulio Magno Quites Machado Filho-2
In reply to this post by Tulio Magno Quites Machado Filho-2
Add a new libm-alias-float128.h in order to provide the __*ieee128
aliases for the existing *f128 that do not have a globally exported
symbol.

2018-06-19  Tulio Magno Quites Machado Filho  <[hidden email]>
            Gabriel F. T. Gomes  <[hidden email]>

        * sysdeps/ieee754/ldbl-128ibm-compat/Versions: New file.
        * sysdeps/ieee754/ldbl-128ibm-compat/libm-alias-float128.h: New file.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Versions        | 113 +++++++++++++++++++++
 .../ldbl-128ibm-compat/libm-alias-float128.h       |  64 ++++++++++++
 2 files changed, 177 insertions(+)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/Versions
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/libm-alias-float128.h

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
new file mode 100644
index 0000000000..322041132e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -0,0 +1,113 @@
+%include <ldbl-128ibm-compat-abi.h>
+%ifndef LDBL_IBM128_VERSION
+% error "ldbl-128ibm-compat-abi.h must define LDBL_IBM128_VERSION"
+%endif
+
+libm {
+  LDBL_IBM128_VERSION {
+    __acoshieee128;
+    __acosieee128;
+    __asinhieee128;
+    __asinieee128;
+    __atan2ieee128;
+    __atanhieee128;
+    __atanieee128;
+    __cabsieee128;
+    __cacoshieee128;
+    __cacosieee128;
+    __canonicalizeieee128;
+    __cargieee128;
+    __casinhieee128;
+    __casinieee128;
+    __catanhieee128;
+    __catanieee128;
+    __cbrtieee128;
+    __ccoshieee128;
+    __ccosieee128;
+    __ceilieee128;
+    __cexpieee128;
+    __cimagieee128;
+    __clog10ieee128;
+    __clogieee128;
+    __conjieee128;
+    __copysignieee128;
+    __coshieee128;
+    __cosieee128;
+    __cpowieee128;
+    __cprojieee128;
+    __crealieee128;
+    __csinhieee128;
+    __csinieee128;
+    __csqrtieee128;
+    __ctanhieee128;
+    __ctanieee128;
+    __erfcieee128;
+    __erfieee128;
+    __exp10ieee128;
+    __exp2ieee128;
+    __expieee128;
+    __expm1ieee128;
+    __fabsieee128;
+    __fdimieee128;
+    __floorieee128;
+    __fmaieee128;
+    __fmaxieee128;
+    __fmaxmagieee128;
+    __fminieee128;
+    __fminmagieee128;
+    __fmodieee128;
+    __frexpieee128;
+    __fromfpieee128;
+    __fromfpxieee128;
+    __getpayloadieee128;
+    __hypotieee128;
+    __ilogbieee128;
+    __j0ieee128;
+    __j1ieee128;
+    __jnieee128;
+    __ldexpieee128;
+    __lgammaieee128;
+    __lgammaieee128_r;
+    __llogbieee128;
+    __llrintieee128;
+    __llroundieee128;
+    __log10ieee128;
+    __log1pieee128;
+    __log2ieee128;
+    __logbieee128;
+    __logieee128;
+    __lrintieee128;
+    __lroundieee128;
+    __modfieee128;
+    __nanieee128;
+    __nearbyintieee128;
+    __nextafterieee128;
+    __nextdownieee128;
+    __nextupieee128;
+    __powieee128;
+    __remainderieee128;
+    __remquoieee128;
+    __rintieee128;
+    __roundevenieee128;
+    __roundieee128;
+    __scalblnieee128;
+    __scalbnieee128;
+    __setpayloadieee128;
+    __setpayloadsigieee128;
+    __sincosieee128;
+    __sinhieee128;
+    __sinieee128;
+    __sqrtieee128;
+    __tanhieee128;
+    __tanieee128;
+    __tgammaieee128;
+    __totalorderieee128;
+    __totalordermagieee128;
+    __truncieee128;
+    __ufromfpieee128;
+    __ufromfpxieee128;
+    __y0ieee128;
+    __y1ieee128;
+    __ynieee128;
+  }
+}
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/libm-alias-float128.h b/sysdeps/ieee754/ldbl-128ibm-compat/libm-alias-float128.h
new file mode 100644
index 0000000000..a21dfcaea5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/libm-alias-float128.h
@@ -0,0 +1,64 @@
+/* Define aliases for libm _Float128 functions.
+   Copyright (C) 2018 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 _LIBM_ALIAS_FLOAT128_H
+#define _LIBM_ALIAS_FLOAT128_H
+
+#include <bits/floatn.h>
+#include <ldbl-128ibm-compat-abi.h>
+
+/* This macro should be used on all long double functions that are not part of
+   the _Float128 API in order to provide *ieee128 symbols without exposing
+   internal *f128 symbols.  */
+#define libm_alias_float128_other_r_ldbl(from, to, r) \
+  strong_alias (from ## f128 ## r, __ ## to ## ieee128 ## r)
+
+/* Define _FloatN / _FloatNx aliases (other than that for _Float128)
+   for a _Float128 libm function that has internal name FROM ## f128
+   ## R and public names TO ## suffix ## R for each suffix of a
+   supported _FloatN / _FloatNx floating-point type with the same
+   format as _Float128.  */
+#if __HAVE_FLOAT64X && !__HAVE_FLOAT64X_LONG_DOUBLE
+# define libm_alias_float128_other_r(from, to, r) \
+  weak_alias (from ## f128 ## r, to ## f64x ## r); \
+  libm_alias_float128_other_r_ldbl(from, to, r)
+#else
+# define libm_alias_float128_other_r(from, to, r) \
+  libm_alias_float128_other_r_ldbl(from, to, r)
+#endif
+
+/* Likewise, but without the R suffix.  */
+#define libm_alias_float128_other(from, to) \
+  libm_alias_float128_other_r (from, to, )
+
+/* Define aliases for a _Float128 libm function that has internal name
+   FROM ## f128 ## R and public names TO ## suffix ## R for each
+   suffix of a supported floating-point type with the same format as
+   _Float128.  This should only be used for functions where such
+   public names exist for _FloatN types, not for
+   implementation-namespace exported names (where there is one name
+   per format, not per type) or for obsolescent functions not provided
+   for _FloatN types.  */
+#define libm_alias_float128_r(from, to, r) \
+  weak_alias (from ## f128 ## r, to ## f128 ## r); \
+  libm_alias_float128_other_r (from, to, r)
+
+/* Likewise, but without the R suffix.  */
+#define libm_alias_float128(from, to) libm_alias_float128_r (from, to, )
+
+#endif
--
2.14.4

Reply | Threaded
Open this post in threaded view
|

[PATCH 07/12] ldbl-128ibm-compat: Provide a scalb implementation

Tulio Magno Quites Machado Filho-2
In reply to this post by Tulio Magno Quites Machado Filho-2
Reuse the template in order to provide the global symbols
__scalbf128_finite and __scalbieee128.

2018-06-19  Tulio Magno Quites Machado Filho  <[hidden email]>
            Gabriel F. T. Gomes  <[hidden email]>

        * sysdeps/ieee754/ldbl-128ibm-compat/Versions: Add
        __scalbf128_finite and __scalbieee128.
        * sysdeps/ieee754/ldbl-128ibm-compat/e_scalbf128.c: New file.
        * sysdeps/ieee754/ldbl-128ibm-compat/w_scalbf128.c: New file.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Versions      |  2 ++
 sysdeps/ieee754/ldbl-128ibm-compat/e_scalbf128.c | 21 ++++++++++++++++++
 sysdeps/ieee754/ldbl-128ibm-compat/w_scalbf128.c | 27 ++++++++++++++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/e_scalbf128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/w_scalbf128.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 322041132e..6496bd9187 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -90,6 +90,8 @@ libm {
     __rintieee128;
     __roundevenieee128;
     __roundieee128;
+    __scalbf128_finite;
+    __scalbieee128;
     __scalblnieee128;
     __scalbnieee128;
     __setpayloadieee128;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/e_scalbf128.c b/sysdeps/ieee754/ldbl-128ibm-compat/e_scalbf128.c
new file mode 100644
index 0000000000..355be95996
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/e_scalbf128.c
@@ -0,0 +1,21 @@
+/* Get mantissa of long double.
+   Copyright (C) 2018 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 <math-type-macros-float128.h>
+
+#include <math/e_scalb_template.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/w_scalbf128.c b/sysdeps/ieee754/ldbl-128ibm-compat/w_scalbf128.c
new file mode 100644
index 0000000000..4094fbfb19
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/w_scalbf128.c
@@ -0,0 +1,27 @@
+/* Get mantissa of long double.
+   Copyright (C) 2018 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 <float128_private.h>
+#include <math-type-macros-float128.h>
+
+#undef declare_mgen_alias
+#define declare_mgen_alias(a,b)
+#define __ieee754_scalbl __ieee754_scalbf128
+#include <w_scalb_template.c>
+
+libm_alias_float128_other_r_ldbl (__scalb, scalb,)
--
2.14.4

Reply | Threaded
Open this post in threaded view
|

[PATCH 08/12] ldbl-128ibm-compat: Provide a significand implementation

Tulio Magno Quites Machado Filho-2
In reply to this post by Tulio Magno Quites Machado Filho-2
Reuse the template in order to provide the global symbol
__significandieee128.

2018-06-19  Tulio Magno Quites Machado Filho  <[hidden email]>

        * sysdeps/ieee754/ldbl-128ibm-compat/Versions: Add __significandieee128.
        * sysdeps/ieee754/ldbl-128ibm-compat/s_significandf128.c: New file.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Versions        |  1 +
 .../ieee754/ldbl-128ibm-compat/s_significandf128.c | 25 ++++++++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/s_significandf128.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 6496bd9187..3c430f2074 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -96,6 +96,7 @@ libm {
     __scalbnieee128;
     __setpayloadieee128;
     __setpayloadsigieee128;
+    __significandieee128;
     __sincosieee128;
     __sinhieee128;
     __sinieee128;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/s_significandf128.c b/sysdeps/ieee754/ldbl-128ibm-compat/s_significandf128.c
new file mode 100644
index 0000000000..4ae0fde6a5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/s_significandf128.c
@@ -0,0 +1,25 @@
+/* Get mantissa of long double.
+   Copyright (C) 2018 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 <float128_private.h>
+#include <math-type-macros-float128.h>
+
+#define __significandf128 __significandieee128
+#undef declare_mgen_alias
+#define declare_mgen_alias(...)
+#include <math/s_significand_template.c>
--
2.14.4

Reply | Threaded
Open this post in threaded view
|

[PATCH 09/12] ldbl-128ibm-compat: Provide nexttoward functions

Tulio Magno Quites Machado Filho-2
In reply to this post by Tulio Magno Quites Machado Filho-2
From: "Gabriel F. T. Gomes" <[hidden email]>

The functions in the nexttoward family are special, in the sense that
they always have a long double argument, regardless of their suffix
(i.e.: nexttowardf and nexttoward have a long double argument, besides
the float and double arguments).

On top of that, they are also special because nexttoward functions are
not part of the _FloatN API, hence __nexttowardf128 do not exist.

This patch adds 4 new function implementations for the new long double
format:

  __nexttoward_to_ieee128
  __nexttowardf_to_ieee128
  __nexttowardieee128 (as an alias to __nextafterieee128)

2018-06-19  Gabriel F. T. Gomes  <[hidden email]>
            Tulio Magno Quites Machado Filho  <[hidden email]>

        * sysdeps/ieee754/ldbl-128ibm-compat/Versions: Add
        __nexttowardf_to_ieee128, __nexttowardieee128 and
        __nexttoward_to_ieee128.
        * sysdeps/ieee754/ldbl-128ibm-compat/s_nextafterf128.c: New file.
        * sysdeps/ieee754/ldbl-128ibm-compat/s_nexttowardf128.c: New file.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Versions        |  3 ++
 .../ieee754/ldbl-128ibm-compat/s_nextafterf128.c   | 20 ++++++++++++
 .../ieee754/ldbl-128ibm-compat/s_nexttowardf128.c  | 38 ++++++++++++++++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/s_nextafterf128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/s_nexttowardf128.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 3c430f2074..01e67aec1a 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -83,6 +83,9 @@ libm {
     __nearbyintieee128;
     __nextafterieee128;
     __nextdownieee128;
+    __nexttowardf_to_ieee128;
+    __nexttowardieee128;
+    __nexttoward_to_ieee128;
     __nextupieee128;
     __powieee128;
     __remainderieee128;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/s_nextafterf128.c b/sysdeps/ieee754/ldbl-128ibm-compat/s_nextafterf128.c
new file mode 100644
index 0000000000..419068f8b1
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/s_nextafterf128.c
@@ -0,0 +1,20 @@
+/* Provide nexttowardl and nextafterl implementations for IEEE long double.
+   Copyright (C) 2018 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 "../float128/s_nextafterf128.c"
+
+strong_alias (__nextafterieee128, __nexttowardieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/s_nexttowardf128.c b/sysdeps/ieee754/ldbl-128ibm-compat/s_nexttowardf128.c
new file mode 100644
index 0000000000..4403783a56
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/s_nexttowardf128.c
@@ -0,0 +1,38 @@
+/* Provide nexttoward[|f] implementations for IEEE long double.
+   Copyright (C) 2018 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 <float128_private.h>
+
+/* Build nexttoward functions with binary128 format.  */
+#undef weak_alias
+#define weak_alias(from, to)
+#undef libm_alias_ldouble
+#define libm_alias_ldouble(from, to)
+#undef __nexttoward
+#define __nexttoward __nexttoward_to_ieee128
+#include <sysdeps/ieee754/ldbl-128/s_nexttoward.c>
+
+#undef weak_alias
+#define weak_alias(from, to)
+#undef libm_alias_ldouble
+#define libm_alias_ldouble(from, to)
+#undef __nexttowardf
+#define __nexttowardf __nexttowardf_to_ieee128
+#include <sysdeps/ieee754/ldbl-128/s_nexttowardf.c>
+
+#include <libm-alias-ldouble.h>
--
2.14.4

Reply | Threaded
Open this post in threaded view
|

[PATCH 10/12] ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions

Tulio Magno Quites Machado Filho-2
In reply to this post by Tulio Magno Quites Machado Filho-2
Modify the headers to redirect long double functions to global __*f128
symbols or to __*ieee128 otherwise.

Most of the functions in math.h benefit from the infrastructure already
available for __LDBL_COMPAT.  The only exceptions are nexttowardf and
nexttoward that need especial treatment.

Both math/bits/mathcalls-helper-functions.h and math/bits/mathcalls.h
were modified in order to provide alternative redirection destinations
that are essential to support functions that should not be redirected to
the same name pattern of the rest of the functions, i.e.: __fpclassify,
__signbit, __iseqsig, __issignaling, isinf, finite and isnan, which will
be redirected to __*f128 instead of __*ieee128 used for the rest.

2018-06-19  Tulio Magno Quites Machado Filho  <[hidden email]>

        * include/math.h [__HAVE_DISTINCT_FLOAT128 &&
        !__HAVE_FLOAT128_UNLIKE_LDBL]: Avoid redirecting __finitel,
        __isinfl, __isnanl, __fpclassifyl, __issignalingl, __expl,
        __expml and sqrtl as they conflict with the redirections from
        math/math.h.
        * sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
        [__HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL]: Likewise
        for function iscanonical(_Float128).
        * math/math.h [__HAVE_DISTINCT_FLOAT128 &&
        !__HAVE_FLOAT128_UNLIKE_LDBL]: Redirect long double functions to
        __*f128 or _*ieee128.
        (__MATHDECL_ALIAS): New macro.
        * math/bits/mathcalls-helper-functions.h: Replace __MATHDECL_1
        with __MATHDECL_ALIAS.
        * math/bits/mathcalls.h: Likewise for isinf, finite and isnan.

Signed-off-by: Tulio Magno Quites Machado Filho <[hidden email]>
---
 include/math.h                                 | 12 ++++-
 math/bits/mathcalls-helper-functions.h         | 18 +++----
 math/bits/mathcalls.h                          |  9 ++--
 math/math.h                                    | 66 ++++++++++++++++++++++++--
 sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h |  6 ++-
 5 files changed, 94 insertions(+), 17 deletions(-)

diff --git a/include/math.h b/include/math.h
index e21d34b868..57d77cfd13 100644
--- a/include/math.h
+++ b/include/math.h
@@ -18,7 +18,9 @@ hidden_proto (__finitef)
 hidden_proto (__isinff)
 hidden_proto (__isnanf)
 
-#  ifndef __NO_LONG_DOUBLE_MATH
+#  if !defined __NO_LONG_DOUBLE_MATH \
+      && (!__HAVE_DISTINCT_FLOAT128 \
+  || (__HAVE_DISTINCT_FLOAT128 && __HAVE_FLOAT128_UNLIKE_LDBL))
 hidden_proto (__finitel)
 hidden_proto (__isinfl)
 hidden_proto (__isnanl)
@@ -40,7 +42,9 @@ libm_hidden_proto (__exp)
 libm_hidden_proto (__expf)
 libm_hidden_proto (__roundeven)
 
-# ifndef __NO_LONG_DOUBLE_MATH
+#  if !defined __NO_LONG_DOUBLE_MATH \
+  && (!__HAVE_DISTINCT_FLOAT128 \
+      || (__HAVE_DISTINCT_FLOAT128 && __HAVE_FLOAT128_UNLIKE_LDBL))
 libm_hidden_proto (__fpclassifyl)
 libm_hidden_proto (__issignalingl)
 libm_hidden_proto (__expl)
@@ -61,7 +65,11 @@ libm_hidden_proto (__expm1f128)
 float (sqrtf) (float) asm ("__ieee754_sqrtf");
 double (sqrt) (double) asm ("__ieee754_sqrt");
 #   ifndef __NO_LONG_DOUBLE_MATH
+/* Do not redirect sqrtl twice when the long double already redirects it.  */
+#    if !__HAVE_DISTINCT_FLOAT128 \
+ || (__HAVE_DISTINCT_FLOAT128 && __HAVE_FLOAT128_UNLIKE_LDBL)
 long double (sqrtl) (long double) asm ("__ieee754_sqrtl");
+#    endif
 #   endif
 #   if __HAVE_DISTINCT_FLOAT128 > 0
 _Float128 (sqrtf128) (_Float128) asm ("__ieee754_sqrtf128");
diff --git a/math/bits/mathcalls-helper-functions.h b/math/bits/mathcalls-helper-functions.h
index ac3115bfdc..a6d83bf4e6 100644
--- a/math/bits/mathcalls-helper-functions.h
+++ b/math/bits/mathcalls-helper-functions.h
@@ -16,28 +16,30 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-
 /* Classify given number.  */
-__MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value))
+__MATHDECL_ALIAS (int, __fpclassify,, (_Mdouble_ __value), fpclassify)
      __attribute__ ((__const__));
 
 /* Test for negative number.  */
-__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value))
+__MATHDECL_ALIAS (int, __signbit,, (_Mdouble_ __value), signbit)
      __attribute__ ((__const__));
 
 /* Return 0 if VALUE is finite or NaN, +1 if it
    is +Infinity, -1 if it is -Infinity.  */
-__MATHDECL_1 (int, __isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_ALIAS (int, __isinf,, (_Mdouble_ __value), isinf)
+  __attribute__ ((__const__));
 
 /* Return nonzero if VALUE is finite and not NaN.  Used by isfinite macro.  */
-__MATHDECL_1 (int, __finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_ALIAS (int, __finite,, (_Mdouble_ __value), finite)
+  __attribute__ ((__const__));
 
 /* Return nonzero if VALUE is not a number.  */
-__MATHDECL_1 (int, __isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_ALIAS (int, __isnan,, (_Mdouble_ __value), isnan)
+  __attribute__ ((__const__));
 
 /* Test equality.  */
-__MATHDECL_1 (int, __iseqsig,, (_Mdouble_ __x, _Mdouble_ __y));
+__MATHDECL_ALIAS (int, __iseqsig,, (_Mdouble_ __x, _Mdouble_ __y), iseqsig);
 
 /* Test for signaling NaN.  */
-__MATHDECL_1 (int, __issignaling,, (_Mdouble_ __value))
+__MATHDECL_ALIAS (int, __issignaling,, (_Mdouble_ __value), issignaling)
      __attribute__ ((__const__));
diff --git a/math/bits/mathcalls.h b/math/bits/mathcalls.h
index f4246a7881..9ace71bef6 100644
--- a/math/bits/mathcalls.h
+++ b/math/bits/mathcalls.h
@@ -173,12 +173,14 @@ __MATHCALL_FINITE (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
       && !__MATH_DECLARING_FLOATN
 /* Return 0 if VALUE is finite or NaN, +1 if it
    is +Infinity, -1 if it is -Infinity.  */
-__MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_ALIAS (int,isinf,, (_Mdouble_ __value), isinf)
+  __attribute__ ((__const__));
 # endif
 
 # if !__MATH_DECLARING_FLOATN
 /* Return nonzero if VALUE is finite and not NaN.  */
-__MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_ALIAS (int,finite,, (_Mdouble_ __value), finite)
+  __attribute__ ((__const__));
 
 /* Return the remainder of X/Y.  */
 __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
@@ -207,7 +209,8 @@ __MATHCALL (nan,, (const char *__tagb));
        || __MATH_DECLARING_DOUBLE == 0)) /* isnanf or isnanl don't.  */ \
       && !__MATH_DECLARING_FLOATN
 /* Return nonzero if VALUE is not a number.  */
-__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_ALIAS (int,isnan,, (_Mdouble_ __value), isnan)
+  __attribute__ ((__const__));
 # endif
 #endif
 
diff --git a/math/math.h b/math/math.h
index c1765e4c8c..8d0880b262 100644
--- a/math/math.h
+++ b/math/math.h
@@ -283,6 +283,10 @@ enum
   extern type __MATH_PRECNAME(function,suffix) args __THROW
 #define __MATHDECL_1(type, function, suffix, args) \
   __MATHDECL_1_IMPL(type, function, suffix, args)
+/* Ignore the alias by default.  The alias is only useful with
+   redirections.  */
+#define __MATHDECL_ALIAS(type, function, suffix, args, alias) \
+  __MATHDECL_1_IMPL(type, function, suffix, args)
 
 #define __MATHREDIR(type, function, suffix, args, to) \
   extern type __REDIRECT_NTH (__MATH_PRECNAME (function, suffix), args, to)
@@ -364,6 +368,39 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #   undef __MATHDECL_1
 #   define __MATHDECL_1(type, function,suffix, args) \
   __MATHREDIR(type, function, suffix, args, __CONCAT(function,suffix))
+
+#  elif __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL
+#   ifdef __REDIRECT_NTH
+#    ifdef __USE_ISOC99
+extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y),
+    __nexttowardf_to_ieee128)
+  __attribute__ ((__const__));
+extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y),
+     __nexttoward_to_ieee128)
+  __attribute__ ((__const__));
+
+#define __dremieee128 __remainderieee128
+#define __gammaieee128 __lgammaieee128
+
+#    endif
+#   endif
+
+#   undef __MATHDECL_1
+#   undef __MATHDECL_ALIAS
+
+#   define __REDIRTO(function, suffix) \
+  __ ## function ## ieee128 ## suffix
+#   define __REDIRTO_ALT(function, suffix) \
+  __ ## function ## f128 ## suffix
+
+#   undef __MATH_FINITE_NAME
+#   define __MATH_FINITE_NAME(function, suffix) \
+  __MATH_FINITE_NAMEX (, __REDIRTO_ALT (function, suffix), _finite)
+
+#   define __MATHDECL_1(type, function, suffix, args) \
+  __MATHREDIR (type, function, suffix, args, __REDIRTO (function, suffix))
+#   define __MATHDECL_ALIAS(type, function, suffix, args, alias) \
+  __MATHREDIR (type, function, suffix, args, __REDIRTO_ALT (alias, suffix))
 #  endif
 
 /* Include the file of declarations again, this time using `long double'
@@ -376,15 +413,25 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #  define __MATH_DECLARE_LDOUBLE   1
 #  include <bits/mathcalls-helper-functions.h>
 #  include <bits/mathcalls.h>
+
 #  undef _Mdouble_
 #  undef __MATH_PRECNAME
 #  undef __MATH_DECLARING_DOUBLE
 #  undef __MATH_DECLARING_FLOATN
 
-#  if defined __LDBL_COMPAT
+#  if defined __LDBL_COMPAT \
+      || (__HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL)
+#   undef __REDIRTO
+#   undef __REDIRTO_ALT
 #   undef __MATHDECL_1
+#   undef __MATHDECL_ALIAS
+#   undef __MATH_FINITE_NAME
+#   define __MATH_FINITE_NAME(function, suffix) \
+  __MATH_FINITE_NAME_IMPL (function, suffix)
 #   define __MATHDECL_1(type, function, suffix, args) \
   __MATHDECL_1_IMPL(type, function, suffix, args)
+#   define __MATHDECL_ALIAS(type, function, suffix, args, alias) \
+  __MATHDECL_1_IMPL(type, function, suffix, args)
 #  endif
 # endif /* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */
 
@@ -720,6 +767,7 @@ extern int signgam;
 #undef __REDIRTO_PUBLIC_X
 #undef __MATHDECL_1_IMPL
 #undef __MATHDECL_1
+#undef __MATHDECL_ALIAS
 #undef __MATHDECL
 #undef __MATHCALL
 #undef __MATHCALL_VEC
@@ -759,6 +807,11 @@ extern int signgam;
 # ifdef __LDBL_COMPAT
 #  define __MATHCALL_REDIR_NAME(name) f ## name
 #  undef __MATHCALL_NARROW
+#  define __MATHCALL_NARROW(func, redir, nargs) \
+  __MATHCALL_NARROW_REDIR (func, redir, nargs)
+# elif __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL
+#  define __MATHCALL_REDIR_NAME(name) __ ## f32 ## name ## ieee128
+#  undef __MATHCALL_NARROW
 #  define __MATHCALL_NARROW(func, redir, nargs) \
   __MATHCALL_NARROW_REDIR (func, redir, nargs)
 # endif
@@ -766,7 +819,8 @@ extern int signgam;
 # undef _Mret_
 # undef _Marg_
 # undef __MATHCALL_NAME
-# ifdef __LDBL_COMPAT
+# if defined __LDBL_COMPAT \
+     || (__HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL)
 #  undef __MATHCALL_REDIR_NAME
 #  undef __MATHCALL_NARROW
 #  define __MATHCALL_NARROW(func, redir, nargs) \
@@ -779,6 +833,11 @@ extern int signgam;
 # ifdef __LDBL_COMPAT
 #  define __MATHCALL_REDIR_NAME(name) __nldbl_d ## name ## l
 #  undef __MATHCALL_NARROW
+#  define __MATHCALL_NARROW(func, redir, nargs) \
+  __MATHCALL_NARROW_REDIR (func, redir, nargs)
+# elif __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL
+#  define __MATHCALL_REDIR_NAME(name) __ ## f64 ## name ## ieee128
+#  undef __MATHCALL_NARROW
 #  define __MATHCALL_NARROW(func, redir, nargs) \
   __MATHCALL_NARROW_REDIR (func, redir, nargs)
 # endif
@@ -786,7 +845,8 @@ extern int signgam;
 # undef _Mret_
 # undef _Marg_
 # undef __MATHCALL_NAME
-# ifdef __LDBL_COMPAT
+# if defined __LDBL_COMPAT \
+     || (__HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL)
 #  undef __MATHCALL_REDIR_NAME
 #  undef __MATHCALL_NARROW
 #  define __MATHCALL_NARROW(func, redir, nargs) \
diff --git a/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h b/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
index 60c54cca46..f54e5d9ddb 100644
--- a/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
+++ b/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
@@ -50,7 +50,11 @@ extern "C++" {
 inline int iscanonical (float __val) { return __iscanonicalf (__val); }
 inline int iscanonical (double __val) { return __iscanonical (__val); }
 inline int iscanonical (long double __val) { return __iscanonicall (__val); }
-#  if __HAVE_DISTINCT_FLOAT128
+/* When using an IEEE 128-bit long double, _Float128 is defined as long double
+   in C++.  */
+#  if __HAVE_DISTINCT_FLOAT128 \
+      && (!defined __cplusplus \
+  || defined __cplusplus && __HAVE_FLOAT128_UNLIKE_LDBL)
 inline int iscanonical (_Float128 __val) { return __iscanonicalf128 (__val); }
 #  endif
 }
--
2.14.4

Reply | Threaded
Open this post in threaded view
|

[PATCH 11/12] ldbl-128ibm-compat: Redirect complex math functions

Tulio Magno Quites Machado Filho-2
In reply to this post by Tulio Magno Quites Machado Filho-2
From: Rajalakshmi Srinivasaraghavan <[hidden email]>

The API doesn't change, i.e. compilers using a long double format compatible
with the IEEE 128-bit extended precision format are redirected from *l
functions to __*ieee128 symbols using the same mechanism already
used with -mlong-double-64 for complex math functions.

2018-06-19  Rajalakshmi Srinivasaraghavan  <[hidden email]>

        * math/complex.h [__HAVE_DISTINCT_FLOAT128 &&
        !__HAVE_FLOAT128_UNLIKE_LDBL]: Redirect long double functions
        to __*ieee128.
---
 math/complex.h | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/math/complex.h b/math/complex.h
index 40cf8e0705..8e917105bc 100644
--- a/math/complex.h
+++ b/math/complex.h
@@ -95,9 +95,11 @@ __BEGIN_DECLS
 
 #define __MATHCALL(function, args) \
   __MATHDECL (_Mdouble_complex_,function, args)
-#define __MATHDECL(type, function, args) \
+#define __MATHDECL_IMPL(type, function, args) \
   __MATHDECL_1(type, function, args); \
   __MATHDECL_1(type, __CONCAT(__,function), args)
+#define __MATHDECL(type, function, args) \
+  __MATHDECL_IMPL(type, function, args)
 #define __MATHDECL_1_IMPL(type, function, args) \
   extern type __MATH_PRECNAME(function) args __THROW
 #define __MATHDECL_1(type, function, args) \
@@ -124,13 +126,28 @@ __BEGIN_DECLS
 #  undef __MATHDECL_1
 #  define __MATHDECL_1(type, function, args) \
   extern type __REDIRECT_NTH(__MATH_PRECNAME(function), args, function)
+# elif __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL
+#  undef __MATHDECL_1
+#  undef __MATHDECL
+#  define __REDIR_TO(function) \
+  __ ## function ## ieee128
+#  define __MATHDECL_1(type, function, alias, args) \
+  extern type __REDIRECT_NTH(__MATH_PRECNAME(function), args, alias)
+#define __MATHDECL(type, function, args) \
+  __MATHDECL_1(type, function, __REDIR_TO(function), args); \
+  __MATHDECL_1(type, __CONCAT(__,function), __REDIR_TO(function), args)
 # endif
 
 # define _Mdouble_ long double
 # define __MATH_PRECNAME(name) name##l
 # include <bits/cmathcalls.h>
-# if defined __LDBL_COMPAT
+# if defined __LDBL_COMPAT \
+     || (__HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL)
+#  undef __REDIR_TO
 #  undef __MATHDECL_1
+#  undef __MATHDECL
+#define __MATHDECL(type, function, args) \
+  __MATHDECL_IMPL(type, function, args)
 #  define __MATHDECL_1(type, function, args) \
   __MATHDECL_1_IMPL(type, function, args)
 # endif
--
2.14.4

Reply | Threaded
Open this post in threaded view
|

[PATCH 12/12] ldbl-128ibm-compat: Provide ieee128 symbols to narrow functions

Tulio Magno Quites Machado Filho-2
In reply to this post by Tulio Magno Quites Machado Filho-2
Add ieee128 aliases for faddl, fdivl, fmull, fsubl, daddl, ddivl, dmull, dsubl.

2018-06-19  Tulio Magno Quites Machado Filho  <[hidden email]>

        * math/math-narrow.h [__HAVE_DISTINCT_FLOAT128 &&
        !__HAVE_FLOAT128_UNLIKE_LDBL] (libm_alias_float32_float128,
        libm_alias_float64_float128): Provide *ieee128 aliases.
        * sysdeps/ieee754/ldbl-128ibm-compat/Versions: Add
        __f32addieee128, __f32divieee128, __f32mulieee128,
        __f32subieee128, __f64addieee128, __f64divieee128,
        __f64mulieee128 and __f64subieee128.

Signed-off-by: Tulio Magno Quites Machado Filho <[hidden email]>
---
 math/math-narrow.h                          | 10 ++++++++++
 sysdeps/ieee754/ldbl-128ibm-compat/Versions |  8 ++++++++
 2 files changed, 18 insertions(+)

diff --git a/math/math-narrow.h b/math/math-narrow.h
index c4065e88f7..bfc1c8dced 100644
--- a/math/math-narrow.h
+++ b/math/math-narrow.h
@@ -356,6 +356,16 @@
   libm_alias_float32_float128_main (func)
 # define libm_alias_float64_float128(func) \
   libm_alias_float64_float128_main (func)
+#elif __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL
+# define libm_alias_float32_float128(func) \
+  libm_alias_float32_float128_main (func) \
+  weak_alias (__f32 ## func ## f128, f32 ## func ## f64x) \
+  weak_alias (__f32 ## func ## f128, __ ## f32 ## func ## ieee128)
+# define libm_alias_float64_float128(func) \
+  libm_alias_float64_float128_main (func) \
+  weak_alias (__f64 ## func ## f128, f64 ## func ## f64x) \
+  weak_alias (__f64 ## func ## f128, f32x ## func ## f64x) \
+  weak_alias (__f64 ## func ## f128, __ ## f64 ## func ## ieee128)
 #else
 # define libm_alias_float32_float128(func) \
   libm_alias_float32_float128_main (func) \
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 01e67aec1a..8fc6fb05f3 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -47,6 +47,14 @@ libm {
     __exp2ieee128;
     __expieee128;
     __expm1ieee128;
+    __f32addieee128;
+    __f32divieee128;
+    __f32mulieee128;
+    __f32subieee128;
+    __f64addieee128;
+    __f64divieee128;
+    __f64mulieee128;
+    __f64subieee128;
     __fabsieee128;
     __fdimieee128;
     __floorieee128;
--
2.14.4

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 01/12] Undefine redirections after long double definition on __LDBL_COMPAT [BZ #23294]

Joseph Myers
In reply to this post by Tulio Magno Quites Machado Filho-2
I'd expect this patch to include tests (for both math.h and complex.h,
that fail before and pass after the patch) in sysdeps/ieee754/ldbl-opt.

--
Joseph S. Myers
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 02/12] Move declare_mgen_finite_alias definition

Joseph Myers
In reply to this post by Tulio Magno Quites Machado Filho-2
How does this patch differ from the version I already approved?

--
Joseph S. Myers
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 05/12] Refactor math/bits/math-finite.h, reusing math/bits/mathcalls.h [BZ #23292]

Joseph Myers
In reply to this post by Tulio Magno Quites Machado Filho-2
I don't see anything in this patch to ensure that the redirections now
done through bits/mathcalls.h don't apply on ia64, as that doesn't have
__*_finite (e.g. a new bits/ header defining a macro for whether _finite
redirects are supported, for which ia64 provides its own version).

--
Joseph S. Myers
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 12/12] ldbl-128ibm-compat: Provide ieee128 symbols to narrow functions

Joseph Myers
In reply to this post by Tulio Magno Quites Machado Filho-2
On Wed, 20 Jun 2018, Tulio Magno Quites Machado Filho wrote:

> Add ieee128 aliases for faddl, fdivl, fmull, fsubl, daddl, ddivl, dmull, dsubl.
>
> 2018-06-19  Tulio Magno Quites Machado Filho  <[hidden email]>
>
> * math/math-narrow.h [__HAVE_DISTINCT_FLOAT128 &&
> !__HAVE_FLOAT128_UNLIKE_LDBL] (libm_alias_float32_float128,

I don't think __HAVE_FLOAT128_UNLIKE_LDBL is logically right here.  That's
about the current compilation, i.e. about whether these particular files
end up getting built with IEEE long double.  I don't know what files in
the source tree might end up getting built with what long double setting,
but it shouldn't matter for these files whether they are built with IEEE
long double or not.

Your property is something different, "glibc has *ieee128 aliases for
_Float128 functions" (a property of the glibc configuration, not of the
current compilation, but a different property from
__HAVE_DISTINCT_FLOAT128).  That suggests to me that either you need some
new macro tested by this file, or you need e.g.
math-narrow-alias-float128.h (included by math-narrow.h) which contains
these float128 alias macros and for which ldbl-128ibm-compat provides a
different version.

--
Joseph S. Myers
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 02/12] Move declare_mgen_finite_alias definition

Tulio Magno Quites Machado Filho-2
In reply to this post by Joseph Myers
Joseph Myers <[hidden email]> writes:

> How does this patch differ from the version I already approved?

There is no difference.  I re-sent it because it's part of the patch set.
I can merge it you believe it's OK.

--
Tulio Magno

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 03/12] Add a generic scalb implementation

Joseph Myers
In reply to this post by Tulio Magno Quites Machado Filho-2
On Tue, 19 Jun 2018, Tulio Magno Quites Machado Filho wrote:

> Create templates for e_scabl, w_scalb and w_scalb_compat.

I don't think w_scalb_compat should become a template, just a new w_scalb
(with the compat files having all their contents become conditional on
LIBM_SVID_COMPAT).  Then you don't need to do anything with M_K_STANDARD,
because __kernel_standard is only used in compat files (and note the
arguments passed to it are different numbers for float / double / long
double, so M_K_STANDARD in this patch isn't actually correct).  And
w_scalbF_compat would stay in libm-compat-calls, so no empty float128
version would be needed (whereas an empty float128 version of w_scalb
would be needed).

--
Joseph S. Myers
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 04/12] Add a generic significand implementation

Joseph Myers
In reply to this post by Tulio Magno Quites Machado Filho-2
On Tue, 19 Jun 2018, Tulio Magno Quites Machado Filho wrote:

> Create a template for significand.
>
> 2018-06-19  Tulio Magno Quites Machado Filho  <[hidden email]>
>
> * math/Makefile (libm-calls): Move s_significandF to...
> (gen-libm-calls): ... here.
> * math/s_significand_template.c: New file.
> * math/s_significand.c: Removed.
> * math/s_significandf.c: Removed.
> * math/s_significandl.c: Removed.
> * sysdeps/ieee754/ldbl-opt/s_significand.c: Removed.
> * sysdeps/ieee754/ldbl-opt/s_significandl.c: Removed.

OK.

--
Joseph S. Myers
[hidden email]
123