From patchwork Wed Jun 6 22:39:08 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: 926065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-92972-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="XurO9Sd4"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 411Nxh2pKLz9rxs for ; Thu, 7 Jun 2018 08:43:36 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=uyw7Xe5TejWM+d3vRwKv5e7H5BFQJAo 4q1SkEmC6AwEc85s6B9XQ7QlfhsFxzpGs07piS8E/yKGkH7Qb3gpI6gHVI0DzYyn 1G1+G41Xal5UmtV+QQbrc7vCwCLNrll2j2+P/jlIfE+EiTxB2WJ2J/lTIPCaiBcn ptf01kmwXZx0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:in-reply-to:references :message-id; s=default; bh=rW6Bx2qjrjBcySQSYm+2sKas23U=; b=XurO9 Sd4TbIrsCklkbUth0c+sFvTjJfkW2qqlOjElIOkdBOZmAWo/d1mDiP8vSOyVNTIr aZFcAXGTLvgBnQhXpKLjZcCmVh3ctvtFshxUw+Ewy1IjyVVPTS9BcIuE0glOtJ2F OLplsLBu3DpGp6Bd1axTZ2ZY+kCBG0SbB19lGY= Received: (qmail 84719 invoked by alias); 6 Jun 2018 22:42:50 -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 83430 invoked by uid 89); 6 Jun 2018 22:42:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, 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, 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, 6 Jun 2018 19:39:08 -0300 In-Reply-To: <20180606223909.16675-1-tuliom@linux.ibm.com> References: <20180606223909.16675-1-tuliom@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18060622-0016-0000-0000-000008E84BBD X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009139; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000265; SDB=6.01043027; UDB=6.00534142; IPR=6.00822157; MB=3.00021491; MTD=3.00000008; XFM=3.00000015; UTC=2018-06-06 22:42:27 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18060622-0017-0000-0000-00003F2594B4 Message-Id: <20180606223909.16675-9-tuliom@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-06_10:, , signatures=0 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 * 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 --- 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 # include + +/* 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 +/* 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 }