unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/6] long double to _Float128 redirecting support
@ 2020-02-03 21:10 Paul E. Murphy
  2020-02-03 21:10 ` [PATCH 1/6] Prepare redirections for IEEE long double on powerpc64le Paul E. Murphy
                   ` (5 more replies)
  0 siblings, 6 replies; 22+ messages in thread
From: Paul E. Murphy @ 2020-02-03 21:10 UTC (permalink / raw)
  To: libc-alpha

There are still quite a few (about 26) patches to enable support
for a third long double format on powerpc64le.  I will focus on
the changes to the shared headers and common files first.

Patch 1 is unmodified from shortly before the closure of the 2.31
development cycle, and should complete the libc work to support
the newest long double format.

Patch 2 fixes some bugs in the header redirects for ldbl == dbl.
This has been rebased, but is otherwise the same.  It is necessary
to support the redirects in the subsequent patches.

Patches 3-5 add redirects to the math functions sufficient to
expose the new ABI.  These have been posted previously around
mid 2018.  I have updated them and dusted them off.

Patch 6 introduces templating to the scalb functions in support
of using these templates to support ldbl == ieee128 later on.
I've tested this on x86 and ppc64le.

The remaining patches are mostly self-contained, but can be
posted to a feature branch for those wanting a sneak peak at the
whole story.

---8<---

As an aside, I have taken over the work to support the ldbl
ieee128 transition from Gabriel.  Likewise, my copyright
assignment should also remain intact after my... intermission.

Gabriel F. T. Gomes (1):
  Prepare redirections for IEEE long double on powerpc64le

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

Tulio Magno Quites Machado Filho (4):
  Undefine redirections after long double definition on __LDBL_COMPAT
    [BZ #23294]
  ldbl-128ibm-compat: Redirect long double functions to f128/ieee128
    functions
  ldbl-128ibm-compat: Provide ieee128 symbols to narrow functions
  Add a generic scalb implementation

 argp/argp.h                                   |  3 +-
 include/math.h                                |  9 +-
 libio/bits/stdio-ldbl.h                       | 46 ++++++----
 libio/stdio.h                                 | 16 ++--
 math/Makefile                                 |  7 +-
 math/bits/mathcalls-helper-functions.h        | 18 ++--
 math/bits/mathcalls.h                         |  9 +-
 math/complex.h                                | 29 ++++++-
 math/{e_scalb.c => e_scalb_template.c}        | 33 +++----
 math/e_scalbf.c                               | 54 ------------
 math/e_scalbl.c                               | 54 ------------
 math/math-narrow.h                            | 15 +---
 math/math.h                                   | 75 ++++++++++++++--
 math/w_scalb_compat.c                         |  6 +-
 math/w_scalb_template.c                       | 59 +++++++++++++
 math/w_scalbf_compat.c                        |  4 +-
 math/w_scalbl_compat.c                        |  4 +-
 misc/bits/syslog-ldbl.h                       |  4 +-
 misc/err.h                                    |  3 +-
 misc/error.h                                  |  6 +-
 misc/sys/cdefs.h                              | 38 +++++++-
 misc/sys/syslog.h                             |  4 +-
 stdio-common/printf.h                         |  3 +-
 stdlib/bits/stdlib-ldbl.h                     | 22 +++++
 stdlib/monetary.h                             |  3 +-
 stdlib/stdlib.h                               |  4 +-
 sysdeps/generic/math-narrow-alias-float128.h  | 32 +++++++
 sysdeps/ieee754/float128/w_scalbf128.c        |  1 +
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  8 ++
 .../math-narrow-alias-float128.h              | 34 ++++++++
 .../ieee754/ldbl-128ibm/bits/iscanonical.h    |  8 +-
 sysdeps/ieee754/ldbl-opt/Makefile             |  4 +-
 .../ldbl-opt/test-redirection-ldbl-64.c       | 87 +++++++++++++++++++
 sysdeps/ieee754/ldbl-opt/w_scalb_compat.c     |  4 +-
 sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c    |  2 +
 wcsmbs/bits/wchar-ldbl.h                      | 36 ++++++--
 wcsmbs/wchar.h                                | 14 +--
 37 files changed, 539 insertions(+), 219 deletions(-)
 rename math/{e_scalb.c => e_scalb_template.c} (64%)
 delete mode 100644 math/e_scalbf.c
 delete mode 100644 math/e_scalbl.c
 create mode 100644 math/w_scalb_template.c
 create mode 100644 sysdeps/generic/math-narrow-alias-float128.h
 create mode 100644 sysdeps/ieee754/float128/w_scalbf128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/math-narrow-alias-float128.h
 create mode 100644 sysdeps/ieee754/ldbl-opt/test-redirection-ldbl-64.c

-- 
2.21.1


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

* [PATCH 1/6] Prepare redirections for IEEE long double on powerpc64le
  2020-02-03 21:10 [PATCH 0/6] long double to _Float128 redirecting support Paul E. Murphy
@ 2020-02-03 21:10 ` Paul E. Murphy
  2020-02-10 21:32   ` Paul E Murphy
  2020-02-11 18:25   ` Tulio Magno Quites Machado Filho
  2020-02-03 21:10 ` [PATCH 2/6] Undefine redirections after long double definition on __LDBL_COMPAT [BZ #23294] Paul E. Murphy
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 22+ messages in thread
From: Paul E. Murphy @ 2020-02-03 21:10 UTC (permalink / raw)
  To: libc-alpha

From: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>

New since v4.

  - Thanks, Paul, for the suggestion to split it from the last patch.

-- 8< --
All functions that have a format string, which can consume a long double
argument, must have one version for each long double format supported on
a platform.  On powerpc64le, these functions currently have two versions
(i.e.: long double with the same format as double, and long double with
IBM Extended Precision format).  Support for a third long double format
option (i.e. long double with IEEE long double format) is being prepared
and all the aforementioned functions now have a third version (not yet
exported on the master branch, but the code is in).

For these functions to get selected (during build time), references to
them in user programs (or dependent libraries) must get redirected to
the aforementioned new versions of the functions.  This patch installs
the header magic required to perform such redirections.

Notice, however, that since the redirections only happen when
__LONG_DOUBLE_USES_FLOAT128 is set to 1, and no platform (including
powerpc64le) currently does it, no redirections actually happen.
Redirections and the exporting of the new functions will happen at the
same time (when powerpc64le adds ldbl-128ibm-compat to their Implies.
---
 argp/argp.h               |  3 ++-
 libio/bits/stdio-ldbl.h   | 46 ++++++++++++++++++++++++++-------------
 libio/stdio.h             | 16 +++++++++-----
 misc/bits/syslog-ldbl.h   |  4 ++--
 misc/err.h                |  3 ++-
 misc/error.h              |  6 +++--
 misc/sys/cdefs.h          | 38 ++++++++++++++++++++++++++++++--
 misc/sys/syslog.h         |  4 +++-
 stdio-common/printf.h     |  3 ++-
 stdlib/bits/stdlib-ldbl.h | 22 +++++++++++++++++++
 stdlib/monetary.h         |  3 ++-
 stdlib/stdlib.h           |  4 +++-
 wcsmbs/bits/wchar-ldbl.h  | 36 +++++++++++++++++++++++++-----
 wcsmbs/wchar.h            | 14 +++++++-----
 14 files changed, 159 insertions(+), 43 deletions(-)

diff --git a/argp/argp.h b/argp/argp.h
index 329aae097f..358d9b43cd 100644
--- a/argp/argp.h
+++ b/argp/argp.h
@@ -554,7 +554,8 @@ __NTH (__option_is_end (const struct argp_option *__opt))
 # endif
 #endif /* Use extern inlines.  */
 
-#ifdef __LDBL_COMPAT
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
 # include <bits/argp-ldbl.h>
 #endif
 
diff --git a/libio/bits/stdio-ldbl.h b/libio/bits/stdio-ldbl.h
index 6626412fce..3bb9f7dd2c 100644
--- a/libio/bits/stdio-ldbl.h
+++ b/libio/bits/stdio-ldbl.h
@@ -27,9 +27,17 @@ __LDBL_REDIR_DECL (vfprintf)
 __LDBL_REDIR_DECL (vprintf)
 __LDBL_REDIR_DECL (vsprintf)
 #if !__GLIBC_USE (DEPRECATED_SCANF)
+# if defined __LDBL_COMPAT
 __LDBL_REDIR1_DECL (fscanf, __nldbl___isoc99_fscanf)
 __LDBL_REDIR1_DECL (scanf, __nldbl___isoc99_scanf)
 __LDBL_REDIR1_DECL (sscanf, __nldbl___isoc99_sscanf)
+# elif __LONG_DOUBLE_USES_FLOAT128 == 1
+__LDBL_REDIR1_DECL (fscanf, __isoc99_fscanfieee128)
+__LDBL_REDIR1_DECL (scanf, __isoc99_scanfieee128)
+__LDBL_REDIR1_DECL (sscanf, __isoc99_sscanfieee128)
+# else
+#  error bits/stdlib-ldbl.h included when no ldbl redirections are required.
+# endif
 #else
 __LDBL_REDIR_DECL (fscanf)
 __LDBL_REDIR_DECL (scanf)
@@ -43,9 +51,17 @@ __LDBL_REDIR_DECL (vsnprintf)
 
 #ifdef	__USE_ISOC99
 # if !__GLIBC_USE (DEPRECATED_SCANF)
+#  if defined __LDBL_COMPAT
 __LDBL_REDIR1_DECL (vfscanf, __nldbl___isoc99_vfscanf)
 __LDBL_REDIR1_DECL (vscanf, __nldbl___isoc99_vscanf)
 __LDBL_REDIR1_DECL (vsscanf, __nldbl___isoc99_vsscanf)
+#  elif __LONG_DOUBLE_USES_FLOAT128 == 1
+__LDBL_REDIR1_DECL (vfscanf, __isoc99_vfscanfieee128)
+__LDBL_REDIR1_DECL (vscanf, __isoc99_vscanfieee128)
+__LDBL_REDIR1_DECL (vsscanf, __isoc99_vsscanfieee128)
+#  else
+#   error bits/stdlib-ldbl.h included when no ldbl redirections are required.
+#  endif
 # else
 __LDBL_REDIR_DECL (vfscanf)
 __LDBL_REDIR_DECL (vsscanf)
@@ -60,33 +76,33 @@ __LDBL_REDIR_DECL (dprintf)
 
 #ifdef __USE_GNU
 __LDBL_REDIR_DECL (vasprintf)
-__LDBL_REDIR_DECL (__asprintf)
+__LDBL_REDIR2_DECL (asprintf)
 __LDBL_REDIR_DECL (asprintf)
 __LDBL_REDIR_DECL (obstack_printf)
 __LDBL_REDIR_DECL (obstack_vprintf)
 #endif
 
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
-__LDBL_REDIR_DECL (__sprintf_chk)
-__LDBL_REDIR_DECL (__vsprintf_chk)
+__LDBL_REDIR2_DECL (sprintf_chk)
+__LDBL_REDIR2_DECL (vsprintf_chk)
 # if defined __USE_ISOC99 || defined __USE_UNIX98
-__LDBL_REDIR_DECL (__snprintf_chk)
-__LDBL_REDIR_DECL (__vsnprintf_chk)
+__LDBL_REDIR2_DECL (snprintf_chk)
+__LDBL_REDIR2_DECL (vsnprintf_chk)
 # endif
 # if __USE_FORTIFY_LEVEL > 1
-__LDBL_REDIR_DECL (__fprintf_chk)
-__LDBL_REDIR_DECL (__printf_chk)
-__LDBL_REDIR_DECL (__vfprintf_chk)
-__LDBL_REDIR_DECL (__vprintf_chk)
+__LDBL_REDIR2_DECL (fprintf_chk)
+__LDBL_REDIR2_DECL (printf_chk)
+__LDBL_REDIR2_DECL (vfprintf_chk)
+__LDBL_REDIR2_DECL (vprintf_chk)
 #  ifdef __USE_XOPEN2K8
-__LDBL_REDIR_DECL (__dprintf_chk)
-__LDBL_REDIR_DECL (__vdprintf_chk)
+__LDBL_REDIR2_DECL (dprintf_chk)
+__LDBL_REDIR2_DECL (vdprintf_chk)
 #  endif
 #  ifdef __USE_GNU
-__LDBL_REDIR_DECL (__asprintf_chk)
-__LDBL_REDIR_DECL (__vasprintf_chk)
-__LDBL_REDIR_DECL (__obstack_printf_chk)
-__LDBL_REDIR_DECL (__obstack_vprintf_chk)
+__LDBL_REDIR2_DECL (asprintf_chk)
+__LDBL_REDIR2_DECL (vasprintf_chk)
+__LDBL_REDIR2_DECL (obstack_printf_chk)
+__LDBL_REDIR2_DECL (obstack_vprintf_chk)
 #  endif
 # endif
 #endif
diff --git a/libio/stdio.h b/libio/stdio.h
index 5a10a4d3ee..18e29752c4 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -400,9 +400,12 @@ extern int sscanf (const char *__restrict __s,
 		   const char *__restrict __format, ...) __THROW;
 
 /* For historical reasons, the C99-compliant versions of the scanf
-   functions are at alternative names.  When __LDBL_COMPAT is in
-   effect, this is handled in bits/stdio-ldbl.h.  */
-#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT
+   functions are at alternative names.  When __LDBL_COMPAT or
+   __LONG_DOUBLE_USES_FLOAT128 are in effect, this is handled in
+   bits/stdio-ldbl.h.  */
+#include <bits/floatn.h>
+#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
+    && __LONG_DOUBLE_USES_FLOAT128 == 0
 # ifdef __REDIRECT
 extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
 				const char *__restrict __format, ...),
@@ -447,7 +450,8 @@ extern int vsscanf (const char *__restrict __s,
 
 /* Same redirection as above for the v*scanf family.  */
 # if !__GLIBC_USE (DEPRECATED_SCANF)
-#  if defined __REDIRECT && !defined __LDBL_COMPAT
+#  if defined __REDIRECT && !defined __LDBL_COMPAT \
+      && __LONG_DOUBLE_USES_FLOAT128 == 0
 extern int __REDIRECT (vfscanf,
 		       (FILE *__restrict __s,
 			const char *__restrict __format, __gnuc_va_list __arg),
@@ -866,7 +870,9 @@ extern int __overflow (FILE *, int);
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
 # include <bits/stdio2.h>
 #endif
-#ifdef __LDBL_COMPAT
+
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
 # include <bits/stdio-ldbl.h>
 #endif
 
diff --git a/misc/bits/syslog-ldbl.h b/misc/bits/syslog-ldbl.h
index fead0d4648..657b192b9b 100644
--- a/misc/bits/syslog-ldbl.h
+++ b/misc/bits/syslog-ldbl.h
@@ -27,9 +27,9 @@ __LDBL_REDIR_DECL (vsyslog)
 #endif
 
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
-__LDBL_REDIR_DECL (__syslog_chk)
+__LDBL_REDIR2_DECL (syslog_chk)
 
 # ifdef __USE_MISC
-__LDBL_REDIR_DECL (__vsyslog_chk)
+__LDBL_REDIR2_DECL (vsyslog_chk)
 # endif
 #endif
diff --git a/misc/err.h b/misc/err.h
index f6fd72945f..d146a55054 100644
--- a/misc/err.h
+++ b/misc/err.h
@@ -52,7 +52,8 @@ extern void errx (int __status, const char *__format, ...)
 extern void verrx (int __status, const char *, __gnuc_va_list)
      __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0)));
 
-#ifdef __LDBL_COMPAT
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
 # include <bits/err-ldbl.h>
 #endif
 
diff --git a/misc/error.h b/misc/error.h
index a456695f1a..bb8a3b26a4 100644
--- a/misc/error.h
+++ b/misc/error.h
@@ -47,11 +47,13 @@ extern unsigned int error_message_count;
    variable controls whether this mode is selected or not.  */
 extern int error_one_per_line;
 
-#ifdef __LDBL_COMPAT
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
 # include <bits/error-ldbl.h>
 #else
 /* Do not inline error and error_at_line when long double has the same
-   size of double, because that would invalidate the redirections to the
+   size of double, nor when long double reuses the float128
+   implementation, because that would invalidate the redirections to the
    compatibility functions.  */
 # if defined __extern_always_inline && defined __va_arg_pack
 #  include <bits/error.h>
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index ff7144f3f3..dd5f69f833 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -452,7 +452,37 @@
 #include <bits/wordsize.h>
 #include <bits/long-double.h>
 
-#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
+#if __LONG_DOUBLE_USES_FLOAT128 == 1
+# ifdef __REDIRECT
+
+/* Alias name defined automatically.  */
+#  define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
+#  define __LDBL_REDIR_DECL(name) \
+  extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
+
+/* Alias name defined automatically, with leading underscores.  */
+#  define __LDBL_REDIR2_DECL(name) \
+  extern __typeof (__##name) __##name \
+    __asm (__ASMNAME ("__" #name "ieee128"));
+
+/* Alias name defined manually.  */
+#  define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
+#  define __LDBL_REDIR1_DECL(name, alias) \
+  extern __typeof (name) name __asm (__ASMNAME (#alias));
+
+#  define __LDBL_REDIR1_NTH(name, proto, alias) \
+  __REDIRECT_NTH (name, proto, alias)
+#  define __REDIRECT_NTH_LDBL(name, proto, alias) \
+  __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
+
+/* Unused.  */
+#  define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
+#  define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
+
+# else
+_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
+# endif
+#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
 # define __LDBL_COMPAT 1
 # ifdef __REDIRECT
 #  define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
@@ -461,6 +491,8 @@
 #  define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
 #  define __LDBL_REDIR_NTH(name, proto) \
   __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
+#  define __LDBL_REDIR2_DECL(name) \
+  extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
 #  define __LDBL_REDIR1_DECL(name, alias) \
   extern __typeof (name) name __asm (__ASMNAME (#alias));
 #  define __LDBL_REDIR_DECL(name) \
@@ -471,11 +503,13 @@
   __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
 # endif
 #endif
-#if !defined __LDBL_COMPAT || !defined __REDIRECT
+#if (!defined __LDBL_COMPAT && __LONG_DOUBLE_USES_FLOAT128 == 0) \
+    || !defined __REDIRECT
 # define __LDBL_REDIR1(name, proto, alias) name proto
 # define __LDBL_REDIR(name, proto) name proto
 # define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
 # define __LDBL_REDIR_NTH(name, proto) name proto __THROW
+# define __LDBL_REDIR2_DECL(name)
 # define __LDBL_REDIR_DECL(name)
 # ifdef __REDIRECT
 #  define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
diff --git a/misc/sys/syslog.h b/misc/sys/syslog.h
index ee01478c4b..c000b8e915 100644
--- a/misc/sys/syslog.h
+++ b/misc/sys/syslog.h
@@ -206,7 +206,9 @@ extern void vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap)
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
 # include <bits/syslog.h>
 #endif
-#ifdef __LDBL_COMPAT
+
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
 # include <bits/syslog-ldbl.h>
 #endif
 
diff --git a/stdio-common/printf.h b/stdio-common/printf.h
index ad3c8a4254..00bedebfdb 100644
--- a/stdio-common/printf.h
+++ b/stdio-common/printf.h
@@ -182,7 +182,8 @@ extern int printf_size_info (const struct printf_info *__restrict
 			     __info, size_t __n, int *__restrict __argtypes)
      __THROW;
 
-#ifdef __LDBL_COMPAT
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
 # include <bits/printf-ldbl.h>
 #endif
 
diff --git a/stdlib/bits/stdlib-ldbl.h b/stdlib/bits/stdlib-ldbl.h
index 5c6294ed9b..2469474532 100644
--- a/stdlib/bits/stdlib-ldbl.h
+++ b/stdlib/bits/stdlib-ldbl.h
@@ -21,21 +21,43 @@
 #endif
 
 #ifdef	__USE_ISOC99
+# ifdef __LDBL_COMPAT
 __LDBL_REDIR1_DECL (strtold, strtod)
+# else
+__LDBL_REDIR1_DECL (strtold, __strtoieee128)
+# endif
 #endif
 
 #ifdef __USE_GNU
+# ifdef __LDBL_COMPAT
 __LDBL_REDIR1_DECL (strtold_l, strtod_l)
+# else
+__LDBL_REDIR1_DECL (strtold_l, __strtoieee128_l)
+# endif
 #endif
 
 #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
+# ifdef __LDBL_COMPAT
 __LDBL_REDIR1_DECL (strfroml, strfromd)
+# else
+__LDBL_REDIR1_DECL (strfroml, __strfromieee128)
+# endif
 #endif
 
 #ifdef __USE_MISC
+# if defined __LDBL_COMPAT
 __LDBL_REDIR1_DECL (qecvt, ecvt)
 __LDBL_REDIR1_DECL (qfcvt, fcvt)
 __LDBL_REDIR1_DECL (qgcvt, gcvt)
 __LDBL_REDIR1_DECL (qecvt_r, ecvt_r)
 __LDBL_REDIR1_DECL (qfcvt_r, fcvt_r)
+# elif __LONG_DOUBLE_USES_FLOAT128 == 1
+__LDBL_REDIR1_DECL (qecvt, __qecvtieee128)
+__LDBL_REDIR1_DECL (qfcvt, __qfcvtieee128)
+__LDBL_REDIR1_DECL (qgcvt, __qgcvtieee128)
+__LDBL_REDIR1_DECL (qecvt_r, __qecvtieee128_r)
+__LDBL_REDIR1_DECL (qfcvt_r, __qfcvtieee128_r)
+# else
+#  error bits/stdlib-ldbl.h included when no ldbl redirections are required.
+# endif
 #endif
diff --git a/stdlib/monetary.h b/stdlib/monetary.h
index dfb6ed5c0c..4a6d61fd2d 100644
--- a/stdlib/monetary.h
+++ b/stdlib/monetary.h
@@ -50,7 +50,8 @@ extern ssize_t strfmon_l (char *__restrict __s, size_t __maxsize,
      __THROW __attribute_format_strfmon__ (4, 5);
 #endif
 
-#ifdef __LDBL_COMPAT
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
 # include <bits/monetary-ldbl.h>
 #endif
 
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index e3470631e1..a7c0c71a80 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -1016,7 +1016,9 @@ extern int ttyslot (void) __THROW;
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
 # include <bits/stdlib.h>
 #endif
-#ifdef __LDBL_COMPAT
+
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
 # include <bits/stdlib-ldbl.h>
 #endif
 
diff --git a/wcsmbs/bits/wchar-ldbl.h b/wcsmbs/bits/wchar-ldbl.h
index fc50ee26de..75d547f680 100644
--- a/wcsmbs/bits/wchar-ldbl.h
+++ b/wcsmbs/bits/wchar-ldbl.h
@@ -28,9 +28,17 @@ __LDBL_REDIR_DECL (vfwprintf);
 __LDBL_REDIR_DECL (vwprintf);
 __LDBL_REDIR_DECL (vswprintf);
 # if !__GLIBC_USE (DEPRECATED_SCANF)
+#  if defined __LDBL_COMPAT
 __LDBL_REDIR1_DECL (fwscanf, __nldbl___isoc99_fwscanf)
 __LDBL_REDIR1_DECL (wscanf, __nldbl___isoc99_wscanf)
 __LDBL_REDIR1_DECL (swscanf, __nldbl___isoc99_swscanf)
+#  elif __LONG_DOUBLE_USES_FLOAT128 == 1
+__LDBL_REDIR1_DECL (fwscanf, __isoc99_fwscanfieee128)
+__LDBL_REDIR1_DECL (wscanf, __isoc99_wscanfieee128)
+__LDBL_REDIR1_DECL (swscanf, __isoc99_swscanfieee128)
+#  else
+#   error bits/stdlib-ldbl.h included when no ldbl redirections are required.
+#  endif
 # else
 __LDBL_REDIR_DECL (fwscanf);
 __LDBL_REDIR_DECL (wscanf);
@@ -39,11 +47,23 @@ __LDBL_REDIR_DECL (swscanf);
 #endif
 
 #ifdef __USE_ISOC99
+# ifdef __LDBL_COMPAT
 __LDBL_REDIR1_DECL (wcstold, wcstod);
+# else
+__LDBL_REDIR1_DECL (wcstold, __wcstoieee128)
+# endif
 # if !__GLIBC_USE (DEPRECATED_SCANF)
+#  if defined __LDBL_COMPAT
 __LDBL_REDIR1_DECL (vfwscanf, __nldbl___isoc99_vfwscanf)
 __LDBL_REDIR1_DECL (vwscanf, __nldbl___isoc99_vwscanf)
 __LDBL_REDIR1_DECL (vswscanf, __nldbl___isoc99_vswscanf)
+#  elif __LONG_DOUBLE_USES_FLOAT128 == 1
+__LDBL_REDIR1_DECL (vfwscanf, __isoc99_vfwscanfieee128)
+__LDBL_REDIR1_DECL (vwscanf, __isoc99_vwscanfieee128)
+__LDBL_REDIR1_DECL (vswscanf, __isoc99_vswscanfieee128)
+#  else
+#   error bits/stdlib-ldbl.h included when no ldbl redirections are required.
+#  endif
 # else
 __LDBL_REDIR_DECL (vfwscanf);
 __LDBL_REDIR_DECL (vwscanf);
@@ -52,16 +72,20 @@ __LDBL_REDIR_DECL (vswscanf);
 #endif
 
 #ifdef __USE_GNU
+# ifdef __LDBL_COMPAT
 __LDBL_REDIR1_DECL (wcstold_l, wcstod_l);
+# else
+__LDBL_REDIR1_DECL (wcstold_l, __wcstoieee128_l)
+# endif
 #endif
 
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
-__LDBL_REDIR_DECL (__swprintf_chk)
-__LDBL_REDIR_DECL (__vswprintf_chk)
+__LDBL_REDIR2_DECL (swprintf_chk)
+__LDBL_REDIR2_DECL (vswprintf_chk)
 # if __USE_FORTIFY_LEVEL > 1
-__LDBL_REDIR_DECL (__fwprintf_chk)
-__LDBL_REDIR_DECL (__wprintf_chk)
-__LDBL_REDIR_DECL (__vfwprintf_chk)
-__LDBL_REDIR_DECL (__vwprintf_chk)
+__LDBL_REDIR2_DECL (fwprintf_chk)
+__LDBL_REDIR2_DECL (wprintf_chk)
+__LDBL_REDIR2_DECL (vfwprintf_chk)
+__LDBL_REDIR2_DECL (vwprintf_chk)
 # endif
 #endif
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index 5e0d65b14e..fb2cec8167 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -633,9 +633,11 @@ extern int swscanf (const wchar_t *__restrict __s,
      __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
 
 /* For historical reasons, the C99-compliant versions of the scanf
-   functions are at alternative names.  When __LDBL_COMPAT is in
-   effect, this is handled in bits/wchar-ldbl.h.  */
-#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT
+   functions are at alternative names.  When __LDBL_COMPAT or
+   __LONG_DOUBLE_USES_FLOAT128 are in effect, this is handled in
+   bits/wchar-ldbl.h.  */
+#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
+     && __LONG_DOUBLE_USES_FLOAT128 == 0
 #  ifdef __REDIRECT
 extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream,
 				 const wchar_t *__restrict __format, ...),
@@ -688,7 +690,8 @@ extern int vswscanf (const wchar_t *__restrict __s,
 /* Same redirection as above for the v*wscanf family.  */
 # if !__GLIBC_USE (DEPRECATED_SCANF) \
      && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
-     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
+     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) \
+     && __LONG_DOUBLE_USES_FLOAT128 == 0
 #  ifdef __REDIRECT
 extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
 				  const wchar_t *__restrict __format,
@@ -849,7 +852,8 @@ extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
 # include <bits/wchar2.h>
 #endif
 
-#ifdef __LDBL_COMPAT
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
 # include <bits/wchar-ldbl.h>
 #endif
 
-- 
2.21.1


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

* [PATCH 2/6] Undefine redirections after long double definition on __LDBL_COMPAT [BZ #23294]
  2020-02-03 21:10 [PATCH 0/6] long double to _Float128 redirecting support Paul E. Murphy
  2020-02-03 21:10 ` [PATCH 1/6] Prepare redirections for IEEE long double on powerpc64le Paul E. Murphy
@ 2020-02-03 21:10 ` Paul E. Murphy
  2020-02-17 15:08   ` Paul E Murphy
  2020-02-03 21:10 ` [PATCH 3/6] ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions Paul E. Murphy
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 22+ messages in thread
From: Paul E. Murphy @ 2020-02-03 21:10 UTC (permalink / raw)
  To: libc-alpha

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

After defining the long double redirections to double, __MATHDECL_1 has
to be redefined to its previous state in order to avoid redirecting all
subsequent types.
---
 math/complex.h                                | 10 ++-
 math/math.h                                   | 18 ++--
 sysdeps/ieee754/ldbl-opt/Makefile             |  4 +-
 .../ldbl-opt/test-redirection-ldbl-64.c       | 87 +++++++++++++++++++
 4 files changed, 112 insertions(+), 7 deletions(-)
 create mode 100644 sysdeps/ieee754/ldbl-opt/test-redirection-ldbl-64.c

diff --git a/math/complex.h b/math/complex.h
index d63005bec6..42f3fd7517 100644
--- a/math/complex.h
+++ b/math/complex.h
@@ -98,8 +98,10 @@ __BEGIN_DECLS
 #define __MATHDECL(type, function, args) \
   __MATHDECL_1(type, function, args); \
   __MATHDECL_1(type, __CONCAT(__,function), args)
-#define __MATHDECL_1(type, function, args) \
+#define __MATHDECL_1_IMPL(type, function, args) \
   extern type __MATH_PRECNAME(function) args __THROW
+#define __MATHDECL_1(type, function, args) \
+  __MATHDECL_1_IMPL(type, function, args)
 
 #define _Mdouble_ 		double
 #define __MATH_PRECNAME(name)	name
@@ -127,6 +129,11 @@ __BEGIN_DECLS
 # define _Mdouble_ 		long double
 # define __MATH_PRECNAME(name)	name##l
 # include <bits/cmathcalls.h>
+# if defined __LDBL_COMPAT
+#  undef __MATHDECL_1
+#  define __MATHDECL_1(type, function, args) \
+  __MATHDECL_1_IMPL(type, function, args)
+# endif
 #endif
 #undef	_Mdouble_
 #undef	__MATH_PRECNAME
@@ -215,6 +222,7 @@ __BEGIN_DECLS
 # undef _Mdouble_complex_
 #endif
 
+#undef	__MATHDECL_1_IMPL
 #undef	__MATHDECL_1
 #undef	__MATHDECL
 #undef	__MATHCALL
diff --git a/math/math.h b/math/math.h
index fb211bb00b..e13b3f3a29 100644
--- a/math/math.h
+++ b/math/math.h
@@ -279,8 +279,13 @@ enum
 #define __MATHDECLX(type, function,suffix, args, attrib) \
   __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
   __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib)
-#define __MATHDECL_1(type, function,suffix, args) \
+#define __MATHDECL_1_IMPL(type, function, suffix, args) \
   extern type __MATH_PRECNAME(function,suffix) args __THROW
+#define __MATHDECL_1(type, function, suffix, args) \
+  __MATHDECL_1_IMPL(type, function, suffix, args)
+
+#define __MATHREDIR(type, function, suffix, args, to) \
+  extern type __REDIRECT_NTH (__MATH_PRECNAME (function, suffix), args, to)
 
 #define _Mdouble_		double
 #define __MATH_PRECNAME(name,r)	__CONCAT(name,r)
@@ -331,11 +336,8 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #   endif
 
 #   undef __MATHDECL_1
-#   define __MATHDECL_2(type, function,suffix, args, alias) \
-  extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \
-			     args, alias)
 #   define __MATHDECL_1(type, function,suffix, args) \
-  __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix))
+  __MATHREDIR(type, function, suffix, args, __CONCAT(function,suffix))
 #  endif
 
 /* Include the file of declarations again, this time using `long double'
@@ -353,6 +355,11 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #  undef __MATH_DECLARING_DOUBLE
 #  undef __MATH_DECLARING_FLOATN
 
+#  if defined __LDBL_COMPAT
+#   undef __MATHDECL_1
+#   define __MATHDECL_1(type, function, suffix, args) \
+  __MATHDECL_1_IMPL(type, function, suffix, args)
+#  endif
 # endif /* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */
 
 #endif	/* Use ISO C99.  */
@@ -479,6 +486,7 @@ extern long double __REDIRECT_NTH (nexttowardl,
 # undef __MATH_DECLARING_FLOATN
 #endif /* __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC).  */
 
+#undef	__MATHDECL_1_IMPL
 #undef	__MATHDECL_1
 #undef	__MATHDECL
 #undef	__MATHCALL
diff --git a/sysdeps/ieee754/ldbl-opt/Makefile b/sysdeps/ieee754/ldbl-opt/Makefile
index 791a5eabd2..4e41a27e80 100644
--- a/sysdeps/ieee754/ldbl-opt/Makefile
+++ b/sysdeps/ieee754/ldbl-opt/Makefile
@@ -172,9 +172,11 @@ CFLAGS-nldbl-y0.c = -fno-builtin-y0l
 CFLAGS-nldbl-y1.c = -fno-builtin-y1l
 CFLAGS-nldbl-yn.c = -fno-builtin-ynl
 
-tests += test-narrow-macros-ldbl-64 test-nldbl-redirect
+tests += test-narrow-macros-ldbl-64 test-nldbl-redirect \
+	 test-redirection-ldbl-64
 CFLAGS-test-narrow-macros-ldbl-64.c += -mlong-double-64
 CFLAGS-test-nldbl-redirect.c += -mlong-double-64
+CFLAGS-test-redirection-ldbl-64.c += -mlong-double-64
 
 $(objpfx)test-nldbl-redirect: $(objpfx)libnldbl_nonshared.a
 
diff --git a/sysdeps/ieee754/ldbl-opt/test-redirection-ldbl-64.c b/sysdeps/ieee754/ldbl-opt/test-redirection-ldbl-64.c
new file mode 100644
index 0000000000..cc683596a0
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/test-redirection-ldbl-64.c
@@ -0,0 +1,87 @@
+/* Test if __LDBL_COMPAT redirections conflict with other types.
+   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/>.  */
+
+/* Redirecting functions twice may lead to -Werror=pragmas errors.
+   In a __LDBL_COMPAT environment, only long double functions should be
+   redirected.  This test redirects math functions to a dummy function in
+   order to validate if they have not been redirected before.  */
+
+#include <math.h>
+#include <complex.h>
+
+#if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+# error "This test should never request finite functions"
+#endif
+
+#define MATH_REDIRX(function, to) \
+  extern typeof (function) function __asm__ ("" # to);
+#define MATH_REDIR(function) MATH_REDIRX (function, __ ## function)
+
+#if __HAVE_FLOAT32
+# define MATH_F32(function) MATH_REDIR(function ## f32)
+#else
+# define MATH_F32(function)
+#endif
+
+#if __HAVE_FLOAT32X
+# define MATH_F32X(function) MATH_REDIR(function ## f32x)
+#else
+# define MATH_F32X(function)
+#endif
+
+#if __HAVE_FLOAT64
+# define MATH_F64(function) MATH_REDIR(function ## f64)
+#else
+# define MATH_F64(function)
+#endif
+
+#if __HAVE_FLOAT64X
+# define MATH_F64X(function) MATH_REDIR(function ## f64x)
+#else
+# define MATH_F64X(function)
+#endif
+
+#define MATH_FUNCTION(function) \
+  MATH_REDIR(function); \
+  MATH_REDIR(function ## f); \
+  MATH_F32(function); \
+  MATH_F32X(function); \
+  MATH_F64(function); \
+  MATH_F64X(function);
+
+MATH_FUNCTION (acos);
+MATH_FUNCTION (asin);
+MATH_FUNCTION (exp);
+MATH_FUNCTION (floor);
+MATH_FUNCTION (ldexp);
+MATH_FUNCTION (log);
+MATH_FUNCTION (sin);
+MATH_FUNCTION (cabs);
+MATH_FUNCTION (cacos);
+MATH_FUNCTION (casin);
+MATH_FUNCTION (clog);
+MATH_FUNCTION (csin);
+
+static int
+do_test (void)
+{
+  /* This is a compilation test.  */
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
2.21.1


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

* [PATCH 3/6] ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions
  2020-02-03 21:10 [PATCH 0/6] long double to _Float128 redirecting support Paul E. Murphy
  2020-02-03 21:10 ` [PATCH 1/6] Prepare redirections for IEEE long double on powerpc64le Paul E. Murphy
  2020-02-03 21:10 ` [PATCH 2/6] Undefine redirections after long double definition on __LDBL_COMPAT [BZ #23294] Paul E. Murphy
@ 2020-02-03 21:10 ` Paul E. Murphy
  2020-02-24 14:58   ` Paul E Murphy
  2020-02-03 21:10 ` [PATCH 4/6] ldbl-128ibm-compat: Redirect complex math functions Paul E. Murphy
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 22+ messages in thread
From: Paul E. Murphy @ 2020-02-03 21:10 UTC (permalink / raw)
  To: libc-alpha

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

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

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

Both math/bits/mathcalls-helper-functions.h and math/bits/mathcalls.h
were modified in order to provide alternative redirection destinations
that are essential to support functions that should not be redirected to
the same name pattern of the rest of the functions, i.e.: __fpclassify,
__signbit, __iseqsig, __issignaling, isinf, finite and isnan, which will
be redirected to __*f128 instead of __*ieee128 used for the rest.
---
 include/math.h                                |  9 ++-
 math/bits/mathcalls-helper-functions.h        | 18 +++---
 math/bits/mathcalls.h                         |  9 ++-
 math/math.h                                   | 59 ++++++++++++++++++-
 .../ieee754/ldbl-128ibm/bits/iscanonical.h    |  8 ++-
 5 files changed, 85 insertions(+), 18 deletions(-)

diff --git a/include/math.h b/include/math.h
index a274f2bdfd..1b3199b3f6 100644
--- a/include/math.h
+++ b/include/math.h
@@ -18,7 +18,8 @@ hidden_proto (__finitef)
 hidden_proto (__isinff)
 hidden_proto (__isnanf)
 
-#  ifndef __NO_LONG_DOUBLE_MATH
+#  if !defined __NO_LONG_DOUBLE_MATH \
+      && __LONG_DOUBLE_USES_FLOAT128 == 0
 hidden_proto (__finitel)
 hidden_proto (__isinfl)
 hidden_proto (__isnanl)
@@ -40,7 +41,8 @@ libm_hidden_proto (__exp)
 libm_hidden_proto (__expf)
 libm_hidden_proto (__roundeven)
 
-# ifndef __NO_LONG_DOUBLE_MATH
+#  if !defined __NO_LONG_DOUBLE_MATH \
+      && __LONG_DOUBLE_USES_FLOAT128 == 0
 libm_hidden_proto (__fpclassifyl)
 libm_hidden_proto (__issignalingl)
 libm_hidden_proto (__expl)
@@ -140,7 +142,8 @@ fabsf128 (_Float128 x)
   double (FUNC) (ARGS (double)) asm (PREFIX #FUNC );		\
   MATH_REDIRECT_LDBL (FUNC, PREFIX, ARGS)			\
   MATH_REDIRECT_F128 (FUNC, PREFIX, ARGS)
-#   ifdef __NO_LONG_DOUBLE_MATH
+#   if defined __NO_LONG_DOUBLE_MATH 				\
+       || __LONG_DOUBLE_USES_FLOAT128 == 1
 #    define MATH_REDIRECT_LDBL(FUNC, PREFIX, ARGS)
 #   else
 #    define MATH_REDIRECT_LDBL(FUNC, PREFIX, ARGS)			\
diff --git a/math/bits/mathcalls-helper-functions.h b/math/bits/mathcalls-helper-functions.h
index 5b1e9edb01..8d1970df81 100644
--- a/math/bits/mathcalls-helper-functions.h
+++ b/math/bits/mathcalls-helper-functions.h
@@ -16,28 +16,30 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-
 /* Classify given number.  */
-__MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value))
+__MATHDECL_ALIAS (int, __fpclassify,, (_Mdouble_ __value), fpclassify)
      __attribute__ ((__const__));
 
 /* Test for negative number.  */
-__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value))
+__MATHDECL_ALIAS (int, __signbit,, (_Mdouble_ __value), signbit)
      __attribute__ ((__const__));
 
 /* Return 0 if VALUE is finite or NaN, +1 if it
    is +Infinity, -1 if it is -Infinity.  */
-__MATHDECL_1 (int, __isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_ALIAS (int, __isinf,, (_Mdouble_ __value), isinf)
+  __attribute__ ((__const__));
 
 /* Return nonzero if VALUE is finite and not NaN.  Used by isfinite macro.  */
-__MATHDECL_1 (int, __finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_ALIAS (int, __finite,, (_Mdouble_ __value), finite)
+  __attribute__ ((__const__));
 
 /* Return nonzero if VALUE is not a number.  */
-__MATHDECL_1 (int, __isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_ALIAS (int, __isnan,, (_Mdouble_ __value), isnan)
+  __attribute__ ((__const__));
 
 /* Test equality.  */
-__MATHDECL_1 (int, __iseqsig,, (_Mdouble_ __x, _Mdouble_ __y));
+__MATHDECL_ALIAS (int, __iseqsig,, (_Mdouble_ __x, _Mdouble_ __y), iseqsig);
 
 /* Test for signaling NaN.  */
-__MATHDECL_1 (int, __issignaling,, (_Mdouble_ __value))
+__MATHDECL_ALIAS (int, __issignaling,, (_Mdouble_ __value), issignaling)
      __attribute__ ((__const__));
diff --git a/math/bits/mathcalls.h b/math/bits/mathcalls.h
index 43e5481b94..d39c2fa5f1 100644
--- a/math/bits/mathcalls.h
+++ b/math/bits/mathcalls.h
@@ -174,12 +174,14 @@ __MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
       && !__MATH_DECLARING_FLOATN
 /* Return 0 if VALUE is finite or NaN, +1 if it
    is +Infinity, -1 if it is -Infinity.  */
-__MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_ALIAS (int,isinf,, (_Mdouble_ __value), isinf)
+  __attribute__ ((__const__));
 # endif
 
 # if !__MATH_DECLARING_FLOATN
 /* Return nonzero if VALUE is finite and not NaN.  */
-__MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_ALIAS (int,finite,, (_Mdouble_ __value), finite)
+  __attribute__ ((__const__));
 
 /* Return the remainder of X/Y.  */
 __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
@@ -208,7 +210,8 @@ __MATHCALL (nan,, (const char *__tagb));
        || __MATH_DECLARING_DOUBLE == 0)) /* isnanf or isnanl don't.  */ \
       && !__MATH_DECLARING_FLOATN
 /* Return nonzero if VALUE is not a number.  */
-__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_ALIAS (int,isnan,, (_Mdouble_ __value), isnan)
+  __attribute__ ((__const__));
 # endif
 #endif
 
diff --git a/math/math.h b/math/math.h
index e13b3f3a29..1692ff4a45 100644
--- a/math/math.h
+++ b/math/math.h
@@ -283,6 +283,10 @@ enum
   extern type __MATH_PRECNAME(function,suffix) args __THROW
 #define __MATHDECL_1(type, function, suffix, args) \
   __MATHDECL_1_IMPL(type, function, suffix, args)
+/* Ignore the alias by default.  The alias is only useful with
+   redirections.  */
+#define __MATHDECL_ALIAS(type, function, suffix, args, alias) \
+  __MATHDECL_1(type, function, suffix, args)
 
 #define __MATHREDIR(type, function, suffix, args, to) \
   extern type __REDIRECT_NTH (__MATH_PRECNAME (function, suffix), args, to)
@@ -338,6 +342,35 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #   undef __MATHDECL_1
 #   define __MATHDECL_1(type, function,suffix, args) \
   __MATHREDIR(type, function, suffix, args, __CONCAT(function,suffix))
+
+#  elif __LONG_DOUBLE_USES_FLOAT128 == 1
+#   ifdef __REDIRECT_NTH
+#    ifdef __USE_ISOC99
+extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y),
+			    __nexttowardf_to_ieee128)
+  __attribute__ ((__const__));
+extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y),
+			     __nexttoward_to_ieee128)
+  __attribute__ ((__const__));
+
+#define __dremieee128 __remainderieee128
+#define __gammaieee128 __lgammaieee128
+
+#    endif
+#   endif
+
+#   undef __MATHDECL_1
+#   undef __MATHDECL_ALIAS
+
+#   define __REDIRTO(function, suffix) \
+  __ ## function ## ieee128 ## suffix
+#   define __REDIRTO_ALT(function, suffix) \
+  __ ## function ## f128 ## suffix
+
+#   define __MATHDECL_1(type, function, suffix, args) \
+  __MATHREDIR (type, function, suffix, args, __REDIRTO (function, suffix))
+#   define __MATHDECL_ALIAS(type, function, suffix, args, alias) \
+  __MATHREDIR (type, function, suffix, args, __REDIRTO_ALT (alias, suffix))
 #  endif
 
 /* Include the file of declarations again, this time using `long double'
@@ -350,15 +383,22 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #  define __MATH_DECLARE_LDOUBLE   1
 #  include <bits/mathcalls-helper-functions.h>
 #  include <bits/mathcalls.h>
+
 #  undef _Mdouble_
 #  undef __MATH_PRECNAME
 #  undef __MATH_DECLARING_DOUBLE
 #  undef __MATH_DECLARING_FLOATN
 
-#  if defined __LDBL_COMPAT
+#  if defined __LDBL_COMPAT \
+      || __LONG_DOUBLE_USES_FLOAT128 == 1
+#   undef __REDIRTO
+#   undef __REDIRTO_ALT
 #   undef __MATHDECL_1
+#   undef __MATHDECL_ALIAS
 #   define __MATHDECL_1(type, function, suffix, args) \
   __MATHDECL_1_IMPL(type, function, suffix, args)
+#   define __MATHDECL_ALIAS(type, function, suffix, args, alias) \
+  __MATHDECL_1(type, function, suffix, args)
 #  endif
 # endif /* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */
 
@@ -488,6 +528,7 @@ extern long double __REDIRECT_NTH (nexttowardl,
 
 #undef	__MATHDECL_1_IMPL
 #undef	__MATHDECL_1
+#undef	__MATHDECL_ALIAS
 #undef	__MATHDECL
 #undef	__MATHCALL
 
@@ -519,6 +560,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 __LONG_DOUBLE_USES_FLOAT128 == 1
+#  define __MATHCALL_REDIR_NAME(name) __ ## f32 ## name ## ieee128
+#  undef __MATHCALL_NARROW
 #  define __MATHCALL_NARROW(func, redir, nargs) \
   __MATHCALL_NARROW_REDIR (func, redir, nargs)
 # endif
@@ -526,7 +572,8 @@ extern long double __REDIRECT_NTH (nexttowardl,
 # undef _Mret_
 # undef _Marg_
 # undef __MATHCALL_NAME
-# ifdef __LDBL_COMPAT
+# if defined __LDBL_COMPAT \
+     || __LONG_DOUBLE_USES_FLOAT128 == 1
 #  undef __MATHCALL_REDIR_NAME
 #  undef __MATHCALL_NARROW
 #  define __MATHCALL_NARROW(func, redir, nargs) \
@@ -539,6 +586,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 __LONG_DOUBLE_USES_FLOAT128 == 1
+#  define __MATHCALL_REDIR_NAME(name) __ ## f64 ## name ## ieee128
+#  undef __MATHCALL_NARROW
 #  define __MATHCALL_NARROW(func, redir, nargs) \
   __MATHCALL_NARROW_REDIR (func, redir, nargs)
 # endif
@@ -546,7 +598,8 @@ extern long double __REDIRECT_NTH (nexttowardl,
 # undef _Mret_
 # undef _Marg_
 # undef __MATHCALL_NAME
-# ifdef __LDBL_COMPAT
+# if defined __LDBL_COMPAT \
+     || __LONG_DOUBLE_USES_FLOAT128 == 1
 #  undef __MATHCALL_REDIR_NAME
 #  undef __MATHCALL_NARROW
 #  define __MATHCALL_NARROW(func, redir, nargs) \
diff --git a/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h b/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
index 6eaf8add26..70da85f2cb 100644
--- a/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
+++ b/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
@@ -23,8 +23,12 @@
 #ifdef __NO_LONG_DOUBLE_MATH
 # define iscanonical(x) ((void) (__typeof (x)) (x), 1)
 #else
+# if __LONG_DOUBLE_USES_FLOAT128 == 1
+# define __iscanonicall(x) ((void) (__typeof (x)) (x), 1)
+# else
 extern int __iscanonicall (long double __x)
      __THROW __attribute__ ((__const__));
+# endif
 # define __iscanonicalf(x) ((void) (__typeof (x)) (x), 1)
 # define __iscanonical(x) ((void) (__typeof (x)) (x), 1)
 # if __HAVE_DISTINCT_FLOAT128
@@ -50,7 +54,9 @@ 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 && __HAVE_FLOAT128_UNLIKE_LDBL
 inline int iscanonical (_Float128 __val) { return __iscanonicalf128 (__val); }
 #  endif
 }
-- 
2.21.1


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

* [PATCH 4/6] ldbl-128ibm-compat: Redirect complex math functions
  2020-02-03 21:10 [PATCH 0/6] long double to _Float128 redirecting support Paul E. Murphy
                   ` (2 preceding siblings ...)
  2020-02-03 21:10 ` [PATCH 3/6] ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions Paul E. Murphy
@ 2020-02-03 21:10 ` Paul E. Murphy
  2020-02-11 18:36   ` Tulio Magno Quites Machado Filho
  2020-02-03 21:10 ` [PATCH 5/6] ldbl-128ibm-compat: Provide ieee128 symbols to narrow functions Paul E. Murphy
  2020-02-03 21:10 ` [PATCH 6/6] Add a generic scalb implementation Paul E. Murphy
  5 siblings, 1 reply; 22+ messages in thread
From: Paul E. Murphy @ 2020-02-03 21:10 UTC (permalink / raw)
  To: libc-alpha

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.
---
 math/complex.h | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

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


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

* [PATCH 5/6] ldbl-128ibm-compat: Provide ieee128 symbols to narrow functions
  2020-02-03 21:10 [PATCH 0/6] long double to _Float128 redirecting support Paul E. Murphy
                   ` (3 preceding siblings ...)
  2020-02-03 21:10 ` [PATCH 4/6] ldbl-128ibm-compat: Redirect complex math functions Paul E. Murphy
@ 2020-02-03 21:10 ` Paul E. Murphy
  2020-02-18 22:23   ` Paul E Murphy
  2020-02-03 21:10 ` [PATCH 6/6] Add a generic scalb implementation Paul E. Murphy
  5 siblings, 1 reply; 22+ messages in thread
From: Paul E. Murphy @ 2020-02-03 21:10 UTC (permalink / raw)
  To: libc-alpha

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

Move the narrow math aliasing macros into a new sysdep header file
math-narrow-alias-float128.h.  Then, provide an override header
to supply the necessary changes to supply the *ieee128 aliases of
these symbols.

This adds ieee128 aliases for faddl, fdivl, fmull, fsubl, daddl, ddivl,
dmull, dsubl.
---
 math/math-narrow.h                            | 15 +-------
 sysdeps/generic/math-narrow-alias-float128.h  | 32 +++++++++++++++++
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  8 +++++
 .../math-narrow-alias-float128.h              | 34 +++++++++++++++++++
 4 files changed, 75 insertions(+), 14 deletions(-)
 create mode 100644 sysdeps/generic/math-narrow-alias-float128.h
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/math-narrow-alias-float128.h

diff --git a/math/math-narrow.h b/math/math-narrow.h
index ec22913710..d8092c287e 100644
--- a/math/math-narrow.h
+++ b/math/math-narrow.h
@@ -352,19 +352,6 @@
   weak_alias (__f64 ## func ## f128, f64 ## func ## f128)	\
   weak_alias (__f64 ## func ## f128, f32x ## func ## f128)
 
-#if __HAVE_FLOAT64X_LONG_DOUBLE
-# define libm_alias_float32_float128(func)	\
-  libm_alias_float32_float128_main (func)
-# define libm_alias_float64_float128(func)	\
-  libm_alias_float64_float128_main (func)
-#else
-# define libm_alias_float32_float128(func)			\
-  libm_alias_float32_float128_main (func)			\
-  weak_alias (__f32 ## func ## f128, f32 ## func ## f64x)
-# define libm_alias_float64_float128(func)			\
-  libm_alias_float64_float128_main (func)			\
-  weak_alias (__f64 ## func ## f128, f64 ## func ## f64x)	\
-  weak_alias (__f64 ## func ## f128, f32x ## func ## f64x)
-#endif
+#include <math-narrow-alias-float128.h>
 
 #endif /* math-narrow.h.  */
diff --git a/sysdeps/generic/math-narrow-alias-float128.h b/sysdeps/generic/math-narrow-alias-float128.h
new file mode 100644
index 0000000000..4788708c78
--- /dev/null
+++ b/sysdeps/generic/math-narrow-alias-float128.h
@@ -0,0 +1,32 @@
+/* Helper macros for functions returning a narrower type.  F128-specific.
+   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/>.  */
+
+#if __HAVE_FLOAT64X_LONG_DOUBLE
+# define libm_alias_float32_float128(func)	\
+  libm_alias_float32_float128_main (func)
+# define libm_alias_float64_float128(func)	\
+  libm_alias_float64_float128_main (func)
+#else
+# define libm_alias_float32_float128(func)			\
+  libm_alias_float32_float128_main (func)			\
+  weak_alias (__f32 ## func ## f128, f32 ## func ## f64x)
+# define libm_alias_float64_float128(func)			\
+  libm_alias_float64_float128_main (func)			\
+  weak_alias (__f64 ## func ## f128, f64 ## func ## f64x)	\
+  weak_alias (__f64 ## func ## f128, f32x ## func ## f64x)
+#endif
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index b4609c99f7..83a0a36e62 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -47,6 +47,14 @@ libm {
     __exp2ieee128;
     __expieee128;
     __expm1ieee128;
+    __f32addieee128;
+    __f32divieee128;
+    __f32mulieee128;
+    __f32subieee128;
+    __f64addieee128;
+    __f64divieee128;
+    __f64mulieee128;
+    __f64subieee128;
     __fabsieee128;
     __fdimieee128;
     __floorieee128;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/math-narrow-alias-float128.h b/sysdeps/ieee754/ldbl-128ibm-compat/math-narrow-alias-float128.h
new file mode 100644
index 0000000000..5353b539d7
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/math-narrow-alias-float128.h
@@ -0,0 +1,34 @@
+/* Helper macros for functions returning a narrower type.  F128-specific.
+   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/>.  */
+
+#if __HAVE_FLOAT64X_LONG_DOUBLE
+# define libm_alias_float32_float128(func)	\
+  libm_alias_float32_float128_main (func)
+# define libm_alias_float64_float128(func)	\
+  libm_alias_float64_float128_main (func)
+#else
+# define libm_alias_float32_float128(func)				\
+  libm_alias_float32_float128_main (func)				\
+  weak_alias (__f32 ## func ## f128, f32 ## func ## f64x)		\
+  weak_alias (__f32 ## func ## f128, __ ## f32 ## func ## ieee128)
+# define libm_alias_float64_float128(func)				\
+  libm_alias_float64_float128_main (func)				\
+  weak_alias (__f64 ## func ## f128, f64 ## func ## f64x)		\
+  weak_alias (__f64 ## func ## f128, f32x ## func ## f64x)		\
+  weak_alias (__f64 ## func ## f128, __ ## f64 ## func ## ieee128)
+#endif
-- 
2.21.1


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

* [PATCH 6/6] Add a generic scalb implementation
  2020-02-03 21:10 [PATCH 0/6] long double to _Float128 redirecting support Paul E. Murphy
                   ` (4 preceding siblings ...)
  2020-02-03 21:10 ` [PATCH 5/6] ldbl-128ibm-compat: Provide ieee128 symbols to narrow functions Paul E. Murphy
@ 2020-02-03 21:10 ` Paul E. Murphy
  2020-02-11 20:20   ` Paul E Murphy
  5 siblings, 1 reply; 22+ messages in thread
From: Paul E. Murphy @ 2020-02-03 21:10 UTC (permalink / raw)
  To: libc-alpha

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

Create templates for e_scabl and w_scalb.
---
 math/Makefile                              |  7 +--
 math/{e_scalb.c => e_scalb_template.c}     | 33 ++++++------
 math/e_scalbf.c                            | 54 --------------------
 math/e_scalbl.c                            | 54 --------------------
 math/w_scalb_compat.c                      |  6 +--
 math/w_scalb_template.c                    | 59 ++++++++++++++++++++++
 math/w_scalbf_compat.c                     |  4 +-
 math/w_scalbl_compat.c                     |  4 +-
 sysdeps/ieee754/float128/w_scalbf128.c     |  1 +
 sysdeps/ieee754/ldbl-opt/w_scalb_compat.c  |  4 +-
 sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c |  2 +
 11 files changed, 91 insertions(+), 137 deletions(-)
 rename math/{e_scalb.c => e_scalb_template.c} (64%)
 delete mode 100644 math/e_scalbf.c
 delete mode 100644 math/e_scalbl.c
 create mode 100644 math/w_scalb_template.c
 create mode 100644 sysdeps/ieee754/float128/w_scalbf128.c

diff --git a/math/Makefile b/math/Makefile
index 5985b6744b..1d203e7ad5 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -48,7 +48,7 @@ libm-support = s_lib_version s_matherr s_signgam			\
 
 # Wrappers for these functions generated per type using a file named
 # <func>_template.c and the appropriate math-type-macros-<TYPE>.h.
-gen-libm-calls = cargF conjF cimagF crealF cabsF s_cacosF		  \
+gen-libm-calls = cargF conjF cimagF crealF cabsF e_scalbF s_cacosF	  \
 	         s_cacoshF s_ccosF s_ccoshF s_casinF s_csinF s_casinhF	  \
 		 k_casinhF s_csinhF k_casinhF s_csinhF s_catanhF s_catanF \
 		 s_ctanF s_ctanhF s_cexpF s_clogF s_cprojF s_csqrtF	  \
@@ -58,13 +58,14 @@ gen-libm-calls = cargF conjF cimagF crealF cabsF s_cacosF		  \
 		 w_log1pF w_scalblnF s_fmaxmagF s_fminmagF w_acosF	  \
 		 w_acoshF w_asinF w_atan2F w_atanhF w_coshF w_exp10F	  \
 		 w_exp2F w_fmodF w_hypotF w_j0F w_j1F w_jnF w_logF	  \
-		 w_log10F w_log2F w_powF w_remainderF w_sinhF w_sqrtF	  \
+		 w_log10F w_log2F w_powF w_remainderF w_scalbF		  \
+		 w_sinhF w_sqrtF					  \
 		 w_tgammaF w_lgammaF w_lgammaF_r w_expF e_exp2F
 
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
 	e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF	  \
-	e_remainderF e_scalbF e_sinhF e_sqrtF e_gammaF_r	  \
+	e_remainderF e_sinhF e_sqrtF e_gammaF_r				  \
 	e_ilogbF							  \
 	k_tanF s_asinhF s_atanF s_cbrtF					  \
 	s_ceilF s_cosF s_erfF s_expm1F s_fabsF				  \
diff --git a/math/e_scalb.c b/math/e_scalb_template.c
similarity index 64%
rename from math/e_scalb.c
rename to math/e_scalb_template.c
index dbe3b51d6a..ed0508c7bf 100644
--- a/math/e_scalb.c
+++ b/math/e_scalb_template.c
@@ -1,6 +1,8 @@
-/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
+/* Multiply by integral power of radix.
+
+   Copyright (C) 2011-2020 Free Software Foundation, Inc.
+
    This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -20,35 +22,36 @@
 #include <math_private.h>
 #include <libm-alias-finite.h>
 
-static double
+static FLOAT
 __attribute__ ((noinline))
-invalid_fn (double x, double fn)
+invalid_fn (FLOAT x, FLOAT fn)
 {
-  if (rint (fn) != fn)
+  if (M_SUF (rint) (fn) != fn)
     return (fn - fn) / (fn - fn);
-  else if (fn > 65000.0)
-    return __scalbn (x, 65000);
+  else if (fn > M_LIT (65000.0))
+    return M_SUF (__scalbn) (x, 65000);
   else
-    return __scalbn (x,-65000);
+    return M_SUF (__scalbn) (x,-65000);
 }
 
 
-double
-__ieee754_scalb (double x, double fn)
+FLOAT
+M_DECL_FUNC (__ieee754_scalb) (FLOAT x, FLOAT fn)
 {
   if (__glibc_unlikely (isnan (x)))
     return x * fn;
   if (__glibc_unlikely (!isfinite (fn)))
     {
-      if (isnan (fn) || fn > 0.0)
+      if (isnan (fn) || fn > M_LIT (0.0))
 	return x * fn;
-      if (x == 0.0)
+      if (x == M_LIT (0.0))
 	return x;
       return x / -fn;
     }
-  if (__glibc_unlikely (fabs (fn) >= 0x1p31 || (double) (int) fn != fn))
+  if (__glibc_unlikely (M_FABS (fn) >= M_LIT (0x1p31)
+			|| (FLOAT) (int) fn != fn))
     return invalid_fn (x, fn);
 
-  return __scalbn (x, (int) fn);
+  return M_SCALBN (x, (int) fn);
 }
-libm_alias_finite (__ieee754_scalb, __scalb)
+declare_mgen_finite_alias (__ieee754_scalb, __scalb)
diff --git a/math/e_scalbf.c b/math/e_scalbf.c
deleted file mode 100644
index 944cfbefc9..0000000000
--- a/math/e_scalbf.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-#include <math_private.h>
-#include <libm-alias-finite.h>
-
-static float
-__attribute__ ((noinline))
-invalid_fn (float x, float fn)
-{
-  if (rintf (fn) != fn)
-    return (fn - fn) / (fn - fn);
-  else if (fn > 65000.0f)
-    return __scalbnf (x, 65000);
-  else
-    return __scalbnf (x,-65000);
-}
-
-
-float
-__ieee754_scalbf (float x, float fn)
-{
-  if (__glibc_unlikely (isnan (x)))
-    return x * fn;
-  if (__glibc_unlikely (!isfinite (fn)))
-    {
-      if (isnan (fn) || fn > 0.0f)
-	return x * fn;
-      if (x == 0.0f)
-	return x;
-      return x / -fn;
-    }
-  if (__glibc_unlikely (fabsf (fn) >= 0x1p31f || (float) (int) fn != fn))
-    return invalid_fn (x, fn);
-
-  return __scalbnf (x, (int) fn);
-}
-libm_alias_finite (__ieee754_scalbf, __scalbf)
diff --git a/math/e_scalbl.c b/math/e_scalbl.c
deleted file mode 100644
index 6595ec6c27..0000000000
--- a/math/e_scalbl.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-#include <math_private.h>
-#include <libm-alias-finite.h>
-
-static long double
-__attribute__ ((noinline))
-invalid_fn (long double x, long double fn)
-{
-  if (rintl (fn) != fn)
-    return (fn - fn) / (fn - fn);
-  else if (fn > 65000.0L)
-    return __scalbnl (x, 65000);
-  else
-    return __scalbnl (x,-65000);
-}
-
-
-long double
-__ieee754_scalbl (long double x, long double fn)
-{
-  if (__glibc_unlikely (isnan (x)))
-    return x * fn;
-  if (__glibc_unlikely (!isfinite (fn)))
-    {
-      if (isnan (fn) || fn > 0.0L)
-	return x * fn;
-      if (x == 0.0L)
-	return x;
-      return x / -fn;
-    }
-  if (__glibc_unlikely (fabsl (fn) >= 0x1p31L || (long double) (int) fn != fn))
-    return invalid_fn (x, fn);
-
-  return __scalbnl (x, (int) fn);
-}
-libm_alias_finite (__ieee754_scalbl, __scalbl)
diff --git a/math/w_scalb_compat.c b/math/w_scalb_compat.c
index c3dd3db4f7..664c0474a7 100644
--- a/math/w_scalb_compat.c
+++ b/math/w_scalb_compat.c
@@ -41,18 +41,15 @@ sysv_scalb (double x, double fn)
 
   return z;
 }
-#endif
 
 
 /* Wrapper scalb */
 double
 __scalb (double x, double fn)
 {
-#if LIBM_SVID_COMPAT
   if (__glibc_unlikely (_LIB_VERSION == _SVID_))
     return sysv_scalb (x, fn);
   else
-#endif
     {
       double z = __ieee754_scalb (x, fn);
 
@@ -79,7 +76,8 @@ __scalb (double x, double fn)
     }
 }
 weak_alias (__scalb, scalb)
-#ifdef NO_LONG_DOUBLE
+# ifdef NO_LONG_DOUBLE
 strong_alias (__scalb, __scalbl)
 weak_alias (__scalb, scalbl)
+# endif
 #endif
diff --git a/math/w_scalb_template.c b/math/w_scalb_template.c
new file mode 100644
index 0000000000..b2aafcdf36
--- /dev/null
+++ b/math/w_scalb_template.c
@@ -0,0 +1,59 @@
+/* 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>
+
+/* Wrapper scalb */
+FLOAT
+M_DECL_FUNC (__scalb) (FLOAT x, FLOAT fn)
+{
+    {
+      FLOAT z = M_SUF (__ieee754_scalb) (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/math/w_scalbf_compat.c b/math/w_scalbf_compat.c
index 42bba44cc6..1b742e9b98 100644
--- a/math/w_scalbf_compat.c
+++ b/math/w_scalbf_compat.c
@@ -41,18 +41,15 @@ sysv_scalbf (float x, float fn)
 
   return z;
 }
-#endif
 
 
 /* Wrapper scalbf */
 float
 __scalbf (float x, float fn)
 {
-#if LIBM_SVID_COMPAT
   if (__glibc_unlikely (_LIB_VERSION == _SVID_))
     return sysv_scalbf (x, fn);
   else
-#endif
     {
       float z = __ieee754_scalbf (x, fn);
 
@@ -79,3 +76,4 @@ __scalbf (float x, float fn)
     }
 }
 weak_alias (__scalbf, scalbf)
+#endif
diff --git a/math/w_scalbl_compat.c b/math/w_scalbl_compat.c
index 8858c6b66d..c8ba3fddb4 100644
--- a/math/w_scalbl_compat.c
+++ b/math/w_scalbl_compat.c
@@ -41,18 +41,15 @@ sysv_scalbl (long double x, long double fn)
 
   return z;
 }
-#endif
 
 
 /* Wrapper scalbl */
 long double
 __scalbl (long double x, long double fn)
 {
-#if LIBM_SVID_COMPAT
   if (__glibc_unlikely (_LIB_VERSION == _SVID_))
     return sysv_scalbl (x, fn);
   else
-#endif
     {
       long double z = __ieee754_scalbl (x, fn);
 
@@ -79,3 +76,4 @@ __scalbl (long double x, long double fn)
     }
 }
 weak_alias (__scalbl, scalbl)
+#endif
diff --git a/sysdeps/ieee754/float128/w_scalbf128.c b/sysdeps/ieee754/float128/w_scalbf128.c
new file mode 100644
index 0000000000..067b724164
--- /dev/null
+++ b/sysdeps/ieee754/float128/w_scalbf128.c
@@ -0,0 +1 @@
+/* Not defined for _FloatN types.  */
diff --git a/sysdeps/ieee754/ldbl-opt/w_scalb_compat.c b/sysdeps/ieee754/ldbl-opt/w_scalb_compat.c
index f6d53a5ba5..56735e825e 100644
--- a/sysdeps/ieee754/ldbl-opt/w_scalb_compat.c
+++ b/sysdeps/ieee754/ldbl-opt/w_scalb_compat.c
@@ -1,5 +1,7 @@
 #include <math_ldbl_opt.h>
 #include <math/w_scalb_compat.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
+#if LIBM_SVID_COMPAT
+# if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
 compat_symbol (libm, __scalb, scalbl, GLIBC_2_0);
+# endif
 #endif
diff --git a/sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c b/sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c
index c8feb654a2..4d16f413c4 100644
--- a/sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c
+++ b/sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c
@@ -2,4 +2,6 @@
 #undef weak_alias
 #define weak_alias(n,a)
 #include <math/w_scalbl_compat.c>
+#if LIBM_SVID_COMPAT
 long_double_symbol (libm, __scalbl, scalbl);
+#endif
-- 
2.21.1


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

* Re: [PATCH 1/6] Prepare redirections for IEEE long double on powerpc64le
  2020-02-03 21:10 ` [PATCH 1/6] Prepare redirections for IEEE long double on powerpc64le Paul E. Murphy
@ 2020-02-10 21:32   ` Paul E Murphy
  2020-02-17 14:34     ` Paul E Murphy
  2020-02-11 18:25   ` Tulio Magno Quites Machado Filho
  1 sibling, 1 reply; 22+ messages in thread
From: Paul E Murphy @ 2020-02-10 21:32 UTC (permalink / raw)
  To: libc-alpha

Ping? If no objections I would like to commit this next Monday.

I was under the incorrect assumption this patch had been sent out
in December as-is.  This is the continuation of 
https://sourceware.org/ml/libc-alpha/2019-12/msg00515.html based on my 
feedback from https://sourceware.org/ml/libc-alpha/2019-12/msg00521.html .

On 2/3/20 3:10 PM, Paul E. Murphy wrote:
> From: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
> 
> New since v4.
> 
>    - Thanks, Paul, for the suggestion to split it from the last patch.
> 
> -- 8< --
> All functions that have a format string, which can consume a long double
> argument, must have one version for each long double format supported on
> a platform.  On powerpc64le, these functions currently have two versions
> (i.e.: long double with the same format as double, and long double with
> IBM Extended Precision format).  Support for a third long double format
> option (i.e. long double with IEEE long double format) is being prepared
> and all the aforementioned functions now have a third version (not yet
> exported on the master branch, but the code is in).
> 
> For these functions to get selected (during build time), references to
> them in user programs (or dependent libraries) must get redirected to
> the aforementioned new versions of the functions.  This patch installs
> the header magic required to perform such redirections.
> 
> Notice, however, that since the redirections only happen when
> __LONG_DOUBLE_USES_FLOAT128 is set to 1, and no platform (including
> powerpc64le) currently does it, no redirections actually happen.
> Redirections and the exporting of the new functions will happen at the
> same time (when powerpc64le adds ldbl-128ibm-compat to their Implies.
> ---
>   argp/argp.h               |  3 ++-
>   libio/bits/stdio-ldbl.h   | 46 ++++++++++++++++++++++++++-------------
>   libio/stdio.h             | 16 +++++++++-----
>   misc/bits/syslog-ldbl.h   |  4 ++--
>   misc/err.h                |  3 ++-
>   misc/error.h              |  6 +++--
>   misc/sys/cdefs.h          | 38 ++++++++++++++++++++++++++++++--
>   misc/sys/syslog.h         |  4 +++-
>   stdio-common/printf.h     |  3 ++-
>   stdlib/bits/stdlib-ldbl.h | 22 +++++++++++++++++++
>   stdlib/monetary.h         |  3 ++-
>   stdlib/stdlib.h           |  4 +++-
>   wcsmbs/bits/wchar-ldbl.h  | 36 +++++++++++++++++++++++++-----
>   wcsmbs/wchar.h            | 14 +++++++-----
>   14 files changed, 159 insertions(+), 43 deletions(-)
> 
> diff --git a/argp/argp.h b/argp/argp.h
> index 329aae097f..358d9b43cd 100644
> --- a/argp/argp.h
> +++ b/argp/argp.h
> @@ -554,7 +554,8 @@ __NTH (__option_is_end (const struct argp_option *__opt))
>   # endif
>   #endif /* Use extern inlines.  */
> 
> -#ifdef __LDBL_COMPAT
> +#include <bits/floatn.h>
> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>   # include <bits/argp-ldbl.h>
>   #endif
> 
> diff --git a/libio/bits/stdio-ldbl.h b/libio/bits/stdio-ldbl.h
> index 6626412fce..3bb9f7dd2c 100644
> --- a/libio/bits/stdio-ldbl.h
> +++ b/libio/bits/stdio-ldbl.h
> @@ -27,9 +27,17 @@ __LDBL_REDIR_DECL (vfprintf)
>   __LDBL_REDIR_DECL (vprintf)
>   __LDBL_REDIR_DECL (vsprintf)
>   #if !__GLIBC_USE (DEPRECATED_SCANF)
> +# if defined __LDBL_COMPAT
>   __LDBL_REDIR1_DECL (fscanf, __nldbl___isoc99_fscanf)
>   __LDBL_REDIR1_DECL (scanf, __nldbl___isoc99_scanf)
>   __LDBL_REDIR1_DECL (sscanf, __nldbl___isoc99_sscanf)
> +# elif __LONG_DOUBLE_USES_FLOAT128 == 1
> +__LDBL_REDIR1_DECL (fscanf, __isoc99_fscanfieee128)
> +__LDBL_REDIR1_DECL (scanf, __isoc99_scanfieee128)
> +__LDBL_REDIR1_DECL (sscanf, __isoc99_sscanfieee128)
> +# else
> +#  error bits/stdlib-ldbl.h included when no ldbl redirections are required.
> +# endif
>   #else
>   __LDBL_REDIR_DECL (fscanf)
>   __LDBL_REDIR_DECL (scanf)
> @@ -43,9 +51,17 @@ __LDBL_REDIR_DECL (vsnprintf)
> 
>   #ifdef	__USE_ISOC99
>   # if !__GLIBC_USE (DEPRECATED_SCANF)
> +#  if defined __LDBL_COMPAT
>   __LDBL_REDIR1_DECL (vfscanf, __nldbl___isoc99_vfscanf)
>   __LDBL_REDIR1_DECL (vscanf, __nldbl___isoc99_vscanf)
>   __LDBL_REDIR1_DECL (vsscanf, __nldbl___isoc99_vsscanf)
> +#  elif __LONG_DOUBLE_USES_FLOAT128 == 1
> +__LDBL_REDIR1_DECL (vfscanf, __isoc99_vfscanfieee128)
> +__LDBL_REDIR1_DECL (vscanf, __isoc99_vscanfieee128)
> +__LDBL_REDIR1_DECL (vsscanf, __isoc99_vsscanfieee128)
> +#  else
> +#   error bits/stdlib-ldbl.h included when no ldbl redirections are required.
> +#  endif
>   # else
>   __LDBL_REDIR_DECL (vfscanf)
>   __LDBL_REDIR_DECL (vsscanf)
> @@ -60,33 +76,33 @@ __LDBL_REDIR_DECL (dprintf)
> 
>   #ifdef __USE_GNU
>   __LDBL_REDIR_DECL (vasprintf)
> -__LDBL_REDIR_DECL (__asprintf)
> +__LDBL_REDIR2_DECL (asprintf)
>   __LDBL_REDIR_DECL (asprintf)
>   __LDBL_REDIR_DECL (obstack_printf)
>   __LDBL_REDIR_DECL (obstack_vprintf)
>   #endif
> 
>   #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
> -__LDBL_REDIR_DECL (__sprintf_chk)
> -__LDBL_REDIR_DECL (__vsprintf_chk)
> +__LDBL_REDIR2_DECL (sprintf_chk)
> +__LDBL_REDIR2_DECL (vsprintf_chk)
>   # if defined __USE_ISOC99 || defined __USE_UNIX98
> -__LDBL_REDIR_DECL (__snprintf_chk)
> -__LDBL_REDIR_DECL (__vsnprintf_chk)
> +__LDBL_REDIR2_DECL (snprintf_chk)
> +__LDBL_REDIR2_DECL (vsnprintf_chk)
>   # endif
>   # if __USE_FORTIFY_LEVEL > 1
> -__LDBL_REDIR_DECL (__fprintf_chk)
> -__LDBL_REDIR_DECL (__printf_chk)
> -__LDBL_REDIR_DECL (__vfprintf_chk)
> -__LDBL_REDIR_DECL (__vprintf_chk)
> +__LDBL_REDIR2_DECL (fprintf_chk)
> +__LDBL_REDIR2_DECL (printf_chk)
> +__LDBL_REDIR2_DECL (vfprintf_chk)
> +__LDBL_REDIR2_DECL (vprintf_chk)
>   #  ifdef __USE_XOPEN2K8
> -__LDBL_REDIR_DECL (__dprintf_chk)
> -__LDBL_REDIR_DECL (__vdprintf_chk)
> +__LDBL_REDIR2_DECL (dprintf_chk)
> +__LDBL_REDIR2_DECL (vdprintf_chk)
>   #  endif
>   #  ifdef __USE_GNU
> -__LDBL_REDIR_DECL (__asprintf_chk)
> -__LDBL_REDIR_DECL (__vasprintf_chk)
> -__LDBL_REDIR_DECL (__obstack_printf_chk)
> -__LDBL_REDIR_DECL (__obstack_vprintf_chk)
> +__LDBL_REDIR2_DECL (asprintf_chk)
> +__LDBL_REDIR2_DECL (vasprintf_chk)
> +__LDBL_REDIR2_DECL (obstack_printf_chk)
> +__LDBL_REDIR2_DECL (obstack_vprintf_chk)
>   #  endif
>   # endif
>   #endif
> diff --git a/libio/stdio.h b/libio/stdio.h
> index 5a10a4d3ee..18e29752c4 100644
> --- a/libio/stdio.h
> +++ b/libio/stdio.h
> @@ -400,9 +400,12 @@ extern int sscanf (const char *__restrict __s,
>   		   const char *__restrict __format, ...) __THROW;
> 
>   /* For historical reasons, the C99-compliant versions of the scanf
> -   functions are at alternative names.  When __LDBL_COMPAT is in
> -   effect, this is handled in bits/stdio-ldbl.h.  */
> -#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT
> +   functions are at alternative names.  When __LDBL_COMPAT or
> +   __LONG_DOUBLE_USES_FLOAT128 are in effect, this is handled in
> +   bits/stdio-ldbl.h.  */
> +#include <bits/floatn.h>
> +#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
> +    && __LONG_DOUBLE_USES_FLOAT128 == 0
>   # ifdef __REDIRECT
>   extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
>   				const char *__restrict __format, ...),
> @@ -447,7 +450,8 @@ extern int vsscanf (const char *__restrict __s,
> 
>   /* Same redirection as above for the v*scanf family.  */
>   # if !__GLIBC_USE (DEPRECATED_SCANF)
> -#  if defined __REDIRECT && !defined __LDBL_COMPAT
> +#  if defined __REDIRECT && !defined __LDBL_COMPAT \
> +      && __LONG_DOUBLE_USES_FLOAT128 == 0
>   extern int __REDIRECT (vfscanf,
>   		       (FILE *__restrict __s,
>   			const char *__restrict __format, __gnuc_va_list __arg),
> @@ -866,7 +870,9 @@ extern int __overflow (FILE *, int);
>   #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
>   # include <bits/stdio2.h>
>   #endif
> -#ifdef __LDBL_COMPAT
> +
> +#include <bits/floatn.h>
> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>   # include <bits/stdio-ldbl.h>
>   #endif
> 
> diff --git a/misc/bits/syslog-ldbl.h b/misc/bits/syslog-ldbl.h
> index fead0d4648..657b192b9b 100644
> --- a/misc/bits/syslog-ldbl.h
> +++ b/misc/bits/syslog-ldbl.h
> @@ -27,9 +27,9 @@ __LDBL_REDIR_DECL (vsyslog)
>   #endif
> 
>   #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
> -__LDBL_REDIR_DECL (__syslog_chk)
> +__LDBL_REDIR2_DECL (syslog_chk)
> 
>   # ifdef __USE_MISC
> -__LDBL_REDIR_DECL (__vsyslog_chk)
> +__LDBL_REDIR2_DECL (vsyslog_chk)
>   # endif
>   #endif
> diff --git a/misc/err.h b/misc/err.h
> index f6fd72945f..d146a55054 100644
> --- a/misc/err.h
> +++ b/misc/err.h
> @@ -52,7 +52,8 @@ extern void errx (int __status, const char *__format, ...)
>   extern void verrx (int __status, const char *, __gnuc_va_list)
>        __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0)));
> 
> -#ifdef __LDBL_COMPAT
> +#include <bits/floatn.h>
> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>   # include <bits/err-ldbl.h>
>   #endif
> 
> diff --git a/misc/error.h b/misc/error.h
> index a456695f1a..bb8a3b26a4 100644
> --- a/misc/error.h
> +++ b/misc/error.h
> @@ -47,11 +47,13 @@ extern unsigned int error_message_count;
>      variable controls whether this mode is selected or not.  */
>   extern int error_one_per_line;
> 
> -#ifdef __LDBL_COMPAT
> +#include <bits/floatn.h>
> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>   # include <bits/error-ldbl.h>
>   #else
>   /* Do not inline error and error_at_line when long double has the same
> -   size of double, because that would invalidate the redirections to the
> +   size of double, nor when long double reuses the float128
> +   implementation, because that would invalidate the redirections to the
>      compatibility functions.  */
>   # if defined __extern_always_inline && defined __va_arg_pack
>   #  include <bits/error.h>
> diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
> index ff7144f3f3..dd5f69f833 100644
> --- a/misc/sys/cdefs.h
> +++ b/misc/sys/cdefs.h
> @@ -452,7 +452,37 @@
>   #include <bits/wordsize.h>
>   #include <bits/long-double.h>
> 
> -#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
> +#if __LONG_DOUBLE_USES_FLOAT128 == 1
> +# ifdef __REDIRECT
> +
> +/* Alias name defined automatically.  */
> +#  define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
> +#  define __LDBL_REDIR_DECL(name) \
> +  extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
> +
> +/* Alias name defined automatically, with leading underscores.  */
> +#  define __LDBL_REDIR2_DECL(name) \
> +  extern __typeof (__##name) __##name \
> +    __asm (__ASMNAME ("__" #name "ieee128"));
> +
> +/* Alias name defined manually.  */
> +#  define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
> +#  define __LDBL_REDIR1_DECL(name, alias) \
> +  extern __typeof (name) name __asm (__ASMNAME (#alias));
> +
> +#  define __LDBL_REDIR1_NTH(name, proto, alias) \
> +  __REDIRECT_NTH (name, proto, alias)
> +#  define __REDIRECT_NTH_LDBL(name, proto, alias) \
> +  __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
> +
> +/* Unused.  */
> +#  define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
> +#  define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
> +
> +# else
> +_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
> +# endif
> +#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
>   # define __LDBL_COMPAT 1
>   # ifdef __REDIRECT
>   #  define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
> @@ -461,6 +491,8 @@
>   #  define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
>   #  define __LDBL_REDIR_NTH(name, proto) \
>     __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
> +#  define __LDBL_REDIR2_DECL(name) \
> +  extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
>   #  define __LDBL_REDIR1_DECL(name, alias) \
>     extern __typeof (name) name __asm (__ASMNAME (#alias));
>   #  define __LDBL_REDIR_DECL(name) \
> @@ -471,11 +503,13 @@
>     __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
>   # endif
>   #endif
> -#if !defined __LDBL_COMPAT || !defined __REDIRECT
> +#if (!defined __LDBL_COMPAT && __LONG_DOUBLE_USES_FLOAT128 == 0) \
> +    || !defined __REDIRECT
>   # define __LDBL_REDIR1(name, proto, alias) name proto
>   # define __LDBL_REDIR(name, proto) name proto
>   # define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
>   # define __LDBL_REDIR_NTH(name, proto) name proto __THROW
> +# define __LDBL_REDIR2_DECL(name)
>   # define __LDBL_REDIR_DECL(name)
>   # ifdef __REDIRECT
>   #  define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
> diff --git a/misc/sys/syslog.h b/misc/sys/syslog.h
> index ee01478c4b..c000b8e915 100644
> --- a/misc/sys/syslog.h
> +++ b/misc/sys/syslog.h
> @@ -206,7 +206,9 @@ extern void vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap)
>   #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
>   # include <bits/syslog.h>
>   #endif
> -#ifdef __LDBL_COMPAT
> +
> +#include <bits/floatn.h>
> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>   # include <bits/syslog-ldbl.h>
>   #endif
> 
> diff --git a/stdio-common/printf.h b/stdio-common/printf.h
> index ad3c8a4254..00bedebfdb 100644
> --- a/stdio-common/printf.h
> +++ b/stdio-common/printf.h
> @@ -182,7 +182,8 @@ extern int printf_size_info (const struct printf_info *__restrict
>   			     __info, size_t __n, int *__restrict __argtypes)
>        __THROW;
> 
> -#ifdef __LDBL_COMPAT
> +#include <bits/floatn.h>
> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>   # include <bits/printf-ldbl.h>
>   #endif
> 
> diff --git a/stdlib/bits/stdlib-ldbl.h b/stdlib/bits/stdlib-ldbl.h
> index 5c6294ed9b..2469474532 100644
> --- a/stdlib/bits/stdlib-ldbl.h
> +++ b/stdlib/bits/stdlib-ldbl.h
> @@ -21,21 +21,43 @@
>   #endif
> 
>   #ifdef	__USE_ISOC99
> +# ifdef __LDBL_COMPAT
>   __LDBL_REDIR1_DECL (strtold, strtod)
> +# else
> +__LDBL_REDIR1_DECL (strtold, __strtoieee128)
> +# endif
>   #endif
> 
>   #ifdef __USE_GNU
> +# ifdef __LDBL_COMPAT
>   __LDBL_REDIR1_DECL (strtold_l, strtod_l)
> +# else
> +__LDBL_REDIR1_DECL (strtold_l, __strtoieee128_l)
> +# endif
>   #endif
> 
>   #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
> +# ifdef __LDBL_COMPAT
>   __LDBL_REDIR1_DECL (strfroml, strfromd)
> +# else
> +__LDBL_REDIR1_DECL (strfroml, __strfromieee128)
> +# endif
>   #endif
> 
>   #ifdef __USE_MISC
> +# if defined __LDBL_COMPAT
>   __LDBL_REDIR1_DECL (qecvt, ecvt)
>   __LDBL_REDIR1_DECL (qfcvt, fcvt)
>   __LDBL_REDIR1_DECL (qgcvt, gcvt)
>   __LDBL_REDIR1_DECL (qecvt_r, ecvt_r)
>   __LDBL_REDIR1_DECL (qfcvt_r, fcvt_r)
> +# elif __LONG_DOUBLE_USES_FLOAT128 == 1
> +__LDBL_REDIR1_DECL (qecvt, __qecvtieee128)
> +__LDBL_REDIR1_DECL (qfcvt, __qfcvtieee128)
> +__LDBL_REDIR1_DECL (qgcvt, __qgcvtieee128)
> +__LDBL_REDIR1_DECL (qecvt_r, __qecvtieee128_r)
> +__LDBL_REDIR1_DECL (qfcvt_r, __qfcvtieee128_r)
> +# else
> +#  error bits/stdlib-ldbl.h included when no ldbl redirections are required.
> +# endif
>   #endif
> diff --git a/stdlib/monetary.h b/stdlib/monetary.h
> index dfb6ed5c0c..4a6d61fd2d 100644
> --- a/stdlib/monetary.h
> +++ b/stdlib/monetary.h
> @@ -50,7 +50,8 @@ extern ssize_t strfmon_l (char *__restrict __s, size_t __maxsize,
>        __THROW __attribute_format_strfmon__ (4, 5);
>   #endif
> 
> -#ifdef __LDBL_COMPAT
> +#include <bits/floatn.h>
> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>   # include <bits/monetary-ldbl.h>
>   #endif
> 
> diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
> index e3470631e1..a7c0c71a80 100644
> --- a/stdlib/stdlib.h
> +++ b/stdlib/stdlib.h
> @@ -1016,7 +1016,9 @@ extern int ttyslot (void) __THROW;
>   #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
>   # include <bits/stdlib.h>
>   #endif
> -#ifdef __LDBL_COMPAT
> +
> +#include <bits/floatn.h>
> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>   # include <bits/stdlib-ldbl.h>
>   #endif
> 
> diff --git a/wcsmbs/bits/wchar-ldbl.h b/wcsmbs/bits/wchar-ldbl.h
> index fc50ee26de..75d547f680 100644
> --- a/wcsmbs/bits/wchar-ldbl.h
> +++ b/wcsmbs/bits/wchar-ldbl.h
> @@ -28,9 +28,17 @@ __LDBL_REDIR_DECL (vfwprintf);
>   __LDBL_REDIR_DECL (vwprintf);
>   __LDBL_REDIR_DECL (vswprintf);
>   # if !__GLIBC_USE (DEPRECATED_SCANF)
> +#  if defined __LDBL_COMPAT
>   __LDBL_REDIR1_DECL (fwscanf, __nldbl___isoc99_fwscanf)
>   __LDBL_REDIR1_DECL (wscanf, __nldbl___isoc99_wscanf)
>   __LDBL_REDIR1_DECL (swscanf, __nldbl___isoc99_swscanf)
> +#  elif __LONG_DOUBLE_USES_FLOAT128 == 1
> +__LDBL_REDIR1_DECL (fwscanf, __isoc99_fwscanfieee128)
> +__LDBL_REDIR1_DECL (wscanf, __isoc99_wscanfieee128)
> +__LDBL_REDIR1_DECL (swscanf, __isoc99_swscanfieee128)
> +#  else
> +#   error bits/stdlib-ldbl.h included when no ldbl redirections are required.
> +#  endif
>   # else
>   __LDBL_REDIR_DECL (fwscanf);
>   __LDBL_REDIR_DECL (wscanf);
> @@ -39,11 +47,23 @@ __LDBL_REDIR_DECL (swscanf);
>   #endif
> 
>   #ifdef __USE_ISOC99
> +# ifdef __LDBL_COMPAT
>   __LDBL_REDIR1_DECL (wcstold, wcstod);
> +# else
> +__LDBL_REDIR1_DECL (wcstold, __wcstoieee128)
> +# endif
>   # if !__GLIBC_USE (DEPRECATED_SCANF)
> +#  if defined __LDBL_COMPAT
>   __LDBL_REDIR1_DECL (vfwscanf, __nldbl___isoc99_vfwscanf)
>   __LDBL_REDIR1_DECL (vwscanf, __nldbl___isoc99_vwscanf)
>   __LDBL_REDIR1_DECL (vswscanf, __nldbl___isoc99_vswscanf)
> +#  elif __LONG_DOUBLE_USES_FLOAT128 == 1
> +__LDBL_REDIR1_DECL (vfwscanf, __isoc99_vfwscanfieee128)
> +__LDBL_REDIR1_DECL (vwscanf, __isoc99_vwscanfieee128)
> +__LDBL_REDIR1_DECL (vswscanf, __isoc99_vswscanfieee128)
> +#  else
> +#   error bits/stdlib-ldbl.h included when no ldbl redirections are required.
> +#  endif
>   # else
>   __LDBL_REDIR_DECL (vfwscanf);
>   __LDBL_REDIR_DECL (vwscanf);
> @@ -52,16 +72,20 @@ __LDBL_REDIR_DECL (vswscanf);
>   #endif
> 
>   #ifdef __USE_GNU
> +# ifdef __LDBL_COMPAT
>   __LDBL_REDIR1_DECL (wcstold_l, wcstod_l);
> +# else
> +__LDBL_REDIR1_DECL (wcstold_l, __wcstoieee128_l)
> +# endif
>   #endif
> 
>   #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
> -__LDBL_REDIR_DECL (__swprintf_chk)
> -__LDBL_REDIR_DECL (__vswprintf_chk)
> +__LDBL_REDIR2_DECL (swprintf_chk)
> +__LDBL_REDIR2_DECL (vswprintf_chk)
>   # if __USE_FORTIFY_LEVEL > 1
> -__LDBL_REDIR_DECL (__fwprintf_chk)
> -__LDBL_REDIR_DECL (__wprintf_chk)
> -__LDBL_REDIR_DECL (__vfwprintf_chk)
> -__LDBL_REDIR_DECL (__vwprintf_chk)
> +__LDBL_REDIR2_DECL (fwprintf_chk)
> +__LDBL_REDIR2_DECL (wprintf_chk)
> +__LDBL_REDIR2_DECL (vfwprintf_chk)
> +__LDBL_REDIR2_DECL (vwprintf_chk)
>   # endif
>   #endif
> diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
> index 5e0d65b14e..fb2cec8167 100644
> --- a/wcsmbs/wchar.h
> +++ b/wcsmbs/wchar.h
> @@ -633,9 +633,11 @@ extern int swscanf (const wchar_t *__restrict __s,
>        __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
> 
>   /* For historical reasons, the C99-compliant versions of the scanf
> -   functions are at alternative names.  When __LDBL_COMPAT is in
> -   effect, this is handled in bits/wchar-ldbl.h.  */
> -#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT
> +   functions are at alternative names.  When __LDBL_COMPAT or
> +   __LONG_DOUBLE_USES_FLOAT128 are in effect, this is handled in
> +   bits/wchar-ldbl.h.  */
> +#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
> +     && __LONG_DOUBLE_USES_FLOAT128 == 0
>   #  ifdef __REDIRECT
>   extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream,
>   				 const wchar_t *__restrict __format, ...),
> @@ -688,7 +690,8 @@ extern int vswscanf (const wchar_t *__restrict __s,
>   /* Same redirection as above for the v*wscanf family.  */
>   # if !__GLIBC_USE (DEPRECATED_SCANF) \
>        && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
> -     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
> +     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) \
> +     && __LONG_DOUBLE_USES_FLOAT128 == 0
>   #  ifdef __REDIRECT
>   extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
>   				  const wchar_t *__restrict __format,
> @@ -849,7 +852,8 @@ extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
>   # include <bits/wchar2.h>
>   #endif
> 
> -#ifdef __LDBL_COMPAT
> +#include <bits/floatn.h>
> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>   # include <bits/wchar-ldbl.h>
>   #endif
> 

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

* Re: [PATCH 1/6] Prepare redirections for IEEE long double on powerpc64le
  2020-02-03 21:10 ` [PATCH 1/6] Prepare redirections for IEEE long double on powerpc64le Paul E. Murphy
  2020-02-10 21:32   ` Paul E Murphy
@ 2020-02-11 18:25   ` Tulio Magno Quites Machado Filho
  1 sibling, 0 replies; 22+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2020-02-11 18:25 UTC (permalink / raw)
  To: Paul E. Murphy, libc-alpha

"Paul E. Murphy" <murphyp@linux.vnet.ibm.com> writes:

> All functions that have a format string, which can consume a long double
> argument, must have one version for each long double format supported on
> a platform.  On powerpc64le, these functions currently have two versions
> (i.e.: long double with the same format as double, and long double with
> IBM Extended Precision format).  Support for a third long double format
> option (i.e. long double with IEEE long double format) is being prepared
> and all the aforementioned functions now have a third version (not yet
> exported on the master branch, but the code is in).
>
> For these functions to get selected (during build time), references to
> them in user programs (or dependent libraries) must get redirected to
> the aforementioned new versions of the functions.  This patch installs
> the header magic required to perform such redirections.
>
> Notice, however, that since the redirections only happen when
> __LONG_DOUBLE_USES_FLOAT128 is set to 1, and no platform (including
> powerpc64le) currently does it, no redirections actually happen.
> Redirections and the exporting of the new functions will happen at the
> same time (when powerpc64le adds ldbl-128ibm-compat to their Implies.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>

-- 
Tulio Magno



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

* Re: [PATCH 4/6] ldbl-128ibm-compat: Redirect complex math functions
  2020-02-03 21:10 ` [PATCH 4/6] ldbl-128ibm-compat: Redirect complex math functions Paul E. Murphy
@ 2020-02-11 18:36   ` Tulio Magno Quites Machado Filho
  2020-02-28 14:59     ` Paul E Murphy
  0 siblings, 1 reply; 22+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2020-02-11 18:36 UTC (permalink / raw)
  To: Paul E. Murphy, libc-alpha

"Paul E. Murphy" <murphyp@linux.vnet.ibm.com> writes:

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

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>

-- 
Tulio Magno

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

* Re: [PATCH 6/6] Add a generic scalb implementation
  2020-02-03 21:10 ` [PATCH 6/6] Add a generic scalb implementation Paul E. Murphy
@ 2020-02-11 20:20   ` Paul E Murphy
  2020-02-12  1:21     ` Joseph Myers
  0 siblings, 1 reply; 22+ messages in thread
From: Paul E Murphy @ 2020-02-11 20:20 UTC (permalink / raw)
  To: libc-alpha

Ping? If no objections/feedback, I will commit with patch 1 in the 
series next week.

Tested on x86_64 and ppc64le.  I've also built/check-abi csky to verify 
the LIBM_SVID_COMPAT changes still generate the appropriate symbols for 
those arches not requiring the compat versions.

On 2/3/20 3:10 PM, Paul E. Murphy wrote:
> From: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
> 
> Create templates for e_scabl and w_scalb.
> ---
>   math/Makefile                              |  7 +--
>   math/{e_scalb.c => e_scalb_template.c}     | 33 ++++++------
>   math/e_scalbf.c                            | 54 --------------------
>   math/e_scalbl.c                            | 54 --------------------
>   math/w_scalb_compat.c                      |  6 +--
>   math/w_scalb_template.c                    | 59 ++++++++++++++++++++++
>   math/w_scalbf_compat.c                     |  4 +-
>   math/w_scalbl_compat.c                     |  4 +-
>   sysdeps/ieee754/float128/w_scalbf128.c     |  1 +
>   sysdeps/ieee754/ldbl-opt/w_scalb_compat.c  |  4 +-
>   sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c |  2 +
>   11 files changed, 91 insertions(+), 137 deletions(-)
>   rename math/{e_scalb.c => e_scalb_template.c} (64%)
>   delete mode 100644 math/e_scalbf.c
>   delete mode 100644 math/e_scalbl.c
>   create mode 100644 math/w_scalb_template.c
>   create mode 100644 sysdeps/ieee754/float128/w_scalbf128.c
> 
> diff --git a/math/Makefile b/math/Makefile
> index 5985b6744b..1d203e7ad5 100644
> --- a/math/Makefile
> +++ b/math/Makefile
> @@ -48,7 +48,7 @@ libm-support = s_lib_version s_matherr s_signgam			\
> 
>   # Wrappers for these functions generated per type using a file named
>   # <func>_template.c and the appropriate math-type-macros-<TYPE>.h.
> -gen-libm-calls = cargF conjF cimagF crealF cabsF s_cacosF		  \
> +gen-libm-calls = cargF conjF cimagF crealF cabsF e_scalbF s_cacosF	  \
>   	         s_cacoshF s_ccosF s_ccoshF s_casinF s_csinF s_casinhF	  \
>   		 k_casinhF s_csinhF k_casinhF s_csinhF s_catanhF s_catanF \
>   		 s_ctanF s_ctanhF s_cexpF s_clogF s_cprojF s_csqrtF	  \
> @@ -58,13 +58,14 @@ gen-libm-calls = cargF conjF cimagF crealF cabsF s_cacosF		  \
>   		 w_log1pF w_scalblnF s_fmaxmagF s_fminmagF w_acosF	  \
>   		 w_acoshF w_asinF w_atan2F w_atanhF w_coshF w_exp10F	  \
>   		 w_exp2F w_fmodF w_hypotF w_j0F w_j1F w_jnF w_logF	  \
> -		 w_log10F w_log2F w_powF w_remainderF w_sinhF w_sqrtF	  \
> +		 w_log10F w_log2F w_powF w_remainderF w_scalbF		  \
> +		 w_sinhF w_sqrtF					  \
>   		 w_tgammaF w_lgammaF w_lgammaF_r w_expF e_exp2F
> 
>   libm-calls =								  \
>   	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
>   	e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF	  \
> -	e_remainderF e_scalbF e_sinhF e_sqrtF e_gammaF_r	  \
> +	e_remainderF e_sinhF e_sqrtF e_gammaF_r				  \
>   	e_ilogbF							  \
>   	k_tanF s_asinhF s_atanF s_cbrtF					  \
>   	s_ceilF s_cosF s_erfF s_expm1F s_fabsF				  \
> diff --git a/math/e_scalb.c b/math/e_scalb_template.c
> similarity index 64%
> rename from math/e_scalb.c
> rename to math/e_scalb_template.c
> index dbe3b51d6a..ed0508c7bf 100644
> --- a/math/e_scalb.c
> +++ b/math/e_scalb_template.c
> @@ -1,6 +1,8 @@
> -/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
> +/* Multiply by integral power of radix.
> +
> +   Copyright (C) 2011-2020 Free Software Foundation, Inc.
> +
>      This file is part of the GNU C Library.
> -   Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
> 
>      The GNU C Library is free software; you can redistribute it and/or
>      modify it under the terms of the GNU Lesser General Public
> @@ -20,35 +22,36 @@
>   #include <math_private.h>
>   #include <libm-alias-finite.h>
> 
> -static double
> +static FLOAT
>   __attribute__ ((noinline))
> -invalid_fn (double x, double fn)
> +invalid_fn (FLOAT x, FLOAT fn)
>   {
> -  if (rint (fn) != fn)
> +  if (M_SUF (rint) (fn) != fn)
>       return (fn - fn) / (fn - fn);
> -  else if (fn > 65000.0)
> -    return __scalbn (x, 65000);
> +  else if (fn > M_LIT (65000.0))
> +    return M_SUF (__scalbn) (x, 65000);
>     else
> -    return __scalbn (x,-65000);
> +    return M_SUF (__scalbn) (x,-65000);
>   }
> 
> 
> -double
> -__ieee754_scalb (double x, double fn)
> +FLOAT
> +M_DECL_FUNC (__ieee754_scalb) (FLOAT x, FLOAT fn)
>   {
>     if (__glibc_unlikely (isnan (x)))
>       return x * fn;
>     if (__glibc_unlikely (!isfinite (fn)))
>       {
> -      if (isnan (fn) || fn > 0.0)
> +      if (isnan (fn) || fn > M_LIT (0.0))
>   	return x * fn;
> -      if (x == 0.0)
> +      if (x == M_LIT (0.0))
>   	return x;
>         return x / -fn;
>       }
> -  if (__glibc_unlikely (fabs (fn) >= 0x1p31 || (double) (int) fn != fn))
> +  if (__glibc_unlikely (M_FABS (fn) >= M_LIT (0x1p31)
> +			|| (FLOAT) (int) fn != fn))
>       return invalid_fn (x, fn);
> 
> -  return __scalbn (x, (int) fn);
> +  return M_SCALBN (x, (int) fn);
>   }
> -libm_alias_finite (__ieee754_scalb, __scalb)
> +declare_mgen_finite_alias (__ieee754_scalb, __scalb)
> diff --git a/math/e_scalbf.c b/math/e_scalbf.c
> deleted file mode 100644
> index 944cfbefc9..0000000000
> --- a/math/e_scalbf.c
> +++ /dev/null
> @@ -1,54 +0,0 @@
> -/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -   Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <math.h>
> -#include <math_private.h>
> -#include <libm-alias-finite.h>
> -
> -static float
> -__attribute__ ((noinline))
> -invalid_fn (float x, float fn)
> -{
> -  if (rintf (fn) != fn)
> -    return (fn - fn) / (fn - fn);
> -  else if (fn > 65000.0f)
> -    return __scalbnf (x, 65000);
> -  else
> -    return __scalbnf (x,-65000);
> -}
> -
> -
> -float
> -__ieee754_scalbf (float x, float fn)
> -{
> -  if (__glibc_unlikely (isnan (x)))
> -    return x * fn;
> -  if (__glibc_unlikely (!isfinite (fn)))
> -    {
> -      if (isnan (fn) || fn > 0.0f)
> -	return x * fn;
> -      if (x == 0.0f)
> -	return x;
> -      return x / -fn;
> -    }
> -  if (__glibc_unlikely (fabsf (fn) >= 0x1p31f || (float) (int) fn != fn))
> -    return invalid_fn (x, fn);
> -
> -  return __scalbnf (x, (int) fn);
> -}
> -libm_alias_finite (__ieee754_scalbf, __scalbf)
> diff --git a/math/e_scalbl.c b/math/e_scalbl.c
> deleted file mode 100644
> index 6595ec6c27..0000000000
> --- a/math/e_scalbl.c
> +++ /dev/null
> @@ -1,54 +0,0 @@
> -/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -   Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <math.h>
> -#include <math_private.h>
> -#include <libm-alias-finite.h>
> -
> -static long double
> -__attribute__ ((noinline))
> -invalid_fn (long double x, long double fn)
> -{
> -  if (rintl (fn) != fn)
> -    return (fn - fn) / (fn - fn);
> -  else if (fn > 65000.0L)
> -    return __scalbnl (x, 65000);
> -  else
> -    return __scalbnl (x,-65000);
> -}
> -
> -
> -long double
> -__ieee754_scalbl (long double x, long double fn)
> -{
> -  if (__glibc_unlikely (isnan (x)))
> -    return x * fn;
> -  if (__glibc_unlikely (!isfinite (fn)))
> -    {
> -      if (isnan (fn) || fn > 0.0L)
> -	return x * fn;
> -      if (x == 0.0L)
> -	return x;
> -      return x / -fn;
> -    }
> -  if (__glibc_unlikely (fabsl (fn) >= 0x1p31L || (long double) (int) fn != fn))
> -    return invalid_fn (x, fn);
> -
> -  return __scalbnl (x, (int) fn);
> -}
> -libm_alias_finite (__ieee754_scalbl, __scalbl)
> diff --git a/math/w_scalb_compat.c b/math/w_scalb_compat.c
> index c3dd3db4f7..664c0474a7 100644
> --- a/math/w_scalb_compat.c
> +++ b/math/w_scalb_compat.c
> @@ -41,18 +41,15 @@ sysv_scalb (double x, double fn)
> 
>     return z;
>   }
> -#endif
> 
> 
>   /* Wrapper scalb */
>   double
>   __scalb (double x, double fn)
>   {
> -#if LIBM_SVID_COMPAT
>     if (__glibc_unlikely (_LIB_VERSION == _SVID_))
>       return sysv_scalb (x, fn);
>     else
> -#endif
>       {
>         double z = __ieee754_scalb (x, fn);
> 
> @@ -79,7 +76,8 @@ __scalb (double x, double fn)
>       }
>   }
>   weak_alias (__scalb, scalb)
> -#ifdef NO_LONG_DOUBLE
> +# ifdef NO_LONG_DOUBLE
>   strong_alias (__scalb, __scalbl)
>   weak_alias (__scalb, scalbl)
> +# endif
>   #endif
> diff --git a/math/w_scalb_template.c b/math/w_scalb_template.c
> new file mode 100644
> index 0000000000..b2aafcdf36
> --- /dev/null
> +++ b/math/w_scalb_template.c
> @@ -0,0 +1,59 @@
> +/* 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>
> +
> +/* Wrapper scalb */
> +FLOAT
> +M_DECL_FUNC (__scalb) (FLOAT x, FLOAT fn)
> +{
> +    {
> +      FLOAT z = M_SUF (__ieee754_scalb) (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/math/w_scalbf_compat.c b/math/w_scalbf_compat.c
> index 42bba44cc6..1b742e9b98 100644
> --- a/math/w_scalbf_compat.c
> +++ b/math/w_scalbf_compat.c
> @@ -41,18 +41,15 @@ sysv_scalbf (float x, float fn)
> 
>     return z;
>   }
> -#endif
> 
> 
>   /* Wrapper scalbf */
>   float
>   __scalbf (float x, float fn)
>   {
> -#if LIBM_SVID_COMPAT
>     if (__glibc_unlikely (_LIB_VERSION == _SVID_))
>       return sysv_scalbf (x, fn);
>     else
> -#endif
>       {
>         float z = __ieee754_scalbf (x, fn);
> 
> @@ -79,3 +76,4 @@ __scalbf (float x, float fn)
>       }
>   }
>   weak_alias (__scalbf, scalbf)
> +#endif
> diff --git a/math/w_scalbl_compat.c b/math/w_scalbl_compat.c
> index 8858c6b66d..c8ba3fddb4 100644
> --- a/math/w_scalbl_compat.c
> +++ b/math/w_scalbl_compat.c
> @@ -41,18 +41,15 @@ sysv_scalbl (long double x, long double fn)
> 
>     return z;
>   }
> -#endif
> 
> 
>   /* Wrapper scalbl */
>   long double
>   __scalbl (long double x, long double fn)
>   {
> -#if LIBM_SVID_COMPAT
>     if (__glibc_unlikely (_LIB_VERSION == _SVID_))
>       return sysv_scalbl (x, fn);
>     else
> -#endif
>       {
>         long double z = __ieee754_scalbl (x, fn);
> 
> @@ -79,3 +76,4 @@ __scalbl (long double x, long double fn)
>       }
>   }
>   weak_alias (__scalbl, scalbl)
> +#endif
> diff --git a/sysdeps/ieee754/float128/w_scalbf128.c b/sysdeps/ieee754/float128/w_scalbf128.c
> new file mode 100644
> index 0000000000..067b724164
> --- /dev/null
> +++ b/sysdeps/ieee754/float128/w_scalbf128.c
> @@ -0,0 +1 @@
> +/* Not defined for _FloatN types.  */
> diff --git a/sysdeps/ieee754/ldbl-opt/w_scalb_compat.c b/sysdeps/ieee754/ldbl-opt/w_scalb_compat.c
> index f6d53a5ba5..56735e825e 100644
> --- a/sysdeps/ieee754/ldbl-opt/w_scalb_compat.c
> +++ b/sysdeps/ieee754/ldbl-opt/w_scalb_compat.c
> @@ -1,5 +1,7 @@
>   #include <math_ldbl_opt.h>
>   #include <math/w_scalb_compat.c>
> -#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
> +#if LIBM_SVID_COMPAT
> +# if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
>   compat_symbol (libm, __scalb, scalbl, GLIBC_2_0);
> +# endif
>   #endif
> diff --git a/sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c b/sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c
> index c8feb654a2..4d16f413c4 100644
> --- a/sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c
> +++ b/sysdeps/ieee754/ldbl-opt/w_scalbl_compat.c
> @@ -2,4 +2,6 @@
>   #undef weak_alias
>   #define weak_alias(n,a)
>   #include <math/w_scalbl_compat.c>
> +#if LIBM_SVID_COMPAT
>   long_double_symbol (libm, __scalbl, scalbl);
> +#endif
> 

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

* Re: [PATCH 6/6] Add a generic scalb implementation
  2020-02-11 20:20   ` Paul E Murphy
@ 2020-02-12  1:21     ` Joseph Myers
  0 siblings, 0 replies; 22+ messages in thread
From: Joseph Myers @ 2020-02-12  1:21 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

On Tue, 11 Feb 2020, Paul E Murphy wrote:

> Tested on x86_64 and ppc64le.  I've also built/check-abi csky to verify the
> LIBM_SVID_COMPAT changes still generate the appropriate symbols for those
> arches not requiring the compat versions.

I think a complete build-many-glibcs build is appropriate here.  It's also 
important to verify that it's still the case that no scalbf128 is built - 
that on platforms with _Float128, all the *scalbf128* object files contain 
no code (via the sysdeps/ieee754/float128 versions taking precedence).

> > +/* Wrapper scalb */
> > +FLOAT
> > +M_DECL_FUNC (__scalb) (FLOAT x, FLOAT fn)
> > +{
> > +    {
> > +      FLOAT z = M_SUF (__ieee754_scalb) (x, fn);

The indentation seems wrong here, as well as having an unnecessary layer 
of braces.

Please repost the patch for review with these issues fixed and a more 
detailed commit message with some explanation of the patch and its 
motivation.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 1/6] Prepare redirections for IEEE long double on powerpc64le
  2020-02-10 21:32   ` Paul E Murphy
@ 2020-02-17 14:34     ` Paul E Murphy
  2020-02-18 14:27       ` Paul E Murphy
  0 siblings, 1 reply; 22+ messages in thread
From: Paul E Murphy @ 2020-02-17 14:34 UTC (permalink / raw)
  To: libc-alpha

Ping x2.  This has been run through all configs of many-build-glibcs.py 
without any apparent issues.  Hearing nothing, I will commit this later 
today.

On 2/10/20 3:32 PM, Paul E Murphy wrote:
> Ping? If no objections I would like to commit this next Monday.
> 
> I was under the incorrect assumption this patch had been sent out
> in December as-is.  This is the continuation of 
> https://sourceware.org/ml/libc-alpha/2019-12/msg00515.html based on my 
> feedback from https://sourceware.org/ml/libc-alpha/2019-12/msg00521.html .
> 
> On 2/3/20 3:10 PM, Paul E. Murphy wrote:
>> From: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
>>
>> New since v4.
>>
>>    - Thanks, Paul, for the suggestion to split it from the last patch.
>>
>> -- 8< --
>> All functions that have a format string, which can consume a long double
>> argument, must have one version for each long double format supported on
>> a platform.  On powerpc64le, these functions currently have two versions
>> (i.e.: long double with the same format as double, and long double with
>> IBM Extended Precision format).  Support for a third long double format
>> option (i.e. long double with IEEE long double format) is being prepared
>> and all the aforementioned functions now have a third version (not yet
>> exported on the master branch, but the code is in).
>>
>> For these functions to get selected (during build time), references to
>> them in user programs (or dependent libraries) must get redirected to
>> the aforementioned new versions of the functions.  This patch installs
>> the header magic required to perform such redirections.
>>
>> Notice, however, that since the redirections only happen when
>> __LONG_DOUBLE_USES_FLOAT128 is set to 1, and no platform (including
>> powerpc64le) currently does it, no redirections actually happen.
>> Redirections and the exporting of the new functions will happen at the
>> same time (when powerpc64le adds ldbl-128ibm-compat to their Implies.
>> ---
>>   argp/argp.h               |  3 ++-
>>   libio/bits/stdio-ldbl.h   | 46 ++++++++++++++++++++++++++-------------
>>   libio/stdio.h             | 16 +++++++++-----
>>   misc/bits/syslog-ldbl.h   |  4 ++--
>>   misc/err.h                |  3 ++-
>>   misc/error.h              |  6 +++--
>>   misc/sys/cdefs.h          | 38 ++++++++++++++++++++++++++++++--
>>   misc/sys/syslog.h         |  4 +++-
>>   stdio-common/printf.h     |  3 ++-
>>   stdlib/bits/stdlib-ldbl.h | 22 +++++++++++++++++++
>>   stdlib/monetary.h         |  3 ++-
>>   stdlib/stdlib.h           |  4 +++-
>>   wcsmbs/bits/wchar-ldbl.h  | 36 +++++++++++++++++++++++++-----
>>   wcsmbs/wchar.h            | 14 +++++++-----
>>   14 files changed, 159 insertions(+), 43 deletions(-)
>>
>> diff --git a/argp/argp.h b/argp/argp.h
>> index 329aae097f..358d9b43cd 100644
>> --- a/argp/argp.h
>> +++ b/argp/argp.h
>> @@ -554,7 +554,8 @@ __NTH (__option_is_end (const struct argp_option 
>> *__opt))
>>   # endif
>>   #endif /* Use extern inlines.  */
>>
>> -#ifdef __LDBL_COMPAT
>> +#include <bits/floatn.h>
>> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>>   # include <bits/argp-ldbl.h>
>>   #endif
>>
>> diff --git a/libio/bits/stdio-ldbl.h b/libio/bits/stdio-ldbl.h
>> index 6626412fce..3bb9f7dd2c 100644
>> --- a/libio/bits/stdio-ldbl.h
>> +++ b/libio/bits/stdio-ldbl.h
>> @@ -27,9 +27,17 @@ __LDBL_REDIR_DECL (vfprintf)
>>   __LDBL_REDIR_DECL (vprintf)
>>   __LDBL_REDIR_DECL (vsprintf)
>>   #if !__GLIBC_USE (DEPRECATED_SCANF)
>> +# if defined __LDBL_COMPAT
>>   __LDBL_REDIR1_DECL (fscanf, __nldbl___isoc99_fscanf)
>>   __LDBL_REDIR1_DECL (scanf, __nldbl___isoc99_scanf)
>>   __LDBL_REDIR1_DECL (sscanf, __nldbl___isoc99_sscanf)
>> +# elif __LONG_DOUBLE_USES_FLOAT128 == 1
>> +__LDBL_REDIR1_DECL (fscanf, __isoc99_fscanfieee128)
>> +__LDBL_REDIR1_DECL (scanf, __isoc99_scanfieee128)
>> +__LDBL_REDIR1_DECL (sscanf, __isoc99_sscanfieee128)
>> +# else
>> +#  error bits/stdlib-ldbl.h included when no ldbl redirections are 
>> required.
>> +# endif
>>   #else
>>   __LDBL_REDIR_DECL (fscanf)
>>   __LDBL_REDIR_DECL (scanf)
>> @@ -43,9 +51,17 @@ __LDBL_REDIR_DECL (vsnprintf)
>>
>>   #ifdef    __USE_ISOC99
>>   # if !__GLIBC_USE (DEPRECATED_SCANF)
>> +#  if defined __LDBL_COMPAT
>>   __LDBL_REDIR1_DECL (vfscanf, __nldbl___isoc99_vfscanf)
>>   __LDBL_REDIR1_DECL (vscanf, __nldbl___isoc99_vscanf)
>>   __LDBL_REDIR1_DECL (vsscanf, __nldbl___isoc99_vsscanf)
>> +#  elif __LONG_DOUBLE_USES_FLOAT128 == 1
>> +__LDBL_REDIR1_DECL (vfscanf, __isoc99_vfscanfieee128)
>> +__LDBL_REDIR1_DECL (vscanf, __isoc99_vscanfieee128)
>> +__LDBL_REDIR1_DECL (vsscanf, __isoc99_vsscanfieee128)
>> +#  else
>> +#   error bits/stdlib-ldbl.h included when no ldbl redirections are 
>> required.
>> +#  endif
>>   # else
>>   __LDBL_REDIR_DECL (vfscanf)
>>   __LDBL_REDIR_DECL (vsscanf)
>> @@ -60,33 +76,33 @@ __LDBL_REDIR_DECL (dprintf)
>>
>>   #ifdef __USE_GNU
>>   __LDBL_REDIR_DECL (vasprintf)
>> -__LDBL_REDIR_DECL (__asprintf)
>> +__LDBL_REDIR2_DECL (asprintf)
>>   __LDBL_REDIR_DECL (asprintf)
>>   __LDBL_REDIR_DECL (obstack_printf)
>>   __LDBL_REDIR_DECL (obstack_vprintf)
>>   #endif
>>
>>   #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
>> -__LDBL_REDIR_DECL (__sprintf_chk)
>> -__LDBL_REDIR_DECL (__vsprintf_chk)
>> +__LDBL_REDIR2_DECL (sprintf_chk)
>> +__LDBL_REDIR2_DECL (vsprintf_chk)
>>   # if defined __USE_ISOC99 || defined __USE_UNIX98
>> -__LDBL_REDIR_DECL (__snprintf_chk)
>> -__LDBL_REDIR_DECL (__vsnprintf_chk)
>> +__LDBL_REDIR2_DECL (snprintf_chk)
>> +__LDBL_REDIR2_DECL (vsnprintf_chk)
>>   # endif
>>   # if __USE_FORTIFY_LEVEL > 1
>> -__LDBL_REDIR_DECL (__fprintf_chk)
>> -__LDBL_REDIR_DECL (__printf_chk)
>> -__LDBL_REDIR_DECL (__vfprintf_chk)
>> -__LDBL_REDIR_DECL (__vprintf_chk)
>> +__LDBL_REDIR2_DECL (fprintf_chk)
>> +__LDBL_REDIR2_DECL (printf_chk)
>> +__LDBL_REDIR2_DECL (vfprintf_chk)
>> +__LDBL_REDIR2_DECL (vprintf_chk)
>>   #  ifdef __USE_XOPEN2K8
>> -__LDBL_REDIR_DECL (__dprintf_chk)
>> -__LDBL_REDIR_DECL (__vdprintf_chk)
>> +__LDBL_REDIR2_DECL (dprintf_chk)
>> +__LDBL_REDIR2_DECL (vdprintf_chk)
>>   #  endif
>>   #  ifdef __USE_GNU
>> -__LDBL_REDIR_DECL (__asprintf_chk)
>> -__LDBL_REDIR_DECL (__vasprintf_chk)
>> -__LDBL_REDIR_DECL (__obstack_printf_chk)
>> -__LDBL_REDIR_DECL (__obstack_vprintf_chk)
>> +__LDBL_REDIR2_DECL (asprintf_chk)
>> +__LDBL_REDIR2_DECL (vasprintf_chk)
>> +__LDBL_REDIR2_DECL (obstack_printf_chk)
>> +__LDBL_REDIR2_DECL (obstack_vprintf_chk)
>>   #  endif
>>   # endif
>>   #endif
>> diff --git a/libio/stdio.h b/libio/stdio.h
>> index 5a10a4d3ee..18e29752c4 100644
>> --- a/libio/stdio.h
>> +++ b/libio/stdio.h
>> @@ -400,9 +400,12 @@ extern int sscanf (const char *__restrict __s,
>>              const char *__restrict __format, ...) __THROW;
>>
>>   /* For historical reasons, the C99-compliant versions of the scanf
>> -   functions are at alternative names.  When __LDBL_COMPAT is in
>> -   effect, this is handled in bits/stdio-ldbl.h.  */
>> -#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT
>> +   functions are at alternative names.  When __LDBL_COMPAT or
>> +   __LONG_DOUBLE_USES_FLOAT128 are in effect, this is handled in
>> +   bits/stdio-ldbl.h.  */
>> +#include <bits/floatn.h>
>> +#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
>> +    && __LONG_DOUBLE_USES_FLOAT128 == 0
>>   # ifdef __REDIRECT
>>   extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
>>                   const char *__restrict __format, ...),
>> @@ -447,7 +450,8 @@ extern int vsscanf (const char *__restrict __s,
>>
>>   /* Same redirection as above for the v*scanf family.  */
>>   # if !__GLIBC_USE (DEPRECATED_SCANF)
>> -#  if defined __REDIRECT && !defined __LDBL_COMPAT
>> +#  if defined __REDIRECT && !defined __LDBL_COMPAT \
>> +      && __LONG_DOUBLE_USES_FLOAT128 == 0
>>   extern int __REDIRECT (vfscanf,
>>                  (FILE *__restrict __s,
>>               const char *__restrict __format, __gnuc_va_list __arg),
>> @@ -866,7 +870,9 @@ extern int __overflow (FILE *, int);
>>   #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
>>   # include <bits/stdio2.h>
>>   #endif
>> -#ifdef __LDBL_COMPAT
>> +
>> +#include <bits/floatn.h>
>> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>>   # include <bits/stdio-ldbl.h>
>>   #endif
>>
>> diff --git a/misc/bits/syslog-ldbl.h b/misc/bits/syslog-ldbl.h
>> index fead0d4648..657b192b9b 100644
>> --- a/misc/bits/syslog-ldbl.h
>> +++ b/misc/bits/syslog-ldbl.h
>> @@ -27,9 +27,9 @@ __LDBL_REDIR_DECL (vsyslog)
>>   #endif
>>
>>   #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
>> -__LDBL_REDIR_DECL (__syslog_chk)
>> +__LDBL_REDIR2_DECL (syslog_chk)
>>
>>   # ifdef __USE_MISC
>> -__LDBL_REDIR_DECL (__vsyslog_chk)
>> +__LDBL_REDIR2_DECL (vsyslog_chk)
>>   # endif
>>   #endif
>> diff --git a/misc/err.h b/misc/err.h
>> index f6fd72945f..d146a55054 100644
>> --- a/misc/err.h
>> +++ b/misc/err.h
>> @@ -52,7 +52,8 @@ extern void errx (int __status, const char 
>> *__format, ...)
>>   extern void verrx (int __status, const char *, __gnuc_va_list)
>>        __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0)));
>>
>> -#ifdef __LDBL_COMPAT
>> +#include <bits/floatn.h>
>> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>>   # include <bits/err-ldbl.h>
>>   #endif
>>
>> diff --git a/misc/error.h b/misc/error.h
>> index a456695f1a..bb8a3b26a4 100644
>> --- a/misc/error.h
>> +++ b/misc/error.h
>> @@ -47,11 +47,13 @@ extern unsigned int error_message_count;
>>      variable controls whether this mode is selected or not.  */
>>   extern int error_one_per_line;
>>
>> -#ifdef __LDBL_COMPAT
>> +#include <bits/floatn.h>
>> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>>   # include <bits/error-ldbl.h>
>>   #else
>>   /* Do not inline error and error_at_line when long double has the same
>> -   size of double, because that would invalidate the redirections to the
>> +   size of double, nor when long double reuses the float128
>> +   implementation, because that would invalidate the redirections to the
>>      compatibility functions.  */
>>   # if defined __extern_always_inline && defined __va_arg_pack
>>   #  include <bits/error.h>
>> diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
>> index ff7144f3f3..dd5f69f833 100644
>> --- a/misc/sys/cdefs.h
>> +++ b/misc/sys/cdefs.h
>> @@ -452,7 +452,37 @@
>>   #include <bits/wordsize.h>
>>   #include <bits/long-double.h>
>>
>> -#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
>> +#if __LONG_DOUBLE_USES_FLOAT128 == 1
>> +# ifdef __REDIRECT
>> +
>> +/* Alias name defined automatically.  */
>> +#  define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
>> +#  define __LDBL_REDIR_DECL(name) \
>> +  extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
>> +
>> +/* Alias name defined automatically, with leading underscores.  */
>> +#  define __LDBL_REDIR2_DECL(name) \
>> +  extern __typeof (__##name) __##name \
>> +    __asm (__ASMNAME ("__" #name "ieee128"));
>> +
>> +/* Alias name defined manually.  */
>> +#  define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
>> +#  define __LDBL_REDIR1_DECL(name, alias) \
>> +  extern __typeof (name) name __asm (__ASMNAME (#alias));
>> +
>> +#  define __LDBL_REDIR1_NTH(name, proto, alias) \
>> +  __REDIRECT_NTH (name, proto, alias)
>> +#  define __REDIRECT_NTH_LDBL(name, proto, alias) \
>> +  __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
>> +
>> +/* Unused.  */
>> +#  define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
>> +#  define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
>> +
>> +# else
>> +_Static_assert (0, "IEEE 128-bits long double requires redirection on 
>> this platform");
>> +# endif
>> +#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined 
>> __NO_LONG_DOUBLE_MATH
>>   # define __LDBL_COMPAT 1
>>   # ifdef __REDIRECT
>>   #  define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, 
>> alias)
>> @@ -461,6 +491,8 @@
>>   #  define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH 
>> (name, proto, alias)
>>   #  define __LDBL_REDIR_NTH(name, proto) \
>>     __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
>> +#  define __LDBL_REDIR2_DECL(name) \
>> +  extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" 
>> #name));
>>   #  define __LDBL_REDIR1_DECL(name, alias) \
>>     extern __typeof (name) name __asm (__ASMNAME (#alias));
>>   #  define __LDBL_REDIR_DECL(name) \
>> @@ -471,11 +503,13 @@
>>     __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
>>   # endif
>>   #endif
>> -#if !defined __LDBL_COMPAT || !defined __REDIRECT
>> +#if (!defined __LDBL_COMPAT && __LONG_DOUBLE_USES_FLOAT128 == 0) \
>> +    || !defined __REDIRECT
>>   # define __LDBL_REDIR1(name, proto, alias) name proto
>>   # define __LDBL_REDIR(name, proto) name proto
>>   # define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
>>   # define __LDBL_REDIR_NTH(name, proto) name proto __THROW
>> +# define __LDBL_REDIR2_DECL(name)
>>   # define __LDBL_REDIR_DECL(name)
>>   # ifdef __REDIRECT
>>   #  define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, 
>> proto, alias)
>> diff --git a/misc/sys/syslog.h b/misc/sys/syslog.h
>> index ee01478c4b..c000b8e915 100644
>> --- a/misc/sys/syslog.h
>> +++ b/misc/sys/syslog.h
>> @@ -206,7 +206,9 @@ extern void vsyslog (int __pri, const char *__fmt, 
>> __gnuc_va_list __ap)
>>   #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
>>   # include <bits/syslog.h>
>>   #endif
>> -#ifdef __LDBL_COMPAT
>> +
>> +#include <bits/floatn.h>
>> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>>   # include <bits/syslog-ldbl.h>
>>   #endif
>>
>> diff --git a/stdio-common/printf.h b/stdio-common/printf.h
>> index ad3c8a4254..00bedebfdb 100644
>> --- a/stdio-common/printf.h
>> +++ b/stdio-common/printf.h
>> @@ -182,7 +182,8 @@ extern int printf_size_info (const struct 
>> printf_info *__restrict
>>                    __info, size_t __n, int *__restrict __argtypes)
>>        __THROW;
>>
>> -#ifdef __LDBL_COMPAT
>> +#include <bits/floatn.h>
>> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>>   # include <bits/printf-ldbl.h>
>>   #endif
>>
>> diff --git a/stdlib/bits/stdlib-ldbl.h b/stdlib/bits/stdlib-ldbl.h
>> index 5c6294ed9b..2469474532 100644
>> --- a/stdlib/bits/stdlib-ldbl.h
>> +++ b/stdlib/bits/stdlib-ldbl.h
>> @@ -21,21 +21,43 @@
>>   #endif
>>
>>   #ifdef    __USE_ISOC99
>> +# ifdef __LDBL_COMPAT
>>   __LDBL_REDIR1_DECL (strtold, strtod)
>> +# else
>> +__LDBL_REDIR1_DECL (strtold, __strtoieee128)
>> +# endif
>>   #endif
>>
>>   #ifdef __USE_GNU
>> +# ifdef __LDBL_COMPAT
>>   __LDBL_REDIR1_DECL (strtold_l, strtod_l)
>> +# else
>> +__LDBL_REDIR1_DECL (strtold_l, __strtoieee128_l)
>> +# endif
>>   #endif
>>
>>   #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
>> +# ifdef __LDBL_COMPAT
>>   __LDBL_REDIR1_DECL (strfroml, strfromd)
>> +# else
>> +__LDBL_REDIR1_DECL (strfroml, __strfromieee128)
>> +# endif
>>   #endif
>>
>>   #ifdef __USE_MISC
>> +# if defined __LDBL_COMPAT
>>   __LDBL_REDIR1_DECL (qecvt, ecvt)
>>   __LDBL_REDIR1_DECL (qfcvt, fcvt)
>>   __LDBL_REDIR1_DECL (qgcvt, gcvt)
>>   __LDBL_REDIR1_DECL (qecvt_r, ecvt_r)
>>   __LDBL_REDIR1_DECL (qfcvt_r, fcvt_r)
>> +# elif __LONG_DOUBLE_USES_FLOAT128 == 1
>> +__LDBL_REDIR1_DECL (qecvt, __qecvtieee128)
>> +__LDBL_REDIR1_DECL (qfcvt, __qfcvtieee128)
>> +__LDBL_REDIR1_DECL (qgcvt, __qgcvtieee128)
>> +__LDBL_REDIR1_DECL (qecvt_r, __qecvtieee128_r)
>> +__LDBL_REDIR1_DECL (qfcvt_r, __qfcvtieee128_r)
>> +# else
>> +#  error bits/stdlib-ldbl.h included when no ldbl redirections are 
>> required.
>> +# endif
>>   #endif
>> diff --git a/stdlib/monetary.h b/stdlib/monetary.h
>> index dfb6ed5c0c..4a6d61fd2d 100644
>> --- a/stdlib/monetary.h
>> +++ b/stdlib/monetary.h
>> @@ -50,7 +50,8 @@ extern ssize_t strfmon_l (char *__restrict __s, 
>> size_t __maxsize,
>>        __THROW __attribute_format_strfmon__ (4, 5);
>>   #endif
>>
>> -#ifdef __LDBL_COMPAT
>> +#include <bits/floatn.h>
>> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>>   # include <bits/monetary-ldbl.h>
>>   #endif
>>
>> diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
>> index e3470631e1..a7c0c71a80 100644
>> --- a/stdlib/stdlib.h
>> +++ b/stdlib/stdlib.h
>> @@ -1016,7 +1016,9 @@ extern int ttyslot (void) __THROW;
>>   #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
>>   # include <bits/stdlib.h>
>>   #endif
>> -#ifdef __LDBL_COMPAT
>> +
>> +#include <bits/floatn.h>
>> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>>   # include <bits/stdlib-ldbl.h>
>>   #endif
>>
>> diff --git a/wcsmbs/bits/wchar-ldbl.h b/wcsmbs/bits/wchar-ldbl.h
>> index fc50ee26de..75d547f680 100644
>> --- a/wcsmbs/bits/wchar-ldbl.h
>> +++ b/wcsmbs/bits/wchar-ldbl.h
>> @@ -28,9 +28,17 @@ __LDBL_REDIR_DECL (vfwprintf);
>>   __LDBL_REDIR_DECL (vwprintf);
>>   __LDBL_REDIR_DECL (vswprintf);
>>   # if !__GLIBC_USE (DEPRECATED_SCANF)
>> +#  if defined __LDBL_COMPAT
>>   __LDBL_REDIR1_DECL (fwscanf, __nldbl___isoc99_fwscanf)
>>   __LDBL_REDIR1_DECL (wscanf, __nldbl___isoc99_wscanf)
>>   __LDBL_REDIR1_DECL (swscanf, __nldbl___isoc99_swscanf)
>> +#  elif __LONG_DOUBLE_USES_FLOAT128 == 1
>> +__LDBL_REDIR1_DECL (fwscanf, __isoc99_fwscanfieee128)
>> +__LDBL_REDIR1_DECL (wscanf, __isoc99_wscanfieee128)
>> +__LDBL_REDIR1_DECL (swscanf, __isoc99_swscanfieee128)
>> +#  else
>> +#   error bits/stdlib-ldbl.h included when no ldbl redirections are 
>> required.
>> +#  endif
>>   # else
>>   __LDBL_REDIR_DECL (fwscanf);
>>   __LDBL_REDIR_DECL (wscanf);
>> @@ -39,11 +47,23 @@ __LDBL_REDIR_DECL (swscanf);
>>   #endif
>>
>>   #ifdef __USE_ISOC99
>> +# ifdef __LDBL_COMPAT
>>   __LDBL_REDIR1_DECL (wcstold, wcstod);
>> +# else
>> +__LDBL_REDIR1_DECL (wcstold, __wcstoieee128)
>> +# endif
>>   # if !__GLIBC_USE (DEPRECATED_SCANF)
>> +#  if defined __LDBL_COMPAT
>>   __LDBL_REDIR1_DECL (vfwscanf, __nldbl___isoc99_vfwscanf)
>>   __LDBL_REDIR1_DECL (vwscanf, __nldbl___isoc99_vwscanf)
>>   __LDBL_REDIR1_DECL (vswscanf, __nldbl___isoc99_vswscanf)
>> +#  elif __LONG_DOUBLE_USES_FLOAT128 == 1
>> +__LDBL_REDIR1_DECL (vfwscanf, __isoc99_vfwscanfieee128)
>> +__LDBL_REDIR1_DECL (vwscanf, __isoc99_vwscanfieee128)
>> +__LDBL_REDIR1_DECL (vswscanf, __isoc99_vswscanfieee128)
>> +#  else
>> +#   error bits/stdlib-ldbl.h included when no ldbl redirections are 
>> required.
>> +#  endif
>>   # else
>>   __LDBL_REDIR_DECL (vfwscanf);
>>   __LDBL_REDIR_DECL (vwscanf);
>> @@ -52,16 +72,20 @@ __LDBL_REDIR_DECL (vswscanf);
>>   #endif
>>
>>   #ifdef __USE_GNU
>> +# ifdef __LDBL_COMPAT
>>   __LDBL_REDIR1_DECL (wcstold_l, wcstod_l);
>> +# else
>> +__LDBL_REDIR1_DECL (wcstold_l, __wcstoieee128_l)
>> +# endif
>>   #endif
>>
>>   #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
>> -__LDBL_REDIR_DECL (__swprintf_chk)
>> -__LDBL_REDIR_DECL (__vswprintf_chk)
>> +__LDBL_REDIR2_DECL (swprintf_chk)
>> +__LDBL_REDIR2_DECL (vswprintf_chk)
>>   # if __USE_FORTIFY_LEVEL > 1
>> -__LDBL_REDIR_DECL (__fwprintf_chk)
>> -__LDBL_REDIR_DECL (__wprintf_chk)
>> -__LDBL_REDIR_DECL (__vfwprintf_chk)
>> -__LDBL_REDIR_DECL (__vwprintf_chk)
>> +__LDBL_REDIR2_DECL (fwprintf_chk)
>> +__LDBL_REDIR2_DECL (wprintf_chk)
>> +__LDBL_REDIR2_DECL (vfwprintf_chk)
>> +__LDBL_REDIR2_DECL (vwprintf_chk)
>>   # endif
>>   #endif
>> diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
>> index 5e0d65b14e..fb2cec8167 100644
>> --- a/wcsmbs/wchar.h
>> +++ b/wcsmbs/wchar.h
>> @@ -633,9 +633,11 @@ extern int swscanf (const wchar_t *__restrict __s,
>>        __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
>>
>>   /* For historical reasons, the C99-compliant versions of the scanf
>> -   functions are at alternative names.  When __LDBL_COMPAT is in
>> -   effect, this is handled in bits/wchar-ldbl.h.  */
>> -#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT
>> +   functions are at alternative names.  When __LDBL_COMPAT or
>> +   __LONG_DOUBLE_USES_FLOAT128 are in effect, this is handled in
>> +   bits/wchar-ldbl.h.  */
>> +#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
>> +     && __LONG_DOUBLE_USES_FLOAT128 == 0
>>   #  ifdef __REDIRECT
>>   extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream,
>>                    const wchar_t *__restrict __format, ...),
>> @@ -688,7 +690,8 @@ extern int vswscanf (const wchar_t *__restrict __s,
>>   /* Same redirection as above for the v*wscanf family.  */
>>   # if !__GLIBC_USE (DEPRECATED_SCANF) \
>>        && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
>> -     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
>> +     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) \
>> +     && __LONG_DOUBLE_USES_FLOAT128 == 0
>>   #  ifdef __REDIRECT
>>   extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
>>                     const wchar_t *__restrict __format,
>> @@ -849,7 +852,8 @@ extern size_t wcsftime_l (wchar_t *__restrict __s, 
>> size_t __maxsize,
>>   # include <bits/wchar2.h>
>>   #endif
>>
>> -#ifdef __LDBL_COMPAT
>> +#include <bits/floatn.h>
>> +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1
>>   # include <bits/wchar-ldbl.h>
>>   #endif
>>

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

* Re: [PATCH 2/6] Undefine redirections after long double definition on __LDBL_COMPAT [BZ #23294]
  2020-02-03 21:10 ` [PATCH 2/6] Undefine redirections after long double definition on __LDBL_COMPAT [BZ #23294] Paul E. Murphy
@ 2020-02-17 15:08   ` Paul E Murphy
  2020-02-18 15:15     ` Paul E Murphy
  0 siblings, 1 reply; 22+ messages in thread
From: Paul E Murphy @ 2020-02-17 15:08 UTC (permalink / raw)
  To: libc-alpha

Ping.

On 2/3/20 3:10 PM, Paul E. Murphy wrote:
> From: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
> 
> After defining the long double redirections to double, __MATHDECL_1 has
> to be redefined to its previous state in order to avoid redirecting all
> subsequent types.
> ---
>   math/complex.h                                | 10 ++-
>   math/math.h                                   | 18 ++--
>   sysdeps/ieee754/ldbl-opt/Makefile             |  4 +-
>   .../ldbl-opt/test-redirection-ldbl-64.c       | 87 +++++++++++++++++++
>   4 files changed, 112 insertions(+), 7 deletions(-)
>   create mode 100644 sysdeps/ieee754/ldbl-opt/test-redirection-ldbl-64.c

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

* Re: [PATCH 1/6] Prepare redirections for IEEE long double on powerpc64le
  2020-02-17 14:34     ` Paul E Murphy
@ 2020-02-18 14:27       ` Paul E Murphy
  0 siblings, 0 replies; 22+ messages in thread
From: Paul E Murphy @ 2020-02-18 14:27 UTC (permalink / raw)
  To: libc-alpha

And committed.  Thank you Gabriel and community for the heavy lifting on 
this and the many changes leading up to it. (My apologies for the email 
delay.  Some SMTP issues cropped up last night)

On 2/17/20 8:34 AM, Paul E Murphy wrote:
> Ping x2.  This has been run through all configs of many-build-glibcs.py 
> without any apparent issues.  Hearing nothing, I will commit this later 
> today.
> 
> On 2/10/20 3:32 PM, Paul E Murphy wrote:
>> Ping? If no objections I would like to commit this next Monday.
>>
>> I was under the incorrect assumption this patch had been sent out
>> in December as-is.  This is the continuation of 
>> https://sourceware.org/ml/libc-alpha/2019-12/msg00515.html based on my 
>> feedback from 
>> https://sourceware.org/ml/libc-alpha/2019-12/msg00521.html .
>>
>> On 2/3/20 3:10 PM, Paul E. Murphy wrote:
>>> From: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
>>>
>>> New since v4.
>>>
>>>    - Thanks, Paul, for the suggestion to split it from the last patch.
>>>
>>> -- 8< --
>>> All functions that have a format string, which can consume a long double
>>> argument, must have one version for each long double format supported on
>>> a platform.  On powerpc64le, these functions currently have two versions
>>> (i.e.: long double with the same format as double, and long double with
>>> IBM Extended Precision format).  Support for a third long double format
>>> option (i.e. long double with IEEE long double format) is being prepared
>>> and all the aforementioned functions now have a third version (not yet
>>> exported on the master branch, but the code is in).
>>>
>>> For these functions to get selected (during build time), references to
>>> them in user programs (or dependent libraries) must get redirected to
>>> the aforementioned new versions of the functions.  This patch installs
>>> the header magic required to perform such redirections.
>>>
>>> Notice, however, that since the redirections only happen when
>>> __LONG_DOUBLE_USES_FLOAT128 is set to 1, and no platform (including
>>> powerpc64le) currently does it, no redirections actually happen.
>>> Redirections and the exporting of the new functions will happen at the
>>> same time (when powerpc64le adds ldbl-128ibm-compat to their Implies.
>>> ---
>>>   argp/argp.h               |  3 ++-
>>>   libio/bits/stdio-ldbl.h   | 46 ++++++++++++++++++++++++++-------------
>>>   libio/stdio.h             | 16 +++++++++-----
>>>   misc/bits/syslog-ldbl.h   |  4 ++--
>>>   misc/err.h                |  3 ++-
>>>   misc/error.h              |  6 +++--
>>>   misc/sys/cdefs.h          | 38 ++++++++++++++++++++++++++++++--
>>>   misc/sys/syslog.h         |  4 +++-
>>>   stdio-common/printf.h     |  3 ++-
>>>   stdlib/bits/stdlib-ldbl.h | 22 +++++++++++++++++++
>>>   stdlib/monetary.h         |  3 ++-
>>>   stdlib/stdlib.h           |  4 +++-
>>>   wcsmbs/bits/wchar-ldbl.h  | 36 +++++++++++++++++++++++++-----
>>>   wcsmbs/wchar.h            | 14 +++++++-----
>>>   14 files changed, 159 insertions(+), 43 deletions(-)
>>>

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

* Re: [PATCH 2/6] Undefine redirections after long double definition on __LDBL_COMPAT [BZ #23294]
  2020-02-17 15:08   ` Paul E Murphy
@ 2020-02-18 15:15     ` Paul E Murphy
  2020-02-21 14:31       ` Paul E Murphy
  0 siblings, 1 reply; 22+ messages in thread
From: Paul E Murphy @ 2020-02-18 15:15 UTC (permalink / raw)
  To: libc-alpha, Tulio Magno Quites Machado Filho

My only contribution to this patch is to fix the merge conflict in the 
Makefile while rebasing.

Note, this does address the feedback from Joseph [1] about adding a test 
which will fail without this change.  I Have verified the test does fail 
without the change.

If there are no further requests or objections for this patch, I would 
like to commit it friday.  It is necessary to for functional redirection 
support in ldbl-128ibm-compat.

[1] https://sourceware.org/ml/libc-alpha/2018-06/msg00600.html


Reviewed-by: Paul E. Murphy <murphyp@linux.vnet.ibm.com>

On 2/17/20 9:08 AM, Paul E Murphy wrote:
> Ping.
> 
> On 2/3/20 3:10 PM, Paul E. Murphy wrote:
>> From: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
>>
>> After defining the long double redirections to double, __MATHDECL_1 has
>> to be redefined to its previous state in order to avoid redirecting all
>> subsequent types.
>> ---
>>   math/complex.h                                | 10 ++-
>>   math/math.h                                   | 18 ++--
>>   sysdeps/ieee754/ldbl-opt/Makefile             |  4 +-
>>   .../ldbl-opt/test-redirection-ldbl-64.c       | 87 +++++++++++++++++++
>>   4 files changed, 112 insertions(+), 7 deletions(-)
>>   create mode 100644 sysdeps/ieee754/ldbl-opt/test-redirection-ldbl-64.c

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

* Re: [PATCH 5/6] ldbl-128ibm-compat: Provide ieee128 symbols to narrow functions
  2020-02-03 21:10 ` [PATCH 5/6] ldbl-128ibm-compat: Provide ieee128 symbols to narrow functions Paul E. Murphy
@ 2020-02-18 22:23   ` Paul E Murphy
  2020-02-21 14:29     ` Paul E Murphy
  0 siblings, 1 reply; 22+ messages in thread
From: Paul E Murphy @ 2020-02-18 22:23 UTC (permalink / raw)
  To: libc-alpha

Ping.  I will commit this Friday with Patch 2 hearing no requests for 
improvement or objections.

On 2/3/20 3:10 PM, Paul E. Murphy wrote:
> From: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
> 
> Move the narrow math aliasing macros into a new sysdep header file
> math-narrow-alias-float128.h.  Then, provide an override header
> to supply the necessary changes to supply the *ieee128 aliases of
> these symbols.
> 
> This adds ieee128 aliases for faddl, fdivl, fmull, fsubl, daddl, ddivl,
> dmull, dsubl.
> ---
>   math/math-narrow.h                            | 15 +-------
>   sysdeps/generic/math-narrow-alias-float128.h  | 32 +++++++++++++++++
>   sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  8 +++++
>   .../math-narrow-alias-float128.h              | 34 +++++++++++++++++++
>   4 files changed, 75 insertions(+), 14 deletions(-)
>   create mode 100644 sysdeps/generic/math-narrow-alias-float128.h
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/math-narrow-alias-float128.h
> 

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

* Re: [PATCH 5/6] ldbl-128ibm-compat: Provide ieee128 symbols to narrow functions
  2020-02-18 22:23   ` Paul E Murphy
@ 2020-02-21 14:29     ` Paul E Murphy
  0 siblings, 0 replies; 22+ messages in thread
From: Paul E Murphy @ 2020-02-21 14:29 UTC (permalink / raw)
  To: libc-alpha

Pushed after verification against build-many-glibcs.py.

On 2/18/20 4:23 PM, Paul E Murphy wrote:
> Ping.  I will commit this Friday with Patch 2 hearing no requests for 
> improvement or objections.
> 
> On 2/3/20 3:10 PM, Paul E. Murphy wrote:
>> From: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
>>
>> Move the narrow math aliasing macros into a new sysdep header file
>> math-narrow-alias-float128.h.  Then, provide an override header
>> to supply the necessary changes to supply the *ieee128 aliases of
>> these symbols.
>>
>> This adds ieee128 aliases for faddl, fdivl, fmull, fsubl, daddl, ddivl,
>> dmull, dsubl.
>> ---
>>   math/math-narrow.h                            | 15 +-------
>>   sysdeps/generic/math-narrow-alias-float128.h  | 32 +++++++++++++++++
>>   sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  8 +++++
>>   .../math-narrow-alias-float128.h              | 34 +++++++++++++++++++
>>   4 files changed, 75 insertions(+), 14 deletions(-)
>>   create mode 100644 sysdeps/generic/math-narrow-alias-float128.h
>>   create mode 100644 
>> sysdeps/ieee754/ldbl-128ibm-compat/math-narrow-alias-float128.h
>>

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

* Re: [PATCH 2/6] Undefine redirections after long double definition on __LDBL_COMPAT [BZ #23294]
  2020-02-18 15:15     ` Paul E Murphy
@ 2020-02-21 14:31       ` Paul E Murphy
  0 siblings, 0 replies; 22+ messages in thread
From: Paul E Murphy @ 2020-02-21 14:31 UTC (permalink / raw)
  To: libc-alpha

Pushed after verification against all build-many-glibcs.py targets.

On 2/18/20 9:15 AM, Paul E Murphy wrote:
> My only contribution to this patch is to fix the merge conflict in the 
> Makefile while rebasing.
> 
> Note, this does address the feedback from Joseph [1] about adding a test 
> which will fail without this change.  I Have verified the test does fail 
> without the change.
> 
> If there are no further requests or objections for this patch, I would 
> like to commit it friday.  It is necessary to for functional redirection 
> support in ldbl-128ibm-compat.
> 
> [1] https://sourceware.org/ml/libc-alpha/2018-06/msg00600.html
> 
> 
> Reviewed-by: Paul E. Murphy <murphyp@linux.vnet.ibm.com>
> 
> On 2/17/20 9:08 AM, Paul E Murphy wrote:
>> Ping.
>>
>> On 2/3/20 3:10 PM, Paul E. Murphy wrote:
>>> From: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
>>>
>>> After defining the long double redirections to double, __MATHDECL_1 has
>>> to be redefined to its previous state in order to avoid redirecting all
>>> subsequent types.
>>> ---
>>>   math/complex.h                                | 10 ++-
>>>   math/math.h                                   | 18 ++--
>>>   sysdeps/ieee754/ldbl-opt/Makefile             |  4 +-
>>>   .../ldbl-opt/test-redirection-ldbl-64.c       | 87 +++++++++++++++++++
>>>   4 files changed, 112 insertions(+), 7 deletions(-)
>>>   create mode 100644 sysdeps/ieee754/ldbl-opt/test-redirection-ldbl-64.c

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

* Re: [PATCH 3/6] ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions
  2020-02-03 21:10 ` [PATCH 3/6] ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions Paul E. Murphy
@ 2020-02-24 14:58   ` Paul E Murphy
  2020-02-28 14:55     ` Paul E Murphy
  0 siblings, 1 reply; 22+ messages in thread
From: Paul E Murphy @ 2020-02-24 14:58 UTC (permalink / raw)
  To: libc-alpha



On 2/3/20 3:10 PM, Paul E. Murphy wrote:
> From: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
> 
> Modify the headers to redirect long double functions to global __*f128
> symbols or to __*ieee128 otherwise.
> 
> Most of the functions in math.h benefit from the infrastructure already
> available for __LDBL_COMPAT.  The only exceptions are nexttowardf and
> nexttoward that need especial treatment.
> 
> Both math/bits/mathcalls-helper-functions.h and math/bits/mathcalls.h
> were modified in order to provide alternative redirection destinations
> that are essential to support functions that should not be redirected to
> the same name pattern of the rest of the functions, i.e.: __fpclassify,
> __signbit, __iseqsig, __issignaling, isinf, finite and isnan, which will
> be redirected to __*f128 instead of __*ieee128 used for the rest.
> ---
>   include/math.h                                |  9 ++-
>   math/bits/mathcalls-helper-functions.h        | 18 +++---
>   math/bits/mathcalls.h                         |  9 ++-
>   math/math.h                                   | 59 ++++++++++++++++++-
>   .../ieee754/ldbl-128ibm/bits/iscanonical.h    |  8 ++-
>   5 files changed, 85 insertions(+), 18 deletions(-)

I think the majority of this patch is OK.  My only contribution was to 
fixup against the deprecation of the finite entry points.

The naming of the nexttoward ABI is a bit awkward, but I proffer no 
better solutions.

If there are no requests for improvement, or objections, I will commit 
this and the following patch 4, the equivalent support for complex.h, on 
Friday.

> diff --git a/math/math.h b/math/math.h
> index e13b3f3a29..1692ff4a45 100644
> --- a/math/math.h
> +++ b/math/math.h
> @@ -283,6 +283,10 @@ enum
>     extern type __MATH_PRECNAME(function,suffix) args __THROW
>   #define __MATHDECL_1(type, function, suffix, args) \
>     __MATHDECL_1_IMPL(type, function, suffix, args)
> +/* Ignore the alias by default.  The alias is only useful with
> +   redirections.  */
> +#define __MATHDECL_ALIAS(type, function, suffix, args, alias) \
> +  __MATHDECL_1(type, function, suffix, args)
> 
>   #define __MATHREDIR(type, function, suffix, args, to) \
>     extern type __REDIRECT_NTH (__MATH_PRECNAME (function, suffix), args, to)
> @@ -338,6 +342,35 @@ extern long double __REDIRECT_NTH (nexttowardl,
>   #   undef __MATHDECL_1
>   #   define __MATHDECL_1(type, function,suffix, args) \
>     __MATHREDIR(type, function, suffix, args, __CONCAT(function,suffix))
> +
> +#  elif __LONG_DOUBLE_USES_FLOAT128 == 1
> +#   ifdef __REDIRECT_NTH
> +#    ifdef __USE_ISOC99
> +extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y),
> +			    __nexttowardf_to_ieee128)
> +  __attribute__ ((__const__));
> +extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y),
> +			     __nexttoward_to_ieee128)
> +  __attribute__ ((__const__));

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

* Re: [PATCH 3/6] ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions
  2020-02-24 14:58   ` Paul E Murphy
@ 2020-02-28 14:55     ` Paul E Murphy
  0 siblings, 0 replies; 22+ messages in thread
From: Paul E Murphy @ 2020-02-28 14:55 UTC (permalink / raw)
  To: libc-alpha



On 2/24/20 8:58 AM, Paul E Murphy wrote:
> 
> 
> On 2/3/20 3:10 PM, Paul E. Murphy wrote:
>> From: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
>>
>> Modify the headers to redirect long double functions to global __*f128
>> symbols or to __*ieee128 otherwise.
>>
>> Most of the functions in math.h benefit from the infrastructure already
>> available for __LDBL_COMPAT.  The only exceptions are nexttowardf and
>> nexttoward that need especial treatment.
>>
>> Both math/bits/mathcalls-helper-functions.h and math/bits/mathcalls.h
>> were modified in order to provide alternative redirection destinations
>> that are essential to support functions that should not be redirected to
>> the same name pattern of the rest of the functions, i.e.: __fpclassify,
>> __signbit, __iseqsig, __issignaling, isinf, finite and isnan, which will
>> be redirected to __*f128 instead of __*ieee128 used for the rest.
>> ---
>>   include/math.h                                |  9 ++-
>>   math/bits/mathcalls-helper-functions.h        | 18 +++---
>>   math/bits/mathcalls.h                         |  9 ++-
>>   math/math.h                                   | 59 ++++++++++++++++++-
>>   .../ieee754/ldbl-128ibm/bits/iscanonical.h    |  8 ++-
>>   5 files changed, 85 insertions(+), 18 deletions(-)
> 
> I think the majority of this patch is OK.  My only contribution was to 
> fixup against the deprecation of the finite entry points.
> 
> The naming of the nexttoward ABI is a bit awkward, but I proffer no 
> better solutions.
> 
> If there are no requests for improvement, or objections, I will commit 
> this and the following patch 4, the equivalent support for complex.h, on 
> Friday.
> 

And committed.

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

* Re: [PATCH 4/6] ldbl-128ibm-compat: Redirect complex math functions
  2020-02-11 18:36   ` Tulio Magno Quites Machado Filho
@ 2020-02-28 14:59     ` Paul E Murphy
  0 siblings, 0 replies; 22+ messages in thread
From: Paul E Murphy @ 2020-02-28 14:59 UTC (permalink / raw)
  To: libc-alpha

And committed with the math.h changes.

On 2/11/20 12:36 PM, Tulio Magno Quites Machado Filho wrote:
> "Paul E. Murphy" <murphyp@linux.vnet.ibm.com> writes:
> 
>> 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.
> 
> Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
> 

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

end of thread, other threads:[~2020-02-28 14:59 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-03 21:10 [PATCH 0/6] long double to _Float128 redirecting support Paul E. Murphy
2020-02-03 21:10 ` [PATCH 1/6] Prepare redirections for IEEE long double on powerpc64le Paul E. Murphy
2020-02-10 21:32   ` Paul E Murphy
2020-02-17 14:34     ` Paul E Murphy
2020-02-18 14:27       ` Paul E Murphy
2020-02-11 18:25   ` Tulio Magno Quites Machado Filho
2020-02-03 21:10 ` [PATCH 2/6] Undefine redirections after long double definition on __LDBL_COMPAT [BZ #23294] Paul E. Murphy
2020-02-17 15:08   ` Paul E Murphy
2020-02-18 15:15     ` Paul E Murphy
2020-02-21 14:31       ` Paul E Murphy
2020-02-03 21:10 ` [PATCH 3/6] ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions Paul E. Murphy
2020-02-24 14:58   ` Paul E Murphy
2020-02-28 14:55     ` Paul E Murphy
2020-02-03 21:10 ` [PATCH 4/6] ldbl-128ibm-compat: Redirect complex math functions Paul E. Murphy
2020-02-11 18:36   ` Tulio Magno Quites Machado Filho
2020-02-28 14:59     ` Paul E Murphy
2020-02-03 21:10 ` [PATCH 5/6] ldbl-128ibm-compat: Provide ieee128 symbols to narrow functions Paul E. Murphy
2020-02-18 22:23   ` Paul E Murphy
2020-02-21 14:29     ` Paul E Murphy
2020-02-03 21:10 ` [PATCH 6/6] Add a generic scalb implementation Paul E. Murphy
2020-02-11 20:20   ` Paul E Murphy
2020-02-12  1:21     ` 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).