From patchwork Fri May 22 10:58:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco X-Patchwork-Id: 475544 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 5C3A91402BD for ; Fri, 22 May 2015 20:58:43 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=sourceware.org header.i=@sourceware.org header.b=hgrCsQK3; dkim-atps=neutral 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:references:in-reply-to:subject:date :message-id:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=Qk7iMmh9eWTvZC23A/tJddkWaWhytpVSE8NK1qkzyq0 PM7Z/rI7VADqMX5Ttd0q/6EgQ+KrPKqg+QGXbbSIrHenPrahRPCElgP+QtbEVNbJ j671zao2vZQAzABiY+rF60wvTBlfGdVhZX7i0cLJaWP21p1snD1lNAWqK9+d6LCk = 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:references:in-reply-to:subject:date :message-id:mime-version:content-type:content-transfer-encoding; s=default; bh=BmeDIXyOe9YgueMbg064SFVunuM=; b=hgrCsQK3v9QSv48FE SPNSQMy05KJS39wsS1qAQ8F8MTgp4pfxY0AAR+5UFHlu6+8GwaUw0fFtS9PuyPlC gKemh14hL3nR02erGecrqrhDKgNTHVUI8mizxpRS41KO2/C/2BY7yVMF4NEbJnZ6 atVL/iKPK3q/84Hm/bgLF7vJiU= Received: (qmail 62668 invoked by alias); 22 May 2015 10:58:37 -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 62657 invoked by uid 89); 22 May 2015 10:58:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com From: "Wilco Dijkstra" To: "'Joseph Myers'" Cc: References: <000001d07775$77c71880$67554980$@com> <000001d080d7$830485a0$890d90e0$@com> In-Reply-To: Subject: RE: [PATCH][AArch64] Add inlines for signbit (v2) Date: Fri, 22 May 2015 11:58:26 +0100 Message-ID: <000801d0947e$3af04780$b0d0d680$@com> MIME-Version: 1.0 X-MC-Unique: hiKsoz6SRMW84RHeFzg1ew-1 > Joseph Myers wrote: > On Mon, 27 Apr 2015, Wilco Dijkstra wrote: > > > > Joseph Myers wrote: > > > On Wed, 15 Apr 2015, Wilco Dijkstra wrote: > > > > > > > Is there a reason this couldn't be done by default in math.h similar to isgreater > (unlike > > > > __builtin_isinf et al, GCC implements signbit efficiently and correctly). > > > > > > It is, however, not type-generic in GCC > > > , so you'd still need > > > to have a macro expansion checking sizeof. > > > > Yes indeed. However the issue is how to deal with the targets that currently > > define inlines. Would it be reasonable just to leave them and add a signbit > > expansion for GCC >= 3.0 that directly uses the builtins? > > (if we define __signbit(f/l) to be __builtin_signbit(f/l), things may go > > wrong as the various mathinlines don't do an undef first). > > I'd think defining __signbit to __builtin_signbit, etc., would be > appropriate (with conditionals in the mathinline.h files to disable their > local definitions for GCC versions where __builtin_signbit works and is at > least as good for that architecture). It would also cover cases within > glibc that directly use the __signbit etc. names (although arguably those > should move to using the type-generic macros; likewise direct uses of e.g. > __finite, __isnan). OK, I tried that and it works fine without having to change all the targets if I define __signbit at the end of math.h. Add inlining of the __signbit(f/l) functions for all targets using the GCC builtin functions when available. The out-of-line implementations need undefs to ensure the correct symbols are exported. OK for commit? ChangeLog: 2015-05-22 Wilco Dijkstra * math/math.h: (__signbit): Define. (__signbitf): Define. (__signbitl): Define. * sysdeps/ieee754/dbl-64/s_signbit.c: Undef __signbit. * sysdeps/ieee754/flt-32/s_signbitf.c: Undef __signbitf. * sysdeps/ieee754/ldbl-128/s_signbitl.c: Undef __signbitl. * sysdeps/ieee754/ldbl-128ibm/s_signbitl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_signbitl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_signbitl.c: Likewise. --- math/math.h | 7 +++++++ sysdeps/ieee754/dbl-64/s_signbit.c | 3 ++- sysdeps/ieee754/flt-32/s_signbitf.c | 3 ++- sysdeps/ieee754/ldbl-128/s_signbitl.c | 3 ++- sysdeps/ieee754/ldbl-128ibm/s_signbitl.c | 2 ++ sysdeps/ieee754/ldbl-64-128/s_signbitl.c | 1 + sysdeps/ieee754/ldbl-96/s_signbitl.c | 3 ++- 7 files changed, 18 insertions(+), 4 deletions(-) diff --git a/math/math.h b/math/math.h index 7e959fc..1262f49 100644 --- a/math/math.h +++ b/math/math.h @@ -493,6 +493,13 @@ extern int matherr (struct exception *__exc); fpclassify (__u) == FP_NAN || fpclassify (__v) == FP_NAN; })) # endif +# if __GNUC_PREREQ (4,0) +# undef __signbitl +# define __signbit(x) __builtin_signbit(x) +# define __signbitf(x) __builtin_signbitf(x) +# define __signbitl(x) __builtin_signbitl(x) +# endif + #endif __END_DECLS diff --git a/sysdeps/ieee754/dbl-64/s_signbit.c b/sysdeps/ieee754/dbl-64/s_signbit.c index 764f11a..e78e998 100644 --- a/sysdeps/ieee754/dbl-64/s_signbit.c +++ b/sysdeps/ieee754/dbl-64/s_signbit.c @@ -18,9 +18,10 @@ . */ #include - #include +#undef __signbit + int __signbit (double x) { diff --git a/sysdeps/ieee754/flt-32/s_signbitf.c b/sysdeps/ieee754/flt-32/s_signbitf.c index 169820e..dccf0c7 100644 --- a/sysdeps/ieee754/flt-32/s_signbitf.c +++ b/sysdeps/ieee754/flt-32/s_signbitf.c @@ -18,9 +18,10 @@ . */ #include - #include +#undef __signbitf + int __signbitf (float x) { diff --git a/sysdeps/ieee754/ldbl-128/s_signbitl.c b/sysdeps/ieee754/ldbl-128/s_signbitl.c index acfe859..25c0bc7 100644 --- a/sysdeps/ieee754/ldbl-128/s_signbitl.c +++ b/sysdeps/ieee754/ldbl-128/s_signbitl.c @@ -18,9 +18,10 @@ . */ #include - #include +#undef __signbitl + int __signbitl (long double x) { diff --git a/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c b/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c index e95ad55..39102d2 100644 --- a/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c +++ b/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c @@ -21,6 +21,8 @@ #include #include +#undef __signbitl + int ___signbitl (long double x) { diff --git a/sysdeps/ieee754/ldbl-64-128/s_signbitl.c b/sysdeps/ieee754/ldbl-64-128/s_signbitl.c index 850db73..9955ecf 100644 --- a/sysdeps/ieee754/ldbl-64-128/s_signbitl.c +++ b/sysdeps/ieee754/ldbl-64-128/s_signbitl.c @@ -1,6 +1,7 @@ #include #undef weak_alias #define weak_alias(n,a) +#undef __signbitl #define __signbitl(arg) ___signbitl(arg) #include #undef __signbitl diff --git a/sysdeps/ieee754/ldbl-96/s_signbitl.c b/sysdeps/ieee754/ldbl-96/s_signbitl.c index bbe72a6..5e7a0d7 100644 --- a/sysdeps/ieee754/ldbl-96/s_signbitl.c +++ b/sysdeps/ieee754/ldbl-96/s_signbitl.c @@ -18,9 +18,10 @@ . */ #include - #include +#undef __signbitl + int __signbitl (long double x) {