From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 43709 invoked by alias); 9 Aug 2015 06:27:16 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 43679 invoked by uid 89); 9 Aug 2015 06:27:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-wi0-f178.google.com Received: from mail-wi0-f178.google.com (HELO mail-wi0-f178.google.com) (209.85.212.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 09 Aug 2015 06:27:13 +0000 Received: by wibxm9 with SMTP id xm9so111659466wib.1; Sat, 08 Aug 2015 23:27:10 -0700 (PDT) X-Received: by 10.194.85.130 with SMTP id h2mr34441276wjz.2.1439101630533; Sat, 08 Aug 2015 23:27:10 -0700 (PDT) Received: from pc86.home (ALyon-654-1-395-242.w109-213.abo.wanadoo.fr. [109.213.227.242]) by smtp.gmail.com with ESMTPSA id yz10sm22859344wjc.0.2015.08.08.23.27.09 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 08 Aug 2015 23:27:09 -0700 (PDT) Content-Type: multipart/mixed; boundary="Apple-Mail=_932B0791-CC6B-4668-8831-6ED7EE2CCE0F" Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\)) Subject: Re: [libquadmath, patch] Add logbq() to libquadmath From: FX In-Reply-To: Date: Sun, 09 Aug 2015 06:27:00 -0000 Cc: gfortran , Tobias Burnus , Jakub Jelinek Message-Id: <4CDF46E0-35E0-48D0-A4EA-C90D79959AB2@gmail.com> References: To: gcc-patches X-SW-Source: 2015-08/txt/msg00427.txt.bz2 --Apple-Mail=_932B0791-CC6B-4668-8831-6ED7EE2CCE0F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Content-length: 451 ping In the apparent absence of the libquadmath maintainers, could a global revi= ewer approve this rather simple patch, please? =20 > The attached patch adds logbq() to libquadmath, with code lifted from gli= bc. > It is made necessary by an upcoming patch for gfortran, adding full suppo= rt for the IEEE modules on __float128, and requires logbq(). >=20 > Bootstrapped and regtested on x86_64-apple-darwin14. > OK to commit to trunk? >=20 > FX --Apple-Mail=_932B0791-CC6B-4668-8831-6ED7EE2CCE0F Content-Disposition: attachment; filename=logbq.diff Content-Type: application/octet-stream; name="logbq.diff" Content-Transfer-Encoding: 7bit Content-length: 4004 Index: Makefile.am =================================================================== --- Makefile.am (revision 226429) +++ Makefile.am (working copy) @@ -57,7 +57,7 @@ libquadmath_la_SOURCES = \ math/erfq.c math/logq.c math/sqrtq.c math/expm1q.c math/lroundq.c \ math/tanhq.c math/expq.c math/modfq.c math/tanq.c math/fabsq.c \ math/nanq.c math/tgammaq.c math/finiteq.c math/nextafterq.c \ - math/truncq.c math/floorq.c math/powq.c math/fmaq.c \ + math/truncq.c math/floorq.c math/powq.c math/fmaq.c math/logbq.c \ math/cacoshq.c math/cacosq.c math/casinhq.c math/casinq.c \ math/catanhq.c math/catanq.c math/cimagq.c math/conjq.c math/cprojq.c \ math/crealq.c math/fdimq.c math/fmaxq.c math/fminq.c math/ilogbq.c \ Index: libquadmath.texi =================================================================== --- libquadmath.texi (revision 226429) +++ libquadmath.texi (working copy) @@ -180,6 +180,7 @@ The following mathematical functions are @item @code{lgammaq}: logarithmic gamma function @item @code{llrintq}: round to nearest integer value @item @code{llroundq}: round to nearest integer value away from zero +@item @code{logbq}: get exponent of the value @item @code{logq}: natural logarithm function @item @code{log10q}: base 10 logarithm function @item @code{log1pq}: compute natural logarithm of the value plus one Index: math/logbq.c =================================================================== --- math/logbq.c (revision 0) +++ math/logbq.c (working copy) @@ -0,0 +1,47 @@ +/* s_logbl.c -- long double version of s_logb.c. + * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * long double logbl(x) + * IEEE 754 logb. Included to pass IEEE test suite. Not recommend. + * Use ilogb instead. + */ + +#include "quadmath-imp.h" + +__float128 +logbq (__float128 x) +{ + int64_t lx, hx, ex; + + GET_FLT128_WORDS64 (hx, lx, x); + hx &= 0x7fffffffffffffffLL; /* high |x| */ + if ((hx | lx) == 0) + return -1.0 / fabsq (x); + if (hx >= 0x7fff000000000000LL) + return x * x; + if ((ex = hx >> 48) == 0) /* IEEE 754 logb */ + { + /* POSIX specifies that denormal number is treated as + though it were normalized. */ + int ma; + if (hx == 0) + ma = __builtin_clzll (lx) + 64; + else + ma = __builtin_clzll (hx); + ex -= ma - 16; + } + return (__float128) (ex - 16383); +} Index: quadmath.h =================================================================== --- quadmath.h (revision 226429) +++ quadmath.h (working copy) @@ -76,6 +76,7 @@ extern __float128 ldexpq (__float128, in extern __float128 lgammaq (__float128) __quadmath_throw; extern long long int llrintq (__float128) __quadmath_throw; extern long long int llroundq (__float128) __quadmath_throw; +extern __float128 logbq (__float128) __quadmath_throw; extern __float128 logq (__float128) __quadmath_throw; extern __float128 log10q (__float128) __quadmath_throw; extern __float128 log2q (__float128) __quadmath_throw; Index: quadmath.map =================================================================== --- quadmath.map (revision 226429) +++ quadmath.map (working copy) @@ -96,3 +96,8 @@ QUADMATH_1.0 { local: *; }; + +QUADMATH_1.1 { + global: + logbq; +} QUADMATH_1.0; Index: quadmath_weak.h =================================================================== --- quadmath_weak.h (revision 226429) +++ quadmath_weak.h (working copy) @@ -72,6 +72,7 @@ __qmath3 (ldexpq) __qmath3 (lgammaq) __qmath3 (llrintq) __qmath3 (llroundq) +__qmath3 (logbq) __qmath3 (logq) __qmath3 (log10q) __qmath3 (log1pq) --Apple-Mail=_932B0791-CC6B-4668-8831-6ED7EE2CCE0F Content-Disposition: attachment; filename=logbq.ChangeLog Content-Type: application/octet-stream; name="logbq.ChangeLog" Content-Transfer-Encoding: 7bit Content-length: 301 2015-08-03 Francois-Xavier Coudert * Makefile.am (libquadmath_la_SOURCES): * Makefile.in: Regenerate. * libquadmath.texi: Document logbq. * quadmath.h: Add logbq prototype. * quadmath.map: Add logbq. * quadmath_weak.h: Add logbq prototype. * math/logbq.c: New file --Apple-Mail=_932B0791-CC6B-4668-8831-6ED7EE2CCE0F--