public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 4/9] ldbl-128ibm-compat: Add a generic significand() implementation
  2018-06-06 22:41 [PATCH 0/9] Introduce ieee128 symbols and redirections Tulio Magno Quites Machado Filho
  2018-06-06 22:41 ` [PATCH 1/9] ldbl-128ibm-compat: Create libm-alias-float128.h Tulio Magno Quites Machado Filho
@ 2018-06-06 22:41 ` Tulio Magno Quites Machado Filho
  2018-06-07 13:38   ` Joseph Myers
  2018-06-06 22:41 ` [PATCH 3/9] ldbl-128ibm-compat: Provide a generic scalb implementation Tulio Magno Quites Machado Filho
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-06 22:41 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph, gabriel, raji

Create a template for significand and reuse it in the ldbl-128ibm-compat directory.

2018-06-06  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>

	* math/s_significand_template.c: New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/Versions: Add
	__significandieee128.
	* sysdeps/ieee754/ldbl-128ibm-compat/s_significandf128.c: New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/s_significandl.c: New file.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
---
 math/s_significand_template.c                      | 33 ++++++++++++++++++++++
 sysdeps/ieee754/ldbl-128ibm-compat/Versions        |  1 +
 .../ieee754/ldbl-128ibm-compat/s_significandf128.c | 25 ++++++++++++++++
 3 files changed, 59 insertions(+)
 create mode 100644 math/s_significand_template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/s_significandf128.c

diff --git a/math/s_significand_template.c b/math/s_significand_template.c
new file mode 100644
index 0000000000..c95017e683
--- /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, (long double) - 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/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 8133d874df..06c19569c5 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -110,6 +110,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

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

* [PATCH 0/9] Introduce ieee128 symbols and redirections
@ 2018-06-06 22:41 Tulio Magno Quites Machado Filho
  2018-06-06 22:41 ` [PATCH 1/9] ldbl-128ibm-compat: Create libm-alias-float128.h Tulio Magno Quites Machado Filho
                   ` (9 more replies)
  0 siblings, 10 replies; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-06 22:41 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph, gabriel, raji

*** BLURB HERE ***

This patchset implements what we have discussed recently about the powerpc64le
long double migration for math and complex math functions.

It adds __*ieee128 symbols to all functions that do not provide a respective
global __*f128 symbol.  Which means that __finitef128, __isnanf128,
__issignalingf128, __iseqsigf128, __fpclassifyf128, __signbitf128,
__isinff128 and all *f128_finite symbols are reused.

A list with all the new symbols is available with file
sysdeps/ieee754/ldbl-128ibm-compat/Versions.


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 (7):
  ldbl-128ibm-compat: Create libm-alias-float128.h
  Move declare_mgen_finite_alias definition
  ldbl-128ibm-compat: Provide a generic scalb implementation
  ldbl-128ibm-compat: Add a generic significand() implementation
  ldbl-128ibm-compat: Provide ISO C functions not provided by the
    _Float128 API
  Refactor math-finite.h and introduce mathcalls-redir.h
  ldbl-128ibm-compat: Redirect long double functions to f128/ieee128
    functions

 include/bits/mathcalls-redir.h                     |   1 +
 include/math.h                                     |  12 +-
 math/Makefile                                      |   3 +-
 math/bits/math-finite.h                            | 151 ++-----
 math/bits/mathcalls-redir.h                        | 460 +++++++++++++++++++++
 math/complex.h                                     |  28 +-
 math/e_exp2_template.c                             |   7 -
 math/e_scalb_template.c                            |  54 +++
 math/math.h                                        |  91 +++-
 math/s_significand_template.c                      |  33 ++
 math/w_scalb_template.c                            |  95 +++++
 sysdeps/generic/math-type-macros.h                 |  15 +
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile        |   6 +
 sysdeps/ieee754/ldbl-128ibm-compat/Versions        | 136 ++++++
 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_lgammaf128.c  |  22 +
 .../ieee754/ldbl-128ibm-compat/w_remainderf128.c   |  22 +
 sysdeps/ieee754/ldbl-128ibm-compat/w_scalbf128.c   |  27 ++
 sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h     |   6 +-
 23 files changed, 1204 insertions(+), 133 deletions(-)
 create mode 100644 include/bits/mathcalls-redir.h
 create mode 100644 math/bits/mathcalls-redir.h
 create mode 100644 math/e_scalb_template.c
 create mode 100644 math/s_significand_template.c
 create mode 100644 math/w_scalb_template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/Makefile
 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_lgammaf128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/w_remainderf128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/w_scalbf128.c

-- 
2.14.4

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

* [PATCH 2/9] Move declare_mgen_finite_alias definition
  2018-06-06 22:41 [PATCH 0/9] Introduce ieee128 symbols and redirections Tulio Magno Quites Machado Filho
                   ` (2 preceding siblings ...)
  2018-06-06 22:41 ` [PATCH 3/9] ldbl-128ibm-compat: Provide a generic scalb implementation Tulio Magno Quites Machado Filho
@ 2018-06-06 22:41 ` Tulio Magno Quites Machado Filho
  2018-06-07 13:25   ` Joseph Myers
  2018-06-06 22:42 ` [PATCH 7/9] Refactor math-finite.h and introduce mathcalls-redir.h Tulio Magno Quites Machado Filho
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-06 22:41 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph, gabriel, raji

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-06  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>

	* 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 <tuliom@linux.ibm.com>
---
 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

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

* [PATCH 3/9] ldbl-128ibm-compat: Provide a generic scalb implementation
  2018-06-06 22:41 [PATCH 0/9] Introduce ieee128 symbols and redirections Tulio Magno Quites Machado Filho
  2018-06-06 22:41 ` [PATCH 1/9] ldbl-128ibm-compat: Create libm-alias-float128.h Tulio Magno Quites Machado Filho
  2018-06-06 22:41 ` [PATCH 4/9] ldbl-128ibm-compat: Add a generic significand() implementation Tulio Magno Quites Machado Filho
@ 2018-06-06 22:41 ` Tulio Magno Quites Machado Filho
  2018-06-06 22:41 ` [PATCH 2/9] Move declare_mgen_finite_alias definition Tulio Magno Quites Machado Filho
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-06 22:41 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph, gabriel, raji

Create templates for scalb and reuse them in ldbl-128ibm-compat in order
to provide the local symbol __scalbf128 and the global symbol
__scalbieee128.

2018-06-06  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>
	    Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>

	* math/e_scalb_template.c: New file.
	* math/w_scalb_template.c: New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/Makefile: New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/Versions: Add __scalbieee128.
	* sysdeps/ieee754/ldbl-128ibm-compat/e_scalbf128.c: New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/w_scalbf128.c: New file.
---
 math/e_scalb_template.c                          | 54 ++++++++++++++
 math/w_scalb_template.c                          | 95 ++++++++++++++++++++++++
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile      |  6 ++
 sysdeps/ieee754/ldbl-128ibm-compat/Versions      |  1 +
 sysdeps/ieee754/ldbl-128ibm-compat/e_scalbf128.c | 21 ++++++
 sysdeps/ieee754/ldbl-128ibm-compat/w_scalbf128.c | 27 +++++++
 6 files changed, 204 insertions(+)
 create mode 100644 math/e_scalb_template.c
 create mode 100644 math/w_scalb_template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/Makefile
 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/math/e_scalb_template.c b/math/e_scalb_template.c
new file mode 100644
index 0000000000..02663424a7
--- /dev/null
+++ b/math/e_scalb_template.c
@@ -0,0 +1,54 @@
+/* Multiply by integral power of radix.
+   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.h>
+#include <math_private.h>
+
+static FLOAT
+__attribute__ ((noinline))
+invalid_fn (FLOAT x, FLOAT fn)
+{
+  if (M_SUF (__rint) (fn) != fn)
+    return (fn - fn) / (fn - fn);
+  else if (fn > M_LIT (65000.0))
+    return M_SUF (__scalbn) (x, 65000);
+  else
+    return M_SUF (__scalbn) (x,-65000);
+}
+
+
+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 > M_LIT (0.0))
+	return x * fn;
+      if (x == M_LIT (0.0))
+	return x;
+      return x / -fn;
+    }
+  if (__glibc_unlikely (M_FABS (fn) >= M_LIT (0x1p31)
+			|| (FLOAT) (int) fn != fn))
+    return invalid_fn (x, fn);
+
+  return M_SCALBN (x, (int) fn);
+}
+declare_mgen_finite_alias (__ieee754_scalb, __scalb)
diff --git a/math/w_scalb_template.c b/math/w_scalb_template.c
new file mode 100644
index 0000000000..b42659e561
--- /dev/null
+++ b/math/w_scalb_template.c
@@ -0,0 +1,95 @@
+/* Wrapper to set errno for scalb.
+   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/>.  */
+
+/* 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))
+M_DECL_FUNC (sysv_scalb) (FLOAT x, FLOAT fn)
+{
+  FLOAT z = M_SUF (__ieee754_scalb) (x, fn);
+
+  if (__glibc_unlikely (isinf (z)))
+    {
+      if (isfinite (x))
+	{
+	  /* scalb overflow.  */
+	  __set_errno (ERANGE);
+	  return x > M_LIT (0.0) ? HUGE_VAL : -HUGE_VAL;
+	}
+      else
+	__set_errno (ERANGE);
+    }
+  else if (__builtin_expect (z == M_LIT (0.0), 0) && z != x)
+    {
+      /* scalb underflow.  */
+      __set_errno (ERANGE);
+      return M_LIT (0.0);
+    }
+
+  return z;
+}
+#endif
+
+
+/* Wrapper scalb */
+FLOAT
+M_DECL_FUNC (__scalb) (FLOAT x, FLOAT fn)
+{
+#if LIBM_SVID_COMPAT
+  if (__glibc_unlikely (_LIB_VERSION == _SVID_))
+    return M_SUF (sysv_scalb) (x, fn);
+  else
+#endif
+    {
+      FLOAT z = __ieee754_scalbl (x, fn);
+
+      if (__glibc_unlikely (!isfinite (z) || z == M_LIT (0.0)))
+	{
+	  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 != M_LIT (0.0) && !isinf (fn))
+		__set_errno (ERANGE);
+	    }
+	}
+      return z;
+    }
+}
+declare_mgen_alias (__scalb, scalb);
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
new file mode 100644
index 0000000000..47d2632850
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -0,0 +1,6 @@
+ifeq ($(subdir),math)
+# scalb is a libm-compat-call, so it gets excluded from f128.
+# It's necessary to build it for f128 in order to provide long double symbols
+# based on the f128 implementation.
+libm-routines += w_scalbf128
+endif
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index af6b4b3f60..8133d874df 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -105,6 +105,7 @@ libm {
     __rintieee128;
     __roundevenieee128;
     __roundieee128;
+    __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

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

* [PATCH 1/9] ldbl-128ibm-compat: Create libm-alias-float128.h
  2018-06-06 22:41 [PATCH 0/9] Introduce ieee128 symbols and redirections Tulio Magno Quites Machado Filho
@ 2018-06-06 22:41 ` Tulio Magno Quites Machado Filho
  2018-06-06 23:05   ` Joseph Myers
  2018-06-06 22:41 ` [PATCH 4/9] ldbl-128ibm-compat: Add a generic significand() implementation Tulio Magno Quites Machado Filho
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-06 22:41 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph, gabriel, raji

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-06  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>
	    Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>

	* 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        | 129 +++++++++++++++++++++
 .../ldbl-128ibm-compat/libm-alias-float128.h       |  64 ++++++++++
 2 files changed, 193 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..af6b4b3f60
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -0,0 +1,129 @@
+%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;
+    __f32addieee128;
+    __f32divieee128;
+    __f32mulieee128;
+    __f32subieee128;
+    __f64addieee128;
+    __f64divieee128;
+    __f64mulieee128;
+    __f64subieee128;
+    __f64xaddieee128;
+    __f64xdivieee128;
+    __f64xmulieee128;
+    __f64xsubieee128;
+    __fabsieee128;
+    __fdimieee128;
+    __floorieee128;
+    __fmaieee128;
+    __fmaxieee128;
+    __fmaxmagieee128;
+    __fminieee128;
+    __fminmagieee128;
+    __fmodieee128;
+    __frexpieee128;
+    __fromfpieee128;
+    __fromfpxieee128;
+    __gamma_productieee128;
+    __getpayloadieee128;
+    __hypotieee128;
+    __ilogbieee128;
+    __j0ieee128;
+    __j1ieee128;
+    __jnieee128;
+    __ldexpieee128;
+    __lgammaieee128;
+    __lgammaieee128_r;
+    __lgamma_negieee128;
+    __lgamma_productieee128;
+    __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;
+    __x2y2m1ieee128;
+    __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

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

* [PATCH 8/9] ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions
  2018-06-06 22:41 [PATCH 0/9] Introduce ieee128 symbols and redirections Tulio Magno Quites Machado Filho
                   ` (6 preceding siblings ...)
  2018-06-06 22:42 ` [PATCH 5/9] ldbl-128ibm-compat: Provide ISO C functions not provided by the _Float128 API Tulio Magno Quites Machado Filho
@ 2018-06-06 22:42 ` Tulio Magno Quites Machado Filho
  2018-06-06 22:43 ` [PATCH 9/9] ldbl-128ibm-compat: Redirect complex math functions Tulio Magno Quites Machado Filho
  2018-06-06 23:11 ` [PATCH 0/9] Introduce ieee128 symbols and redirections Joseph Myers
  9 siblings, 0 replies; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-06 22:42 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph, gabriel, raji

Modify the headers to redirect long double functions to global __*f128
symbols or to __*ieee128 otherwise.

Most of the functions benefit from math-redir.h.  The only exceptions
are nexttowardf and nexttoward that need especial treatment.

2018-06-06  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>

	* 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, reusing mathcalls-redir.h.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
---
 include/math.h                                 | 12 +++++-
 math/math.h                                    | 57 +++++++++++++++++++++++++-
 sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h |  6 ++-
 3 files changed, 70 insertions(+), 5 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/math.h b/math/math.h
index 3edf275e26..6ad6c7f6d0 100644
--- a/math/math.h
+++ b/math/math.h
@@ -348,6 +348,42 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #  define __MATH_DECLARE_LDOUBLE   1
 #  include <bits/mathcalls-helper-functions.h>
 #  include <bits/mathcalls.h>
+
+/* Provide ieee long double function redirection.  */
+#  if !defined __LDBL_COMPAT \
+      && __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL
+#   define __REDIRFROM_X(function, reentrant) \
+  function ## l ## reentrant
+#   define __REDIRTO_X(function, reentrant) \
+  __ ## function ## ieee128 ## reentrant
+#   define __REDIRTO_ALT_X(function, reentrant)	\
+  __ ## function ## f128 ## reentrant
+#   define __MATH_REDIR_X(type, from, args, to)			\
+  extern type __REDIRECT_NTH (from, args, to);			\
+  extern type __REDIRECT_NTH (__CONCAT(__,from), args, to);
+#   if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+/* Do not redirect when finite functions are requested.  Leave this job to
+   bits/math-finite.h.  */
+#    define __MATH_REDIR_FINITE 0
+#   else
+#    define __MATH_REDIR_FINITE 1
+#   endif
+#   define __MATH_REDIR_NON_FINITE 1
+#   include <bits/mathcalls-redir.h>
+/* Redirect all nexttoward functions when redirecting long double.  */
+__MATH_REDIR_X (float, nexttowardf, (float __x, long double __y), \
+		__REDIRTO_X (nexttowardf_to_,));
+__MATH_REDIR_X (double, nexttoward, (double __x, long double __y), \
+		__REDIRTO_X (nexttoward_to_,));
+
+#   undef __MATH_REDIR_NON_FINITE
+#   undef __MATH_REDIR_FINITE
+#   undef __MATH_REDIR_X
+#   undef __REDIRTO_ALT_X
+#   undef __REDIRTO_X
+#   undef __REDIRFROM_X
+#  endif
+
 #  undef _Mdouble_
 #  undef __MATH_PRECNAME
 #  undef __MATH_DECLARING_DOUBLE
@@ -511,6 +547,11 @@ extern long double __REDIRECT_NTH (nexttowardl,
 # 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 ## f128
+#  undef __MATHCALL_NARROW
 #  define __MATHCALL_NARROW(func, redir, nargs) \
   __MATHCALL_NARROW_REDIR (func, redir, nargs)
 # endif
@@ -518,7 +559,8 @@ extern long double __REDIRECT_NTH (nexttowardl,
 # 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) \
@@ -531,6 +573,11 @@ extern long double __REDIRECT_NTH (nexttowardl,
 # 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 ## f128
+#  undef __MATHCALL_NARROW
 #  define __MATHCALL_NARROW(func, redir, nargs) \
   __MATHCALL_NARROW_REDIR (func, redir, nargs)
 # endif
@@ -538,7 +585,8 @@ extern long double __REDIRECT_NTH (nexttowardl,
 # 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) \
@@ -1296,6 +1344,11 @@ iszero (__T __val)
    __ ## 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
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

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

* [PATCH 5/9] ldbl-128ibm-compat: Provide ISO C functions not provided by the _Float128 API
  2018-06-06 22:41 [PATCH 0/9] Introduce ieee128 symbols and redirections Tulio Magno Quites Machado Filho
                   ` (5 preceding siblings ...)
  2018-06-06 22:42 ` [PATCH 6/9] ldbl-128ibm-compat: Provide nexttoward functions Tulio Magno Quites Machado Filho
@ 2018-06-06 22:42 ` Tulio Magno Quites Machado Filho
  2018-06-07 14:51   ` Joseph Myers
  2018-06-06 22:42 ` [PATCH 8/9] ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions Tulio Magno Quites Machado Filho
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-06 22:42 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph, gabriel, raji

These functions do not exist in the float128 api, but they need to be
provided for long double (*l api) because they are part of ISO C.

This patch only adds the exported symbols that are used by user
programs, i.e. __gammaieee128 and __dremieee128.

2018-06-06  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>
	    Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>

	* sysdeps/ieee754/ldbl-128ibm-compat/Versions: Add __dremieee128
	and __gammaieee128.
	* sysdeps/ieee754/ldbl-128ibm-compat/w_lgammaf128.c: New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/w_remainderf128.c: New file.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Versions        |  2 ++
 sysdeps/ieee754/ldbl-128ibm-compat/w_lgammaf128.c  | 22 ++++++++++++++++++++++
 .../ieee754/ldbl-128ibm-compat/w_remainderf128.c   | 22 ++++++++++++++++++++++
 3 files changed, 46 insertions(+)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/w_lgammaf128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/w_remainderf128.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 06c19569c5..b7efe84918 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -41,6 +41,7 @@ libm {
     __csqrtieee128;
     __ctanhieee128;
     __ctanieee128;
+    __dremieee128;
     __erfcieee128;
     __erfieee128;
     __exp10ieee128;
@@ -71,6 +72,7 @@ libm {
     __frexpieee128;
     __fromfpieee128;
     __fromfpxieee128;
+    __gammaieee128;
     __gamma_productieee128;
     __getpayloadieee128;
     __hypotieee128;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/w_lgammaf128.c b/sysdeps/ieee754/ldbl-128ibm-compat/w_lgammaf128.c
new file mode 100644
index 0000000000..2b213783da
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/w_lgammaf128.c
@@ -0,0 +1,22 @@
+/* Deprecated gammal 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/>.  */
+
+#include <math-type-macros-float128.h>
+#include <w_lgamma_template.c>
+
+libm_alias_float128_other_r_ldbl(__lgamma, gamma,)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/w_remainderf128.c b/sysdeps/ieee754/ldbl-128ibm-compat/w_remainderf128.c
new file mode 100644
index 0000000000..218b8d8a75
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/w_remainderf128.c
@@ -0,0 +1,22 @@
+/* Deprecated dreml 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/>.  */
+
+#include <math-type-macros-float128.h>
+#include <w_remainder_template.c>
+
+libm_alias_float128_other_r_ldbl (__remainder, drem, );
-- 
2.14.4

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

* [PATCH 6/9] ldbl-128ibm-compat: Provide nexttoward functions
  2018-06-06 22:41 [PATCH 0/9] Introduce ieee128 symbols and redirections Tulio Magno Quites Machado Filho
                   ` (4 preceding siblings ...)
  2018-06-06 22:42 ` [PATCH 7/9] Refactor math-finite.h and introduce mathcalls-redir.h Tulio Magno Quites Machado Filho
@ 2018-06-06 22:42 ` Tulio Magno Quites Machado Filho
  2018-06-06 22:42 ` [PATCH 5/9] ldbl-128ibm-compat: Provide ISO C functions not provided by the _Float128 API Tulio Magno Quites Machado Filho
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-06 22:42 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph, gabriel, raji

From: "Gabriel F. T. Gomes" <gabriel@inconstante.eti.br>

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-06  Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
	    Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>

	* 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 b7efe84918..5f240cb687 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -100,6 +100,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

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

* [PATCH 7/9] Refactor math-finite.h and introduce mathcalls-redir.h
  2018-06-06 22:41 [PATCH 0/9] Introduce ieee128 symbols and redirections Tulio Magno Quites Machado Filho
                   ` (3 preceding siblings ...)
  2018-06-06 22:41 ` [PATCH 2/9] Move declare_mgen_finite_alias definition Tulio Magno Quites Machado Filho
@ 2018-06-06 22:42 ` Tulio Magno Quites Machado Filho
  2018-06-06 23:23   ` Joseph Myers
  2018-06-06 22:42 ` [PATCH 6/9] ldbl-128ibm-compat: Provide nexttoward functions Tulio Magno Quites Machado Filho
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-06 22:42 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph, gabriel, raji

On a new enough compiler, redirecting the same function twice can cause
-Werror=pragmas errors.  This issue may appear when redirecting an ISO C
floating point function to a different ABI at the same time that finite
redirections are expected.

This patch moves all of the common redirections done in math-finite.h to
a new header called mathcalls-redir.h.  The new header uses 2 new
macros to classify whether a function should be redirected or not:

 - __MATH_REDIR_FINITE: redirects the functions that are part of the
   finite ABI when set to 1.
 - __MATH_REDIR_NON_FINITE: redirects all the other math functions when
   set to 1.

With this mechanism, math-finite.h can redirect its functions by using
__MATH_REDIR_FINITE = 1 and __MATH_REDIR_NON_FINITE = 0.

mathcalls-redir.h also provides alternative redirection destinations in
order 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.

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-06  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>

	* include/bits/mathcalls-redir.h: New file
	* math/Makefile (headers): Add bits/mathcalls-redir.h.
	* math/bits/math-finite.h: Move most of the functions to
	bits/mathcalls-redir.h.
	* math/bits/mathcalls-redir.h: New file.
	* math/math.h: Define __REDIRTO_PUBLIC_X before including
	bits/math-finite.h.  Undefine it afterwards.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
---
 include/bits/mathcalls-redir.h |   1 +
 math/Makefile                  |   3 +-
 math/bits/math-finite.h        | 151 +++-----------
 math/bits/mathcalls-redir.h    | 460 +++++++++++++++++++++++++++++++++++++++++
 math/math.h                    |  34 +++
 5 files changed, 530 insertions(+), 119 deletions(-)
 create mode 100644 include/bits/mathcalls-redir.h
 create mode 100644 math/bits/mathcalls-redir.h

diff --git a/include/bits/mathcalls-redir.h b/include/bits/mathcalls-redir.h
new file mode 100644
index 0000000000..74a009eb1d
--- /dev/null
+++ b/include/bits/mathcalls-redir.h
@@ -0,0 +1 @@
+#include <math/bits/mathcalls-redir.h>
diff --git a/math/Makefile b/math/Makefile
index ea141cbf99..a1a248a1a4 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -29,7 +29,8 @@ headers		:= math.h bits/mathcalls.h bits/mathinline.h \
 		   bits/libm-simd-decl-stubs.h bits/iscanonical.h \
 		   bits/flt-eval-method.h bits/fp-fast.h bits/fp-logb.h \
 		   bits/long-double.h bits/mathcalls-helper-functions.h \
-		   bits/floatn.h bits/floatn-common.h bits/mathcalls-narrow.h
+		   bits/floatn.h bits/floatn-common.h bits/mathcalls-narrow.h \
+		   bits/mathcalls-redir.h
 
 # FPU support code.
 aux		:= setfpucw fpu_control
diff --git a/math/bits/math-finite.h b/math/bits/math-finite.h
index 0799fe7b29..90dd9d896b 100644
--- a/math/bits/math-finite.h
+++ b/math/bits/math-finite.h
@@ -20,96 +20,33 @@
 # error "Never use <bits/math-finite.h> directly; include <math.h> instead."
 #endif
 
-#define __REDIRFROM(...) __REDIRFROM_X(__VA_ARGS__)
-
-#define __REDIRTO(...) __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
+#define __REDIRFROM_F(...) __REDIRFROM_X(__VA_ARGS__)
 
-/* asin.  */
-__MATH_REDIRCALL (asin, , (_Mdouble_));
+#define __REDIRTO_F(...) __REDIRTO_X(__VA_ARGS__)
 
-/* atan2.  */
-__MATH_REDIRCALL (atan2, , (_Mdouble_, _Mdouble_));
+/* Redirects to a function that is part of the API.  */
+#define __REDIRTO_PUBLIC_F(...) __REDIRTO_PUBLIC_X(__VA_ARGS__)
 
-#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
-/* atanh.  */
-__MATH_REDIRCALL (atanh, , (_Mdouble_));
-#endif
 
-/* cosh.  */
-__MATH_REDIRCALL (cosh, , (_Mdouble_));
+#define __MATH_REDIR_X(type, from, args, to) \
+  extern type __REDIRECT_NTH (from, args, to)
+#define __MATH_REDIRCALL(function, reentrant, args)		\
+  __MATH_REDIR_X (_Mdouble_,						\
+		  __REDIRFROM_F (function, reentrant), args,	\
+		  __REDIRTO_F (function, reentrant))
 
-/* exp.  */
-__MATH_REDIRCALL (exp, , (_Mdouble_));
+#define __MATH_REDIRCALL_INTERNAL(function, reentrant, args)	\
+  __MATH_REDIR_X (_Mdouble_,						\
+		  __REDIRFROM_F (__CONCAT (__, function),	\
+			       __CONCAT (reentrant, _finite)),	\
+		  args, __REDIRTO_F (function, _r))
 
-#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
-
-#if (__MATH_DECLARING_DOUBLE && (defined __USE_MISC || defined __USE_XOPEN)) \
-    || (!__MATH_DECLARING_DOUBLE && defined __USE_MISC)
-/* j0.  */
-__MATH_REDIRCALL (j0, , (_Mdouble_));
-
-/* y0.  */
-__MATH_REDIRCALL (y0, , (_Mdouble_));
-
-/* j1.  */
-__MATH_REDIRCALL (j1, , (_Mdouble_));
-
-/* y1.  */
-__MATH_REDIRCALL (y1, , (_Mdouble_));
-
-/* jn.  */
-__MATH_REDIRCALL (jn, , (int, _Mdouble_));
-
-/* yn.  */
-__MATH_REDIRCALL (yn, , (int, _Mdouble_));
-#endif
-
-#ifdef __USE_MISC
-/* lgamma_r.  */
-__MATH_REDIRCALL (lgamma, _r, (_Mdouble_, int *));
-#endif
+#define __MATH_REDIR_FINITE 1
+#define __MATH_REDIR_NON_FINITE 0
+#include <bits/mathcalls-redir.h>
+#undef __MATH_REDIR_FINITE
+#undef __MATH_REDIR_NON_FINITE
 
 /* 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 +57,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,30 +72,13 @@ __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 \
@@ -169,29 +89,24 @@ __MATH_REDIRCALL (remainder, , (_Mdouble_, _Mdouble_));
 __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
diff --git a/math/bits/mathcalls-redir.h b/math/bits/mathcalls-redir.h
new file mode 100644
index 0000000000..0f1f325647
--- /dev/null
+++ b/math/bits/mathcalls-redir.h
@@ -0,0 +1,460 @@
+/* Redirections of math 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/>.  */
+
+/* Functions classified as __MATH_REDIR_FINITE == 1 provide finite
+   implementations.
+   Meanwhile functions classified as __MATH_REDIR_NON_FINITE == 1 do not
+   provide finite implementations.
+   This distinction is required to avoid duplicated redirections when a finite
+   implementation is requested.  */
+
+#ifndef _MATH_H
+# error "Never use <bits/math-redir.h> directly; include <math.h> instead."
+#endif
+
+#define __REDIRFROM(...) __REDIRFROM_X(__VA_ARGS__)
+
+#define __REDIRTO(...) __REDIRTO_X(__VA_ARGS__)
+
+#define __REDIRTO_ALT(...) __REDIRTO_ALT_X(__VA_ARGS__)
+
+/* Floating point types may not have a public API available.  In those cases,
+   functions must be redirected via assembly or via a public API.  */
+
+#define __MATH_REDIR(function, reentrant, args)			\
+  __MATH_REDIR_X (_Mdouble_,					\
+		  __REDIRFROM (function, reentrant), args,	\
+		  __REDIRTO (function, reentrant))
+
+#define __MATH_REDIR_T(type, function, reentrant, args)		\
+  __MATH_REDIR_X (type,						\
+		  __REDIRFROM (function, reentrant), args,	\
+		  __REDIRTO (function, reentrant))
+
+#define __MATH_REDIR_TO_ALT(type, from, reentrant, args, to)	\
+  __MATH_REDIR_X (type,						\
+		  __REDIRFROM (from, reentrant), args,		\
+		  __REDIRTO_ALT (to, reentrant))
+
+#define __MATH_REDIR_ALT(type, function, reentrant, args)	\
+  __MATH_REDIR_X (type,						\
+		  __REDIRFROM (function, reentrant), args,	\
+		  __REDIRTO_ALT (function, reentrant))
+
+/* Helper functions.  */
+
+#if __MATH_REDIR_NON_FINITE == 1
+/* Classify given number.  */
+__MATH_REDIR_TO_ALT (int, __fpclassify,, (_Mdouble_ __value), fpclassify);
+
+/* Test for negative number.  */
+__MATH_REDIR_TO_ALT (int, __signbit,, (_Mdouble_ __value), signbit);
+
+/* Test equality.  */
+__MATH_REDIR_TO_ALT (int, __iseqsig,, (_Mdouble_ __x, _Mdouble_ __y), iseqsig);
+
+/* Test for signaling NaN.  */
+__MATH_REDIR_TO_ALT (int, __issignaling,, (_Mdouble_ __value), issignaling);
+#endif  /* __MATH_REDIR_NON_FINITE == 1  */
+
+
+/* Trigonometric functions.  */
+
+#if __MATH_REDIR_FINITE == 1
+/* Arc cosine of X.  */
+__MATH_REDIR (acos,, (_Mdouble_ __x));
+/* Arc sine of X.  */
+__MATH_REDIR (asin,, (_Mdouble_ __x));
+/* Arc tangent of Y/X.  */
+__MATH_REDIR (atan2,, (_Mdouble_ __y, _Mdouble_ __x));
+#endif  /* __MATH_REDIR_FINITE == 1  */
+
+#if __MATH_REDIR_NON_FINITE == 1
+/* Arc tangent of X.  */
+__MATH_REDIR (atan,, (_Mdouble_ __x));
+/* Cosine of X.  */
+__MATH_REDIR (cos,, (_Mdouble_ __x));
+/* Sine of X.  */
+__MATH_REDIR (sin,, (_Mdouble_ __x));
+/* Tangent of X.  */
+__MATH_REDIR (tan,, (_Mdouble_ __x));
+#endif  /* __MATH_REDIR_NON_FINITE == 1  */
+
+
+/* Hyperbolic functions.  */
+
+#if __MATH_REDIR_FINITE == 1
+/* Hyperbolic cosine of X.  */
+__MATH_REDIR (cosh,, (_Mdouble_ __x));
+/* Hyperbolic sine of X.  */
+__MATH_REDIR (sinh,, (_Mdouble_ __x));
+
+# if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+/* Hyperbolic arc cosine of X.  */
+__MATH_REDIR (acosh,, (_Mdouble_ __x));
+/* Hyperbolic arc tangent of X.  */
+__MATH_REDIR (atanh,, (_Mdouble_ __x));
+# endif /* defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 */
+#endif  /* __MATH_REDIR_FINITE == 1  */
+
+#if __MATH_REDIR_NON_FINITE == 1
+# if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+/* Hyperbolic arc sine of X.  */
+__MATH_REDIR (asinh,, (_Mdouble_ __x));
+# endif
+
+/* Hyperbolic tangent of X.  */
+__MATH_REDIR (tanh,, (_Mdouble_ __x));
+
+# ifdef __USE_GNU
+/* Cosine and sine of X.  */
+__MATH_REDIR_T (void, sincos,,
+		(_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx));
+# endif /* defined __USE_GNU  */
+#endif  /* __MATH_REDIR_NON_FINITE == 1  */
+
+
+/* Exponential and logarithmic functions.  */
+
+#if __MATH_REDIR_FINITE == 1
+/* Exponential function of X.  */
+__MATH_REDIR (exp,, (_Mdouble_ __x));
+
+/* Natural logarithm of X.  */
+__MATH_REDIR (log,, (_Mdouble_ __x));
+
+/* Base-ten logarithm of X.  */
+__MATH_REDIR (log10,, (_Mdouble_ __x));
+
+# if __GLIBC_USE (IEC_60559_FUNCS_EXT)
+/* Compute exponent to base ten.  */
+__MATH_REDIR (exp10,, (_Mdouble_ __x));
+# endif  /*__GLIBC_USE (IEC_60559_FUNCS_EXT)  */
+
+# ifdef __USE_ISOC99
+/* Compute base-2 exponential of X.  */
+__MATH_REDIR (exp2,, (_Mdouble_ __x));
+
+/* Compute base-2 logarithm of X.  */
+__MATH_REDIR (log2,, (_Mdouble_ __x));
+# endif  /* defined __USE_ISOC99  */
+#endif  /* __MATH_REDIR_FINITE == 1  */
+
+#if __MATH_REDIR_NON_FINITE == 1
+/* Break VALUE into a normalized fraction and an integral power of 2.  */
+__MATH_REDIR (frexp,, (_Mdouble_ __x, int *__exponent));
+
+/* X times (two to the EXP power).  */
+__MATH_REDIR (ldexp,, (_Mdouble_ __x, int __exponent));
+
+/* Break VALUE into integral and fractional parts.  */
+__MATH_REDIR (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr));
+
+# if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+/* Return exp(X) - 1.  */
+__MATH_REDIR (expm1,, (_Mdouble_ __x));
+
+/* Return log(1 + X).  */
+__MATH_REDIR (log1p,, (_Mdouble_ __x));
+
+/* Return the base 2 signed integral exponent of X.  */
+__MATH_REDIR (logb,, (_Mdouble_ __x));
+# endif  /* defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99  */
+#endif  /* __MATH_REDIR_NON_FINITE == 1  */
+
+
+/* Power functions.  */
+
+#if __MATH_REDIR_FINITE == 1
+/* Return X to the Y power.  */
+__MATH_REDIR (pow,, (_Mdouble_ __x, _Mdouble_ __y));
+
+/* Return the square root of X.  */
+__MATH_REDIR (sqrt,, (_Mdouble_ __x));
+
+# if defined __USE_XOPEN || defined __USE_ISOC99
+/* Return `sqrt(X*X + Y*Y)'.  */
+__MATH_REDIR (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
+# endif
+#endif  /* __MATH_REDIR_FINITE == 1  */
+
+#if __MATH_REDIR_NON_FINITE == 1
+#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+/* Return the cube root of X.  */
+__MATH_REDIR (cbrt,, (_Mdouble_ __x));
+#endif
+#endif  /* __MATH_REDIR_NON_FINITE == 1  */
+
+
+/* Nearest integer, absolute value, and remainder functions.  */
+
+#if __MATH_REDIR_FINITE == 1
+/* Floating-point modulo remainder of X/Y.  */
+__MATH_REDIR (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
+#endif  /* __MATH_REDIR_FINITE == 1  */
+
+#if __MATH_REDIR_NON_FINITE == 1
+/* Smallest integral value not less than X.  */
+__MATH_REDIR (ceil,, (_Mdouble_ __x));
+
+/* Absolute value of X.  */
+__MATH_REDIR (fabs,, (_Mdouble_ __x));
+
+/* Largest integer not greater than X.  */
+__MATH_REDIR (floor,, (_Mdouble_ __x));
+
+# ifdef __USE_MISC
+#  if ((!defined __cplusplus \
+       || __cplusplus < 201103L /* isinf conflicts with C++11.  */ \
+       || __MATH_DECLARING_DOUBLE == 0)) /* isinff or isinfl don't.  */ \
+      && !__MATH_DECLARING_FLOATN
+/* Return 0 if VALUE is finite or NaN, +1 if it
+   is +Infinity, -1 if it is -Infinity.  */
+__MATH_REDIR_ALT (int, isinf,, (_Mdouble_ __value));
+#  endif
+
+#  if !__MATH_DECLARING_FLOATN
+/* Return nonzero if VALUE is finite and not NaN.  */
+__MATH_REDIR_ALT (int, finite,, (_Mdouble_ __value));
+/* Return the remainder of X/Y.  */
+__MATH_REDIR (drem,, (_Mdouble_ __x, _Mdouble_ __y));
+
+/* Return the fractional part of X after dividing out `ilogb (X)'.  */
+__MATH_REDIR (significand,, (_Mdouble_ __x));
+#  endif
+
+# endif /* Use misc.  */
+
+# ifdef __USE_ISOC99
+/* Return X with its signed changed to Y's.  */
+__MATH_REDIR (copysign,, (_Mdouble_ __x, _Mdouble_ __y));
+# endif
+
+# ifdef __USE_ISOC99
+/* Return representation of qNaN for double type.  */
+__MATH_REDIR (nan,, (const char *__tagb));
+# endif
+
+
+# if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
+#  if ((!defined __cplusplus \
+       || __cplusplus < 201103L /* isnan conflicts with C++11.  */ \
+       || __MATH_DECLARING_DOUBLE == 0)) /* isnanf or isnanl don't.  */ \
+      && !__MATH_DECLARING_FLOATN
+/* Return nonzero if VALUE is not a number.  */
+__MATH_REDIR_ALT (int, isnan,, (_Mdouble_ __value));
+#  endif
+# endif
+#endif  /* __MATH_REDIR_NON_FINITE == 1  */
+
+
+#if __MATH_REDIR_FINITE == 1
+# if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE)
+/* Bessel functions.  */
+__MATH_REDIR (j0,, (_Mdouble_));
+__MATH_REDIR (j1,, (_Mdouble_));
+__MATH_REDIR (jn,, (int, _Mdouble_));
+__MATH_REDIR (y0,, (_Mdouble_));
+__MATH_REDIR (y1,, (_Mdouble_));
+__MATH_REDIR (yn,, (int, _Mdouble_));
+# endif
+
+# ifdef __USE_MISC
+/* Reentrant version of lgamma.  This function uses the global variable
+   `signgam'.  The reentrant version instead takes a pointer and stores
+   the value through it.  */
+__MATH_REDIR (lgamma,_r, (_Mdouble_, int *__signgamp));
+# endif
+
+# if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+/* Return the remainder of integer divison X / Y with infinite precision.  */
+__MATH_REDIR (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
+# endif
+#endif  /* __MATH_REDIR_FINITE == 1  */
+
+
+#if __MATH_REDIR_NON_FINITE == 1
+# if defined __USE_XOPEN || defined __USE_ISOC99
+/* Error and gamma functions.  */
+__MATH_REDIR (erf,, (_Mdouble_));
+__MATH_REDIR (erfc,, (_Mdouble_));
+__MATH_REDIR (lgamma,, (_Mdouble_));
+# endif
+
+# ifdef __USE_ISOC99
+/* True gamma function.  */
+__MATH_REDIR (tgamma,, (_Mdouble_));
+# endif
+
+# if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
+#  if !__MATH_DECLARING_FLOATN
+/* Obsolete alias for `lgamma'.  */
+__MATH_REDIR (gamma,, (_Mdouble_));
+#  endif
+# endif
+
+
+# if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+/* Return the integer nearest X in the direction of the
+   prevailing rounding mode.  */
+__MATH_REDIR (rint,, (_Mdouble_ __x));
+
+/* Return X + epsilon if X < Y, X - epsilon if X > Y.  */
+__MATH_REDIR (nextafter,, (_Mdouble_ __x, _Mdouble_ __y));
+#  if defined __USE_ISOC99 && !defined __LDBL_COMPAT && !__MATH_DECLARING_FLOATN
+__MATH_REDIR (nexttoward,, (_Mdouble_ __x, long double __y));
+#  endif
+
+#  if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN
+/* Return X - epsilon.  */
+__MATH_REDIR (nextdown,, (_Mdouble_ __x));
+/* Return X + epsilon.  */
+__MATH_REDIR (nextup,, (_Mdouble_ __x));
+#  endif
+
+#  ifdef __USE_ISOC99
+/* Return X times (2 to the Nth power).  */
+__MATH_REDIR (scalbn,, (_Mdouble_ __x, int __n));
+#  endif
+
+/* Return the binary exponent of X, which must be nonzero.  */
+__MATH_REDIR_T (int, ilogb,, (_Mdouble_ __x));
+# endif
+
+# if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN
+/* Like ilogb, but returning long int.  */
+__MATH_REDIR_T (long int, llogb,, (_Mdouble_ __x));
+# endif
+
+# ifdef __USE_ISOC99
+/* Return X times (2 to the Nth power).  */
+__MATH_REDIR (scalbln,, (_Mdouble_ __x, long int __n));
+
+/* Round X to integral value in floating-point format using current
+   rounding direction, but do not raise inexact exception.  */
+__MATH_REDIR (nearbyint,, (_Mdouble_ __x));
+
+/* Round X to nearest integral value, rounding halfway cases away from
+   zero.  */
+__MATH_REDIR (round,, (_Mdouble_ __x));
+
+/* Round X to the integral value in floating-point format nearest but
+   not larger in magnitude.  */
+__MATH_REDIR (trunc,, (_Mdouble_ __x));
+
+/* Compute remainder of X and Y and put in *QUO a value with sign of x/y
+   and magnitude congruent `mod 2^n' to the magnitude of the integral
+   quotient x/y, with n >= 3.  */
+__MATH_REDIR (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));
+
+
+/* Conversion functions.  */
+
+/* Round X to nearest integral value according to current rounding
+   direction.  */
+__MATH_REDIR_T (long int, lrint,, (_Mdouble_ __x));
+__extension__
+__MATH_REDIR_T (long long int, llrint,, (_Mdouble_ __x));
+
+/* Round X to nearest integral value, rounding halfway cases away from
+   zero.  */
+__MATH_REDIR_T (long int, lround,, (_Mdouble_ __x));
+__extension__
+__MATH_REDIR_T (long long int, llround,, (_Mdouble_ __x));
+
+
+/* Return positive difference between X and Y.  */
+__MATH_REDIR (fdim,, (_Mdouble_ __x, _Mdouble_ __y));
+
+/* Return maximum numeric value from X and Y.  */
+__MATH_REDIR (fmax,, (_Mdouble_ __x, _Mdouble_ __y));
+
+/* Return minimum numeric value from X and Y.  */
+__MATH_REDIR (fmin,, (_Mdouble_ __x, _Mdouble_ __y));
+
+/* Multiply-add function computed as a ternary operation.  */
+__MATH_REDIR (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
+# endif /* Use ISO C99.  */
+
+# if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN
+/* Round X to nearest integer value, rounding halfway cases to even.  */
+__MATH_REDIR (roundeven,, (_Mdouble_ __x));
+
+/* Round X to nearest signed integer value, not raising inexact, with
+   control of rounding direction and width of result.  */
+__MATH_REDIR_T (__intmax_t, fromfp,, (_Mdouble_ __x, int __round,
+				      unsigned int __width));
+
+/* Round X to nearest unsigned integer value, not raising inexact,
+   with control of rounding direction and width of result.  */
+__MATH_REDIR_T (__uintmax_t, ufromfp,, (_Mdouble_ __x, int __round,
+					unsigned int __width));
+
+/* Round X to nearest signed integer value, raising inexact for
+   non-integers, with control of rounding direction and width of
+   result.  */
+__MATH_REDIR_T (__intmax_t, fromfpx,, (_Mdouble_ __x, int __round,
+				       unsigned int __width));
+
+/* Round X to nearest unsigned integer value, raising inexact for
+   non-integers, with control of rounding direction and width of
+   result.  */
+__MATH_REDIR_T (__uintmax_t, ufromfpx,, (_Mdouble_ __x, int __round,
+					 unsigned int __width));
+
+/* Return value with maximum magnitude.  */
+__MATH_REDIR (fmaxmag,, (_Mdouble_ __x, _Mdouble_ __y));
+
+/* Return value with minimum magnitude.  */
+__MATH_REDIR (fminmag,, (_Mdouble_ __x, _Mdouble_ __y));
+
+/* Total order operation.  */
+__MATH_REDIR_T (int, totalorder,, (_Mdouble_ __x, _Mdouble_ __y));
+
+/* Total order operation on absolute values.  */
+__MATH_REDIR_T (int, totalordermag,, (_Mdouble_ __x, _Mdouble_ __y));
+
+/* Canonicalize floating-point representation.  */
+__MATH_REDIR_T (int, canonicalize,, (_Mdouble_ *__cx, const _Mdouble_ *__x));
+
+/* Get NaN payload.  */
+__MATH_REDIR (getpayload,, (const _Mdouble_ *__x));
+
+/* Set quiet NaN payload.  */
+__MATH_REDIR_T (int, setpayload,, (_Mdouble_ *__x, _Mdouble_ __payload));
+
+/* Set signaling NaN payload.  */
+__MATH_REDIR_T (int, setpayloadsig,, (_Mdouble_ *__x, _Mdouble_ __payload));
+# endif
+
+# if (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
+			    && __MATH_DECLARING_DOUBLE	  \
+			    && !defined __USE_XOPEN2K8))  \
+     && !__MATH_DECLARING_FLOATN
+/* Return X times (2 to the Nth power).  */
+__MATH_REDIR (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
+# endif
+#endif  /* __MATH_REDIR_NON_FINITE == 1  */
+
+#undef __MATH_REDIR
+#undef __MATH_REDIR_T
+#undef __MATH_REDIR_TO_ALT
+#undef __MATH_REDIR_ALT
+#undef __REDIRTO_ALT
+#undef __REDIRTO
+#undef __REDIRFROM
diff --git a/math/math.h b/math/math.h
index ddee4e4083..3edf275e26 100644
--- a/math/math.h
+++ b/math/math.h
@@ -1252,12 +1252,15 @@ iszero (__T __val)
   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.  */
@@ -1271,12 +1274,15 @@ iszero (__T __val)
   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
@@ -1288,9 +1294,13 @@ iszero (__T __val)
 #   ifdef __NO_LONG_DOUBLE_MATH
 #    define __REDIRTO_X(function, reentrant) \
    __ ## function ## reentrant ## _finite
+#    define __REDIRTO_PUBLIC_X(function, reentrant) \
+   __REDIRTO_X(function, reentrant)
 #   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_
@@ -1298,6 +1308,7 @@ iszero (__T __val)
 #   undef __MATH_DECLARING_FLOATN
 #   undef __REDIRFROM_X
 #   undef __REDIRTO_X
+#   undef __REDIRTO_PUBLIC_X
 #  endif
 
 # endif /* __USE_ISOC99.  */
@@ -1314,6 +1325,8 @@ iszero (__T __val)
 #  if __HAVE_DISTINCT_FLOAT16
 #   define __REDIRTO_X(function, reentrant) \
    __ ## function ## f16 ## reentrant ## _finite
+#   define __REDIRTO_PUBLIC_X(function, reentrant) \
+   __REDIRTO_X(function, reentrant)
 #  else
 #   error "non-disinct _Float16"
 #  endif
@@ -1323,6 +1336,7 @@ iszero (__T __val)
 #  undef __MATH_DECLARING_FLOATN
 #  undef __REDIRFROM_X
 #  undef __REDIRTO_X
+#  undef __REDIRTO_PUBLIC_X
 # endif
 
 # if (__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC))	\
@@ -1339,12 +1353,15 @@ iszero (__T __val)
 #   define __REDIRTO_X(function, reentrant) \
    __ ## function ## f ## reentrant ## _finite
 #  endif
+#  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
 # endif
 
 # if (__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC))	\
@@ -1361,12 +1378,15 @@ iszero (__T __val)
 #   define __REDIRTO_X(function, reentrant) \
    __ ## function ## reentrant ## _finite
 #  endif
+#  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
 # endif
 
 # if (__HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC))	\
@@ -1379,9 +1399,13 @@ iszero (__T __val)
 #  if __HAVE_DISTINCT_FLOAT128
 #   define __REDIRTO_X(function, reentrant) \
    __ ## function ## f128 ## reentrant ## _finite
+#   define __REDIRTO_PUBLIC_X(function, reentrant) \
+   __REDIRTO_X(function, reentrant)
 #  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_
@@ -1389,6 +1413,7 @@ iszero (__T __val)
 #  undef __MATH_DECLARING_FLOATN
 #  undef __REDIRFROM_X
 #  undef __REDIRTO_X
+#  undef __REDIRTO_PUBLIC_X
 # endif
 
 # if (__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC))	\
@@ -1405,12 +1430,15 @@ iszero (__T __val)
 #   define __REDIRTO_X(function, reentrant) \
    __ ## function ## reentrant ## _finite
 #  endif
+#  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
 # endif
 
 # if (__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC))	\
@@ -1430,12 +1458,15 @@ iszero (__T __val)
 #   define __REDIRTO_X(function, reentrant) \
    __ ## function ## f128 ## reentrant ## _finite
 #  endif
+#  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
 # endif
 
 # if (__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)) \
@@ -1448,6 +1479,8 @@ iszero (__T __val)
 #  if __HAVE_DISTINCT_FLOAT128X
 #   define __REDIRTO_X(function, reentrant) \
    __ ## function ## f128x ## reentrant ## _finite
+#   define __REDIRTO_PUBLIC_X(function, reentrant) \
+   __REDIRTO_X(function, reentrant)
 #  else
 #   error "non-disinct _Float128x"
 #  endif
@@ -1457,6 +1490,7 @@ iszero (__T __val)
 #  undef __MATH_DECLARING_FLOATN
 #  undef __REDIRFROM_X
 #  undef __REDIRTO_X
+#  undef __REDIRTO_PUBLIC_X
 # endif
 
 #endif /* __FINITE_MATH_ONLY__ > 0.  */
-- 
2.14.4

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

* [PATCH 9/9] ldbl-128ibm-compat: Redirect complex math functions
  2018-06-06 22:41 [PATCH 0/9] Introduce ieee128 symbols and redirections Tulio Magno Quites Machado Filho
                   ` (7 preceding siblings ...)
  2018-06-06 22:42 ` [PATCH 8/9] ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions Tulio Magno Quites Machado Filho
@ 2018-06-06 22:43 ` Tulio Magno Quites Machado Filho
  2018-06-06 23:11 ` [PATCH 0/9] Introduce ieee128 symbols and redirections Joseph Myers
  9 siblings, 0 replies; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-06 22:43 UTC (permalink / raw)
  To: libc-alpha; +Cc: joseph, gabriel, raji, Rajalakshmi Srinivasaraghavan

From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>

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-06  Rajalakshmi Srinivasaraghavan  <raji@linux.vnet.ibm.com>

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

diff --git a/math/complex.h b/math/complex.h
index 544e7acd82..097d6dcb6f 100644
--- a/math/complex.h
+++ b/math/complex.h
@@ -95,11 +95,15 @@ __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_1(type, 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) \
+  __MATHDECL_1_IMPL(type, function, args)
 
 #define _Mdouble_ 		double
 #define __MATH_PRECNAME(name)	name
@@ -122,11 +126,31 @@ __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 \
+     && __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
 #endif
 #undef	_Mdouble_
 #undef	__MATH_PRECNAME
-- 
2.14.4

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

* Re: [PATCH 1/9] ldbl-128ibm-compat: Create libm-alias-float128.h
  2018-06-06 22:41 ` [PATCH 1/9] ldbl-128ibm-compat: Create libm-alias-float128.h Tulio Magno Quites Machado Filho
@ 2018-06-06 23:05   ` Joseph Myers
  2018-06-13 20:16     ` Tulio Magno Quites Machado Filho
  0 siblings, 1 reply; 25+ messages in thread
From: Joseph Myers @ 2018-06-06 23:05 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho; +Cc: libc-alpha, gabriel, raji

On Wed, 6 Jun 2018, Tulio Magno Quites Machado Filho wrote:

> +    __f32addieee128;
> +    __f32divieee128;
> +    __f32mulieee128;
> +    __f32subieee128;
> +    __f64addieee128;
> +    __f64divieee128;
> +    __f64mulieee128;
> +    __f64subieee128;
> +    __f64xaddieee128;
> +    __f64xdivieee128;
> +    __f64xmulieee128;
> +    __f64xsubieee128;

The __f64x* functions shouldn't be needed here.

The __f32* and __f64* ones seem appropriate (for faddl / daddl etc. 
redirection), but in patch 8 you appear to be redirecting instead to the 
f32* / f64* functions (only reserved in TS 18661-3, not in TS 18661-1).

> +    __gamma_productieee128;

__gamma_product is an internal part of libm, not a public exported 
function.  You should start from the *f128 functions that are actually 
exported from libm, and justify any additions to that set carefully 
(generally as functions that are part of the long double API and so need 
*ieee128 versions).

> +    __lgamma_negieee128;
> +    __lgamma_productieee128;

Again, these are internal implementation details, not exported functions.

> +    __x2y2m1ieee128;

Likewise.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 0/9] Introduce ieee128 symbols and redirections
  2018-06-06 22:41 [PATCH 0/9] Introduce ieee128 symbols and redirections Tulio Magno Quites Machado Filho
                   ` (8 preceding siblings ...)
  2018-06-06 22:43 ` [PATCH 9/9] ldbl-128ibm-compat: Redirect complex math functions Tulio Magno Quites Machado Filho
@ 2018-06-06 23:11 ` Joseph Myers
  2018-06-13 20:25   ` Tulio Magno Quites Machado Filho
  9 siblings, 1 reply; 25+ messages in thread
From: Joseph Myers @ 2018-06-06 23:11 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho; +Cc: libc-alpha, gabriel, raji

As a general principle, I'd suggest using a consistent naming convention 
for all the ieee128 function variants being added in both libc and libm.  
So, if __ieee128_* is used in libc that would indicate functions such as 
__ieee128_cosl in libm, for example.  (For the libm functions this is 
presumably mainly a matter of how a few macros get defined.)

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 7/9] Refactor math-finite.h and introduce mathcalls-redir.h
  2018-06-06 22:42 ` [PATCH 7/9] Refactor math-finite.h and introduce mathcalls-redir.h Tulio Magno Quites Machado Filho
@ 2018-06-06 23:23   ` Joseph Myers
  2018-06-13 21:36     ` Tulio Magno Quites Machado Filho
  0 siblings, 1 reply; 25+ messages in thread
From: Joseph Myers @ 2018-06-06 23:23 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho; +Cc: libc-alpha, gabriel, raji

On Wed, 6 Jun 2018, Tulio Magno Quites Machado Filho wrote:

> On a new enough compiler, redirecting the same function twice can cause
> -Werror=pragmas errors.  This issue may appear when redirecting an ISO C
> floating point function to a different ABI at the same time that finite
> redirections are expected.

Does this issue already appear with -mlong-double-64?  If so, it should 
definitely be separated out from this patch series and have a bug filed in 
Bugzilla as usual for anything fixing a bug that was user-visible in a 
release.

The approach taken in this patch involves a lot of duplication of both 
function prototypes and the feature-test-macro conditions on when those 
functions are declared (duplicating them for functions not included in 
math-finite.h, when previously only those in math-finite.h had such 
duplication).  Such duplication is, from experience, fragile and a bad 
idea; the conditions and declarations are too likely to get out of sync.

Instead, I'd suggest merging bits/math-finite.h into bits/mathcalls.h as 
much as possible - have macros such as __MATHCALL_FINITE that are called 
in bits/mathcalls.h to declare the functions with __*_finite variants, and 
with __MATHCALL_FINITE defined the same as __MATHCALL when the finite 
function variants aren't in use.  That way you have just a single 
redirection for each function.  (You'll need a sysdeps bits/ header for an 
architecture, i.e. ia64, to declare it doesn't support the _finite 
functions at all.)

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 2/9] Move declare_mgen_finite_alias definition
  2018-06-06 22:41 ` [PATCH 2/9] Move declare_mgen_finite_alias definition Tulio Magno Quites Machado Filho
@ 2018-06-07 13:25   ` Joseph Myers
  0 siblings, 0 replies; 25+ messages in thread
From: Joseph Myers @ 2018-06-07 13:25 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho; +Cc: libc-alpha, gabriel, raji

On Wed, 6 Jun 2018, Tulio Magno Quites Machado Filho wrote:

> 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-06  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>
> 
> 	* 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.

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 4/9] ldbl-128ibm-compat: Add a generic significand() implementation
  2018-06-06 22:41 ` [PATCH 4/9] ldbl-128ibm-compat: Add a generic significand() implementation Tulio Magno Quites Machado Filho
@ 2018-06-07 13:38   ` Joseph Myers
  2018-06-15 20:16     ` Tulio Magno Quites Machado Filho
  0 siblings, 1 reply; 25+ messages in thread
From: Joseph Myers @ 2018-06-07 13:38 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho; +Cc: libc-alpha, gabriel, raji

On Wed, 6 Jun 2018, Tulio Magno Quites Machado Filho wrote:

> Create a template for significand and reuse it in the ldbl-128ibm-compat 
> directory.

The following applies to both this patch and the scalb one: I don't think 
it makes sense to have a template that is, in fact, only used for one 
format.

If using a template for significand, I'd expect it to be used for all 
floating-point types / formats (removing the existing s_significand*.c 
etc. from math/ and sysdeps/ieee754/ldbl-opt/, listing it in 
gen-libm-calls instead of libm-calls).  The empty version in 
sysdeps/ieee754/float128 would still ensure nothing gets built for 
significand for float128 and you'd still have the s_significandf128.c you 
add in this patch (the ChangeLog entry seems wrong to mention 
s_significandl.c).  Using templates like that would mean the object files 
define excess aliases such as significandf32, but those aliases aren't in 
Versions files so they are harmless, not exported from libm.

Much the same would apply to e_scalb templates.  For w_scalb you'd need to 
treat the existing w_scalb*_compat templates like the other compat ones - 
that is, make their entire contents conditional on LIBM_SVID_COMPAT (so 
they don't get built for new targets or static linking at all), while the 
new w_scalb template would be listed in gen-libm-calls and not have any 
LIBM_SVID_COMPAT conditionals in it, and a new dummy 
sysdeps/ieee754/float128/w_scalbf128.c would ensure no code actually gets 
built from that template in the normal float128 case.  Given the general 
handling of finite aliases I'd expect a new __scalbf128_finite function 
export to be added to the Versions file for ldbl-128ibm-compat as well.

I would suggest that patches adding such templates and using them for 
existing formats without changing the ABI anywhere (a cleanup / 
refactoring of existing code) be separated from patches that actually add 
new ldbl-128ibm-compat symbols.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 5/9] ldbl-128ibm-compat: Provide ISO C functions not provided by the _Float128 API
  2018-06-06 22:42 ` [PATCH 5/9] ldbl-128ibm-compat: Provide ISO C functions not provided by the _Float128 API Tulio Magno Quites Machado Filho
@ 2018-06-07 14:51   ` Joseph Myers
  2018-06-13 21:41     ` Tulio Magno Quites Machado Filho
  0 siblings, 1 reply; 25+ messages in thread
From: Joseph Myers @ 2018-06-07 14:51 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho; +Cc: libc-alpha, gabriel, raji

On Wed, 6 Jun 2018, Tulio Magno Quites Machado Filho wrote:

> These functions do not exist in the float128 api, but they need to be
> provided for long double (*l api) because they are part of ISO C.

They're not part of ISO C; they are part of *the long double API provided 
by glibc* (and thus need to be provided for any alternative long double 
format just like any other semi-obsolescent but still-available long 
double interface, e.g. qecvt).

Is it possible to provide these particular functions in the API without 
adding extra ABIs for them?  For example, if the relevant case in math.h 
had #defines of __dremieee128 or __ieee128_dreml or whatever it ends up 
being to the corresponding name for remainder, and likewise for gamma / 
lgamma, would that work correctly with __REDIRECT to get calls to dreml 
and gammal working for -mabi=ieeelongdouble without needing to add two new 
ABIs and two new source files?

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 1/9] ldbl-128ibm-compat: Create libm-alias-float128.h
  2018-06-06 23:05   ` Joseph Myers
@ 2018-06-13 20:16     ` Tulio Magno Quites Machado Filho
  0 siblings, 0 replies; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-13 20:16 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

Joseph Myers <joseph@codesourcery.com> writes:

> On Wed, 6 Jun 2018, Tulio Magno Quites Machado Filho wrote:
>
>> +    __f32addieee128;
>> +    __f32divieee128;
>> +    __f32mulieee128;
>> +    __f32subieee128;
>> +    __f64addieee128;
>> +    __f64divieee128;
>> +    __f64mulieee128;
>> +    __f64subieee128;
>> +    __f64xaddieee128;
>> +    __f64xdivieee128;
>> +    __f64xmulieee128;
>> +    __f64xsubieee128;
>
> The __f64x* functions shouldn't be needed here.
>
> The __f32* and __f64* ones seem appropriate (for faddl / daddl etc. 
> redirection), but in patch 8 you appear to be redirecting instead to the 
> f32* / f64* functions (only reserved in TS 18661-3, not in TS 18661-1).

OK.
The __f32*ieee128 and __f64*ieee128 symbols were not getting created.

>> +    __gamma_productieee128;
>
> __gamma_product is an internal part of libm, not a public exported 
> function.  You should start from the *f128 functions that are actually 
> exported from libm, and justify any additions to that set carefully 
> (generally as functions that are part of the long double API and so need 
> *ieee128 versions).
>
>> +    __lgamma_negieee128;
>> +    __lgamma_productieee128;
>
> Again, these are internal implementation details, not exported functions.
>
>> +    __x2y2m1ieee128;
>
> Likewise.

Oops.

Fixed all these errors.

-- 
Tulio Magno

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

* Re: [PATCH 0/9] Introduce ieee128 symbols and redirections
  2018-06-06 23:11 ` [PATCH 0/9] Introduce ieee128 symbols and redirections Joseph Myers
@ 2018-06-13 20:25   ` Tulio Magno Quites Machado Filho
  2018-06-13 20:28     ` Joseph Myers
  0 siblings, 1 reply; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-13 20:25 UTC (permalink / raw)
  To: Joseph Myers, libc-alpha; +Cc: gabriel, raji

Joseph Myers <joseph@codesourcery.com> writes:

> As a general principle, I'd suggest using a consistent naming convention 
> for all the ieee128 function variants being added in both libc and libm.  
> So, if __ieee128_* is used in libc that would indicate functions such as 
> __ieee128_cosl in libm, for example.  (For the libm functions this is 
> presumably mainly a matter of how a few macros get defined.)

Ack.  We're planning to use the format __*ieee128 everywhere.
However, there are cases that need special treatment and will be slightly
different, e.g.:  __nextowardf_to_ieee128 and __nexttoward_to_ieee128.

Is that OK?

-- 
Tulio Magno

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

* Re: [PATCH 0/9] Introduce ieee128 symbols and redirections
  2018-06-13 20:25   ` Tulio Magno Quites Machado Filho
@ 2018-06-13 20:28     ` Joseph Myers
  0 siblings, 0 replies; 25+ messages in thread
From: Joseph Myers @ 2018-06-13 20:28 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho; +Cc: libc-alpha, gabriel, raji

On Wed, 13 Jun 2018, Tulio Magno Quites Machado Filho wrote:

> Joseph Myers <joseph@codesourcery.com> writes:
> 
> > As a general principle, I'd suggest using a consistent naming convention 
> > for all the ieee128 function variants being added in both libc and libm.  
> > So, if __ieee128_* is used in libc that would indicate functions such as 
> > __ieee128_cosl in libm, for example.  (For the libm functions this is 
> > presumably mainly a matter of how a few macros get defined.)
> 
> Ack.  We're planning to use the format __*ieee128 everywhere.
> However, there are cases that need special treatment and will be slightly
> different, e.g.:  __nextowardf_to_ieee128 and __nexttoward_to_ieee128.
> 
> Is that OK?

Yes.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 7/9] Refactor math-finite.h and introduce mathcalls-redir.h
  2018-06-06 23:23   ` Joseph Myers
@ 2018-06-13 21:36     ` Tulio Magno Quites Machado Filho
  2018-06-13 22:58       ` Joseph Myers
  0 siblings, 1 reply; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-13 21:36 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, gabriel, raji

Joseph Myers <joseph@codesourcery.com> writes:

> On Wed, 6 Jun 2018, Tulio Magno Quites Machado Filho wrote:
>
>> On a new enough compiler, redirecting the same function twice can cause
>> -Werror=pragmas errors.  This issue may appear when redirecting an ISO C
>> floating point function to a different ABI at the same time that finite
>> redirections are expected.
>
> Does this issue already appear with -mlong-double-64?  If so, it should 
> definitely be separated out from this patch series and have a bug filed in 
> Bugzilla as usual for anything fixing a bug that was user-visible in a 
> release.

Yes, I can reproduce it in our tests if I replace -mlong-double-128 with
-mlong-double-64.
However, this is not user-visible because this warning is ignored in system
headers.

Do you still think a bug report is necessary?

> The approach taken in this patch involves a lot of duplication of both 
> function prototypes and the feature-test-macro conditions on when those 
> functions are declared (duplicating them for functions not included in 
> math-finite.h, when previously only those in math-finite.h had such 
> duplication).  Such duplication is, from experience, fragile and a bad 
> idea; the conditions and declarations are too likely to get out of sync.

Agreed.

> Instead, I'd suggest merging bits/math-finite.h into bits/mathcalls.h as 
> much as possible - have macros such as __MATHCALL_FINITE that are called 
> in bits/mathcalls.h to declare the functions with __*_finite variants, and 
> with __MATHCALL_FINITE defined the same as __MATHCALL when the finite 
> function variants aren't in use.  That way you have just a single 
> redirection for each function.  (You'll need a sysdeps bits/ header for an 
> architecture, i.e. ia64, to declare it doesn't support the _finite 
> functions at all.)

It doesn't work well this way because we have prototypes with extra attributes,
e.g:

__MATHDECL_1 (int, totalorder,, (_Mdouble_ __x, _Mdouble_ __y))
     __attribute__ ((__const__));

So, if I do not define __MATHDECL_1 in bits/math-finite.h, this code would end
up as an invalid code:

__attribute__ ((__const__));

I managed to remove bits/math-redir.h and modified both math.h and
bits/math-finite.h to reuse bits/mathcalls.h.  I had to keep using
__MATH_DECLARE_FINITE and __MATH_DECLARE_NON_FINITE.

Would this be acceptable?

-- 
Tulio Magno

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

* Re: [PATCH 5/9] ldbl-128ibm-compat: Provide ISO C functions not provided by the _Float128 API
  2018-06-07 14:51   ` Joseph Myers
@ 2018-06-13 21:41     ` Tulio Magno Quites Machado Filho
  0 siblings, 0 replies; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-13 21:41 UTC (permalink / raw)
  To: Joseph Myers, libc-alpha

Joseph Myers <joseph@codesourcery.com> writes:

> On Wed, 6 Jun 2018, Tulio Magno Quites Machado Filho wrote:
>
>> These functions do not exist in the float128 api, but they need to be
>> provided for long double (*l api) because they are part of ISO C.
>
> They're not part of ISO C; they are part of *the long double API provided 
> by glibc* (and thus need to be provided for any alternative long double 
> format just like any other semi-obsolescent but still-available long 
> double interface, e.g. qecvt).

Indeed.

> Is it possible to provide these particular functions in the API without 
> adding extra ABIs for them?  For example, if the relevant case in math.h 
> had #defines of __dremieee128 or __ieee128_dreml or whatever it ends up 
> being to the corresponding name for remainder, and likewise for gamma / 
> lgamma, would that work correctly with __REDIRECT to get calls to dreml 
> and gammal working for -mabi=ieeelongdouble without needing to add two new 
> ABIs and two new source files?

Yes, it is.

I'm dropping this patch.

-- 
Tulio Magno

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

* Re: [PATCH 7/9] Refactor math-finite.h and introduce mathcalls-redir.h
  2018-06-13 21:36     ` Tulio Magno Quites Machado Filho
@ 2018-06-13 22:58       ` Joseph Myers
  2018-06-14 18:07         ` Tulio Magno Quites Machado Filho
  0 siblings, 1 reply; 25+ messages in thread
From: Joseph Myers @ 2018-06-13 22:58 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho; +Cc: libc-alpha, gabriel, raji

On Wed, 13 Jun 2018, Tulio Magno Quites Machado Filho wrote:

> Yes, I can reproduce it in our tests if I replace -mlong-double-128 with
> -mlong-double-64.
> However, this is not user-visible because this warning is ignored in system
> headers.
> 
> Do you still think a bug report is necessary?

I think we want to be clean with -Wsystem-headers; thus, there should be a 
bug report.

> > Instead, I'd suggest merging bits/math-finite.h into bits/mathcalls.h as 
> > much as possible - have macros such as __MATHCALL_FINITE that are called 
> > in bits/mathcalls.h to declare the functions with __*_finite variants, and 
> > with __MATHCALL_FINITE defined the same as __MATHCALL when the finite 
> > function variants aren't in use.  That way you have just a single 
> > redirection for each function.  (You'll need a sysdeps bits/ header for an 
> > architecture, i.e. ia64, to declare it doesn't support the _finite 
> > functions at all.)
> 
> It doesn't work well this way because we have prototypes with extra attributes,
> e.g:
> 
> __MATHDECL_1 (int, totalorder,, (_Mdouble_ __x, _Mdouble_ __y))
>      __attribute__ ((__const__));
> 
> So, if I do not define __MATHDECL_1 in bits/math-finite.h, this code would end
> up as an invalid code:
> 
> __attribute__ ((__const__));

My proposal is that bits/math-finite.h either shouldn't exist or should 
end up just defining the lgamma / gamma / tgamma inlines.  
bits/mathcalls.h would be included once per type, with the macros 
definitions in effect when it's included depending on "defined 
__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0" (so if that's true some 
functions would be redirected to __*finite versions, if that's false it 
would behave much as it does at present).

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 7/9] Refactor math-finite.h and introduce mathcalls-redir.h
  2018-06-13 22:58       ` Joseph Myers
@ 2018-06-14 18:07         ` Tulio Magno Quites Machado Filho
  0 siblings, 0 replies; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-14 18:07 UTC (permalink / raw)
  To: Joseph Myers, libc-alpha

Joseph Myers <joseph@codesourcery.com> writes:

> On Wed, 13 Jun 2018, Tulio Magno Quites Machado Filho wrote:
>
>> Yes, I can reproduce it in our tests if I replace -mlong-double-128 with
>> -mlong-double-64.
>> However, this is not user-visible because this warning is ignored in system
>> headers.
>> 
>> Do you still think a bug report is necessary?
>
> I think we want to be clean with -Wsystem-headers; thus, there should be a 
> bug report.

Ack.
Reported as https://sourceware.org/bugzilla/show_bug.cgi?id=23292

>> > Instead, I'd suggest merging bits/math-finite.h into bits/mathcalls.h as 
>> > much as possible - have macros such as __MATHCALL_FINITE that are called 
>> > in bits/mathcalls.h to declare the functions with __*_finite variants, and 
>> > with __MATHCALL_FINITE defined the same as __MATHCALL when the finite 
>> > function variants aren't in use.  That way you have just a single 
>> > redirection for each function.  (You'll need a sysdeps bits/ header for an 
>> > architecture, i.e. ia64, to declare it doesn't support the _finite 
>> > functions at all.)
>> 
>> It doesn't work well this way because we have prototypes with extra attributes,
>> e.g:
>> 
>> __MATHDECL_1 (int, totalorder,, (_Mdouble_ __x, _Mdouble_ __y))
>>      __attribute__ ((__const__));
>> 
>> So, if I do not define __MATHDECL_1 in bits/math-finite.h, this code would end
>> up as an invalid code:
>> 
>> __attribute__ ((__const__));
>
> My proposal is that bits/math-finite.h either shouldn't exist or should 
> end up just defining the lgamma / gamma / tgamma inlines.  
> bits/mathcalls.h would be included once per type, with the macros 
> definitions in effect when it's included depending on "defined 
> __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0" (so if that's true some 
> functions would be redirected to __*finite versions, if that's false it 
> would behave much as it does at present).

Interesting...
I'm working on this.

-- 
Tulio Magno

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

* Re: [PATCH 4/9] ldbl-128ibm-compat: Add a generic significand() implementation
  2018-06-07 13:38   ` Joseph Myers
@ 2018-06-15 20:16     ` Tulio Magno Quites Machado Filho
  2018-06-15 20:20       ` Tulio Magno Quites Machado Filho
  0 siblings, 1 reply; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-15 20:16 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, gabriel, raji

Joseph Myers <joseph@codesourcery.com> writes:

> On Wed, 6 Jun 2018, Tulio Magno Quites Machado Filho wrote:
>
>> Create a template for significand and reuse it in the ldbl-128ibm-compat 
>> directory.
>
> The following applies to both this patch and the scalb one: I don't think 
> it makes sense to have a template that is, in fact, only used for one 
> format.
>
> If using a template for significand, I'd expect it to be used for all 
> floating-point types / formats (removing the existing s_significand*.c 
> etc. from math/ and sysdeps/ieee754/ldbl-opt/, listing it in 
> gen-libm-calls instead of libm-calls).  The empty version in 
> sysdeps/ieee754/float128 would still ensure nothing gets built for 
> significand for float128 and you'd still have the s_significandf128.c you 
> add in this patch (the ChangeLog entry seems wrong to mention 
> s_significandl.c).  Using templates like that would mean the object files 
> define excess aliases such as significandf32, but those aliases aren't in 
> Versions files so they are harmless, not exported from libm.

Ack.

> Much the same would apply to e_scalb templates.

Ack.

> For w_scalb you'd need to 
> treat the existing w_scalb*_compat templates like the other compat ones - 

I didn't follow completely your proposal here.
Are you saying that ldbl-128ibm-compat also needs a w_scalbf128_compat?

> that is, make their entire contents conditional on LIBM_SVID_COMPAT (so 
> they don't get built for new targets or static linking at all), while the 
> new w_scalb template would be listed in gen-libm-calls and not have any 
> LIBM_SVID_COMPAT conditionals in it, and a new dummy 
> sysdeps/ieee754/float128/w_scalbf128.c would ensure no code actually gets 
> built from that template in the normal float128 case.

Ack.

> Given the general 
> handling of finite aliases I'd expect a new __scalbf128_finite function 
> export to be added to the Versions file for ldbl-128ibm-compat as well.

Indeed.

> I would suggest that patches adding such templates and using them for 
> existing formats without changing the ABI anywhere (a cleanup / 
> refactoring of existing code) be separated from patches that actually add 
> new ldbl-128ibm-compat symbols.

OK.  I'm going to split both.

-- 
Tulio Magno

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

* Re: [PATCH 4/9] ldbl-128ibm-compat: Add a generic significand() implementation
  2018-06-15 20:16     ` Tulio Magno Quites Machado Filho
@ 2018-06-15 20:20       ` Tulio Magno Quites Machado Filho
  0 siblings, 0 replies; 25+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-06-15 20:20 UTC (permalink / raw)
  To: Joseph Myers, libc-alpha

Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com> writes:

> Joseph Myers <joseph@codesourcery.com> writes:
>
>> On Wed, 6 Jun 2018, Tulio Magno Quites Machado Filho wrote:
>>
>> For w_scalb you'd need to 
>> treat the existing w_scalb*_compat templates like the other compat ones - 
>
> I didn't follow completely your proposal here.
> Are you saying that ldbl-128ibm-compat also needs a w_scalbf128_compat?

Sorry.  I hit send too soon.
Please ignore this question.  :-D

-- 
Tulio Magno

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

end of thread, other threads:[~2018-06-15 20:20 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-06 22:41 [PATCH 0/9] Introduce ieee128 symbols and redirections Tulio Magno Quites Machado Filho
2018-06-06 22:41 ` [PATCH 1/9] ldbl-128ibm-compat: Create libm-alias-float128.h Tulio Magno Quites Machado Filho
2018-06-06 23:05   ` Joseph Myers
2018-06-13 20:16     ` Tulio Magno Quites Machado Filho
2018-06-06 22:41 ` [PATCH 4/9] ldbl-128ibm-compat: Add a generic significand() implementation Tulio Magno Quites Machado Filho
2018-06-07 13:38   ` Joseph Myers
2018-06-15 20:16     ` Tulio Magno Quites Machado Filho
2018-06-15 20:20       ` Tulio Magno Quites Machado Filho
2018-06-06 22:41 ` [PATCH 3/9] ldbl-128ibm-compat: Provide a generic scalb implementation Tulio Magno Quites Machado Filho
2018-06-06 22:41 ` [PATCH 2/9] Move declare_mgen_finite_alias definition Tulio Magno Quites Machado Filho
2018-06-07 13:25   ` Joseph Myers
2018-06-06 22:42 ` [PATCH 7/9] Refactor math-finite.h and introduce mathcalls-redir.h Tulio Magno Quites Machado Filho
2018-06-06 23:23   ` Joseph Myers
2018-06-13 21:36     ` Tulio Magno Quites Machado Filho
2018-06-13 22:58       ` Joseph Myers
2018-06-14 18:07         ` Tulio Magno Quites Machado Filho
2018-06-06 22:42 ` [PATCH 6/9] ldbl-128ibm-compat: Provide nexttoward functions Tulio Magno Quites Machado Filho
2018-06-06 22:42 ` [PATCH 5/9] ldbl-128ibm-compat: Provide ISO C functions not provided by the _Float128 API Tulio Magno Quites Machado Filho
2018-06-07 14:51   ` Joseph Myers
2018-06-13 21:41     ` Tulio Magno Quites Machado Filho
2018-06-06 22:42 ` [PATCH 8/9] ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions Tulio Magno Quites Machado Filho
2018-06-06 22:43 ` [PATCH 9/9] ldbl-128ibm-compat: Redirect complex math functions Tulio Magno Quites Machado Filho
2018-06-06 23:11 ` [PATCH 0/9] Introduce ieee128 symbols and redirections Joseph Myers
2018-06-13 20:25   ` Tulio Magno Quites Machado Filho
2018-06-13 20:28     ` Joseph Myers

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