From patchwork Wed Jun 20 02:04:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tulio Magno Quites Machado Filho X-Patchwork-Id: 27940 X-Patchwork-Delegate: joseph@codesourcery.com Received: (qmail 8317 invoked by alias); 20 Jun 2018 02:06:24 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 8046 invoked by uid 89); 20 Jun 2018 02:06:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Tulio Magno Quites Machado Filho To: libc-alpha@sourceware.org Cc: joseph@codesourcery.com Subject: [PATCH 10/12] ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions Date: Tue, 19 Jun 2018 23:04:24 -0300 In-Reply-To: <20180620020426.20372-1-tuliom@linux.ibm.com> References: <20180620020426.20372-1-tuliom@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18062002-0052-0000-0000-000003012386 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009223; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000265; SDB=6.01049503; UDB=6.00537768; IPR=6.00828477; MB=3.00021748; MTD=3.00000008; XFM=3.00000015; UTC=2018-06-20 02:06:13 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062002-0053-0000-0000-00005D12E8FB Message-Id: <20180620020426.20372-11-tuliom@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-20_01:, , signatures=0 Modify the headers to redirect long double functions to global __*f128 symbols or to __*ieee128 otherwise. Most of the functions in math.h benefit from the infrastructure already available for __LDBL_COMPAT. The only exceptions are nexttowardf and nexttoward that need especial treatment. Both math/bits/mathcalls-helper-functions.h and math/bits/mathcalls.h were modified in order to provide alternative redirection destinations that are essential to support functions that should not be redirected to the same name pattern of the rest of the functions, i.e.: __fpclassify, __signbit, __iseqsig, __issignaling, isinf, finite and isnan, which will be redirected to __*f128 instead of __*ieee128 used for the rest. 2018-06-19 Tulio Magno Quites Machado Filho * include/math.h [__HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL]: Avoid redirecting __finitel, __isinfl, __isnanl, __fpclassifyl, __issignalingl, __expl, __expml and sqrtl as they conflict with the redirections from math/math.h. * sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h [__HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL]: Likewise for function iscanonical(_Float128). * math/math.h [__HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL]: Redirect long double functions to __*f128 or _*ieee128. (__MATHDECL_ALIAS): New macro. * math/bits/mathcalls-helper-functions.h: Replace __MATHDECL_1 with __MATHDECL_ALIAS. * math/bits/mathcalls.h: Likewise for isinf, finite and isnan. Signed-off-by: Tulio Magno Quites Machado Filho --- include/math.h | 12 ++++- math/bits/mathcalls-helper-functions.h | 18 +++---- math/bits/mathcalls.h | 9 ++-- math/math.h | 66 ++++++++++++++++++++++++-- sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h | 6 ++- 5 files changed, 94 insertions(+), 17 deletions(-) diff --git a/include/math.h b/include/math.h index e21d34b868..57d77cfd13 100644 --- a/include/math.h +++ b/include/math.h @@ -18,7 +18,9 @@ hidden_proto (__finitef) hidden_proto (__isinff) hidden_proto (__isnanf) -# ifndef __NO_LONG_DOUBLE_MATH +# if !defined __NO_LONG_DOUBLE_MATH \ + && (!__HAVE_DISTINCT_FLOAT128 \ + || (__HAVE_DISTINCT_FLOAT128 && __HAVE_FLOAT128_UNLIKE_LDBL)) hidden_proto (__finitel) hidden_proto (__isinfl) hidden_proto (__isnanl) @@ -40,7 +42,9 @@ libm_hidden_proto (__exp) libm_hidden_proto (__expf) libm_hidden_proto (__roundeven) -# ifndef __NO_LONG_DOUBLE_MATH +# if !defined __NO_LONG_DOUBLE_MATH \ + && (!__HAVE_DISTINCT_FLOAT128 \ + || (__HAVE_DISTINCT_FLOAT128 && __HAVE_FLOAT128_UNLIKE_LDBL)) libm_hidden_proto (__fpclassifyl) libm_hidden_proto (__issignalingl) libm_hidden_proto (__expl) @@ -61,7 +65,11 @@ libm_hidden_proto (__expm1f128) float (sqrtf) (float) asm ("__ieee754_sqrtf"); double (sqrt) (double) asm ("__ieee754_sqrt"); # ifndef __NO_LONG_DOUBLE_MATH +/* Do not redirect sqrtl twice when the long double already redirects it. */ +# if !__HAVE_DISTINCT_FLOAT128 \ + || (__HAVE_DISTINCT_FLOAT128 && __HAVE_FLOAT128_UNLIKE_LDBL) long double (sqrtl) (long double) asm ("__ieee754_sqrtl"); +# endif # endif # if __HAVE_DISTINCT_FLOAT128 > 0 _Float128 (sqrtf128) (_Float128) asm ("__ieee754_sqrtf128"); diff --git a/math/bits/mathcalls-helper-functions.h b/math/bits/mathcalls-helper-functions.h index ac3115bfdc..a6d83bf4e6 100644 --- a/math/bits/mathcalls-helper-functions.h +++ b/math/bits/mathcalls-helper-functions.h @@ -16,28 +16,30 @@ License along with the GNU C Library; if not, see . */ - /* Classify given number. */ -__MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value)) +__MATHDECL_ALIAS (int, __fpclassify,, (_Mdouble_ __value), fpclassify) __attribute__ ((__const__)); /* Test for negative number. */ -__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value)) +__MATHDECL_ALIAS (int, __signbit,, (_Mdouble_ __value), signbit) __attribute__ ((__const__)); /* Return 0 if VALUE is finite or NaN, +1 if it is +Infinity, -1 if it is -Infinity. */ -__MATHDECL_1 (int, __isinf,, (_Mdouble_ __value)) __attribute__ ((__const__)); +__MATHDECL_ALIAS (int, __isinf,, (_Mdouble_ __value), isinf) + __attribute__ ((__const__)); /* Return nonzero if VALUE is finite and not NaN. Used by isfinite macro. */ -__MATHDECL_1 (int, __finite,, (_Mdouble_ __value)) __attribute__ ((__const__)); +__MATHDECL_ALIAS (int, __finite,, (_Mdouble_ __value), finite) + __attribute__ ((__const__)); /* Return nonzero if VALUE is not a number. */ -__MATHDECL_1 (int, __isnan,, (_Mdouble_ __value)) __attribute__ ((__const__)); +__MATHDECL_ALIAS (int, __isnan,, (_Mdouble_ __value), isnan) + __attribute__ ((__const__)); /* Test equality. */ -__MATHDECL_1 (int, __iseqsig,, (_Mdouble_ __x, _Mdouble_ __y)); +__MATHDECL_ALIAS (int, __iseqsig,, (_Mdouble_ __x, _Mdouble_ __y), iseqsig); /* Test for signaling NaN. */ -__MATHDECL_1 (int, __issignaling,, (_Mdouble_ __value)) +__MATHDECL_ALIAS (int, __issignaling,, (_Mdouble_ __value), issignaling) __attribute__ ((__const__)); diff --git a/math/bits/mathcalls.h b/math/bits/mathcalls.h index f4246a7881..9ace71bef6 100644 --- a/math/bits/mathcalls.h +++ b/math/bits/mathcalls.h @@ -173,12 +173,14 @@ __MATHCALL_FINITE (fmod,, (_Mdouble_ __x, _Mdouble_ __y)); && !__MATH_DECLARING_FLOATN /* Return 0 if VALUE is finite or NaN, +1 if it is +Infinity, -1 if it is -Infinity. */ -__MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__)); +__MATHDECL_ALIAS (int,isinf,, (_Mdouble_ __value), isinf) + __attribute__ ((__const__)); # endif # if !__MATH_DECLARING_FLOATN /* Return nonzero if VALUE is finite and not NaN. */ -__MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__)); +__MATHDECL_ALIAS (int,finite,, (_Mdouble_ __value), finite) + __attribute__ ((__const__)); /* Return the remainder of X/Y. */ __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y)); @@ -207,7 +209,8 @@ __MATHCALL (nan,, (const char *__tagb)); || __MATH_DECLARING_DOUBLE == 0)) /* isnanf or isnanl don't. */ \ && !__MATH_DECLARING_FLOATN /* Return nonzero if VALUE is not a number. */ -__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__)); +__MATHDECL_ALIAS (int,isnan,, (_Mdouble_ __value), isnan) + __attribute__ ((__const__)); # endif #endif diff --git a/math/math.h b/math/math.h index c1765e4c8c..8d0880b262 100644 --- a/math/math.h +++ b/math/math.h @@ -283,6 +283,10 @@ enum extern type __MATH_PRECNAME(function,suffix) args __THROW #define __MATHDECL_1(type, function, suffix, args) \ __MATHDECL_1_IMPL(type, function, suffix, args) +/* Ignore the alias by default. The alias is only useful with + redirections. */ +#define __MATHDECL_ALIAS(type, function, suffix, args, alias) \ + __MATHDECL_1_IMPL(type, function, suffix, args) #define __MATHREDIR(type, function, suffix, args, to) \ extern type __REDIRECT_NTH (__MATH_PRECNAME (function, suffix), args, to) @@ -364,6 +368,39 @@ extern long double __REDIRECT_NTH (nexttowardl, # undef __MATHDECL_1 # define __MATHDECL_1(type, function,suffix, args) \ __MATHREDIR(type, function, suffix, args, __CONCAT(function,suffix)) + +# elif __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL +# ifdef __REDIRECT_NTH +# ifdef __USE_ISOC99 +extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y), + __nexttowardf_to_ieee128) + __attribute__ ((__const__)); +extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y), + __nexttoward_to_ieee128) + __attribute__ ((__const__)); + +#define __dremieee128 __remainderieee128 +#define __gammaieee128 __lgammaieee128 + +# endif +# endif + +# undef __MATHDECL_1 +# undef __MATHDECL_ALIAS + +# define __REDIRTO(function, suffix) \ + __ ## function ## ieee128 ## suffix +# define __REDIRTO_ALT(function, suffix) \ + __ ## function ## f128 ## suffix + +# undef __MATH_FINITE_NAME +# define __MATH_FINITE_NAME(function, suffix) \ + __MATH_FINITE_NAMEX (, __REDIRTO_ALT (function, suffix), _finite) + +# define __MATHDECL_1(type, function, suffix, args) \ + __MATHREDIR (type, function, suffix, args, __REDIRTO (function, suffix)) +# define __MATHDECL_ALIAS(type, function, suffix, args, alias) \ + __MATHREDIR (type, function, suffix, args, __REDIRTO_ALT (alias, suffix)) # endif /* Include the file of declarations again, this time using `long double' @@ -376,15 +413,25 @@ extern long double __REDIRECT_NTH (nexttowardl, # define __MATH_DECLARE_LDOUBLE 1 # include # include + # undef _Mdouble_ # undef __MATH_PRECNAME # undef __MATH_DECLARING_DOUBLE # undef __MATH_DECLARING_FLOATN -# if defined __LDBL_COMPAT +# if defined __LDBL_COMPAT \ + || (__HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL) +# undef __REDIRTO +# undef __REDIRTO_ALT # undef __MATHDECL_1 +# undef __MATHDECL_ALIAS +# undef __MATH_FINITE_NAME +# define __MATH_FINITE_NAME(function, suffix) \ + __MATH_FINITE_NAME_IMPL (function, suffix) # define __MATHDECL_1(type, function, suffix, args) \ __MATHDECL_1_IMPL(type, function, suffix, args) +# define __MATHDECL_ALIAS(type, function, suffix, args, alias) \ + __MATHDECL_1_IMPL(type, function, suffix, args) # endif # endif /* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */ @@ -720,6 +767,7 @@ extern int signgam; #undef __REDIRTO_PUBLIC_X #undef __MATHDECL_1_IMPL #undef __MATHDECL_1 +#undef __MATHDECL_ALIAS #undef __MATHDECL #undef __MATHCALL #undef __MATHCALL_VEC @@ -759,6 +807,11 @@ extern int signgam; # ifdef __LDBL_COMPAT # define __MATHCALL_REDIR_NAME(name) f ## name # undef __MATHCALL_NARROW +# define __MATHCALL_NARROW(func, redir, nargs) \ + __MATHCALL_NARROW_REDIR (func, redir, nargs) +# elif __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL +# define __MATHCALL_REDIR_NAME(name) __ ## f32 ## name ## ieee128 +# undef __MATHCALL_NARROW # define __MATHCALL_NARROW(func, redir, nargs) \ __MATHCALL_NARROW_REDIR (func, redir, nargs) # endif @@ -766,7 +819,8 @@ extern int signgam; # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME -# ifdef __LDBL_COMPAT +# if defined __LDBL_COMPAT \ + || (__HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL) # undef __MATHCALL_REDIR_NAME # undef __MATHCALL_NARROW # define __MATHCALL_NARROW(func, redir, nargs) \ @@ -779,6 +833,11 @@ extern int signgam; # ifdef __LDBL_COMPAT # define __MATHCALL_REDIR_NAME(name) __nldbl_d ## name ## l # undef __MATHCALL_NARROW +# define __MATHCALL_NARROW(func, redir, nargs) \ + __MATHCALL_NARROW_REDIR (func, redir, nargs) +# elif __HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL +# define __MATHCALL_REDIR_NAME(name) __ ## f64 ## name ## ieee128 +# undef __MATHCALL_NARROW # define __MATHCALL_NARROW(func, redir, nargs) \ __MATHCALL_NARROW_REDIR (func, redir, nargs) # endif @@ -786,7 +845,8 @@ extern int signgam; # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME -# ifdef __LDBL_COMPAT +# if defined __LDBL_COMPAT \ + || (__HAVE_DISTINCT_FLOAT128 && !__HAVE_FLOAT128_UNLIKE_LDBL) # undef __MATHCALL_REDIR_NAME # undef __MATHCALL_NARROW # define __MATHCALL_NARROW(func, redir, nargs) \ diff --git a/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h b/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h index 60c54cca46..f54e5d9ddb 100644 --- a/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h +++ b/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h @@ -50,7 +50,11 @@ extern "C++" { inline int iscanonical (float __val) { return __iscanonicalf (__val); } inline int iscanonical (double __val) { return __iscanonical (__val); } inline int iscanonical (long double __val) { return __iscanonicall (__val); } -# if __HAVE_DISTINCT_FLOAT128 +/* When using an IEEE 128-bit long double, _Float128 is defined as long double + in C++. */ +# if __HAVE_DISTINCT_FLOAT128 \ + && (!defined __cplusplus \ + || defined __cplusplus && __HAVE_FLOAT128_UNLIKE_LDBL) inline int iscanonical (_Float128 __val) { return __iscanonicalf128 (__val); } # endif }