From: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
To: libc-alpha@sourceware.org
Cc: joseph@codesourcery.com, gabriel@inconstante.eti.br, raji@linux.ibm.com
Subject: [PATCH 8/9] ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions
Date: Wed, 06 Jun 2018 22:42:00 -0000 [thread overview]
Message-ID: <20180606223909.16675-9-tuliom@linux.ibm.com> (raw)
In-Reply-To: <20180606223909.16675-1-tuliom@linux.ibm.com>
Modify the headers to redirect long double functions to global __*f128
symbols or to __*ieee128 otherwise.
Most of the functions benefit from math-redir.h. The only exceptions
are nexttowardf and nexttoward that need especial treatment.
2018-06-06 Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
* include/math.h [__HAVE_DISTINCT_FLOAT128 &&
!__HAVE_FLOAT128_UNLIKE_LDBL]: Avoid redirecting __finitel,
__isinfl, __isnanl, __fpclassifyl, __issignalingl, __expl,
__expml and sqrtl as they conflict with the redirections from
math/math.h.
* sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
[__HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL]: Likewise
for function iscanonical(_Float128).
* math/math.h [__HAVE_DISTINCT_FLOAT128 &&
!__HAVE_FLOAT128_UNLIKE_LDBL]: Redirect long double functions to
__*f128 or _*ieee128, reusing mathcalls-redir.h.
Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
---
include/math.h | 12 +++++-
math/math.h | 57 +++++++++++++++++++++++++-
sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h | 6 ++-
3 files changed, 70 insertions(+), 5 deletions(-)
diff --git a/include/math.h b/include/math.h
index e21d34b868..57d77cfd13 100644
--- a/include/math.h
+++ b/include/math.h
@@ -18,7 +18,9 @@ hidden_proto (__finitef)
hidden_proto (__isinff)
hidden_proto (__isnanf)
-# ifndef __NO_LONG_DOUBLE_MATH
+# if !defined __NO_LONG_DOUBLE_MATH \
+ && (!__HAVE_DISTINCT_FLOAT128 \
+ || (__HAVE_DISTINCT_FLOAT128 && __HAVE_FLOAT128_UNLIKE_LDBL))
hidden_proto (__finitel)
hidden_proto (__isinfl)
hidden_proto (__isnanl)
@@ -40,7 +42,9 @@ libm_hidden_proto (__exp)
libm_hidden_proto (__expf)
libm_hidden_proto (__roundeven)
-# ifndef __NO_LONG_DOUBLE_MATH
+# if !defined __NO_LONG_DOUBLE_MATH \
+ && (!__HAVE_DISTINCT_FLOAT128 \
+ || (__HAVE_DISTINCT_FLOAT128 && __HAVE_FLOAT128_UNLIKE_LDBL))
libm_hidden_proto (__fpclassifyl)
libm_hidden_proto (__issignalingl)
libm_hidden_proto (__expl)
@@ -61,7 +65,11 @@ libm_hidden_proto (__expm1f128)
float (sqrtf) (float) asm ("__ieee754_sqrtf");
double (sqrt) (double) asm ("__ieee754_sqrt");
# ifndef __NO_LONG_DOUBLE_MATH
+/* Do not redirect sqrtl twice when the long double already redirects it. */
+# if !__HAVE_DISTINCT_FLOAT128 \
+ || (__HAVE_DISTINCT_FLOAT128 && __HAVE_FLOAT128_UNLIKE_LDBL)
long double (sqrtl) (long double) asm ("__ieee754_sqrtl");
+# endif
# endif
# if __HAVE_DISTINCT_FLOAT128 > 0
_Float128 (sqrtf128) (_Float128) asm ("__ieee754_sqrtf128");
diff --git a/math/math.h b/math/math.h
index 3edf275e26..6ad6c7f6d0 100644
--- a/math/math.h
+++ b/math/math.h
@@ -348,6 +348,42 @@ extern long double __REDIRECT_NTH (nexttowardl,
# define __MATH_DECLARE_LDOUBLE 1
# include <bits/mathcalls-helper-functions.h>
# include <bits/mathcalls.h>
+
+/* Provide ieee long double function redirection. */
+# if !defined __LDBL_COMPAT \
+ && __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL
+# define __REDIRFROM_X(function, reentrant) \
+ function ## l ## reentrant
+# define __REDIRTO_X(function, reentrant) \
+ __ ## function ## ieee128 ## reentrant
+# define __REDIRTO_ALT_X(function, reentrant) \
+ __ ## function ## f128 ## reentrant
+# define __MATH_REDIR_X(type, from, args, to) \
+ extern type __REDIRECT_NTH (from, args, to); \
+ extern type __REDIRECT_NTH (__CONCAT(__,from), args, to);
+# if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
+/* Do not redirect when finite functions are requested. Leave this job to
+ bits/math-finite.h. */
+# define __MATH_REDIR_FINITE 0
+# else
+# define __MATH_REDIR_FINITE 1
+# endif
+# define __MATH_REDIR_NON_FINITE 1
+# include <bits/mathcalls-redir.h>
+/* Redirect all nexttoward functions when redirecting long double. */
+__MATH_REDIR_X (float, nexttowardf, (float __x, long double __y), \
+ __REDIRTO_X (nexttowardf_to_,));
+__MATH_REDIR_X (double, nexttoward, (double __x, long double __y), \
+ __REDIRTO_X (nexttoward_to_,));
+
+# undef __MATH_REDIR_NON_FINITE
+# undef __MATH_REDIR_FINITE
+# undef __MATH_REDIR_X
+# undef __REDIRTO_ALT_X
+# undef __REDIRTO_X
+# undef __REDIRFROM_X
+# endif
+
# undef _Mdouble_
# undef __MATH_PRECNAME
# undef __MATH_DECLARING_DOUBLE
@@ -511,6 +547,11 @@ extern long double __REDIRECT_NTH (nexttowardl,
# ifdef __LDBL_COMPAT
# define __MATHCALL_REDIR_NAME(name) f ## name
# undef __MATHCALL_NARROW
+# define __MATHCALL_NARROW(func, redir, nargs) \
+ __MATHCALL_NARROW_REDIR (func, redir, nargs)
+# elif __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL
+# define __MATHCALL_REDIR_NAME(name) f32 ## name ## f128
+# undef __MATHCALL_NARROW
# define __MATHCALL_NARROW(func, redir, nargs) \
__MATHCALL_NARROW_REDIR (func, redir, nargs)
# endif
@@ -518,7 +559,8 @@ extern long double __REDIRECT_NTH (nexttowardl,
# undef _Mret_
# undef _Marg_
# undef __MATHCALL_NAME
-# ifdef __LDBL_COMPAT
+# if defined __LDBL_COMPAT \
+ || (__HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL)
# undef __MATHCALL_REDIR_NAME
# undef __MATHCALL_NARROW
# define __MATHCALL_NARROW(func, redir, nargs) \
@@ -531,6 +573,11 @@ extern long double __REDIRECT_NTH (nexttowardl,
# ifdef __LDBL_COMPAT
# define __MATHCALL_REDIR_NAME(name) __nldbl_d ## name ## l
# undef __MATHCALL_NARROW
+# define __MATHCALL_NARROW(func, redir, nargs) \
+ __MATHCALL_NARROW_REDIR (func, redir, nargs)
+# elif __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL
+# define __MATHCALL_REDIR_NAME(name) f64 ## name ## f128
+# undef __MATHCALL_NARROW
# define __MATHCALL_NARROW(func, redir, nargs) \
__MATHCALL_NARROW_REDIR (func, redir, nargs)
# endif
@@ -538,7 +585,8 @@ extern long double __REDIRECT_NTH (nexttowardl,
# undef _Mret_
# undef _Marg_
# undef __MATHCALL_NAME
-# ifdef __LDBL_COMPAT
+# if defined __LDBL_COMPAT \
+ || (__HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL)
# undef __MATHCALL_REDIR_NAME
# undef __MATHCALL_NARROW
# define __MATHCALL_NARROW(func, redir, nargs) \
@@ -1296,6 +1344,11 @@ iszero (__T __val)
__ ## function ## reentrant ## _finite
# define __REDIRTO_PUBLIC_X(function, reentrant) \
__REDIRTO_X(function, reentrant)
+# elif __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL
+# define __REDIRTO_X(function, reentrant) \
+ __ ## function ## f128 ## reentrant ## _finite
+# define __REDIRTO_PUBLIC_X(function, reentrant) \
+ __ ## function ## l ## reentrant ## _finite
# else
# define __REDIRTO_X(function, reentrant) \
__ ## function ## l ## reentrant ## _finite
diff --git a/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h b/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
index 60c54cca46..f54e5d9ddb 100644
--- a/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
+++ b/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
@@ -50,7 +50,11 @@ extern "C++" {
inline int iscanonical (float __val) { return __iscanonicalf (__val); }
inline int iscanonical (double __val) { return __iscanonical (__val); }
inline int iscanonical (long double __val) { return __iscanonicall (__val); }
-# if __HAVE_DISTINCT_FLOAT128
+/* When using an IEEE 128-bit long double, _Float128 is defined as long double
+ in C++. */
+# if __HAVE_DISTINCT_FLOAT128 \
+ && (!defined __cplusplus \
+ || defined __cplusplus && __HAVE_FLOAT128_UNLIKE_LDBL)
inline int iscanonical (_Float128 __val) { return __iscanonicalf128 (__val); }
# endif
}
--
2.14.4
next prev parent reply other threads:[~2018-06-06 22:42 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-06 22:41 [PATCH 0/9] Introduce ieee128 symbols and redirections Tulio Magno Quites Machado Filho
2018-06-06 22:41 ` [PATCH 2/9] Move declare_mgen_finite_alias definition Tulio Magno Quites Machado Filho
2018-06-07 13:25 ` Joseph Myers
2018-06-06 22:41 ` [PATCH 3/9] ldbl-128ibm-compat: Provide a generic scalb implementation Tulio Magno Quites Machado Filho
2018-06-06 22:41 ` [PATCH 4/9] ldbl-128ibm-compat: Add a generic significand() implementation Tulio Magno Quites Machado Filho
2018-06-07 13:38 ` Joseph Myers
2018-06-15 20:16 ` Tulio Magno Quites Machado Filho
2018-06-15 20:20 ` Tulio Magno Quites Machado Filho
2018-06-06 22:41 ` [PATCH 1/9] ldbl-128ibm-compat: Create libm-alias-float128.h Tulio Magno Quites Machado Filho
2018-06-06 23:05 ` Joseph Myers
2018-06-13 20:16 ` Tulio Magno Quites Machado Filho
2018-06-06 22:42 ` Tulio Magno Quites Machado Filho [this message]
2018-06-06 22:42 ` [PATCH 5/9] ldbl-128ibm-compat: Provide ISO C functions not provided by the _Float128 API Tulio Magno Quites Machado Filho
2018-06-07 14:51 ` Joseph Myers
2018-06-13 21:41 ` Tulio Magno Quites Machado Filho
2018-06-06 22:42 ` [PATCH 7/9] Refactor math-finite.h and introduce mathcalls-redir.h Tulio Magno Quites Machado Filho
2018-06-06 23:23 ` Joseph Myers
2018-06-13 21:36 ` Tulio Magno Quites Machado Filho
2018-06-13 22:58 ` Joseph Myers
2018-06-14 18:07 ` Tulio Magno Quites Machado Filho
2018-06-06 22:42 ` [PATCH 6/9] ldbl-128ibm-compat: Provide nexttoward functions Tulio Magno Quites Machado Filho
2018-06-06 22:43 ` [PATCH 9/9] ldbl-128ibm-compat: Redirect complex math functions Tulio Magno Quites Machado Filho
2018-06-06 23:11 ` [PATCH 0/9] Introduce ieee128 symbols and redirections Joseph Myers
2018-06-13 20:25 ` Tulio Magno Quites Machado Filho
2018-06-13 20:28 ` Joseph Myers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180606223909.16675-9-tuliom@linux.ibm.com \
--to=tuliom@linux.ibm.com \
--cc=gabriel@inconstante.eti.br \
--cc=joseph@codesourcery.com \
--cc=libc-alpha@sourceware.org \
--cc=raji@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).