From patchwork Fri Feb 14 16:10:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 1238151 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-109740-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=QDcDG7Sk; 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 48Jyzv38D8z9sTv for ; Sat, 15 Feb 2020 03:11:23 +1100 (AEDT) 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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=UkV8QAYQmABzcmV7k43KiPZUeRCH9syFISB3MCrE5kPCK9kTkt9uQ Tnhpksefw1si81H33JONe2Z75yAeJsvAvcmb5chJBvA/G7PCwiFLv31I8nQBTn0t mpdjb3MgOGqzU/VVIi9ve6Mp098+N40Sgv2KSvHI/DbN2py4wwqaVQ= 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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=UJpE6xE+zi2FVBXq/j4X+Imp0i8=; b=QDcDG7Skrv/QELp4CensOmoGkiKv KzdnlMR5AKlYX6giI13UI5NidfQpJl+bLOAf0fRqj3COjr/96oMV83JCouQbhylp qmtOIfoPVbQ4YmTuSckq02NtxhaflMOzFC6lyymTPAeDdxqWvBemzaGYsEswEWOa juy/n9mRar7XtV8= Received: (qmail 62279 invoked by alias); 14 Feb 2020 16:11:00 -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 62181 invoked by uid 89); 14 Feb 2020 16:11:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.8 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 autolearn=ham version=3.3.1 spammy=Gabriel, gabriel, helped, UD:float.h X-HELO: mx0a-001b2d01.pphosted.com From: "Paul E. Murphy" To: libc-alpha@sourceware.org Subject: [PATCH 1/7] ldbl-128ibm-compat: Provide nexttoward functions Date: Fri, 14 Feb 2020 10:10:45 -0600 Message-Id: <20200214161051.32579-2-murphyp@linux.vnet.ibm.com> In-Reply-To: <20200214161051.32579-1-murphyp@linux.vnet.ibm.com> References: <20200214161051.32579-1-murphyp@linux.vnet.ibm.com> MIME-Version: 1.0 From: "Gabriel F. T. Gomes" The functions in the nexttoward family are special, in the sense that they always have a long double argument, regardless of their suffix (i.e.: nexttowardf and nexttoward have a long double argument, besides the float and double arguments). On top of that, they are also special because nexttoward functions are not part of the _FloatN API, hence __nexttowardf128 do not exist. This patch adds 4 new function implementations for the new long double format: __nexttoward_to_ieee128 __nexttowardf_to_ieee128 __nexttowardieee128 (as an alias to __nextafterieee128) Likewise, rename "long double" "_Float128" in shared ldbl-128 files to ensure correct type is used irrespective of ABI switches. Thank you to those who helped out with this patch: Gabriel F. T. Gomes Tulio Magno Quites Machado Filho Reviewed-by: Tulio Magno Quites Machado Filho --- sysdeps/ieee754/ldbl-128/s_nexttoward.c | 4 +- sysdeps/ieee754/ldbl-128/s_nexttowardf.c | 4 +- sysdeps/ieee754/ldbl-128ibm-compat/Versions | 3 ++ .../ldbl-128ibm-compat/s_nextafterf128.c | 20 ++++++++++ .../ldbl-128ibm-compat/s_nexttowardf128.c | 38 +++++++++++++++++++ 5 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/s_nextafterf128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/s_nexttowardf128.c diff --git a/sysdeps/ieee754/ldbl-128/s_nexttoward.c b/sysdeps/ieee754/ldbl-128/s_nexttoward.c index 6db8b7f15f..e8c25f51b7 100644 --- a/sysdeps/ieee754/ldbl-128/s_nexttoward.c +++ b/sysdeps/ieee754/ldbl-128/s_nexttoward.c @@ -31,7 +31,7 @@ static char rcsid[] = "$NetBSD: $"; #include #include -double __nexttoward(double x, long double y) +double __nexttoward(double x, _Float128 y) { int32_t hx,ix; int64_t hy,iy; @@ -47,7 +47,7 @@ double __nexttoward(double x, long double y) ((iy>=0x7fff000000000000LL)&&((iy-0x7fff000000000000LL)|ly)!=0)) /* y is nan */ return x+y; - if((long double) x==y) return y; /* x=y, return y */ + if((_Float128) x==y) return y; /* x=y, return y */ if((ix|lx)==0) { /* x == 0 */ double u; INSERT_WORDS(x,(uint32_t)((hy>>32)&0x80000000),1);/* return +-minsub */ diff --git a/sysdeps/ieee754/ldbl-128/s_nexttowardf.c b/sysdeps/ieee754/ldbl-128/s_nexttowardf.c index 7840cb382e..7770c4256d 100644 --- a/sysdeps/ieee754/ldbl-128/s_nexttowardf.c +++ b/sysdeps/ieee754/ldbl-128/s_nexttowardf.c @@ -23,7 +23,7 @@ static char rcsid[] = "$NetBSD: $"; #include #include -float __nexttowardf(float x, long double y) +float __nexttowardf(float x, _Float128 y) { int32_t hx,ix; int64_t hy,iy; @@ -38,7 +38,7 @@ float __nexttowardf(float x, long double y) ((iy>=0x7fff000000000000LL)&&((iy-0x7fff000000000000LL)|ly)!=0)) /* y is nan */ return x+y; - if((long double) x==y) return y; /* x=y, return y */ + if((_Float128) x==y) return y; /* x=y, return y */ if(ix==0) { /* x == 0 */ float u; SET_FLOAT_WORD(x,(uint32_t)((hy>>32)&0x80000000)|1);/* return +-minsub*/ diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index 7224e1ddc7..07e6a5b08a 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -91,6 +91,9 @@ libm { __nearbyintieee128; __nextafterieee128; __nextdownieee128; + __nexttowardf_to_ieee128; + __nexttowardieee128; + __nexttoward_to_ieee128; __nextupieee128; __powieee128; __remainderieee128; diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/s_nextafterf128.c b/sysdeps/ieee754/ldbl-128ibm-compat/s_nextafterf128.c new file mode 100644 index 0000000000..cc30ae02d7 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/s_nextafterf128.c @@ -0,0 +1,20 @@ +/* Provide nexttowardl and nextafterl implementations for IEEE long double. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ +#include "../float128/s_nextafterf128.c" + +strong_alias (__nextafterieee128, __nexttowardieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/s_nexttowardf128.c b/sysdeps/ieee754/ldbl-128ibm-compat/s_nexttowardf128.c new file mode 100644 index 0000000000..0b4204cf64 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/s_nexttowardf128.c @@ -0,0 +1,38 @@ +/* Provide nexttoward[|f] implementations for IEEE long double. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* Build nexttoward functions with binary128 format. */ +#undef weak_alias +#define weak_alias(from, to) +#undef libm_alias_ldouble +#define libm_alias_ldouble(from, to) +#undef __nexttoward +#define __nexttoward __nexttoward_to_ieee128 +#include + +#undef weak_alias +#define weak_alias(from, to) +#undef libm_alias_ldouble +#define libm_alias_ldouble(from, to) +#undef __nexttowardf +#define __nexttowardf __nexttowardf_to_ieee128 +#include + +#include From patchwork Fri Feb 14 16:10:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 1238150 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-109739-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=MKSq2d9J; 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 48Jyzk4f34z9sTx for ; Sat, 15 Feb 2020 03:11:14 +1100 (AEDT) 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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=imDMmMptDtIpo28IPHa+IP9ugZ+PQH12Jr6F/G3VXVPfY0PNtH/on WTzjsSFFlWULo6ju+zmUt8p4EEj161Sgs9xAgBUzzDzamah2UUcGdxEWmCTsxycL GTS86Q0Rz/jjWOto5V+dUb465ZTRNzbFRgBPJCric/+lM1gYD8OPSc= 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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=h9QfBWLqaw9Vx1px40PF228T4Gk=; b=MKSq2d9JOk4ufICe4q7W2ZRzvvQJ zaseVaT1yH3gYxsS6faquc+RfSwf6Nn+fzYejHSVqp63yWkxN+jN4rw6GM2JeHIY AoqyDszGTJVv5P/EECFgvPhJxbwhrPtNSbXwzTGIPXC3Yn5fztNfvvXS3yoSw+f/ dvxHquSt0Mdez/g= Received: (qmail 62228 invoked by alias); 14 Feb 2020 16:11:00 -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 62156 invoked by uid 89); 14 Feb 2020 16:10:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=r, HX-Languages-Length:1179, HContent-Transfer-Encoding:8bit X-HELO: mx0a-001b2d01.pphosted.com From: "Paul E. Murphy" To: libc-alpha@sourceware.org Subject: [PATCH 2/7] ldbl-128ibm-compat: enforce correct abi flags on internal file Date: Fri, 14 Feb 2020 10:10:46 -0600 Message-Id: <20200214161051.32579-3-murphyp@linux.vnet.ibm.com> In-Reply-To: <20200214161051.32579-1-murphyp@linux.vnet.ibm.com> References: <20200214161051.32579-1-murphyp@linux.vnet.ibm.com> MIME-Version: 1.0 A number of utility files and helper objects should also be explicitly configured to build with the ibm128 ABI to prevent gremlins when enabling IEEE long double. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 7efbd00089..2dceb658e7 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -338,6 +338,17 @@ ldbl-ibm128-files := $(objpfx)test-%-ibm128^ \ $(objpfx)iovswscanf^ \ $(objpfx)iovfscanf^ \ $(objpfx)iovfwscanf^ \ + $(objpfx)mpn2ldbl^ \ + $(objpfx)ldbl2mpn^ \ + $(objpfx)strtold_nan^ \ + $(objpfx)strtold_l^ \ + $(objpfx)strtold^ \ + $(objpfx)strfroml^ \ + $(objpfx)wcstold_nan^ \ + $(objpfx)wcstold_l^ \ + $(objpfx)wcstold^ \ + $(objpfx)printf_fphex^ \ + $(objpfx)printf_fp^ \ $(foreach r,$(ldbl-extra-routines),$(objpfx)$(r)^) \ $(foreach r,$(ldbl-extra-routines),$(objpfx)$(r)-internal^) obj-suf-foreach = $(foreach suf,$(all-object-suffixes),$(subst ^,$(suf),$(1))) From patchwork Fri Feb 14 16:10:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 1238153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-109742-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=hnir847h; 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 48Jz0K0JzHz9sXM for ; Sat, 15 Feb 2020 03:11:44 +1100 (AEDT) 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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=c0rwtkta2XRPLaOtkuwWvGCbzTUNYGju7pff88oxkG6kHYBl94Y9K AFqS7QbVROWOjRHkkl4wr2i00OHHio0OV/dknzVMNSEUkjOEfwquYoZf9pns04DZ NnObnServil7UsbuSjrX3HN9KDJgkQa2XcQn2zTl7gaZWXQkLMwuOc= 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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=88iY+gnMZl1b7qzDtAPtr3BT9i4=; b=hnir847hTHSZYf8JLGiy8f86+Hd8 glnyF8d4tYBoUp9QgKiyFKJ9WbEZOfLqskUA8MXvoQN63qAJO86aia6KwmrCPjGX vlN34/PdmXjb9VoXAVsIk8Ry31WHTyzv6MViVBFkvuK+d7kT4pe6if3WuFBT5+An 0MBHrpHrZwWSeMc= Received: (qmail 62691 invoked by alias); 14 Feb 2020 16:11:03 -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 62600 invoked by uid 89); 14 Feb 2020 16:11:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 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 autolearn=ham version=3.3.1 spammy=makefiles, Makefiles X-HELO: mx0a-001b2d01.pphosted.com From: "Paul E. Murphy" To: libc-alpha@sourceware.org Subject: [PATCH 3/7] ldbl-128ibm-compat: Add tests for IBM long double functions Date: Fri, 14 Feb 2020 10:10:47 -0600 Message-Id: <20200214161051.32579-4-murphyp@linux.vnet.ibm.com> In-Reply-To: <20200214161051.32579-1-murphyp@linux.vnet.ibm.com> References: <20200214161051.32579-1-murphyp@linux.vnet.ibm.com> MIME-Version: 1.0 From: Rajalakshmi Srinivasaraghavan This patch creates test-ibm128* tests from the long double function tests. In order to explicitly test IBM long double functions -mabi=ibmlongdouble is added to CFLAGS. Likewise, update the test headers to correct choose ULPs when redirects are enabled. Additional work-credits to: Tulio Magno Quites Machado Filho --- math/Makefile | 7 ++- math/test-float128.h | 2 +- math/test-float64x.h | 2 +- math/test-ibm128.h | 19 +++++++ math/test-ldouble.h | 6 +++ sysdeps/ieee754/ldbl-128ibm-compat/Makeconfig | 3 ++ sysdeps/powerpc/powerpc64/le/Makefile | 50 ++++++++++++++++--- 7 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 math/test-ibm128.h create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/Makeconfig diff --git a/math/Makefile b/math/Makefile index 1d203e7ad5..84a8b94c74 100644 --- a/math/Makefile +++ b/math/Makefile @@ -145,10 +145,15 @@ type-float128-yes := float128 # _Float64x may be supported, only as an alias type. type-float64x-yes := float64x +# IBM long double support in additional to IEEE 128 long double support +type-ibm128-suffix := l +type-ibm128-yes := ibm128 + types = $(types-basic) $(type-float128-$(float128-fcts)) test-types = $(test-types-basic) $(type-float128-$(float128-fcts)) \ float32 float64 $(type-float128-$(float128-alias-fcts)) \ - float32x $(type-float64x-$(float64x-alias-fcts)) + float32x $(type-float64x-$(float64x-alias-fcts)) \ + $(type-ibm128-$(ibm128-fcts)) # Pairs of types for which narrowing functions should be tested (this # variable has more entries than libm-narrow-types because it includes diff --git a/math/test-float128.h b/math/test-float128.h index 8f9eec14aa..07945a090b 100644 --- a/math/test-float128.h +++ b/math/test-float128.h @@ -28,7 +28,7 @@ #define CFLOAT __CFLOAT128 #define BUILD_COMPLEX(real, imag) (CMPLXF128 ((real), (imag))) #define PREFIX FLT128 -#if FLT128_MANT_DIG == LDBL_MANT_DIG +#if __LONG_DOUBLE_USES_FLOAT128 == 0 && FLT128_MANT_DIG == LDBL_MANT_DIG # define TYPE_STR "ldouble" # define ULP_IDX ULP_LDBL # define ULP_I_IDX ULP_I_LDBL diff --git a/math/test-float64x.h b/math/test-float64x.h index 9543238209..f8e7ef2f66 100644 --- a/math/test-float64x.h +++ b/math/test-float64x.h @@ -28,7 +28,7 @@ #define CFLOAT __CFLOAT64X #define BUILD_COMPLEX(real, imag) (CMPLXF64X ((real), (imag))) #define PREFIX FLT64X -#if FLT64X_MANT_DIG == LDBL_MANT_DIG +#if __LONG_DOUBLE_USES_FLOAT128 == 0 && FLT64X_MANT_DIG == LDBL_MANT_DIG # define TYPE_STR "ldouble" # define ULP_IDX ULP_LDBL # define ULP_I_IDX ULP_I_LDBL diff --git a/math/test-ibm128.h b/math/test-ibm128.h new file mode 100644 index 0000000000..cd67fd1493 --- /dev/null +++ b/math/test-ibm128.h @@ -0,0 +1,19 @@ +/* Common definitions for libm tests for ibm long double. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include "test-ldouble.h" diff --git a/math/test-ldouble.h b/math/test-ldouble.h index 17c526bd71..c0a7a94cc1 100644 --- a/math/test-ldouble.h +++ b/math/test-ldouble.h @@ -27,6 +27,12 @@ # define TYPE_STR "double" # define ULP_IDX ULP_DBL # define ULP_I_IDX ULP_I_DBL +#elif __LONG_DOUBLE_USES_FLOAT128 == 1 +# define TYPE_STR "float128" +# define ULP_IDX ULP_FLT128 +# define ULP_I_IDX ULP_I_FLT128 +/* _Float128 unconditionally redirects to lgamma. Ensure the ULPs do too. */ +# define gamma lgamma #else # define TYPE_STR "ldouble" # define ULP_IDX ULP_LDBL diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makeconfig b/sysdeps/ieee754/ldbl-128ibm-compat/Makeconfig new file mode 100644 index 0000000000..997f632319 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makeconfig @@ -0,0 +1,3 @@ +# Include this earlier so it can be used earlier in Makefiles, +# and sysdep/ makefiles. +ibm128-fcts = yes diff --git a/sysdeps/powerpc/powerpc64/le/Makefile b/sysdeps/powerpc/powerpc64/le/Makefile index 0ce3868c3c..1594f6b179 100644 --- a/sysdeps/powerpc/powerpc64/le/Makefile +++ b/sysdeps/powerpc/powerpc64/le/Makefile @@ -6,6 +6,13 @@ # linked executables, forcing to link the loader after libgcc link. f128-loader-link = -Wl,--as-needed $(elf-objpfx)ld.so -Wl,--no-as-needed +# Bootstrapping code for enabling IEEE 128. This can be removed and +# any indirections simplified once IEEE 128 long double is enabled. +type-ldouble-CFLAGS = +ifeq ($(ibm128-fcts),yes) +type-ldouble-CFLAGS += -mabi=ibmlongdouble +endif + ifeq ($(subdir),math) # sqrtf128 requires emulation before POWER9. CPPFLAGS += -I../soft-fp @@ -28,13 +35,34 @@ CFLAGS-test-math-iscanonical.cc += -mfloat128 CFLAGS-test-math-iseqsig.cc += -mfloat128 CFLAGS-test-math-issignaling.cc += -mfloat128 CFLAGS-test-math-iszero.cc += -mfloat128 -$(foreach test, \ - test-float128% test-ifloat128% test-float64x% test-ifloat64x% \ - $(foreach pair,$(f128-pairs),test-$(pair)%) \ - test-math-iscanonical test-math-iseqsig test-math-issignaling \ - test-math-iszero, \ - $(objpfx)$(test)): \ +$(foreach test,\ + basic-test \ + bug-nextafter \ + bug-nexttoward \ + test-fenv-clear \ + test-iszero-excess-precision \ + test-math-iscanonical \ + test-math-iseqsig \ + test-math-issignaling \ + test-math-iszero \ + test-misc \ + test-nan-overflow \ + test-nan-payload \ + test-snan \ + test-tgmath \ + test-tgmath2 \ + tst-CMPLX2 \ + test-%-ldbl-128ibm \ + test-ldouble% test-ildouble% \ + test-float128% test-ifloat128% \ + test-float64x% test-ifloat64x% \ + ,$(objpfx)$(test)): \ gnulib-tests += $(f128-loader-link) + +$(foreach suf,$(all-object-suffixes),\ + $(objpfx)libm-test-%ibm128$(suf) \ + $(objpfx)test-iibm128%$(suf) $(objpfx)test-ibm128%$(suf)): \ + CFLAGS += $(type-ldouble-CFLAGS) endif # Append flags to string <-> _Float128 routines. @@ -82,3 +110,13 @@ CFLAGS-printf_fp.c = -mfloat128 CFLAGS-printf_fphex.c = -mfloat128 CFLAGS-printf_size.c = -mfloat128 endif + +$(foreach suf,$(all-object-suffixes),nldbl-%$(suf)): \ + CFLAGS += $(type-ldouble-CFLAGS) + +sysdep-CFLAGS += -mabi=ieeelongdouble -Wno-psabi +$(foreach suf,$(all-object-suffixes),\ + $(objpfx)libm-test-%ibm128$(suf) \ + $(objpfx)test-iibm128%$(suf) $(objpfx)test-ibm128%$(suf)): \ + sysdep-CFLAGS := $(filter-out -mabi=ieeelongdouble \ + -Wno-psabi, $(sysdep-CFLAGS)) From patchwork Fri Feb 14 16:10:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 1238152 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-109741-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=ipNg0fMH; 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 48Jz072ld0z9sSH for ; Sat, 15 Feb 2020 03:11:35 +1100 (AEDT) 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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=kjVBbztFfocyJptHx5RBcfHFr3u7wuzmQsEDiGWR09/asXLm7WowN gPT9Ik3lNnpIbOMXnhDKI755DVsxZ4zexPp07usVvV+MVL2pvohW8KT9Yv7tVzDG taK7MVWy7jfIVUpX/0A5AEBKNmtEEXD2LZDTtyJQRDGw3rIFSAxVks= 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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=2WnCxO3lavFKtNo5pB8ZJ/Z8BeY=; b=ipNg0fMHymoj6Bw8w0ldhESkDixk d9sbdQczAeoVhkVZnlbYsH5i1KMFfRlXg8H3K4BMCRYmqCesFTu98CxCd0MtKMzM 939WqJP4UkeXiNB/b2C/lG0wEKZ4UWMt3uEAC6RORig8uot14RIvioe32wO8Ujeg 1nIWAFa6Q/Aww7I= Received: (qmail 62635 invoked by alias); 14 Feb 2020 16:11:03 -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 62547 invoked by uid 89); 14 Feb 2020 16:11:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=misplaced, HContent-Transfer-Encoding:8bit X-HELO: mx0b-001b2d01.pphosted.com From: "Paul E. Murphy" To: libc-alpha@sourceware.org Subject: [PATCH 4/7] ldbl-128ibm-compat: fixup subdir location of several funcs Date: Fri, 14 Feb 2020 10:10:48 -0600 Message-Id: <20200214161051.32579-5-murphyp@linux.vnet.ibm.com> In-Reply-To: <20200214161051.32579-1-murphyp@linux.vnet.ibm.com> References: <20200214161051.32579-1-murphyp@linux.vnet.ibm.com> MIME-Version: 1.0 We want to ensure that if a second file is built to support ieee128 long double, we built it's companion implementation with ibm128 long double. The shared object versions of these files build correctly because the aliasing is sufficiently complex to prevent the redirects from applying when defining them. However, this does not prevent the static object variants from becoming quietly broken due to redirects. This is intentionally avoided by marking such objects to be built with -mabi=ibmlongdouble. Shuffle the misplaced routines to build against the subdir which defines the needed symbols. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 2dceb658e7..e40ae08469 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -1,9 +1,21 @@ ifeq ($(subdir),libio) ldbl-extra-routines += fwscanf \ + fwprintf \ + obprintf \ swscanf \ + swprintf \ wscanf \ + vasprintf \ + vdprintf \ + vscanf \ + vsprintf \ + vsnprintf \ + vsscanf \ + vswprintf \ vswscanf \ - vwscanf + vwprintf \ + vwscanf \ + wprintf endif ifeq ($(subdir),wcsmbs) @@ -29,28 +41,14 @@ ldbl-extra-routines += printf_size \ printf \ snprintf \ sprintf \ - vasprintf \ - vdprintf \ vfprintf \ vprintf \ - vsnprintf \ - vsprintf \ - fwprintf \ - swprintf \ - wprintf \ vfwprintf \ - vswprintf \ - vwprintf \ fscanf \ scanf \ sscanf \ vfscanf \ - vscanf \ - vsscanf \ vfwscanf \ - obprintf \ - obstack_chk \ - vobstack_chk \ isoc99_fscanf \ isoc99_scanf \ isoc99_sscanf \ @@ -211,7 +209,9 @@ ldbl-extra-routines += asprintf_chk \ wprintf_chk \ vfwprintf_chk \ vswprintf_chk \ - vwprintf_chk + vwprintf_chk \ + obstack_chk \ + vobstack_chk tests-internal += test-printf-chk-ieee128 test-printf-chk-ibm128 CFLAGS-test-printf-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi From patchwork Fri Feb 14 16:10:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 1238156 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-109744-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=LrtZoVIt; 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 48Jz0s03wVz9sXP for ; Sat, 15 Feb 2020 03:12:12 +1100 (AEDT) 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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=S53KPj+fhjofQ4x2Z7cjwzz5/IwxpVmumEX3w+za54U2MoX+y5OmW ShvDQAr3yFhEBJQL6/lRpSE/KD46PdW3MatMpyCKd/1pOy8JhbRm59cem2PQwmsV gCsrW40A8jddj/KJLTdAuqTsVLya7xrMAV7yOqP9hMRuzDPq5dg7Ms= 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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=6z7JA9O4o51rLtmulaAoi7ooAU8=; b=LrtZoVItiZrY+Y/5bhlfUnSxKP4Y bPK8itg/FvM1qlpjwYXnJtYWktwDWvkS/UgdEAo47DuosdBOPouL0STvKPyKe/Y6 zTWdqYzPDOOwh7vc2t88FKEkNyZUsLfiMPaAIHjfotNwihi4z6vJ7MmrQgQ3XO+P c2oc37cy1b3/KUY= Received: (qmail 63092 invoked by alias); 14 Feb 2020 16:11:06 -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 62970 invoked by uid 89); 14 Feb 2020 16:11:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1576, tack X-HELO: mx0a-001b2d01.pphosted.com From: "Paul E. Murphy" To: libc-alpha@sourceware.org Subject: [PATCH 5/7] ldbl-128ibm-compat: enforce ibm128 on compat tests Date: Fri, 14 Feb 2020 10:10:49 -0600 Message-Id: <20200214161051.32579-6-murphyp@linux.vnet.ibm.com> In-Reply-To: <20200214161051.32579-1-murphyp@linux.vnet.ibm.com> References: <20200214161051.32579-1-murphyp@linux.vnet.ibm.com> MIME-Version: 1.0 For lack of a more comprehensive solution, tack on the ibm128 ABI compiler options for the totalorder{,mag}l compat tests which exist prior to enabling this feature. Reviewed-by: Tulio Magno Quites Machado Filho --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index e40ae08469..af8027cf0e 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -270,6 +270,7 @@ tests-internal += tst-ibm128-error tst-ieee128-error tests-internal += tst-ibm128-efgcvt tst-ieee128-efgcvt $(objpfx)tst-ieee128-efgcvt: gnulib-tests += $(f128-loader-link) +$(objpfx)tst-ldbl-efgcvt: gnulib-tests += $(f128-loader-link) $(objpfx)tst-ibm128-%.c: tst-ldbl-%.c cp $< $@ @@ -318,6 +319,15 @@ CFLAGS-test-strfrom-ibm128.c += -mabi=ibmlongdouble -Wno-psabi $(objpfx)test-strfrom-ieee128: gnulib-tests += $(f128-loader-link) endif +ifeq ($(subdir),math) +# The totalorder{,mag} compatibility tests were added prior to this +# support. Thus, they can only correctly be used with ibm128. +CFLAGS-test-ldouble-compat_totalorder.c += -mabi=ibmlongdouble +CFLAGS-test-ldouble-compat_totalordermag.c += -mabi=ibmlongdouble +CFLAGS-test-ildouble-compat_totalorder.c += -mabi=ibmlongdouble +CFLAGS-test-ildouble-compat_totalordermag.c += -mabi=ibmlongdouble +endif + # Add IEEE binary128 files as make targets. routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r)) From patchwork Fri Feb 14 16:10:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 1238154 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-109743-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=Puy0N39L; 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 48Jz0V2ZQzz9sV2 for ; Sat, 15 Feb 2020 03:11:54 +1100 (AEDT) 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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=MuUMk9IOedMG2T2rv+8GfZJvDIgoAkY4s7kdHtxxdqP6lVenItxP2 cLYHZWLyCEHT2Fu7OBeRyBBCpCf3QlK51++LIx10ADOPYGQNRf3amRWw9CJazIdd DdwKkdrwun/TKpfqBA+jq0dzC2PP9N3TQwB6cu99/7fk0B/RMbKlzk= 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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=8pbxj0KW410skWrfaeMz8NtO+RQ=; b=Puy0N39L6pzk2OmcHAZlWte3aRmR elrjznDG8WrxdeXE41HoJDn4ddSsLr08MDVrGP6ur3ENFePXNrmjpo5J64dGwg39 UjBwkt4a0MVpvXy2kSKocv5IODhfnETXHTPKoWqJEA93/3ER+zLjB77mWUOC0IZc xj9cS5qiRA0odG8= Received: (qmail 62996 invoked by alias); 14 Feb 2020 16:11:05 -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 62909 invoked by uid 89); 14 Feb 2020 16:11:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=f X-HELO: mx0a-001b2d01.pphosted.com From: "Paul E. Murphy" To: libc-alpha@sourceware.org Subject: [PATCH 6/7] ldbl-128ibm: Let long double files have specific compiler flags Date: Fri, 14 Feb 2020 10:10:50 -0600 Message-Id: <20200214161051.32579-7-murphyp@linux.vnet.ibm.com> In-Reply-To: <20200214161051.32579-1-murphyp@linux.vnet.ibm.com> References: <20200214161051.32579-1-murphyp@linux.vnet.ibm.com> MIME-Version: 1.0 From: Tulio Magno Quites Machado Filho Soon, powerpc64le will need to provide extra compiler flags to the long double files in order to continue to build using the IBM 128-bit extended floating point type as long double. --- sysdeps/ieee754/ldbl-128ibm/Makefile | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/sysdeps/ieee754/ldbl-128ibm/Makefile b/sysdeps/ieee754/ldbl-128ibm/Makefile index bdba6cc6b5..c38d4f6ac2 100644 --- a/sysdeps/ieee754/ldbl-128ibm/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm/Makefile @@ -9,8 +9,24 @@ tests += tst-strtold-ldbl-128ibm $(objpfx)tst-strtold-ldbl-128ibm: $(libm) endif +ldbl-tests = test-fmodl-ldbl-128ibm test-remainderl-ldbl-128ibm \ + test-remquol-ldbl-128ibm test-canonical-ldbl-128ibm \ + test-totalorderl-ldbl-128ibm + ifeq ($(subdir),math) -tests += test-fmodl-ldbl-128ibm test-remainderl-ldbl-128ibm \ - test-remquol-ldbl-128ibm test-canonical-ldbl-128ibm \ - test-totalorderl-ldbl-128ibm +tests += $(ldbl-tests) endif + +# Long double files may need extra CFLAGS. +ldbl-128ibm-routines = s_nexttoward s_nexttowardf \ + $(type-ldouble-routines) \ + $(subst F,$(type-ldouble-suffix),$(libm-compat-calls)) \ + $(subst F,$(type-ldouble-suffix),$(libm-calls)) \ + $(subst F,$(type-ldouble-suffix),$(calls)) \ + $(foreach f,$(libm-narrow-fns), \ + $(subst F,$(f), \ + $(libm-narrow-types-ldouble-yes))) +$(foreach suf,$(all-object-suffixes), \ + $(foreach r,$(ldbl-128ibm-routines) $(ldbl-tests), \ + $(objpfx)$(r)$(suf))): \ + CFLAGS += $(type-ldouble-CFLAGS) From patchwork Fri Feb 14 16:10:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 1238155 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-109745-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=AsXcOWnh; 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 48Jz0g5QRyz9sV4 for ; Sat, 15 Feb 2020 03:12:03 +1100 (AEDT) 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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=pMsS7RbC4R3vk1c+WrirLk7rB943hBjB2jjzeV6+WVy9ell7hc01r rhvYqQBibDsU2G1WaGfU9GbKsTY5Pc8rygRBdVzqouUbpuMjeigN3gRrzWfO7AnD 0Hd8VM2ICexmcvFiZXGGRRBXcbvm7YIolCW34oOAOdEllopkXTkTMI= 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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=BCLmfEuiI69BAQGqbUvYupiZN6M=; b=AsXcOWnh6Fjr0E8iyuowZSxsf6dE yrPuuAneYWEFNfTNGImTWIaZNnE263OuaKR+zD4gahk19gSe/KKwqTOgSNgEgW1q dwEtG777Gz6Lo01LqsGvRPg/Olspxmfd1PIo9PDg6/VXxBtKi0ApFKTmAwGVXOxp aJSTqoPlEbQsxR8= Received: (qmail 63317 invoked by alias); 14 Feb 2020 16:11:07 -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 63210 invoked by uid 89); 14 Feb 2020 16:11:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.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 autolearn=ham version=3.3.1 spammy=pf, bridge, sk:__gi___, sk:__GI___ X-HELO: mx0a-001b2d01.pphosted.com From: "Paul E. Murphy" To: libc-alpha@sourceware.org Subject: [PATCH 7/7] RFC: ldbl-128ibm-compat: PLT redirects for using ldbl redirects internally Date: Fri, 14 Feb 2020 10:10:51 -0600 Message-Id: <20200214161051.32579-8-murphyp@linux.vnet.ibm.com> In-Reply-To: <20200214161051.32579-1-murphyp@linux.vnet.ibm.com> References: <20200214161051.32579-1-murphyp@linux.vnet.ibm.com> MIME-Version: 1.0 Tweak the PLT bypass magic when building glibc with long double redirects. This is made more difficult by the fact we only get one chance to redirect functions. This happens via the public headers. There are roughly three classes of redirect we need to attend to today: 1. Simple redirects, redirected via cdef macro overrides and and new libc_hidden_ldbl_proto macro. 2. Internal usage of internal API, e.g __snprintf, which has no direct analogue. This is bypassed directly on case-by- case basis. 3. Double redirects, e.g sscanf and related. These require a heavier handed approach of macro renaming to existing symbols. Most simple redirects are handled via 1. Ideally, the libc_* macro would live in libc-symbols.h, but in practice the macros needed for it to do anything useful live in cdefs.h, so they are defined in the local override. Notably, the internal name of asprintf is renamed to work with internal prefixed usage. This resolves the local plt usage introduced when building glibc with ldbl == ieee128 on ppc64le. Reviewed-by: Tulio Magno Quites Machado Filho --- include/err.h | 12 ++--- include/stdio.h | 51 +++++++++++++------ include/sys/cdefs.h | 23 +++++++++ include/sys/syslog.h | 2 +- include/wchar.h | 2 +- .../ldbl-128ibm-compat/ieee128-asprintf.c | 5 +- .../ldbl-128ibm-compat/ieee128-dprintf.c | 1 + .../ieee754/ldbl-128ibm-compat/ieee128-err.c | 7 +++ .../ldbl-128ibm-compat/ieee128-fprintf.c | 1 + .../ieee128-isoc99_sscanf.c | 1 + .../ieee128-isoc99_vfscanf.c | 2 + .../ieee128-isoc99_vsscanf.c | 1 + .../ldbl-128ibm-compat/ieee128-sprintf.c | 1 + .../ldbl-128ibm-compat/ieee128-syslog.c | 1 + .../ldbl-128ibm-compat/ieee128-vfprintf.c | 1 + .../ldbl-128ibm/include/bits/iscanonical.h | 2 +- 16 files changed, 87 insertions(+), 26 deletions(-) diff --git a/include/err.h b/include/err.h index 7c05cd1dbb..b9b7516287 100644 --- a/include/err.h +++ b/include/err.h @@ -12,12 +12,12 @@ __vwarn_internal (const char *format, __gnuc_va_list ap, # ifndef _ISOMAC -libc_hidden_proto (warn) -libc_hidden_proto (warnx) -libc_hidden_proto (vwarn) -libc_hidden_proto (vwarnx) -libc_hidden_proto (verr) -libc_hidden_proto (verrx) +libc_hidden_ldbl_proto (warn) +libc_hidden_ldbl_proto (warnx) +libc_hidden_ldbl_proto (vwarn) +libc_hidden_ldbl_proto (vwarnx) +libc_hidden_ldbl_proto (verr) +libc_hidden_ldbl_proto (verrx) # endif /* !_ISOMAC */ #endif /* err.h */ diff --git a/include/stdio.h b/include/stdio.h index dffa7765dd..ab3d375ec7 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -9,13 +9,23 @@ /* Now define the internal interfaces. */ +/* Take a little more care when redirecting internal only symbols. Anything + internal to libc should redirect to internal function name. */ +# if __LONG_DOUBLE_USES_FLOAT128 == 1 && IS_IN (libc) +# define stdio_hidden_ldbl_proto(p, f) \ + extern __typeof (p ## f) p ## f __asm (__ASMNAME ("___ieee128_" #f)); +# elif __LONG_DOUBLE_USES_FLOAT128 == 1 +# define stdio_hidden_ldbl_proto(p,f) __LDBL_REDIR1_DECL (p ## f, p ## f ## ieee128) +# else +# define stdio_hidden_ldbl_proto(p,f) libc_hidden_proto (p ## f) +# endif + extern int __fcloseall (void) attribute_hidden; extern int __snprintf (char *__restrict __s, size_t __maxlen, const char *__restrict __format, ...) __attribute__ ((__format__ (__printf__, 3, 4))); -# if __LONG_DOUBLE_USES_FLOAT128 == 0 -libc_hidden_proto (__snprintf) -# endif +stdio_hidden_ldbl_proto (__, snprintf) + extern int __vfscanf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) @@ -66,6 +76,7 @@ extern int __isoc99_vscanf (const char *__restrict __format, extern int __isoc99_vsscanf (const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __THROW; + libc_hidden_proto (__isoc99_sscanf) libc_hidden_proto (__isoc99_vsscanf) libc_hidden_proto (__isoc99_vfscanf) @@ -74,12 +85,25 @@ libc_hidden_proto (__isoc99_vfscanf) Unfortunately, symbol redirection is not transitive, so the __REDIRECT in the public header does not link up with the above libc_hidden_proto. Bridge the gap with a macro. */ -# if !__GLIBC_USE (DEPRECATED_SCANF) \ - && __LONG_DOUBLE_USES_FLOAT128 == 0 +# if !__GLIBC_USE (DEPRECATED_SCANF) # undef sscanf # define sscanf __isoc99_sscanf # endif +# if __LONG_DOUBLE_USES_FLOAT128 == 1 && IS_IN (libc) +/* These are implemented as redirects to other public API. + Therefore, the usual redirection fails to avoid PLT. */ +extern __typeof (__isoc99_sscanf) ___ieee128_isoc99_sscanf __THROW; +extern __typeof (__isoc99_vsscanf) ___ieee128_isoc99_vsscanf __THROW; +extern __typeof (__isoc99_vfscanf) ___ieee128_isoc99_vfscanf __THROW; +libc_hidden_proto (___ieee128_isoc99_sscanf) +libc_hidden_proto (___ieee128_isoc99_vsscanf) +libc_hidden_proto (___ieee128_isoc99_vfscanf) +#define __isoc99_sscanf ___ieee128_isoc99_sscanf +#define __isoc99_vsscanf ___ieee128_isoc99_vsscanf +#define __isoc99_vfscanf ___ieee128_isoc99_vfscanf +# endif + /* Prototypes for compatibility functions. */ extern FILE *__new_tmpfile (void); extern FILE *__old_tmpfile (void); @@ -153,9 +177,8 @@ libc_hidden_proto (__libc_readline_unlocked); extern const char *const _sys_errlist_internal[] attribute_hidden; extern int _sys_nerr_internal attribute_hidden; -#if __LONG_DOUBLE_USES_FLOAT128 == 0 -libc_hidden_proto (__asprintf) -#endif +libc_hidden_ldbl_proto (__asprintf) + # if IS_IN (libc) extern FILE *_IO_new_fopen (const char*, const char*); # define fopen(fname, mode) _IO_new_fopen (fname, mode) @@ -178,13 +201,11 @@ extern int _IO_new_fgetpos (FILE *, __fpos_t *); extern __typeof (dprintf) __dprintf __attribute__ ((__format__ (__printf__, 2, 3))); -libc_hidden_proto (__dprintf) -#if __LONG_DOUBLE_USES_FLOAT128 == 0 -libc_hidden_proto (dprintf) -libc_hidden_proto (fprintf) -libc_hidden_proto (vfprintf) -libc_hidden_proto (sprintf) -#endif +stdio_hidden_ldbl_proto (__, dprintf) +libc_hidden_ldbl_proto (dprintf) +libc_hidden_ldbl_proto (fprintf) +libc_hidden_ldbl_proto (vfprintf) +libc_hidden_ldbl_proto (sprintf) libc_hidden_proto (fwrite) libc_hidden_proto (perror) libc_hidden_proto (remove) diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h index 524fe57a25..ae5802e744 100644 --- a/include/sys/cdefs.h +++ b/include/sys/cdefs.h @@ -15,4 +15,27 @@ rtld_hidden_proto (__chk_fail) #endif +/* If we are using redirects internally to support long double, + we need to tweak some macros to ensure the PLT bypass tricks + continue to work in libc. */ +#if __LONG_DOUBLE_USES_FLOAT128 == 1 && IS_IN (libc) && defined SHARED + +# undef __LDBL_REDIR_DECL +# define __LDBL_REDIR_DECL(name) + +# undef __LDBL_REDIR2_DECL +# define __LDBL_REDIR2_DECL(name) + +# undef __LDBL_REDIR1_DECL +# define __LDBL_REDIR1_DECL(name, to) + +# define libc_hidden_ldbl_proto(func) \ + extern __typeof(func) func __asm (__ASMNAME ("__GI____ieee128_" #func)); \ + extern __typeof(func) ___ieee128_ ## func; \ + libc_hidden_proto (___ieee128_ ## func); + +#else +# define libc_hidden_ldbl_proto(func) libc_hidden_proto (func) +#endif + #endif diff --git a/include/sys/syslog.h b/include/sys/syslog.h index 89d3479ebc..44422eab13 100644 --- a/include/sys/syslog.h +++ b/include/sys/syslog.h @@ -3,7 +3,7 @@ #include #ifndef _ISOMAC -libc_hidden_proto (syslog) +libc_hidden_ldbl_proto (syslog) /* __vsyslog_internal uses the same mode_flags bits as __v*printf_internal; see libio/libioP.h. */ diff --git a/include/wchar.h b/include/wchar.h index c792b38943..617906eb14 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -64,7 +64,7 @@ libc_hidden_proto (__wcstoul_internal) libc_hidden_proto (__wcstoull_internal) libc_hidden_proto (wcstof) libc_hidden_proto (wcstod) -libc_hidden_proto (wcstold) +libc_hidden_ldbl_proto (wcstold) libc_hidden_proto (wcstol) libc_hidden_proto (wcstoll) libc_hidden_proto (wcstoul) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c index 68cafbb2fa..2a6ed2f813 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c @@ -20,7 +20,7 @@ #include extern int -___ieee128_asprintf (char **string_ptr, const char *format, ...) +___ieee128___asprintf (char **string_ptr, const char *format, ...) { va_list ap; int done; @@ -32,4 +32,5 @@ ___ieee128_asprintf (char **string_ptr, const char *format, ...) return done; } -strong_alias (___ieee128_asprintf, __asprintfieee128) +hidden_def (___ieee128___asprintf) +strong_alias (___ieee128___asprintf, __asprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c index 9dc65309bd..87440c9850 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c @@ -32,3 +32,4 @@ ___ieee128_dprintf (int d, const char *format, ...) return done; } strong_alias (___ieee128_dprintf, __dprintfieee128) +hidden_def (___ieee128_dprintf); diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c index eae071b9c4..f81d3edcbf 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c @@ -91,3 +91,10 @@ IEEE128_DECL (errx) (int status, const char *format, ...) VA (verrx (status, format, ap)) } IEEE128_ALIAS (errx) + +hidden_def (___ieee128_warn) +hidden_def (___ieee128_warnx) +hidden_def (___ieee128_vwarn) +hidden_def (___ieee128_vwarnx) +hidden_def (___ieee128_verr) +hidden_def (___ieee128_verrx) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c index e1c989643e..b05e6f1bc6 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c @@ -32,3 +32,4 @@ ___ieee128_fprintf (FILE *fp, const char *format, ...) return done; } strong_alias (___ieee128_fprintf, __fprintfieee128) +hidden_def (___ieee128_fprintf) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c index bfc7270a78..cd1c9fa333 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c @@ -37,3 +37,4 @@ ___ieee128_isoc99_sscanf (const char *string, const char *format, ...) return done; } strong_alias (___ieee128_isoc99_sscanf, __isoc99_sscanfieee128) +hidden_def (___ieee128_isoc99_sscanf) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c index b561fa3044..2a11f49ea6 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c @@ -17,6 +17,7 @@ . */ #include +#include extern int ___ieee128_isoc99_vfscanf (FILE *fp, const char *format, va_list ap) @@ -25,3 +26,4 @@ ___ieee128_isoc99_vfscanf (FILE *fp, const char *format, va_list ap) return __vfscanf_internal (fp, format, ap, mode_flags); } strong_alias (___ieee128_isoc99_vfscanf, __isoc99_vfscanfieee128) +hidden_def (___ieee128_isoc99_vfscanf) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c index bef6ebcce0..d976cdbe1f 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c @@ -28,3 +28,4 @@ ___ieee128_isoc99_vsscanf (const char *string, const char *format, va_list ap) return __vfscanf_internal (fp, format, ap, mode_flags); } strong_alias (___ieee128_isoc99_vsscanf, __isoc99_vsscanfieee128) +hidden_def (___ieee128_isoc99_vsscanf) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c index 52088cd576..690dc3abf1 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c @@ -33,3 +33,4 @@ ___ieee128_sprintf (char *s, const char *format, ...) return done; } strong_alias (___ieee128_sprintf, __sprintfieee128) +hidden_def (___ieee128_sprintf) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c index 914f24aebd..4af546326c 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c @@ -30,6 +30,7 @@ ___ieee128_syslog (int pri, const char *fmt, ...) va_end (ap); } strong_alias (___ieee128_syslog, __syslogieee128) +hidden_def (___ieee128_syslog) void ___ieee128_vsyslog (int pri, const char *fmt, va_list ap) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c index 234cd9de8d..b407eae969 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c @@ -24,3 +24,4 @@ ___ieee128_vfprintf (FILE *fp, const char *format, va_list ap) return __vfprintf_internal (fp, format, ap, PRINTF_LDBL_USES_FLOAT128); } strong_alias (___ieee128_vfprintf, __vfprintfieee128) +hidden_def (___ieee128_vfprintf) diff --git a/sysdeps/ieee754/ldbl-128ibm/include/bits/iscanonical.h b/sysdeps/ieee754/ldbl-128ibm/include/bits/iscanonical.h index bee080bd29..8cbd6f74bf 100644 --- a/sysdeps/ieee754/ldbl-128ibm/include/bits/iscanonical.h +++ b/sysdeps/ieee754/ldbl-128ibm/include/bits/iscanonical.h @@ -1,5 +1,5 @@ #include_next -#ifndef _ISOMAC +#if !defined _ISOMAC && (__LONG_DOUBLE_USES_FLOAT128 == 0) libm_hidden_proto (__iscanonicall) #endif