From patchwork Fri Nov 30 15:57:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006028 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-97757-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="bbbuLqdA"; 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 435zcJ1YQJz9sBZ for ; Sat, 1 Dec 2018 03:00:00 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=MsD1huKIoQFYCxvM2HO6/Mvs7LKmLwp AA+p+m2jM5khFpU831/K+pQOWLlJXJG4pgUpEg0osJDDbMQLw/al6R6F/TQco2h4 WMk9+iUVdm/fkoZL9Bao6voallkHIunYcXDHaulycIeGRJwqwkyGZb55Wr97dQEr B/lTxHTY9rME= 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=6R+vO3k9Ht5Swb76649noH+saVU=; b=bbbuL qdAXlq0be1GGLE9oGEhdUPRj96WpEq74IBcoa1vOxG7r5cs0OnqRs8P6uMUsIEhg d+GVE5rnegtqwTtWxuBGs1u+OL2QqD0pMwz2671Q9/TSpqwmQC8SZ8B625OiKjmc iKJwM0S993OXJWu8qVeEqutNa+nn7guBfyQNak= Received: (qmail 16182 invoked by alias); 30 Nov 2018 15:59: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 16031 invoked by uid 89); 30 Nov 2018 15:59:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 01/56] S390: Add configure check to detect z10 as mininum architecture level set. Date: Fri, 30 Nov 2018 16:57:39 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0016-0000-0000-0000022F30A8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0017-0000-0000-000032879BC1 Message-Id: <1543593514-10251-2-git-send-email-stli@linux.ibm.com> Add a configure check for z10 in the same way as done for z196. ChangeLog: * config.h.in (HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT): New undefine. * sysdeps/s390/configure.ac: Add check for z10 support. * sysdeps/s390/configure: Regenerated. --- config.h.in | 3 +++ sysdeps/s390/configure | 39 +++++++++++++++++++++++++++++++++++++++ sysdeps/s390/configure.ac | 29 +++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) diff --git a/config.h.in b/config.h.in index 141db213a9..beecc39d5b 100644 --- a/config.h.in +++ b/config.h.in @@ -62,6 +62,9 @@ /* Define if assembler supports AVX512DQ. */ #undef HAVE_AVX512DQ_ASM_SUPPORT +/* Define if assembler supports z10 zarch instructions as default on S390. */ +#undef HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT + /* Define if assembler supports z196 zarch instructions as default on S390. */ #undef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT diff --git a/sysdeps/s390/configure b/sysdeps/s390/configure index 74b415f2ab..f30f864436 100644 --- a/sysdeps/s390/configure +++ b/sysdeps/s390/configure @@ -112,6 +112,45 @@ then fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for S390 z10 zarch instruction support as default" >&5 +$as_echo_n "checking for S390 z10 zarch instruction support as default... " >&6; } +if ${libc_cv_asm_s390_min_z10_zarch+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat > conftest.c <<\EOF +void testinsn (void *a, void *b, int n) +{ + __asm__ ("exrl %2,1f \n\t" + "j 2f \n\t" + "1: mvc 0(1,%0),0(%1) \n\t" + "2:" + : : "a" (a), "a" (b), "d" (n) + : "memory", "cc"); +} +EOF +if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c + -o conftest.o &> /dev/null' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } ; +then + libc_cv_asm_s390_min_z10_zarch=yes +else + libc_cv_asm_s390_min_z10_zarch=no +fi +rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_asm_s390_min_z10_zarch" >&5 +$as_echo "$libc_cv_asm_s390_min_z10_zarch" >&6; } + +if test "$libc_cv_asm_s390_min_z10_zarch" = yes ; +then + $as_echo "#define HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT 1" >>confdefs.h + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for S390 z196 zarch instruction support as default" >&5 $as_echo_n "checking for S390 z196 zarch instruction support as default... " >&6; } if ${libc_cv_asm_s390_min_z196_zarch+:} false; then : diff --git a/sysdeps/s390/configure.ac b/sysdeps/s390/configure.ac index 1cdb021282..981f7a79dd 100644 --- a/sysdeps/s390/configure.ac +++ b/sysdeps/s390/configure.ac @@ -80,6 +80,35 @@ then AC_DEFINE(HAVE_S390_VX_GCC_SUPPORT) fi +AC_CACHE_CHECK(for S390 z10 zarch instruction support as default, + libc_cv_asm_s390_min_z10_zarch, [dnl +cat > conftest.c <<\EOF +void testinsn (void *a, void *b, int n) +{ + __asm__ ("exrl %2,1f \n\t" + "j 2f \n\t" + "1: mvc 0(1,%0),0(%1) \n\t" + "2:" + : : "a" (a), "a" (b), "d" (n) + : "memory", "cc"); +} +EOF +dnl +dnl test, if assembler supports S390 z10 zarch instructions as default +if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c + -o conftest.o &> /dev/null]) ; +then + libc_cv_asm_s390_min_z10_zarch=yes +else + libc_cv_asm_s390_min_z10_zarch=no +fi +rm -f conftest* ]) + +if test "$libc_cv_asm_s390_min_z10_zarch" = yes ; +then + AC_DEFINE(HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT) +fi + AC_CACHE_CHECK(for S390 z196 zarch instruction support as default, libc_cv_asm_s390_min_z196_zarch, [dnl cat > conftest.c <<\EOF From patchwork Fri Nov 30 15:57:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006027 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-97756-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="KvexiZ2u"; 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 435zc72lY1z9s8r for ; Sat, 1 Dec 2018 02:59:51 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=pCjQbo5gZtUmaZDfhz4rLjrYpe4596+ Nxw/6fDYVx7YdnIUJdzLlxGs8XN5TIZ9hEJHU5iqZEfx77+J/zwOkxOLuibfrLGu 9iw5iL31uXDNDeafkxqfL3cpV0LIe1ub6e0MYIebzB/JrKthVN11DtxSExGZnfCe jf0c1TueFwrE= 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=ZAHn/uTEieMblHC967xEcJ1gmbc=; b=Kvexi Z2uA0rhmKMR2fqphqhPDcQoRKCMcQ0lSl0rTKI56z/NEtbLLdGv4/fxQRHoYJkHv HX6VsUD9Ane/j5gL233qF+IsykbUM40y6USGHB76Yt/dRihyWzFBo4U+VWDlE3/y jTNjMeLw35sbfyjGPpZx6mOecVodHMN1zLZ0PI= Received: (qmail 16016 invoked by alias); 30 Nov 2018 15:59:23 -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 15835 invoked by uid 89); 30 Nov 2018 15:59:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 02/56] S390: Use hwcap instead of dl_hwcap in ifunc-resolvers. Date: Fri, 30 Nov 2018 16:57:40 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0028-0000-0000-00000323FCA6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0029-0000-0000-000023E01254 Message-Id: <1543593514-10251-3-git-send-email-stli@linux.ibm.com> The renaming of hwcap arguments in ifunc-resolvers is needed in order to prepare for further commits which refactors ifunc handling for memset, memcmp, and memcpy. Now you are able to use s390_libc_ifunc_init which stores the stfle bits within the expression for an ifunc-resolver generated by s390_libc_ifunc_expr. ChangeLog: * sysdeps/s390/multiarch/ifunc-resolve.h (s390_libc_ifunc_init, s390_libc_ifunc, s390_vx_libc_ifunc2_redirected): Use hwcap instead of dl_hwcap. --- sysdeps/s390/multiarch/ifunc-resolve.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sysdeps/s390/multiarch/ifunc-resolve.h b/sysdeps/s390/multiarch/ifunc-resolve.h index b42ed922fd..6139bd39c5 100644 --- a/sysdeps/s390/multiarch/ifunc-resolve.h +++ b/sysdeps/s390/multiarch/ifunc-resolve.h @@ -42,9 +42,9 @@ : : "cc"); #define s390_libc_ifunc_init() \ unsigned long long stfle_bits = 0ULL; \ - if (__glibc_likely((dl_hwcap & HWCAP_S390_STFLE) \ - && (dl_hwcap & HWCAP_S390_ZARCH) \ - && (dl_hwcap & HWCAP_S390_HIGH_GPRS))) \ + if (__glibc_likely((hwcap & HWCAP_S390_STFLE) \ + && (hwcap & HWCAP_S390_ZARCH) \ + && (hwcap & HWCAP_S390_HIGH_GPRS))) \ { \ S390_STORE_STFLE (stfle_bits); \ } @@ -61,7 +61,7 @@ : __glibc_likely (S390_IS_Z10 (stfle_bits)) \ ? RESOLVERFUNC##_z10 \ : RESOLVERFUNC##_default, \ - unsigned long int dl_hwcap, s390_libc_ifunc_init); + unsigned long int hwcap, s390_libc_ifunc_init); #define s390_vx_libc_ifunc(FUNC) \ s390_vx_libc_ifunc2_redirected(FUNC, FUNC, FUNC) @@ -79,10 +79,10 @@ extern __typeof (TYPE_FUNC) RESOLVERFUNC##_vx attribute_hidden; \ extern __typeof (TYPE_FUNC) RESOLVERFUNC##_c attribute_hidden; \ __ifunc (TYPE_FUNC, FUNC, \ - (dl_hwcap & HWCAP_S390_VX) \ + (hwcap & HWCAP_S390_VX) \ ? RESOLVERFUNC##_vx \ : RESOLVERFUNC##_c, \ - unsigned long int dl_hwcap, s390_vx_libc_ifunc_init); + unsigned long int hwcap, s390_vx_libc_ifunc_init); #define s390_libc_ifunc_expr_init() #define s390_libc_ifunc_expr(TYPE_FUNC, FUNC, EXPR) \ From patchwork Fri Nov 30 15:57:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006029 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-97758-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="bDM1dxeP"; 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 435zcW39vvz9s8r for ; Sat, 1 Dec 2018 03:00:11 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=BdjtQ3bJrso3ElSJt2r7OnLv0LPh/a+ YBWCzv7pL+xURccd4CF3ldNjNlo4Bd55gYGYhyJ/uTRng4VLdAGRk2SoTVxXUCM6 UUyGAmEbl2GIdMHldJcMvOS+tpE8oHKnzmKZYyTbIvvDEodKEVFk+ZLDeYfLTl/a j1dq786CKvJw= 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=evl3PB6mKs1EENqE9IAVjFkMgJI=; b=bDM1d xePZaXKfN6bwWxSlh7oPw1P72e7VeKQ2i9tusMllmEJWGlVD4spMU/q0TTXgplv3 1i5EQwZYdyqJUoYb2biD0gV6RFpFy6Sn5D9jrYBxqCTOguBMaAw9kZXoQssp0aNn MXkqZ8oH3I9Oyww7yO71XYCaUssQpwNQR7euuY= Received: (qmail 16774 invoked by alias); 30 Nov 2018 15:59:28 -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 16655 invoked by uid 89); 30 Nov 2018 15:59:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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=chi, 2860 X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 03/56] S390: Unify 31/64bit memset. Date: Fri, 30 Nov 2018 16:57:41 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0016-0000-0000-0000022F30AA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0017-0000-0000-000032879BC2 Message-Id: <1543593514-10251-4-git-send-email-stli@linux.ibm.com> The implementation of memset for s390-32 (31bit) and s390-64 (64bit) is nearly the same. This patch unifies it for maintability reasons. __memset_z10 and __memset_z196 differs between 31 and 64bit: -31bit needs .machinemode "zarch_nohighgprs" and llgfr %r4,%r4 -lr vs lgr and some other instructions: But lgr and co can be also used on 31bit as this ifunc variant is only called if we are on a zarch machine. __memset_default differs between 31 and 64bit: -Some 31bit vs 64bit instructions (e.g. ltr vs ltgr. Solved with 31/64 specific instruction macros). -The address of mvc instruction is setup in different ways (larl vs bras). Solved with #if defined __s390x__. Otherwise 31/64bit implementation has the same structure of the code. ChangeLog: * sysdeps/s390/s390-64/memset.S: Move to ... * sysdeps/s390/memset.S: ... here. Adjust to be usable for 31/64bit. * sysdeps/s390/s390-32/memset.S: Delete File. * sysdeps/s390/multiarch/Makefile (sysdep_routines): Add memset. * sysdeps/s390/s390-32/multiarch/Makefile (sysdep_routines): Remove memset. * sysdeps/s390/s390-64/multiarch/Makefile: Likewise. * sysdeps/s390/s390-64/multiarch/memset-s390x.S: Move to ... * sysdeps/s390/multiarch/memset-s390x.S: ... here. Adjust to be usable for 31/64bit. * sysdeps/s390/s390-32/multiarch/memset-s390.S: Delete File. * sysdeps/s390/s390-64/multiarch/memset.c: Move to ... * sysdeps/s390/multiarch/memset.c: ... here. * sysdeps/s390/s390-32/multiarch/memset.c: Delete File. --- sysdeps/s390/{s390-64 => }/memset.S | 67 +++++++--- sysdeps/s390/multiarch/Makefile | 3 +- .../{s390-64 => }/multiarch/memset-s390x.S | 10 +- sysdeps/s390/{s390-32 => }/multiarch/memset.c | 0 sysdeps/s390/s390-32/memset.S | 65 ---------- sysdeps/s390/s390-32/multiarch/Makefile | 3 +- sysdeps/s390/s390-32/multiarch/memset-s390.S | 116 ------------------ sysdeps/s390/s390-64/multiarch/Makefile | 3 +- sysdeps/s390/s390-64/multiarch/memset.c | 26 ---- 9 files changed, 63 insertions(+), 230 deletions(-) rename sysdeps/s390/{s390-64 => }/memset.S (58%) rename sysdeps/s390/{s390-64 => }/multiarch/memset-s390x.S (90%) rename sysdeps/s390/{s390-32 => }/multiarch/memset.c (100%) delete mode 100644 sysdeps/s390/s390-32/memset.S delete mode 100644 sysdeps/s390/s390-32/multiarch/memset-s390.S delete mode 100644 sysdeps/s390/s390-64/multiarch/memset.c diff --git a/sysdeps/s390/s390-64/memset.S b/sysdeps/s390/memset.S similarity index 58% rename from sysdeps/s390/s390-64/memset.S rename to sysdeps/s390/memset.S index 8799c6592c..72e7c5a42e 100644 --- a/sysdeps/s390/s390-64/memset.S +++ b/sysdeps/s390/memset.S @@ -1,4 +1,4 @@ -/* Set a block of memory to some byte value. 64 bit S/390 version. +/* Set a block of memory to some byte value. 31/64 bit S/390 version. Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -28,33 +28,60 @@ .text +#if defined __s390x__ +# define LTGR ltgr +# define CGHI cghi +# define LGR lgr +# define AGHI aghi +# define BRCTG brctg +#else +# define LTGR ltr +# define CGHI chi +# define LGR lr +# define AGHI ahi +# define BRCTG brct +#endif /* ! defined __s390x__ */ + #ifdef USE_MULTIARCH ENTRY(__memset_default) #else ENTRY(memset) #endif +#if defined __s390x__ .machine "z900" - ltgr %r4,%r4 - je .L_Z900_4 +#else + .machine "g5" +#endif /* ! defined __s390x__ */ + LTGR %r4,%r4 + je .L_Z900_G5_4 stc %r3,0(%r2) - cghi %r4,1 - lgr %r1,%r2 - je .L_Z900_4 - aghi %r4,-2 + CGHI %r4,1 + LGR %r1,%r2 + je .L_Z900_G5_4 + AGHI %r4,-2 +#if defined __s390x__ + larl %r5,.L_Z900_G5_18 srlg %r3,%r4,8 - ltgr %r3,%r3 - jne .L_Z900_14 -.L_Z900_3: - larl %r3,.L_Z900_18 - ex %r4,0(%r3) -.L_Z900_4: +# define Z900_G5_EX_D 0 +#else + basr %r5,0 +.L_Z900_G5_19: +# define Z900_G5_EX_D .L_Z900_G5_18-.L_Z900_G5_19 + lr %r3,%r4 + srl %r3,8 +#endif /* ! defined __s390x__ */ + LTGR %r3,%r3 + jne .L_Z900_G5_14 +.L_Z900_G5_3: + ex %r4,Z900_G5_EX_D(%r5) +.L_Z900_G5_4: br %r14 -.L_Z900_14: +.L_Z900_G5_14: mvc 1(256,%r1),0(%r1) la %r1,256(%r1) - brctg %r3,.L_Z900_14 - j .L_Z900_3 -.L_Z900_18: + BRCTG %r3,.L_Z900_G5_14 + j .L_Z900_G5_3 +.L_Z900_G5_18: mvc 1(1,%r1),0(%r1) #ifdef USE_MULTIARCH END(__memset_default) @@ -62,3 +89,9 @@ END(__memset_default) END(memset) libc_hidden_builtin_def (memset) #endif + +#undef LTGR +#undef CGHI +#undef LGR +#undef AGHI +#undef BRCTG diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index c893ebc565..93ad21bfa2 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -19,7 +19,8 @@ sysdep_routines += strlen strlen-vx strlen-c \ rawmemchr rawmemchr-vx rawmemchr-c \ memccpy memccpy-vx memccpy-c \ memrchr memrchr-vx memrchr-c \ - mempcpy + mempcpy \ + memset memset-s390x endif ifeq ($(subdir),wcsmbs) diff --git a/sysdeps/s390/s390-64/multiarch/memset-s390x.S b/sysdeps/s390/multiarch/memset-s390x.S similarity index 90% rename from sysdeps/s390/s390-64/multiarch/memset-s390x.S rename to sysdeps/s390/multiarch/memset-s390x.S index 0c5aaef34f..aca3ac3fda 100644 --- a/sysdeps/s390/s390-64/multiarch/memset-s390x.S +++ b/sysdeps/s390/multiarch/memset-s390x.S @@ -1,4 +1,4 @@ -/* Set a block of memory to some byte value. 64 bit S/390 version. +/* Set a block of memory to some byte value. 31/64 bit S/390 version. Copyright (C) 2012-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -31,6 +31,10 @@ ENTRY(__memset_z196) .machine "z196" + .machinemode "zarch_nohighgprs" +# if !defined __s390x__ + llgfr %r4,%r4 +# endif /* !defined __s390x__ */ ltgr %r4,%r4 je .L_Z196_4 stc %r3,0(%r2) @@ -61,6 +65,10 @@ END(__memset_z196) ENTRY(__memset_z10) .machine "z10" + .machinemode "zarch_nohighgprs" +# if !defined __s390x__ + llgfr %r4,%r4 +# endif /* !defined __s390x__ */ cgije %r4,0,.L_Z10_4 stc %r3,0(%r2) lgr %r1,%r2 diff --git a/sysdeps/s390/s390-32/multiarch/memset.c b/sysdeps/s390/multiarch/memset.c similarity index 100% rename from sysdeps/s390/s390-32/multiarch/memset.c rename to sysdeps/s390/multiarch/memset.c diff --git a/sysdeps/s390/s390-32/memset.S b/sysdeps/s390/s390-32/memset.S deleted file mode 100644 index 57f08e1cae..0000000000 --- a/sysdeps/s390/s390-32/memset.S +++ /dev/null @@ -1,65 +0,0 @@ -/* Set a block of memory to some byte value. For IBM S390 - Copyright (C) 2012-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 "sysdep.h" -#include "asm-syntax.h" - -/* INPUT PARAMETERS - %r2 = address to memory area - %r3 = byte to fill memory with - %r4 = number of bytes to fill. */ - - .text - -#ifdef USE_MULTIARCH -ENTRY(__memset_default) -#else -ENTRY(memset) -#endif - .machine "g5" - basr %r5,0 -.L_G5_19: - ltr %r4,%r4 - je .L_G5_4 - stc %r3,0(%r2) - chi %r4,1 - lr %r1,%r2 - je .L_G5_4 - ahi %r4,-2 - lr %r3,%r4 - srl %r3,8 - ltr %r3,%r3 - jne .L_G5_14 - ex %r4,.L_G5_20-.L_G5_19(%r5) -.L_G5_4: - br %r14 -.L_G5_14: - mvc 1(256,%r1),0(%r1) - la %r1,256(%r1) - brct %r3,.L_G5_14 - ex %r4,.L_G5_20-.L_G5_19(%r5) - j .L_G5_4 -.L_G5_20: - mvc 1(1,%r1),0(%r1) -#ifdef USE_MULTIARCH -END(__memset_default) -#else -END(memset) -libc_hidden_builtin_def (memset) -#endif diff --git a/sysdeps/s390/s390-32/multiarch/Makefile b/sysdeps/s390/s390-32/multiarch/Makefile index f8aee14bbd..4b11e28656 100644 --- a/sysdeps/s390/s390-32/multiarch/Makefile +++ b/sysdeps/s390/s390-32/multiarch/Makefile @@ -1,4 +1,3 @@ ifeq ($(subdir),string) -sysdep_routines += memset memset-s390 memcpy memcpy-s390 \ - memcmp memcmp-s390 +sysdep_routines += memcpy memcpy-s390 memcmp memcmp-s390 endif diff --git a/sysdeps/s390/s390-32/multiarch/memset-s390.S b/sysdeps/s390/s390-32/multiarch/memset-s390.S deleted file mode 100644 index b092073d6b..0000000000 --- a/sysdeps/s390/s390-32/multiarch/memset-s390.S +++ /dev/null @@ -1,116 +0,0 @@ -/* Set a block of memory to some byte value. 32 bit S/390 version. - Copyright (C) 2012-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 "sysdep.h" -#include "asm-syntax.h" - -/* INPUT PARAMETERS - %r2 = address of memory area - %r3 = byte to fill memory with - %r4 = number of bytes to fill. */ - - .text - -#if IS_IN (libc) - -ENTRY(__memset_z196) - .machine "z196" - .machinemode "zarch_nohighgprs" - llgfr %r4,%r4 - ltgr %r4,%r4 - je .L_Z196_4 - stc %r3,0(%r2) - lr %r1,%r2 - cghi %r4,1 - je .L_Z196_4 - aghi %r4,-2 - srlg %r5,%r4,8 - ltgr %r5,%r5 - jne .L_Z196_1 -.L_Z196_3: - exrl %r4,.L_Z196_17 -.L_Z196_4: - br %r14 -.L_Z196_1: - cgfi %r5,1048576 - jh __memset_mvcle # Switch to mvcle for >256MB -.L_Z196_2: - pfd 2,1024(%r1) - mvc 1(256,%r1),0(%r1) - aghi %r5,-1 - la %r1,256(%r1) - jne .L_Z196_2 - j .L_Z196_3 -.L_Z196_17: - mvc 1(1,%r1),0(%r1) -END(__memset_z196) - -ENTRY(__memset_z10) - .machine "z10" - .machinemode "zarch_nohighgprs" - llgfr %r4,%r4 - cgije %r4,0,.L_Z10_4 - stc %r3,0(%r2) - lr %r1,%r2 - cgije %r4,1,.L_Z10_4 - aghi %r4,-2 - srlg %r5,%r4,8 - cgijlh %r5,0,.L_Z10_15 -.L_Z10_3: - exrl %r4,.L_Z10_18 -.L_Z10_4: - br %r14 -.L_Z10_15: - cgfi %r5,163840 # Switch to mvcle for >40MB - jh __memset_mvcle -.L_Z10_14: - pfd 2,1024(%r1) - mvc 1(256,%r1),0(%r1) - la %r1,256(%r1) - brctg %r5,.L_Z10_14 - j .L_Z10_3 -.L_Z10_18: - mvc 1(1,%r1),0(%r1) -END(__memset_z10) - -ENTRY(__memset_mvcle) - ahi %r4,2 # take back the change done by the caller - lr %r0,%r2 # save source address - lr %r1,%r3 # move pad byte to R1 - lr %r3,%r4 - sr %r4,%r4 # no source for MVCLE, only a pad byte - sr %r5,%r5 -.L0: mvcle %r2,%r4,0(%r1) # thats it, MVCLE is your friend - jo .L0 - lr %r2,%r0 # return value is source address -.L1: - br %r14 -END(__memset_mvcle) - -#endif /* IS_IN (libc) */ - -#include "../memset.S" - -#if !IS_IN (libc) -.globl memset -.set memset,__memset_default -#elif defined SHARED && IS_IN (libc) -.globl __GI_memset -.set __GI_memset,__memset_default -#endif diff --git a/sysdeps/s390/s390-64/multiarch/Makefile b/sysdeps/s390/s390-64/multiarch/Makefile index 91053b5364..e4870c7ee1 100644 --- a/sysdeps/s390/s390-64/multiarch/Makefile +++ b/sysdeps/s390/s390-64/multiarch/Makefile @@ -1,4 +1,3 @@ ifeq ($(subdir),string) -sysdep_routines += memset memset-s390x memcpy memcpy-s390x \ - memcmp memcmp-s390x +sysdep_routines += memcpy memcpy-s390x memcmp memcmp-s390x endif diff --git a/sysdeps/s390/s390-64/multiarch/memset.c b/sysdeps/s390/s390-64/multiarch/memset.c deleted file mode 100644 index 760b3e9df2..0000000000 --- a/sysdeps/s390/s390-64/multiarch/memset.c +++ /dev/null @@ -1,26 +0,0 @@ -/* Multiple versions of memset. - Copyright (C) 2015-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 - . */ - -#if IS_IN (libc) -# define memset __redirect_memset -# include -# undef memset -# include - -s390_libc_ifunc (__redirect_memset, __memset, memset) -#endif From patchwork Fri Nov 30 15:57:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006031 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-97760-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="TwGQ/Ip8"; 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 435zf06PbRz9s8r for ; Sat, 1 Dec 2018 03:01:28 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=ArMCgifwRlMA505ZSLk3ESDGL2woKpS 785hRAE5q1Pq2roqOnlIfuy5nNuldjdZK2aHZc0ZvEGYCxWXyyWn8odCAMfGbOBk Jzx2R3b/aIRv5Wg0EVddtJkgziAQdoy/yNwx+scZHnzu7mxm9JwkfY4M5zmkyOoS pwIoAwjX6NJc= 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=trDr8bS4AQHngokaEaEB0M1XzKs=; b=TwGQ/ Ip8xAT1JTk9vdQEUmX5mGtgPke9TBGWnf3ieE5Fe/lQSdu6dAe8uHSc2zx36mRGL dixaCYioSYqtVQIc7BE/XrHZqzxtJxtoi35Yvm4gt0/IetSErPbv4jfFtZR4qur0 qRgb861h6hKlLwUF3uq7W9c7ZfgwCXIGuMm/bw= Received: (qmail 17247 invoked by alias); 30 Nov 2018 15:59:32 -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 17107 invoked by uid 89); 30 Nov 2018 15:59:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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=chi X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 04/56] S390: Refactor memset ifunc handling. Date: Fri, 30 Nov 2018 16:57:42 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0008-0000-0000-0000029B0395 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0009-0000-0000-000022055452 Message-Id: <1543593514-10251-5-git-send-email-stli@linux.ibm.com> This patch moves all ifunc variants for memset to sysdeps/s390/memset-z900.S. The configure-check/preprocessor logic in sysdeps/s390/ifunc-memset.h decides if ifunc is needed at all and which ifunc variants should be available. E.g. if the compiler/assembler already supports z196 by default, the older ifunc variants are not included. If we only need the newest ifunc variant, then we can skip ifunc at all. Therefore the ifunc-resolvers and __libc_ifunc_impl_list are adjusted in order to handle only the available ifunc variants. ChangeLog: * sysdeps/s390/ifunc-memset.h: New File. * sysdeps/s390/memset.S: Move to ... * sysdeps/s390/memset-z900.S ... here. Move implementations from memset-s390x.s to here. * sysdeps/s390/multiarch/memset-s390x.S: Delete File. * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove memset variants. * sysdeps/s390/Makefile (sysdep_routines): Add memset variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Adjust ifunc variants for memset. * sysdeps/s390/multiarch/memset.c: Move ifunc resolver to ... * sysdeps/s390/memset.c: ... here. Adjust ifunc variants for memset. --- sysdeps/s390/Makefile | 4 + sysdeps/s390/ifunc-memset.h | 65 ++++++++ .../memset-s390x.S => memset-z900.S} | 150 +++++++++++++----- sysdeps/s390/memset.S | 97 ----------- sysdeps/s390/{multiarch => }/memset.c | 26 ++- sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 16 +- 7 files changed, 215 insertions(+), 146 deletions(-) create mode 100644 sysdeps/s390/ifunc-memset.h rename sysdeps/s390/{multiarch/memset-s390x.S => memset-z900.S} (57%) delete mode 100644 sysdeps/s390/memset.S rename sysdeps/s390/{multiarch => }/memset.c (60%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 496ab51973..f90a41d3ae 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -52,3 +52,7 @@ tst-dl-runtime-profile-noaudit-ENV = $(env-profile) tst-dl-runtime-profile-audit-ENV = $(env-profile) $(env-audit) endif endif + +ifeq ($(subdir),string) +sysdep_routines += memset memset-z900 +endif diff --git a/sysdeps/s390/ifunc-memset.h b/sysdeps/s390/ifunc-memset.h new file mode 100644 index 0000000000..9a13b1001f --- /dev/null +++ b/sysdeps/s390/ifunc-memset.h @@ -0,0 +1,65 @@ +/* memset variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT +# define HAVE_MEMSET_IFUNC 1 +#else +# define HAVE_MEMSET_IFUNC 0 +#endif + +#if defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT +# define MEMSET_DEFAULT MEMSET_Z196 +# define HAVE_MEMSET_Z900_G5 0 +# define HAVE_MEMSET_Z10 0 +# define HAVE_MEMSET_Z196 1 +#elif defined HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT +# define MEMSET_DEFAULT MEMSET_Z10 +# define HAVE_MEMSET_Z900_G5 0 +# define HAVE_MEMSET_Z10 1 +# define HAVE_MEMSET_Z196 HAVE_MEMSET_IFUNC +#else +# define MEMSET_DEFAULT MEMSET_Z900_G5 +# define HAVE_MEMSET_Z900_G5 1 +# define HAVE_MEMSET_Z10 HAVE_MEMSET_IFUNC +# define HAVE_MEMSET_Z196 HAVE_MEMSET_IFUNC +#endif + +#if HAVE_MEMSET_Z10 || HAVE_MEMSET_Z196 +# define HAVE_MEMSET_MVCLE 1 +#else +# define HAVE_MEMSET_MVCLE 0 +#endif + +#if HAVE_MEMSET_Z900_G5 +# define MEMSET_Z900_G5 __memset_default +#else +# define MEMSET_Z900_G5 NULL +#endif + +#if HAVE_MEMSET_Z10 +# define MEMSET_Z10 __memset_z10 +#else +# define MEMSET_Z10 NULL +#endif + +#if HAVE_MEMSET_Z196 +# define MEMSET_Z196 __memset_z196 +#else +# define MEMSET_Z196 NULL +#endif diff --git a/sysdeps/s390/multiarch/memset-s390x.S b/sysdeps/s390/memset-z900.S similarity index 57% rename from sysdeps/s390/multiarch/memset-s390x.S rename to sysdeps/s390/memset-z900.S index aca3ac3fda..eaf13402bd 100644 --- a/sysdeps/s390/multiarch/memset-s390x.S +++ b/sysdeps/s390/memset-z900.S @@ -1,5 +1,6 @@ /* Set a block of memory to some byte value. 31/64 bit S/390 version. - Copyright (C) 2012-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2018 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,8 +18,9 @@ . */ -#include "sysdep.h" +#include #include "asm-syntax.h" +#include /* INPUT PARAMETERS %r2 = address of memory area @@ -27,43 +29,68 @@ .text -#if IS_IN (libc) +#if HAVE_MEMSET_Z900_G5 +# if defined __s390x__ +# define LTGR ltgr +# define CGHI cghi +# define LGR lgr +# define AGHI aghi +# define BRCTG brctg +# else +# define LTGR ltr +# define CGHI chi +# define LGR lr +# define AGHI ahi +# define BRCTG brct +# endif /* ! defined __s390x__ */ -ENTRY(__memset_z196) - .machine "z196" - .machinemode "zarch_nohighgprs" -# if !defined __s390x__ - llgfr %r4,%r4 -# endif /* !defined __s390x__ */ - ltgr %r4,%r4 - je .L_Z196_4 +ENTRY(MEMSET_Z900_G5) +#if defined __s390x__ + .machine "z900" +#else + .machine "g5" +#endif /* ! defined __s390x__ */ + LTGR %r4,%r4 + je .L_Z900_G5_4 stc %r3,0(%r2) - lgr %r1,%r2 - cghi %r4,1 - je .L_Z196_4 - aghi %r4,-2 - srlg %r5,%r4,8 - ltgr %r5,%r5 - jne .L_Z196_1 -.L_Z196_3: - exrl %r4,.L_Z196_17 -.L_Z196_4: + CGHI %r4,1 + LGR %r1,%r2 + je .L_Z900_G5_4 + AGHI %r4,-2 +#if defined __s390x__ + larl %r5,.L_Z900_G5_18 + srlg %r3,%r4,8 +# define Z900_G5_EX_D 0 +#else + basr %r5,0 +.L_Z900_G5_19: +# define Z900_G5_EX_D .L_Z900_G5_18-.L_Z900_G5_19 + lr %r3,%r4 + srl %r3,8 +#endif /* ! defined __s390x__ */ + LTGR %r3,%r3 + jne .L_Z900_G5_14 +.L_Z900_G5_3: + ex %r4,Z900_G5_EX_D(%r5) +.L_Z900_G5_4: br %r14 -.L_Z196_1: - cgfi %r5,1048576 - jh __memset_mvcle # Switch to mvcle for >256MB -.L_Z196_2: - pfd 2,1024(%r1) +.L_Z900_G5_14: mvc 1(256,%r1),0(%r1) - aghi %r5,-1 la %r1,256(%r1) - jne .L_Z196_2 - j .L_Z196_3 -.L_Z196_17: + BRCTG %r3,.L_Z900_G5_14 + j .L_Z900_G5_3 +.L_Z900_G5_18: mvc 1(1,%r1),0(%r1) -END(__memset_z196) +END(MEMSET_Z900_G5) +# undef LTGR +# undef CGHI +# undef LGR +# undef AGHI +# undef BRCTG +#endif /* HAVE_MEMSET_Z900_G5 */ -ENTRY(__memset_z10) +#if HAVE_MEMSET_Z10 +ENTRY(MEMSET_Z10) .machine "z10" .machinemode "zarch_nohighgprs" # if !defined __s390x__ @@ -91,8 +118,46 @@ ENTRY(__memset_z10) j .L_Z10_3 .L_Z10_18: mvc 1(1,%r1),0(%r1) -END(__memset_z10) +END(MEMSET_Z10) +#endif /* HAVE_MEMSET_Z10 */ + +#if HAVE_MEMSET_Z196 +ENTRY(MEMSET_Z196) + .machine "z196" + .machinemode "zarch_nohighgprs" +# if !defined __s390x__ + llgfr %r4,%r4 +# endif /* !defined __s390x__ */ + ltgr %r4,%r4 + je .L_Z196_4 + stc %r3,0(%r2) + lgr %r1,%r2 + cghi %r4,1 + je .L_Z196_4 + aghi %r4,-2 + srlg %r5,%r4,8 + ltgr %r5,%r5 + jne .L_Z196_1 +.L_Z196_3: + exrl %r4,.L_Z196_17 +.L_Z196_4: + br %r14 +.L_Z196_1: + cgfi %r5,1048576 + jh __memset_mvcle # Switch to mvcle for >256MB +.L_Z196_2: + pfd 2,1024(%r1) + mvc 1(256,%r1),0(%r1) + aghi %r5,-1 + la %r1,256(%r1) + jne .L_Z196_2 + j .L_Z196_3 +.L_Z196_17: + mvc 1(1,%r1),0(%r1) +END(MEMSET_Z196) +#endif /* HAVE_MEMSET_Z196 */ +#if HAVE_MEMSET_MVCLE ENTRY(__memset_mvcle) aghi %r4,2 # take back the change done by the caller lgr %r0,%r2 # save source address @@ -106,15 +171,16 @@ ENTRY(__memset_mvcle) .L1: br %r14 END(__memset_mvcle) +#endif /* HAVE_MEMSET_MVCLE */ -#endif /* IS_IN (libc) */ - -#include "../memset.S" +#if ! HAVE_MEMSET_IFUNC +/* If we don't use ifunc, define an alias for memset here. + Otherwise see sysdeps/s390/memset.c. */ +strong_alias (MEMSET_DEFAULT, memset) +#endif -#if !IS_IN (libc) -.globl memset -.set memset,__memset_default -#elif defined SHARED && IS_IN (libc) -.globl __GI_memset -.set __GI_memset,__memset_default +#if defined SHARED && IS_IN (libc) +/* Defines the internal symbol. + Compare to libc_hidden_builtin_def (memset) in string/memset.c. */ +strong_alias (MEMSET_DEFAULT, __GI_memset) #endif diff --git a/sysdeps/s390/memset.S b/sysdeps/s390/memset.S deleted file mode 100644 index 72e7c5a42e..0000000000 --- a/sysdeps/s390/memset.S +++ /dev/null @@ -1,97 +0,0 @@ -/* Set a block of memory to some byte value. 31/64 bit S/390 version. - Copyright (C) 2001-2018 Free Software Foundation, Inc. - Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). - 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 -#include "asm-syntax.h" - -/* INPUT PARAMETERS - %r2 = address of memory area - %r3 = byte to fill memory with - %r4 = number of bytes to fill. */ - - .text - -#if defined __s390x__ -# define LTGR ltgr -# define CGHI cghi -# define LGR lgr -# define AGHI aghi -# define BRCTG brctg -#else -# define LTGR ltr -# define CGHI chi -# define LGR lr -# define AGHI ahi -# define BRCTG brct -#endif /* ! defined __s390x__ */ - -#ifdef USE_MULTIARCH -ENTRY(__memset_default) -#else -ENTRY(memset) -#endif -#if defined __s390x__ - .machine "z900" -#else - .machine "g5" -#endif /* ! defined __s390x__ */ - LTGR %r4,%r4 - je .L_Z900_G5_4 - stc %r3,0(%r2) - CGHI %r4,1 - LGR %r1,%r2 - je .L_Z900_G5_4 - AGHI %r4,-2 -#if defined __s390x__ - larl %r5,.L_Z900_G5_18 - srlg %r3,%r4,8 -# define Z900_G5_EX_D 0 -#else - basr %r5,0 -.L_Z900_G5_19: -# define Z900_G5_EX_D .L_Z900_G5_18-.L_Z900_G5_19 - lr %r3,%r4 - srl %r3,8 -#endif /* ! defined __s390x__ */ - LTGR %r3,%r3 - jne .L_Z900_G5_14 -.L_Z900_G5_3: - ex %r4,Z900_G5_EX_D(%r5) -.L_Z900_G5_4: - br %r14 -.L_Z900_G5_14: - mvc 1(256,%r1),0(%r1) - la %r1,256(%r1) - BRCTG %r3,.L_Z900_G5_14 - j .L_Z900_G5_3 -.L_Z900_G5_18: - mvc 1(1,%r1),0(%r1) -#ifdef USE_MULTIARCH -END(__memset_default) -#else -END(memset) -libc_hidden_builtin_def (memset) -#endif - -#undef LTGR -#undef CGHI -#undef LGR -#undef AGHI -#undef BRCTG diff --git a/sysdeps/s390/multiarch/memset.c b/sysdeps/s390/memset.c similarity index 60% rename from sysdeps/s390/multiarch/memset.c rename to sysdeps/s390/memset.c index 760b3e9df2..57a35aebc7 100644 --- a/sysdeps/s390/multiarch/memset.c +++ b/sysdeps/s390/memset.c @@ -16,11 +16,33 @@ License along with the GNU C Library; if not, see . */ -#if IS_IN (libc) +#include +#if HAVE_MEMSET_IFUNC # define memset __redirect_memset # include # undef memset # include -s390_libc_ifunc (__redirect_memset, __memset, memset) +# if HAVE_MEMSET_Z900_G5 +extern __typeof (__redirect_memset) MEMSET_Z900_G5 attribute_hidden; +# endif + +# if HAVE_MEMSET_Z10 +extern __typeof (__redirect_memset) MEMSET_Z10 attribute_hidden; +# endif + +# if HAVE_MEMSET_Z196 +extern __typeof (__redirect_memset) MEMSET_Z196 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect_memset, memset, + ({ + s390_libc_ifunc_init (); + (HAVE_MEMSET_Z196 && S390_IS_Z196 (stfle_bits)) + ? MEMSET_Z196 + : (HAVE_MEMSET_Z10 && S390_IS_Z10 (stfle_bits)) + ? MEMSET_Z10 + : MEMSET_DEFAULT; + }) + ) #endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 93ad21bfa2..c893ebc565 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -19,8 +19,7 @@ sysdep_routines += strlen strlen-vx strlen-c \ rawmemchr rawmemchr-vx rawmemchr-c \ memccpy memccpy-vx memccpy-c \ memrchr memrchr-vx memrchr-c \ - mempcpy \ - memset memset-s390x + mempcpy endif ifeq ($(subdir),wcsmbs) diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index ec3373ae26..2f671eac1f 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -21,6 +21,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -46,12 +47,21 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, S390_STORE_STFLE (stfle_bits); } +#if HAVE_MEMSET_IFUNC IFUNC_IMPL (i, name, memset, +# if HAVE_MEMSET_Z196 IFUNC_IMPL_ADD (array, i, memset, - S390_IS_Z196 (stfle_bits), __memset_z196) + S390_IS_Z196 (stfle_bits), MEMSET_Z196) +# endif +# if HAVE_MEMSET_Z10 IFUNC_IMPL_ADD (array, i, memset, - S390_IS_Z10 (stfle_bits), __memset_z10) - IFUNC_IMPL_ADD (array, i, memset, 1, __memset_default)) + S390_IS_Z10 (stfle_bits), MEMSET_Z10) +# endif +# if HAVE_MEMSET_Z900_G5 + IFUNC_IMPL_ADD (array, i, memset, 1, MEMSET_Z900_G5) +# endif + ) +#endif /* HAVE_MEMSET_IFUNC */ IFUNC_IMPL (i, name, memcmp, IFUNC_IMPL_ADD (array, i, memcmp, From patchwork Fri Nov 30 15:57:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006030 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-97759-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="N3nn3gyE"; 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 435zd04Dy2z9s8r for ; Sat, 1 Dec 2018 03:00:36 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=hZ+5o/Z2hXb+ersIa0jjl+MmHBRIouj FEyy8UES9H8N+ANbdat+D7KJw0tc/3PLcNbW9AEnNmcgErPkioMQqcdQD8WTRYH4 0ir86g/UJEsQrRB3tWYhdNjt7zwc2siuOgsypR7MRHPNFofJcEPN+GYE5iRkQtIK uo/2m31wRLLE= 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=L5izijAV3dumwv8PNB+CLbdo+O0=; b=N3nn3 gyEx3ze43zVJcJFerr/DUdZczveo+eB9sT/kCrbamF8shw6/jD7WYXzzYqvTiKRG xPSJaxw+aiJVec+I7IF0MLcueSeqOLi1i1KQFuF3h9zAUkFmQ3klYRjQqVbYHRpK A3ZpJMXX2auM446v/Jf6DG9EfRjFByXeZvoO6w= Received: (qmail 17001 invoked by alias); 30 Nov 2018 15:59:30 -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 16862 invoked by uid 89); 30 Nov 2018 15:59:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 05/56] S390: Implement bzero with memset. Date: Fri, 30 Nov 2018 16:57:43 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0020-0000-0000-000002F039B0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0021-0000-0000-0000213FA02C Message-Id: <1543593514-10251-6-git-send-email-stli@linux.ibm.com> This patch removes the bzero s390 implementation with mvcle and adds entry points for bzero in memset ifunc variants. Therefore an ifunc resolver is implemented for bzero, too. ChangeLog: * sysdeps/s390/s390-32/bzero.S: Delete file. * sysdeps/s390/s390-64/bzero.S: Likewise. * sysdeps/s390/Makefile (sysdep_routines): Add bzero. * sysdeps/s390/bzero.c: New file. * sysdeps/s390/memset-z900.S: Add bzero entry points. * sysdeps/s390/ifunc-memset.h: Add bzero function macros. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Add bzero ifunc variants. --- sysdeps/s390/Makefile | 2 +- sysdeps/s390/{s390-32/bzero.S => bzero.c} | 53 +++++++++++++---------- sysdeps/s390/ifunc-memset.h | 9 ++++ sysdeps/s390/memset-z900.S | 37 +++++++++++++++- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 +++++++ sysdeps/s390/s390-64/bzero.S | 41 ------------------ 6 files changed, 89 insertions(+), 68 deletions(-) rename sysdeps/s390/{s390-32/bzero.S => bzero.c} (52%) delete mode 100644 sysdeps/s390/s390-64/bzero.S diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index f90a41d3ae..31ae2ce418 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -54,5 +54,5 @@ endif endif ifeq ($(subdir),string) -sysdep_routines += memset memset-z900 +sysdep_routines += bzero memset memset-z900 endif diff --git a/sysdeps/s390/s390-32/bzero.S b/sysdeps/s390/bzero.c similarity index 52% rename from sysdeps/s390/s390-32/bzero.S rename to sysdeps/s390/bzero.c index 897aa2154a..9f8d95781b 100644 --- a/sysdeps/s390/s390-32/bzero.S +++ b/sysdeps/s390/bzero.c @@ -1,7 +1,6 @@ -/* bzero -- set a block of memory to zero. IBM S390 version +/* Multiple versions of bzero. + Copyright (C) 2018 Free Software Foundation, Inc. This file is part of the GNU C Library. - Copyright (C) 2000-2018 Free Software Foundation, Inc. - Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -17,26 +16,32 @@ License along with the GNU C Library; if not, see . */ -/* - * R2 = address to memory area - * R3 = number of bytes to fill - */ - -#include "sysdep.h" -#include "asm-syntax.h" - - .text -ENTRY(__bzero) - ltr %r3,%r3 - jz .L1 - sr %r1,%r1 # set pad byte to zero - sr %r4,%r4 # no source for MVCLE, only a pad byte - sr %r5,%r5 -.L0: mvcle %r2,%r4,0(%r1) # thats it, MVCLE is your friend - jo .L0 -.L1: br %r14 -END(__bzero) - -#ifndef NO_WEAK_ALIAS +#include +#if HAVE_MEMSET_IFUNC +# include +# include + +# if HAVE_MEMSET_Z900_G5 +extern __typeof (__bzero) BZERO_Z900_G5 attribute_hidden; +# endif + +# if HAVE_MEMSET_Z10 +extern __typeof (__bzero) BZERO_Z10 attribute_hidden; +# endif + +# if HAVE_MEMSET_Z196 +extern __typeof (__bzero) BZERO_Z196 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__bzero, __bzero, + ({ + s390_libc_ifunc_init (); + (HAVE_MEMSET_Z196 && S390_IS_Z196 (stfle_bits)) + ? BZERO_Z196 + : (HAVE_MEMSET_Z10 && S390_IS_Z10 (stfle_bits)) + ? BZERO_Z10 + : BZERO_DEFAULT; + }) + ) weak_alias (__bzero, bzero) #endif diff --git a/sysdeps/s390/ifunc-memset.h b/sysdeps/s390/ifunc-memset.h index 9a13b1001f..32bc155f7e 100644 --- a/sysdeps/s390/ifunc-memset.h +++ b/sysdeps/s390/ifunc-memset.h @@ -25,16 +25,19 @@ #if defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT # define MEMSET_DEFAULT MEMSET_Z196 +# define BZERO_DEFAULT BZERO_Z196 # define HAVE_MEMSET_Z900_G5 0 # define HAVE_MEMSET_Z10 0 # define HAVE_MEMSET_Z196 1 #elif defined HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT # define MEMSET_DEFAULT MEMSET_Z10 +# define BZERO_DEFAULT BZERO_Z10 # define HAVE_MEMSET_Z900_G5 0 # define HAVE_MEMSET_Z10 1 # define HAVE_MEMSET_Z196 HAVE_MEMSET_IFUNC #else # define MEMSET_DEFAULT MEMSET_Z900_G5 +# define BZERO_DEFAULT BZERO_Z900_G5 # define HAVE_MEMSET_Z900_G5 1 # define HAVE_MEMSET_Z10 HAVE_MEMSET_IFUNC # define HAVE_MEMSET_Z196 HAVE_MEMSET_IFUNC @@ -48,18 +51,24 @@ #if HAVE_MEMSET_Z900_G5 # define MEMSET_Z900_G5 __memset_default +# define BZERO_Z900_G5 __bzero_default #else # define MEMSET_Z900_G5 NULL +# define BZERO_Z900_G5 NULL #endif #if HAVE_MEMSET_Z10 # define MEMSET_Z10 __memset_z10 +# define BZERO_Z10 __bzero_z10 #else # define MEMSET_Z10 NULL +# define BZERO_Z10 NULL #endif #if HAVE_MEMSET_Z196 # define MEMSET_Z196 __memset_z196 +# define BZERO_Z196 __bzero_z196 #else # define MEMSET_Z196 NULL +# define BZERO_Z196 NULL #endif diff --git a/sysdeps/s390/memset-z900.S b/sysdeps/s390/memset-z900.S index eaf13402bd..bfc659ae0b 100644 --- a/sysdeps/s390/memset-z900.S +++ b/sysdeps/s390/memset-z900.S @@ -22,10 +22,14 @@ #include "asm-syntax.h" #include -/* INPUT PARAMETERS +/* INPUT PARAMETERS - MEMSET %r2 = address of memory area %r3 = byte to fill memory with - %r4 = number of bytes to fill. */ + %r4 = number of bytes to fill. + + INPUT PARAMETERS - BZERO + %r2 = address of memory area + %r3 = number of bytes to fill. */ .text @@ -44,7 +48,14 @@ # define BRCTG brct # endif /* ! defined __s390x__ */ +ENTRY(BZERO_Z900_G5) + LGR %r4,%r3 + xr %r3,%r3 + j .L_Z900_G5_start +END(BZERO_Z900_G5) + ENTRY(MEMSET_Z900_G5) +.L_Z900_G5_start: #if defined __s390x__ .machine "z900" #else @@ -90,7 +101,16 @@ END(MEMSET_Z900_G5) #endif /* HAVE_MEMSET_Z900_G5 */ #if HAVE_MEMSET_Z10 +ENTRY(BZERO_Z10) + .machine "z10" + .machinemode "zarch_nohighgprs" + lgr %r4,%r3 + xr %r3,%r3 + j .L_Z10_start +END(BZERO_Z10) + ENTRY(MEMSET_Z10) +.L_Z10_start: .machine "z10" .machinemode "zarch_nohighgprs" # if !defined __s390x__ @@ -122,7 +142,16 @@ END(MEMSET_Z10) #endif /* HAVE_MEMSET_Z10 */ #if HAVE_MEMSET_Z196 +ENTRY(BZERO_Z196) + .machine "z196" + .machinemode "zarch_nohighgprs" + lgr %r4,%r3 + xr %r3,%r3 + j .L_Z196_start +END(BZERO_Z196) + ENTRY(MEMSET_Z196) +.L_Z196_start: .machine "z196" .machinemode "zarch_nohighgprs" # if !defined __s390x__ @@ -177,6 +206,10 @@ END(__memset_mvcle) /* If we don't use ifunc, define an alias for memset here. Otherwise see sysdeps/s390/memset.c. */ strong_alias (MEMSET_DEFAULT, memset) +/* Same for bzero. If ifunc is used, see + sysdeps/s390/bzero.c. */ +strong_alias (BZERO_DEFAULT, __bzero) +weak_alias (__bzero, bzero) #endif #if defined SHARED && IS_IN (libc) diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 2f671eac1f..253f36045b 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -59,6 +59,21 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, # endif # if HAVE_MEMSET_Z900_G5 IFUNC_IMPL_ADD (array, i, memset, 1, MEMSET_Z900_G5) +# endif + ) + + /* Note: bzero is implemented in memset. */ + IFUNC_IMPL (i, name, bzero, +# if HAVE_MEMSET_Z196 + IFUNC_IMPL_ADD (array, i, bzero, + S390_IS_Z196 (stfle_bits), BZERO_Z196) +# endif +# if HAVE_MEMSET_Z10 + IFUNC_IMPL_ADD (array, i, bzero, + S390_IS_Z10 (stfle_bits), BZERO_Z10) +# endif +# if HAVE_MEMSET_Z900_G5 + IFUNC_IMPL_ADD (array, i, bzero, 1, BZERO_Z900_G5) # endif ) #endif /* HAVE_MEMSET_IFUNC */ diff --git a/sysdeps/s390/s390-64/bzero.S b/sysdeps/s390/s390-64/bzero.S deleted file mode 100644 index b321665298..0000000000 --- a/sysdeps/s390/s390-64/bzero.S +++ /dev/null @@ -1,41 +0,0 @@ -/* bzero -- set a block of memory to zero. 64 bit S/390 version. - This file is part of the GNU C Library. - Copyright (C) 2001-2018 Free Software Foundation, Inc. - Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). - - 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 - . */ - -/* INPUT PARAMETERS - %r2 = address of memory area - %r3 = number of bytes to fill. */ - -#include "sysdep.h" -#include "asm-syntax.h" - - .text -ENTRY(__bzero) - ltgr %r3,%r3 - jz .L1 - sgr %r1,%r1 # set pad byte to zero - sgr %r4,%r4 # no source for MVCLE, only a pad byte - sgr %r5,%r5 -.L0: mvcle %r2,%r4,0(%r1) # thats it, MVCLE is your friend - jo .L0 -.L1: br %r14 -END(__bzero) - -#ifndef NO_WEAK_ALIAS -weak_alias (__bzero, bzero) -#endif From patchwork Fri Nov 30 15:57:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006032 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-97761-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="oTkjNmxv"; 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 435zfB2Lz7z9s8r for ; Sat, 1 Dec 2018 03:01:38 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=s3t6om37nNXyiP3pHiZEkdJ6aA9jOZC S7mfL+UZZ4u2BusNu58Q599S7DCUUkmA5kZ235zNBh8t5ZhOFc4M8pAvLTzUjzjo xU7Oy+MaOH3rnG08uEadgot8j9fWyZod3FhGUNSJvmzh9tnFlT8Z8GAqQPbKtK6I wC2zAWn+GOlM= 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=0MuKEff8EKnzPYANpo4rmvUN2Xc=; b=oTkjN mxvnLfHqZMN3IYHndhQ3ixE+scxaTebZpTZQktE0yChMdoc0xNj7ddSSgJiW4wbf bNxV5OvUJkRcx21trIdpibGZZQOhzealHurGWdZsHBtNCbTgeX+AD8sic3L31k/L TWnV4x6Pp1VaYpR5g3roS92fgCoV+nhgMCovCU= Received: (qmail 17469 invoked by alias); 30 Nov 2018 15:59:33 -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 17348 invoked by uid 89); 30 Nov 2018 15:59:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 06/56] S390: Unify 31/64bit memcmp. Date: Fri, 30 Nov 2018 16:57:44 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0016-0000-0000-0000022F30AD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0017-0000-0000-000032879BC6 Message-Id: <1543593514-10251-7-git-send-email-stli@linux.ibm.com> The implementation of memcmp for s390-32 (31bit) and s390-64 (64bit) is nearly the same. This patch unifies it for maintability reasons. __memcmp_z10 and __memcmp_z196 differs between 31 and 64bit: -31bit needs .machinemode "zarch_nohighgprs" and llgfr %r4,%r4 -lr vs lgr and some other instructions: But lgr and co can be also used on 31bit as this ifunc variant is only called if we are on a zarch machine. __memcmp_default differs between 31 and 64bit: -Some 31bit vs 64bit instructions (e.g. ltr vs ltgr. Solved with 31/64 specific instruction macros). -The address of mvc instruction is setup in different ways (larl vs bras). Solved with #if defined __s390x__. Otherwise 31/64bit implementation has the same structure of the code. ChangeLog: * sysdeps/s390/s390-64/memcmp.S: Move to ... * sysdeps/s390/memcmp.S: ... here. Adjust to be usable for 31/64bit. * sysdeps/s390/s390-32/memcmp.S: Delete File. * sysdeps/s390/multiarch/Makefile (sysdep_routines): Add memcmp. * sysdeps/s390/s390-32/multiarch/Makefile (sysdep_routines): Remove memcmp. * sysdeps/s390/s390-64/multiarch/Makefile: Likewise. * sysdeps/s390/s390-64/multiarch/memcmp-s390x.S: Move to ... * sysdeps/s390/multiarch/memcmp-s390x.S: ... here. Adjust to be usable for 31/64bit. * sysdeps/s390/s390-32/multiarch/memcmp-s390.S: Delete File. * sysdeps/s390/s390-64/multiarch/memcmp.c: Move to ... * sysdeps/s390/multiarch/memcmp.c: ... here. * sysdeps/s390/s390-32/multiarch/memcmp.c: Delete File. --- sysdeps/s390/{s390-64 => }/memcmp.S | 62 +++++++--- sysdeps/s390/multiarch/Makefile | 3 +- .../{s390-64 => }/multiarch/memcmp-s390x.S | 10 +- sysdeps/s390/{s390-32 => }/multiarch/memcmp.c | 0 sysdeps/s390/s390-32/memcmp.S | 66 ----------- sysdeps/s390/s390-32/multiarch/Makefile | 2 +- sysdeps/s390/s390-32/multiarch/memcmp-s390.S | 107 ------------------ sysdeps/s390/s390-64/multiarch/Makefile | 2 +- sysdeps/s390/s390-64/multiarch/memcmp.c | 27 ----- 9 files changed, 60 insertions(+), 219 deletions(-) rename sysdeps/s390/{s390-64 => }/memcmp.S (60%) rename sysdeps/s390/{s390-64 => }/multiarch/memcmp-s390x.S (89%) rename sysdeps/s390/{s390-32 => }/multiarch/memcmp.c (100%) delete mode 100644 sysdeps/s390/s390-32/memcmp.S delete mode 100644 sysdeps/s390/s390-32/multiarch/memcmp-s390.S delete mode 100644 sysdeps/s390/s390-64/multiarch/memcmp.c diff --git a/sysdeps/s390/s390-64/memcmp.S b/sysdeps/s390/memcmp.S similarity index 60% rename from sysdeps/s390/s390-64/memcmp.S rename to sysdeps/s390/memcmp.S index 005b19de45..751293a99e 100644 --- a/sysdeps/s390/s390-64/memcmp.S +++ b/sysdeps/s390/memcmp.S @@ -1,4 +1,4 @@ -/* memcmp - compare two memory blocks. 64 bit S/390 version. +/* memcmp - compare two memory blocks. 31/64 bit S/390 version. Copyright (C) 2012-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -26,34 +26,62 @@ %r4 = number of bytes to compare. */ .text +#if defined __s390x__ +# define LTGR ltgr +# define AGHI aghi +# define BRCTG brctg +#else +# define LTGR ltr +# define AGHI ahi +# define BRCTG brct +#endif /* ! defined __s390x__ */ + #ifdef USE_MULTIARCH ENTRY(__memcmp_default) #else ENTRY(memcmp) #endif +#if defined __s390x__ .machine "z900" - ltgr %r4,%r4 - je .L_Z900_4 - aghi %r4,-1 +#else + .machine "g5" + basr %r5,0 +.L_Z900_G5_16: +# define Z900_G5_EX_D .L_Z900_G5_15-.L_Z900_G5_16 +#endif /* ! defined __s390x__ */ + LTGR %r4,%r4 + je .L_Z900_G5_4 + AGHI %r4,-1 +#if defined __s390x__ srlg %r1,%r4,8 - ltgr %r1,%r1 - jne .L_Z900_12 -.L_Z900_3: - larl %r1,.L_Z900_15 - ex %r4,0(%r1) -.L_Z900_4: + larl %r5,.L_Z900_G5_15 +# define Z900_G5_EX_D 0 +#else + lr %r1,%r4 + srl %r1,8 +#endif /* ! defined __s390x__ */ + LTGR %r1,%r1 + jne .L_Z900_G5_12 +.L_Z900_G5_3: + ex %r4,Z900_G5_EX_D(%r5) +.L_Z900_G5_4: ipm %r2 +#if defined __s390x__ sllg %r2,%r2,34 srag %r2,%r2,62 +#else + sll %r2,2 + sra %r2,30 +#endif /* ! defined __s390x__ */ br %r14 -.L_Z900_12: +.L_Z900_G5_12: clc 0(256,%r3),0(%r2) - jne .L_Z900_4 + jne .L_Z900_G5_4 la %r3,256(%r3) la %r2,256(%r2) - brctg %r1,.L_Z900_12 - j .L_Z900_3 -.L_Z900_15: + BRCTG %r1,.L_Z900_G5_12 + j .L_Z900_G5_3 +.L_Z900_G5_15: clc 0(1,%r3),0(%r2) #ifdef USE_MULTIARCH END(__memcmp_default) @@ -62,3 +90,7 @@ END(memcmp) libc_hidden_builtin_def (memcmp) weak_alias (memcmp, bcmp) #endif + +#undef LTGR +#undef AGHI +#undef BRCTG diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index c893ebc565..53dd8654d7 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -19,7 +19,8 @@ sysdep_routines += strlen strlen-vx strlen-c \ rawmemchr rawmemchr-vx rawmemchr-c \ memccpy memccpy-vx memccpy-c \ memrchr memrchr-vx memrchr-c \ - mempcpy + mempcpy \ + memcmp memcmp-s390x endif ifeq ($(subdir),wcsmbs) diff --git a/sysdeps/s390/s390-64/multiarch/memcmp-s390x.S b/sysdeps/s390/multiarch/memcmp-s390x.S similarity index 89% rename from sysdeps/s390/s390-64/multiarch/memcmp-s390x.S rename to sysdeps/s390/multiarch/memcmp-s390x.S index 35f9bf9cf7..6321737ace 100644 --- a/sysdeps/s390/s390-64/multiarch/memcmp-s390x.S +++ b/sysdeps/s390/multiarch/memcmp-s390x.S @@ -1,4 +1,4 @@ -/* CPU specific memcmp implementations. 64 bit S/390 version. +/* CPU specific memcmp implementations. 31/64 bit S/390 version. Copyright (C) 2012-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -31,6 +31,10 @@ ENTRY(__memcmp_z196) .machine "z196" + .machinemode "zarch_nohighgprs" +# if !defined __s390x__ + llgfr %r4,%r4 +# endif /* !defined __s390x__ */ ltgr %r4,%r4 je .L_Z196_4 aghi %r4,-1 @@ -64,6 +68,10 @@ END(__memcmp_z196) ENTRY(__memcmp_z10) .machine "z10" + .machinemode "zarch_nohighgprs" +# if !defined __s390x__ + llgfr %r4,%r4 +# endif /* !defined __s390x__ */ ltgr %r4,%r4 je .L_Z10_4 aghi %r4,-1 diff --git a/sysdeps/s390/s390-32/multiarch/memcmp.c b/sysdeps/s390/multiarch/memcmp.c similarity index 100% rename from sysdeps/s390/s390-32/multiarch/memcmp.c rename to sysdeps/s390/multiarch/memcmp.c diff --git a/sysdeps/s390/s390-32/memcmp.S b/sysdeps/s390/s390-32/memcmp.S deleted file mode 100644 index f9ad0bc745..0000000000 --- a/sysdeps/s390/s390-32/memcmp.S +++ /dev/null @@ -1,66 +0,0 @@ -/* memcmp - compare two memory blocks. 32 bit S/390 version. - Copyright (C) 2012-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 "sysdep.h" -#include "asm-syntax.h" - -/* INPUT PARAMETERS - %r2 = address of first memory area - %r3 = address of second memory area - %r4 = number of bytes to compare. */ - - .text -#ifdef USE_MULTIARCH -ENTRY(__memcmp_default) -#else -ENTRY(memcmp) -#endif - .machine "g5" - basr %r5,0 -.L_G5_16: - ltr %r4,%r4 - je .L_G5_4 - ahi %r4,-1 - lr %r1,%r4 - srl %r1,8 - ltr %r1,%r1 - jne .L_G5_12 - ex %r4,.L_G5_17-.L_G5_16(%r5) -.L_G5_4: - ipm %r2 - sll %r2,2 - sra %r2,30 - br %r14 -.L_G5_12: - clc 0(256,%r3),0(%r2) - jne .L_G5_4 - la %r3,256(%r3) - la %r2,256(%r2) - brct %r1,.L_G5_12 - ex %r4,.L_G5_17-.L_G5_16(%r5) - j .L_G5_4 -.L_G5_17: - clc 0(1,%r3),0(%r2) -#ifdef USE_MULTIARCH -END(__memcmp_default) -#else -END(memcmp) -libc_hidden_builtin_def (memcmp) -weak_alias(memcmp, bcmp) -#endif diff --git a/sysdeps/s390/s390-32/multiarch/Makefile b/sysdeps/s390/s390-32/multiarch/Makefile index 4b11e28656..82a7492eb8 100644 --- a/sysdeps/s390/s390-32/multiarch/Makefile +++ b/sysdeps/s390/s390-32/multiarch/Makefile @@ -1,3 +1,3 @@ ifeq ($(subdir),string) -sysdep_routines += memcpy memcpy-s390 memcmp memcmp-s390 +sysdep_routines += memcpy memcpy-s390 endif diff --git a/sysdeps/s390/s390-32/multiarch/memcmp-s390.S b/sysdeps/s390/s390-32/multiarch/memcmp-s390.S deleted file mode 100644 index e53b508c98..0000000000 --- a/sysdeps/s390/s390-32/multiarch/memcmp-s390.S +++ /dev/null @@ -1,107 +0,0 @@ -/* CPU specific memcmp implementations. 32 bit S/390 version. - Copyright (C) 2012-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 "sysdep.h" -#include "asm-syntax.h" - -/* INPUT PARAMETERS - %r2 = address of first memory area - %r3 = address of second memory area - %r4 = number of bytes to compare. */ - - .text - -#if IS_IN (libc) - -ENTRY(__memcmp_z196) - .machine "z196" - .machinemode "zarch_nohighgprs" - ltr %r4,%r4 - je .L_Z196_4 - ahi %r4,-1 - srlk %r1,%r4,8 - ltr %r1,%r1 - jne .L_Z196_2 -.L_Z196_3: - exrl %r4,.L_Z196_14 -.L_Z196_4: - ipm %r2 - sll %r2,2 - sra %r2,30 - br %r14 -.L_Z196_17: - la %r3,256(%r3) - la %r2,256(%r2) - ahi %r1,-1 - je .L_Z196_3 -.L_Z196_2: - pfd 1,512(%r3) - pfd 1,512(%r2) - clc 0(256,%r3),0(%r2) - je .L_Z196_17 - ipm %r2 - sll %r2,2 - sra %r2,30 - br %r14 -.L_Z196_14: - clc 0(1,%r3),0(%r2) -END(__memcmp_z196) - -ENTRY(__memcmp_z10) - .machine "z10" - .machinemode "zarch_nohighgprs" - ltr %r4,%r4 - je .L_Z10_4 - ahi %r4,-1 - lr %r1,%r4 - srl %r1,8 - cijlh %r1,0,.L_Z10_12 -.L_Z10_3: - exrl %r4,.L_Z10_15 -.L_Z10_4: - ipm %r2 - sll %r2,2 - sra %r2,30 - br %r14 -.L_Z10_12: - pfd 1,512(%r3) - pfd 1,512(%r2) - clc 0(256,%r3),0(%r2) - jne .L_Z10_4 - la %r3,256(%r3) - la %r2,256(%r2) - brct %r1,.L_Z10_12 - j .L_Z10_3 -.L_Z10_15: - clc 0(1,%r3),0(%r2) -END(__memcmp_z10) - -#endif /* IS_IN (libc) */ - -#include "../memcmp.S" - -#if !IS_IN (libc) -.globl memcmp -.set memcmp,__memcmp_default -.weak bcmp -.set bcmp,__memcmp_default -#elif defined SHARED && IS_IN (libc) -.globl __GI_memcmp -.set __GI_memcmp,__memcmp_default -#endif diff --git a/sysdeps/s390/s390-64/multiarch/Makefile b/sysdeps/s390/s390-64/multiarch/Makefile index e4870c7ee1..8a043e3327 100644 --- a/sysdeps/s390/s390-64/multiarch/Makefile +++ b/sysdeps/s390/s390-64/multiarch/Makefile @@ -1,3 +1,3 @@ ifeq ($(subdir),string) -sysdep_routines += memcpy memcpy-s390x memcmp memcmp-s390x +sysdep_routines += memcpy memcpy-s390x endif diff --git a/sysdeps/s390/s390-64/multiarch/memcmp.c b/sysdeps/s390/s390-64/multiarch/memcmp.c deleted file mode 100644 index 1e6f31806e..0000000000 --- a/sysdeps/s390/s390-64/multiarch/memcmp.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Multiple versions of memcmp. - Copyright (C) 2015-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 - . */ - -#if IS_IN (libc) -# define memcmp __redirect_memcmp -# include -# undef memcmp -# include - -s390_libc_ifunc (__redirect_memcmp, __memcmp, memcmp) -weak_alias (memcmp, bcmp); -#endif From patchwork Fri Nov 30 15:57:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006034 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-97763-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="Y8tyQceG"; 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 435zfb1zlBz9s8r for ; Sat, 1 Dec 2018 03:01:59 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=J7jYCY9w71/5rKBdwduKNLa1F6l/V87 Nq57wMI4yA9jxJJyxGrqMSbneNLnGjMg+PU0XHrUPLwcmZFs/HYu0t3CZizRpJWV uYgIAaFNVrkYXQIy4gANMy+wPNhWXvXn+Tr3ehbsbIjf6TenQEEyEFVihQviMthg RGo5C1zNUyMQ= 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=CwsuiHpWx3ofXJ7TbnmgWXpBS9Q=; b=Y8tyQ ceG/6IiwzOWb5/BnmqVz82SJBBO9raeJ/IrZ9h6qR2VkssARYgyv1gHkDh9VNZLh GjGfgG+UyRKAxMWZTBRVhEXL1fkgWXA/R7VspbTQxPzoe2710vmftIAqcB1ctmWQ s5OombC7dfTZHi5KKPxaVcHGGLfZCmW05vJYSE= Received: (qmail 17994 invoked by alias); 30 Nov 2018 15:59: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 17745 invoked by uid 89); 30 Nov 2018 15:59:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 07/56] S390: Refactor memcmp ifunc handling. Date: Fri, 30 Nov 2018 16:57:45 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0028-0000-0000-00000323FCA9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0029-0000-0000-000023E01256 Message-Id: <1543593514-10251-8-git-send-email-stli@linux.ibm.com> This patch moves all ifunc variants for memcmp to sysdeps/s390/memcmp-z900.S. The configure-check/preprocessor logic in sysdeps/s390/ifunc-memcmp.h decides if ifunc is needed at all and which ifunc variants should be available. E.g. if the compiler/assembler already supports z196 by default, the older ifunc variants are not included. If we only need the newest ifunc variant, then we can skip ifunc at all. Therefore the ifunc-resolvers and __libc_ifunc_impl_list are adjusted in order to handle only the available ifunc variants. ChangeLog: * sysdeps/s390/ifunc-memcmp.h: New File. * sysdeps/s390/memcmp.S: Move to ... * sysdeps/s390/memcmp-z900.S ... here. Move implementations from memcmp-s390x.s to here. * sysdeps/s390/multiarch/memcmp-s390x.S: Delete File. * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove memcmp variants. * sysdeps/s390/Makefile (sysdep_routines): Add memcmp variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Adjust ifunc variants for memcmp. * sysdeps/s390/multiarch/memcmp.c: Move ifunc resolver to ... * sysdeps/s390/memcmp.c: ... here. Adjust ifunc variants for memcmp. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-memcmp.h | 59 +++++++ .../memcmp-s390x.S => memcmp-z900.S} | 149 ++++++++++++------ sysdeps/s390/memcmp.S | 96 ----------- sysdeps/s390/{multiarch => }/memcmp.c | 26 ++- sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 16 +- 7 files changed, 204 insertions(+), 148 deletions(-) create mode 100644 sysdeps/s390/ifunc-memcmp.h rename sysdeps/s390/{multiarch/memcmp-s390x.S => memcmp-z900.S} (54%) delete mode 100644 sysdeps/s390/memcmp.S rename sysdeps/s390/{multiarch => }/memcmp.c (60%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 31ae2ce418..44a2f28bfd 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -54,5 +54,6 @@ endif endif ifeq ($(subdir),string) -sysdep_routines += bzero memset memset-z900 +sysdep_routines += bzero memset memset-z900 \ + memcmp memcmp-z900 endif diff --git a/sysdeps/s390/ifunc-memcmp.h b/sysdeps/s390/ifunc-memcmp.h new file mode 100644 index 0000000000..536ac455d1 --- /dev/null +++ b/sysdeps/s390/ifunc-memcmp.h @@ -0,0 +1,59 @@ +/* memcmp variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT +# define HAVE_MEMCMP_IFUNC 1 +#else +# define HAVE_MEMCMP_IFUNC 0 +#endif + +#if defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT +# define MEMCMP_DEFAULT MEMCMP_Z196 +# define HAVE_MEMCMP_Z900_G5 0 +# define HAVE_MEMCMP_Z10 0 +# define HAVE_MEMCMP_Z196 1 +#elif defined HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT +# define MEMCMP_DEFAULT MEMCMP_Z10 +# define HAVE_MEMCMP_Z900_G5 0 +# define HAVE_MEMCMP_Z10 1 +# define HAVE_MEMCMP_Z196 HAVE_MEMCMP_IFUNC +#else +# define MEMCMP_DEFAULT MEMCMP_Z900_G5 +# define HAVE_MEMCMP_Z900_G5 1 +# define HAVE_MEMCMP_Z10 HAVE_MEMCMP_IFUNC +# define HAVE_MEMCMP_Z196 HAVE_MEMCMP_IFUNC +#endif + +#if HAVE_MEMCMP_Z900_G5 +# define MEMCMP_Z900_G5 __memcmp_default +#else +# define MEMCMP_Z900_G5 NULL +#endif + +#if HAVE_MEMCMP_Z10 +# define MEMCMP_Z10 __memcmp_z10 +#else +# define MEMCMP_Z10 NULL +#endif + +#if HAVE_MEMCMP_Z196 +# define MEMCMP_Z196 __memcmp_z196 +#else +# define MEMCMP_Z196 NULL +#endif diff --git a/sysdeps/s390/multiarch/memcmp-s390x.S b/sysdeps/s390/memcmp-z900.S similarity index 54% rename from sysdeps/s390/multiarch/memcmp-s390x.S rename to sysdeps/s390/memcmp-z900.S index 6321737ace..c3b3677ba7 100644 --- a/sysdeps/s390/multiarch/memcmp-s390x.S +++ b/sysdeps/s390/memcmp-z900.S @@ -1,4 +1,4 @@ -/* CPU specific memcmp implementations. 31/64 bit S/390 version. +/* memcmp - compare two memory blocks. 31/64 bit S/390 version. Copyright (C) 2012-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -17,8 +17,9 @@ . */ -#include "sysdep.h" +#include #include "asm-syntax.h" +#include /* INPUT PARAMETERS %r2 = address of first memory area @@ -27,46 +28,67 @@ .text -#if IS_IN (libc) - -ENTRY(__memcmp_z196) - .machine "z196" - .machinemode "zarch_nohighgprs" -# if !defined __s390x__ - llgfr %r4,%r4 -# endif /* !defined __s390x__ */ - ltgr %r4,%r4 - je .L_Z196_4 - aghi %r4,-1 +#if HAVE_MEMCMP_Z900_G5 +# if defined __s390x__ +# define LTGR ltgr +# define AGHI aghi +# define BRCTG brctg +# else +# define LTGR ltr +# define AGHI ahi +# define BRCTG brct +# endif /* ! defined __s390x__ */ +ENTRY(MEMCMP_Z900_G5) +# if defined __s390x__ + .machine "z900" +# else + .machine "g5" + basr %r5,0 +.L_Z900_G5_16: +# define Z900_G5_EX_D .L_Z900_G5_15-.L_Z900_G5_16 +# endif /* ! defined __s390x__ */ + LTGR %r4,%r4 + je .L_Z900_G5_4 + AGHI %r4,-1 +# if defined __s390x__ srlg %r1,%r4,8 - ltgr %r1,%r1 - jne .L_Z196_2 -.L_Z196_3: - exrl %r4,.L_Z196_14 -.L_Z196_4: + larl %r5,.L_Z900_G5_15 +# define Z900_G5_EX_D 0 +# else + lr %r1,%r4 + srl %r1,8 +# endif /* ! defined __s390x__ */ + LTGR %r1,%r1 + jne .L_Z900_G5_12 +.L_Z900_G5_3: + ex %r4,Z900_G5_EX_D(%r5) +.L_Z900_G5_4: ipm %r2 +# if defined __s390x__ sllg %r2,%r2,34 srag %r2,%r2,62 +# else + sll %r2,2 + sra %r2,30 +# endif /* ! defined __s390x__ */ br %r14 -.L_Z196_17: +.L_Z900_G5_12: + clc 0(256,%r3),0(%r2) + jne .L_Z900_G5_4 la %r3,256(%r3) la %r2,256(%r2) - aghi %r1,-1 - je .L_Z196_3 -.L_Z196_2: - pfd 1,512(%r3) - pfd 1,512(%r2) - clc 0(256,%r3),0(%r2) - je .L_Z196_17 - ipm %r2 - sllg %r2,%r2,34 - srag %r2,%r2,62 - br %r14 -.L_Z196_14: + BRCTG %r1,.L_Z900_G5_12 + j .L_Z900_G5_3 +.L_Z900_G5_15: clc 0(1,%r3),0(%r2) -END(__memcmp_z196) +END(MEMCMP_Z900_G5) +# undef LTGR +# undef AGHI +# undef BRCTG +#endif /* HAVE_MEMCMP_Z900_G5 */ -ENTRY(__memcmp_z10) +#if HAVE_MEMCMP_Z10 +ENTRY(MEMCMP_Z10) .machine "z10" .machinemode "zarch_nohighgprs" # if !defined __s390x__ @@ -95,18 +117,57 @@ ENTRY(__memcmp_z10) j .L_Z10_3 .L_Z10_15: clc 0(1,%r3),0(%r2) -END(__memcmp_z10) +END(MEMCMP_Z10) +#endif /* HAVE_MEMCMP_Z10 */ -#endif /* IS_IN (libc) */ +#if HAVE_MEMCMP_Z196 +ENTRY(MEMCMP_Z196) + .machine "z196" + .machinemode "zarch_nohighgprs" +# if !defined __s390x__ + llgfr %r4,%r4 +# endif /* !defined __s390x__ */ + ltgr %r4,%r4 + je .L_Z196_4 + aghi %r4,-1 + srlg %r1,%r4,8 + ltgr %r1,%r1 + jne .L_Z196_2 +.L_Z196_3: + exrl %r4,.L_Z196_14 +.L_Z196_4: + ipm %r2 + sllg %r2,%r2,34 + srag %r2,%r2,62 + br %r14 +.L_Z196_17: + la %r3,256(%r3) + la %r2,256(%r2) + aghi %r1,-1 + je .L_Z196_3 +.L_Z196_2: + pfd 1,512(%r3) + pfd 1,512(%r2) + clc 0(256,%r3),0(%r2) + je .L_Z196_17 + ipm %r2 + sllg %r2,%r2,34 + srag %r2,%r2,62 + br %r14 +.L_Z196_14: + clc 0(1,%r3),0(%r2) +END(MEMCMP_Z196) +#endif /* HAVE_MEMCMP_Z196 */ -#include "../memcmp.S" +#if ! HAVE_MEMCMP_IFUNC +/* If we don't use ifunc, define an alias for memcmp here. + Otherwise see sysdeps/s390/memcmp.c. */ +strong_alias (MEMCMP_DEFAULT, memcmp) +weak_alias (memcmp, bcmp) +#endif -#if !IS_IN (libc) -.globl memcmp -.set memcmp,__memcmp_default -.weak bcmp -.set bcmp,__memcmp_default -#elif defined SHARED && IS_IN (libc) -.globl __GI_memcmp -.set __GI_memcmp,__memcmp_default +#if defined SHARED && IS_IN (libc) +/* Defines the internal symbols. + Compare to libc_hidden_builtin_def (memcmp) in string/memcmp.c. */ +strong_alias (MEMCMP_DEFAULT, __GI_memcmp) #endif diff --git a/sysdeps/s390/memcmp.S b/sysdeps/s390/memcmp.S deleted file mode 100644 index 751293a99e..0000000000 --- a/sysdeps/s390/memcmp.S +++ /dev/null @@ -1,96 +0,0 @@ -/* memcmp - compare two memory blocks. 31/64 bit S/390 version. - Copyright (C) 2012-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 -#include "asm-syntax.h" - -/* INPUT PARAMETERS - %r2 = address of first memory area - %r3 = address of second memory area - %r4 = number of bytes to compare. */ - - .text -#if defined __s390x__ -# define LTGR ltgr -# define AGHI aghi -# define BRCTG brctg -#else -# define LTGR ltr -# define AGHI ahi -# define BRCTG brct -#endif /* ! defined __s390x__ */ - -#ifdef USE_MULTIARCH -ENTRY(__memcmp_default) -#else -ENTRY(memcmp) -#endif -#if defined __s390x__ - .machine "z900" -#else - .machine "g5" - basr %r5,0 -.L_Z900_G5_16: -# define Z900_G5_EX_D .L_Z900_G5_15-.L_Z900_G5_16 -#endif /* ! defined __s390x__ */ - LTGR %r4,%r4 - je .L_Z900_G5_4 - AGHI %r4,-1 -#if defined __s390x__ - srlg %r1,%r4,8 - larl %r5,.L_Z900_G5_15 -# define Z900_G5_EX_D 0 -#else - lr %r1,%r4 - srl %r1,8 -#endif /* ! defined __s390x__ */ - LTGR %r1,%r1 - jne .L_Z900_G5_12 -.L_Z900_G5_3: - ex %r4,Z900_G5_EX_D(%r5) -.L_Z900_G5_4: - ipm %r2 -#if defined __s390x__ - sllg %r2,%r2,34 - srag %r2,%r2,62 -#else - sll %r2,2 - sra %r2,30 -#endif /* ! defined __s390x__ */ - br %r14 -.L_Z900_G5_12: - clc 0(256,%r3),0(%r2) - jne .L_Z900_G5_4 - la %r3,256(%r3) - la %r2,256(%r2) - BRCTG %r1,.L_Z900_G5_12 - j .L_Z900_G5_3 -.L_Z900_G5_15: - clc 0(1,%r3),0(%r2) -#ifdef USE_MULTIARCH -END(__memcmp_default) -#else -END(memcmp) -libc_hidden_builtin_def (memcmp) -weak_alias (memcmp, bcmp) -#endif - -#undef LTGR -#undef AGHI -#undef BRCTG diff --git a/sysdeps/s390/multiarch/memcmp.c b/sysdeps/s390/memcmp.c similarity index 60% rename from sysdeps/s390/multiarch/memcmp.c rename to sysdeps/s390/memcmp.c index 1e6f31806e..952ff6af73 100644 --- a/sysdeps/s390/multiarch/memcmp.c +++ b/sysdeps/s390/memcmp.c @@ -16,12 +16,34 @@ License along with the GNU C Library; if not, see . */ -#if IS_IN (libc) +#include +#if HAVE_MEMCMP_IFUNC # define memcmp __redirect_memcmp # include # undef memcmp # include -s390_libc_ifunc (__redirect_memcmp, __memcmp, memcmp) +# if HAVE_MEMCMP_Z900_G5 +extern __typeof (__redirect_memcmp) MEMCMP_Z900_G5 attribute_hidden; +# endif + +# if HAVE_MEMCMP_Z10 +extern __typeof (__redirect_memcmp) MEMCMP_Z10 attribute_hidden; +# endif + +# if HAVE_MEMCMP_Z196 +extern __typeof (__redirect_memcmp) MEMCMP_Z196 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect_memcmp, memcmp, + ({ + s390_libc_ifunc_init (); + (HAVE_MEMCMP_Z196 && S390_IS_Z196 (stfle_bits)) + ? MEMCMP_Z196 + : (HAVE_MEMCMP_Z10 && S390_IS_Z10 (stfle_bits)) + ? MEMCMP_Z10 + : MEMCMP_DEFAULT; + }) + ) weak_alias (memcmp, bcmp); #endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 53dd8654d7..c893ebc565 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -19,8 +19,7 @@ sysdep_routines += strlen strlen-vx strlen-c \ rawmemchr rawmemchr-vx rawmemchr-c \ memccpy memccpy-vx memccpy-c \ memrchr memrchr-vx memrchr-c \ - mempcpy \ - memcmp memcmp-s390x + mempcpy endif ifeq ($(subdir),wcsmbs) diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 253f36045b..2e57d01abc 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -22,6 +22,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -78,12 +79,21 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_MEMSET_IFUNC */ +#if HAVE_MEMCMP_IFUNC IFUNC_IMPL (i, name, memcmp, +# if HAVE_MEMCMP_Z196 IFUNC_IMPL_ADD (array, i, memcmp, - S390_IS_Z196 (stfle_bits), __memcmp_z196) + S390_IS_Z196 (stfle_bits), MEMCMP_Z196) +# endif +# if HAVE_MEMCMP_Z10 IFUNC_IMPL_ADD (array, i, memcmp, - S390_IS_Z10 (stfle_bits), __memcmp_z10) - IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_default)) + S390_IS_Z10 (stfle_bits), MEMCMP_Z10) +# endif +# if HAVE_MEMCMP_Z900_G5 + IFUNC_IMPL_ADD (array, i, memcmp, 1, MEMCMP_Z900_G5) +# endif + ) +#endif /* HAVE_MEMCMP_IFUNC */ #ifdef SHARED From patchwork Fri Nov 30 15:57:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006035 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-97764-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="bmORdOhe"; 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 435zfp0LLcz9sBZ for ; Sat, 1 Dec 2018 03:02:09 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=pSHMQl8vRD7OW9dMPO6Jy9JkqhlNbdc jUnNPonFtqGPHgCDmGzqaM6eTS0U9vgtszr+/idZFAC/fLIxkNOHyL190KGnY3h/ LO063iWDM7kljVltROCZ2aIFVZfjg6qzLwkq21D86xziEpT+zyjP/WdfojkTXolL JBu86xwTNijo= 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=fWTit+cRJNIQI2Eb91ugw4bsecA=; b=bmORd OhepQRXDh4rx76hpn2FeP95fGC6RtfmBW19z6JB7/LL5ZJdbR/1nPloS9wu4Xbbp OiF8hEx364L8Bw6yvu+DnEK4aPccx4WLLTmOrFMOdihjCTz7BM5lDMfLHaDQpG94 YUKLKo3XkwIW6/lQRU0u/D5yFew+OxzLlHn97E= Received: (qmail 18609 invoked by alias); 30 Nov 2018 15:59:41 -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 18196 invoked by uid 89); 30 Nov 2018 15:59:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 08/56] S390: Unify 31/64bit memcpy. Date: Fri, 30 Nov 2018 16:57:46 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0028-0000-0000-00000323FCAB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0029-0000-0000-000023E01257 Message-Id: <1543593514-10251-9-git-send-email-stli@linux.ibm.com> The implementation of memcpy/mempcpy for s390-32 (31bit) and s390-64 (64bit) is nearly the same. This patch unifies it for maintability reasons. __mem[p]cpy_z10 and __mem[p]cpy_z196 differs between 31 and 64bit: -31bit needs .machinemode "zarch_nohighgprs" and llgfr %r4,%r4 -lr vs lgr; lgr can be also used on 31bit as this ifunc variant is only called if we are on a zarch machine. __mem[p]cpy_default differs between 31 and 64bit: -Some 31bit vs 64bit instructions (e.g. ltr vs ltgr. Solved with 31/64 specific instruction macros). -The address of mvc instruction is setup in different ways (larl vs bras). Solved with #if defined __s390x__. __memcpy_mvcle differs between 31 and 64bit: -lr vs lgr; ahi vs aghi; Solved with 31/64bit specific instruction macros. Otherwise 31/64bit implementation has the same structure of the code. ChangeLog: * sysdeps/s390/s390-64/memcpy.S: Move to ... * sysdeps/s390/memcpy.S: ... here. Adjust to be usable for 31/64bit. * sysdeps/s390/s390-32/memcpy.S: Delete File. * sysdeps/s390/multiarch/Makefile (sysdep_routines): Add memcpy. * sysdeps/s390/s390-32/multiarch/Makefile: Delete file. * sysdeps/s390/s390-64/multiarch/Makefile: Likewise. * sysdeps/s390/s390-64/multiarch/memcpy-s390x.S: Move to ... * sysdeps/s390/multiarch/memcpy-s390x.S: ... here. Adjust to be usable for 31/64bit. * sysdeps/s390/s390-32/multiarch/memcpy-s390.S: Delete File. * sysdeps/s390/s390-64/multiarch/memcpy.c: Move to ... * sysdeps/s390/multiarch/memcpy.c: ... here. * sysdeps/s390/s390-32/multiarch/memcpy.c: Delete File. --- sysdeps/s390/{s390-64 => }/memcpy.S | 98 ++++++++++---- sysdeps/s390/multiarch/Makefile | 2 +- .../{s390-64 => }/multiarch/memcpy-s390x.S | 12 +- sysdeps/s390/{s390-32 => }/multiarch/memcpy.c | 0 sysdeps/s390/s390-32/memcpy.S | 89 ------------ sysdeps/s390/s390-32/multiarch/Makefile | 3 - sysdeps/s390/s390-32/multiarch/memcpy-s390.S | 128 ------------------ sysdeps/s390/s390-64/multiarch/Makefile | 3 - sysdeps/s390/s390-64/multiarch/memcpy.c | 27 ---- 9 files changed, 81 insertions(+), 281 deletions(-) rename sysdeps/s390/{s390-64 => }/memcpy.S (52%) rename sysdeps/s390/{s390-64 => }/multiarch/memcpy-s390x.S (89%) rename sysdeps/s390/{s390-32 => }/multiarch/memcpy.c (100%) delete mode 100644 sysdeps/s390/s390-32/memcpy.S delete mode 100644 sysdeps/s390/s390-32/multiarch/Makefile delete mode 100644 sysdeps/s390/s390-32/multiarch/memcpy-s390.S delete mode 100644 sysdeps/s390/s390-64/multiarch/Makefile delete mode 100644 sysdeps/s390/s390-64/multiarch/memcpy.c diff --git a/sysdeps/s390/s390-64/memcpy.S b/sysdeps/s390/memcpy.S similarity index 52% rename from sysdeps/s390/s390-64/memcpy.S rename to sysdeps/s390/memcpy.S index 2e5490df23..2a6c6b7503 100644 --- a/sysdeps/s390/s390-64/memcpy.S +++ b/sysdeps/s390/memcpy.S @@ -1,4 +1,4 @@ -/* memcpy - copy a block from source to destination. 64 bit S/390 version. +/* memcpy - copy a block from source to destination. 31/64 bit S/390 version. Copyright (C) 2012-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -25,13 +25,31 @@ %r3 = address of source memory area %r4 = number of bytes to copy. */ - .text + +#if defined __s390x__ +# define LTGR ltgr +# define CGHI cghi +# define LGR lgr +# define AGHI aghi +# define BRCTG brctg +#else +# define LTGR ltr +# define CGHI chi +# define LGR lr +# define AGHI ahi +# define BRCTG brct +#endif /* ! defined __s390x__ */ + ENTRY(__mempcpy) +#if defined __s390x__ .machine "z900" - lgr %r1,%r2 # Use as dest +#else + .machine "g5" +#endif /* ! defined __s390x__ */ + LGR %r1,%r2 # Use as dest la %r2,0(%r4,%r2) # Return dest + n - j .L_Z900_start + j .L_Z900_G5_start END(__mempcpy) #ifndef USE_MULTIARCH libc_hidden_def (__mempcpy) @@ -40,30 +58,46 @@ libc_hidden_builtin_def (mempcpy) #endif ENTRY(memcpy) +#if defined __s390x__ .machine "z900" - lgr %r1,%r2 # r1: Use as dest ; r2: Return dest -.L_Z900_start: - ltgr %r4,%r4 - je .L_Z900_4 - aghi %r4,-1 - srlg %r5,%r4,8 - ltgr %r5,%r5 - jne .L_Z900_13 -.L_Z900_3: - larl %r5,.L_Z900_15 - ex %r4,0(%r5) -.L_Z900_4: +#else + .machine "g5" +#endif /* ! defined __s390x__ */ + LGR %r1,%r2 # r1: Use as dest ; r2: Return dest +.L_Z900_G5_start: + LTGR %r4,%r4 + je .L_Z900_G5_4 + AGHI %r4,-1 +#if defined __s390x__ + srlg %r5,%r4,8 +#else + lr %r5,%r4 + srl %r5,8 +#endif /* ! defined __s390x__ */ + LTGR %r5,%r5 + jne .L_Z900_G5_13 +.L_Z900_G5_3: +#if defined __s390x__ + larl %r5,.L_Z900_G5_15 +# define Z900_G5_EX_D 0 +#else + basr %r5,0 +.L_Z900_G5_14: +# define Z900_G5_EX_D .L_Z900_G5_15-.L_Z900_G5_14 +#endif /* ! defined __s390x__ */ + ex %r4,Z900_G5_EX_D(%r5) +.L_Z900_G5_4: br %r14 -.L_Z900_13: - cghi %r5,4096 # Switch to mvcle for copies >1MB +.L_Z900_G5_13: + CGHI %r5,4096 # Switch to mvcle for copies >1MB jh __memcpy_mvcle -.L_Z900_12: +.L_Z900_G5_12: mvc 0(256,%r1),0(%r3) la %r1,256(%r1) la %r3,256(%r3) - brctg %r5,.L_Z900_12 - j .L_Z900_3 -.L_Z900_15: + BRCTG %r5,.L_Z900_G5_12 + j .L_Z900_G5_3 +.L_Z900_G5_15: mvc 0(1,%r1),0(%r3) END(memcpy) #ifndef USE_MULTIARCH @@ -74,15 +108,21 @@ ENTRY(__memcpy_mvcle) # Using as standalone function will result in unexpected # results since the length field is incremented by 1 in order to # compensate the changes already done in the functions above. - lgr %r0,%r2 # backup return dest [ + n ] - aghi %r4,1 # length + 1 - lgr %r5,%r4 # source length - lgr %r4,%r3 # source address - lgr %r2,%r1 # destination address - lgr %r3,%r5 # destination length = source length + LGR %r0,%r2 # backup return dest [ + n ] + AGHI %r4,1 # length + 1 + LGR %r5,%r4 # source length + LGR %r4,%r3 # source address + LGR %r2,%r1 # destination address + LGR %r3,%r5 # destination length = source length .L_MVCLE_1: mvcle %r2,%r4,0 # thats it, MVCLE is your friend jo .L_MVCLE_1 - lgr %r2,%r0 # return destination address + LGR %r2,%r0 # return destination address br %r14 END(__memcpy_mvcle) + +#undef LTGR +#undef CGHI +#undef LGR +#undef AGHI +#undef BRCTG diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index c893ebc565..3cbd5fad69 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -19,7 +19,7 @@ sysdep_routines += strlen strlen-vx strlen-c \ rawmemchr rawmemchr-vx rawmemchr-c \ memccpy memccpy-vx memccpy-c \ memrchr memrchr-vx memrchr-c \ - mempcpy + mempcpy memcpy memcpy-s390x endif ifeq ($(subdir),wcsmbs) diff --git a/sysdeps/s390/s390-64/multiarch/memcpy-s390x.S b/sysdeps/s390/multiarch/memcpy-s390x.S similarity index 89% rename from sysdeps/s390/s390-64/multiarch/memcpy-s390x.S rename to sysdeps/s390/multiarch/memcpy-s390x.S index 6d60a70834..b38caac72b 100644 --- a/sysdeps/s390/s390-64/multiarch/memcpy-s390x.S +++ b/sysdeps/s390/multiarch/memcpy-s390x.S @@ -1,4 +1,4 @@ -/* CPU specific memcpy implementations. 64 bit S/390 version. +/* CPU specific memcpy implementations. 31/64 bit S/390 version. Copyright (C) 2012-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -31,6 +31,7 @@ ENTRY(____mempcpy_z196) .machine "z196" + .machinemode "zarch_nohighgprs" lgr %r1,%r2 # Use as dest la %r2,0(%r4,%r2) # Return dest + n j .L_Z196_start @@ -38,8 +39,12 @@ END(____mempcpy_z196) ENTRY(__memcpy_z196) .machine "z196" + .machinemode "zarch_nohighgprs" lgr %r1,%r2 # r1: Use as dest ; r2: Return dest .L_Z196_start: +# if !defined __s390x__ + llgfr %r4,%r4 +# endif /* !defined __s390x__ */ ltgr %r4,%r4 je .L_Z196_4 aghi %r4,-1 @@ -68,6 +73,7 @@ END(__memcpy_z196) ENTRY(____mempcpy_z10) .machine "z10" + .machinemode "zarch_nohighgprs" lgr %r1,%r2 # Use as dest la %r2,0(%r4,%r2) # Return dest + n j .L_Z10_start @@ -75,8 +81,12 @@ END(____mempcpy_z10) ENTRY(__memcpy_z10) .machine "z10" + .machinemode "zarch_nohighgprs" lgr %r1,%r2 # r1: Use as dest ; r2: Return dest .L_Z10_start: +# if !defined __s390x__ + llgfr %r4,%r4 +# endif /* !defined __s390x__ */ cgije %r4,0,.L_Z10_4 aghi %r4,-1 srlg %r5,%r4,8 diff --git a/sysdeps/s390/s390-32/multiarch/memcpy.c b/sysdeps/s390/multiarch/memcpy.c similarity index 100% rename from sysdeps/s390/s390-32/multiarch/memcpy.c rename to sysdeps/s390/multiarch/memcpy.c diff --git a/sysdeps/s390/s390-32/memcpy.S b/sysdeps/s390/s390-32/memcpy.S deleted file mode 100644 index 493cc18aba..0000000000 --- a/sysdeps/s390/s390-32/memcpy.S +++ /dev/null @@ -1,89 +0,0 @@ -/* memcpy - copy a block from source to destination. S/390 version. - Copyright (C) 2012-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 "sysdep.h" -#include "asm-syntax.h" - -/* INPUT PARAMETERS - %r2 = address of destination memory area - %r3 = address of source memory area - %r4 = number of bytes to copy. */ - - .text -ENTRY(__mempcpy) - .machine "g5" - lr %r1,%r2 # Use as dest - la %r2,0(%r4,%r2) # Return dest + n - j .L_G5_start -END(__mempcpy) -#ifndef USE_MULTIARCH -libc_hidden_def (__mempcpy) -weak_alias (__mempcpy, mempcpy) -libc_hidden_builtin_def (mempcpy) -#endif - -ENTRY(memcpy) - .machine "g5" - lr %r1,%r2 # r1: Use as dest ; r2: Return dest -.L_G5_start: - ltr %r4,%r4 - je .L_G5_99 - ahi %r4,-1 - lr %r5,%r4 - srl %r5,8 - ltr %r5,%r5 - jne .L_G5_13 -.L_G5_4: - basr %r5,0 -.L_G5_16: - ex %r4,.L_G5_17-.L_G5_16(%r5) -.L_G5_99: - br %r14 -.L_G5_13: - chi %r5,4096 # Switch to mvcle for copies >1MB - jh __memcpy_mvcle -.L_G5_12: - mvc 0(256,%r1),0(%r3) - la %r1,256(%r1) - la %r3,256(%r3) - brct %r5,.L_G5_12 - j .L_G5_4 -.L_G5_17: - mvc 0(1,%r1),0(%r3) -END(memcpy) -#ifndef USE_MULTIARCH -libc_hidden_builtin_def (memcpy) -#endif - -ENTRY(__memcpy_mvcle) - # Using as standalone function will result in unexpected - # results since the length field is incremented by 1 in order to - # compensate the changes already done in the functions above. - lr %r0,%r2 # backup return dest [ + n ] - ahi %r4,1 # length + 1 - lr %r5,%r4 # source length - lr %r4,%r3 # source address - lr %r2,%r1 # destination address - lr %r3,%r5 # destination length = source length -.L_MVCLE_1: - mvcle %r2,%r4,0 # thats it, MVCLE is your friend - jo .L_MVCLE_1 - lr %r2,%r0 # return destination address - br %r14 -END(__memcpy_mvcle) diff --git a/sysdeps/s390/s390-32/multiarch/Makefile b/sysdeps/s390/s390-32/multiarch/Makefile deleted file mode 100644 index 82a7492eb8..0000000000 --- a/sysdeps/s390/s390-32/multiarch/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -ifeq ($(subdir),string) -sysdep_routines += memcpy memcpy-s390 -endif diff --git a/sysdeps/s390/s390-32/multiarch/memcpy-s390.S b/sysdeps/s390/s390-32/multiarch/memcpy-s390.S deleted file mode 100644 index aad13bd07c..0000000000 --- a/sysdeps/s390/s390-32/multiarch/memcpy-s390.S +++ /dev/null @@ -1,128 +0,0 @@ -/* CPU specific memcpy implementations. 32 bit S/390 version. - Copyright (C) 2012-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 "sysdep.h" -#include "asm-syntax.h" - -/* INPUT PARAMETERS - %r2 = target operands address - %r3 = source operands address - %r4 = number of bytes to copy. */ - - .text - -#if defined SHARED && IS_IN (libc) - -ENTRY(____mempcpy_z196) - .machine "z196" - .machinemode "zarch_nohighgprs" - lr %r1,%r2 # Use as dest - la %r2,0(%r4,%r2) # Return dest + n - j .L_Z196_start -END(____mempcpy_z196) - -ENTRY(__memcpy_z196) - .machine "z196" - .machinemode "zarch_nohighgprs" - lr %r1,%r2 # r1: Use as dest ; r2: Return dest -.L_Z196_start: - llgfr %r4,%r4 - ltgr %r4,%r4 - je .L_Z196_4 - aghi %r4,-1 - srlg %r5,%r4,8 - ltgr %r5,%r5 - jne .L_Z196_5 -.L_Z196_3: - exrl %r4,.L_Z196_14 -.L_Z196_4: - br %r14 -.L_Z196_5: - cgfi %r5,262144 # Switch to mvcle for copies >64MB - jh __memcpy_mvcle -.L_Z196_2: - pfd 1,768(%r3) - pfd 2,768(%r1) - mvc 0(256,%r1),0(%r3) - aghi %r5,-1 - la %r1,256(%r1) - la %r3,256(%r3) - jne .L_Z196_2 - j .L_Z196_3 -.L_Z196_14: - mvc 0(1,%r1),0(%r3) -END(__memcpy_z196) - -ENTRY(____mempcpy_z10) - .machine "z10" - .machinemode "zarch_nohighgprs" - lr %r1,%r2 # Use as dest - la %r2,0(%r4,%r2) # Return dest + n - j .L_Z10_start -END(____mempcpy_z10) - -ENTRY(__memcpy_z10) - .machine "z10" - .machinemode "zarch_nohighgprs" - lr %r1,%r2 # r1: Use as dest ; r2: Return dest -.L_Z10_start: - llgfr %r4,%r4 - cgije %r4,0,.L_Z10_4 - aghi %r4,-1 - srlg %r5,%r4,8 - cgijlh %r5,0,.L_Z10_13 -.L_Z10_3: - exrl %r4,.L_Z10_15 -.L_Z10_4: - br %r14 -.L_Z10_13: - cgfi %r5,65535 # Switch to mvcle for copies >16MB - jh __memcpy_mvcle -.L_Z10_12: - pfd 1,768(%r3) - pfd 2,768(%r1) - mvc 0(256,%r1),0(%r3) - la %r1,256(%r1) - la %r3,256(%r3) - brctg %r5,.L_Z10_12 - j .L_Z10_3 -.L_Z10_15: - mvc 0(1,%r1),0(%r3) -END(__memcpy_z10) - -# define __mempcpy ____mempcpy_default -#endif /* SHARED && IS_IN (libc) */ - -#define memcpy __memcpy_default -#include "../memcpy.S" -#undef memcpy - -#if defined SHARED && IS_IN (libc) -.globl __GI_memcpy -.set __GI_memcpy,__memcpy_default -.globl __GI_mempcpy -.set __GI_mempcpy,____mempcpy_default -.globl __GI___mempcpy -.set __GI___mempcpy,____mempcpy_default -#else -.globl memcpy -.set memcpy,__memcpy_default -.weak mempcpy -.set mempcpy,__mempcpy -#endif diff --git a/sysdeps/s390/s390-64/multiarch/Makefile b/sysdeps/s390/s390-64/multiarch/Makefile deleted file mode 100644 index 8a043e3327..0000000000 --- a/sysdeps/s390/s390-64/multiarch/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -ifeq ($(subdir),string) -sysdep_routines += memcpy memcpy-s390x -endif diff --git a/sysdeps/s390/s390-64/multiarch/memcpy.c b/sysdeps/s390/s390-64/multiarch/memcpy.c deleted file mode 100644 index c9577a854a..0000000000 --- a/sysdeps/s390/s390-64/multiarch/memcpy.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Multiple versions of memcpy. - Copyright (C) 2015-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 - . */ - -/* In the static lib memcpy is needed before the reloc is resolved. */ -#if defined SHARED && IS_IN (libc) -# define memcpy __redirect_memcpy -# include -# undef memcpy -# include - -s390_libc_ifunc (__redirect_memcpy, __memcpy, memcpy) -#endif From patchwork Fri Nov 30 15:57:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006093 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-97805-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="pksXrZR0"; 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 4361642pjVz9sBQ for ; Sat, 1 Dec 2018 04:07:24 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=bwAnCag8bQMGXYok3mE2ehx0DGkGA2j ShzjdK/BR9IDLctIswG7AMFoaQQ4TTZOqTMHYkDCZqOBEj9+pDGZ63t1HevnpaD4 x/6z9DLzYHW0wRvdjDygYkRXqnMGnM6i/xXffqzoi5VGiXSu5ATSRJZ/PdRiDMpw ux+/j9L5es1g= 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=Yhiox+h+8QU35QKGBs8szhPyNck=; b=pksXr ZR0mfiRHVmLuB+qca0tqKeYCC8zvoUSwuY8HVHErseyj0TmOrCht8bSypSRQG8vB MwwOIbftNJ+AJZv+rhw6Jj604s5W1KFjo8mf4/CiO9tvIF+mj90KswmvvOz8f1zS sc5B1BWInm+CaYG9nc3iPpvhBBe5t/8yve9c3U= Received: (qmail 66840 invoked by alias); 30 Nov 2018 17:07:17 -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 66806 invoked by uid 89); 30 Nov 2018 17:07:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 09/56] S390: Refactor memcpy/mempcpy ifunc handling. Date: Fri, 30 Nov 2018 16:57:47 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0020-0000-0000-000002F039B3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0021-0000-0000-0000213FA02E Message-Id: <1543593514-10251-10-git-send-email-stli@linux.ibm.com> This patch moves all ifunc variants for memcpy/mempcpy to sysdeps/s390/memcpy-z900.S. The configure-check/preprocessor logic in sysdeps/s390/ifunc-memcpy.h decides if ifunc is needed at all and which ifunc variants should be available. E.g. if the compiler/assembler already supports z196 by default, the older ifunc variants are not included. If we only need the newest ifunc variant, then we can skip ifunc at all. Therefore the ifunc-resolvers and __libc_ifunc_impl_list are adjusted in order to handle only the available ifunc variants. ChangeLog: * sysdeps/s390/ifunc-memcpy.h: New File. * sysdeps/s390/memcpy.S: Move to ... * sysdeps/s390/memcpy-z900.S ... here. Move implementations from memcpy-s390x.s to here. * sysdeps/s390/multiarch/memcpy-s390x.S: Delete File. * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove memcpy/mempcpy variants. * sysdeps/s390/Makefile (sysdep_routines): Add memcpy/mempcpy variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Adjust ifunc variants for memcpy and mempcpy. * sysdeps/s390/multiarch/memcpy.c: Move ifunc resolver to ... * sysdeps/s390/memcpy.c: ... here. Adjust ifunc variants for memcpy. * sysdeps/s390/multiarch/mempcpy.c: Move to ... * sysdeps/s390/mempcpy.c: ... here. Adjust ifunc variants for mempcpy. * sysdeps/s390/mempcpy.S: Delete file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-memcpy.h | 68 +++++++++++ sysdeps/s390/{memcpy.S => memcpy-z900.S} | 148 +++++++++++++++++++---- sysdeps/s390/{multiarch => }/memcpy.c | 28 ++++- sysdeps/s390/mempcpy.S | 19 --- sysdeps/s390/{multiarch => }/mempcpy.c | 26 +++- sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 33 +++-- sysdeps/s390/multiarch/memcpy-s390x.S | 132 -------------------- 9 files changed, 265 insertions(+), 195 deletions(-) create mode 100644 sysdeps/s390/ifunc-memcpy.h rename sysdeps/s390/{memcpy.S => memcpy-z900.S} (50%) rename sysdeps/s390/{multiarch => }/memcpy.c (60%) delete mode 100644 sysdeps/s390/mempcpy.S rename sysdeps/s390/{multiarch => }/mempcpy.c (63%) delete mode 100644 sysdeps/s390/multiarch/memcpy-s390x.S diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 44a2f28bfd..c196a19bfb 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -55,5 +55,6 @@ endif ifeq ($(subdir),string) sysdep_routines += bzero memset memset-z900 \ - memcmp memcmp-z900 + memcmp memcmp-z900 \ + mempcpy memcpy memcpy-z900 endif diff --git a/sysdeps/s390/ifunc-memcpy.h b/sysdeps/s390/ifunc-memcpy.h new file mode 100644 index 0000000000..51c71baa2c --- /dev/null +++ b/sysdeps/s390/ifunc-memcpy.h @@ -0,0 +1,68 @@ +/* memcpy variant information on S/390 version. + 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 + . */ + +#if defined SHARED && defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT +# define HAVE_MEMCPY_IFUNC 1 +#else +# define HAVE_MEMCPY_IFUNC 0 +#endif + +#if defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT +# define MEMCPY_DEFAULT MEMCPY_Z196 +# define MEMPCPY_DEFAULT MEMPCPY_Z196 +# define HAVE_MEMCPY_Z900_G5 0 +# define HAVE_MEMCPY_Z10 0 +# define HAVE_MEMCPY_Z196 1 +#elif defined HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT +# define MEMCPY_DEFAULT MEMCPY_Z10 +# define MEMPCPY_DEFAULT MEMPCPY_Z10 +# define HAVE_MEMCPY_Z900_G5 0 +# define HAVE_MEMCPY_Z10 1 +# define HAVE_MEMCPY_Z196 HAVE_MEMCPY_IFUNC +#else +# define MEMCPY_DEFAULT MEMCPY_Z900_G5 +# define MEMPCPY_DEFAULT MEMPCPY_Z900_G5 +# define HAVE_MEMCPY_Z900_G5 1 +# define HAVE_MEMCPY_Z10 HAVE_MEMCPY_IFUNC +# define HAVE_MEMCPY_Z196 HAVE_MEMCPY_IFUNC +#endif + +#if HAVE_MEMCPY_Z900_G5 +# define MEMCPY_Z900_G5 __memcpy_default +# define MEMPCPY_Z900_G5 __mempcpy_default +#else +# define MEMCPY_Z900_G5 NULL +# define MEMPCPY_Z900_G5 NULL +#endif + +#if HAVE_MEMCPY_Z10 +# define MEMCPY_Z10 __memcpy_z10 +# define MEMPCPY_Z10 __mempcpy_z10 +#else +# define MEMCPY_Z10 NULL +# define MEMPCPY_Z10 NULL +#endif + +#if HAVE_MEMCPY_Z196 +# define MEMCPY_Z196 __memcpy_z196 +# define MEMPCPY_Z196 __mempcpy_z196 +#else +# define MEMCPY_Z196 NULL +# define MEMPCPY_Z196 NULL +#endif diff --git a/sysdeps/s390/memcpy.S b/sysdeps/s390/memcpy-z900.S similarity index 50% rename from sysdeps/s390/memcpy.S rename to sysdeps/s390/memcpy-z900.S index 2a6c6b7503..3a50cf44d8 100644 --- a/sysdeps/s390/memcpy.S +++ b/sysdeps/s390/memcpy-z900.S @@ -19,6 +19,7 @@ #include #include "asm-syntax.h" +#include /* INPUT PARAMETERS %r2 = address of destination memory area @@ -41,50 +42,46 @@ # define BRCTG brct #endif /* ! defined __s390x__ */ -ENTRY(__mempcpy) -#if defined __s390x__ +#if HAVE_MEMCPY_Z900_G5 +ENTRY(MEMPCPY_Z900_G5) +# if defined __s390x__ .machine "z900" -#else +# else .machine "g5" -#endif /* ! defined __s390x__ */ +# endif /* ! defined __s390x__ */ LGR %r1,%r2 # Use as dest la %r2,0(%r4,%r2) # Return dest + n j .L_Z900_G5_start -END(__mempcpy) -#ifndef USE_MULTIARCH -libc_hidden_def (__mempcpy) -weak_alias (__mempcpy, mempcpy) -libc_hidden_builtin_def (mempcpy) -#endif +END(MEMPCPY_Z900_G5) -ENTRY(memcpy) -#if defined __s390x__ +ENTRY(MEMCPY_Z900_G5) +# if defined __s390x__ .machine "z900" -#else +# else .machine "g5" -#endif /* ! defined __s390x__ */ +# endif /* ! defined __s390x__ */ LGR %r1,%r2 # r1: Use as dest ; r2: Return dest .L_Z900_G5_start: LTGR %r4,%r4 je .L_Z900_G5_4 AGHI %r4,-1 -#if defined __s390x__ +# if defined __s390x__ srlg %r5,%r4,8 -#else +# else lr %r5,%r4 srl %r5,8 -#endif /* ! defined __s390x__ */ +# endif /* ! defined __s390x__ */ LTGR %r5,%r5 jne .L_Z900_G5_13 .L_Z900_G5_3: -#if defined __s390x__ +# if defined __s390x__ larl %r5,.L_Z900_G5_15 -# define Z900_G5_EX_D 0 -#else +# define Z900_G5_EX_D 0 +# else basr %r5,0 .L_Z900_G5_14: -# define Z900_G5_EX_D .L_Z900_G5_15-.L_Z900_G5_14 -#endif /* ! defined __s390x__ */ +# define Z900_G5_EX_D .L_Z900_G5_15-.L_Z900_G5_14 +# endif /* ! defined __s390x__ */ ex %r4,Z900_G5_EX_D(%r5) .L_Z900_G5_4: br %r14 @@ -99,10 +96,8 @@ ENTRY(memcpy) j .L_Z900_G5_3 .L_Z900_G5_15: mvc 0(1,%r1),0(%r3) -END(memcpy) -#ifndef USE_MULTIARCH -libc_hidden_builtin_def (memcpy) -#endif +END(MEMCPY_Z900_G5) +#endif /* HAVE_MEMCPY_Z900_G5 */ ENTRY(__memcpy_mvcle) # Using as standalone function will result in unexpected @@ -126,3 +121,104 @@ END(__memcpy_mvcle) #undef LGR #undef AGHI #undef BRCTG + +#if HAVE_MEMCPY_Z10 +ENTRY(MEMPCPY_Z10) + .machine "z10" + .machinemode "zarch_nohighgprs" + lgr %r1,%r2 # Use as dest + la %r2,0(%r4,%r2) # Return dest + n + j .L_Z10_start +END(MEMPCPY_Z10) + +ENTRY(MEMCPY_Z10) + .machine "z10" + .machinemode "zarch_nohighgprs" + lgr %r1,%r2 # r1: Use as dest ; r2: Return dest +.L_Z10_start: +# if !defined __s390x__ + llgfr %r4,%r4 +# endif /* !defined __s390x__ */ + cgije %r4,0,.L_Z10_4 + aghi %r4,-1 + srlg %r5,%r4,8 + cgijlh %r5,0,.L_Z10_13 +.L_Z10_3: + exrl %r4,.L_Z10_15 +.L_Z10_4: + br %r14 +.L_Z10_13: + cgfi %r5,65535 # Switch to mvcle for copies >16MB + jh __memcpy_mvcle +.L_Z10_12: + pfd 1,768(%r3) + pfd 2,768(%r1) + mvc 0(256,%r1),0(%r3) + la %r1,256(%r1) + la %r3,256(%r3) + brctg %r5,.L_Z10_12 + j .L_Z10_3 +.L_Z10_15: + mvc 0(1,%r1),0(%r3) +END(MEMCPY_Z10) +#endif /* HAVE_MEMCPY_Z10 */ + +#if HAVE_MEMCPY_Z196 +ENTRY(MEMPCPY_Z196) + .machine "z196" + .machinemode "zarch_nohighgprs" + lgr %r1,%r2 # Use as dest + la %r2,0(%r4,%r2) # Return dest + n + j .L_Z196_start +END(MEMPCPY_Z196) + +ENTRY(MEMCPY_Z196) + .machine "z196" + .machinemode "zarch_nohighgprs" + lgr %r1,%r2 # r1: Use as dest ; r2: Return dest +.L_Z196_start: +# if !defined __s390x__ + llgfr %r4,%r4 +# endif /* !defined __s390x__ */ + ltgr %r4,%r4 + je .L_Z196_4 + aghi %r4,-1 + srlg %r5,%r4,8 + ltgr %r5,%r5 + jne .L_Z196_5 +.L_Z196_3: + exrl %r4,.L_Z196_14 +.L_Z196_4: + br %r14 +.L_Z196_5: + cgfi %r5,262144 # Switch to mvcle for copies >64MB + jh __memcpy_mvcle +.L_Z196_2: + pfd 1,768(%r3) + pfd 2,768(%r1) + mvc 0(256,%r1),0(%r3) + aghi %r5,-1 + la %r1,256(%r1) + la %r3,256(%r3) + jne .L_Z196_2 + j .L_Z196_3 +.L_Z196_14: + mvc 0(1,%r1),0(%r3) +END(MEMCPY_Z196) +#endif /* HAVE_MEMCPY_Z196 */ + +#if ! HAVE_MEMCPY_IFUNC +/* If we don't use ifunc, define an alias for mem[p]cpy here. + Otherwise see sysdeps/s390/mem[p]cpy.c. */ +strong_alias (MEMCPY_DEFAULT, memcpy) +strong_alias (MEMPCPY_DEFAULT, __mempcpy) +weak_alias (__mempcpy, mempcpy) +#endif + +#if defined SHARED && IS_IN (libc) +/* Defines the internal symbols. + Compare to libc_hidden_[builtin_]def (mem[p]cpy) in string/mem[p]cpy.c. */ +strong_alias (MEMCPY_DEFAULT, __GI_memcpy) +strong_alias (MEMPCPY_DEFAULT, __GI_mempcpy) +strong_alias (MEMPCPY_DEFAULT, __GI___mempcpy) +#endif diff --git a/sysdeps/s390/multiarch/memcpy.c b/sysdeps/s390/memcpy.c similarity index 60% rename from sysdeps/s390/multiarch/memcpy.c rename to sysdeps/s390/memcpy.c index c9577a854a..90a53ac27d 100644 --- a/sysdeps/s390/multiarch/memcpy.c +++ b/sysdeps/s390/memcpy.c @@ -16,12 +16,34 @@ License along with the GNU C Library; if not, see . */ -/* In the static lib memcpy is needed before the reloc is resolved. */ -#if defined SHARED && IS_IN (libc) +#include + +#if HAVE_MEMCPY_IFUNC # define memcpy __redirect_memcpy # include # undef memcpy # include -s390_libc_ifunc (__redirect_memcpy, __memcpy, memcpy) +# if HAVE_MEMCPY_Z900_G5 +extern __typeof (__redirect_memcpy) MEMCPY_Z900_G5 attribute_hidden; +# endif + +# if HAVE_MEMCPY_Z10 +extern __typeof (__redirect_memcpy) MEMCPY_Z10 attribute_hidden; +# endif + +# if HAVE_MEMCPY_Z196 +extern __typeof (__redirect_memcpy) MEMCPY_Z196 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect_memcpy, memcpy, + ({ + s390_libc_ifunc_init (); + (HAVE_MEMCPY_Z196 && S390_IS_Z196 (stfle_bits)) + ? MEMCPY_Z196 + : (HAVE_MEMCPY_Z10 && S390_IS_Z10 (stfle_bits)) + ? MEMCPY_Z10 + : MEMCPY_DEFAULT; + }) + ) #endif diff --git a/sysdeps/s390/mempcpy.S b/sysdeps/s390/mempcpy.S deleted file mode 100644 index 18ef29213e..0000000000 --- a/sysdeps/s390/mempcpy.S +++ /dev/null @@ -1,19 +0,0 @@ -/* CPU specific mempcpy without multiarch - 32/64 bit S/390 version. - Copyright (C) 2016-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 - . */ - -/* mempcpy is implemented in memcpy.S. */ diff --git a/sysdeps/s390/multiarch/mempcpy.c b/sysdeps/s390/mempcpy.c similarity index 63% rename from sysdeps/s390/multiarch/mempcpy.c rename to sysdeps/s390/mempcpy.c index 363fe47aef..a6a2373126 100644 --- a/sysdeps/s390/multiarch/mempcpy.c +++ b/sysdeps/s390/mempcpy.c @@ -16,8 +16,9 @@ License along with the GNU C Library; if not, see . */ +#include -#if defined SHARED && IS_IN (libc) +#if HAVE_MEMCPY_IFUNC # define mempcpy __redirect_mempcpy # define __mempcpy __redirect___mempcpy # define __NO_STRING_INLINES @@ -27,6 +28,27 @@ # undef __mempcpy # include -s390_libc_ifunc (__redirect___mempcpy, ____mempcpy, __mempcpy) +# if HAVE_MEMCPY_Z900_G5 +extern __typeof (__redirect___mempcpy) MEMPCPY_Z900_G5 attribute_hidden; +# endif + +# if HAVE_MEMCPY_Z10 +extern __typeof (__redirect___mempcpy) MEMPCPY_Z10 attribute_hidden; +# endif + +# if HAVE_MEMCPY_Z196 +extern __typeof (__redirect___mempcpy) MEMPCPY_Z196 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect___mempcpy, __mempcpy, + ({ + s390_libc_ifunc_init (); + (HAVE_MEMCPY_Z196 && S390_IS_Z196 (stfle_bits)) + ? MEMPCPY_Z196 + : (HAVE_MEMCPY_Z10 && S390_IS_Z10 (stfle_bits)) + ? MEMPCPY_Z10 + : MEMPCPY_DEFAULT; + }) + ) weak_alias (__mempcpy, mempcpy); #endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 3cbd5fad69..24949cd3a8 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -18,8 +18,7 @@ sysdep_routines += strlen strlen-vx strlen-c \ memchr memchr-vx \ rawmemchr rawmemchr-vx rawmemchr-c \ memccpy memccpy-vx memccpy-c \ - memrchr memrchr-vx memrchr-c \ - mempcpy memcpy memcpy-s390x + memrchr memrchr-vx memrchr-c endif ifeq ($(subdir),wcsmbs) diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 2e57d01abc..6969c480cc 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -23,6 +23,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -95,23 +96,35 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_MEMCMP_IFUNC */ -#ifdef SHARED - +#if HAVE_MEMCPY_IFUNC IFUNC_IMPL (i, name, memcpy, +# if HAVE_MEMCPY_Z196 IFUNC_IMPL_ADD (array, i, memcpy, - S390_IS_Z196 (stfle_bits), __memcpy_z196) + S390_IS_Z196 (stfle_bits), MEMCPY_Z196) +# endif +# if HAVE_MEMCPY_Z10 IFUNC_IMPL_ADD (array, i, memcpy, - S390_IS_Z10 (stfle_bits), __memcpy_z10) - IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_default)) + S390_IS_Z10 (stfle_bits), MEMCPY_Z10) +# endif +# if HAVE_MEMCPY_Z900_G5 + IFUNC_IMPL_ADD (array, i, memcpy, 1, MEMCPY_Z900_G5) +# endif + ) IFUNC_IMPL (i, name, mempcpy, +# if HAVE_MEMCPY_Z196 IFUNC_IMPL_ADD (array, i, mempcpy, - S390_IS_Z196 (stfle_bits), ____mempcpy_z196) + S390_IS_Z196 (stfle_bits), MEMPCPY_Z196) +# endif +# if HAVE_MEMCPY_Z10 IFUNC_IMPL_ADD (array, i, mempcpy, - S390_IS_Z10 (stfle_bits), ____mempcpy_z10) - IFUNC_IMPL_ADD (array, i, mempcpy, 1, ____mempcpy_default)) - -#endif /* SHARED */ + S390_IS_Z10 (stfle_bits), MEMPCPY_Z10) +# endif +# if HAVE_MEMCPY_Z900_G5 + IFUNC_IMPL_ADD (array, i, mempcpy, 1, MEMPCPY_Z900_G5) +# endif + ) +#endif /* HAVE_MEMCPY_IFUNC */ #ifdef HAVE_S390_VX_ASM_SUPPORT diff --git a/sysdeps/s390/multiarch/memcpy-s390x.S b/sysdeps/s390/multiarch/memcpy-s390x.S deleted file mode 100644 index b38caac72b..0000000000 --- a/sysdeps/s390/multiarch/memcpy-s390x.S +++ /dev/null @@ -1,132 +0,0 @@ -/* CPU specific memcpy implementations. 31/64 bit S/390 version. - Copyright (C) 2012-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 "sysdep.h" -#include "asm-syntax.h" - -/* INPUT PARAMETERS - %r2 = target operands address - %r3 = source operands address - %r4 = number of bytes to copy. */ - - .text - -#if defined SHARED && IS_IN (libc) - -ENTRY(____mempcpy_z196) - .machine "z196" - .machinemode "zarch_nohighgprs" - lgr %r1,%r2 # Use as dest - la %r2,0(%r4,%r2) # Return dest + n - j .L_Z196_start -END(____mempcpy_z196) - -ENTRY(__memcpy_z196) - .machine "z196" - .machinemode "zarch_nohighgprs" - lgr %r1,%r2 # r1: Use as dest ; r2: Return dest -.L_Z196_start: -# if !defined __s390x__ - llgfr %r4,%r4 -# endif /* !defined __s390x__ */ - ltgr %r4,%r4 - je .L_Z196_4 - aghi %r4,-1 - srlg %r5,%r4,8 - ltgr %r5,%r5 - jne .L_Z196_5 -.L_Z196_3: - exrl %r4,.L_Z196_14 -.L_Z196_4: - br %r14 -.L_Z196_5: - cgfi %r5,262144 # Switch to mvcle for copies >64MB - jh __memcpy_mvcle -.L_Z196_2: - pfd 1,768(%r3) - pfd 2,768(%r1) - mvc 0(256,%r1),0(%r3) - aghi %r5,-1 - la %r1,256(%r1) - la %r3,256(%r3) - jne .L_Z196_2 - j .L_Z196_3 -.L_Z196_14: - mvc 0(1,%r1),0(%r3) -END(__memcpy_z196) - -ENTRY(____mempcpy_z10) - .machine "z10" - .machinemode "zarch_nohighgprs" - lgr %r1,%r2 # Use as dest - la %r2,0(%r4,%r2) # Return dest + n - j .L_Z10_start -END(____mempcpy_z10) - -ENTRY(__memcpy_z10) - .machine "z10" - .machinemode "zarch_nohighgprs" - lgr %r1,%r2 # r1: Use as dest ; r2: Return dest -.L_Z10_start: -# if !defined __s390x__ - llgfr %r4,%r4 -# endif /* !defined __s390x__ */ - cgije %r4,0,.L_Z10_4 - aghi %r4,-1 - srlg %r5,%r4,8 - cgijlh %r5,0,.L_Z10_13 -.L_Z10_3: - exrl %r4,.L_Z10_15 -.L_Z10_4: - br %r14 -.L_Z10_13: - cgfi %r5,65535 # Switch to mvcle for copies >16MB - jh __memcpy_mvcle -.L_Z10_12: - pfd 1,768(%r3) - pfd 2,768(%r1) - mvc 0(256,%r1),0(%r3) - la %r1,256(%r1) - la %r3,256(%r3) - brctg %r5,.L_Z10_12 - j .L_Z10_3 -.L_Z10_15: - mvc 0(1,%r1),0(%r3) -END(__memcpy_z10) - -# define __mempcpy ____mempcpy_default -#endif /* SHARED && IS_IN (libc) */ - -#define memcpy __memcpy_default -#include "../memcpy.S" -#undef memcpy - -#if defined SHARED && IS_IN (libc) -.globl __GI_memcpy -.set __GI_memcpy,__memcpy_default -.globl __GI_mempcpy -.set __GI_mempcpy,____mempcpy_default -.globl __GI___mempcpy -.set __GI___mempcpy,____mempcpy_default -#else -.globl memcpy -.set memcpy,__memcpy_default -.weak mempcpy -.set mempcpy,__mempcpy -#endif From patchwork Fri Nov 30 15:57:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006033 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-97762-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="kfSug4LQ"; 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 435zfP2lsjz9s8r for ; Sat, 1 Dec 2018 03:01:49 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=xBA+THoP1zV5OYdU5UOB8e+J0QDE+oi kql9lt9PkUlABVLi65vUaOHRVSzj0ck0rpCpQJToeyeZ26Oi2wDBGNUq6iY8WPDx pHLuCs26apt5MAvgQVVsoDx+dLUo5SjMXtrPqUrqXFSnpyp8++JArWmfLxvqkOy1 BMYu/sXJq8oU= 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=zCEVKEut7JzGBld0UqZsKTB32j0=; b=kfSug 4LQ7vY1HueztpbyCbOYESsD3Z52AqOUx8c0CxQvM5bBubiu8kKk+NvLvx/SVziA3 OuPJIYnF2rUGbKtVfx9c8etnSDYVUjaYnr2NwDzEeIn2NKWPoR70GudgstlOfOTO ode95rrpNNsvqJTyhgNMp1+VA/okPY6pFnfDNE= Received: (qmail 17807 invoked by alias); 30 Nov 2018 15:59:36 -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 17701 invoked by uid 89); 30 Nov 2018 15:59:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 10/56] S390: Remove s390 specific implementation of bcopy. Date: Fri, 30 Nov 2018 16:57:48 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0008-0000-0000-0000029B0397 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0009-0000-0000-000022055455 Message-Id: <1543593514-10251-11-git-send-email-stli@linux.ibm.com> Nowadays gcc is automatically replacing a call to bcopy with a call to memmove. Thus only old binaries will call the s390 specific bcopy implementation. The s390 specific implementation is using an own implementation for memcpy in the forward case and is relying on memmove in the backward case. After removing the s390 specific bcopy, the common code bcopy is used. It just performs a tail call to memmove. ChangeLog: * sysdeps/s390/s390-32/bcopy.S: Remove. * sysdeps/s390/s390-64/bcopy.S: Likewise. --- sysdeps/s390/s390-32/bcopy.S | 85 ------------------------------------ sysdeps/s390/s390-64/bcopy.S | 71 ------------------------------ 2 files changed, 156 deletions(-) delete mode 100644 sysdeps/s390/s390-32/bcopy.S delete mode 100644 sysdeps/s390/s390-64/bcopy.S diff --git a/sysdeps/s390/s390-32/bcopy.S b/sysdeps/s390/s390-32/bcopy.S deleted file mode 100644 index 560e04fdee..0000000000 --- a/sysdeps/s390/s390-32/bcopy.S +++ /dev/null @@ -1,85 +0,0 @@ -/* bcopy -- copy a block from source to destination. S/390 version. - This file is part of the GNU C Library. - Copyright (C) 2000-2018 Free Software Foundation, Inc. - Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). - - 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 - . */ - -/* INPUT PARAMETERS - %r2 = address of source - %r3 = address of destination - %r4 = number of bytes to copy. */ - -#include "sysdep.h" -#include "asm-syntax.h" - - .text -ENTRY(__bcopy) - ltr %r1,%r4 # zero bcopy ? - jz .L4 - clr %r2,%r3 # check against destructive overlap - jnl .L0 - alr %r1,%r2 - clr %r1,%r3 - jh .L7 -.L0: ahi %r4,-1 # length - 1 - lr %r1,%r4 - srl %r1,8 - ltr %r1,%r1 # < 256 bytes to move ? - jz .L2 - chi %r1,255 # > 1MB to move ? - jh .L5 -.L1: mvc 0(256,%r3),0(%r2) # move in 256 byte chunks - la %r2,256(%r2) - la %r3,256(%r3) - brct %r1,.L1 -.L2: bras %r1,.L3 # setup base pointer for execute - mvc 0(1,%r3),0(%r2) # instruction for execute -.L3: ex %r4,0(%r1) # execute mvc with length ((%r4)&255)+1 -.L4: br %r14 - - # data copies > 1MB are faster with mvcle. -.L5: ahi %r4,1 # length + 1 - lr %r5,%r4 # source length - lr %r4,%r2 # source address - lr %r2,%r3 # set destination - lr %r3,%r5 # destination length = source length -.L6: mvcle %r2,%r4,0 # thats it, MVCLE is your friend - jo .L6 - br %r14 -.L7: # destructive overlay, can not use mvcle - lr %r1,%r2 # bcopy is called with source,dest - lr %r2,%r3 # memmove with dest,source! Oh, well... - lr %r3,%r1 - basr %r1,0 -.L8: -#ifdef PIC - al %r1,.L9-.L8(%r1) # get address of global offset table - # load address of memmove - l %r1,memmove@GOT(%r1) - br %r1 -.L9: .long _GLOBAL_OFFSET_TABLE_-.L8 -#else - al %r1,.L9-.L8(%r1) # load address of memmove - br %r1 # jump to memmove -.L9: .long memmove-.L8 -#endif - -END(__bcopy) - -#ifndef NO_WEAK_ALIAS -weak_alias (__bcopy, bcopy) -#endif - diff --git a/sysdeps/s390/s390-64/bcopy.S b/sysdeps/s390/s390-64/bcopy.S deleted file mode 100644 index 806dd15d02..0000000000 --- a/sysdeps/s390/s390-64/bcopy.S +++ /dev/null @@ -1,71 +0,0 @@ -/* bcopy -- copy a block from source to destination. 64 bit S/390 version. - This file is part of the GNU C Library. - Copyright (C) 2000-2018 Free Software Foundation, Inc. - Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). - - 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 - . */ - -/* INPUT PARAMETERS - %r2 = address of source - %r3 = address of destination - %r4 = number of bytes to copy. */ - -#include "sysdep.h" -#include "asm-syntax.h" - - .text -ENTRY(__bcopy) - ltgr %r1,%r4 # zero bcopy ? - jz .L4 - clgr %r2,%r3 # check against destructive overlap - jnl .L0 - algr %r1,%r2 - clgr %r1,%r3 - jh .L7 -.L0: aghi %r4,-1 # length - 1 - srlg %r1,%r4,8 - ltgr %r1,%r1 # < 256 bytes to move ? - jz .L2 - cghi %r1,255 # > 1MB to move ? - jh .L5 -.L1: mvc 0(256,%r3),0(%r2) # move in 256 byte chunks - la %r2,256(%r2) - la %r3,256(%r3) - brctg %r1,.L1 -.L2: bras %r1,.L3 # setup base pointer for execute - mvc 0(1,%r3),0(%r2) # instruction for execute -.L3: ex %r4,0(%r1) # execute mvc with length ((%r4)&255)+1 -.L4: br %r14 - # data copies > 1MB are faster with mvcle. -.L5: aghi %r4,1 # length + 1 - lgr %r5,%r4 # source length - lgr %r4,%r2 # source address - lgr %r2,%r3 # set destination - lgr %r3,%r5 # destination length = source length -.L6: mvcle %r2,%r4,0 # thats it, MVCLE is your friend - jo .L6 - br %r14 -.L7: # destructive overlay, can not use mvcle - lgr %r1,%r2 # bcopy is called with source,dest - lgr %r2,%r3 # memmove with dest,source! Oh, well... - lgr %r3,%r1 - jg HIDDEN_BUILTIN_JUMPTARGET(memmove) - -END(__bcopy) - -#ifndef NO_WEAK_ALIAS -weak_alias (__bcopy, bcopy) -#endif - From patchwork Fri Nov 30 15:57:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006115 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-97810-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="X4kl7Z5G"; 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 43622V5B7hz9s89 for ; Sat, 1 Dec 2018 04:49:22 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=iConSi41TJztwrr9texW2CAb/SdZL8r 6vXX4ehV4wOxvXiyZ7uGS6oM69fTzM+GHJDGFxql7lZZp02NVsL2JVVnDXEGIkuf vi3NN9mlVOUqw46AyaVvkAVecn/9u7aYgxbVY8zjDhOyyZO/LWkKm4XqYbKxVvM7 dwZbYuYmrb0o= 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=dysxoDwMqCx7qZSiWo4U+t7PCa0=; b=X4kl7 Z5GZ7DZVSrE06ihnGAKyX6DJrQ56ca4fjgTxh/8A2elIG8Mb8UTb0zYrRv2fH9HV JmqHts61RkWQNbRJKdop7zIipKMmubbsqn/daaqYmXC4tW6I2eshrrnCZsfnjMwh L1L1aNVi3qQsuwRmElTCvT8/Y6aUMvnRrlbmng= Received: (qmail 61177 invoked by alias); 30 Nov 2018 17:49:16 -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 61037 invoked by uid 89); 30 Nov 2018 17:49:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 11/56] S390: Use memcpy for forward cases in memmove. Date: Fri, 30 Nov 2018 16:57:49 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0028-0000-0000-00000323FCAC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0029-0000-0000-000023E01259 Message-Id: <1543593514-10251-12-git-send-email-stli@linux.ibm.com> The s390/s390x memcpy implementations are safe to be used by memmove. Starting with this commit, memmove is using memcpy for the forward cases on s390. ChangeLog: * sysdeps/s390/memcopy.h: New file. --- sysdeps/s390/memcopy.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 sysdeps/s390/memcopy.h diff --git a/sysdeps/s390/memcopy.h b/sysdeps/s390/memcopy.h new file mode 100644 index 0000000000..9a76196502 --- /dev/null +++ b/sysdeps/s390/memcopy.h @@ -0,0 +1,23 @@ +/* memcopy.h -- definitions for memory copy functions. + 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 + +/* The s390/s390x memcpy implementations are safe to be used by memmove. */ +#undef MEMCPY_OK_FOR_FWD_MEMMOVE +#define MEMCPY_OK_FOR_FWD_MEMMOVE 1 From patchwork Fri Nov 30 15:57:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006123 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-97811-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="iTHpylOn"; 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 4362B65pygz9s89 for ; Sat, 1 Dec 2018 04:55:57 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=L8VcAgYRjy4eHt2g9p74r3bSE4cgyrg TKQbKRD1xxAqlw1dNj0S0OjiMlBc/7Cz7N2e4lHHzDo+NhQYZ3DdKmObmYeXQWc9 dkqzBhWQEoSJnajDa/pF9ygNOMtW7Px9+ruttfpJlMWtgfyq+J674BfwGG9w7w0H ivkR8sCT8DdA= 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=i8uBB2rYhBhST+b6XJGGLdDwbeY=; b=iTHpy lOn/d97Ym3LIsutRI+pAyWukh4KeRomhJJjNKs8H0BeEz+oGIGp3yS4YiyTvsQeT UbaHDERUoOhMfBA6p+EyGeFk94JRheEcnhBMMVrYQBrnrIgqH5MDbgdXXbViv0Pr 6CkW8lHDSSrdZK5XmKmsPZSbkZpGuQaqU+VxnQ= Received: (qmail 80562 invoked by alias); 30 Nov 2018 17:55:52 -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 80553 invoked by uid 89); 30 Nov 2018 17:55:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 12/56] S390: Add configure check to detect z13 as mininum architecture level set. Date: Fri, 30 Nov 2018 16:57:50 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0008-0000-0000-0000029B0399 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0009-0000-0000-000022055457 Message-Id: <1543593514-10251-13-git-send-email-stli@linux.ibm.com> Add a configure check for z13 in the same way as done for z196. ChangeLog: * config.h.in (HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT): New undefine. * sysdeps/s390/configure.ac: Add check for z13 support. * sysdeps/s390/configure: Regenerated. --- config.h.in | 3 +++ sysdeps/s390/configure | 38 ++++++++++++++++++++++++++++++++++++++ sysdeps/s390/configure.ac | 28 ++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/config.h.in b/config.h.in index beecc39d5b..422a6036ab 100644 --- a/config.h.in +++ b/config.h.in @@ -68,6 +68,9 @@ /* Define if assembler supports z196 zarch instructions as default on S390. */ #undef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT +/* Define if assembler supports z13 zarch instructions as default on S390. */ +#undef HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT + /* Define if assembler supports vector instructions on S390. */ #undef HAVE_S390_VX_ASM_SUPPORT diff --git a/sysdeps/s390/configure b/sysdeps/s390/configure index f30f864436..4a44775e30 100644 --- a/sysdeps/s390/configure +++ b/sysdeps/s390/configure @@ -187,5 +187,43 @@ then fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for S390 z13 zarch instruction support as default" >&5 +$as_echo_n "checking for S390 z13 zarch instruction support as default... " >&6; } +if ${libc_cv_asm_s390_min_z13_zarch+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat > conftest.c <<\EOF +int testinsn (void) +{ + int i; + __asm__ ("vl %%v16,0(%%r15)\n\t" + "vlgvf %0,%%v16,0" + : "=d" (i) : : "memory", "v16"); + return i; +} +EOF +if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c + -o conftest.o &> /dev/null' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } ; +then + libc_cv_asm_s390_min_z13_zarch=yes +else + libc_cv_asm_s390_min_z13_zarch=no +fi +rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_asm_s390_min_z13_zarch" >&5 +$as_echo "$libc_cv_asm_s390_min_z13_zarch" >&6; } + +if test "$libc_cv_asm_s390_min_z13_zarch" = yes ; +then + $as_echo "#define HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT 1" >>confdefs.h + +fi + test -n "$critic_missing" && as_fn_error $? " *** $critic_missing" "$LINENO" 5 diff --git a/sysdeps/s390/configure.ac b/sysdeps/s390/configure.ac index 981f7a79dd..4dfb5574b4 100644 --- a/sysdeps/s390/configure.ac +++ b/sysdeps/s390/configure.ac @@ -135,5 +135,33 @@ then AC_DEFINE(HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT) fi +AC_CACHE_CHECK(for S390 z13 zarch instruction support as default, + libc_cv_asm_s390_min_z13_zarch, [dnl +cat > conftest.c <<\EOF +int testinsn (void) +{ + int i; + __asm__ ("vl %%v16,0(%%r15)\n\t" + "vlgvf %0,%%v16,0" + : "=d" (i) : : "memory", "v16"); + return i; +} +EOF +dnl +dnl test, if assembler supports S390 z13 zarch instructions as default +if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c + -o conftest.o &> /dev/null]) ; +then + libc_cv_asm_s390_min_z13_zarch=yes +else + libc_cv_asm_s390_min_z13_zarch=no +fi +rm -f conftest* ]) + +if test "$libc_cv_asm_s390_min_z13_zarch" = yes ; +then + AC_DEFINE(HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT) +fi + test -n "$critic_missing" && AC_MSG_ERROR([ *** $critic_missing]) From patchwork Fri Nov 30 15:57:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006037 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-97766-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="tkDaGMqI"; 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 435zgH3W7nz9s8r for ; Sat, 1 Dec 2018 03:02: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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=hV6+5qo0YCSpbxnP5xPNEa74391c4q8 lIPy+fN8vhilkysEUkwYOELhnQDB4unICCqV937l6HzmzN3lFm8wv+ts8BMQ4r53 R4RUxpbLyoKEwvMZB5Izlw/ngCBa91TwB+kKuJrhg/pMR1qvQWmxEuHH5YJv5Xfm mQrFH2vRGzfA= 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=cNBRx61SNtBAvCkCplImC0286PA=; b=tkDaG MqIgZZZJ09L1bXeoeEFpZd0vIEYua64dGbA4G8FuWegD8wvpNvX8BgmnQxdfmhv1 vzyJzOst5E13L4KhDOsf3E1cOXVM71l+kBbOus5mvDxvz6XM1AxTJ14KRlI1IDo5 45M1vcvG+ELy6pH4RONH+vr4Z0fv4AJVwI/5og= Received: (qmail 19607 invoked by alias); 30 Nov 2018 15:59:48 -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 18636 invoked by uid 89); 30 Nov 2018 15:59:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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=4329 X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 13/56] S390: Add z13 memmove ifunc variant. Date: Fri, 30 Nov 2018 16:57:51 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0016-0000-0000-0000022F30B0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0017-0000-0000-000032879BC9 Message-Id: <1543593514-10251-14-git-send-email-stli@linux.ibm.com> This patch introduces a z13 specific ifunc variant for memmove. As the common code implementation, it checks if we can copy from the beginning to the end - with z196 memcpy implementation - or if we have to copy from the end to the beginning. The latter case is done by using vector load/store instructions. If vector instructions are not available, the common-code is used as fallback. Therefore it is implemented in memmove-c with a different name. Furthermore the ifunc logic decides if we need the common-code implementation at all. If vector instructions are supported due to the minimum architecture level set we can skip the common-code ifunc variant. ChangeLog: * sysdeps/s390/Makefile (sysdep_routines): Add memmove-c. * sysdeps/s390/ifunc-memcpy.h (HAVE_MEMMOVE_IFUNC, HAVE_MEMMOVE_IFUNC_AND_VX_SUPPORT, MEMMOVE_DEFAULT, HAVE_MEMMOVE_C, MEMMOVE_C, HAVE_MEMMOVE_Z13, MEMMOVE_Z13): New defines. * sysdeps/s390/memcpy-z900.S: Add z13 memmove implementation. * sysdeps/s390/memmove-c.c: New file. * sysdeps/s390/memmove.c: Likewise. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Add ifunc variants for memmove. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-memcpy.h | 35 ++++++++++ sysdeps/s390/memcpy-z900.S | 87 ++++++++++++++++++++++++ sysdeps/s390/memmove-c.c | 37 ++++++++++ sysdeps/s390/memmove.c | 44 ++++++++++++ sysdeps/s390/multiarch/ifunc-impl-list.c | 12 ++++ 6 files changed, 217 insertions(+), 1 deletion(-) create mode 100644 sysdeps/s390/memmove-c.c create mode 100644 sysdeps/s390/memmove.c diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index c196a19bfb..859f36f249 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -56,5 +56,6 @@ endif ifeq ($(subdir),string) sysdep_routines += bzero memset memset-z900 \ memcmp memcmp-z900 \ - mempcpy memcpy memcpy-z900 + mempcpy memcpy memcpy-z900 \ + memmove memmove-c endif diff --git a/sysdeps/s390/ifunc-memcpy.h b/sysdeps/s390/ifunc-memcpy.h index 51c71baa2c..0e701968c8 100644 --- a/sysdeps/s390/ifunc-memcpy.h +++ b/sysdeps/s390/ifunc-memcpy.h @@ -43,6 +43,29 @@ # define HAVE_MEMCPY_Z196 HAVE_MEMCPY_IFUNC #endif +#if defined SHARED && defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_MEMMOVE_IFUNC 1 +#else +# define HAVE_MEMMOVE_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_MEMMOVE_IFUNC_AND_VX_SUPPORT HAVE_MEMMOVE_IFUNC +#else +# define HAVE_MEMMOVE_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define MEMMOVE_DEFAULT MEMMOVE_Z13 +# define HAVE_MEMMOVE_C 0 +# define HAVE_MEMMOVE_Z13 1 +#else +# define MEMMOVE_DEFAULT MEMMOVE_C +# define HAVE_MEMMOVE_C 1 +# define HAVE_MEMMOVE_Z13 HAVE_MEMMOVE_IFUNC_AND_VX_SUPPORT +#endif + #if HAVE_MEMCPY_Z900_G5 # define MEMCPY_Z900_G5 __memcpy_default # define MEMPCPY_Z900_G5 __mempcpy_default @@ -66,3 +89,15 @@ # define MEMCPY_Z196 NULL # define MEMPCPY_Z196 NULL #endif + +#if HAVE_MEMMOVE_C +# define MEMMOVE_C __memmove_c +#else +# define MEMMOVE_C NULL +#endif + +#if HAVE_MEMMOVE_Z13 +# define MEMMOVE_Z13 __memmove_z13 +#else +# define MEMMOVE_Z13 NULL +#endif diff --git a/sysdeps/s390/memcpy-z900.S b/sysdeps/s390/memcpy-z900.S index 3a50cf44d8..bd3b1950ee 100644 --- a/sysdeps/s390/memcpy-z900.S +++ b/sysdeps/s390/memcpy-z900.S @@ -182,6 +182,7 @@ ENTRY(MEMCPY_Z196) # endif /* !defined __s390x__ */ ltgr %r4,%r4 je .L_Z196_4 +.L_Z196_start2: aghi %r4,-1 srlg %r5,%r4,8 ltgr %r5,%r5 @@ -207,6 +208,75 @@ ENTRY(MEMCPY_Z196) END(MEMCPY_Z196) #endif /* HAVE_MEMCPY_Z196 */ +#if HAVE_MEMMOVE_Z13 +ENTRY(MEMMOVE_Z13) + .machine "z13" + .machinemode "zarch_nohighgprs" +# if !defined __s390x__ + /* Note: The 31bit dst and src pointers are prefixed with zeroes. */ + llgfr %r4,%r4 + llgfr %r3,%r3 + llgfr %r2,%r2 +# endif /* !defined __s390x__ */ + sgrk %r0,%r2,%r3 + clgijh %r4,16,.L_MEMMOVE_Z13_LARGE + aghik %r5,%r4,-1 +.L_MEMMOVE_Z13_SMALL: + jl .L_MEMMOVE_Z13_END /* Jump away if len was zero. */ + /* Store up to 16 bytes with vll/vstl which needs the index + instead of lengths. */ + vll %v16,%r5,0(%r3) + vstl %v16,%r5,0(%r2) +.L_MEMMOVE_Z13_END: + br %r14 +.L_MEMMOVE_Z13_LARGE: + lgr %r1,%r2 /* For memcpy: r1: Use as dest ; + r2: Return dest */ + /* The unsigned comparison (dst - src >= len) determines if we can + execute the forward case with memcpy. */ +#if ! HAVE_MEMCPY_Z196 +# error The z13 variant of memmove needs the z196 variant of memcpy! +#endif + clgrjhe %r0,%r4,.L_Z196_start2 + risbgn %r5,%r4,4,128+63,60 /* r5 = r4 / 16 */ + aghi %r4,-16 + clgijhe %r5,8,.L_MEMMOVE_Z13_LARGE_64B +.L_MEMMOVE_Z13_LARGE_16B_LOOP: + /* Store at least 16 bytes with vl/vst. The number of 16byte blocks + is stored in r5. */ + vl %v16,0(%r4,%r3) + vst %v16,0(%r4,%r2) + aghi %r4,-16 + brctg %r5,.L_MEMMOVE_Z13_LARGE_16B_LOOP + aghik %r5,%r4,15 + j .L_MEMMOVE_Z13_SMALL +.L_MEMMOVE_Z13_LARGE_64B: + /* Store at least 128 bytes with 4x vl/vst. The number of 64byte blocks + will be stored in r0. */ + aghi %r4,-48 + srlg %r0,%r5,2 /* r5 = %r0 / 4 + => Number of 64byte blocks. */ +.L_MEMMOVE_Z13_LARGE_64B_LOOP: + vl %v20,48(%r4,%r3) + vl %v19,32(%r4,%r3) + vl %v18,16(%r4,%r3) + vl %v17,0(%r4,%r3) + vst %v20,48(%r4,%r2) + vst %v19,32(%r4,%r2) + vst %v18,16(%r4,%r2) + vst %v17,0(%r4,%r2) + aghi %r4,-64 + brctg %r0,.L_MEMMOVE_Z13_LARGE_64B_LOOP + aghi %r4,48 + /* Recalculate the number of 16byte blocks. */ + risbg %r5,%r5,62,128+63,0 /* r5 = r5 & 3 + => Remaining 16byte blocks. */ + jne .L_MEMMOVE_Z13_LARGE_16B_LOOP + aghik %r5,%r4,15 + j .L_MEMMOVE_Z13_SMALL +END(MEMMOVE_Z13) +#endif /* HAVE_MEMMOVE_Z13 */ + #if ! HAVE_MEMCPY_IFUNC /* If we don't use ifunc, define an alias for mem[p]cpy here. Otherwise see sysdeps/s390/mem[p]cpy.c. */ @@ -215,10 +285,27 @@ strong_alias (MEMPCPY_DEFAULT, __mempcpy) weak_alias (__mempcpy, mempcpy) #endif +#if ! HAVE_MEMMOVE_IFUNC +/* If we don't use ifunc, define an alias for memmove here. + Otherwise see sysdeps/s390/memmove.c. */ +# if ! HAVE_MEMMOVE_C +/* If the c variant is needed, then sysdeps/s390/memmove-c.c + defines memmove. + Otherwise MEMMOVE_DEFAULT is implemented here and we have to define it. */ +strong_alias (MEMMOVE_DEFAULT, memmove) +# endif +#endif + #if defined SHARED && IS_IN (libc) /* Defines the internal symbols. Compare to libc_hidden_[builtin_]def (mem[p]cpy) in string/mem[p]cpy.c. */ strong_alias (MEMCPY_DEFAULT, __GI_memcpy) strong_alias (MEMPCPY_DEFAULT, __GI_mempcpy) strong_alias (MEMPCPY_DEFAULT, __GI___mempcpy) +# if ! HAVE_MEMMOVE_C +/* If the c variant is needed, then sysdeps/s390/memmove-c.c + defines the internal symbol. + Otherwise MEMMOVE_DEFAULT is implemented here and we have to define it. */ +strong_alias (MEMMOVE_DEFAULT, __GI_memmove) +# endif #endif diff --git a/sysdeps/s390/memmove-c.c b/sysdeps/s390/memmove-c.c new file mode 100644 index 0000000000..be571093e0 --- /dev/null +++ b/sysdeps/s390/memmove-c.c @@ -0,0 +1,37 @@ +/* Fallback C version of memmove. + 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 + +#if HAVE_MEMMOVE_C +# if HAVE_MEMMOVE_IFUNC +/* If we use ifunc, then the memmove symbol is defined + in sysdeps/s390/memmove.c and we use a different name here. + Otherwise, we have to define memmove here or in + sysdeps/s390/memcpy.S depending on the used default implementation. */ +# define MEMMOVE MEMMOVE_C +# if defined SHARED && IS_IN (libc) +/* Define the internal symbol. */ +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) \ + __hidden_ver1 (__memmove_c, __GI_memmove, __memmove_c); +# endif +# endif + +# include +#endif diff --git a/sysdeps/s390/memmove.c b/sysdeps/s390/memmove.c new file mode 100644 index 0000000000..ac34edf80f --- /dev/null +++ b/sysdeps/s390/memmove.c @@ -0,0 +1,44 @@ +/* Multiple versions of memmove. + Copyright (C) 2016-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 + +#if HAVE_MEMMOVE_IFUNC +/* If we don't use ifunc, an alias is defined for memmove + in sysdeps/s390/memmove-c.c or sysdeps/s390/memcpy.S + depending on the used default implementation. */ +# undef memmove +# define memmove __redirect_memmove +# include +# include +# undef memmove + +# if HAVE_MEMMOVE_C +extern __typeof (__redirect_memmove) MEMMOVE_C attribute_hidden; +# endif + +# if HAVE_MEMMOVE_Z13 +extern __typeof (__redirect_memmove) MEMMOVE_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect_memmove, memmove, + (HAVE_MEMMOVE_Z13 && (hwcap & HWCAP_S390_VX)) + ? MEMMOVE_Z13 + : MEMMOVE_DEFAULT + ) +#endif diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 6969c480cc..c05c63e006 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -126,6 +126,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_MEMCPY_IFUNC */ +#if HAVE_MEMMOVE_IFUNC + IFUNC_IMPL (i, name, memmove, +# if HAVE_MEMMOVE_Z13 + IFUNC_IMPL_ADD (array, i, memmove, + dl_hwcap & HWCAP_S390_VX, MEMMOVE_Z13) +# endif +# if HAVE_MEMMOVE_C + IFUNC_IMPL_ADD (array, i, memmove, 1, MEMMOVE_C) +# endif + ) +#endif /* HAVE_MEMMOVE_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ From patchwork Fri Nov 30 15:57:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006036 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-97765-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="mSSmrC9p"; 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 435zg05tn2z9s8r for ; Sat, 1 Dec 2018 03:02:20 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=ck9YSW6iyoCPf4JXLKi7eG7OdHzD8VZ dJttsLn6VswydSmN18Z7V3zuuhgM26qX7gRJuksAiJ3DkKUlBt1eWkR2uvJfG7hS 5t1kCMt9KIfkOIXDjy9VbfPxMf9yjUIF8PIRH5ZVku5a+m8M2ALHWinTF80WgBfg T2pH+4sKxAXw= 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=sHkOSfXweshLNES9lvbERtO3R2g=; b=mSSmr C9pxkJ/SjrViapwsMPtVVPdBVhZlRs3fynwCd4rDMl0tWElwV0jsaUp4b7B0P5/s Xcg95TK2JjIUJes7wy+f4x50yRQKeXaUC7o+DEEhIqhpe/18n6ll9yO/0+5tUnpN z1laFhqUbEEu5uoQKISeNAEi2x/nynzrRDKgLw= Received: (qmail 18675 invoked by alias); 30 Nov 2018 15:59:42 -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 18559 invoked by uid 89); 30 Nov 2018 15:59:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 14/56] S390: Add z13 strstr ifunc variant. Date: Fri, 30 Nov 2018 16:57:52 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0008-0000-0000-0000029B039A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0009-0000-0000-000022055458 Message-Id: <1543593514-10251-15-git-send-email-stli@linux.ibm.com> The new vector variant of strstr is using the common code implementation, but instead of calling the default str* / mem* functions, the vector variants are called. ChangeLog: * sysdeps/s390/Makefile (sysdep_routines): Add strstr variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Add ifunc variants for strstr. * sysdeps/s390/ifunc-strstr.h: New file. * sysdeps/s390/strstr.c: Likewise. * sysdeps/s390/strstr-c.c: Likewise. * sysdeps/s390/strstr-vx.c: Likewise. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strstr.h | 52 ++++++++++++++++++++++++ sysdeps/s390/multiarch/ifunc-impl-list.c | 13 ++++++ sysdeps/s390/strstr-c.c | 32 +++++++++++++++ sysdeps/s390/strstr-vx.c | 52 ++++++++++++++++++++++++ sysdeps/s390/strstr.c | 40 ++++++++++++++++++ 6 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 sysdeps/s390/ifunc-strstr.h create mode 100644 sysdeps/s390/strstr-c.c create mode 100644 sysdeps/s390/strstr-vx.c create mode 100644 sysdeps/s390/strstr.c diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 859f36f249..c886fe31f3 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -57,5 +57,6 @@ ifeq ($(subdir),string) sysdep_routines += bzero memset memset-z900 \ memcmp memcmp-z900 \ mempcpy memcpy memcpy-z900 \ - memmove memmove-c + memmove memmove-c \ + strstr strstr-vx strstr-c endif diff --git a/sysdeps/s390/ifunc-strstr.h b/sysdeps/s390/ifunc-strstr.h new file mode 100644 index 0000000000..e6ccfd4e44 --- /dev/null +++ b/sysdeps/s390/ifunc-strstr.h @@ -0,0 +1,52 @@ +/* strstr variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRSTR_IFUNC 1 +#else +# define HAVE_STRSTR_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRSTR_IFUNC_AND_VX_SUPPORT HAVE_STRSTR_IFUNC +#else +# define HAVE_STRSTR_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRSTR_DEFAULT STRSTR_Z13 +# define HAVE_STRSTR_C 0 +# define HAVE_STRSTR_Z13 1 +#else +# define STRSTR_DEFAULT STRSTR_C +# define HAVE_STRSTR_C 1 +# define HAVE_STRSTR_Z13 HAVE_STRSTR_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRSTR_C +# define STRSTR_C __strstr_c +#else +# define STRSTR_C NULL +#endif + +#if HAVE_STRSTR_Z13 +# define STRSTR_Z13 __strstr_vx +#else +# define STRSTR_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index c05c63e006..14727f8fef 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -24,6 +24,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -138,6 +139,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_MEMMOVE_IFUNC */ +#if HAVE_STRSTR_IFUNC + IFUNC_IMPL (i, name, strstr, +# if HAVE_STRSTR_Z13 + IFUNC_IMPL_ADD (array, i, strstr, + dl_hwcap & HWCAP_S390_VX, STRSTR_Z13) +# endif +# if HAVE_STRSTR_C + IFUNC_IMPL_ADD (array, i, strstr, 1, STRSTR_C) +# endif + ) +#endif /* HAVE_STRSTR_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ diff --git a/sysdeps/s390/strstr-c.c b/sysdeps/s390/strstr-c.c new file mode 100644 index 0000000000..53717bfb27 --- /dev/null +++ b/sysdeps/s390/strstr-c.c @@ -0,0 +1,32 @@ +/* Default strstr implementation for S/390. + 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 + +#if HAVE_STRSTR_C +# if HAVE_STRSTR_IFUNC +# define STRSTR STRSTR_C +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) \ + __hidden_ver1 (__strstr_c, __GI_strstr, __strstr_c); +# endif +# endif + +# include +#endif diff --git a/sysdeps/s390/strstr-vx.c b/sysdeps/s390/strstr-vx.c new file mode 100644 index 0000000000..effae9d5eb --- /dev/null +++ b/sysdeps/s390/strstr-vx.c @@ -0,0 +1,52 @@ +/* Default strstr implementation with vector string functions for S/390. + 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 + +#if HAVE_STRSTR_Z13 +# if HAVE_STRSTR_IFUNC +# define STRSTR STRSTR_Z13 +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_builtin_def +# if HAVE_STRSTR_C +# define libc_hidden_builtin_def(name) +# else +# define libc_hidden_builtin_def(name) \ + __hidden_ver1 (__strstr_vx, __GI_strstr, __strstr_vx); +# endif +# endif +# endif + +# include + +# ifdef USE_MULTIARCH +extern __typeof (strchr) __strchr_vx attribute_hidden; +# define strchr __strchr_vx + +extern __typeof (strlen) __strlen_vx attribute_hidden; +# define strlen __strlen_vx + +extern __typeof (__strnlen) __strnlen_vx attribute_hidden; +# define __strnlen __strnlen_vx + +extern __typeof (memcmp) __memcmp_z196 attribute_hidden; +# define memcmp __memcmp_z196 +# endif + +# include +#endif diff --git a/sysdeps/s390/strstr.c b/sysdeps/s390/strstr.c new file mode 100644 index 0000000000..f8432349a7 --- /dev/null +++ b/sysdeps/s390/strstr.c @@ -0,0 +1,40 @@ +/* Multiple versions of strstr. + 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 + +#if HAVE_STRSTR_IFUNC +# define strstr __redirect_strstr +# include +# include +# undef strstr + +# if HAVE_STRSTR_C +extern __typeof (__redirect_strstr) STRSTR_C attribute_hidden; +# endif + +# if HAVE_STRSTR_Z13 +extern __typeof (__redirect_strstr) STRSTR_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect_strstr, strstr, + (HAVE_STRSTR_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRSTR_Z13 + : STRSTR_DEFAULT + ) +#endif From patchwork Fri Nov 30 15:57:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006072 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-97798-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="AjAZzl3v"; 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 43603M1F9Wz9s8r for ; Sat, 1 Dec 2018 03:19:58 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=harrWH+zkYIdZIOZ3dm/QbFAoF9evkn HRV4IXTYFiwb1xAr38mXguvMbDeoPgR+g/zj7qT1C59wL6eS7yQVF1bwZAak88d6 u+DMtZit9ktu/muOx7Fo0iQXBNo7SuQZ6q2vHhgH9NTIMlyzmbmbP4Z99agS5RRS 7acaJ8r+ZC08= 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=eI6+faOeZM5KqTjBWqunukgT9K8=; b=AjAZz l3vSDPfQ/ov8Jc9KwVIloWqMuCLzGe2P0uGUrdbqine0reGYbA5w38fR9N0lws0R uKDUBcrFY6Vp4NDBSgR329mHbdaRwe8oTNqK4DxdHc28+RHCkxyZ3jak29uHUi1i 1eSnsuMe9yUtMbEzSR4rhqRZ/eXMlEtpLdPHe0= Received: (qmail 22211 invoked by alias); 30 Nov 2018 16:19:52 -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 19209 invoked by uid 89); 30 Nov 2018 16:19:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 15/56] S390: Add z13 memmem ifunc variant. Date: Fri, 30 Nov 2018 16:57:53 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0016-0000-0000-0000022F30B2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0017-0000-0000-000032879BCB Message-Id: <1543593514-10251-16-git-send-email-stli@linux.ibm.com> The new vector variant of memmem is using the common code implementation, but instead of calling the default mem* functions, the vector variants are called. ChangeLog: * sysdeps/s390/Makefile (sysdep_routines): Add memmem variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Add ifunc variants for memmem. * sysdeps/s390/ifunc-memmem.h: New file. * sysdeps/s390/memmem.c: Likewise. * sysdeps/s390/memmem-c.c: Likewise. * sysdeps/s390/memmem-vx.c: Likewise. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-memmem.h | 52 ++++++++++++++++++++ sysdeps/s390/memmem-c.c | 47 ++++++++++++++++++ sysdeps/s390/memmem-vx.c | 61 ++++++++++++++++++++++++ sysdeps/s390/memmem.c | 43 +++++++++++++++++ sysdeps/s390/multiarch/ifunc-impl-list.c | 13 +++++ 6 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 sysdeps/s390/ifunc-memmem.h create mode 100644 sysdeps/s390/memmem-c.c create mode 100644 sysdeps/s390/memmem-vx.c create mode 100644 sysdeps/s390/memmem.c diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index c886fe31f3..0a964e0d4d 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -58,5 +58,6 @@ sysdep_routines += bzero memset memset-z900 \ memcmp memcmp-z900 \ mempcpy memcpy memcpy-z900 \ memmove memmove-c \ - strstr strstr-vx strstr-c + strstr strstr-vx strstr-c \ + memmem memmem-vx memmem-c endif diff --git a/sysdeps/s390/ifunc-memmem.h b/sysdeps/s390/ifunc-memmem.h new file mode 100644 index 0000000000..0f860d8d40 --- /dev/null +++ b/sysdeps/s390/ifunc-memmem.h @@ -0,0 +1,52 @@ +/* memmem variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_MEMMEM_IFUNC 1 +#else +# define HAVE_MEMMEM_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_MEMMEM_IFUNC_AND_VX_SUPPORT HAVE_MEMMEM_IFUNC +#else +# define HAVE_MEMMEM_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define MEMMEM_DEFAULT MEMMEM_Z13 +# define HAVE_MEMMEM_C 0 +# define HAVE_MEMMEM_Z13 1 +#else +# define MEMMEM_DEFAULT MEMMEM_C +# define HAVE_MEMMEM_C 1 +# define HAVE_MEMMEM_Z13 HAVE_MEMMEM_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_MEMMEM_C +# define MEMMEM_C __memmem_c +#else +# define MEMMEM_C NULL +#endif + +#if HAVE_MEMMEM_Z13 +# define MEMMEM_Z13 __memmem_vx +#else +# define MEMMEM_Z13 NULL +#endif diff --git a/sysdeps/s390/memmem-c.c b/sysdeps/s390/memmem-c.c new file mode 100644 index 0000000000..1d8ffefcb8 --- /dev/null +++ b/sysdeps/s390/memmem-c.c @@ -0,0 +1,47 @@ +/* Default memmem implementation for S/390. + 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 + +#if HAVE_MEMMEM_C +# if HAVE_MEMMEM_IFUNC +# include + +# ifndef _LIBC +# define memmem MEMMEM_C +# else +# define __memmem MEMMEM_C +# endif + +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_def +# define libc_hidden_def(name) \ + strong_alias (__memmem_c, __memmem_c_1); \ + __hidden_ver1 (__memmem_c, __GI___memmem, __memmem_c); + +# undef libc_hidden_weak +# define libc_hidden_weak(name) \ + __hidden_ver1 (__memmem_c_1, __GI_memmem, __memmem_c_1) __attribute__((weak)); +# endif + +# undef weak_alias +# define weak_alias(a, b) +# endif + +# include +#endif diff --git a/sysdeps/s390/memmem-vx.c b/sysdeps/s390/memmem-vx.c new file mode 100644 index 0000000000..af6e200e4e --- /dev/null +++ b/sysdeps/s390/memmem-vx.c @@ -0,0 +1,61 @@ +/* Default memmem implementation with vector string functions for S/390. + 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 + +#if HAVE_MEMMEM_Z13 +# include +# if HAVE_MEMMEM_IFUNC + +# ifndef _LIBC +# define memmem MEMMEM_Z13 +# else +# define __memmem MEMMEM_Z13 +# endif + +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_def +# undef libc_hidden_weak + +# if HAVE_MEMMEM_C +# define libc_hidden_def(name) +# define libc_hidden_weak(name) +# else +# define libc_hidden_def(name) \ + strong_alias (__memmem_vx, __memmem_vx_1); \ + __hidden_ver1 (__memmem_vx, __GI___memmem, __memmem_vx); + +# define libc_hidden_weak(name) \ + __hidden_ver1 (__memmem_vx_1, __GI_memmem, __memmem_vx_1) __attribute__((weak)); +# endif +# endif + +# undef weak_alias +# define weak_alias(a, b) +# endif + +# ifdef USE_MULTIARCH +extern __typeof (memchr) __memchr_vx attribute_hidden; +# define memchr __memchr_vx + +extern __typeof (memcmp) __memcmp_z196 attribute_hidden; +# define memcmp __memcmp_z196 +# endif + +# include +#endif diff --git a/sysdeps/s390/memmem.c b/sysdeps/s390/memmem.c new file mode 100644 index 0000000000..8c50b3f403 --- /dev/null +++ b/sysdeps/s390/memmem.c @@ -0,0 +1,43 @@ +/* Multiple versions of memmem. + 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 + +#if HAVE_MEMMEM_IFUNC +# define memmem __redirect_memmem +# define __memmem __redirect___memmem +# include +# include +# undef memmem +# undef __memmem + +# if HAVE_MEMMEM_C +extern __typeof (__redirect_memmem) MEMMEM_C attribute_hidden; +# endif + +# if HAVE_MEMMEM_Z13 +extern __typeof (__redirect_memmem) MEMMEM_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect_memmem, __memmem, + (HAVE_MEMMEM_Z13 && (hwcap & HWCAP_S390_VX)) + ? MEMMEM_Z13 + : MEMMEM_DEFAULT + ) +weak_alias (__memmem, memmem) +#endif diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 14727f8fef..da8696d917 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -25,6 +25,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -151,6 +152,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRSTR_IFUNC */ +#if HAVE_MEMMEM_IFUNC + IFUNC_IMPL (i, name, memmem, +# if HAVE_MEMMEM_Z13 + IFUNC_IMPL_ADD (array, i, memmem, + dl_hwcap & HWCAP_S390_VX, MEMMEM_Z13) +# endif +# if HAVE_MEMMEM_C + IFUNC_IMPL_ADD (array, i, memmem, 1, MEMMEM_C) +# endif + ) +#endif /* HAVE_MEMMEM_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ From patchwork Fri Nov 30 15:57:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006086 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-97803-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="kirr6AMO"; 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 4360yY15ZTz9sBQ for ; Sat, 1 Dec 2018 04:00:52 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=ngHEA90JrSnHeBI+wQWJxz/4gyxXLlz 0TbDRoBBqex62m/k4nogUq63nO91QiXVIbDlxe613QGzYtuc9eDZY9YSmvpFfzAS 6AK+yQ56dBOJ+tdeP6B0jTQJaPYnv8kFXQGVsYlSIThO2Fu7Ohe0TuaC4iJrs35s 0LlXSPA4Su4w= 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=UuZndJhsRKpBMlL2E2z1C9c91jk=; b=kirr6 AMOvLDSY4Km0rN+OzZ12wkmGez8aceHTH5FT5pzQs5Mbz1ckEk2Ihi0wJGgyKW3d OtwpwyrRFaZv02iX6fuwXPMXeqZmLfwJLbrFxlqYV/t9BTmrSahMg7m3i2PyMEox IeuIqh8KnI+1M9FAQF6wM+j9r74FA1F0p+lX4Q= Received: (qmail 51503 invoked by alias); 30 Nov 2018 17:00:47 -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 51450 invoked by uid 89); 30 Nov 2018 17:00:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 16/56] S390: Refactor strlen ifunc handling. Date: Fri, 30 Nov 2018 16:57:54 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-4275-0000-0000-000002E935CB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-4276-0000-0000-000037F67E67 Message-Id: <1543593514-10251-17-git-send-email-stli@linux.ibm.com> The ifunc handling for strlen is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove strlen variants. * sysdeps/s390/Makefile (sysdep_routines): Add strlen variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for strlen. * sysdeps/s390/multiarch/strlen-c.c: Move to ... * sysdeps/s390/strlen-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strlen-vx.S: Move to ... * sysdeps/s390/strlen-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strlen.c: Move to ... * sysdeps/s390/strlen.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-strlen.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strlen.h | 52 ++++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 ++++++- sysdeps/s390/{multiarch => }/strlen-c.c | 18 ++++---- sysdeps/s390/{multiarch => }/strlen-vx.S | 17 ++++++-- sysdeps/s390/{multiarch => }/strlen.c | 21 +++++++--- 7 files changed, 108 insertions(+), 20 deletions(-) create mode 100644 sysdeps/s390/ifunc-strlen.h rename sysdeps/s390/{multiarch => }/strlen-c.c (78%) rename sysdeps/s390/{multiarch => }/strlen-vx.S (90%) rename sysdeps/s390/{multiarch => }/strlen.c (69%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 0a964e0d4d..bc21b06825 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -59,5 +59,6 @@ sysdep_routines += bzero memset memset-z900 \ mempcpy memcpy memcpy-z900 \ memmove memmove-c \ strstr strstr-vx strstr-c \ - memmem memmem-vx memmem-c + memmem memmem-vx memmem-c \ + strlen strlen-vx strlen-c endif diff --git a/sysdeps/s390/ifunc-strlen.h b/sysdeps/s390/ifunc-strlen.h new file mode 100644 index 0000000000..f207059663 --- /dev/null +++ b/sysdeps/s390/ifunc-strlen.h @@ -0,0 +1,52 @@ +/* strlen variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRLEN_IFUNC 1 +#else +# define HAVE_STRLEN_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRLEN_IFUNC_AND_VX_SUPPORT HAVE_STRLEN_IFUNC +#else +# define HAVE_STRLEN_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRLEN_DEFAULT STRLEN_Z13 +# define HAVE_STRLEN_C 0 +# define HAVE_STRLEN_Z13 1 +#else +# define STRLEN_DEFAULT STRLEN_C +# define HAVE_STRLEN_C 1 +# define HAVE_STRLEN_Z13 HAVE_STRLEN_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRLEN_C +# define STRLEN_C __strlen_c +#else +# define STRLEN_C NULL +#endif + +#if HAVE_STRLEN_Z13 +# define STRLEN_Z13 __strlen_vx +#else +# define STRLEN_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 24949cd3a8..601523919c 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strlen strlen-vx strlen-c \ - strnlen strnlen-vx strnlen-c \ +sysdep_routines += strnlen strnlen-vx strnlen-c \ strcpy strcpy-vx \ stpcpy stpcpy-vx stpcpy-c \ strncpy strncpy-vx \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index da8696d917..c531be4bc7 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -26,6 +26,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -164,6 +165,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_MEMMEM_IFUNC */ +#if HAVE_STRLEN_IFUNC + IFUNC_IMPL (i, name, strlen, +# if HAVE_STRLEN_Z13 + IFUNC_IMPL_ADD (array, i, strlen, + dl_hwcap & HWCAP_S390_VX, STRLEN_Z13) +# endif +# if HAVE_STRLEN_C + IFUNC_IMPL_ADD (array, i, strlen, 1, STRLEN_C) +# endif + ) +#endif /* HAVE_STRLEN_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -172,7 +185,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (strlen); IFUNC_VX_IMPL (wcslen); IFUNC_VX_IMPL (strnlen); diff --git a/sysdeps/s390/multiarch/strlen-c.c b/sysdeps/s390/strlen-c.c similarity index 78% rename from sysdeps/s390/multiarch/strlen-c.c rename to sysdeps/s390/strlen-c.c index a2c8e43624..b4569701af 100644 --- a/sysdeps/s390/multiarch/strlen-c.c +++ b/sysdeps/s390/strlen-c.c @@ -16,13 +16,17 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define STRLEN __strlen_c -# ifdef SHARED -# undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) \ +#include + +#if HAVE_STRLEN_C +# if HAVE_STRLEN_IFUNC +# define STRLEN STRLEN_C +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) \ __hidden_ver1 (__strlen_c, __GI_strlen, __strlen_c); -# endif /* SHARED */ +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/strlen-vx.S b/sysdeps/s390/strlen-vx.S similarity index 90% rename from sysdeps/s390/multiarch/strlen-vx.S rename to sysdeps/s390/strlen-vx.S index 9308b33237..39ef43107d 100644 --- a/sysdeps/s390/multiarch/strlen-vx.S +++ b/sysdeps/s390/strlen-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_STRLEN_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -34,7 +35,7 @@ -r5=current_len and return_value -v16=part of s */ -ENTRY(__strlen_vx) +ENTRY(STRLEN_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -80,5 +81,13 @@ ENTRY(__strlen_vx) vlgvb %r2,%v16,7 /* Load byte index of zero. */ algr %r2,%r5 br %r14 -END(__strlen_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(STRLEN_Z13) + +# if ! HAVE_STRLEN_IFUNC +strong_alias (STRLEN_Z13, strlen) +# endif + +# if ! HAVE_STRLEN_C && defined SHARED && IS_IN (libc) +strong_alias (STRLEN_Z13, __GI_strlen) +# endif +#endif diff --git a/sysdeps/s390/multiarch/strlen.c b/sysdeps/s390/strlen.c similarity index 69% rename from sysdeps/s390/multiarch/strlen.c rename to sysdeps/s390/strlen.c index 0edf8b7d02..6ba0fe86fe 100644 --- a/sysdeps/s390/multiarch/strlen.c +++ b/sysdeps/s390/strlen.c @@ -16,14 +16,25 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRLEN_IFUNC # define strlen __redirect_strlen # include # include # undef strlen -s390_vx_libc_ifunc2_redirected (__redirect_strlen, __strlen, strlen) +# if HAVE_STRLEN_C +extern __typeof (__redirect_strlen) STRLEN_C attribute_hidden; +# endif + +# if HAVE_STRLEN_Z13 +extern __typeof (__redirect_strlen) STRLEN_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (__redirect_strlen, strlen, + (HAVE_STRLEN_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRLEN_Z13 + : STRLEN_DEFAULT + ) +#endif From patchwork Fri Nov 30 15:57:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006039 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-97767-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="wTo1L8/l"; 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 435zgT2rVpz9s8r for ; Sat, 1 Dec 2018 03:02:45 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=WN95rashcqIjyylzNC7g/m7+CiTZGNT 5SnL77vQk2NNp2FEPHjlSCu7oABzprImz+Q3M7WTa5IFdnZw7DYo/hSWOgcHuTkg D2PqMefwtOFsJgHGrScUPbmO315AOj2xz6M6Br2ofNQeszsgOB9J99MN974KP7/d dDQNHAp+tjJM= 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=OUSc06S/xzGv4ZhDHuxbedl7IhA=; b=wTo1L 8/lirA/HSvAoXZJ0wmv0zN+/m+Pf0rwKee2eavivHp73TEkSA1Epy5HXIX/ZoMWR ZqIrZ2PMy3Z/AGcDkUE8+7a/XUx5eqSdUS41S8V0MXRwMN9M4msmU9t5bXqn//jZ 4kj7LrV+Oi2D2XShIpULHXNjIRAIfX9k99uMCs= Received: (qmail 19890 invoked by alias); 30 Nov 2018 15:59: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 18841 invoked by uid 89); 30 Nov 2018 15:59:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 17/56] S390: Refactor strnlen ifunc handling. Date: Fri, 30 Nov 2018 16:57:55 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0016-0000-0000-0000022F30B3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0017-0000-0000-000032879BCC Message-Id: <1543593514-10251-18-git-send-email-stli@linux.ibm.com> The ifunc handling for strnlen is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove strnlen variants. * sysdeps/s390/Makefile (sysdep_routines): Add strnlen variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for strnlen. * sysdeps/s390/multiarch/strnlen-c.c: Move to ... * sysdeps/s390/strnlen-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strnlen-vx.S: Move to ... * sysdeps/s390/strnlen-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strnlen.c: Move to ... * sysdeps/s390/strnlen.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-strnlen.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strnlen.h | 52 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 +++++- sysdeps/s390/{multiarch => }/strnlen-c.c | 18 +++++--- sysdeps/s390/{multiarch => }/strnlen-vx.S | 21 +++++++-- sysdeps/s390/{multiarch => }/strnlen.c | 23 +++++++--- 7 files changed, 113 insertions(+), 21 deletions(-) create mode 100644 sysdeps/s390/ifunc-strnlen.h rename sysdeps/s390/{multiarch => }/strnlen-c.c (81%) rename sysdeps/s390/{multiarch => }/strnlen-vx.S (90%) rename sysdeps/s390/{multiarch => }/strnlen.c (69%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index bc21b06825..4390af56b3 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -60,5 +60,6 @@ sysdep_routines += bzero memset memset-z900 \ memmove memmove-c \ strstr strstr-vx strstr-c \ memmem memmem-vx memmem-c \ - strlen strlen-vx strlen-c + strlen strlen-vx strlen-c \ + strnlen strnlen-vx strnlen-c endif diff --git a/sysdeps/s390/ifunc-strnlen.h b/sysdeps/s390/ifunc-strnlen.h new file mode 100644 index 0000000000..e923298887 --- /dev/null +++ b/sysdeps/s390/ifunc-strnlen.h @@ -0,0 +1,52 @@ +/* strnlen variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRNLEN_IFUNC 1 +#else +# define HAVE_STRNLEN_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRNLEN_IFUNC_AND_VX_SUPPORT HAVE_STRNLEN_IFUNC +#else +# define HAVE_STRNLEN_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRNLEN_DEFAULT STRNLEN_Z13 +# define HAVE_STRNLEN_C 0 +# define HAVE_STRNLEN_Z13 1 +#else +# define STRNLEN_DEFAULT STRNLEN_C +# define HAVE_STRNLEN_C 1 +# define HAVE_STRNLEN_Z13 HAVE_STRNLEN_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRNLEN_C +# define STRNLEN_C __strnlen_c +#else +# define STRNLEN_C NULL +#endif + +#if HAVE_STRNLEN_Z13 +# define STRNLEN_Z13 __strnlen_vx +#else +# define STRNLEN_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 601523919c..35ba223c5d 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strnlen strnlen-vx strnlen-c \ - strcpy strcpy-vx \ +sysdep_routines += strcpy strcpy-vx \ stpcpy stpcpy-vx stpcpy-c \ strncpy strncpy-vx \ stpncpy stpncpy-vx stpncpy-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index c531be4bc7..680e5b738b 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -27,6 +27,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -177,6 +178,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRLEN_IFUNC */ +#if HAVE_STRNLEN_IFUNC + IFUNC_IMPL (i, name, strnlen, +# if HAVE_STRNLEN_Z13 + IFUNC_IMPL_ADD (array, i, strnlen, + dl_hwcap & HWCAP_S390_VX, STRNLEN_Z13) +# endif +# if HAVE_STRNLEN_C + IFUNC_IMPL_ADD (array, i, strnlen, 1, STRNLEN_C) +# endif + ) +#endif /* HAVE_STRNLEN_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -187,7 +200,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcslen); - IFUNC_VX_IMPL (strnlen); IFUNC_VX_IMPL (wcsnlen); IFUNC_VX_IMPL (strcpy); diff --git a/sysdeps/s390/multiarch/strnlen-c.c b/sysdeps/s390/strnlen-c.c similarity index 81% rename from sysdeps/s390/multiarch/strnlen-c.c rename to sysdeps/s390/strnlen-c.c index 353e83ed35..c2d887f1e4 100644 --- a/sysdeps/s390/multiarch/strnlen-c.c +++ b/sysdeps/s390/strnlen-c.c @@ -16,15 +16,19 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define STRNLEN __strnlen_c -# ifdef SHARED -# undef libc_hidden_def -# define libc_hidden_def(name) \ +#include + +#if HAVE_STRNLEN_C +# if HAVE_STRNLEN_IFUNC +# define STRNLEN STRNLEN_C +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_def +# define libc_hidden_def(name) \ __hidden_ver1 (__strnlen_c, __GI_strnlen, __strnlen_c); \ strong_alias (__strnlen_c, __strnlen_c_1); \ __hidden_ver1 (__strnlen_c_1, __GI___strnlen, __strnlen_c_1); -# endif /* SHARED */ +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/strnlen-vx.S b/sysdeps/s390/strnlen-vx.S similarity index 90% rename from sysdeps/s390/multiarch/strnlen-vx.S rename to sysdeps/s390/strnlen-vx.S index fc659a956c..0b8fe3da34 100644 --- a/sysdeps/s390/multiarch/strnlen-vx.S +++ b/sysdeps/s390/strnlen-vx.S @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRNLEN_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -34,7 +36,7 @@ -r5=current_len and return_value -v16=part of s */ -ENTRY(__strnlen_vx) +ENTRY(STRNLEN_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -130,5 +132,16 @@ ENTRY(__strnlen_vx) clgrjl %r1,%r3,.Lloop64 j .Llt64 -END(__strnlen_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(STRNLEN_Z13) + +# if ! HAVE_STRNLEN_IFUNC +strong_alias (STRNLEN_Z13, __strnlen) +weak_alias (__strnlen, strnlen) +# endif + +# if ! HAVE_STRNLEN_C && defined SHARED && IS_IN (libc) +strong_alias (STRNLEN_Z13, __GI_strnlen) +strong_alias (STRNLEN_Z13, __GI___strnlen) +# endif + +#endif /* HAVE_STRNLEN_Z13 */ diff --git a/sysdeps/s390/multiarch/strnlen.c b/sysdeps/s390/strnlen.c similarity index 69% rename from sysdeps/s390/multiarch/strnlen.c rename to sysdeps/s390/strnlen.c index 0f9cff5d69..aa4953d503 100644 --- a/sysdeps/s390/multiarch/strnlen.c +++ b/sysdeps/s390/strnlen.c @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRNLEN_IFUNC # define strnlen __redirect_strnlen # define __strnlen __redirect___strnlen # include @@ -24,9 +26,18 @@ # undef __strnlen # include -s390_vx_libc_ifunc_redirected (__redirect___strnlen, __strnlen) -weak_alias (__strnlen, strnlen) +# if HAVE_STRNLEN_C +extern __typeof (__redirect_strnlen) STRNLEN_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_STRNLEN_Z13 +extern __typeof (__redirect_strnlen) STRNLEN_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect___strnlen, __strnlen, + (HAVE_STRNLEN_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRNLEN_Z13 + : STRNLEN_DEFAULT + ) +weak_alias (__strnlen, strnlen) +#endif /* HAVE_STRNLEN_IFUNC */ From patchwork Fri Nov 30 15:57:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006105 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-97807-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="QnA5r5o6"; 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 4361K32dWZz9sBQ for ; Sat, 1 Dec 2018 04:16:55 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=ZVMFXd7fjl5YVsXM3OjEVFT470scoes UTw5eOfFK5VFz+LcqhT1Jht6YcsIPd/xqcS7fAHZnricyAoIK6AezFFCXJXy8jQM mV2OqNFvBQDNOoYSIpcixViHqUDaC3//0p+kCjOS5gh24p63c+fFaf/WMx2izBdU 4wCOGG7xzJ8g= 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=rGut8tGbwh36N0bJ66D3gPcFzu0=; b=QnA5r 5o69sLXmgdghZh1XGsOocRhcYbyxFkGILewh1uVNF7BQJljm6mQnqMN+Cr2HbeBZ LmVAbDRaHSIcATiJ0uuJBeMh6zg5YcEUJI2QDKkaRnlZrtygRbbDcm8UPw+ZDXYu 94TVZMe0DndxWlK4MRpybgl209cjx4hUszALMs= Received: (qmail 80639 invoked by alias); 30 Nov 2018 17:16:49 -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 80626 invoked by uid 89); 30 Nov 2018 17:16:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 18/56] S390: Refactor strcpy ifunc handling. Date: Fri, 30 Nov 2018 16:57:56 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0020-0000-0000-000002F039B7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0021-0000-0000-0000213FA033 Message-Id: <1543593514-10251-19-git-send-email-stli@linux.ibm.com> The ifunc handling for strcpy is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. Note: The fallback s390-32/s390-64 ifunc variants with mvst instruction are now moved to the unified strcpy-z900.S file which can be used for 31/64bit. The s390-32/s390-64 files multiarch/strcpy.c and strcpy.S are deleted. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove strcpy variants. * sysdeps/s390/Makefile (sysdep_routines): Add strcpy variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for strcpy. * sysdeps/s390/multiarch/strcpy-vx.S: Move to ... * sysdeps/s390/strcpy-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strcpy.c: Move to ... * sysdeps/s390/strcpy.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-strcpy.h: New file. * sysdeps/s390/s390-64/strcpy.S: Move to ... * sysdeps/s390/strcpy-z900.S: ... here and adjust to be usable for 31/64bit and ifunc handling. * sysdeps/s390/s390-32/multiarch/strcpy.c: Delete file. * sysdeps/s390/s390-64/multiarch/strcpy.c: Likewise. * sysdeps/s390/s390-32/strcpy.S: Likewise. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strcpy.h | 52 +++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 ++++- sysdeps/s390/s390-32/multiarch/strcpy.c | 21 -------- sysdeps/s390/s390-32/strcpy.S | 36 ------------- sysdeps/s390/s390-64/multiarch/strcpy.c | 21 -------- sysdeps/s390/{multiarch => }/strcpy-vx.S | 26 +++++----- .../s390/{s390-64/strcpy.S => strcpy-z900.S} | 33 +++++++++--- sysdeps/s390/{multiarch => }/strcpy.c | 17 +++++- 10 files changed, 123 insertions(+), 103 deletions(-) create mode 100644 sysdeps/s390/ifunc-strcpy.h delete mode 100644 sysdeps/s390/s390-32/multiarch/strcpy.c delete mode 100644 sysdeps/s390/s390-32/strcpy.S delete mode 100644 sysdeps/s390/s390-64/multiarch/strcpy.c rename sysdeps/s390/{multiarch => }/strcpy-vx.S (85%) rename sysdeps/s390/{s390-64/strcpy.S => strcpy-z900.S} (66%) rename sysdeps/s390/{multiarch => }/strcpy.c (69%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 4390af56b3..af9482adc3 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -61,5 +61,6 @@ sysdep_routines += bzero memset memset-z900 \ strstr strstr-vx strstr-c \ memmem memmem-vx memmem-c \ strlen strlen-vx strlen-c \ - strnlen strnlen-vx strnlen-c + strnlen strnlen-vx strnlen-c \ + strcpy strcpy-vx strcpy-z900 endif diff --git a/sysdeps/s390/ifunc-strcpy.h b/sysdeps/s390/ifunc-strcpy.h new file mode 100644 index 0000000000..85e45556e6 --- /dev/null +++ b/sysdeps/s390/ifunc-strcpy.h @@ -0,0 +1,52 @@ +/* strcpy variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRCPY_IFUNC 1 +#else +# define HAVE_STRCPY_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRCPY_IFUNC_AND_VX_SUPPORT HAVE_STRCPY_IFUNC +#else +# define HAVE_STRCPY_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRCPY_DEFAULT STRCPY_Z13 +# define HAVE_STRCPY_Z900_G5 0 +# define HAVE_STRCPY_Z13 1 +#else +# define STRCPY_DEFAULT STRCPY_Z900_G5 +# define HAVE_STRCPY_Z900_G5 1 +# define HAVE_STRCPY_Z13 HAVE_STRCPY_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRCPY_Z900_G5 +# define STRCPY_Z900_G5 __strcpy_default +#else +# define STRCPY_Z900_G5 NULL +#endif + +#if HAVE_STRCPY_Z13 +# define STRCPY_Z13 __strcpy_vx +#else +# define STRCPY_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 35ba223c5d..50f7f0b78d 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strcpy strcpy-vx \ - stpcpy stpcpy-vx stpcpy-c \ +sysdep_routines += stpcpy stpcpy-vx stpcpy-c \ strncpy strncpy-vx \ stpncpy stpncpy-vx stpncpy-c \ strcat strcat-vx strcat-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 680e5b738b..1784372db9 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -28,6 +28,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -190,6 +191,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRNLEN_IFUNC */ +#if HAVE_STRCPY_IFUNC + IFUNC_IMPL (i, name, strcpy, +# if HAVE_STRCPY_Z13 + IFUNC_IMPL_ADD (array, i, strcpy, + dl_hwcap & HWCAP_S390_VX, STRCPY_Z13) +# endif +# if HAVE_STRCPY_Z900_G5 + IFUNC_IMPL_ADD (array, i, strcpy, 1, STRCPY_Z900_G5) +# endif + ) +#endif /* HAVE_STRCPY_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -202,7 +215,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcsnlen); - IFUNC_VX_IMPL (strcpy); IFUNC_VX_IMPL (wcscpy); IFUNC_VX_IMPL (stpcpy); diff --git a/sysdeps/s390/s390-32/multiarch/strcpy.c b/sysdeps/s390/s390-32/multiarch/strcpy.c deleted file mode 100644 index 6a22e31a03..0000000000 --- a/sysdeps/s390/s390-32/multiarch/strcpy.c +++ /dev/null @@ -1,21 +0,0 @@ -/* Multiple versions of strcpy. - Copyright (C) 2015-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 - . */ - -/* This wrapper-file is needed, because otherwise file - sysdeps/s390/s390-[32|64]/strcpy.S will be used. */ -#include diff --git a/sysdeps/s390/s390-32/strcpy.S b/sysdeps/s390/s390-32/strcpy.S deleted file mode 100644 index d49136ee92..0000000000 --- a/sysdeps/s390/s390-32/strcpy.S +++ /dev/null @@ -1,36 +0,0 @@ -/* strcpy - copy a string from source to destination. For IBM S390 - This file is part of the GNU C Library. - Copyright (C) 2000-2018 Free Software Foundation, Inc. - Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). - - 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 - . */ - -/* - * R2 = address of destination - * R3 = address of source - */ - -#include "sysdep.h" -#include "asm-syntax.h" - - .text -ENTRY(strcpy) - slr %r0,%r0 - lr %r1,%r2 -0: mvst %r1,%r3 - jo 0b - br %r14 -END(strcpy) -libc_hidden_builtin_def (strcpy) diff --git a/sysdeps/s390/s390-64/multiarch/strcpy.c b/sysdeps/s390/s390-64/multiarch/strcpy.c deleted file mode 100644 index 6a22e31a03..0000000000 --- a/sysdeps/s390/s390-64/multiarch/strcpy.c +++ /dev/null @@ -1,21 +0,0 @@ -/* Multiple versions of strcpy. - Copyright (C) 2015-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 - . */ - -/* This wrapper-file is needed, because otherwise file - sysdeps/s390/s390-[32|64]/strcpy.S will be used. */ -#include diff --git a/sysdeps/s390/multiarch/strcpy-vx.S b/sysdeps/s390/strcpy-vx.S similarity index 85% rename from sysdeps/s390/multiarch/strcpy-vx.S rename to sysdeps/s390/strcpy-vx.S index 52197f57f7..844d23e4fe 100644 --- a/sysdeps/s390/multiarch/strcpy-vx.S +++ b/sysdeps/s390/strcpy-vx.S @@ -16,13 +16,13 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) - -# include "sysdep.h" -# include "asm-syntax.h" +#include +#include "sysdep.h" +#include "asm-syntax.h" .text +#if HAVE_STRCPY_Z13 /* char * strcpy (const char *dest, const char *src) Copy string src to dest. @@ -36,7 +36,7 @@ -v17=index of zero -v18=part of src */ -ENTRY(__strcpy_vx) +ENTRY(STRCPY_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -97,13 +97,13 @@ ENTRY(__strcpy_vx) .Lfound_align: vstl %v16,%r5,0(%r2) /* Copy characters including zero. */ br %r14 -END(__strcpy_vx) +END(STRCPY_Z13) -/* Use mvst-strcpy-implementation as default implementation. */ -# define strcpy __strcpy_c -# undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) strong_alias(__strcpy_c, __GI_strcpy) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +# if ! HAVE_STRCPY_IFUNC +strong_alias (STRCPY_Z13, strcpy) +# endif -/* Include mvst-strcpy-implementation in s390-32/s390-64 subdirectory. */ -#include +# if ! HAVE_STRCPY_Z900_G5 && defined SHARED && IS_IN (libc) +strong_alias (STRCPY_Z13, __GI_strcpy) +# endif +#endif diff --git a/sysdeps/s390/s390-64/strcpy.S b/sysdeps/s390/strcpy-z900.S similarity index 66% rename from sysdeps/s390/s390-64/strcpy.S rename to sysdeps/s390/strcpy-z900.S index 203c73c905..42798b1fd5 100644 --- a/sysdeps/s390/s390-64/strcpy.S +++ b/sysdeps/s390/strcpy-z900.S @@ -1,4 +1,4 @@ -/* strcpy - copy a string from source to destination. 64 bit S/390 version. +/* strcpy - copy a string from source to destination. 64/31 bit S/390 version. Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -21,15 +21,36 @@ %r2 = address of destination %r3 = address of source. */ +#include #include "sysdep.h" #include "asm-syntax.h" +#if HAVE_STRCPY_Z900_G5 +# if defined __s390x__ +# define SLGR slgr +# define LGR lgr +# else +# define SLGR slr +# define LGR lr +# endif /* ! defined __s390x__ */ + .text -ENTRY(strcpy) - slgr %r0,%r0 - lgr %r1,%r2 +ENTRY(STRCPY_Z900_G5) + SLGR %r0,%r0 + LGR %r1,%r2 0: mvst %r1,%r3 jo 0b br %r14 -END(strcpy) -libc_hidden_builtin_def (strcpy) +END(STRCPY_Z900_G5) + +# undef SLGR +# undef LGR + +# if ! HAVE_STRCPY_IFUNC +strong_alias (STRCPY_Z900_G5, strcpy) +# endif + +# if defined SHARED && IS_IN (libc) +strong_alias (STRCPY_Z900_G5, __GI_strcpy) +# endif +#endif diff --git a/sysdeps/s390/multiarch/strcpy.c b/sysdeps/s390/strcpy.c similarity index 69% rename from sysdeps/s390/multiarch/strcpy.c rename to sysdeps/s390/strcpy.c index 8f32a13f67..f4e28e24c8 100644 --- a/sysdeps/s390/multiarch/strcpy.c +++ b/sysdeps/s390/strcpy.c @@ -16,12 +16,25 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRCPY_IFUNC # define strcpy __redirect_strcpy # include # undef strcpy # include -s390_vx_libc_ifunc2_redirected (__redirect_strcpy, __strcpy, strcpy) +# if HAVE_STRCPY_Z900_G5 +extern __typeof (__redirect_strcpy) STRCPY_Z900_G5 attribute_hidden; +# endif + +# if HAVE_STRCPY_Z13 +extern __typeof (__redirect_strcpy) STRCPY_Z13 attribute_hidden; +# endif +s390_libc_ifunc_expr (__redirect_strcpy, strcpy, + (HAVE_STRCPY_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRCPY_Z13 + : STRCPY_DEFAULT + ) #endif From patchwork Fri Nov 30 15:57:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006040 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-97768-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="C+YaFmdf"; 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 435zgh5lcxz9sBn for ; Sat, 1 Dec 2018 03:02:56 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=VoVmPP8SK+jH7YMhWTAM/9cXQPYdeoh tC/mlUJDvgXOWEU2Pz1i+jm3xe6A+lkW3G5vP6p5+ESHX54bCYwBcfeJ1zxXPJdz dQUB8W5mrxQeX4+cHulO6Zi1fzFMqxgcc4lLjBKe7qfYnsnwK8qQMk9V9vr+Ts2r 9nWIG0Wl4Yp8= 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=WZkwwY6LWE5PloKw4UZm5TlzWUo=; b=C+YaF mdfqyk6BaKfcBv1d4+B9WoKMievytYK4SKgM/mQ8cpgd9r/HFhoXV/3xQeZA5WIE Cv3eic6ExoSo+C9wJKFtCsAA4c5DF5n7R75h5fdelkB1vrq6Abpnw0/tDCr++34r YBJBNCbNx/seSBupLO5FyYyLnKKx0BFVKGfArg= Received: (qmail 20072 invoked by alias); 30 Nov 2018 15:59:51 -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 19223 invoked by uid 89); 30 Nov 2018 15:59:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 19/56] S390: Refactor stpcpy ifunc handling. Date: Fri, 30 Nov 2018 16:57:57 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0016-0000-0000-0000022F30B4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0017-0000-0000-000032879BCD Message-Id: <1543593514-10251-20-git-send-email-stli@linux.ibm.com> The ifunc handling for stpcpy is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove stpcpy variants. * sysdeps/s390/Makefile (sysdep_routines): Add stpcpy variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for stpcpy. * sysdeps/s390/multiarch/stpcpy-c.c: Move to ... * sysdeps/s390/stpcpy-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/stpcpy-vx.S: Move to ... * sysdeps/s390/stpcpy-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/stpcpy.c: Move to ... * sysdeps/s390/stpcpy.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-stpcpy.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-stpcpy.h | 52 ++++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 ++++++- sysdeps/s390/{multiarch => }/stpcpy-c.c | 29 +++++++------ sysdeps/s390/{multiarch => }/stpcpy-vx.S | 20 +++++++-- sysdeps/s390/{multiarch => }/stpcpy.c | 23 ++++++++--- 7 files changed, 118 insertions(+), 26 deletions(-) create mode 100644 sysdeps/s390/ifunc-stpcpy.h rename sysdeps/s390/{multiarch => }/stpcpy-c.c (74%) rename sysdeps/s390/{multiarch => }/stpcpy-vx.S (90%) rename sysdeps/s390/{multiarch => }/stpcpy.c (74%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index af9482adc3..96f1538cfd 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -62,5 +62,6 @@ sysdep_routines += bzero memset memset-z900 \ memmem memmem-vx memmem-c \ strlen strlen-vx strlen-c \ strnlen strnlen-vx strnlen-c \ - strcpy strcpy-vx strcpy-z900 + strcpy strcpy-vx strcpy-z900 \ + stpcpy stpcpy-vx stpcpy-c endif diff --git a/sysdeps/s390/ifunc-stpcpy.h b/sysdeps/s390/ifunc-stpcpy.h new file mode 100644 index 0000000000..9a70cd7c8c --- /dev/null +++ b/sysdeps/s390/ifunc-stpcpy.h @@ -0,0 +1,52 @@ +/* stpcpy variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STPCPY_IFUNC 1 +#else +# define HAVE_STPCPY_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STPCPY_IFUNC_AND_VX_SUPPORT HAVE_STPCPY_IFUNC +#else +# define HAVE_STPCPY_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STPCPY_DEFAULT STPCPY_Z13 +# define HAVE_STPCPY_C 0 +# define HAVE_STPCPY_Z13 1 +#else +# define STPCPY_DEFAULT STPCPY_C +# define HAVE_STPCPY_C 1 +# define HAVE_STPCPY_Z13 HAVE_STPCPY_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STPCPY_C +# define STPCPY_C __stpcpy_c +#else +# define STPCPY_C NULL +#endif + +#if HAVE_STPCPY_Z13 +# define STPCPY_Z13 __stpcpy_vx +#else +# define STPCPY_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 50f7f0b78d..9517417dcb 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += stpcpy stpcpy-vx stpcpy-c \ - strncpy strncpy-vx \ +sysdep_routines += strncpy strncpy-vx \ stpncpy stpncpy-vx stpncpy-c \ strcat strcat-vx strcat-c \ strncat strncat-vx strncat-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 1784372db9..678ed13833 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -29,6 +29,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -203,6 +204,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRCPY_IFUNC */ +#if HAVE_STPCPY_IFUNC + IFUNC_IMPL (i, name, stpcpy, +# if HAVE_STPCPY_Z13 + IFUNC_IMPL_ADD (array, i, stpcpy, + dl_hwcap & HWCAP_S390_VX, STPCPY_Z13) +# endif +# if HAVE_STPCPY_C + IFUNC_IMPL_ADD (array, i, stpcpy, 1, STPCPY_C) +# endif + ) +#endif /* HAVE_STPCPY_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -217,7 +230,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcscpy); - IFUNC_VX_IMPL (stpcpy); IFUNC_VX_IMPL (wcpcpy); IFUNC_VX_IMPL (strncpy); diff --git a/sysdeps/s390/multiarch/stpcpy-c.c b/sysdeps/s390/stpcpy-c.c similarity index 74% rename from sysdeps/s390/multiarch/stpcpy-c.c rename to sysdeps/s390/stpcpy-c.c index 4a1c3e5832..76ec884627 100644 --- a/sysdeps/s390/multiarch/stpcpy-c.c +++ b/sysdeps/s390/stpcpy-c.c @@ -16,20 +16,25 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define STPCPY __stpcpy_c -# undef weak_alias -# define weak_alias(a, b) -# ifdef SHARED -# undef libc_hidden_def -# define libc_hidden_def(name) \ +#include + +#if HAVE_STPCPY_C +# if HAVE_STPCPY_IFUNC +# define STPCPY STPCPY_C + +# undef weak_alias +# define weak_alias(a, b) + +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_def +# define libc_hidden_def(name) \ __hidden_ver1 (__stpcpy_c, __GI___stpcpy, __stpcpy_c); -# undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) \ +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) \ strong_alias (__stpcpy_c, __stpcpy_c_1); \ __hidden_ver1 (__stpcpy_c_1, __GI_stpcpy, __stpcpy_c_1); -# endif /* SHARED */ - +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/stpcpy-vx.S b/sysdeps/s390/stpcpy-vx.S similarity index 90% rename from sysdeps/s390/multiarch/stpcpy-vx.S rename to sysdeps/s390/stpcpy-vx.S index 6c17def0fc..d2db02d0cd 100644 --- a/sysdeps/s390/multiarch/stpcpy-vx.S +++ b/sysdeps/s390/stpcpy-vx.S @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STPCPY_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -36,7 +38,7 @@ -v17=index of zero -v18=part of src */ -ENTRY(__stpcpy_vx) +ENTRY(STPCPY_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -100,5 +102,15 @@ ENTRY(__stpcpy_vx) vstl %v16,%r5,0(%r2) /* Copy characters including zero. */ la %r2,0(%r5,%r2) /* Return pointer to zero. */ br %r14 -END(__stpcpy_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(STPCPY_Z13) + +# if ! HAVE_STPCPY_IFUNC +strong_alias (STPCPY_Z13, __stpcpy) +weak_alias (__stpcpy, stpcpy) +# endif + +# if ! HAVE_STPCPY_C && defined SHARED && IS_IN (libc) +strong_alias (STPCPY_Z13, __GI_stpcpy) +strong_alias (STPCPY_Z13, __GI___stpcpy) +# endif +#endif diff --git a/sysdeps/s390/multiarch/stpcpy.c b/sysdeps/s390/stpcpy.c similarity index 74% rename from sysdeps/s390/multiarch/stpcpy.c rename to sysdeps/s390/stpcpy.c index 654f9dfbef..670604e2de 100644 --- a/sysdeps/s390/multiarch/stpcpy.c +++ b/sysdeps/s390/stpcpy.c @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STPCPY_IFUNC # define stpcpy __redirect_stpcpy # define __stpcpy __redirect___stpcpy /* Omit the stpcpy inline definitions because it would redefine stpcpy. */ @@ -27,9 +29,18 @@ # undef __stpcpy # include -s390_vx_libc_ifunc_redirected (__redirect___stpcpy, __stpcpy); -weak_alias (__stpcpy, stpcpy) +# if HAVE_STPCPY_C +extern __typeof (__redirect_stpcpy) STPCPY_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_STPCPY_Z13 +extern __typeof (__redirect_stpcpy) STPCPY_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect___stpcpy, __stpcpy, + (HAVE_STPCPY_Z13 && (hwcap & HWCAP_S390_VX)) + ? STPCPY_Z13 + : STPCPY_DEFAULT + ) +weak_alias (__stpcpy, stpcpy) +#endif From patchwork Fri Nov 30 15:57:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006041 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-97769-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="hoqza04Y"; 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 435zgv0bXcz9s8r for ; Sat, 1 Dec 2018 03:03:06 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=rTqAnkWsbbWSrh8lkYucZstEofFCPLZ AKSSAVxVPgDXVm5hO7euFohiBiQh6N6Wy0AY0mFV2njNpKhmZVMyOAKqtgYaGRY9 jSOJVZHrnNTBjmOKVoIFcOXkULKuJ5+MHqEaQOsanLKAI3RulezBHPK7WRU4NURG bMTxLjiaYSxc= 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=5OPQZEO8wedlU3IGC9dJaya1d4k=; b=hoqza 04YgtQVVb9vNFNgqWGgrrOeOny2qtPBR0PDZfb3/PMlCJIfhIEkdig82pKxqH76B DRwFuggpsyoR/Q6R2OqZrVF3SRbvltSpdFMWJF7WEWd6uUYsQfd/K39pPPkswjIl 2R9DXrXLlkRPh1qxLhGfI7LCFm4w3ChdAeIfDA= Received: (qmail 20152 invoked by alias); 30 Nov 2018 15:59:51 -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 19544 invoked by uid 89); 30 Nov 2018 15:59:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 20/56] S390: Refactor strncpy ifunc handling. Date: Fri, 30 Nov 2018 16:57:58 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0012-0000-0000-000002D2B613 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0013-0000-0000-000021080467 Message-Id: <1543593514-10251-21-git-send-email-stli@linux.ibm.com> The ifunc handling for strncpy is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. Note: The fallback s390-32/s390-64 ifunc variants are now moved to the strncpy-z900.S files. The s390-32/s390-64 files multiarch/strncpy.c and strncpy.S are deleted. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove strncpy variants. * sysdeps/s390/Makefile (sysdep_routines): Add strncpy variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for strncpy. * sysdeps/s390/multiarch/strncpy-vx.S: Move to ... * sysdeps/s390/strncpy-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strncpy.c: Move to ... * sysdeps/s390/strncpy.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-strncpy.h: New file. * sysdeps/s390/s390-64/strncpy.S: Move to ... * sysdeps/s390/s390-64/strncpy-z900.S: ... here and adjust ifunc handling. * sysdeps/s390/s390-32/strncpy.S: Move to ... * sysdeps/s390/s390-32/strncpy-z900.S: ... here and adjust ifunc handling. * sysdeps/s390/s390-32/multiarch/strncpy.c: Delete file. * sysdeps/s390/s390-64/multiarch/strncpy.c: Likewise. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strncpy.h | 52 +++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 +++++- sysdeps/s390/s390-32/multiarch/strncpy.c | 21 -------- .../s390-32/{strncpy.S => strncpy-z900.S} | 16 ++++-- sysdeps/s390/s390-64/multiarch/strncpy.c | 21 -------- .../s390-64/{strncpy.S => strncpy-z900.S} | 16 ++++-- sysdeps/s390/{multiarch => }/strncpy-vx.S | 25 ++++----- sysdeps/s390/{multiarch => }/strncpy.c | 17 +++++- 10 files changed, 123 insertions(+), 66 deletions(-) create mode 100644 sysdeps/s390/ifunc-strncpy.h delete mode 100644 sysdeps/s390/s390-32/multiarch/strncpy.c rename sysdeps/s390/s390-32/{strncpy.S => strncpy-z900.S} (89%) delete mode 100644 sysdeps/s390/s390-64/multiarch/strncpy.c rename sysdeps/s390/s390-64/{strncpy.S => strncpy-z900.S} (90%) rename sysdeps/s390/{multiarch => }/strncpy-vx.S (93%) rename sysdeps/s390/{multiarch => }/strncpy.c (71%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 96f1538cfd..7cadf7ceba 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -63,5 +63,6 @@ sysdep_routines += bzero memset memset-z900 \ strlen strlen-vx strlen-c \ strnlen strnlen-vx strnlen-c \ strcpy strcpy-vx strcpy-z900 \ - stpcpy stpcpy-vx stpcpy-c + stpcpy stpcpy-vx stpcpy-c \ + strncpy strncpy-vx strncpy-z900 endif diff --git a/sysdeps/s390/ifunc-strncpy.h b/sysdeps/s390/ifunc-strncpy.h new file mode 100644 index 0000000000..31e87e93c5 --- /dev/null +++ b/sysdeps/s390/ifunc-strncpy.h @@ -0,0 +1,52 @@ +/* strncpy variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRNCPY_IFUNC 1 +#else +# define HAVE_STRNCPY_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRNCPY_IFUNC_AND_VX_SUPPORT HAVE_STRNCPY_IFUNC +#else +# define HAVE_STRNCPY_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRNCPY_DEFAULT STRNCPY_Z13 +# define HAVE_STRNCPY_Z900_G5 0 +# define HAVE_STRNCPY_Z13 1 +#else +# define STRNCPY_DEFAULT STRNCPY_Z900_G5 +# define HAVE_STRNCPY_Z900_G5 1 +# define HAVE_STRNCPY_Z13 HAVE_STRNCPY_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRNCPY_Z900_G5 +# define STRNCPY_Z900_G5 __strncpy_default +#else +# define STRNCPY_Z900_G5 NULL +#endif + +#if HAVE_STRNCPY_Z13 +# define STRNCPY_Z13 __strncpy_vx +#else +# define STRNCPY_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 9517417dcb..c5189b556c 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strncpy strncpy-vx \ - stpncpy stpncpy-vx stpncpy-c \ +sysdep_routines += stpncpy stpncpy-vx stpncpy-c \ strcat strcat-vx strcat-c \ strncat strncat-vx strncat-c \ strcmp strcmp-vx \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 678ed13833..d598fc5c22 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -30,6 +30,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -216,6 +217,19 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STPCPY_IFUNC */ +#if HAVE_STRNCPY_IFUNC + IFUNC_IMPL (i, name, strncpy, +# if HAVE_STRNCPY_Z13 + IFUNC_IMPL_ADD (array, i, strncpy, + dl_hwcap & HWCAP_S390_VX, STRNCPY_Z13) +# endif +# if HAVE_STRNCPY_Z900_G5 + IFUNC_IMPL_ADD (array, i, strncpy, 1, STRNCPY_Z900_G5) +# endif + ) +#endif /* HAVE_STRNCPY_IFUNC */ + + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -232,7 +246,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcpcpy); - IFUNC_VX_IMPL (strncpy); IFUNC_VX_IMPL (wcsncpy); IFUNC_VX_IMPL (stpncpy); diff --git a/sysdeps/s390/s390-32/multiarch/strncpy.c b/sysdeps/s390/s390-32/multiarch/strncpy.c deleted file mode 100644 index 57f9df18d1..0000000000 --- a/sysdeps/s390/s390-32/multiarch/strncpy.c +++ /dev/null @@ -1,21 +0,0 @@ -/* Multiple versions of strncpy. - Copyright (C) 2015-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 - . */ - -/* This wrapper-file is needed, because otherwise file - sysdeps/s390/s390-[32|64]/strncpy.S will be used. */ -#include diff --git a/sysdeps/s390/s390-32/strncpy.S b/sysdeps/s390/s390-32/strncpy-z900.S similarity index 89% rename from sysdeps/s390/s390-32/strncpy.S rename to sysdeps/s390/s390-32/strncpy-z900.S index 9086eb1c70..ebdaba0152 100644 --- a/sysdeps/s390/s390-32/strncpy.S +++ b/sysdeps/s390/s390-32/strncpy-z900.S @@ -24,10 +24,12 @@ * R4 = max of bytes to copy */ +#include #include "sysdep.h" #include "asm-syntax.h" -ENTRY(strncpy) +#if HAVE_STRNCPY_Z900_G5 +ENTRY(STRNCPY_Z900_G5) .text st %r2,24(%r15) # save dst pointer slr %r2,%r3 # %r3 points to src, %r2+%r3 to dst @@ -75,5 +77,13 @@ ENTRY(strncpy) jo .L9 .Lexit: l %r2,24(%r15) # return dst pointer br %r14 -END(strncpy) -libc_hidden_builtin_def (strncpy) +END(STRNCPY_Z900_G5) + +# if ! HAVE_STRNCPY_IFUNC +strong_alias (STRNCPY_Z900_G5, strncpy) +# endif + +# if defined SHARED && IS_IN (libc) +strong_alias (STRNCPY_Z900_G5, __GI_strncpy) +# endif +#endif diff --git a/sysdeps/s390/s390-64/multiarch/strncpy.c b/sysdeps/s390/s390-64/multiarch/strncpy.c deleted file mode 100644 index 57f9df18d1..0000000000 --- a/sysdeps/s390/s390-64/multiarch/strncpy.c +++ /dev/null @@ -1,21 +0,0 @@ -/* Multiple versions of strncpy. - Copyright (C) 2015-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 - . */ - -/* This wrapper-file is needed, because otherwise file - sysdeps/s390/s390-[32|64]/strncpy.S will be used. */ -#include diff --git a/sysdeps/s390/s390-64/strncpy.S b/sysdeps/s390/s390-64/strncpy-z900.S similarity index 90% rename from sysdeps/s390/s390-64/strncpy.S rename to sysdeps/s390/s390-64/strncpy-z900.S index be40aa32d5..5732e6d83b 100644 --- a/sysdeps/s390/s390-64/strncpy.S +++ b/sysdeps/s390/s390-64/strncpy-z900.S @@ -23,10 +23,12 @@ %r3 = address of source (src) %r4 = max of bytes to copy. */ +#include #include "sysdep.h" #include "asm-syntax.h" -ENTRY(strncpy) +#if HAVE_STRNCPY_Z900_G5 +ENTRY(STRNCPY_Z900_G5) .text stg %r2,48(%r15) # save dst pointer slgr %r2,%r3 # %r3 points to src, %r2+%r3 to dst @@ -86,5 +88,13 @@ ENTRY(strncpy) jo .L13 .Lexit: lg %r2,48(%r15) # return dst pointer br %r14 -END(strncpy) -libc_hidden_builtin_def (strncpy) +END(STRNCPY_Z900_G5) + +# if ! HAVE_STRNCPY_IFUNC +strong_alias (STRNCPY_Z900_G5, strncpy) +# endif + +# if defined SHARED && IS_IN (libc) +strong_alias (STRNCPY_Z900_G5, __GI_strncpy) +# endif +#endif diff --git a/sysdeps/s390/multiarch/strncpy-vx.S b/sysdeps/s390/strncpy-vx.S similarity index 93% rename from sysdeps/s390/multiarch/strncpy-vx.S rename to sysdeps/s390/strncpy-vx.S index 2a37b7b84e..be09ddf092 100644 --- a/sysdeps/s390/multiarch/strncpy-vx.S +++ b/sysdeps/s390/strncpy-vx.S @@ -16,13 +16,13 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) - -# include "sysdep.h" -# include "asm-syntax.h" +#include +#include "sysdep.h" +#include "asm-syntax.h" .text +#if HAVE_STRNCPY_Z13 /* char * strncpy (const char *dest, const char *src, size_t n) Copy at most n characters of string src to dest. @@ -40,7 +40,7 @@ -v18=part of src -v31=register save area for r6, r7 */ -ENTRY(__strncpy_vx) +ENTRY(STRNCPY_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -196,12 +196,13 @@ ENTRY(__strncpy_vx) vl %v16,0(%r5,%r3) /* Load s. */ j .Llt64 -END(__strncpy_vx) +END(STRNCPY_Z13) -# define strncpy __strncpy_c -# undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) strong_alias(__strncpy_c, __GI_strncpy) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +# if ! HAVE_STRNCPY_IFUNC +strong_alias (STRNCPY_Z13, strncpy) +# endif -/* Include strncpy-implementation in s390-32/s390-64 subdirectory. */ -#include +# if ! HAVE_STRNCPY_Z900_G5 && defined SHARED && IS_IN (libc) +strong_alias (STRNCPY_Z13, __GI_strncpy) +# endif +#endif diff --git a/sysdeps/s390/multiarch/strncpy.c b/sysdeps/s390/strncpy.c similarity index 71% rename from sysdeps/s390/multiarch/strncpy.c rename to sysdeps/s390/strncpy.c index 2d4c456d96..ec8a26471b 100644 --- a/sysdeps/s390/multiarch/strncpy.c +++ b/sysdeps/s390/strncpy.c @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRNCPY_IFUNC # define strncpy __redirect_strncpy /* Omit the strncpy inline definitions because it would redefine strncpy. */ # define __NO_STRING_INLINES @@ -24,6 +26,17 @@ # undef strncpy # include -s390_vx_libc_ifunc2_redirected (__redirect_strncpy, __strncpy, strncpy); +# if HAVE_STRNCPY_Z900_G5 +extern __typeof (__redirect_strncpy) STRNCPY_Z900_G5 attribute_hidden; +# endif + +# if HAVE_STRNCPY_Z13 +extern __typeof (__redirect_strncpy) STRNCPY_Z13 attribute_hidden; +# endif +s390_libc_ifunc_expr (__redirect_strncpy, strncpy, + (HAVE_STRNCPY_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRNCPY_Z13 + : STRNCPY_DEFAULT + ) #endif From patchwork Fri Nov 30 15:57:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006048 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-97776-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="xkiPal7a"; 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 435zjb3kK1z9s8r for ; Sat, 1 Dec 2018 03:04: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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=pybnjRP2yQFb9mjW6ASJVEaLzIoWs5Q ja0+y1QX/1fLUmVRIVCuVXlaHoDWixtGEf84tkfoTAqipbrpnWDHSmWAsc0X70gC ysckCwooyUT2kQBmtr/xfwU/srPJ2mtrSxw10lJWtwTnO6OHX8hjcg0iN8/BcHiQ 1g/bQojFmUrs= 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=vh5LFyPdqbMWH9jzZ5zPtJTkI30=; b=xkiPa l7a7IMsliNv9WAogvKGUMat4WYyGbgCF12CgYTlR3Wq63JbnlQU22HjlRP7hP6RE nUhO2T3oP54tXAhmnJ0FyAsycQABNEe3eYByk5X2CS0Xp3HP1Rp4MQm6nXQjmej8 +a8fRi1rExXFvvZHQ2gvQCenqS6yilvZ8K8lm8= Received: (qmail 87907 invoked by alias); 30 Nov 2018 16:01:28 -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 60802 invoked by uid 89); 30 Nov 2018 16:00:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=unavailable version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 21/56] S390: Refactor stpncpy ifunc handling. Date: Fri, 30 Nov 2018 16:57:59 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0020-0000-0000-000002F039BA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0021-0000-0000-0000213FA036 Message-Id: <1543593514-10251-22-git-send-email-stli@linux.ibm.com> The ifunc handling for stpncpy is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove stpncpy variants. * sysdeps/s390/Makefile (sysdep_routines): Add stpncpy variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for stpncpy. * sysdeps/s390/multiarch/stpncpy-c.c: Move to ... * sysdeps/s390/stpncpy-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/stpncpy-vx.S: Move to ... * sysdeps/s390/stpncpy-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/stpncpy.c: Move to ... * sysdeps/s390/stpncpy.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-stpncpy.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-stpncpy.h | 52 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 +++++- sysdeps/s390/{multiarch => }/stpncpy-c.c | 21 +++++---- sysdeps/s390/{multiarch => }/stpncpy-vx.S | 19 +++++++-- sysdeps/s390/{multiarch => }/stpncpy.c | 23 +++++++--- 7 files changed, 113 insertions(+), 22 deletions(-) create mode 100644 sysdeps/s390/ifunc-stpncpy.h rename sysdeps/s390/{multiarch => }/stpncpy-c.c (74%) rename sysdeps/s390/{multiarch => }/stpncpy-vx.S (95%) rename sysdeps/s390/{multiarch => }/stpncpy.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 7cadf7ceba..f02afd4d02 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -64,5 +64,6 @@ sysdep_routines += bzero memset memset-z900 \ strnlen strnlen-vx strnlen-c \ strcpy strcpy-vx strcpy-z900 \ stpcpy stpcpy-vx stpcpy-c \ - strncpy strncpy-vx strncpy-z900 + strncpy strncpy-vx strncpy-z900 \ + stpncpy stpncpy-vx stpncpy-c endif diff --git a/sysdeps/s390/ifunc-stpncpy.h b/sysdeps/s390/ifunc-stpncpy.h new file mode 100644 index 0000000000..46e57334e8 --- /dev/null +++ b/sysdeps/s390/ifunc-stpncpy.h @@ -0,0 +1,52 @@ +/* stpncpy variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STPNCPY_IFUNC 1 +#else +# define HAVE_STPNCPY_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STPNCPY_IFUNC_AND_VX_SUPPORT HAVE_STPNCPY_IFUNC +#else +# define HAVE_STPNCPY_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STPNCPY_DEFAULT STPNCPY_Z13 +# define HAVE_STPNCPY_C 0 +# define HAVE_STPNCPY_Z13 1 +#else +# define STPNCPY_DEFAULT STPNCPY_C +# define HAVE_STPNCPY_C 1 +# define HAVE_STPNCPY_Z13 HAVE_STPNCPY_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STPNCPY_C +# define STPNCPY_C __stpncpy_c +#else +# define STPNCPY_C NULL +#endif + +#if HAVE_STPNCPY_Z13 +# define STPNCPY_Z13 __stpncpy_vx +#else +# define STPNCPY_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index c5189b556c..3d97d21da1 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += stpncpy stpncpy-vx stpncpy-c \ - strcat strcat-vx strcat-c \ +sysdep_routines += strcat strcat-vx strcat-c \ strncat strncat-vx strncat-c \ strcmp strcmp-vx \ strncmp strncmp-vx strncmp-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index d598fc5c22..021e9f247f 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -31,6 +31,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -229,6 +230,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRNCPY_IFUNC */ +#if HAVE_STPNCPY_IFUNC + IFUNC_IMPL (i, name, stpncpy, +# if HAVE_STPNCPY_Z13 + IFUNC_IMPL_ADD (array, i, stpncpy, + dl_hwcap & HWCAP_S390_VX, STPNCPY_Z13) +# endif +# if HAVE_STPNCPY_C + IFUNC_IMPL_ADD (array, i, stpncpy, 1, STPNCPY_C) +# endif + ) +#endif /* HAVE_STPNCPY_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT @@ -248,7 +261,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcsncpy); - IFUNC_VX_IMPL (stpncpy); IFUNC_VX_IMPL (wcpncpy); IFUNC_VX_IMPL (strcat); diff --git a/sysdeps/s390/multiarch/stpncpy-c.c b/sysdeps/s390/stpncpy-c.c similarity index 74% rename from sysdeps/s390/multiarch/stpncpy-c.c rename to sysdeps/s390/stpncpy-c.c index 45e50aa9e7..e5d1ae8675 100644 --- a/sysdeps/s390/multiarch/stpncpy-c.c +++ b/sysdeps/s390/stpncpy-c.c @@ -16,13 +16,18 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define STPNCPY __stpncpy_c -# ifdef SHARED -# undef libc_hidden_def -# define libc_hidden_def(name) \ - __hidden_ver1 (__stpncpy_c, __GI___stpncpy, __stpncpy_c); -# endif /* SHARED */ +#include + +#if HAVE_STPNCPY_C +# if HAVE_STPNCPY_IFUNC +# define STPNCPY STPNCPY_C + +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_def +# define libc_hidden_def(name) \ + __hidden_ver1 (__stpncpy_c, __GI___stpncpy, __stpncpy_c); +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/stpncpy-vx.S b/sysdeps/s390/stpncpy-vx.S similarity index 95% rename from sysdeps/s390/multiarch/stpncpy-vx.S rename to sysdeps/s390/stpncpy-vx.S index 922bd7a355..3dccc10be3 100644 --- a/sysdeps/s390/multiarch/stpncpy-vx.S +++ b/sysdeps/s390/stpncpy-vx.S @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STPNCPY_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -38,7 +40,7 @@ -%r6 = loaded bytes -%r7 = border, tmp */ -ENTRY(__stpncpy_vx) +ENTRY(STPNCPY_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -196,5 +198,14 @@ ENTRY(__stpncpy_vx) vl %v16,0(%r5,%r3) /* Load s. */ j .Llt64 -END(__stpncpy_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(STPNCPY_Z13) + +# if ! HAVE_STPNCPY_IFUNC +strong_alias (STPNCPY_Z13, __stpncpy) +weak_alias (__stpncpy, stpncpy) +# endif + +# if ! HAVE_STPNCPY_C && defined SHARED && IS_IN (libc) +strong_alias (STPNCPY_Z13, __GI___stpncpy) +# endif +#endif diff --git a/sysdeps/s390/multiarch/stpncpy.c b/sysdeps/s390/stpncpy.c similarity index 70% rename from sysdeps/s390/multiarch/stpncpy.c rename to sysdeps/s390/stpncpy.c index f7f9d51a50..250dc68ed1 100644 --- a/sysdeps/s390/multiarch/stpncpy.c +++ b/sysdeps/s390/stpncpy.c @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STPNCPY_IFUNC # define stpncpy __redirect_stpncpy # define __stpncpy __redirect___stpncpy # include @@ -24,9 +26,18 @@ # undef __stpncpy # include -s390_vx_libc_ifunc_redirected (__redirect___stpncpy, __stpncpy) -weak_alias (__stpncpy, stpncpy) +# if HAVE_STPNCPY_C +extern __typeof (__redirect_stpncpy) STPNCPY_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_STPNCPY_Z13 +extern __typeof (__redirect_stpncpy) STPNCPY_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect___stpncpy, __stpncpy, + (HAVE_STPNCPY_Z13 && (hwcap & HWCAP_S390_VX)) + ? STPNCPY_Z13 + : STPNCPY_DEFAULT + ) +weak_alias (__stpncpy, stpncpy) +#endif From patchwork Fri Nov 30 15:58:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006065 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-97792-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="IRvHefEp"; 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 435zmw4Gr4z9sBZ for ; Sat, 1 Dec 2018 03:07:28 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=wYI6Ym6Cgw/+zSw/cruOQMaXqmZOOUN t/FbTV0UdrdxmIjRpOc5um2nVrO/ojPPATMAo9EGdlfgM1ZhHtU13/bHET9YwMCN GzVJ5zLcyVu9kMtm4YK1sKGuAb5YR8JNuEu5Nv7LKsXNZdc7C02RCGefkfcgdCk7 EgDYHUCf/9+8= 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=VSC0CflbfKHYnyUl34LXXTLXVxA=; b=IRvHe fEp1yP4pGlMV8pPRRz/rZ9eo5UyrrNWAsCQyZn9NlQf6Hr7eBKOSpmewfP55jYXK ezkUEjjoMyOiWVllYzqQRkObQ64KRYbgK5TJ07DUofZxIY4gAa1AbunrVXKg1PoQ DVU4NL3l69oJPm5KPWNZzkBbPmPyQoXJr7oQuE= Received: (qmail 110309 invoked by alias); 30 Nov 2018 16:04:15 -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 110218 invoked by uid 89); 30 Nov 2018 16:04:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 22/56] S390: Refactor strcat ifunc handling. Date: Fri, 30 Nov 2018 16:58:00 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-4275-0000-0000-000002E935D1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-4276-0000-0000-000037F67E6F Message-Id: <1543593514-10251-23-git-send-email-stli@linux.ibm.com> The ifunc handling for strcat is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove strcat variants. * sysdeps/s390/Makefile (sysdep_routines): Add strcat variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for strcat. * sysdeps/s390/multiarch/strcat-c.c: Move to ... * sysdeps/s390/strcat-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strcat-vx.S: Move to ... * sysdeps/s390/strcat-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strcat.c: Move to ... * sysdeps/s390/strcat.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-strcat.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strcat.h | 52 ++++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 13 +++++- sysdeps/s390/{multiarch => }/strcat-c.c | 20 +++++---- sysdeps/s390/{multiarch => }/strcat-vx.S | 17 ++++++-- sysdeps/s390/{multiarch => }/strcat.c | 21 +++++++--- 7 files changed, 108 insertions(+), 21 deletions(-) create mode 100644 sysdeps/s390/ifunc-strcat.h rename sysdeps/s390/{multiarch => }/strcat-c.c (73%) rename sysdeps/s390/{multiarch => }/strcat-vx.S (94%) rename sysdeps/s390/{multiarch => }/strcat.c (69%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index f02afd4d02..3783f44252 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -65,5 +65,6 @@ sysdep_routines += bzero memset memset-z900 \ strcpy strcpy-vx strcpy-z900 \ stpcpy stpcpy-vx stpcpy-c \ strncpy strncpy-vx strncpy-z900 \ - stpncpy stpncpy-vx stpncpy-c + stpncpy stpncpy-vx stpncpy-c \ + strcat strcat-vx strcat-c endif diff --git a/sysdeps/s390/ifunc-strcat.h b/sysdeps/s390/ifunc-strcat.h new file mode 100644 index 0000000000..6fd2f7dd31 --- /dev/null +++ b/sysdeps/s390/ifunc-strcat.h @@ -0,0 +1,52 @@ +/* strcat variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRCAT_IFUNC 1 +#else +# define HAVE_STRCAT_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRCAT_IFUNC_AND_VX_SUPPORT HAVE_STRCAT_IFUNC +#else +# define HAVE_STRCAT_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRCAT_DEFAULT STRCAT_Z13 +# define HAVE_STRCAT_C 0 +# define HAVE_STRCAT_Z13 1 +#else +# define STRCAT_DEFAULT STRCAT_C +# define HAVE_STRCAT_C 1 +# define HAVE_STRCAT_Z13 HAVE_STRCAT_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRCAT_C +# define STRCAT_C __strcat_c +#else +# define STRCAT_C NULL +#endif + +#if HAVE_STRCAT_Z13 +# define STRCAT_Z13 __strcat_vx +#else +# define STRCAT_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 3d97d21da1..9b66237aaf 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strcat strcat-vx strcat-c \ - strncat strncat-vx strncat-c \ +sysdep_routines += strncat strncat-vx strncat-c \ strcmp strcmp-vx \ strncmp strncmp-vx strncmp-c \ strchr strchr-vx strchr-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 021e9f247f..1b7f3df3a3 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -32,6 +32,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -242,6 +243,17 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STPNCPY_IFUNC */ +#if HAVE_STRCAT_IFUNC + IFUNC_IMPL (i, name, strcat, +# if HAVE_STRCAT_Z13 + IFUNC_IMPL_ADD (array, i, strcat, + dl_hwcap & HWCAP_S390_VX, STRCAT_Z13) +# endif +# if HAVE_STRCAT_C + IFUNC_IMPL_ADD (array, i, strcat, 1, STRCAT_C) +# endif + ) +#endif /* HAVE_STRCAT_IFUNC */ #ifdef HAVE_S390_VX_ASM_SUPPORT @@ -263,7 +275,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcpncpy); - IFUNC_VX_IMPL (strcat); IFUNC_VX_IMPL (wcscat); IFUNC_VX_IMPL (strncat); diff --git a/sysdeps/s390/multiarch/strcat-c.c b/sysdeps/s390/strcat-c.c similarity index 73% rename from sysdeps/s390/multiarch/strcat-c.c rename to sysdeps/s390/strcat-c.c index f871faa7b5..7accc6c7ef 100644 --- a/sysdeps/s390/multiarch/strcat-c.c +++ b/sysdeps/s390/strcat-c.c @@ -16,13 +16,17 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define STRCAT __strcat_c -# ifdef SHARED -# undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) \ - __hidden_ver1 (__strcat_c, __GI_strcat, __strcat_c); -# endif /* SHARED */ +#include + +#if HAVE_STRCAT_C +# if HAVE_STRCAT_IFUNC +# define STRCAT STRCAT_C +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) \ + __hidden_ver1 (__strcat_c, __GI_strcat, __strcat_c); +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/strcat-vx.S b/sysdeps/s390/strcat-vx.S similarity index 94% rename from sysdeps/s390/multiarch/strcat-vx.S rename to sysdeps/s390/strcat-vx.S index 3abbbccced..218e301f10 100644 --- a/sysdeps/s390/multiarch/strcat-vx.S +++ b/sysdeps/s390/strcat-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_STRCAT_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -37,7 +38,7 @@ -v17=index of zero -v18=part of src */ -ENTRY(__strcat_vx) +ENTRY(STRCAT_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -157,5 +158,13 @@ ENTRY(__strcat_vx) vstl %v16,%r5,0(%r2) /* Copy characters including zero. */ lgr %r2,%r0 /* Load saved dest-ptr. */ br %r14 -END(__strcat_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(STRCAT_Z13) + +# if ! HAVE_STRCAT_IFUNC +strong_alias (STRCAT_Z13, strcat) +# endif + +# if ! HAVE_STRCAT_C && defined SHARED && IS_IN (libc) +strong_alias (STRCAT_Z13, __GI_strcat) +# endif +#endif diff --git a/sysdeps/s390/multiarch/strcat.c b/sysdeps/s390/strcat.c similarity index 69% rename from sysdeps/s390/multiarch/strcat.c rename to sysdeps/s390/strcat.c index 7d4126b44f..d378519c8a 100644 --- a/sysdeps/s390/multiarch/strcat.c +++ b/sysdeps/s390/strcat.c @@ -16,14 +16,25 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRCAT_IFUNC # define strcat __redirect_strcat # include # undef strcat # include -s390_vx_libc_ifunc2_redirected (__redirect_strcat, __strcat, strcat) +# if HAVE_STRCAT_C +extern __typeof (__redirect_strcat) STRCAT_C attribute_hidden; +# endif + +# if HAVE_STRCAT_Z13 +extern __typeof (__redirect_strcat) STRCAT_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (__redirect_strcat, strcat, + (HAVE_STRCAT_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRCAT_Z13 + : STRCAT_DEFAULT + ) +#endif From patchwork Fri Nov 30 15:58:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006064 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-97791-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="cCmTkzlt"; 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 435zmk2Y46z9s8r for ; Sat, 1 Dec 2018 03:07:18 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=CTpvcNi7Str6HBb0EWGQrXK2Q/+iAcz g+KrVMpq5NTnso7kOpUzcJRPYIPW4wXyGzGhJ68BhAyBZvedkZg7CSpCW/tMFzEA pCERg5ehwIjAAYAEIvVAVUhbU45jNTa3VMAr1zCqsQztxdZM1vg+HDzkQDcyzFvV 8HY5mBCIJQ1Q= 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=CujoCwlzsUHz9bKOhYoa0nsUzTY=; b=cCmTk zltFn0iG6tHr3MvyRwIKKq8V1wiFPStUoie7/hE8fnkMjuvyR9yf9jBBK6tCJopx xrBvegEamTGM4PGJpiQckOqq9olIZav9p2qWFhV71vMM4jK84sVqrU6kD8bRsS5j JUdb81fV/XdljgFWnf1B0zN7W2K2LzdD6nRMpc= Received: (qmail 109787 invoked by alias); 30 Nov 2018 16:04:11 -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 109660 invoked by uid 89); 30 Nov 2018 16:04:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 23/56] S390: Refactor strncat ifunc handling. Date: Fri, 30 Nov 2018 16:58:01 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0020-0000-0000-000002F039BC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0021-0000-0000-0000213FA038 Message-Id: <1543593514-10251-24-git-send-email-stli@linux.ibm.com> The ifunc handling for strncat is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove strncat variants. * sysdeps/s390/Makefile (sysdep_routines): Add strncat variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for strncat. * sysdeps/s390/multiarch/strncat-c.c: Move to ... * sysdeps/s390/strncat-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strncat-vx.S: Move to ... * sysdeps/s390/strncat-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strncat.c: Move to ... * sysdeps/s390/strncat.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-strncat.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strncat.h | 52 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 +++++- sysdeps/s390/{multiarch => }/strncat-c.c | 10 +++-- sysdeps/s390/{multiarch => }/strncat-vx.S | 21 +++++++-- sysdeps/s390/{multiarch => }/strncat.c | 21 ++++++--- 7 files changed, 108 insertions(+), 16 deletions(-) create mode 100644 sysdeps/s390/ifunc-strncat.h rename sysdeps/s390/{multiarch => }/strncat-c.c (86%) rename sysdeps/s390/{multiarch => }/strncat-vx.S (94%) rename sysdeps/s390/{multiarch => }/strncat.c (69%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 3783f44252..ec0fb8c2ad 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -66,5 +66,6 @@ sysdep_routines += bzero memset memset-z900 \ stpcpy stpcpy-vx stpcpy-c \ strncpy strncpy-vx strncpy-z900 \ stpncpy stpncpy-vx stpncpy-c \ - strcat strcat-vx strcat-c + strcat strcat-vx strcat-c \ + strncat strncat-vx strncat-c endif diff --git a/sysdeps/s390/ifunc-strncat.h b/sysdeps/s390/ifunc-strncat.h new file mode 100644 index 0000000000..bb164dcc32 --- /dev/null +++ b/sysdeps/s390/ifunc-strncat.h @@ -0,0 +1,52 @@ +/* strncat variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRNCAT_IFUNC 1 +#else +# define HAVE_STRNCAT_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRNCAT_IFUNC_AND_VX_SUPPORT HAVE_STRNCAT_IFUNC +#else +# define HAVE_STRNCAT_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRNCAT_DEFAULT STRNCAT_Z13 +# define HAVE_STRNCAT_C 0 +# define HAVE_STRNCAT_Z13 1 +#else +# define STRNCAT_DEFAULT STRNCAT_C +# define HAVE_STRNCAT_C 1 +# define HAVE_STRNCAT_Z13 HAVE_STRNCAT_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRNCAT_C +# define STRNCAT_C __strncat_c +#else +# define STRNCAT_C NULL +#endif + +#if HAVE_STRNCAT_Z13 +# define STRNCAT_Z13 __strncat_vx +#else +# define STRNCAT_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 9b66237aaf..24be3eac51 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strncat strncat-vx strncat-c \ - strcmp strcmp-vx \ +sysdep_routines += strcmp strcmp-vx \ strncmp strncmp-vx strncmp-c \ strchr strchr-vx strchr-c \ strchrnul strchrnul-vx strchrnul-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 1b7f3df3a3..3abcaf08e0 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -33,6 +33,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -255,6 +256,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRCAT_IFUNC */ +#if HAVE_STRNCAT_IFUNC + IFUNC_IMPL (i, name, strncat, +# if HAVE_STRNCAT_Z13 + IFUNC_IMPL_ADD (array, i, strncat, + dl_hwcap & HWCAP_S390_VX, STRNCAT_Z13) +# endif +# if HAVE_STRNCAT_C + IFUNC_IMPL_ADD (array, i, strncat, 1, STRNCAT_C) +# endif + ) +#endif /* HAVE_STRNCAT_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -277,7 +290,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcscat); - IFUNC_VX_IMPL (strncat); IFUNC_VX_IMPL (wcsncat); IFUNC_VX_IMPL (strcmp); diff --git a/sysdeps/s390/multiarch/strncat-c.c b/sysdeps/s390/strncat-c.c similarity index 86% rename from sysdeps/s390/multiarch/strncat-c.c rename to sysdeps/s390/strncat-c.c index 9e6c245ccb..86df89887c 100644 --- a/sysdeps/s390/multiarch/strncat-c.c +++ b/sysdeps/s390/strncat-c.c @@ -16,8 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define STRNCAT __strncat_c -# define STRNCAT_PRIMARY +#include + +#if HAVE_STRNCAT_C +# if HAVE_STRNCAT_IFUNC +# define STRNCAT STRNCAT_C +# define STRNCAT_PRIMARY +# endif # include #endif diff --git a/sysdeps/s390/multiarch/strncat-vx.S b/sysdeps/s390/strncat-vx.S similarity index 94% rename from sysdeps/s390/multiarch/strncat-vx.S rename to sysdeps/s390/strncat-vx.S index e6584d0f43..76345e7dd7 100644 --- a/sysdeps/s390/multiarch/strncat-vx.S +++ b/sysdeps/s390/strncat-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_STRNCAT_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -40,7 +41,7 @@ -v18=part of src -v31=register save area for r6, r7 */ -ENTRY(__strncat_vx) +ENTRY(STRNCAT_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -235,5 +236,17 @@ ENTRY(__strncat_vx) vl %v16,0(%r5,%r3) /* Load s. */ j .Lcpy_lt64 -END(__strncat_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(STRNCAT_Z13) + +# if ! HAVE_STRNCAT_IFUNC +strong_alias (STRNCAT_Z13, strncat) +# endif + +# if ! HAVE_STRNCAT_C +/* See string/strncat.c and define STRNCAT_PRIMARY. */ +strong_alias (STRNCAT_Z13, __strncat) +# if defined SHARED && IS_IN (libc) +strong_alias (__strncat, __GI___strncat) +# endif +# endif +#endif diff --git a/sysdeps/s390/multiarch/strncat.c b/sysdeps/s390/strncat.c similarity index 69% rename from sysdeps/s390/multiarch/strncat.c rename to sysdeps/s390/strncat.c index 94b8dffa85..b4b3656c5a 100644 --- a/sysdeps/s390/multiarch/strncat.c +++ b/sysdeps/s390/strncat.c @@ -16,12 +16,23 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRNCAT_IFUNC # include # include -s390_vx_libc_ifunc2 (__strncat, strncat) +# if HAVE_STRNCAT_C +extern __typeof (__strncat) STRNCAT_C attribute_hidden; +# endif + +# if HAVE_STRNCAT_Z13 +extern __typeof (__strncat) STRNCAT_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (__strncat, strncat, + (HAVE_STRNCAT_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRNCAT_Z13 + : STRNCAT_DEFAULT + ) +#endif From patchwork Fri Nov 30 15:58:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006050 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-97778-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="vpEJnASe"; 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 435zjz4Mlsz9s8r for ; Sat, 1 Dec 2018 03:04:55 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=bd0hd+cYZYpxHgGicGfqDjQSDUDpJ3W sqCHif2fbcLoYCd70SHpt4mDoVEF93YVlKo4JaU+6uYsdJVpPWJdBQfiRx+Q07n4 BFm3YW8mfmroYMnalBGapQYrPEQ+vJEX8K3MnluZM+3Oz92vxcmNADnLglqe2rrb 1kIt8+tlaO2U= 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=bx33mdIcXcIVrr6gHanE3xaw8qI=; b=vpEJn ASezwgMEADNivzG1udAHwbKQF073ySICjvQA4qR/pDYiha3UBVR0wQmyhgJIFF7v uTD35gn0gLpmFONoUR0MvmCwqsmf43fsqrcYIWVB+Je7XkUEoPIsCWN7bspy8Fqh kWkIMMV382toWcn/IXPGwC8KKANUckqJ1wkzBg= Received: (qmail 94990 invoked by alias); 30 Nov 2018 16:02:20 -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 94881 invoked by uid 89); 30 Nov 2018 16:02:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 24/56] S390: Refactor strcmp ifunc handling. Date: Fri, 30 Nov 2018 16:58:02 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-4275-0000-0000-000002E935D4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-4276-0000-0000-000037F67E71 Message-Id: <1543593514-10251-25-git-send-email-stli@linux.ibm.com> The ifunc handling for strcmp is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. Note: The fallback s390-32/s390-64 ifunc variants with clst instruction are now moved to the unified strcmp-z900.S file which can be used for 31/64bit. The s390-32/s390-64 files multiarch/strcmp.c and strcmp.S are deleted. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove strcmp variants. * sysdeps/s390/Makefile (sysdep_routines): Add strcmp variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for strcmp. * sysdeps/s390/multiarch/strcmp-vx.S: Move to ... * sysdeps/s390/strcmp-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strcmp.c: Move to ... * sysdeps/s390/strcmp.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-strcmp.h: New file. * sysdeps/s390/s390-64/strcmp.S: Move to ... * sysdeps/s390/strcmp-z900.S: ... here and adjust to be usable for 31/64bit and ifunc handling. * sysdeps/s390/s390-32/multiarch/strcmp.c: Delete file. * sysdeps/s390/s390-64/multiarch/strcmp.c: Likewise. * sysdeps/s390/s390-32/strcmp.S: Likewise. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strcmp.h | 52 +++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 ++++- sysdeps/s390/s390-32/multiarch/strcmp.c | 21 -------- sysdeps/s390/s390-32/strcmp.S | 41 --------------- sysdeps/s390/s390-64/multiarch/strcmp.c | 21 -------- sysdeps/s390/{multiarch => }/strcmp-vx.S | 19 ++++--- .../s390/{s390-64/strcmp.S => strcmp-z900.S} | 32 +++++++++--- sysdeps/s390/{multiarch => }/strcmp.c | 17 +++++- 10 files changed, 119 insertions(+), 104 deletions(-) create mode 100644 sysdeps/s390/ifunc-strcmp.h delete mode 100644 sysdeps/s390/s390-32/multiarch/strcmp.c delete mode 100644 sysdeps/s390/s390-32/strcmp.S delete mode 100644 sysdeps/s390/s390-64/multiarch/strcmp.c rename sysdeps/s390/{multiarch => }/strcmp-vx.S (90%) rename sysdeps/s390/{s390-64/strcmp.S => strcmp-z900.S} (70%) rename sysdeps/s390/{multiarch => }/strcmp.c (71%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index ec0fb8c2ad..9e7d5625c9 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -67,5 +67,6 @@ sysdep_routines += bzero memset memset-z900 \ strncpy strncpy-vx strncpy-z900 \ stpncpy stpncpy-vx stpncpy-c \ strcat strcat-vx strcat-c \ - strncat strncat-vx strncat-c + strncat strncat-vx strncat-c \ + strcmp strcmp-vx strcmp-z900 endif diff --git a/sysdeps/s390/ifunc-strcmp.h b/sysdeps/s390/ifunc-strcmp.h new file mode 100644 index 0000000000..86ffe686ad --- /dev/null +++ b/sysdeps/s390/ifunc-strcmp.h @@ -0,0 +1,52 @@ +/* strcmp variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRCMP_IFUNC 1 +#else +# define HAVE_STRCMP_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRCMP_IFUNC_AND_VX_SUPPORT HAVE_STRCMP_IFUNC +#else +# define HAVE_STRCMP_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRCMP_DEFAULT STRCMP_Z13 +# define HAVE_STRCMP_Z900_G5 0 +# define HAVE_STRCMP_Z13 1 +#else +# define STRCMP_DEFAULT STRCMP_Z900_G5 +# define HAVE_STRCMP_Z900_G5 1 +# define HAVE_STRCMP_Z13 HAVE_STRCMP_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRCMP_Z900_G5 +# define STRCMP_Z900_G5 __strcmp_default +#else +# define STRCMP_Z900_G5 NULL +#endif + +#if HAVE_STRCMP_Z13 +# define STRCMP_Z13 __strcmp_vx +#else +# define STRCMP_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 24be3eac51..97421a4996 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strcmp strcmp-vx \ - strncmp strncmp-vx strncmp-c \ +sysdep_routines += strncmp strncmp-vx strncmp-c \ strchr strchr-vx strchr-c \ strchrnul strchrnul-vx strchrnul-c \ strrchr strrchr-vx strrchr-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 3abcaf08e0..44637c431b 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -34,6 +34,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -268,6 +269,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRNCAT_IFUNC */ +#if HAVE_STRCMP_IFUNC + IFUNC_IMPL (i, name, strcmp, +# if HAVE_STRCMP_Z13 + IFUNC_IMPL_ADD (array, i, strcmp, + dl_hwcap & HWCAP_S390_VX, STRCMP_Z13) +# endif +# if HAVE_STRCMP_Z900_G5 + IFUNC_IMPL_ADD (array, i, strcmp, 1, STRCMP_Z900_G5) +# endif + ) +#endif /* HAVE_STRCMP_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -292,7 +305,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcsncat); - IFUNC_VX_IMPL (strcmp); IFUNC_VX_IMPL (wcscmp); IFUNC_VX_IMPL (strncmp); diff --git a/sysdeps/s390/s390-32/multiarch/strcmp.c b/sysdeps/s390/s390-32/multiarch/strcmp.c deleted file mode 100644 index d06b0f3436..0000000000 --- a/sysdeps/s390/s390-32/multiarch/strcmp.c +++ /dev/null @@ -1,21 +0,0 @@ -/* Multiple versions of strcmp. - Copyright (C) 2015-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 - . */ - -/* This wrapper-file is needed, because otherwise file - sysdeps/s390/s390-[32|64]/strcmp.S will be used. */ -#include diff --git a/sysdeps/s390/s390-32/strcmp.S b/sysdeps/s390/s390-32/strcmp.S deleted file mode 100644 index 3cf3f239fd..0000000000 --- a/sysdeps/s390/s390-32/strcmp.S +++ /dev/null @@ -1,41 +0,0 @@ -/* strcmp - compare two string. S/390 version. - This file is part of the GNU C Library. - Copyright (C) 2001-2018 Free Software Foundation, Inc. - Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). - - 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 - . */ - -/* INPUT PARAMETERS - %r2 = address of string 1 - %r3 = address of string 2. */ - -#include "sysdep.h" -#include "asm-syntax.h" - - .text -ENTRY(strcmp) - slr %r0,%r0 -0: clst %r2,%r3 - jo 0b - jp 1f - jm 2f - slr %r2,%r2 - br %r14 -1: lhi %r2,1 - br %r14 -2: lhi %r2,-1 - br %r14 -END(strcmp) -libc_hidden_builtin_def (strcmp) diff --git a/sysdeps/s390/s390-64/multiarch/strcmp.c b/sysdeps/s390/s390-64/multiarch/strcmp.c deleted file mode 100644 index d06b0f3436..0000000000 --- a/sysdeps/s390/s390-64/multiarch/strcmp.c +++ /dev/null @@ -1,21 +0,0 @@ -/* Multiple versions of strcmp. - Copyright (C) 2015-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 - . */ - -/* This wrapper-file is needed, because otherwise file - sysdeps/s390/s390-[32|64]/strcmp.S will be used. */ -#include diff --git a/sysdeps/s390/multiarch/strcmp-vx.S b/sysdeps/s390/strcmp-vx.S similarity index 90% rename from sysdeps/s390/multiarch/strcmp-vx.S rename to sysdeps/s390/strcmp-vx.S index bcaeb564d4..801ad9d32b 100644 --- a/sysdeps/s390/multiarch/strcmp-vx.S +++ b/sysdeps/s390/strcmp-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_STRCMP_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -36,7 +37,7 @@ -v17=part of s2 -v18=index of unequal */ -ENTRY(__strcmp_vx) +ENTRY(STRCMP_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -106,11 +107,13 @@ ENTRY(__strcmp_vx) .Lend_equal: lghi %r2,0 br %r14 -END(__strcmp_vx) +END(STRCMP_Z13) -# define strcmp __strcmp_c -# undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) strong_alias(__strcmp_c, __GI_strcmp) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +# if ! HAVE_STRCMP_IFUNC +strong_alias (STRCMP_Z13, strcmp) +# endif -#include +# if ! HAVE_STRCMP_Z900_G5 && defined SHARED && IS_IN (libc) +strong_alias (STRCMP_Z13, __GI_strcmp) +# endif +#endif diff --git a/sysdeps/s390/s390-64/strcmp.S b/sysdeps/s390/strcmp-z900.S similarity index 70% rename from sysdeps/s390/s390-64/strcmp.S rename to sysdeps/s390/strcmp-z900.S index 6cf1addd8b..67b3c8b2e5 100644 --- a/sysdeps/s390/s390-64/strcmp.S +++ b/sysdeps/s390/strcmp-z900.S @@ -21,21 +21,39 @@ %r2 = address of string 1 %r3 = address of string 2. */ +#include #include "sysdep.h" #include "asm-syntax.h" +#if HAVE_STRCMP_Z900_G5 +# if defined __s390x__ +# define SLGR slgr +# define LGHI lghi +# else +# define SLGR slr +# define LGHI lhi +# endif /* ! defined __s390x__ */ + .text -ENTRY(strcmp) - slr %r0,%r0 +ENTRY(STRCMP_Z900_G5) + SLGR %r0,%r0 0: clst %r2,%r3 jo 0b jp 1f jm 2f - slgr %r2,%r2 + SLGR %r2,%r2 br %r14 -1: lghi %r2,1 +1: LGHI %r2,1 br %r14 -2: lghi %r2,-1 +2: LGHI %r2,-1 br %r14 -END(strcmp) -libc_hidden_builtin_def (strcmp) +END(STRCMP_Z900_G5) + +# if ! HAVE_STRCMP_IFUNC +strong_alias (STRCMP_Z900_G5, strcmp) +# endif + +# if defined SHARED && IS_IN (libc) +strong_alias (STRCMP_Z900_G5, __GI_strcmp) +# endif +#endif diff --git a/sysdeps/s390/multiarch/strcmp.c b/sysdeps/s390/strcmp.c similarity index 71% rename from sysdeps/s390/multiarch/strcmp.c rename to sysdeps/s390/strcmp.c index 7c8b17b304..9efa30acaf 100644 --- a/sysdeps/s390/multiarch/strcmp.c +++ b/sysdeps/s390/strcmp.c @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRCMP_IFUNC # define strcmp __redirect_strcmp /* Omit the strcmp inline definitions because it would redefine strcmp. */ # define __NO_STRING_INLINES @@ -24,6 +26,17 @@ # include # undef strcmp -s390_vx_libc_ifunc2_redirected (__redirect_strcmp, __strcmp, strcmp) +# if HAVE_STRCMP_Z900_G5 +extern __typeof (__redirect_strcmp) STRCMP_Z900_G5 attribute_hidden; +# endif + +# if HAVE_STRCMP_Z13 +extern __typeof (__redirect_strcmp) STRCMP_Z13 attribute_hidden; +# endif +s390_libc_ifunc_expr (__redirect_strcmp, strcmp, + (HAVE_STRCMP_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRCMP_Z13 + : STRCMP_DEFAULT + ) #endif From patchwork Fri Nov 30 15:58:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006062 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-97789-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="qM/yA0oL"; 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 435zmJ424Nz9s8r for ; Sat, 1 Dec 2018 03:06:56 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=WY6Oeq8lpvUP/MB61yEHH9FbOFqPrL8 JulMcm8d8bFeo91+uWeKUyABHBBXkM54Kn4vDe0k9refxgKbMorhrx1Qyu21tW69 eqd5zC0QlA79bSqjoZ6zKwpEcAkt3yTLIBTVKqZkJQflNR1x8KARrXzr0VFE42m4 to9VLevC476s= 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=R7bFPrqP+eG1uSd2j3a1/TjRdvM=; b=qM/yA 0oL3452evifamNkLYF88UNn0Tav4zjYR/e2mcVn1pNtMKPz3hWa6c86n2X3AsQwJ N53rRSRNVfkcj0QPUuPT1jyunn1DCW1Z5ptTpnNBxv61cPaE/5cCns/58pWlM/ue EWRxhb91wUGJnZuYhFomybiFBJ7mxHEOrnuXWI= Received: (qmail 109139 invoked by alias); 30 Nov 2018 16:04: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 109039 invoked by uid 89); 30 Nov 2018 16:04:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 25/56] S390: Refactor strncmp ifunc handling. Date: Fri, 30 Nov 2018 16:58:03 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0016-0000-0000-0000022F30B9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0017-0000-0000-000032879BD3 Message-Id: <1543593514-10251-26-git-send-email-stli@linux.ibm.com> The ifunc handling for strncmp is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove strncmp variants. * sysdeps/s390/Makefile (sysdep_routines): Add strncmp variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for strncmp. * sysdeps/s390/multiarch/strncmp-c.c: Move to ... * sysdeps/s390/strncmp-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strncmp-vx.S: Move to ... * sysdeps/s390/strncmp-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strncmp.c: Move to ... * sysdeps/s390/strncmp.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-strncmp.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strncmp.h | 52 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 +++++- sysdeps/s390/{multiarch => }/strncmp-c.c | 18 +++++--- sysdeps/s390/{multiarch => }/strncmp-vx.S | 19 +++++++-- sysdeps/s390/{multiarch => }/strncmp.c | 21 ++++++--- 7 files changed, 110 insertions(+), 20 deletions(-) create mode 100644 sysdeps/s390/ifunc-strncmp.h rename sysdeps/s390/{multiarch => }/strncmp-c.c (78%) rename sysdeps/s390/{multiarch => }/strncmp-vx.S (93%) rename sysdeps/s390/{multiarch => }/strncmp.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 9e7d5625c9..3aaf5a0d40 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -68,5 +68,6 @@ sysdep_routines += bzero memset memset-z900 \ stpncpy stpncpy-vx stpncpy-c \ strcat strcat-vx strcat-c \ strncat strncat-vx strncat-c \ - strcmp strcmp-vx strcmp-z900 + strcmp strcmp-vx strcmp-z900 \ + strncmp strncmp-vx strncmp-c endif diff --git a/sysdeps/s390/ifunc-strncmp.h b/sysdeps/s390/ifunc-strncmp.h new file mode 100644 index 0000000000..511b3e9720 --- /dev/null +++ b/sysdeps/s390/ifunc-strncmp.h @@ -0,0 +1,52 @@ +/* strncmp variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRNCMP_IFUNC 1 +#else +# define HAVE_STRNCMP_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRNCMP_IFUNC_AND_VX_SUPPORT HAVE_STRNCMP_IFUNC +#else +# define HAVE_STRNCMP_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRNCMP_DEFAULT STRNCMP_Z13 +# define HAVE_STRNCMP_C 0 +# define HAVE_STRNCMP_Z13 1 +#else +# define STRNCMP_DEFAULT STRNCMP_C +# define HAVE_STRNCMP_C 1 +# define HAVE_STRNCMP_Z13 HAVE_STRNCMP_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRNCMP_C +# define STRNCMP_C __strncmp_c +#else +# define STRNCMP_C NULL +#endif + +#if HAVE_STRNCMP_Z13 +# define STRNCMP_Z13 __strncmp_vx +#else +# define STRNCMP_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 97421a4996..381376bf9f 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strncmp strncmp-vx strncmp-c \ - strchr strchr-vx strchr-c \ +sysdep_routines += strchr strchr-vx strchr-c \ strchrnul strchrnul-vx strchrnul-c \ strrchr strrchr-vx strrchr-c \ strspn strspn-vx strspn-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 44637c431b..d982de5788 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -35,6 +35,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -281,6 +282,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRCMP_IFUNC */ +#if HAVE_STRNCMP_IFUNC + IFUNC_IMPL (i, name, strncmp, +# if HAVE_STRNCMP_Z13 + IFUNC_IMPL_ADD (array, i, strncmp, + dl_hwcap & HWCAP_S390_VX, STRNCMP_Z13) +# endif +# if HAVE_STRNCMP_C + IFUNC_IMPL_ADD (array, i, strncmp, 1, STRNCMP_C) +# endif + ) +#endif /* HAVE_STRNCMP_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -307,7 +320,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcscmp); - IFUNC_VX_IMPL (strncmp); IFUNC_VX_IMPL (wcsncmp); IFUNC_VX_IMPL (strchr); diff --git a/sysdeps/s390/multiarch/strncmp-c.c b/sysdeps/s390/strncmp-c.c similarity index 78% rename from sysdeps/s390/multiarch/strncmp-c.c rename to sysdeps/s390/strncmp-c.c index e54277ec1b..c7ffdb03e3 100644 --- a/sysdeps/s390/multiarch/strncmp-c.c +++ b/sysdeps/s390/strncmp-c.c @@ -16,13 +16,17 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define STRNCMP __strncmp_c -# ifdef SHARED -# undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) \ +#include + +#if HAVE_STRNCMP_C +# if HAVE_STRNCMP_IFUNC +# define STRNCMP STRNCMP_C +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) \ __hidden_ver1 (__strncmp_c, __GI_strncmp, __strncmp_c); -# endif /* SHARED */ +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/strncmp-vx.S b/sysdeps/s390/strncmp-vx.S similarity index 93% rename from sysdeps/s390/multiarch/strncmp-vx.S rename to sysdeps/s390/strncmp-vx.S index 168fd657da..f557afb336 100644 --- a/sysdeps/s390/multiarch/strncmp-vx.S +++ b/sysdeps/s390/strncmp-vx.S @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRNCMP_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -37,7 +39,7 @@ -v17=part of s2 -v18=index of unequal */ -ENTRY(__strncmp_vx) +ENTRY(STRNCMP_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -133,5 +135,14 @@ ENTRY(__strncmp_vx) .Lend_equal: lghi %r2,0 br %r14 -END(__strncmp_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(STRNCMP_Z13) + +# if ! HAVE_STRNCMP_IFUNC +strong_alias (STRNCMP_Z13, strncmp) +# endif + +# if ! HAVE_STRNCMP_C && defined SHARED && IS_IN (libc) +strong_alias (STRNCMP_Z13, __GI_strncmp) +# endif + +#endif /* HAVE_STRNCMP_Z13 */ diff --git a/sysdeps/s390/multiarch/strncmp.c b/sysdeps/s390/strncmp.c similarity index 70% rename from sysdeps/s390/multiarch/strncmp.c rename to sysdeps/s390/strncmp.c index 0ec472c3b0..71351273c4 100644 --- a/sysdeps/s390/multiarch/strncmp.c +++ b/sysdeps/s390/strncmp.c @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRNCMP_IFUNC # define strncmp __redirect_strncmp /* Omit the strncmp inline definitions because it would redefine strncmp. */ # define __NO_STRING_INLINES @@ -24,8 +26,17 @@ # undef strncmp # include -s390_vx_libc_ifunc2_redirected (__redirect_strncmp, __strncmp, strncmp) +# if HAVE_STRNCMP_C +extern __typeof (__redirect_strncmp) STRNCMP_C attribute_hidden; +# endif + +# if HAVE_STRNCMP_Z13 +extern __typeof (__redirect_strncmp) STRNCMP_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (__redirect_strncmp, strncmp, + (HAVE_STRNCMP_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRNCMP_Z13 + : STRNCMP_DEFAULT + ) +#endif /* HAVE_STRNCMP_IFUNC */ From patchwork Fri Nov 30 15:58:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006047 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-97773-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="XfH8vidi"; 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 435zj52qMcz9s8r for ; Sat, 1 Dec 2018 03:04:09 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=n4vBQqJzzH1/TerkjqbKceWe8N9UOW1 OHW8WDFNaZN5Gt45QOrZ7x7KavBj9R+NOUDk0ZZkXbIQimUSFV6GYN5KMhRSHZtf K6Xo/1YMOWK74BcrGFzYGaKjyCNn5XrKisleOkkxXgh7GRGPukQsvdMZDYegRWTv ncI7TsCwTmTY= 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=oI2gelsUZbo8F3ZP1bcqLyVGnUc=; b=XfH8v idi74AZM7FylA/w9LXNAVKnUwvUAAV+FoezD79RqM8CkF2wDwqusz8olwK7UMud0 4BAa50Sw9mABHP9p+wrnHGnllgWDrTuUWO9gtfd3U+Q4SqrCUpY/hwZXLieL2D9d wFsh5mb0LU9XEdPO3iXDleXc1YxJE4kxGYKgv8= Received: (qmail 58191 invoked by alias); 30 Nov 2018 16:00:57 -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 37690 invoked by uid 89); 30 Nov 2018 16:00:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 26/56] S390: Refactor strchr ifunc handling. Date: Fri, 30 Nov 2018 16:58:04 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-4275-0000-0000-000002E935D6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-4276-0000-0000-000037F67E73 Message-Id: <1543593514-10251-27-git-send-email-stli@linux.ibm.com> The ifunc handling for strchr is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove strchr variants. * sysdeps/s390/Makefile (sysdep_routines): Add strchr variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for strchr. * sysdeps/s390/multiarch/strchr-c.c: Move to ... * sysdeps/s390/strchr-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strchr-vx.S: Move to ... * sysdeps/s390/strchr-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strchr.c: Move to ... * sysdeps/s390/strchr.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-strchr.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strchr.h | 52 ++++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 ++++++- sysdeps/s390/{multiarch => }/strchr-c.c | 20 +++++---- sysdeps/s390/{multiarch => }/strchr-vx.S | 20 +++++++-- sysdeps/s390/{multiarch => }/strchr.c | 23 ++++++++--- 7 files changed, 113 insertions(+), 22 deletions(-) create mode 100644 sysdeps/s390/ifunc-strchr.h rename sysdeps/s390/{multiarch => }/strchr-c.c (77%) rename sysdeps/s390/{multiarch => }/strchr-vx.S (90%) rename sysdeps/s390/{multiarch => }/strchr.c (71%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 3aaf5a0d40..59d6e845db 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -69,5 +69,6 @@ sysdep_routines += bzero memset memset-z900 \ strcat strcat-vx strcat-c \ strncat strncat-vx strncat-c \ strcmp strcmp-vx strcmp-z900 \ - strncmp strncmp-vx strncmp-c + strncmp strncmp-vx strncmp-c \ + strchr strchr-vx strchr-c endif diff --git a/sysdeps/s390/ifunc-strchr.h b/sysdeps/s390/ifunc-strchr.h new file mode 100644 index 0000000000..cfeb00eeda --- /dev/null +++ b/sysdeps/s390/ifunc-strchr.h @@ -0,0 +1,52 @@ +/* strchr variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRCHR_IFUNC 1 +#else +# define HAVE_STRCHR_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRCHR_IFUNC_AND_VX_SUPPORT HAVE_STRCHR_IFUNC +#else +# define HAVE_STRCHR_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRCHR_DEFAULT STRCHR_Z13 +# define HAVE_STRCHR_C 0 +# define HAVE_STRCHR_Z13 1 +#else +# define STRCHR_DEFAULT STRCHR_C +# define HAVE_STRCHR_C 1 +# define HAVE_STRCHR_Z13 HAVE_STRCHR_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRCHR_C +# define STRCHR_C __strchr_c +#else +# define STRCHR_C NULL +#endif + +#if HAVE_STRCHR_Z13 +# define STRCHR_Z13 __strchr_vx +#else +# define STRCHR_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 381376bf9f..a8e9d0acd9 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strchr strchr-vx strchr-c \ - strchrnul strchrnul-vx strchrnul-c \ +sysdep_routines += strchrnul strchrnul-vx strchrnul-c \ strrchr strrchr-vx strrchr-c \ strspn strspn-vx strspn-c \ strpbrk strpbrk-vx strpbrk-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index d982de5788..e809ca3bac 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -36,6 +36,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -294,6 +295,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRNCMP_IFUNC */ +#if HAVE_STRCHR_IFUNC + IFUNC_IMPL (i, name, strchr, +# if HAVE_STRCHR_Z13 + IFUNC_IMPL_ADD (array, i, strchr, + dl_hwcap & HWCAP_S390_VX, STRCHR_Z13) +# endif +# if HAVE_STRCHR_C + IFUNC_IMPL_ADD (array, i, strchr, 1, STRCHR_C) +# endif + ) +#endif /* HAVE_STRCHR_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -322,7 +335,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcsncmp); - IFUNC_VX_IMPL (strchr); IFUNC_VX_IMPL (wcschr); IFUNC_VX_IMPL (strchrnul); diff --git a/sysdeps/s390/multiarch/strchr-c.c b/sysdeps/s390/strchr-c.c similarity index 77% rename from sysdeps/s390/multiarch/strchr-c.c rename to sysdeps/s390/strchr-c.c index 606cb56788..3d3579a1d3 100644 --- a/sysdeps/s390/multiarch/strchr-c.c +++ b/sysdeps/s390/strchr-c.c @@ -16,14 +16,18 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define STRCHR __strchr_c -# undef weak_alias -# ifdef SHARED -# undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) \ +#include + +#if HAVE_STRCHR_C +# if HAVE_STRCHR_IFUNC +# define STRCHR STRCHR_C +# undef weak_alias +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) \ __hidden_ver1 (__strchr_c, __GI_strchr, __strchr_c); -# endif /* SHARED */ +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/strchr-vx.S b/sysdeps/s390/strchr-vx.S similarity index 90% rename from sysdeps/s390/multiarch/strchr-vx.S rename to sysdeps/s390/strchr-vx.S index 6e744fb82f..6ffa06f78c 100644 --- a/sysdeps/s390/multiarch/strchr-vx.S +++ b/sysdeps/s390/strchr-vx.S @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRCHR_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -36,7 +38,7 @@ -v17=index of unequal -v18=replicated c */ -ENTRY(__strchr_vx) +ENTRY(STRCHR_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -96,5 +98,15 @@ ENTRY(__strchr_vx) clije %r3,0,.Lcharacter /* Found zero and c is zero. */ lghi %r2,0 /* Return null if character not found. */ br %r14 -END(__strchr_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(STRCHR_Z13) + +# if ! HAVE_STRCHR_IFUNC +strong_alias (STRCHR_Z13, strchr) +weak_alias (strchr, index) +# endif + +# if ! HAVE_STRCHR_C && defined SHARED && IS_IN (libc) +strong_alias (STRCHR_Z13, __GI_strchr) +# endif + +#endif /* HAVE_STRCHR_Z13 */ diff --git a/sysdeps/s390/multiarch/strchr.c b/sysdeps/s390/strchr.c similarity index 71% rename from sysdeps/s390/multiarch/strchr.c rename to sysdeps/s390/strchr.c index 8aa33a51cc..a106c6106d 100644 --- a/sysdeps/s390/multiarch/strchr.c +++ b/sysdeps/s390/strchr.c @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRCHR_IFUNC # define strchr __redirect_strchr /* Omit the strchr inline definitions because it would redefine strchr. */ # define __NO_STRING_INLINES @@ -24,9 +26,18 @@ # undef strchr # include -s390_vx_libc_ifunc2_redirected (__redirect_strchr, __strchr, strchr) -weak_alias (strchr, index) +# if HAVE_STRCHR_C +extern __typeof (__redirect_strchr) STRCHR_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_STRCHR_Z13 +extern __typeof (__redirect_strchr) STRCHR_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect_strchr, strchr, + (HAVE_STRCHR_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRCHR_Z13 + : STRCHR_DEFAULT + ) +weak_alias (strchr, index) +#endif /* HAVE_STRCHR_IFUNC */ From patchwork Fri Nov 30 15:58:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006058 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-97785-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="SwrIu8kX"; 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 435zlT49z0z9sC7 for ; Sat, 1 Dec 2018 03:06:13 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=eO2HY/kjhaA9+L3n1YFYOKcIjpLtlKf 4FRsPXdLOKk6d5bhq41gViBkHCNzb2d32+7onSxXDAoUa9YB4btROgTk2/HxDKzQ +BPQuIQyJRcaBQAlCcHM6eTIAlpsSabmHqAiUaBu9YvtTMyyazqm/5g1gtOxWKpP Tsx1mKkP1Lrs= 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=B8Dk7IgdGkK6oSJCPy2+ivej28Y=; b=SwrIu 8kX/C02VID7fO1nR/pg3WNtjOXaUljrT0GPJdQkQzd9G4U1Mif5X3Cr3CF1hQt6o 9LdHJr1j3zYa+4UivClgwjcKvWv5dnDKckQu7w/JpzBBFTCTjHj4HSfK/KczkCc5 tFizX6hBTOwY47WPEwnCjJIXYgkv7WOdhVAXfU= Received: (qmail 108020 invoked by alias); 30 Nov 2018 16:03:59 -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 107885 invoked by uid 89); 30 Nov 2018 16:03:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 27/56] S390: Refactor strchrnul ifunc handling. Date: Fri, 30 Nov 2018 16:58:05 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0012-0000-0000-000002D2B617 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0013-0000-0000-00002108046B Message-Id: <1543593514-10251-28-git-send-email-stli@linux.ibm.com> The ifunc handling for strchrnul is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove strchrnul variants. * sysdeps/s390/Makefile (sysdep_routines): Add strchrnul variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for strchrnul. * sysdeps/s390/multiarch/strchrnul-c.c: Move to ... * sysdeps/s390/strchrnul-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strchrnul-vx.S: Move to ... * sysdeps/s390/strchrnul-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strchrnul.c: Move to ... * sysdeps/s390/strchrnul.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-strchrnul.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strchrnul.h | 52 +++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 +++++- sysdeps/s390/{multiarch => }/strchrnul-c.c | 14 ++++-- sysdeps/s390/{multiarch => }/strchrnul-vx.S | 16 +++++-- sysdeps/s390/{multiarch => }/strchrnul.c | 23 ++++++--- 7 files changed, 106 insertions(+), 19 deletions(-) create mode 100644 sysdeps/s390/ifunc-strchrnul.h rename sysdeps/s390/{multiarch => }/strchrnul-c.c (81%) rename sysdeps/s390/{multiarch => }/strchrnul-vx.S (91%) rename sysdeps/s390/{multiarch => }/strchrnul.c (67%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 59d6e845db..07ec5e969f 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -70,5 +70,6 @@ sysdep_routines += bzero memset memset-z900 \ strncat strncat-vx strncat-c \ strcmp strcmp-vx strcmp-z900 \ strncmp strncmp-vx strncmp-c \ - strchr strchr-vx strchr-c + strchr strchr-vx strchr-c \ + strchrnul strchrnul-vx strchrnul-c endif diff --git a/sysdeps/s390/ifunc-strchrnul.h b/sysdeps/s390/ifunc-strchrnul.h new file mode 100644 index 0000000000..cac817e6f0 --- /dev/null +++ b/sysdeps/s390/ifunc-strchrnul.h @@ -0,0 +1,52 @@ +/* strchrnul variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRCHRNUL_IFUNC 1 +#else +# define HAVE_STRCHRNUL_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRCHRNUL_IFUNC_AND_VX_SUPPORT HAVE_STRCHRNUL_IFUNC +#else +# define HAVE_STRCHRNUL_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRCHRNUL_DEFAULT STRCHRNUL_Z13 +# define HAVE_STRCHRNUL_C 0 +# define HAVE_STRCHRNUL_Z13 1 +#else +# define STRCHRNUL_DEFAULT STRCHRNUL_C +# define HAVE_STRCHRNUL_C 1 +# define HAVE_STRCHRNUL_Z13 HAVE_STRCHRNUL_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRCHRNUL_C +# define STRCHRNUL_C __strchrnul_c +#else +# define STRCHRNUL_C NULL +#endif + +#if HAVE_STRCHRNUL_Z13 +# define STRCHRNUL_Z13 __strchrnul_vx +#else +# define STRCHRNUL_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index a8e9d0acd9..999a979fee 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strchrnul strchrnul-vx strchrnul-c \ - strrchr strrchr-vx strrchr-c \ +sysdep_routines += strrchr strrchr-vx strrchr-c \ strspn strspn-vx strspn-c \ strpbrk strpbrk-vx strpbrk-c \ strcspn strcspn-vx strcspn-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index e809ca3bac..0a47ffeac3 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -37,6 +37,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -307,6 +308,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRCHR_IFUNC */ +#if HAVE_STRCHRNUL_IFUNC + IFUNC_IMPL (i, name, strchrnul, +# if HAVE_STRCHRNUL_Z13 + IFUNC_IMPL_ADD (array, i, strchrnul, + dl_hwcap & HWCAP_S390_VX, STRCHRNUL_Z13) +# endif +# if HAVE_STRCHRNUL_C + IFUNC_IMPL_ADD (array, i, strchrnul, 1, STRCHRNUL_C) +# endif + ) +#endif /* HAVE_STRCHRNUL_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -337,7 +350,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcschr); - IFUNC_VX_IMPL (strchrnul); IFUNC_VX_IMPL (wcschrnul); IFUNC_VX_IMPL (strrchr); diff --git a/sysdeps/s390/multiarch/strchrnul-c.c b/sysdeps/s390/strchrnul-c.c similarity index 81% rename from sysdeps/s390/multiarch/strchrnul-c.c rename to sysdeps/s390/strchrnul-c.c index 020cebcf3e..585273f5de 100644 --- a/sysdeps/s390/multiarch/strchrnul-c.c +++ b/sysdeps/s390/strchrnul-c.c @@ -16,11 +16,15 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define STRCHRNUL __strchrnul_c -# define __strchrnul STRCHRNUL -# undef weak_alias -# define weak_alias(name, alias) +#include + +#if HAVE_STRCHRNUL_C +# if HAVE_STRCHRNUL_IFUNC +# define STRCHRNUL STRCHRNUL_C +# define __strchrnul STRCHRNUL +# undef weak_alias +# define weak_alias(name, alias) +# endif # include #endif diff --git a/sysdeps/s390/multiarch/strchrnul-vx.S b/sysdeps/s390/strchrnul-vx.S similarity index 91% rename from sysdeps/s390/multiarch/strchrnul-vx.S rename to sysdeps/s390/strchrnul-vx.S index d561825e04..0cd587bc32 100644 --- a/sysdeps/s390/multiarch/strchrnul-vx.S +++ b/sysdeps/s390/strchrnul-vx.S @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRCHRNUL_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -35,7 +37,7 @@ -v16=part of s -v18=vector with c replicated in every byte */ -ENTRY(__strchrnul_vx) +ENTRY(STRCHRNUL_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -89,5 +91,11 @@ ENTRY(__strchrnul_vx) .Lend: br %r14 -END(__strchrnul_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(STRCHRNUL_Z13) + +# if ! HAVE_STRCHRNUL_IFUNC +strong_alias (STRCHRNUL_Z13, __strchrnul) +weak_alias (__strchrnul, strchrnul) +# endif + +#endif /* HAVE_STRCHRNUL_Z13 */ diff --git a/sysdeps/s390/multiarch/strchrnul.c b/sysdeps/s390/strchrnul.c similarity index 67% rename from sysdeps/s390/multiarch/strchrnul.c rename to sysdeps/s390/strchrnul.c index 62dfc6bd90..e9fefe1bdc 100644 --- a/sysdeps/s390/multiarch/strchrnul.c +++ b/sysdeps/s390/strchrnul.c @@ -16,13 +16,24 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRCHRNUL_IFUNC # include # include -s390_vx_libc_ifunc (__strchrnul) -weak_alias (__strchrnul, strchrnul) +# if HAVE_STRCHRNUL_C +extern __typeof (__strchrnul) STRCHRNUL_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_STRCHRNUL_Z13 +extern __typeof (__strchrnul) STRCHRNUL_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__strchrnul, __strchrnul, + (HAVE_STRCHRNUL_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRCHRNUL_Z13 + : STRCHRNUL_DEFAULT + ) +weak_alias (__strchrnul, strchrnul) +#endif /* HAVE_STRCHRNUL_IFUNC */ From patchwork Fri Nov 30 15:58:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006055 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-97782-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="CPXGyTlQ"; 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 435zkn5vkSz9s8r for ; Sat, 1 Dec 2018 03:05:37 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=qmz7McknCMH/PMuFQOqyeI+Y6LIkrGP 1bcowBIGdx6RSaAkaq3gZw30eWNW+b8K6IbmVCsngt4hDU1xF7SP9JxpTCP8SFSB Rs/Up6NZTou2DLPQ6YtT1YFTmscG0c9FIf5y085UudUvesU/ZwSktVcwJUzq5+/T Di+y3WiW/qfE= 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=q8giBnp4sxVa2WB3/UKE2mSeY34=; b=CPXGy TlQoDIhsBWx/EwgC7BgqysDZKySw03QkpRvr7mULCEMflIwoTYOv+DBNQIeDj3Hh 9LJjBu8AV7xhpD0wvjxIkHVfsDNYqA9RnEKPk+YHCWAlEgruJiN0Ux77DhRF4egB HRXEbvGiBu4wAiO15lmT0VMJR8/+cURqOe2CpE= Received: (qmail 96848 invoked by alias); 30 Nov 2018 16:02:35 -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 96691 invoked by uid 89); 30 Nov 2018 16:02:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 28/56] S390: Refactor strrchr ifunc handling. Date: Fri, 30 Nov 2018 16:58:06 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0028-0000-0000-00000323FCB0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0029-0000-0000-000023E0125D Message-Id: <1543593514-10251-29-git-send-email-stli@linux.ibm.com> The ifunc handling for strrchr is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove strrchr variants. * sysdeps/s390/Makefile (sysdep_routines): Add strrchr variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for strrchr. * sysdeps/s390/multiarch/strrchr-c.c: Move to ... * sysdeps/s390/strrchr-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strrchr-vx.S: Move to ... * sysdeps/s390/strrchr-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strrchr.c: Move to ... * sysdeps/s390/strrchr.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-strrchr.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strrchr.h | 52 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 +++++- sysdeps/s390/{multiarch => }/strrchr-c.c | 20 +++++---- sysdeps/s390/{multiarch => }/strrchr-vx.S | 20 +++++++-- sysdeps/s390/{multiarch => }/strrchr.c | 23 +++++++--- 7 files changed, 113 insertions(+), 22 deletions(-) create mode 100644 sysdeps/s390/ifunc-strrchr.h rename sysdeps/s390/{multiarch => }/strrchr-c.c (77%) rename sysdeps/s390/{multiarch => }/strrchr-vx.S (94%) rename sysdeps/s390/{multiarch => }/strrchr.c (66%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 07ec5e969f..c423c80a43 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -71,5 +71,6 @@ sysdep_routines += bzero memset memset-z900 \ strcmp strcmp-vx strcmp-z900 \ strncmp strncmp-vx strncmp-c \ strchr strchr-vx strchr-c \ - strchrnul strchrnul-vx strchrnul-c + strchrnul strchrnul-vx strchrnul-c \ + strrchr strrchr-vx strrchr-c endif diff --git a/sysdeps/s390/ifunc-strrchr.h b/sysdeps/s390/ifunc-strrchr.h new file mode 100644 index 0000000000..7185fc3260 --- /dev/null +++ b/sysdeps/s390/ifunc-strrchr.h @@ -0,0 +1,52 @@ +/* strrchr variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRRCHR_IFUNC 1 +#else +# define HAVE_STRRCHR_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRRCHR_IFUNC_AND_VX_SUPPORT HAVE_STRRCHR_IFUNC +#else +# define HAVE_STRRCHR_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRRCHR_DEFAULT STRRCHR_Z13 +# define HAVE_STRRCHR_C 0 +# define HAVE_STRRCHR_Z13 1 +#else +# define STRRCHR_DEFAULT STRRCHR_C +# define HAVE_STRRCHR_C 1 +# define HAVE_STRRCHR_Z13 HAVE_STRRCHR_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRRCHR_C +# define STRRCHR_C __strrchr_c +#else +# define STRRCHR_C NULL +#endif + +#if HAVE_STRRCHR_Z13 +# define STRRCHR_Z13 __strrchr_vx +#else +# define STRRCHR_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 999a979fee..c826755558 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strrchr strrchr-vx strrchr-c \ - strspn strspn-vx strspn-c \ +sysdep_routines += strspn strspn-vx strspn-c \ strpbrk strpbrk-vx strpbrk-c \ strcspn strcspn-vx strcspn-c \ memchr memchr-vx \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 0a47ffeac3..60cd705ffa 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -38,6 +38,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -320,6 +321,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRCHRNUL_IFUNC */ +#if HAVE_STRRCHR_IFUNC + IFUNC_IMPL (i, name, strrchr, +# if HAVE_STRRCHR_Z13 + IFUNC_IMPL_ADD (array, i, strrchr, + dl_hwcap & HWCAP_S390_VX, STRRCHR_Z13) +# endif +# if HAVE_STRRCHR_C + IFUNC_IMPL_ADD (array, i, strrchr, 1, STRRCHR_C) +# endif + ) +#endif /* HAVE_STRRCHR_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -352,7 +365,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcschrnul); - IFUNC_VX_IMPL (strrchr); IFUNC_VX_IMPL (wcsrchr); IFUNC_VX_IMPL (strspn); diff --git a/sysdeps/s390/multiarch/strrchr-c.c b/sysdeps/s390/strrchr-c.c similarity index 77% rename from sysdeps/s390/multiarch/strrchr-c.c rename to sysdeps/s390/strrchr-c.c index 53ceb8086f..615f16da7d 100644 --- a/sysdeps/s390/multiarch/strrchr-c.c +++ b/sysdeps/s390/strrchr-c.c @@ -16,14 +16,18 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define STRRCHR __strrchr_c -# undef weak_alias -# ifdef SHARED -# undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) \ +#include + +#if HAVE_STRRCHR_C +# if HAVE_STRRCHR_IFUNC +# define STRRCHR STRRCHR_C +# undef weak_alias +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) \ __hidden_ver1 (__strrchr_c, __GI_strrchr, __strrchr_c); -# endif /* SHARED */ +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/strrchr-vx.S b/sysdeps/s390/strrchr-vx.S similarity index 94% rename from sysdeps/s390/multiarch/strrchr-vx.S rename to sysdeps/s390/strrchr-vx.S index 8b3b989631..5f4ac14ee3 100644 --- a/sysdeps/s390/multiarch/strrchr-vx.S +++ b/sysdeps/s390/strrchr-vx.S @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRRCHR_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -39,7 +41,7 @@ -v19=part of s with last occurence of c. -v20=permute pattern */ -ENTRY(__strrchr_vx) +ENTRY(STRRCHR_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -176,5 +178,15 @@ ENTRY(__strrchr_vx) .Lpermute_mask: .byte 0x0F,0x0E,0x0D,0x0C,0x0B,0x0A,0x09,0x08 .byte 0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00 -END(__strrchr_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(STRRCHR_Z13) + +# if ! HAVE_STRRCHR_IFUNC +strong_alias (STRRCHR_Z13, strrchr) +weak_alias (strrchr, rindex) +# endif + +# if ! HAVE_STRRCHR_C && defined SHARED && IS_IN (libc) +strong_alias (STRRCHR_Z13, __GI_strrchr) +# endif + +#endif /* HAVE_STRRCHR_Z13 */ diff --git a/sysdeps/s390/multiarch/strrchr.c b/sysdeps/s390/strrchr.c similarity index 66% rename from sysdeps/s390/multiarch/strrchr.c rename to sysdeps/s390/strrchr.c index e00e25a3a4..9a8cecff0b 100644 --- a/sysdeps/s390/multiarch/strrchr.c +++ b/sysdeps/s390/strrchr.c @@ -16,15 +16,26 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRRCHR_IFUNC # define strrchr __redirect_strrchr # include # undef strrchr # include -s390_vx_libc_ifunc2_redirected (__redirect_strrchr, __strrchr, strrchr) -weak_alias (strrchr, rindex); +# if HAVE_STRRCHR_C +extern __typeof (__redirect_strrchr) STRRCHR_C attribute_hidden; +# endif + +# if HAVE_STRRCHR_Z13 +extern __typeof (__redirect_strrchr) STRRCHR_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (__redirect_strrchr, strrchr, + (HAVE_STRRCHR_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRRCHR_Z13 + : STRRCHR_DEFAULT + ) +weak_alias (strrchr, rindex) +#endif /* HAVE_STRRCHR_IFUNC */ From patchwork Fri Nov 30 15:58:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006114 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-97809-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="wOpxg3Dw"; 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 4361xY6tRPz9s89 for ; Sat, 1 Dec 2018 04:45:05 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=aLptUKQOYZvjP0AMs1x+22Halyt/U0d /DLf9vMIMoFA1M3toLZlwBlR1l5sxJPIUkFjxCTipr/VIo0FagcvPxbl8EXNb9KG 3Sf9ktWVJ4DFgmKB1fiuQ3YUqLZFSI44Zljwi0ggdyxTuwF9M1P1uhbe0PAAJLoS X9fkmgPPQufE= 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=Cu5s/LlR191ngHdaF/zUAUSl3dc=; b=wOpxg 3DwOsTdw8c5eTNOov59LDIgS3uz/RA5YShmyu1JOVwhZebyYhWfsTTz8VySgQe6E 133WKRnu6qMMr52O6nWq/kO/7oUCeVft/KCY9gd+v4RXa1ba//1TDVHYHH9Z4ybJ KbTnZxXokgu7xW3CsC7USZLYnvP3Zxa9ndmYbo= Received: (qmail 116680 invoked by alias); 30 Nov 2018 17:44:59 -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 116636 invoked by uid 89); 30 Nov 2018 17:44:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 29/56] S390: Refactor strspn ifunc handling. Date: Fri, 30 Nov 2018 16:58:07 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-4275-0000-0000-000002E935D8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-4276-0000-0000-000037F67E75 Message-Id: <1543593514-10251-30-git-send-email-stli@linux.ibm.com> The ifunc handling for strspn is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove strspn variants. * sysdeps/s390/Makefile (sysdep_routines): Add strspn variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for strspn. * sysdeps/s390/multiarch/strspn-c.c: Move to ... * sysdeps/s390/strspn-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strspn-vx.S: Move to ... * sysdeps/s390/strspn-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strspn.c: Move to ... * sysdeps/s390/strspn.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-strspn.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strspn.h | 52 ++++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 ++++++- sysdeps/s390/{multiarch => }/strspn-c.c | 18 ++++---- sysdeps/s390/{multiarch => }/strspn-vx.S | 19 +++++++-- sysdeps/s390/{multiarch => }/strspn.c | 21 +++++++--- 7 files changed, 110 insertions(+), 20 deletions(-) create mode 100644 sysdeps/s390/ifunc-strspn.h rename sysdeps/s390/{multiarch => }/strspn-c.c (78%) rename sysdeps/s390/{multiarch => }/strspn-vx.S (97%) rename sysdeps/s390/{multiarch => }/strspn.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index c423c80a43..604ca68ef1 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -72,5 +72,6 @@ sysdep_routines += bzero memset memset-z900 \ strncmp strncmp-vx strncmp-c \ strchr strchr-vx strchr-c \ strchrnul strchrnul-vx strchrnul-c \ - strrchr strrchr-vx strrchr-c + strrchr strrchr-vx strrchr-c \ + strspn strspn-vx strspn-c endif diff --git a/sysdeps/s390/ifunc-strspn.h b/sysdeps/s390/ifunc-strspn.h new file mode 100644 index 0000000000..1152ba1f3d --- /dev/null +++ b/sysdeps/s390/ifunc-strspn.h @@ -0,0 +1,52 @@ +/* strspn variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRSPN_IFUNC 1 +#else +# define HAVE_STRSPN_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRSPN_IFUNC_AND_VX_SUPPORT HAVE_STRSPN_IFUNC +#else +# define HAVE_STRSPN_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRSPN_DEFAULT STRSPN_Z13 +# define HAVE_STRSPN_C 0 +# define HAVE_STRSPN_Z13 1 +#else +# define STRSPN_DEFAULT STRSPN_C +# define HAVE_STRSPN_C 1 +# define HAVE_STRSPN_Z13 HAVE_STRSPN_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRSPN_C +# define STRSPN_C __strspn_c +#else +# define STRSPN_C NULL +#endif + +#if HAVE_STRSPN_Z13 +# define STRSPN_Z13 __strspn_vx +#else +# define STRSPN_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index c826755558..9b141e338c 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strspn strspn-vx strspn-c \ - strpbrk strpbrk-vx strpbrk-c \ +sysdep_routines += strpbrk strpbrk-vx strpbrk-c \ strcspn strcspn-vx strcspn-c \ memchr memchr-vx \ rawmemchr rawmemchr-vx rawmemchr-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 60cd705ffa..c39e1f793a 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -39,6 +39,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -333,6 +334,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRRCHR_IFUNC */ +#if HAVE_STRSPN_IFUNC + IFUNC_IMPL (i, name, strspn, +# if HAVE_STRSPN_Z13 + IFUNC_IMPL_ADD (array, i, strspn, + dl_hwcap & HWCAP_S390_VX, STRSPN_Z13) +# endif +# if HAVE_STRSPN_C + IFUNC_IMPL_ADD (array, i, strspn, 1, STRSPN_C) +# endif + ) +#endif /* HAVE_STRSPN_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -367,7 +380,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcsrchr); - IFUNC_VX_IMPL (strspn); IFUNC_VX_IMPL (wcsspn); IFUNC_VX_IMPL (strpbrk); diff --git a/sysdeps/s390/multiarch/strspn-c.c b/sysdeps/s390/strspn-c.c similarity index 78% rename from sysdeps/s390/multiarch/strspn-c.c rename to sysdeps/s390/strspn-c.c index 0efe61bfb2..506f668321 100644 --- a/sysdeps/s390/multiarch/strspn-c.c +++ b/sysdeps/s390/strspn-c.c @@ -16,13 +16,17 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define STRSPN __strspn_c -# ifdef SHARED -# undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) \ +#include + +#if HAVE_STRSPN_C +# if HAVE_STRSPN_IFUNC +# define STRSPN STRSPN_C +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) \ __hidden_ver1 (__strspn_c, __GI_strspn, __strspn_c); -# endif /* SHARED */ +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/strspn-vx.S b/sysdeps/s390/strspn-vx.S similarity index 97% rename from sysdeps/s390/multiarch/strspn-vx.S rename to sysdeps/s390/strspn-vx.S index 6aa823e63b..ae5529b567 100644 --- a/sysdeps/s390/multiarch/strspn-vx.S +++ b/sysdeps/s390/strspn-vx.S @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRSPN_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -57,7 +59,7 @@ otherwise =0; r9: loaded byte count of vlbb accept-string */ -ENTRY(__strspn_vx) +ENTRY(STRSPN_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -252,5 +254,14 @@ ENTRY(__strspn_vx) Check for zero is in jump-target. */ j .Lslow_next_acc_notonbb /* ... and search for zero in fully loaded vreg again. */ -END(__strspn_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(STRSPN_Z13) + +# if ! HAVE_STRSPN_IFUNC +strong_alias (STRSPN_Z13, strspn) +# endif + +# if ! HAVE_STRSPN_C && defined SHARED && IS_IN (libc) +strong_alias (STRSPN_Z13, __GI_strspn) +# endif + +#endif /* HAVE_STRSPN_Z13 */ diff --git a/sysdeps/s390/multiarch/strspn.c b/sysdeps/s390/strspn.c similarity index 70% rename from sysdeps/s390/multiarch/strspn.c rename to sysdeps/s390/strspn.c index bedbe98cfc..91401fdaf8 100644 --- a/sysdeps/s390/multiarch/strspn.c +++ b/sysdeps/s390/strspn.c @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRSPN_IFUNC # define strspn __redirect_strspn /* Omit the strspn inline definitions because it would redefine strspn. */ # define __NO_STRING_INLINES @@ -24,8 +26,17 @@ # undef strspn # include -s390_vx_libc_ifunc2_redirected (__redirect_strspn, __strspn, strspn) +# if HAVE_STRSPN_C +extern __typeof (__redirect_strspn) STRSPN_C attribute_hidden; +# endif + +# if HAVE_STRSPN_Z13 +extern __typeof (__redirect_strspn) STRSPN_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (__redirect_strspn, strspn, + (HAVE_STRSPN_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRSPN_Z13 + : STRSPN_DEFAULT + ) +#endif /* HAVE_STRSPN_IFUNC */ From patchwork Fri Nov 30 15:58:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006051 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-97779-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="CTT756jd"; 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 435zk94Szzz9s8r for ; Sat, 1 Dec 2018 03:05:05 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=suE1UwBPKsITp4h/jLpzU3Lt3ElbpFH AY0Qw2Zgr0GXIB180Yt+dDUXcVrx2esplnDPXOV3p7mghlfdPfUREbVkIo4Ptv5P R9GaGpmsxXck05SVVajsCu3zq/P2i/L/taxVkXDdlI28IJSOedB1EPSCgqQpMuZy ys0s4QYX4Bkk= 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=eZS1J2dMgVGsICvRSNxt7SpiyGs=; b=CTT75 6jdkZbeYU+GDEQX7uhsO19apUj1yviGw/jhc2HtznDV/0qfMzIwQ/9szkXHy3JgG FjmMEYg1nSE45O/73hme8irSFz1CjQm6qZp0vc9U3lW2XAAY8RFhS/6KopZxSJqk KpBoUq7Af6ZgV/rujTGLIGsaAOwxJ8jelCP9zE= Received: (qmail 95392 invoked by alias); 30 Nov 2018 16:02:23 -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 95268 invoked by uid 89); 30 Nov 2018 16:02:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 30/56] S390: Refactor strpbrk ifunc handling. Date: Fri, 30 Nov 2018 16:58:08 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0028-0000-0000-00000323FCB1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0029-0000-0000-000023E0125F Message-Id: <1543593514-10251-31-git-send-email-stli@linux.ibm.com> The ifunc handling for strpbrk is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove strpbrk variants. * sysdeps/s390/Makefile (sysdep_routines): Add strpbrk variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for strpbrk. * sysdeps/s390/multiarch/strpbrk-c.c: Move to ... * sysdeps/s390/strpbrk-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strpbrk-vx.S: Move to ... * sysdeps/s390/strpbrk-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strpbrk.c: Move to ... * sysdeps/s390/strpbrk.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-strpbrk.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strpbrk.h | 52 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 +++++- sysdeps/s390/{multiarch => }/strpbrk-c.c | 20 +++++---- sysdeps/s390/{multiarch => }/strpbrk-vx.S | 19 +++++++-- sysdeps/s390/{multiarch => }/strpbrk.c | 21 ++++++--- 7 files changed, 111 insertions(+), 21 deletions(-) create mode 100644 sysdeps/s390/ifunc-strpbrk.h rename sysdeps/s390/{multiarch => }/strpbrk-c.c (73%) rename sysdeps/s390/{multiarch => }/strpbrk-vx.S (97%) rename sysdeps/s390/{multiarch => }/strpbrk.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 604ca68ef1..df1f858e28 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -73,5 +73,6 @@ sysdep_routines += bzero memset memset-z900 \ strchr strchr-vx strchr-c \ strchrnul strchrnul-vx strchrnul-c \ strrchr strrchr-vx strrchr-c \ - strspn strspn-vx strspn-c + strspn strspn-vx strspn-c \ + strpbrk strpbrk-vx strpbrk-c endif diff --git a/sysdeps/s390/ifunc-strpbrk.h b/sysdeps/s390/ifunc-strpbrk.h new file mode 100644 index 0000000000..4a3138c6bf --- /dev/null +++ b/sysdeps/s390/ifunc-strpbrk.h @@ -0,0 +1,52 @@ +/* strpbrk variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRPBRK_IFUNC 1 +#else +# define HAVE_STRPBRK_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRPBRK_IFUNC_AND_VX_SUPPORT HAVE_STRPBRK_IFUNC +#else +# define HAVE_STRPBRK_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRPBRK_DEFAULT STRPBRK_Z13 +# define HAVE_STRPBRK_C 0 +# define HAVE_STRPBRK_Z13 1 +#else +# define STRPBRK_DEFAULT STRPBRK_C +# define HAVE_STRPBRK_C 1 +# define HAVE_STRPBRK_Z13 HAVE_STRPBRK_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRPBRK_C +# define STRPBRK_C __strpbrk_c +#else +# define STRPBRK_C NULL +#endif + +#if HAVE_STRPBRK_Z13 +# define STRPBRK_Z13 __strpbrk_vx +#else +# define STRPBRK_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 9b141e338c..1a3fed9fc8 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strpbrk strpbrk-vx strpbrk-c \ - strcspn strcspn-vx strcspn-c \ +sysdep_routines += strcspn strcspn-vx strcspn-c \ memchr memchr-vx \ rawmemchr rawmemchr-vx rawmemchr-c \ memccpy memccpy-vx memccpy-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index c39e1f793a..8e23416730 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -40,6 +40,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -346,6 +347,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRSPN_IFUNC */ +#if HAVE_STRPBRK_IFUNC + IFUNC_IMPL (i, name, strpbrk, +# if HAVE_STRPBRK_Z13 + IFUNC_IMPL_ADD (array, i, strpbrk, + dl_hwcap & HWCAP_S390_VX, STRPBRK_Z13) +# endif +# if HAVE_STRPBRK_C + IFUNC_IMPL_ADD (array, i, strpbrk, 1, STRPBRK_C) +# endif + ) +#endif /* HAVE_STRPBRK_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -382,7 +395,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcsspn); - IFUNC_VX_IMPL (strpbrk); IFUNC_VX_IMPL (wcspbrk); IFUNC_VX_IMPL (strcspn); diff --git a/sysdeps/s390/multiarch/strpbrk-c.c b/sysdeps/s390/strpbrk-c.c similarity index 73% rename from sysdeps/s390/multiarch/strpbrk-c.c rename to sysdeps/s390/strpbrk-c.c index 2c0517aeb5..70cc5db672 100644 --- a/sysdeps/s390/multiarch/strpbrk-c.c +++ b/sysdeps/s390/strpbrk-c.c @@ -16,13 +16,17 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define STRPBRK __strpbrk_c -# ifdef SHARED -# undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) \ - __hidden_ver1 (__strpbrk_c, __GI_strpbrk, __strpbrk_c); -# endif /* SHARED */ +#include + +#if HAVE_STRPBRK_C +# if HAVE_STRPBRK_IFUNC +# define STRPBRK STRPBRK_C +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) \ + __hidden_ver1 (__strpbrk_c, __GI_strpbrk, __strpbrk_c); +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/strpbrk-vx.S b/sysdeps/s390/strpbrk-vx.S similarity index 97% rename from sysdeps/s390/multiarch/strpbrk-vx.S rename to sysdeps/s390/strpbrk-vx.S index e19c550ed4..0fc7dc1433 100644 --- a/sysdeps/s390/multiarch/strpbrk-vx.S +++ b/sysdeps/s390/strpbrk-vx.S @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRPBRK_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -59,7 +61,7 @@ otherwise =0; r9: loaded byte count of vlbb accept-string */ -ENTRY(__strpbrk_vx) +ENTRY(STRPBRK_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -298,5 +300,14 @@ ENTRY(__strpbrk_vx) vlgvg %r9,%v31,1 lgr %r2,%r1 br %r14 -END(__strpbrk_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(STRPBRK_Z13) + +# if ! HAVE_STRPBRK_IFUNC +strong_alias (STRPBRK_Z13, strpbrk) +# endif + +# if ! HAVE_STRPBRK_C && defined SHARED && IS_IN (libc) +strong_alias (STRPBRK_Z13, __GI_strpbrk) +# endif + +#endif /* HAVE_STRPBRK_Z13 */ diff --git a/sysdeps/s390/multiarch/strpbrk.c b/sysdeps/s390/strpbrk.c similarity index 70% rename from sysdeps/s390/multiarch/strpbrk.c rename to sysdeps/s390/strpbrk.c index 11afc268f7..41ce00a1ae 100644 --- a/sysdeps/s390/multiarch/strpbrk.c +++ b/sysdeps/s390/strpbrk.c @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRPBRK_IFUNC # define strpbrk __redirect_strpbrk /* Omit the strpbrk inline definitions because it would redefine strpbrk. */ # define __NO_STRING_INLINES @@ -24,8 +26,17 @@ # undef strpbrk # include -s390_vx_libc_ifunc2_redirected (__redirect_strpbrk, __strpbrk, strpbrk) +# if HAVE_STRPBRK_C +extern __typeof (__redirect_strpbrk) STRPBRK_C attribute_hidden; +# endif + +# if HAVE_STRPBRK_Z13 +extern __typeof (__redirect_strpbrk) STRPBRK_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (__redirect_strpbrk, strpbrk, + (HAVE_STRPBRK_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRPBRK_Z13 + : STRPBRK_DEFAULT + ) +#endif /* HAVE_STRPBRK_IFUNC */ From patchwork Fri Nov 30 15:58:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006070 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-97797-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="QHsp2v7z"; 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 435znz0fkjz9s8r for ; Sat, 1 Dec 2018 03:08:22 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=QdrQMSqh+Bnq8vGtP3fRf9UuxWbGoa4 PNrZ+0me1hHZESTMNpIgG8j1CctK08Gr18UNXAF0dHqmvZFUD49RIdiPbulzNv37 bYiaabUsMedJUmD2pEJjuqToZG6bbpPxmg7PzNCQL3YoiwvZAb/30zr6TBFdCNh+ FjyHMe2vnhqY= 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=hwFzJo/Ox8rpHAMzJAZfV6YXDi0=; b=QHsp2 v7zlBG/lNc7arT8yGFminq+EatnaEZcC3K8nTeN3E+OJmEb2UAhyOdkGI7DTFkPQ YQ9FPUzzXRGPqHcDcN9TCblHlATWBgxd2yxBDvQyK7XsMT9QNopa/8uWf0Y5uwyz UlrHCYLClivAIQi8WEQI+T6sRjiVjWz95/ZDPE= Received: (qmail 113272 invoked by alias); 30 Nov 2018 16:04: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 113144 invoked by uid 89); 30 Nov 2018 16:04:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 31/56] S390: Refactor strcspn ifunc handling. Date: Fri, 30 Nov 2018 16:58:09 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0028-0000-0000-00000323FCB3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0029-0000-0000-000023E01260 Message-Id: <1543593514-10251-32-git-send-email-stli@linux.ibm.com> The ifunc handling for strcspn is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove strcspn variants. * sysdeps/s390/Makefile (sysdep_routines): Add strcspn variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for strcspn. * sysdeps/s390/multiarch/strcspn-c.c: Move to ... * sysdeps/s390/strcspn-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strcspn-vx.S: Move to ... * sysdeps/s390/strcspn-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/strcspn.c: Move to ... * sysdeps/s390/strcspn.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-strcspn.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-strcspn.h | 52 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 +++++- sysdeps/s390/{multiarch => }/strcspn-c.c | 20 +++++---- sysdeps/s390/{multiarch => }/strcspn-vx.S | 19 +++++++-- sysdeps/s390/{multiarch => }/strcspn.c | 21 ++++++--- 7 files changed, 111 insertions(+), 21 deletions(-) create mode 100644 sysdeps/s390/ifunc-strcspn.h rename sysdeps/s390/{multiarch => }/strcspn-c.c (73%) rename sysdeps/s390/{multiarch => }/strcspn-vx.S (97%) rename sysdeps/s390/{multiarch => }/strcspn.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index df1f858e28..c163969652 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -74,5 +74,6 @@ sysdep_routines += bzero memset memset-z900 \ strchrnul strchrnul-vx strchrnul-c \ strrchr strrchr-vx strrchr-c \ strspn strspn-vx strspn-c \ - strpbrk strpbrk-vx strpbrk-c + strpbrk strpbrk-vx strpbrk-c \ + strcspn strcspn-vx strcspn-c endif diff --git a/sysdeps/s390/ifunc-strcspn.h b/sysdeps/s390/ifunc-strcspn.h new file mode 100644 index 0000000000..9b7032509a --- /dev/null +++ b/sysdeps/s390/ifunc-strcspn.h @@ -0,0 +1,52 @@ +/* strcspn variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_STRCSPN_IFUNC 1 +#else +# define HAVE_STRCSPN_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_STRCSPN_IFUNC_AND_VX_SUPPORT HAVE_STRCSPN_IFUNC +#else +# define HAVE_STRCSPN_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define STRCSPN_DEFAULT STRCSPN_Z13 +# define HAVE_STRCSPN_C 0 +# define HAVE_STRCSPN_Z13 1 +#else +# define STRCSPN_DEFAULT STRCSPN_C +# define HAVE_STRCSPN_C 1 +# define HAVE_STRCSPN_Z13 HAVE_STRCSPN_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_STRCSPN_C +# define STRCSPN_C __strcspn_c +#else +# define STRCSPN_C NULL +#endif + +#if HAVE_STRCSPN_Z13 +# define STRCSPN_Z13 __strcspn_vx +#else +# define STRCSPN_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 1a3fed9fc8..1578f21af4 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += strcspn strcspn-vx strcspn-c \ - memchr memchr-vx \ +sysdep_routines += memchr memchr-vx \ rawmemchr rawmemchr-vx rawmemchr-c \ memccpy memccpy-vx memccpy-c \ memrchr memrchr-vx memrchr-c diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 8e23416730..2d48c99c8d 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -41,6 +41,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -359,6 +360,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRPBRK_IFUNC */ +#if HAVE_STRCSPN_IFUNC + IFUNC_IMPL (i, name, strcspn, +# if HAVE_STRCSPN_Z13 + IFUNC_IMPL_ADD (array, i, strcspn, + dl_hwcap & HWCAP_S390_VX, STRCSPN_Z13) +# endif +# if HAVE_STRCSPN_C + IFUNC_IMPL_ADD (array, i, strcspn, 1, STRCSPN_C) +# endif + ) +#endif /* HAVE_STRCSPN_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -397,7 +410,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcspbrk); - IFUNC_VX_IMPL (strcspn); IFUNC_VX_IMPL (wcscspn); IFUNC_VX_IMPL (memchr); diff --git a/sysdeps/s390/multiarch/strcspn-c.c b/sysdeps/s390/strcspn-c.c similarity index 73% rename from sysdeps/s390/multiarch/strcspn-c.c rename to sysdeps/s390/strcspn-c.c index 7b454f5b56..9f51f92bdb 100644 --- a/sysdeps/s390/multiarch/strcspn-c.c +++ b/sysdeps/s390/strcspn-c.c @@ -16,13 +16,17 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define STRCSPN __strcspn_c -# ifdef SHARED -# undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) \ - __hidden_ver1 (__strcspn_c, __GI_strcspn, __strcspn_c); -# endif /* SHARED */ +#include + +#if HAVE_STRCSPN_C +# if HAVE_STRCSPN_IFUNC +# define STRCSPN STRCSPN_C +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_builtin_def +# define libc_hidden_builtin_def(name) \ + __hidden_ver1 (__strcspn_c, __GI_strcspn, __strcspn_c); +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/strcspn-vx.S b/sysdeps/s390/strcspn-vx.S similarity index 97% rename from sysdeps/s390/multiarch/strcspn-vx.S rename to sysdeps/s390/strcspn-vx.S index ea1668742b..ff5b1be549 100644 --- a/sysdeps/s390/multiarch/strcspn-vx.S +++ b/sysdeps/s390/strcspn-vx.S @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRCSPN_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -58,7 +60,7 @@ otherwise =0; r9: loaded byte count of vlbb reject-string */ -ENTRY(__strcspn_vx) +ENTRY(STRCSPN_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -277,5 +279,14 @@ ENTRY(__strcspn_vx) vlgvg %r8,%v31,0 vlgvg %r9,%v31,1 br %r14 -END(__strcspn_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(STRCSPN_Z13) + +# if ! HAVE_STRCSPN_IFUNC +strong_alias (STRCSPN_Z13, strcspn) +# endif + +# if ! HAVE_STRCSPN_C && defined SHARED && IS_IN (libc) +strong_alias (STRCSPN_Z13, __GI_strcspn) +# endif + +#endif /* HAVE_STRCSPN_Z13 */ diff --git a/sysdeps/s390/multiarch/strcspn.c b/sysdeps/s390/strcspn.c similarity index 70% rename from sysdeps/s390/multiarch/strcspn.c rename to sysdeps/s390/strcspn.c index 418ffcdded..a3f35d39c5 100644 --- a/sysdeps/s390/multiarch/strcspn.c +++ b/sysdeps/s390/strcspn.c @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_STRCSPN_IFUNC # define strcspn __redirect_strcspn /* Omit the strcspn inline definitions because it would redefine strcspn. */ # define __NO_STRING_INLINES @@ -24,8 +26,17 @@ # undef strcspn # include -s390_vx_libc_ifunc2_redirected (__redirect_strcspn, __strcspn, strcspn) +# if HAVE_STRCSPN_C +extern __typeof (__redirect_strcspn) STRCSPN_C attribute_hidden; +# endif + +# if HAVE_STRCSPN_Z13 +extern __typeof (__redirect_strcspn) STRCSPN_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (__redirect_strcspn, strcspn, + (HAVE_STRCSPN_Z13 && (hwcap & HWCAP_S390_VX)) + ? STRCSPN_Z13 + : STRCSPN_DEFAULT + ) +#endif /* HAVE_STRCSPN_IFUNC */ From patchwork Fri Nov 30 15:58:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006046 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-97772-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="cYdjY4bo"; 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 435zht3sgGz9s8r for ; Sat, 1 Dec 2018 03:03:58 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=H0uRa8Hmp/KVHNYtP4M1kTP8g2ndYXw h1KMWqLS04FLos9r+8Y036JK0PDXoKbGtN6Rvs4qddTzyhqqjOE+RC9nAVNcrmnd /YhILmpC8N0f2+mwRJa7AF2j8SEgIbcMrt+E4rUARWG78sGQv81IMOcp47MKCA+V B+2NMUjD2/BE= 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=bC9yhy0nLjgs2xpJZAsFEF5v9NY=; b=cYdjY 4boJ3pWuwukMWshKTg6Q0Rs+hdAwVJ+HMD/7/41sn7Uikaag3pWelyQ1/Xal1ppi bXSfcO/NayzkciNLsl/eci3ReXALOY5GdPG6Rn3elHoxdmvppzyb8xlGry62ezyM McQxPmEOMxCDFw+t2zI4lbvgQA9hK70NV5x5YQ= Received: (qmail 50251 invoked by alias); 30 Nov 2018 16:00:49 -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 37691 invoked by uid 89); 30 Nov 2018 16:00:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 32/56] S390: Refactor memchr ifunc handling. Date: Fri, 30 Nov 2018 16:58:10 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-4275-0000-0000-000002E935DA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-4276-0000-0000-000037F67E77 Message-Id: <1543593514-10251-33-git-send-email-stli@linux.ibm.com> The ifunc handling for memchr is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. Note: The fallback s390-32/s390-64 ifunc variants with srst instruction are now moved to the unified memchr-z900.S file which can be used for 31/64bit. The s390-32/s390-64 files multiarch/memchr.c and memchr.S are deleted. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove memchr variants. * sysdeps/s390/Makefile (sysdep_routines): Add memchr variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for memchr. * sysdeps/s390/multiarch/memchr-vx.S: Move to ... * sysdeps/s390/memchr-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/memchr.c: Move to ... * sysdeps/s390/memchr.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-memchr.h: New file. * sysdeps/s390/s390-64/memchr.S: Move to ... * sysdeps/s390/memchr-z900.S: ... here and adjust to be usable for 31/64bit and ifunc handling. * sysdeps/s390/s390-32/multiarch/memchr.c: Delete file. * sysdeps/s390/s390-64/multiarch/memchr.c: Likewise. * sysdeps/s390/s390-32/memchr.S: Likewise. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-memchr.h | 52 +++++++++++++++++++ sysdeps/s390/{multiarch => }/memchr-vx.S | 20 ++++--- .../s390/{s390-64/memchr.S => memchr-z900.S} | 39 +++++++++++--- sysdeps/s390/{multiarch => }/memchr.c | 18 ++++++- sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 ++++- sysdeps/s390/s390-32/memchr.S | 41 --------------- sysdeps/s390/s390-32/multiarch/memchr.c | 21 -------- sysdeps/s390/s390-64/multiarch/memchr.c | 21 -------- 10 files changed, 127 insertions(+), 105 deletions(-) create mode 100644 sysdeps/s390/ifunc-memchr.h rename sysdeps/s390/{multiarch => }/memchr-vx.S (92%) rename sysdeps/s390/{s390-64/memchr.S => memchr-z900.S} (63%) rename sysdeps/s390/{multiarch => }/memchr.c (68%) delete mode 100644 sysdeps/s390/s390-32/memchr.S delete mode 100644 sysdeps/s390/s390-32/multiarch/memchr.c delete mode 100644 sysdeps/s390/s390-64/multiarch/memchr.c diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index c163969652..8f11ed5463 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -75,5 +75,6 @@ sysdep_routines += bzero memset memset-z900 \ strrchr strrchr-vx strrchr-c \ strspn strspn-vx strspn-c \ strpbrk strpbrk-vx strpbrk-c \ - strcspn strcspn-vx strcspn-c + strcspn strcspn-vx strcspn-c \ + memchr memchr-vx memchr-z900 endif diff --git a/sysdeps/s390/ifunc-memchr.h b/sysdeps/s390/ifunc-memchr.h new file mode 100644 index 0000000000..5d1327b453 --- /dev/null +++ b/sysdeps/s390/ifunc-memchr.h @@ -0,0 +1,52 @@ +/* memchr variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_MEMCHR_IFUNC 1 +#else +# define HAVE_MEMCHR_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_MEMCHR_IFUNC_AND_VX_SUPPORT HAVE_MEMCHR_IFUNC +#else +# define HAVE_MEMCHR_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define MEMCHR_DEFAULT MEMCHR_Z13 +# define HAVE_MEMCHR_Z900_G5 0 +# define HAVE_MEMCHR_Z13 1 +#else +# define MEMCHR_DEFAULT MEMCHR_Z900_G5 +# define HAVE_MEMCHR_Z900_G5 1 +# define HAVE_MEMCHR_Z13 HAVE_MEMCHR_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_MEMCHR_Z900_G5 +# define MEMCHR_Z900_G5 __memchr_default +#else +# define MEMCHR_Z900_G5 NULL +#endif + +#if HAVE_MEMCHR_Z13 +# define MEMCHR_Z13 __memchr_vx +#else +# define MEMCHR_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/memchr-vx.S b/sysdeps/s390/memchr-vx.S similarity index 92% rename from sysdeps/s390/multiarch/memchr-vx.S rename to sysdeps/s390/memchr-vx.S index 77d31e0036..274e7971ca 100644 --- a/sysdeps/s390/multiarch/memchr-vx.S +++ b/sysdeps/s390/memchr-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_MEMCHR_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -38,7 +39,7 @@ -v17=index of found c -v18=c replicated */ -ENTRY(__memchr_vx) +ENTRY(MEMCHR_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -149,11 +150,14 @@ ENTRY(__memchr_vx) clgrjl %r0,%r4,.Lloop64 j .Llt64 -END(__memchr_vx) +END(MEMCHR_Z13) -# define memchr __memchr_c -# undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) strong_alias(__memchr_c, __GI_memchr) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +# if ! HAVE_MEMCHR_IFUNC +strong_alias (MEMCHR_Z13, __memchr) +weak_alias (__memchr, memchr) +# endif -#include +# if ! HAVE_MEMCHR_Z900_G5 && defined SHARED && IS_IN (libc) +strong_alias (MEMCHR_Z13, __GI_memchr) +# endif +#endif diff --git a/sysdeps/s390/s390-64/memchr.S b/sysdeps/s390/memchr-z900.S similarity index 63% rename from sysdeps/s390/s390-64/memchr.S rename to sysdeps/s390/memchr-z900.S index a19fcafa14..c016bc41c6 100644 --- a/sysdeps/s390/s390-64/memchr.S +++ b/sysdeps/s390/memchr-z900.S @@ -1,4 +1,4 @@ -/* Search a character in a block of memory. 64 bit S/390 version. +/* Search a character in a block of memory. 31/64 bit S/390 version. Copyright (C) 2001-2018 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -22,19 +22,42 @@ %r3 = character to find %r4 = number of bytes to search. */ +#include #include "sysdep.h" #include "asm-syntax.h" +#if HAVE_MEMCHR_Z900_G5 +# if defined __s390x__ +# define SLGR slgr +# define LGHI lghi +# define NGR ngr +# define LGR lgr +# else +# define SLGR slr +# define LGHI lhi +# define NGR nr +# define LGR lr +# endif /* ! defined __s390x__ */ + .text -ENTRY(memchr) - lghi %r0,0xff - ngr %r0,%r3 - lgr %r1,%r2 +ENTRY(MEMCHR_Z900_G5) + LGHI %r0,0xff + NGR %r0,%r3 + LGR %r1,%r2 la %r2,0(%r4,%r1) 0: srst %r2,%r1 jo 0b brc 13,1f - slgr %r2,%r2 + SLGR %r2,%r2 1: br %r14 -END(memchr) -libc_hidden_builtin_def (memchr) +END(MEMCHR_Z900_G5) + +# if ! HAVE_MEMCHR_IFUNC +strong_alias (MEMCHR_Z900_G5, __memchr) +weak_alias (__memchr, memchr) +# endif + +# if defined SHARED && IS_IN (libc) +strong_alias (MEMCHR_Z900_G5, __GI_memchr) +# endif +#endif diff --git a/sysdeps/s390/multiarch/memchr.c b/sysdeps/s390/memchr.c similarity index 68% rename from sysdeps/s390/multiarch/memchr.c rename to sysdeps/s390/memchr.c index 3885ebaa4d..490f1b6600 100644 --- a/sysdeps/s390/multiarch/memchr.c +++ b/sysdeps/s390/memchr.c @@ -16,12 +16,26 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_MEMCHR_IFUNC # define memchr __redirect_memchr # include # undef memchr # include -s390_vx_libc_ifunc2_redirected (__redirect_memchr, __memchr, memchr) +# if HAVE_MEMCHR_Z900_G5 +extern __typeof (__redirect_memchr) MEMCHR_Z900_G5 attribute_hidden; +# endif + +# if HAVE_MEMCHR_Z13 +extern __typeof (__redirect_memchr) MEMCHR_Z13 attribute_hidden; +# endif +s390_libc_ifunc_expr (__redirect_memchr, __memchr, + (HAVE_MEMCHR_Z13 && (hwcap & HWCAP_S390_VX)) + ? MEMCHR_Z13 + : MEMCHR_DEFAULT + ) +weak_alias (__memchr, memchr) #endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 1578f21af4..fa1f7b81db 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += memchr memchr-vx \ - rawmemchr rawmemchr-vx rawmemchr-c \ +sysdep_routines += rawmemchr rawmemchr-vx rawmemchr-c \ memccpy memccpy-vx memccpy-c \ memrchr memrchr-vx memrchr-c endif diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 2d48c99c8d..b4be014042 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -42,6 +42,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -372,6 +373,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_STRCSPN_IFUNC */ +#if HAVE_MEMCHR_IFUNC + IFUNC_IMPL (i, name, memchr, +# if HAVE_MEMCHR_Z13 + IFUNC_IMPL_ADD (array, i, memchr, + dl_hwcap & HWCAP_S390_VX, MEMCHR_Z13) +# endif +# if HAVE_MEMCHR_Z900_G5 + IFUNC_IMPL_ADD (array, i, memchr, 1, MEMCHR_Z900_G5) +# endif + ) +#endif /* HAVE_MEMCHR_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -412,7 +425,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcscspn); - IFUNC_VX_IMPL (memchr); IFUNC_VX_IMPL (wmemchr); IFUNC_VX_IMPL (rawmemchr); diff --git a/sysdeps/s390/s390-32/memchr.S b/sysdeps/s390/s390-32/memchr.S deleted file mode 100644 index 54f9b85f57..0000000000 --- a/sysdeps/s390/s390-32/memchr.S +++ /dev/null @@ -1,41 +0,0 @@ -/* Search a character in a block of memory. For IBM S390 - Copyright (C) 2000-2018 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). - - 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 - . */ - -/* - * R2 = address to memory area - * R3 = character to find - * R4 = number of bytes to search - */ - -#include "sysdep.h" -#include "asm-syntax.h" - - .text -ENTRY(memchr) - lhi %r0,0xff - nr %r0,%r3 - lr %r1,%r2 - la %r2,0(%r4,%r1) -0: srst %r2,%r1 - jo 0b - brc 13,1f - slr %r2,%r2 -1: br %r14 -END(memchr) -libc_hidden_builtin_def (memchr) diff --git a/sysdeps/s390/s390-32/multiarch/memchr.c b/sysdeps/s390/s390-32/multiarch/memchr.c deleted file mode 100644 index 5e1610afa4..0000000000 --- a/sysdeps/s390/s390-32/multiarch/memchr.c +++ /dev/null @@ -1,21 +0,0 @@ -/* Multiple versions of memchr. - Copyright (C) 2015-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 - . */ - -/* This wrapper-file is needed, because otherwise file - sysdeps/s390/s390-[32|64]/memchr.S will be used. */ -#include diff --git a/sysdeps/s390/s390-64/multiarch/memchr.c b/sysdeps/s390/s390-64/multiarch/memchr.c deleted file mode 100644 index 5e1610afa4..0000000000 --- a/sysdeps/s390/s390-64/multiarch/memchr.c +++ /dev/null @@ -1,21 +0,0 @@ -/* Multiple versions of memchr. - Copyright (C) 2015-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 - . */ - -/* This wrapper-file is needed, because otherwise file - sysdeps/s390/s390-[32|64]/memchr.S will be used. */ -#include From patchwork Fri Nov 30 15:58:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006060 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-97787-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="yQxZyz2v"; 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 435zls0FRHz9sBZ for ; Sat, 1 Dec 2018 03:06:32 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=pOVsFDC4j6IRt+drIgMSmg4b+a6Lc2B oFw5RAVsygi8Mu6SWCqGQWjbISjzwOngoVboUPtpaPEZkD6pI+b+fRPfXrH5VZMD +Uf4vLBMQVsGrUgbqBap435G2hnn+0a8mkWdjUNZopkZfQQ8Zrq9JPUqJEFenVT3 XfXI1W5cex0A= 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=pDEWkX28vTPb3OqoRDCgmMn8SZc=; b=yQxZy z2vjKUzC+TtmsxLWMPBwRwisU9qD26z033raSNdoLJD499xuq8fJdlxaBgYWv0f1 TiK4fw5ITCxsoyKffNCjVfePam5YVoUO4uxPFsP/tQlM4I1i4FF+3/1vBW9D8mCX 432AXU+l3xzTIARcVenPmZfXZoA1VJStcFy2w8= Received: (qmail 108469 invoked by alias); 30 Nov 2018 16:04:02 -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 108331 invoked by uid 89); 30 Nov 2018 16:04:01 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 33/56] S390: Refactor rawmemchr ifunc handling. Date: Fri, 30 Nov 2018 16:58:11 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0008-0000-0000-0000029B03A0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0009-0000-0000-00002205545F Message-Id: <1543593514-10251-34-git-send-email-stli@linux.ibm.com> The ifunc handling for rawmemchr is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove rawmemchr variants. * sysdeps/s390/Makefile (sysdep_routines): Add rawmemchr variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for rawmemchr. * sysdeps/s390/multiarch/rawmemchr-c.c: Move to ... * sysdeps/s390/rawmemchr-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/rawmemchr-vx.S: Move to ... * sysdeps/s390/rawmemchr-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/rawmemchr.c: Move to ... * sysdeps/s390/rawmemchr.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-rawmemchr.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-rawmemchr.h | 52 +++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 14 ++++- .../{multiarch/rawmemchr.c => rawmemchr-c.c} | 25 +++++---- sysdeps/s390/{multiarch => }/rawmemchr-vx.S | 20 +++++-- .../{multiarch/rawmemchr-c.c => rawmemchr.c} | 33 +++++++----- 7 files changed, 118 insertions(+), 32 deletions(-) create mode 100644 sysdeps/s390/ifunc-rawmemchr.h rename sysdeps/s390/{multiarch/rawmemchr.c => rawmemchr-c.c} (67%) rename sysdeps/s390/{multiarch => }/rawmemchr-vx.S (87%) rename sysdeps/s390/{multiarch/rawmemchr-c.c => rawmemchr.c} (56%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 8f11ed5463..a181eeac8a 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -76,5 +76,6 @@ sysdep_routines += bzero memset memset-z900 \ strspn strspn-vx strspn-c \ strpbrk strpbrk-vx strpbrk-c \ strcspn strcspn-vx strcspn-c \ - memchr memchr-vx memchr-z900 + memchr memchr-vx memchr-z900 \ + rawmemchr rawmemchr-vx rawmemchr-c endif diff --git a/sysdeps/s390/ifunc-rawmemchr.h b/sysdeps/s390/ifunc-rawmemchr.h new file mode 100644 index 0000000000..bfcbeae802 --- /dev/null +++ b/sysdeps/s390/ifunc-rawmemchr.h @@ -0,0 +1,52 @@ +/* rawmemchr variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_RAWMEMCHR_IFUNC 1 +#else +# define HAVE_RAWMEMCHR_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_RAWMEMCHR_IFUNC_AND_VX_SUPPORT HAVE_RAWMEMCHR_IFUNC +#else +# define HAVE_RAWMEMCHR_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define RAWMEMCHR_DEFAULT RAWMEMCHR_Z13 +# define HAVE_RAWMEMCHR_C 0 +# define HAVE_RAWMEMCHR_Z13 1 +#else +# define RAWMEMCHR_DEFAULT RAWMEMCHR_C +# define HAVE_RAWMEMCHR_C 1 +# define HAVE_RAWMEMCHR_Z13 HAVE_RAWMEMCHR_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_RAWMEMCHR_C +# define RAWMEMCHR_C __rawmemchr_c +#else +# define RAWMEMCHR_C NULL +#endif + +#if HAVE_RAWMEMCHR_Z13 +# define RAWMEMCHR_Z13 __rawmemchr_vx +#else +# define RAWMEMCHR_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index fa1f7b81db..ac6cfcf9c7 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += rawmemchr rawmemchr-vx rawmemchr-c \ - memccpy memccpy-vx memccpy-c \ +sysdep_routines += memccpy memccpy-vx memccpy-c \ memrchr memrchr-vx memrchr-c endif diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index b4be014042..bf3b40e111 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -43,6 +43,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -385,6 +386,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_MEMCHR_IFUNC */ +#if HAVE_RAWMEMCHR_IFUNC + IFUNC_IMPL (i, name, rawmemchr, +# if HAVE_RAWMEMCHR_Z13 + IFUNC_IMPL_ADD (array, i, rawmemchr, + dl_hwcap & HWCAP_S390_VX, RAWMEMCHR_Z13) +# endif +# if HAVE_RAWMEMCHR_C + IFUNC_IMPL_ADD (array, i, rawmemchr, 1, RAWMEMCHR_C) +# endif + ) +#endif /* HAVE_RAWMEMCHR_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -426,7 +439,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wcscspn); IFUNC_VX_IMPL (wmemchr); - IFUNC_VX_IMPL (rawmemchr); IFUNC_VX_IMPL (memccpy); diff --git a/sysdeps/s390/multiarch/rawmemchr.c b/sysdeps/s390/rawmemchr-c.c similarity index 67% rename from sysdeps/s390/multiarch/rawmemchr.c rename to sysdeps/s390/rawmemchr-c.c index 5fdb2252df..8b8208e542 100644 --- a/sysdeps/s390/multiarch/rawmemchr.c +++ b/sysdeps/s390/rawmemchr-c.c @@ -1,4 +1,4 @@ -/* Multiple versions of rawmemchr. +/* Default rawmemchr implementation for S/390. Copyright (C) 2015-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -16,16 +16,19 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define __rawmemchr __redirect___rawmemchr -# include -# undef __rawmemchr -# include +#include -s390_vx_libc_ifunc2_redirected (__redirect___rawmemchr, __rawmemchr - , __rawmemchr) -weak_alias (__rawmemchr, rawmemchr) +#if HAVE_RAWMEMCHR_C +# if HAVE_RAWMEMCHR_IFUNC +# define RAWMEMCHR RAWMEMCHR_C +# undef weak_alias +# define weak_alias(a, b) +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_def +# define libc_hidden_def(name) \ + __hidden_ver1 (__rawmemchr_c, __GI___rawmemchr, __rawmemchr_c); +# endif +# endif -#else # include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +#endif diff --git a/sysdeps/s390/multiarch/rawmemchr-vx.S b/sysdeps/s390/rawmemchr-vx.S similarity index 87% rename from sysdeps/s390/multiarch/rawmemchr-vx.S rename to sysdeps/s390/rawmemchr-vx.S index d5778be068..f04c0e8b61 100644 --- a/sysdeps/s390/multiarch/rawmemchr-vx.S +++ b/sysdeps/s390/rawmemchr-vx.S @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_RAWMEMCHR_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -37,7 +39,7 @@ -v17=index of unequal -v18=c replicated */ -ENTRY(__rawmemchr_vx) +ENTRY(RAWMEMCHR_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -88,5 +90,15 @@ ENTRY(__rawmemchr_vx) .Lend_found: la %r2,0(%r5,%r2) /* Return pointer to character. */ br %r14 -END(__rawmemchr_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(RAWMEMCHR_Z13) + +# if ! HAVE_RAWMEMCHR_IFUNC +strong_alias (RAWMEMCHR_Z13, __rawmemchr) +weak_alias (__rawmemchr, rawmemchr) +# endif + +# if ! HAVE_RAWMEMCHR_C && defined SHARED && IS_IN (libc) +strong_alias (RAWMEMCHR_Z13, __GI___rawmemchr) +# endif + +#endif /* HAVE_RAWMEMCHR_Z13 */ diff --git a/sysdeps/s390/multiarch/rawmemchr-c.c b/sysdeps/s390/rawmemchr.c similarity index 56% rename from sysdeps/s390/multiarch/rawmemchr-c.c rename to sysdeps/s390/rawmemchr.c index f43c883a76..d9263ce208 100644 --- a/sysdeps/s390/multiarch/rawmemchr-c.c +++ b/sysdeps/s390/rawmemchr.c @@ -1,4 +1,4 @@ -/* Default rawmemchr implementation for S/390. +/* Multiple versions of rawmemchr. Copyright (C) 2015-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -16,19 +16,26 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_RAWMEMCHR_IFUNC +# define __rawmemchr __redirect___rawmemchr # include +# undef __rawmemchr +# include -# define RAWMEMCHR __rawmemchr_c -# undef weak_alias -# define weak_alias(a, b) -# ifdef SHARED -# undef libc_hidden_def -# define libc_hidden_def(name) \ - __hidden_ver1 (__rawmemchr_c, __GI___rawmemchr, __rawmemchr_c); -# endif /* SHARED */ +# if HAVE_RAWMEMCHR_C +extern __typeof (__redirect___rawmemchr) RAWMEMCHR_C attribute_hidden; +# endif -extern __typeof (rawmemchr) __rawmemchr_c attribute_hidden; +# if HAVE_RAWMEMCHR_Z13 +extern __typeof (__redirect___rawmemchr) RAWMEMCHR_Z13 attribute_hidden; +# endif -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (__redirect___rawmemchr, __rawmemchr, + (HAVE_RAWMEMCHR_Z13 && (hwcap & HWCAP_S390_VX)) + ? RAWMEMCHR_Z13 + : RAWMEMCHR_DEFAULT + ) +weak_alias (__rawmemchr, rawmemchr) +#endif /* HAVE_RAWMEMCHR_IFUNC */ From patchwork Fri Nov 30 15:58:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006057 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-97784-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="IBX65tKt"; 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 435zlH74GYz9s8r for ; Sat, 1 Dec 2018 03:06: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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=FkVoZHfZr0dDJq7NghIO3SAf+1JPrpa Q9ly6rOBj+4C/3shADJIPOqeuYPxVR7t+XvM/3QA+c/P/7TWuYca4WSy6WggbVSZ YjLCjyNNd0NzcgZQ+WFxlbaN92a4iWQWDNI3BpD1dhvO+hZzNWUf0+LKuxe0eRZK 4Gg213a5nCCc= 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=UBFRMl74DRCHEJgmKC5w8BZudw4=; b=IBX65 tKt9dmUDq6z63FQcOyanz7F5NBBZYSgvwfOD48HiIHlSELcpZfL6QcWJnTKCegPP Q8jbRfGLEETYej/4vxMEzI+9hCZiJ7nylwPaAonFdkCJBDSG4UxIiIAzC4HNs4rc nyWrJ/1Jz0v4RL2stCsx2WZtRr83YDSA2sTKiE= Received: (qmail 107401 invoked by alias); 30 Nov 2018 16:03:54 -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 107290 invoked by uid 89); 30 Nov 2018 16:03:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 34/56] S390: Refactor memccpy ifunc handling. Date: Fri, 30 Nov 2018 16:58:12 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0012-0000-0000-000002D2B61A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0013-0000-0000-00002108046F Message-Id: <1543593514-10251-35-git-send-email-stli@linux.ibm.com> The ifunc handling for memccpy is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove memccpy variants. * sysdeps/s390/Makefile (sysdep_routines): Add memccpy variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for memccpy. * sysdeps/s390/multiarch/memccpy-c.c: Move to ... * sysdeps/s390/memccpy-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/memccpy-vx.S: Move to ... * sysdeps/s390/memccpy-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/memccpy.c: Move to ... * sysdeps/s390/memccpy.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-memccpy.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-memccpy.h | 52 +++++++++++++++++++++++ sysdeps/s390/{multiarch => }/memccpy-c.c | 12 ++++-- sysdeps/s390/{multiarch => }/memccpy-vx.S | 16 +++++-- sysdeps/s390/{multiarch => }/memccpy.c | 23 +++++++--- sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- 7 files changed, 105 insertions(+), 19 deletions(-) create mode 100644 sysdeps/s390/ifunc-memccpy.h rename sysdeps/s390/{multiarch => }/memccpy-c.c (85%) rename sysdeps/s390/{multiarch => }/memccpy-vx.S (95%) rename sysdeps/s390/{multiarch => }/memccpy.c (68%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index a181eeac8a..649f29adc2 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -77,5 +77,6 @@ sysdep_routines += bzero memset memset-z900 \ strpbrk strpbrk-vx strpbrk-c \ strcspn strcspn-vx strcspn-c \ memchr memchr-vx memchr-z900 \ - rawmemchr rawmemchr-vx rawmemchr-c + rawmemchr rawmemchr-vx rawmemchr-c \ + memccpy memccpy-vx memccpy-c endif diff --git a/sysdeps/s390/ifunc-memccpy.h b/sysdeps/s390/ifunc-memccpy.h new file mode 100644 index 0000000000..8f7a1d0f9f --- /dev/null +++ b/sysdeps/s390/ifunc-memccpy.h @@ -0,0 +1,52 @@ +/* memccpy variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_MEMCCPY_IFUNC 1 +#else +# define HAVE_MEMCCPY_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_MEMCCPY_IFUNC_AND_VX_SUPPORT HAVE_MEMCCPY_IFUNC +#else +# define HAVE_MEMCCPY_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define MEMCCPY_DEFAULT MEMCCPY_Z13 +# define HAVE_MEMCCPY_C 0 +# define HAVE_MEMCCPY_Z13 1 +#else +# define MEMCCPY_DEFAULT MEMCCPY_C +# define HAVE_MEMCCPY_C 1 +# define HAVE_MEMCCPY_Z13 HAVE_MEMCCPY_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_MEMCCPY_C +# define MEMCCPY_C __memccpy_c +#else +# define MEMCCPY_C NULL +#endif + +#if HAVE_MEMCCPY_Z13 +# define MEMCCPY_Z13 __memccpy_vx +#else +# define MEMCCPY_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/memccpy-c.c b/sysdeps/s390/memccpy-c.c similarity index 85% rename from sysdeps/s390/multiarch/memccpy-c.c rename to sysdeps/s390/memccpy-c.c index 1f4c548199..2b2f81eb9c 100644 --- a/sysdeps/s390/multiarch/memccpy-c.c +++ b/sysdeps/s390/memccpy-c.c @@ -16,10 +16,14 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define MEMCCPY __memccpy_c +#include + +#if HAVE_MEMCCPY_C +# if HAVE_MEMCCPY_IFUNC +# define MEMCCPY MEMCCPY_C +# undef weak_alias +# define weak_alias(a, b) +#endif -# include -extern __typeof (__memccpy) __memccpy_c; # include #endif diff --git a/sysdeps/s390/multiarch/memccpy-vx.S b/sysdeps/s390/memccpy-vx.S similarity index 95% rename from sysdeps/s390/multiarch/memccpy-vx.S rename to sysdeps/s390/memccpy-vx.S index 150aa0e4a4..44f7bc5824 100644 --- a/sysdeps/s390/multiarch/memccpy-vx.S +++ b/sysdeps/s390/memccpy-vx.S @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_MEMCCPY_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -42,7 +44,7 @@ -v19=part #2 of s -v31=save area for r6 */ -ENTRY(__memccpy_vx) +ENTRY(MEMCCPY_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -152,5 +154,11 @@ ENTRY(__memccpy_vx) vlgvg %r7,%v31,1 lghi %r2,0 /* Return null. */ br %r14 -END(__memccpy_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(MEMCCPY_Z13) + +# if ! HAVE_MEMCCPY_IFUNC +strong_alias (MEMCCPY_Z13, __memccpy) +weak_alias (__memccpy, memccpy) +# endif + +#endif /* HAVE_MEMCCPY_Z13 */ diff --git a/sysdeps/s390/multiarch/memccpy.c b/sysdeps/s390/memccpy.c similarity index 68% rename from sysdeps/s390/multiarch/memccpy.c rename to sysdeps/s390/memccpy.c index 30aae82321..bcfeb31e86 100644 --- a/sysdeps/s390/multiarch/memccpy.c +++ b/sysdeps/s390/memccpy.c @@ -16,13 +16,24 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_MEMCCPY_IFUNC # include # include -s390_vx_libc_ifunc (__memccpy) -weak_alias (__memccpy, memccpy) +# if HAVE_MEMCCPY_C +extern __typeof (__memccpy) MEMCCPY_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_MEMCCPY_Z13 +extern __typeof (__memccpy) MEMCCPY_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__memccpy, __memccpy, + (HAVE_MEMCCPY_Z13 && (hwcap & HWCAP_S390_VX)) + ? MEMCCPY_Z13 + : MEMCCPY_DEFAULT + ) +weak_alias (__memccpy, memccpy) +#endif /* HAVE_MEMCCPY_IFUNC */ diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index ac6cfcf9c7..d5a32fc309 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),string) -sysdep_routines += memccpy memccpy-vx memccpy-c \ - memrchr memrchr-vx memrchr-c +sysdep_routines += memrchr memrchr-vx memrchr-c endif ifeq ($(subdir),wcsmbs) diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index bf3b40e111..b8917747f0 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -44,6 +44,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -398,6 +399,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_RAWMEMCHR_IFUNC */ +#if HAVE_MEMCCPY_IFUNC + IFUNC_IMPL (i, name, memccpy, +# if HAVE_MEMCCPY_Z13 + IFUNC_IMPL_ADD (array, i, memccpy, + dl_hwcap & HWCAP_S390_VX, MEMCCPY_Z13) +# endif +# if HAVE_MEMCCPY_C + IFUNC_IMPL_ADD (array, i, memccpy, 1, MEMCCPY_C) +# endif + ) +#endif /* HAVE_MEMCCPY_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -440,8 +453,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wmemchr); - IFUNC_VX_IMPL (memccpy); - IFUNC_VX_IMPL (wmemset); IFUNC_VX_IMPL (wmemcmp); From patchwork Fri Nov 30 15:58:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006042 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-97770-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="qz3ccocb"; 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 435zh56Vqvz9s8r for ; Sat, 1 Dec 2018 03:03:17 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=wlNrnlgQ4y2vsC3CcAAayNZHdIYvutl DjXXATIw9Wovn7jw2yK3aikRcYZx4tTom4b6SCQqs4TFP7EGDsEwP2pmyG+nqDGQ a4GfkIQji1lEXV2x6Sc1XQyg1kR8pvPnUGq/9VByFK+pJIKNv3fVdLnmNitHrtmp aIgONnsku3LQ= 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=0fu27/FVmSv+8sX+GdqyUEL47Zw=; b=qz3cc ocbaIZMn0jvESc1qkLrkqEgqkuN2W93jS8XHiuVv0GQ5axfEFqqewnYlWh71pIex bNR5CZSeyeZcQr5rNE7SSGWHKXm2ZZ86PH1pLJDPalZBxZrlAvc2lhwRLrvHet1G WNWzgQ8YYLqswYeCBDDrauvimXj+sMuLWlQEbQ= Received: (qmail 22606 invoked by alias); 30 Nov 2018 16:00: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 22207 invoked by uid 89); 30 Nov 2018 16:00:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 35/56] S390: Refactor memrchr ifunc handling. Date: Fri, 30 Nov 2018 16:58:13 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0008-0000-0000-0000029B03A3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0009-0000-0000-000022055461 Message-Id: <1543593514-10251-36-git-send-email-stli@linux.ibm.com> The ifunc handling for memrchr is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove memrchr variants. * sysdeps/s390/Makefile (sysdep_routines): Add memrchr variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for memrchr. * sysdeps/s390/multiarch/memrchr-c.c: Move to ... * sysdeps/s390/memrchr-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/memrchr-vx.S: Move to ... * sysdeps/s390/memrchr-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/memrchr.c: Move to ... * sysdeps/s390/memrchr.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-memrchr.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-memrchr.h | 52 +++++++++++++++++++++++ sysdeps/s390/{multiarch => }/memrchr-c.c | 10 +++-- sysdeps/s390/{multiarch => }/memrchr-vx.S | 16 +++++-- sysdeps/s390/{multiarch => }/memrchr.c | 23 +++++++--- sysdeps/s390/multiarch/Makefile | 4 -- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- 7 files changed, 102 insertions(+), 21 deletions(-) create mode 100644 sysdeps/s390/ifunc-memrchr.h rename sysdeps/s390/{multiarch => }/memrchr-c.c (85%) rename sysdeps/s390/{multiarch => }/memrchr-vx.S (94%) rename sysdeps/s390/{multiarch => }/memrchr.c (68%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 649f29adc2..0e86242c5d 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -78,5 +78,6 @@ sysdep_routines += bzero memset memset-z900 \ strcspn strcspn-vx strcspn-c \ memchr memchr-vx memchr-z900 \ rawmemchr rawmemchr-vx rawmemchr-c \ - memccpy memccpy-vx memccpy-c + memccpy memccpy-vx memccpy-c \ + memrchr memrchr-vx memrchr-c endif diff --git a/sysdeps/s390/ifunc-memrchr.h b/sysdeps/s390/ifunc-memrchr.h new file mode 100644 index 0000000000..9d80d5528d --- /dev/null +++ b/sysdeps/s390/ifunc-memrchr.h @@ -0,0 +1,52 @@ +/* memrchr variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_MEMRCHR_IFUNC 1 +#else +# define HAVE_MEMRCHR_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_MEMRCHR_IFUNC_AND_VX_SUPPORT HAVE_MEMRCHR_IFUNC +#else +# define HAVE_MEMRCHR_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define MEMRCHR_DEFAULT MEMRCHR_Z13 +# define HAVE_MEMRCHR_C 0 +# define HAVE_MEMRCHR_Z13 1 +#else +# define MEMRCHR_DEFAULT MEMRCHR_C +# define HAVE_MEMRCHR_C 1 +# define HAVE_MEMRCHR_Z13 HAVE_MEMRCHR_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_MEMRCHR_C +# define MEMRCHR_C __memrchr_c +#else +# define MEMRCHR_C NULL +#endif + +#if HAVE_MEMRCHR_Z13 +# define MEMRCHR_Z13 __memrchr_vx +#else +# define MEMRCHR_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/memrchr-c.c b/sysdeps/s390/memrchr-c.c similarity index 85% rename from sysdeps/s390/multiarch/memrchr-c.c rename to sysdeps/s390/memrchr-c.c index 1e3c914a5d..333c0fc8d1 100644 --- a/sysdeps/s390/multiarch/memrchr-c.c +++ b/sysdeps/s390/memrchr-c.c @@ -16,10 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define MEMRCHR __memrchr_c +#include + +#if HAVE_MEMRCHR_C +# if HAVE_MEMRCHR_IFUNC +# define MEMRCHR MEMRCHR_C +# endif -# include -extern __typeof (__memrchr) __memrchr_c; # include #endif diff --git a/sysdeps/s390/multiarch/memrchr-vx.S b/sysdeps/s390/memrchr-vx.S similarity index 94% rename from sysdeps/s390/multiarch/memrchr-vx.S rename to sysdeps/s390/memrchr-vx.S index 8e81f5ed75..ba832f1b21 100644 --- a/sysdeps/s390/multiarch/memrchr-vx.S +++ b/sysdeps/s390/memrchr-vx.S @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_MEMRCHR_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -40,7 +42,7 @@ -v18=c replicated -v20=permute pattern */ -ENTRY(__memrchr_vx) +ENTRY(MEMRCHR_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -156,5 +158,11 @@ ENTRY(__memrchr_vx) clgijhe %r4,64,.Lloop64 /* If n >= 64 -> loop64. */ j .Llt64 -END(__memrchr_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(MEMRCHR_Z13) + +# if ! HAVE_MEMRCHR_IFUNC +strong_alias (MEMRCHR_Z13, __memrchr) +weak_alias (__memrchr, memrchr) +# endif + +#endif /* HAVE_MEMRCHR_Z13 */ diff --git a/sysdeps/s390/multiarch/memrchr.c b/sysdeps/s390/memrchr.c similarity index 68% rename from sysdeps/s390/multiarch/memrchr.c rename to sysdeps/s390/memrchr.c index 43a44abcf6..d995e9961c 100644 --- a/sysdeps/s390/multiarch/memrchr.c +++ b/sysdeps/s390/memrchr.c @@ -16,13 +16,24 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_MEMRCHR_IFUNC # include # include -s390_vx_libc_ifunc (__memrchr) -weak_alias (__memrchr, memrchr) +# if HAVE_MEMRCHR_C +extern __typeof (__memrchr) MEMRCHR_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_MEMRCHR_Z13 +extern __typeof (__memrchr) MEMRCHR_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__memrchr, __memrchr, + (HAVE_MEMRCHR_Z13 && (hwcap & HWCAP_S390_VX)) + ? MEMRCHR_Z13 + : MEMRCHR_DEFAULT + ) +weak_alias (__memrchr, memrchr) +#endif /* HAVE_MEMRCHR_IFUNC */ diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index d5a32fc309..260b514936 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,7 +1,3 @@ -ifeq ($(subdir),string) -sysdep_routines += memrchr memrchr-vx memrchr-c -endif - ifeq ($(subdir),wcsmbs) sysdep_routines += wcslen wcslen-vx wcslen-c \ wcsnlen wcsnlen-vx wcsnlen-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index b8917747f0..0f01b99691 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -45,6 +45,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -411,6 +412,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_MEMCCPY_IFUNC */ +#if HAVE_MEMRCHR_IFUNC + IFUNC_IMPL (i, name, memrchr, +# if HAVE_MEMRCHR_Z13 + IFUNC_IMPL_ADD (array, i, memrchr, + dl_hwcap & HWCAP_S390_VX, MEMRCHR_Z13) +# endif +# if HAVE_MEMRCHR_C + IFUNC_IMPL_ADD (array, i, memrchr, 1, MEMRCHR_C) +# endif + ) +#endif /* HAVE_MEMRCHR_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -457,8 +470,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_VX_IMPL (wmemcmp); - IFUNC_VX_IMPL (memrchr); - #endif /* HAVE_S390_VX_ASM_SUPPORT */ return i; From patchwork Fri Nov 30 15:58:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006061 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-97788-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="KZ7iplRE"; 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 435zm259tMz9s8r for ; Sat, 1 Dec 2018 03:06:42 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=m5e2xV5Gmbd9wtOGqlWWlqqkxcVyAUy 2MYnhVwACg7UrGmlzxF7o+7/zv9HcwERwWpwszOeOZvyxKeqlotxcqVIJ7XaeuIW gKo2qh7xEWAezK++c8cBJgbdJ8/9qKpFxyK/QPKzYu7yfDgSC49n51N+Xl5gVz3A JwgZ4LHXgCfg= 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=RXgHiXuJ84EqFCyBt2GPMz81cvA=; b=KZ7ip lREC7MFp12TNNxgIxkQcauh5P7CzT7g8IxyiMipEJb16ufJvjVEl7iqMVWOrONNg J4dlYX/KccfEODHgMrPqitA1s40A2JT2iSBqQudYenJ+zjtXaK57aMPu6WI8SGr8 wRrgjRzonwJE22omI81cqFwSLQcxraVijK0BZc= Received: (qmail 108565 invoked by alias); 30 Nov 2018 16:04:02 -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 108413 invoked by uid 89); 30 Nov 2018 16:04:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 36/56] S390: Refactor wcslen ifunc handling. Date: Fri, 30 Nov 2018 16:58:14 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-4275-0000-0000-000002E935DB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-4276-0000-0000-000037F67E79 Message-Id: <1543593514-10251-37-git-send-email-stli@linux.ibm.com> The ifunc handling for wcslen is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcslen variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcslen variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcslen. * sysdeps/s390/multiarch/wcslen-c.c: Move to ... * sysdeps/s390/wcslen-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcslen-vx.S: Move to ... * sysdeps/s390/wcslen-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcslen.c: Move to ... * sysdeps/s390/wcslen.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcslen.h: New file. --- sysdeps/s390/Makefile | 4 ++ sysdeps/s390/ifunc-wcslen.h | 53 ++++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcslen-c.c | 10 +++-- sysdeps/s390/{multiarch => }/wcslen-vx.S | 16 ++++--- sysdeps/s390/{multiarch => }/wcslen.c | 23 +++++++--- 7 files changed, 105 insertions(+), 19 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcslen.h rename sysdeps/s390/{multiarch => }/wcslen-c.c (86%) rename sysdeps/s390/{multiarch => }/wcslen-vx.S (92%) rename sysdeps/s390/{multiarch => }/wcslen.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 0e86242c5d..10c0e1bea0 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -81,3 +81,7 @@ sysdep_routines += bzero memset memset-z900 \ memccpy memccpy-vx memccpy-c \ memrchr memrchr-vx memrchr-c endif + +ifeq ($(subdir),wcsmbs) +sysdep_routines += wcslen wcslen-vx wcslen-c +endif diff --git a/sysdeps/s390/ifunc-wcslen.h b/sysdeps/s390/ifunc-wcslen.h new file mode 100644 index 0000000000..50d879caf2 --- /dev/null +++ b/sysdeps/s390/ifunc-wcslen.h @@ -0,0 +1,53 @@ +/* wcslen variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCSLEN_IFUNC 1 +#else +# define HAVE_WCSLEN_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCSLEN_IFUNC_AND_VX_SUPPORT HAVE_WCSLEN_IFUNC +#else +# define HAVE_WCSLEN_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCSLEN_DEFAULT WCSLEN_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WCSLEN_C 1 +# define HAVE_WCSLEN_Z13 1 +#else +# define WCSLEN_DEFAULT WCSLEN_C +# define HAVE_WCSLEN_C 1 +# define HAVE_WCSLEN_Z13 HAVE_WCSLEN_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCSLEN_C +# define WCSLEN_C __wcslen_c +#else +# define WCSLEN_C NULL +#endif + +#if HAVE_WCSLEN_Z13 +# define WCSLEN_Z13 __wcslen_vx +#else +# define WCSLEN_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 260b514936..421d40d020 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcslen wcslen-vx wcslen-c \ - wcsnlen wcsnlen-vx wcsnlen-c \ +sysdep_routines += wcsnlen wcsnlen-vx wcsnlen-c \ wcscpy wcscpy-vx wcscpy-c \ wcpcpy wcpcpy-vx wcpcpy-c \ wcsncpy wcsncpy-vx wcsncpy-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 0f01b99691..7bf5f14c01 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -46,6 +46,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -424,6 +425,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_MEMRCHR_IFUNC */ +#if HAVE_WCSLEN_IFUNC + IFUNC_IMPL (i, name, wcslen, +# if HAVE_WCSLEN_Z13 + IFUNC_IMPL_ADD (array, i, wcslen, + dl_hwcap & HWCAP_S390_VX, WCSLEN_Z13) +# endif +# if HAVE_WCSLEN_C + IFUNC_IMPL_ADD (array, i, wcslen, 1, WCSLEN_C) +# endif + ) +#endif /* HAVE_WCSLEN_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -432,8 +445,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcslen); - IFUNC_VX_IMPL (wcsnlen); IFUNC_VX_IMPL (wcscpy); diff --git a/sysdeps/s390/multiarch/wcslen-c.c b/sysdeps/s390/wcslen-c.c similarity index 86% rename from sysdeps/s390/multiarch/wcslen-c.c rename to sysdeps/s390/wcslen-c.c index 32a23e206d..45399cff3a 100644 --- a/sysdeps/s390/multiarch/wcslen-c.c +++ b/sysdeps/s390/wcslen-c.c @@ -16,10 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCSLEN __wcslen_c +#include + +#if HAVE_WCSLEN_C +# if HAVE_WCSLEN_IFUNC || HAVE_WCSLEN_Z13 +# define WCSLEN WCSLEN_C +# endif -# include -extern __typeof (__wcslen) __wcslen_c; # include #endif diff --git a/sysdeps/s390/multiarch/wcslen-vx.S b/sysdeps/s390/wcslen-vx.S similarity index 92% rename from sysdeps/s390/multiarch/wcslen-vx.S rename to sysdeps/s390/wcslen-vx.S index 337cbed6ec..114f7ef743 100644 --- a/sysdeps/s390/multiarch/wcslen-vx.S +++ b/sysdeps/s390/wcslen-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCSLEN_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -34,7 +35,7 @@ -r5=current_len and return_value -v16=part of s */ -ENTRY(__wcslen_vx) +ENTRY(WCSLEN_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -86,6 +87,11 @@ ENTRY(__wcslen_vx) srlg %r2,%r2,2 /* Convert byte-count to character-count. */ br %r14 .Lfallback: - jg __wcslen_c -END(__wcslen_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WCSLEN_C +END(WCSLEN_Z13) + +# if ! HAVE_WCSLEN_IFUNC +strong_alias (WCSLEN_Z13, __wcslen) +weak_alias (__wcslen, wcslen) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcslen.c b/sysdeps/s390/wcslen.c similarity index 70% rename from sysdeps/s390/multiarch/wcslen.c rename to sysdeps/s390/wcslen.c index 3a1d1a32c9..a5eee83f6c 100644 --- a/sysdeps/s390/multiarch/wcslen.c +++ b/sysdeps/s390/wcslen.c @@ -16,13 +16,24 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCSLEN_IFUNC # include # include -s390_vx_libc_ifunc (__wcslen) -weak_alias (__wcslen, wcslen) +# if HAVE_WCSLEN_C +extern __typeof (__wcslen) WCSLEN_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_WCSLEN_Z13 +extern __typeof (__wcslen) WCSLEN_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__wcslen, __wcslen, + (HAVE_WCSLEN_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCSLEN_Z13 + : WCSLEN_DEFAULT + ) +weak_alias (__wcslen, wcslen) +#endif From patchwork Fri Nov 30 15:58:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006052 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-97780-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="Z/pg3CQB"; 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 435zkR2Gz5z9sBZ for ; Sat, 1 Dec 2018 03:05:19 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=wPP1UL+BQgnBMzTiGEVrB/xoRPgjbcw omWSikeUlwX/ivIOvQNSamnUgXCo9V2ftROjlyeBG8JU1HRvSWATZstRVuxEH7L8 FvdXBbJtLKLpkk88n/xL1KcQOtcpw3zEiD7+xwer/WGXbWtfuLPQPTZf0imrDHRh agbls6AsFGxU= 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=UOymlsZt8poIZqS86pGOe58duho=; b=Z/pg3 CQBGdCVR1AIpvcAJJjUzYWr104pKY5DD2AK2CGnAJeNBFSJGpOLg5CgqU4PF1Mvt xQG23mxZrztsS29hgoTXfQyvgo9Aa+bti+5kWb3IDE2WZUM+RbgApA2mF0LOyWw+ g6pY4Lv+PoPTU0/a3INYJ2NTQhPP5IhhWv/Smg= Received: (qmail 95828 invoked by alias); 30 Nov 2018 16:02:27 -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 95728 invoked by uid 89); 30 Nov 2018 16:02:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 37/56] S390: Refactor wcsnlen ifunc handling. Date: Fri, 30 Nov 2018 16:58:15 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0008-0000-0000-0000029B03A4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0009-0000-0000-000022055462 Message-Id: <1543593514-10251-38-git-send-email-stli@linux.ibm.com> The ifunc handling for wcsnlen is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. Glibc internal calls will use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcsnlen variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcsnlen variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcsnlen. * sysdeps/s390/multiarch/wcsnlen-c.c: Move to ... * sysdeps/s390/wcsnlen-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcsnlen-vx.S: Move to ... * sysdeps/s390/wcsnlen-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcsnlen.c: Move to ... * sysdeps/s390/wcsnlen.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcsnlen.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcsnlen.h | 53 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcsnlen-c.c | 10 +++-- sysdeps/s390/{multiarch => }/wcsnlen-vx.S | 16 ++++--- sysdeps/s390/{multiarch => }/wcsnlen.c | 23 +++++++--- 7 files changed, 103 insertions(+), 20 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcsnlen.h rename sysdeps/s390/{multiarch => }/wcsnlen-c.c (85%) rename sysdeps/s390/{multiarch => }/wcsnlen-vx.S (95%) rename sysdeps/s390/{multiarch => }/wcsnlen.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 10c0e1bea0..590d2207b7 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -83,5 +83,6 @@ sysdep_routines += bzero memset memset-z900 \ endif ifeq ($(subdir),wcsmbs) -sysdep_routines += wcslen wcslen-vx wcslen-c +sysdep_routines += wcslen wcslen-vx wcslen-c \ + wcsnlen wcsnlen-vx wcsnlen-c endif diff --git a/sysdeps/s390/ifunc-wcsnlen.h b/sysdeps/s390/ifunc-wcsnlen.h new file mode 100644 index 0000000000..b5b21da2f1 --- /dev/null +++ b/sysdeps/s390/ifunc-wcsnlen.h @@ -0,0 +1,53 @@ +/* wcsnlen variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCSNLEN_IFUNC 1 +#else +# define HAVE_WCSNLEN_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCSNLEN_IFUNC_AND_VX_SUPPORT HAVE_WCSNLEN_IFUNC +#else +# define HAVE_WCSNLEN_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCSNLEN_DEFAULT WCSNLEN_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WCSNLEN_C 1 +# define HAVE_WCSNLEN_Z13 1 +#else +# define WCSNLEN_DEFAULT WCSNLEN_C +# define HAVE_WCSNLEN_C 1 +# define HAVE_WCSNLEN_Z13 HAVE_WCSNLEN_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCSNLEN_C +# define WCSNLEN_C __wcsnlen_c +#else +# define WCSNLEN_C NULL +#endif + +#if HAVE_WCSNLEN_Z13 +# define WCSNLEN_Z13 __wcsnlen_vx +#else +# define WCSNLEN_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 421d40d020..ce2e7ce5f4 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcsnlen wcsnlen-vx wcsnlen-c \ - wcscpy wcscpy-vx wcscpy-c \ +sysdep_routines += wcscpy wcscpy-vx wcscpy-c \ wcpcpy wcpcpy-vx wcpcpy-c \ wcsncpy wcsncpy-vx wcsncpy-c \ wcpncpy wcpncpy-vx wcpncpy-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 7bf5f14c01..c199fd0e0b 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -47,6 +47,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -437,6 +438,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCSLEN_IFUNC */ +#if HAVE_WCSNLEN_IFUNC + IFUNC_IMPL (i, name, wcsnlen, +# if HAVE_WCSNLEN_Z13 + IFUNC_IMPL_ADD (array, i, wcsnlen, + dl_hwcap & HWCAP_S390_VX, WCSNLEN_Z13) +# endif +# if HAVE_WCSNLEN_C + IFUNC_IMPL_ADD (array, i, wcsnlen, 1, WCSNLEN_C) +# endif + ) +#endif /* HAVE_WCSNLEN_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -445,8 +458,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcsnlen); - IFUNC_VX_IMPL (wcscpy); IFUNC_VX_IMPL (wcpcpy); diff --git a/sysdeps/s390/multiarch/wcsnlen-c.c b/sysdeps/s390/wcsnlen-c.c similarity index 85% rename from sysdeps/s390/multiarch/wcsnlen-c.c rename to sysdeps/s390/wcsnlen-c.c index 8f43f5104f..7495a6f97c 100644 --- a/sysdeps/s390/multiarch/wcsnlen-c.c +++ b/sysdeps/s390/wcsnlen-c.c @@ -16,10 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCSNLEN __wcsnlen_c +#include + +#if HAVE_WCSNLEN_C +# if HAVE_WCSNLEN_IFUNC || HAVE_WCSNLEN_Z13 +# define WCSNLEN WCSNLEN_C +# endif -# include -extern __typeof (__wcsnlen) __wcsnlen_c; # include #endif diff --git a/sysdeps/s390/multiarch/wcsnlen-vx.S b/sysdeps/s390/wcsnlen-vx.S similarity index 95% rename from sysdeps/s390/multiarch/wcsnlen-vx.S rename to sysdeps/s390/wcsnlen-vx.S index 420f29fbc0..47f4ca8284 100644 --- a/sysdeps/s390/multiarch/wcsnlen-vx.S +++ b/sysdeps/s390/wcsnlen-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCSNLEN_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -34,7 +35,7 @@ -r5=current_len and return_value -v16=part of s */ -ENTRY(__wcsnlen_vx) +ENTRY(WCSNLEN_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -146,6 +147,11 @@ ENTRY(__wcsnlen_vx) j .Llt64 .Lfallback: - jg __wcsnlen_c -END(__wcsnlen_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WCSNLEN_C +END(WCSNLEN_Z13) + +# if ! HAVE_WCSNLEN_IFUNC +strong_alias (WCSNLEN_Z13, __wcsnlen) +weak_alias (__wcsnlen, wcsnlen) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcsnlen.c b/sysdeps/s390/wcsnlen.c similarity index 70% rename from sysdeps/s390/multiarch/wcsnlen.c rename to sysdeps/s390/wcsnlen.c index 5234074b1f..b5c8ad9fde 100644 --- a/sysdeps/s390/multiarch/wcsnlen.c +++ b/sysdeps/s390/wcsnlen.c @@ -16,13 +16,24 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCSNLEN_IFUNC # include # include -s390_vx_libc_ifunc (__wcsnlen) -weak_alias (__wcsnlen, wcsnlen) +# if HAVE_WCSNLEN_C +extern __typeof (__wcsnlen) WCSNLEN_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_WCSNLEN_Z13 +extern __typeof (__wcsnlen) WCSNLEN_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__wcsnlen, __wcsnlen, + (HAVE_WCSNLEN_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCSNLEN_Z13 + : WCSNLEN_DEFAULT + ) +weak_alias (__wcsnlen, wcsnlen) +#endif From patchwork Fri Nov 30 15:58:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006045 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-97775-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="bdzEhFGJ"; 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 435zhh0dFwz9sBZ for ; Sat, 1 Dec 2018 03:03:47 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=rZabeAIpaNPO+xsAy1qKrSnEnrig8CS pD7uX31LoPxM8eXtbIG9b2htZKOfVe1LbI+SAWznGvQuDyqeqW3PvjK5q1Whj8qa gVLTPFD3C8dhSCZAJLNT/Ht95v/V/8LcZ3WtsojjIhe+o0Y5GJOAUGXgk/aoSV4F gy2IDCt2BiQQ= 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=WOEmx3arbr3XzG3NRN4wyoz7spk=; b=bdzEh FGJ4bCRFLlheFIfs+wyeywULh3wfjQWo+RVKEVxxmfUYFa5BgTnTvgz0Xi5VK6LU nmUJPknzqkfzIDM8QQ+uLBi26R8AXcU9ouaHzjPGFno+26MAjzyqw6K++u1tE+vK nme7Phnx1NMozld+f5FQYJ4b036erheDvRSKzY= Received: (qmail 84060 invoked by alias); 30 Nov 2018 16:01:18 -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 37689 invoked by uid 89); 30 Nov 2018 16:00:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=unavailable version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 38/56] S390: Refactor wcscpy ifunc handling. Date: Fri, 30 Nov 2018 16:58:16 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0028-0000-0000-00000323FCB6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0029-0000-0000-000023E01263 Message-Id: <1543593514-10251-39-git-send-email-stli@linux.ibm.com> The ifunc handling for wcscpy is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcscpy variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcscpy variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcscpy. * sysdeps/s390/multiarch/wcscpy-c.c: Move to ... * sysdeps/s390/wcscpy-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcscpy-vx.S: Move to ... * sysdeps/s390/wcscpy-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcscpy.c: Move to ... * sysdeps/s390/wcscpy.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcscpy.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcscpy.h | 53 ++++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcscpy-c.c | 10 +++-- sysdeps/s390/{multiarch => }/wcscpy-vx.S | 15 ++++--- sysdeps/s390/{multiarch => }/wcscpy.c | 21 +++++++--- 7 files changed, 101 insertions(+), 19 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcscpy.h rename sysdeps/s390/{multiarch => }/wcscpy-c.c (86%) rename sysdeps/s390/{multiarch => }/wcscpy-vx.S (95%) rename sysdeps/s390/{multiarch => }/wcscpy.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 590d2207b7..f2fc88af26 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -84,5 +84,6 @@ endif ifeq ($(subdir),wcsmbs) sysdep_routines += wcslen wcslen-vx wcslen-c \ - wcsnlen wcsnlen-vx wcsnlen-c + wcsnlen wcsnlen-vx wcsnlen-c \ + wcscpy wcscpy-vx wcscpy-c endif diff --git a/sysdeps/s390/ifunc-wcscpy.h b/sysdeps/s390/ifunc-wcscpy.h new file mode 100644 index 0000000000..fba7c9c7a7 --- /dev/null +++ b/sysdeps/s390/ifunc-wcscpy.h @@ -0,0 +1,53 @@ +/* wcscpy variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCSCPY_IFUNC 1 +#else +# define HAVE_WCSCPY_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCSCPY_IFUNC_AND_VX_SUPPORT HAVE_WCSCPY_IFUNC +#else +# define HAVE_WCSCPY_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCSCPY_DEFAULT WCSCPY_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WCSCPY_C 1 +# define HAVE_WCSCPY_Z13 1 +#else +# define WCSCPY_DEFAULT WCSCPY_C +# define HAVE_WCSCPY_C 1 +# define HAVE_WCSCPY_Z13 HAVE_WCSCPY_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCSCPY_C +# define WCSCPY_C __wcscpy_c +#else +# define WCSCPY_C NULL +#endif + +#if HAVE_WCSCPY_Z13 +# define WCSCPY_Z13 __wcscpy_vx +#else +# define WCSCPY_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index ce2e7ce5f4..8828897a59 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcscpy wcscpy-vx wcscpy-c \ - wcpcpy wcpcpy-vx wcpcpy-c \ +sysdep_routines += wcpcpy wcpcpy-vx wcpcpy-c \ wcsncpy wcsncpy-vx wcsncpy-c \ wcpncpy wcpncpy-vx wcpncpy-c \ wcscat wcscat-vx wcscat-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index c199fd0e0b..aac8f4ea46 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -48,6 +48,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -450,6 +451,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCSNLEN_IFUNC */ +#if HAVE_WCSCPY_IFUNC + IFUNC_IMPL (i, name, wcscpy, +# if HAVE_WCSCPY_Z13 + IFUNC_IMPL_ADD (array, i, wcscpy, + dl_hwcap & HWCAP_S390_VX, WCSCPY_Z13) +# endif +# if HAVE_WCSCPY_C + IFUNC_IMPL_ADD (array, i, wcscpy, 1, WCSCPY_C) +# endif + ) +#endif /* HAVE_WCSCPY_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -458,8 +471,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcscpy); - IFUNC_VX_IMPL (wcpcpy); IFUNC_VX_IMPL (wcsncpy); diff --git a/sysdeps/s390/multiarch/wcscpy-c.c b/sysdeps/s390/wcscpy-c.c similarity index 86% rename from sysdeps/s390/multiarch/wcscpy-c.c rename to sysdeps/s390/wcscpy-c.c index 4a510f466b..db2967f47d 100644 --- a/sysdeps/s390/multiarch/wcscpy-c.c +++ b/sysdeps/s390/wcscpy-c.c @@ -16,10 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCSCPY __wcscpy_c +#include + +#if HAVE_WCSCPY_C +# if HAVE_WCSCPY_IFUNC || HAVE_WCSCPY_Z13 +# define WCSCPY WCSCPY_C +# endif -# include -extern __typeof (wcscpy) __wcscpy_c; # include #endif diff --git a/sysdeps/s390/multiarch/wcscpy-vx.S b/sysdeps/s390/wcscpy-vx.S similarity index 95% rename from sysdeps/s390/multiarch/wcscpy-vx.S rename to sysdeps/s390/wcscpy-vx.S index c2e81055be..8fe12f4d8b 100644 --- a/sysdeps/s390/multiarch/wcscpy-vx.S +++ b/sysdeps/s390/wcscpy-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCSCPY_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -37,7 +38,7 @@ -v17=index of zero -v18=part of src */ -ENTRY(__wcscpy_vx) +ENTRY(WCSCPY_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -106,6 +107,10 @@ ENTRY(__wcscpy_vx) br %r14 .Lfallback: - jg __wcscpy_c -END(__wcscpy_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WCSCPY_C +END(WCSCPY_Z13) + +# if ! HAVE_WCSCPY_IFUNC +strong_alias (WCSCPY_Z13, wcscpy) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcscpy.c b/sysdeps/s390/wcscpy.c similarity index 70% rename from sysdeps/s390/multiarch/wcscpy.c rename to sysdeps/s390/wcscpy.c index e69baa6c59..51f07327da 100644 --- a/sysdeps/s390/multiarch/wcscpy.c +++ b/sysdeps/s390/wcscpy.c @@ -16,12 +16,23 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCSCPY_IFUNC # include # include -s390_vx_libc_ifunc2 (__wcscpy, wcscpy) +# if HAVE_WCSCPY_C +extern __typeof (wcscpy) WCSCPY_C attribute_hidden; +# endif + +# if HAVE_WCSCPY_Z13 +extern __typeof (wcscpy) WCSCPY_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (wcscpy, wcscpy, + (HAVE_WCSCPY_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCSCPY_Z13 + : WCSCPY_DEFAULT + ) +#endif From patchwork Fri Nov 30 15:58:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006043 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-97771-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="IYoLwTSu"; 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 435zhH62Fhz9s8r for ; Sat, 1 Dec 2018 03:03:27 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=EcH+Jy3VVvGUvWhvjL8pjEQUy20k+Zr AHVVIZHtDam2qOHCYAHSWNm8p00yV/oyMra2FskrR4MHJcpnSseKH1qBS9LhOW24 fEUsBnotPjUaVT8js0PCv2fyiMhcEmK9IibCCrA20W3xNYd6CO6Yxx16MH8VpYd5 TNFipDM2JZ3k= 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=WSiHrnJGN+RNSrs9mEN+PWjQN3c=; b=IYoLw TSu/VnzxrCDMeqOAQW0d0rqJDp7Hful2U6KYQQZj/epXEs1h8Mb9BhjDCXQ1H6GY OMaiq3gu5MrbeECHtOMO2YgGXx1PKWfHAeOA/4shOKMpjcOiJsRQ/VVBfZpo6bT1 S4BPZSq+NCcp5fTjOXORobRH++cPjQAOve2c/4= Received: (qmail 49631 invoked by alias); 30 Nov 2018 16:00:48 -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 22876 invoked by uid 89); 30 Nov 2018 16:00:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 39/56] S390: Refactor wcpcpy ifunc handling. Date: Fri, 30 Nov 2018 16:58:17 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-0016-0000-0000-0000022F30BE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0017-0000-0000-000032879BD5 Message-Id: <1543593514-10251-40-git-send-email-stli@linux.ibm.com> The ifunc handling for wcpcpy is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcpcpy variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcpcpy variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcpcpy. * sysdeps/s390/multiarch/wcpcpy-c.c: Move to ... * sysdeps/s390/wcpcpy-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcpcpy-vx.S: Move to ... * sysdeps/s390/wcpcpy-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcpcpy.c: Move to ... * sysdeps/s390/wcpcpy.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcpcpy.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcpcpy.h | 53 ++++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcpcpy-c.c | 10 +++-- sysdeps/s390/{multiarch => }/wcpcpy-vx.S | 16 ++++--- sysdeps/s390/{multiarch => }/wcpcpy.c | 23 +++++++--- 7 files changed, 103 insertions(+), 20 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcpcpy.h rename sysdeps/s390/{multiarch => }/wcpcpy-c.c (86%) rename sysdeps/s390/{multiarch => }/wcpcpy-vx.S (94%) rename sysdeps/s390/{multiarch => }/wcpcpy.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index f2fc88af26..0fc0cdaee9 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -85,5 +85,6 @@ endif ifeq ($(subdir),wcsmbs) sysdep_routines += wcslen wcslen-vx wcslen-c \ wcsnlen wcsnlen-vx wcsnlen-c \ - wcscpy wcscpy-vx wcscpy-c + wcscpy wcscpy-vx wcscpy-c \ + wcpcpy wcpcpy-vx wcpcpy-c endif diff --git a/sysdeps/s390/ifunc-wcpcpy.h b/sysdeps/s390/ifunc-wcpcpy.h new file mode 100644 index 0000000000..0d5e2ba1a0 --- /dev/null +++ b/sysdeps/s390/ifunc-wcpcpy.h @@ -0,0 +1,53 @@ +/* wcpcpy variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCPCPY_IFUNC 1 +#else +# define HAVE_WCPCPY_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCPCPY_IFUNC_AND_VX_SUPPORT HAVE_WCPCPY_IFUNC +#else +# define HAVE_WCPCPY_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCPCPY_DEFAULT WCPCPY_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WCPCPY_C 1 +# define HAVE_WCPCPY_Z13 1 +#else +# define WCPCPY_DEFAULT WCPCPY_C +# define HAVE_WCPCPY_C 1 +# define HAVE_WCPCPY_Z13 HAVE_WCPCPY_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCPCPY_C +# define WCPCPY_C __wcpcpy_c +#else +# define WCPCPY_C NULL +#endif + +#if HAVE_WCPCPY_Z13 +# define WCPCPY_Z13 __wcpcpy_vx +#else +# define WCPCPY_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 8828897a59..7d7b05dcf2 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcpcpy wcpcpy-vx wcpcpy-c \ - wcsncpy wcsncpy-vx wcsncpy-c \ +sysdep_routines += wcsncpy wcsncpy-vx wcsncpy-c \ wcpncpy wcpncpy-vx wcpncpy-c \ wcscat wcscat-vx wcscat-c \ wcsncat wcsncat-vx wcsncat-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index aac8f4ea46..656ab59db6 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -49,6 +49,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -463,6 +464,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCSCPY_IFUNC */ +#if HAVE_WCPCPY_IFUNC + IFUNC_IMPL (i, name, wcpcpy, +# if HAVE_WCPCPY_Z13 + IFUNC_IMPL_ADD (array, i, wcpcpy, + dl_hwcap & HWCAP_S390_VX, WCPCPY_Z13) +# endif +# if HAVE_WCPCPY_C + IFUNC_IMPL_ADD (array, i, wcpcpy, 1, WCPCPY_C) +# endif + ) +#endif /* HAVE_WCPCPY_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -471,8 +484,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcpcpy); - IFUNC_VX_IMPL (wcsncpy); IFUNC_VX_IMPL (wcpncpy); diff --git a/sysdeps/s390/multiarch/wcpcpy-c.c b/sysdeps/s390/wcpcpy-c.c similarity index 86% rename from sysdeps/s390/multiarch/wcpcpy-c.c rename to sysdeps/s390/wcpcpy-c.c index e3282fde19..ed1539cde2 100644 --- a/sysdeps/s390/multiarch/wcpcpy-c.c +++ b/sysdeps/s390/wcpcpy-c.c @@ -16,10 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCPCPY __wcpcpy_c +#include + +#if HAVE_WCPCPY_C +# if HAVE_WCPCPY_IFUNC || HAVE_WCPCPY_Z13 +# define WCPCPY WCPCPY_C +# endif -# include -extern __typeof (__wcpcpy) __wcpcpy_c; # include #endif diff --git a/sysdeps/s390/multiarch/wcpcpy-vx.S b/sysdeps/s390/wcpcpy-vx.S similarity index 94% rename from sysdeps/s390/multiarch/wcpcpy-vx.S rename to sysdeps/s390/wcpcpy-vx.S index bff6e85628..5154ad4461 100644 --- a/sysdeps/s390/multiarch/wcpcpy-vx.S +++ b/sysdeps/s390/wcpcpy-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCPCPY_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -37,7 +38,7 @@ -v17=index of zero -v18=part of src */ -ENTRY(__wcpcpy_vx) +ENTRY(WCPCPY_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -109,6 +110,11 @@ ENTRY(__wcpcpy_vx) br %r14 .Lfallback: - jg __wcpcpy_c -END(__wcpcpy_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WCPCPY_C +END(WCPCPY_Z13) + +# if ! HAVE_WCPCPY_IFUNC +strong_alias (WCPCPY_Z13, __wcpcpy) +weak_alias (__wcpcpy, wcpcpy) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcpcpy.c b/sysdeps/s390/wcpcpy.c similarity index 70% rename from sysdeps/s390/multiarch/wcpcpy.c rename to sysdeps/s390/wcpcpy.c index f19d376d85..34ac68b31f 100644 --- a/sysdeps/s390/multiarch/wcpcpy.c +++ b/sysdeps/s390/wcpcpy.c @@ -16,13 +16,24 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCPCPY_IFUNC # include # include -s390_vx_libc_ifunc (__wcpcpy) -weak_alias (__wcpcpy, wcpcpy) +# if HAVE_WCPCPY_C +extern __typeof (__wcpcpy) WCPCPY_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_WCPCPY_Z13 +extern __typeof (__wcpcpy) WCPCPY_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__wcpcpy, __wcpcpy, + (HAVE_WCPCPY_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCPCPY_Z13 + : WCPCPY_DEFAULT + ) +weak_alias (__wcpcpy, wcpcpy) +#endif From patchwork Fri Nov 30 15:58:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006126 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-97812-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="A9MzzhAp"; 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 4362C46clcz9s89 for ; Sat, 1 Dec 2018 04:56:48 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=ZpMcDTbJslCpbS4tFVT/v9x5K7xXn/t mcrKm9NfxQPbHvNhyfDhKYmGi6z4qU1fbQLqTJY8WWggidYL9H2AQfc1z0lql6Cr PvdX1xwUolxmT3yLtcNVrnvWHXDB6vKjfuZfR3syG4mbcIFLdCcktNYAwZkf/A9t AvgO0GX6rEPc= 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=H/XUvElWQjjPVRa1knW49NFRgyQ=; b=A9Mzz hAp1I50520lWNcxHu+dUFIfJPNHG1e84CKTYkxNtyZb6CiZLugV6+dZijreiCiQD QFZvlPuxWthUOMlr+cvrptY8ILQLrSug7eQBgjI1W2ZMjOmvmXJomkAbhaAkfwDN CruSwtuSwAyhUPLGRCRdbMWzfto+/iJqGrJqtQ= Received: (qmail 87322 invoked by alias); 30 Nov 2018 17:56:42 -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 87297 invoked by uid 89); 30 Nov 2018 17:56:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 40/56] S390: Refactor wcsncpy ifunc handling. Date: Fri, 30 Nov 2018 16:58:18 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113015-4275-0000-0000-000002E935DD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-4276-0000-0000-000037F67E7A Message-Id: <1543593514-10251-41-git-send-email-stli@linux.ibm.com> The ifunc handling for wcsncpy is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcsncpy variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcsncpy variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcsncpy. * sysdeps/s390/multiarch/wcsncpy-c.c: Move to ... * sysdeps/s390/wcsncpy-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcsncpy-vx.S: Move to ... * sysdeps/s390/wcsncpy-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcsncpy.c: Move to ... * sysdeps/s390/wcsncpy.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcsncpy.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcsncpy.h | 53 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcsncpy-c.c | 10 +++-- sysdeps/s390/{multiarch => }/wcsncpy-vx.S | 17 +++++--- sysdeps/s390/{multiarch => }/wcsncpy.c | 23 +++++++--- 7 files changed, 103 insertions(+), 21 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcsncpy.h rename sysdeps/s390/{multiarch => }/wcsncpy-c.c (85%) rename sysdeps/s390/{multiarch => }/wcsncpy-vx.S (97%) rename sysdeps/s390/{multiarch => }/wcsncpy.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 0fc0cdaee9..e10ad5b470 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -86,5 +86,6 @@ ifeq ($(subdir),wcsmbs) sysdep_routines += wcslen wcslen-vx wcslen-c \ wcsnlen wcsnlen-vx wcsnlen-c \ wcscpy wcscpy-vx wcscpy-c \ - wcpcpy wcpcpy-vx wcpcpy-c + wcpcpy wcpcpy-vx wcpcpy-c \ + wcsncpy wcsncpy-vx wcsncpy-c endif diff --git a/sysdeps/s390/ifunc-wcsncpy.h b/sysdeps/s390/ifunc-wcsncpy.h new file mode 100644 index 0000000000..d7beca128a --- /dev/null +++ b/sysdeps/s390/ifunc-wcsncpy.h @@ -0,0 +1,53 @@ +/* wcsncpy variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCSNCPY_IFUNC 1 +#else +# define HAVE_WCSNCPY_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCSNCPY_IFUNC_AND_VX_SUPPORT HAVE_WCSNCPY_IFUNC +#else +# define HAVE_WCSNCPY_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCSNCPY_DEFAULT WCSNCPY_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WCSNCPY_C 1 +# define HAVE_WCSNCPY_Z13 1 +#else +# define WCSNCPY_DEFAULT WCSNCPY_C +# define HAVE_WCSNCPY_C 1 +# define HAVE_WCSNCPY_Z13 HAVE_WCSNCPY_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCSNCPY_C +# define WCSNCPY_C __wcsncpy_c +#else +# define WCSNCPY_C NULL +#endif + +#if HAVE_WCSNCPY_Z13 +# define WCSNCPY_Z13 __wcsncpy_vx +#else +# define WCSNCPY_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 7d7b05dcf2..6631fd14d3 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcsncpy wcsncpy-vx wcsncpy-c \ - wcpncpy wcpncpy-vx wcpncpy-c \ +sysdep_routines += wcpncpy wcpncpy-vx wcpncpy-c \ wcscat wcscat-vx wcscat-c \ wcsncat wcsncat-vx wcsncat-c \ wcscmp wcscmp-vx wcscmp-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 656ab59db6..9ebaf4de6f 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -50,6 +50,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -476,6 +477,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCPCPY_IFUNC */ +#if HAVE_WCSNCPY_IFUNC + IFUNC_IMPL (i, name, wcsncpy, +# if HAVE_WCSNCPY_Z13 + IFUNC_IMPL_ADD (array, i, wcsncpy, + dl_hwcap & HWCAP_S390_VX, WCSNCPY_Z13) +# endif +# if HAVE_WCSNCPY_C + IFUNC_IMPL_ADD (array, i, wcsncpy, 1, WCSNCPY_C) +# endif + ) +#endif /* HAVE_WCSNCPY_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -484,8 +497,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcsncpy); - IFUNC_VX_IMPL (wcpncpy); IFUNC_VX_IMPL (wcscat); diff --git a/sysdeps/s390/multiarch/wcsncpy-c.c b/sysdeps/s390/wcsncpy-c.c similarity index 85% rename from sysdeps/s390/multiarch/wcsncpy-c.c rename to sysdeps/s390/wcsncpy-c.c index 6b89b8c14b..4d0ddb09ec 100644 --- a/sysdeps/s390/multiarch/wcsncpy-c.c +++ b/sysdeps/s390/wcsncpy-c.c @@ -16,10 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCSNCPY __wcsncpy_c +#include + +#if HAVE_WCSNCPY_C +# if HAVE_WCSNCPY_IFUNC || HAVE_WCSNCPY_Z13 +# define WCSNCPY WCSNCPY_C +# endif -# include -extern __typeof (__wcsncpy) __wcsncpy_c; # include #endif diff --git a/sysdeps/s390/multiarch/wcsncpy-vx.S b/sysdeps/s390/wcsncpy-vx.S similarity index 97% rename from sysdeps/s390/multiarch/wcsncpy-vx.S rename to sysdeps/s390/wcsncpy-vx.S index b3400d50d9..9bcbdbf322 100644 --- a/sysdeps/s390/multiarch/wcsncpy-vx.S +++ b/sysdeps/s390/wcsncpy-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCSNCPY_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -40,7 +41,7 @@ -v18=part of src -v31=register save area for r6, r7 */ -ENTRY(__wcsncpy_vx) +ENTRY(WCSNCPY_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -217,7 +218,11 @@ ENTRY(__wcsncpy_vx) j .Llt64 .Lfallback: - jg __wcsncpy_c -END(__wcsncpy_vx) - -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WCSNCPY_C +END(WCSNCPY_Z13) + +# if ! HAVE_WCSNCPY_IFUNC +strong_alias (WCSNCPY_Z13, __wcsncpy) +weak_alias (__wcsncpy, wcsncpy) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcsncpy.c b/sysdeps/s390/wcsncpy.c similarity index 70% rename from sysdeps/s390/multiarch/wcsncpy.c rename to sysdeps/s390/wcsncpy.c index 7209c7d431..e011de7ee7 100644 --- a/sysdeps/s390/multiarch/wcsncpy.c +++ b/sysdeps/s390/wcsncpy.c @@ -16,13 +16,24 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCSNCPY_IFUNC # include # include -s390_vx_libc_ifunc (__wcsncpy) -weak_alias (__wcsncpy, wcsncpy) +# if HAVE_WCSNCPY_C +extern __typeof (__wcsncpy) WCSNCPY_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_WCSNCPY_Z13 +extern __typeof (__wcsncpy) WCSNCPY_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__wcsncpy, __wcsncpy, + (HAVE_WCSNCPY_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCSNCPY_Z13 + : WCSNCPY_DEFAULT + ) +weak_alias (__wcsncpy, wcsncpy) +#endif From patchwork Fri Nov 30 15:58:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006053 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-97781-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="FF8ooNY2"; 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 435zkc4X5cz9s8r for ; Sat, 1 Dec 2018 03:05:28 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=OTuTdVoz69r/HW5QfeuVVJuYI5idQEQ gAJyCA/Diz/KupXrurd6N4e55P2c2pxMffhftwAotln9AI1XWBzLq7QSOQhdo4cI GWdf3Ura4T0At9gPOoQNfYRto6zcxV25ydi87kGdF86a27G7UwbA0FF//d/e14qj fpSZ+BMicgNY= 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=lRFCcR6ftkJzyW/V20wQ+XmzXG8=; b=FF8oo NY2z+piCtI0SGnwwHESDBwkg5r+4DWDbq2EHdFDSlWRbmuQs/gdWS9JE0EtWUJkV /gnKJbH/7oLChvPDDuqnJmiuFwonH/ZmAKrVL7s9s2eF28+CoIn60C5upV5OVlNR Om/xlEeLalTG9khuyd3mdiWxFXMSemTVOEQY5U= Received: (qmail 96696 invoked by alias); 30 Nov 2018 16:02:34 -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 96468 invoked by uid 89); 30 Nov 2018 16:02:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 41/56] S390: Refactor wcpncpy ifunc handling. Date: Fri, 30 Nov 2018 16:58:19 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0020-0000-0000-000002F039C2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113015-0021-0000-0000-0000213FA03F Message-Id: <1543593514-10251-42-git-send-email-stli@linux.ibm.com> The ifunc handling for wcpncpy is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcpncpy variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcpncpy variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcpncpy. * sysdeps/s390/multiarch/wcpncpy-c.c: Move to ... * sysdeps/s390/wcpncpy-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcpncpy-vx.S: Move to ... * sysdeps/s390/wcpncpy-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcpncpy.c: Move to ... * sysdeps/s390/wcpncpy.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcpncpy.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcpncpy.h | 53 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcpncpy-c.c | 10 +++-- sysdeps/s390/{multiarch => }/wcpncpy-vx.S | 16 ++++--- sysdeps/s390/{multiarch => }/wcpncpy.c | 23 +++++++--- 7 files changed, 103 insertions(+), 20 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcpncpy.h rename sysdeps/s390/{multiarch => }/wcpncpy-c.c (85%) rename sysdeps/s390/{multiarch => }/wcpncpy-vx.S (97%) rename sysdeps/s390/{multiarch => }/wcpncpy.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index e10ad5b470..e49b1bd26b 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -87,5 +87,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \ wcsnlen wcsnlen-vx wcsnlen-c \ wcscpy wcscpy-vx wcscpy-c \ wcpcpy wcpcpy-vx wcpcpy-c \ - wcsncpy wcsncpy-vx wcsncpy-c + wcsncpy wcsncpy-vx wcsncpy-c \ + wcpncpy wcpncpy-vx wcpncpy-c endif diff --git a/sysdeps/s390/ifunc-wcpncpy.h b/sysdeps/s390/ifunc-wcpncpy.h new file mode 100644 index 0000000000..0dd5633aa9 --- /dev/null +++ b/sysdeps/s390/ifunc-wcpncpy.h @@ -0,0 +1,53 @@ +/* wcpncpy variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCPNCPY_IFUNC 1 +#else +# define HAVE_WCPNCPY_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCPNCPY_IFUNC_AND_VX_SUPPORT HAVE_WCPNCPY_IFUNC +#else +# define HAVE_WCPNCPY_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCPNCPY_DEFAULT WCPNCPY_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WCPNCPY_C 1 +# define HAVE_WCPNCPY_Z13 1 +#else +# define WCPNCPY_DEFAULT WCPNCPY_C +# define HAVE_WCPNCPY_C 1 +# define HAVE_WCPNCPY_Z13 HAVE_WCPNCPY_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCPNCPY_C +# define WCPNCPY_C __wcpncpy_c +#else +# define WCPNCPY_C NULL +#endif + +#if HAVE_WCPNCPY_Z13 +# define WCPNCPY_Z13 __wcpncpy_vx +#else +# define WCPNCPY_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 6631fd14d3..158fb49552 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcpncpy wcpncpy-vx wcpncpy-c \ - wcscat wcscat-vx wcscat-c \ +sysdep_routines += wcscat wcscat-vx wcscat-c \ wcsncat wcsncat-vx wcsncat-c \ wcscmp wcscmp-vx wcscmp-c \ wcsncmp wcsncmp-vx wcsncmp-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 9ebaf4de6f..e60238fcde 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -51,6 +51,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -489,6 +490,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCSNCPY_IFUNC */ +#if HAVE_WCPNCPY_IFUNC + IFUNC_IMPL (i, name, wcpncpy, +# if HAVE_WCPNCPY_Z13 + IFUNC_IMPL_ADD (array, i, wcpncpy, + dl_hwcap & HWCAP_S390_VX, WCPNCPY_Z13) +# endif +# if HAVE_WCPNCPY_C + IFUNC_IMPL_ADD (array, i, wcpncpy, 1, WCPNCPY_C) +# endif + ) +#endif /* HAVE_WCPNCPY_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -497,8 +510,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcpncpy); - IFUNC_VX_IMPL (wcscat); IFUNC_VX_IMPL (wcsncat); diff --git a/sysdeps/s390/multiarch/wcpncpy-c.c b/sysdeps/s390/wcpncpy-c.c similarity index 85% rename from sysdeps/s390/multiarch/wcpncpy-c.c rename to sysdeps/s390/wcpncpy-c.c index 1f44bacea9..d03359217e 100644 --- a/sysdeps/s390/multiarch/wcpncpy-c.c +++ b/sysdeps/s390/wcpncpy-c.c @@ -16,10 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCPNCPY __wcpncpy_c +#include + +#if HAVE_WCPNCPY_C +# if HAVE_WCPNCPY_IFUNC || HAVE_WCPNCPY_Z13 +# define WCPNCPY WCPNCPY_C +# endif -# include -extern __typeof (__wcpncpy) __wcpncpy_c; # include #endif diff --git a/sysdeps/s390/multiarch/wcpncpy-vx.S b/sysdeps/s390/wcpncpy-vx.S similarity index 97% rename from sysdeps/s390/multiarch/wcpncpy-vx.S rename to sysdeps/s390/wcpncpy-vx.S index 004f512e1f..7b5e4ad32d 100644 --- a/sysdeps/s390/multiarch/wcpncpy-vx.S +++ b/sysdeps/s390/wcpncpy-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCPNCPY_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -38,7 +39,7 @@ -%r6 = loaded bytes -%r7 = border, tmp */ -ENTRY(__wcpncpy_vx) +ENTRY(WCPNCPY_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -217,6 +218,11 @@ ENTRY(__wcpncpy_vx) j .Llt64 .Lfallback: - jg __wcpncpy_c -END(__wcpncpy_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WCPNCPY_C +END(WCPNCPY_Z13) + +# if ! HAVE_WCPNCPY_IFUNC +strong_alias (WCPNCPY_Z13, __wcpncpy) +weak_alias (__wcpncpy, wcpncpy) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcpncpy.c b/sysdeps/s390/wcpncpy.c similarity index 70% rename from sysdeps/s390/multiarch/wcpncpy.c rename to sysdeps/s390/wcpncpy.c index b72265fbe9..08d097dd2c 100644 --- a/sysdeps/s390/multiarch/wcpncpy.c +++ b/sysdeps/s390/wcpncpy.c @@ -16,13 +16,24 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCPNCPY_IFUNC # include # include -s390_vx_libc_ifunc (__wcpncpy) -weak_alias (__wcpncpy, wcpncpy) +# if HAVE_WCPNCPY_C +extern __typeof (__wcpncpy) WCPNCPY_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_WCPNCPY_Z13 +extern __typeof (__wcpncpy) WCPNCPY_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__wcpncpy, __wcpncpy, + (HAVE_WCPNCPY_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCPNCPY_Z13 + : WCPNCPY_DEFAULT + ) +weak_alias (__wcpncpy, wcpncpy) +#endif From patchwork Fri Nov 30 15:58:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006092 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-97804-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="GTqGa76v"; 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 436153186Dz9sD9 for ; Sat, 1 Dec 2018 04:06:30 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=Z7ty6/wQdRBLP+6hKsDBREP5ZvBAqOQ a6/1Ps7DpbTaywcX8PDH+kv0dMeVUOltCZUoeak+OtHa9hG1kLV8GNu/FtVMuNiK uXh7asg5A3AiDZ5nsS1Yq6AFYAv6fLs13+Lbh8Tgge9jMWaqhzj3DSFLko4neMvE /AQWP8KwORk4= 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=njpB41u2HOG7JQVAdio2jFe0mAM=; b=GTqGa 76v/HC89dcVKT/xaNA5jvlUNy67mZsfLDEhn3vxNoKNfl/pZYyIu+D9MMPZk89xl GVJ+5iTcXevXhRnrin8z6xj3rbf6tJnUXJCM87/FFYgy1g54PbOhpu6yzFIPZekd reoVNKNccDK8RsugJyTH0Pe7CT15JJcNncRhUQ= Received: (qmail 64455 invoked by alias); 30 Nov 2018 17:06:25 -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 64438 invoked by uid 89); 30 Nov 2018 17:06:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 42/56] S390: Refactor wcscat ifunc handling. Date: Fri, 30 Nov 2018 16:58:20 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0016-0000-0000-0000022F30BF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-0017-0000-0000-000032879BD9 Message-Id: <1543593514-10251-43-git-send-email-stli@linux.ibm.com> The ifunc handling for wcscat is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcscat variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcscat variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcscat. * sysdeps/s390/multiarch/wcscat-c.c: Move to ... * sysdeps/s390/wcscat-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcscat-vx.S: Move to ... * sysdeps/s390/wcscat-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcscat.c: Move to ... * sysdeps/s390/wcscat.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcscat.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcscat.h | 53 ++++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcscat-c.c | 10 +++-- sysdeps/s390/{multiarch => }/wcscat-vx.S | 16 ++++--- sysdeps/s390/{multiarch => }/wcscat.c | 23 +++++++--- 7 files changed, 103 insertions(+), 20 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcscat.h rename sysdeps/s390/{multiarch => }/wcscat-c.c (86%) rename sysdeps/s390/{multiarch => }/wcscat-vx.S (96%) rename sysdeps/s390/{multiarch => }/wcscat.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index e49b1bd26b..f393a2b1ef 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -88,5 +88,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \ wcscpy wcscpy-vx wcscpy-c \ wcpcpy wcpcpy-vx wcpcpy-c \ wcsncpy wcsncpy-vx wcsncpy-c \ - wcpncpy wcpncpy-vx wcpncpy-c + wcpncpy wcpncpy-vx wcpncpy-c \ + wcscat wcscat-vx wcscat-c endif diff --git a/sysdeps/s390/ifunc-wcscat.h b/sysdeps/s390/ifunc-wcscat.h new file mode 100644 index 0000000000..fecae21403 --- /dev/null +++ b/sysdeps/s390/ifunc-wcscat.h @@ -0,0 +1,53 @@ +/* wcscat variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCSCAT_IFUNC 1 +#else +# define HAVE_WCSCAT_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCSCAT_IFUNC_AND_VX_SUPPORT HAVE_WCSCAT_IFUNC +#else +# define HAVE_WCSCAT_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCSCAT_DEFAULT WCSCAT_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WCSCAT_C 1 +# define HAVE_WCSCAT_Z13 1 +#else +# define WCSCAT_DEFAULT WCSCAT_C +# define HAVE_WCSCAT_C 1 +# define HAVE_WCSCAT_Z13 HAVE_WCSCAT_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCSCAT_C +# define WCSCAT_C __wcscat_c +#else +# define WCSCAT_C NULL +#endif + +#if HAVE_WCSCAT_Z13 +# define WCSCAT_Z13 __wcscat_vx +#else +# define WCSCAT_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 158fb49552..617017496c 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcscat wcscat-vx wcscat-c \ - wcsncat wcsncat-vx wcsncat-c \ +sysdep_routines += wcsncat wcsncat-vx wcsncat-c \ wcscmp wcscmp-vx wcscmp-c \ wcsncmp wcsncmp-vx wcsncmp-c \ wcschr wcschr-vx wcschr-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index e60238fcde..b05bd35fd8 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -52,6 +52,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -502,6 +503,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCPNCPY_IFUNC */ +#if HAVE_WCSCAT_IFUNC + IFUNC_IMPL (i, name, wcscat, +# if HAVE_WCSCAT_Z13 + IFUNC_IMPL_ADD (array, i, wcscat, + dl_hwcap & HWCAP_S390_VX, WCSCAT_Z13) +# endif +# if HAVE_WCSCAT_C + IFUNC_IMPL_ADD (array, i, wcscat, 1, WCSCAT_C) +# endif + ) +#endif /* HAVE_WCSCAT_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -510,8 +523,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcscat); - IFUNC_VX_IMPL (wcsncat); IFUNC_VX_IMPL (wcscmp); diff --git a/sysdeps/s390/multiarch/wcscat-c.c b/sysdeps/s390/wcscat-c.c similarity index 86% rename from sysdeps/s390/multiarch/wcscat-c.c rename to sysdeps/s390/wcscat-c.c index 9a31c65a0b..bc1a50b1a5 100644 --- a/sysdeps/s390/multiarch/wcscat-c.c +++ b/sysdeps/s390/wcscat-c.c @@ -16,10 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCSCAT __wcscat_c +#include + +#if HAVE_WCSCAT_C +# if HAVE_WCSCAT_IFUNC || HAVE_WCSCAT_Z13 +# define WCSCAT WCSCAT_C +# endif -# include -extern __typeof (__wcscat) __wcscat_c; # include #endif diff --git a/sysdeps/s390/multiarch/wcscat-vx.S b/sysdeps/s390/wcscat-vx.S similarity index 96% rename from sysdeps/s390/multiarch/wcscat-vx.S rename to sysdeps/s390/wcscat-vx.S index 2164a8da41..4e40d69e84 100644 --- a/sysdeps/s390/multiarch/wcscat-vx.S +++ b/sysdeps/s390/wcscat-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCSCAT_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -37,7 +38,7 @@ -v17=index of zero -v18=part of src */ -ENTRY(__wcscat_vx) +ENTRY(WCSCAT_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -170,6 +171,11 @@ ENTRY(__wcscat_vx) lgr %r2,%r0 /* Load saved dest-ptr. */ br %r14 .Lfallback: - jg __wcscat_c -END(__wcscat_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WCSCAT_C +END(WCSCAT_Z13) + +# if ! HAVE_WCSCAT_IFUNC +strong_alias (WCSCAT_Z13, __wcscat) +weak_alias (__wcscat, wcscat) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcscat.c b/sysdeps/s390/wcscat.c similarity index 70% rename from sysdeps/s390/multiarch/wcscat.c rename to sysdeps/s390/wcscat.c index 33e4f6da3f..3741210a17 100644 --- a/sysdeps/s390/multiarch/wcscat.c +++ b/sysdeps/s390/wcscat.c @@ -16,13 +16,24 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCSCAT_IFUNC # include # include -s390_vx_libc_ifunc (__wcscat) -weak_alias (__wcscat, wcscat) +# if HAVE_WCSCAT_C +extern __typeof (__wcscat) WCSCAT_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_WCSCAT_Z13 +extern __typeof (__wcscat) WCSCAT_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__wcscat, __wcscat, + (HAVE_WCSCAT_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCSCAT_Z13 + : WCSCAT_DEFAULT + ) +weak_alias (__wcscat, wcscat) +#endif From patchwork Fri Nov 30 15:58:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006049 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-97777-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="NyT0ZEcw"; 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 435zjp1HkRz9s8r for ; Sat, 1 Dec 2018 03:04:45 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=JWfKIFKgPbn/U2B+ZxM8pCFJIetG3lq Db9AF3Ul0fE2jJYU7Xo18Pf+4gkXSBPen/yBASFuBT59HVbo3VCAxTZPhYUN/pdR UP6/i602F2oeW981s62nHIVojVyjN8ftWtg4beDLjnjuxs56pxVDsxYECTLaotaL nes0DRTLz09k= 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=PVq5orklq3qqYENxcBTjljNELsA=; b=NyT0Z EcwUqUPDAyPzD+yYN/oUCXPXVSDv07X5tVMEGs1EHUmFzikzZrjPl837nV9SgacS YKb0kr+GbBO1eFmNFMJqfQOCLgeGRusCBjDrCpxdANV9u9pjmrGGJtesf5BhBtGz nAj9TeSpIqtd8kUUs8jamPDLwupzXdRroVKu8Q= Received: (qmail 94346 invoked by alias); 30 Nov 2018 16:02:15 -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 94215 invoked by uid 89); 30 Nov 2018 16:02:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 43/56] S390: Refactor wcsncat ifunc handling. Date: Fri, 30 Nov 2018 16:58:21 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0012-0000-0000-000002D2B61C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-0013-0000-0000-000021080471 Message-Id: <1543593514-10251-44-git-send-email-stli@linux.ibm.com> The ifunc handling for wcsncat is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcsncat variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcsncat variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcsncat. * sysdeps/s390/multiarch/wcsncat-c.c: Move to ... * sysdeps/s390/wcsncat-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcsncat-vx.S: Move to ... * sysdeps/s390/wcsncat-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcsncat.c: Move to ... * sysdeps/s390/wcsncat.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcsncat.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcsncat.h | 53 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcsncat-c.c | 10 +++-- sysdeps/s390/{multiarch => }/wcsncat-vx.S | 15 ++++--- sysdeps/s390/{multiarch => }/wcsncat.c | 21 ++++++--- 7 files changed, 101 insertions(+), 19 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcsncat.h rename sysdeps/s390/{multiarch => }/wcsncat-c.c (85%) rename sysdeps/s390/{multiarch => }/wcsncat-vx.S (97%) rename sysdeps/s390/{multiarch => }/wcsncat.c (69%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index f393a2b1ef..cb8dd2134f 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -89,5 +89,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \ wcpcpy wcpcpy-vx wcpcpy-c \ wcsncpy wcsncpy-vx wcsncpy-c \ wcpncpy wcpncpy-vx wcpncpy-c \ - wcscat wcscat-vx wcscat-c + wcscat wcscat-vx wcscat-c \ + wcsncat wcsncat-vx wcsncat-c endif diff --git a/sysdeps/s390/ifunc-wcsncat.h b/sysdeps/s390/ifunc-wcsncat.h new file mode 100644 index 0000000000..99495e0e64 --- /dev/null +++ b/sysdeps/s390/ifunc-wcsncat.h @@ -0,0 +1,53 @@ +/* wcsncat variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCSNCAT_IFUNC 1 +#else +# define HAVE_WCSNCAT_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCSNCAT_IFUNC_AND_VX_SUPPORT HAVE_WCSNCAT_IFUNC +#else +# define HAVE_WCSNCAT_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCSNCAT_DEFAULT WCSNCAT_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WCSNCAT_C 1 +# define HAVE_WCSNCAT_Z13 1 +#else +# define WCSNCAT_DEFAULT WCSNCAT_C +# define HAVE_WCSNCAT_C 1 +# define HAVE_WCSNCAT_Z13 HAVE_WCSNCAT_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCSNCAT_C +# define WCSNCAT_C __wcsncat_c +#else +# define WCSNCAT_C NULL +#endif + +#if HAVE_WCSNCAT_Z13 +# define WCSNCAT_Z13 __wcsncat_vx +#else +# define WCSNCAT_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 617017496c..6cb75950c2 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcsncat wcsncat-vx wcsncat-c \ - wcscmp wcscmp-vx wcscmp-c \ +sysdep_routines += wcscmp wcscmp-vx wcscmp-c \ wcsncmp wcsncmp-vx wcsncmp-c \ wcschr wcschr-vx wcschr-c \ wcschrnul wcschrnul-vx wcschrnul-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index b05bd35fd8..7b7b1e7497 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -53,6 +53,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -515,6 +516,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCSCAT_IFUNC */ +#if HAVE_WCSNCAT_IFUNC + IFUNC_IMPL (i, name, wcsncat, +# if HAVE_WCSNCAT_Z13 + IFUNC_IMPL_ADD (array, i, wcsncat, + dl_hwcap & HWCAP_S390_VX, WCSNCAT_Z13) +# endif +# if HAVE_WCSNCAT_C + IFUNC_IMPL_ADD (array, i, wcsncat, 1, WCSNCAT_C) +# endif + ) +#endif /* HAVE_WCSNCAT_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -523,8 +536,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcsncat); - IFUNC_VX_IMPL (wcscmp); IFUNC_VX_IMPL (wcsncmp); diff --git a/sysdeps/s390/multiarch/wcsncat-c.c b/sysdeps/s390/wcsncat-c.c similarity index 85% rename from sysdeps/s390/multiarch/wcsncat-c.c rename to sysdeps/s390/wcsncat-c.c index 2cf1a76385..5782d5cb28 100644 --- a/sysdeps/s390/multiarch/wcsncat-c.c +++ b/sysdeps/s390/wcsncat-c.c @@ -16,10 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCSNCAT __wcsncat_c +#include + +#if HAVE_WCSNCAT_C +# if HAVE_WCSNCAT_IFUNC || HAVE_WCSNCAT_Z13 +# define WCSNCAT WCSNCAT_C +# endif -# include -extern __typeof (wcsncat) __wcsncat_c; # include #endif diff --git a/sysdeps/s390/multiarch/wcsncat-vx.S b/sysdeps/s390/wcsncat-vx.S similarity index 97% rename from sysdeps/s390/multiarch/wcsncat-vx.S rename to sysdeps/s390/wcsncat-vx.S index 1d3935690d..7c89d3d856 100644 --- a/sysdeps/s390/multiarch/wcsncat-vx.S +++ b/sysdeps/s390/wcsncat-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCSNCAT_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -40,7 +41,7 @@ -v18=part of src -v31=register save area for r6, r7 */ -ENTRY(__wcsncat_vx) +ENTRY(WCSNCAT_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -260,6 +261,10 @@ ENTRY(__wcsncat_vx) j .Lcpy_lt64 .Lfallback: - jg __wcsncat_c -END(__wcsncat_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WCSNCAT_C +END(WCSNCAT_Z13) + +# if ! HAVE_WCSNCAT_IFUNC +strong_alias (WCSNCAT_Z13, wcsncat) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcsncat.c b/sysdeps/s390/wcsncat.c similarity index 69% rename from sysdeps/s390/multiarch/wcsncat.c rename to sysdeps/s390/wcsncat.c index c49b8ff786..722429fd5b 100644 --- a/sysdeps/s390/multiarch/wcsncat.c +++ b/sysdeps/s390/wcsncat.c @@ -16,12 +16,23 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCSNCAT_IFUNC # include # include -s390_vx_libc_ifunc2 (__wcsncat, wcsncat) +# if HAVE_WCSNCAT_C +extern __typeof (wcsncat) WCSNCAT_C attribute_hidden; +# endif + +# if HAVE_WCSNCAT_Z13 +extern __typeof (wcsncat) WCSNCAT_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (wcsncat, wcsncat, + (HAVE_WCSNCAT_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCSNCAT_Z13 + : WCSNCAT_DEFAULT + ) +#endif From patchwork Fri Nov 30 15:58:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006084 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-97801-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="fyYDcWwF"; 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 4360bF6BKvz9s9J for ; Sat, 1 Dec 2018 03:44:09 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=Yl/rwCF6Lzz50neiBEdznf627mSKR2+ gpDUA27XydS+c1S54ZCMOqnaUjyKeQE2r13AAWH/5Bz8majUBqyyrTzvNcotf+1S D8Z2JaYVU+r1Kc+O0qD3Sm10u/cW4sAGKC430nShK5Et8xCH5+vpPf0HRR9bKp2K 3/QAx4lrq3ik= 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=kbx65D0Tf0QDvvECb76wH4HUwTU=; b=fyYDc WwFXV7OS29lwvnNIFtvNL3n1N1ppkWAj/35XC/d9Nm/SV2SjH/ExlZFRoJYvSx7e A4+lnYU5DnF+SNNFbCc8DJAoH4MOvNmryfbNVA8dPDoxiDu9/VeLdXf1RkXYNYsZ bLQthScrdJCTSAngOFwWcuV8bqE2Nqj8xDGpPg= Received: (qmail 21791 invoked by alias); 30 Nov 2018 16:44:02 -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 21764 invoked by uid 89); 30 Nov 2018 16:44:01 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 44/56] S390: Refactor wcscmp ifunc handling. Date: Fri, 30 Nov 2018 16:58:22 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0020-0000-0000-000002F039C4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-0021-0000-0000-0000213FA041 Message-Id: <1543593514-10251-45-git-send-email-stli@linux.ibm.com> The ifunc handling for wcscmp is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. Glibc internal calls will then also use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcscmp variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcscmp variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcscmp. * sysdeps/s390/multiarch/wcscmp-c.c: Move to ... * sysdeps/s390/wcscmp-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcscmp-vx.S: Move to ... * sysdeps/s390/wcscmp-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcscmp.c: Move to ... * sysdeps/s390/wcscmp.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcscmp.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcscmp.h | 52 ++++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcscmp-c.c | 24 ++++++----- sysdeps/s390/{multiarch => }/wcscmp-vx.S | 18 ++++++-- sysdeps/s390/{multiarch => }/wcscmp.c | 23 ++++++++--- 7 files changed, 112 insertions(+), 26 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcscmp.h rename sysdeps/s390/{multiarch => }/wcscmp-c.c (72%) rename sysdeps/s390/{multiarch => }/wcscmp-vx.S (92%) rename sysdeps/s390/{multiarch => }/wcscmp.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index cb8dd2134f..00398ba6c2 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -90,5 +90,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \ wcsncpy wcsncpy-vx wcsncpy-c \ wcpncpy wcpncpy-vx wcpncpy-c \ wcscat wcscat-vx wcscat-c \ - wcsncat wcsncat-vx wcsncat-c + wcsncat wcsncat-vx wcsncat-c \ + wcscmp wcscmp-vx wcscmp-c endif diff --git a/sysdeps/s390/ifunc-wcscmp.h b/sysdeps/s390/ifunc-wcscmp.h new file mode 100644 index 0000000000..99fe021302 --- /dev/null +++ b/sysdeps/s390/ifunc-wcscmp.h @@ -0,0 +1,52 @@ +/* wcscmp variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCSCMP_IFUNC 1 +#else +# define HAVE_WCSCMP_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCSCMP_IFUNC_AND_VX_SUPPORT HAVE_WCSCMP_IFUNC +#else +# define HAVE_WCSCMP_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCSCMP_DEFAULT WCSCMP_Z13 +# define HAVE_WCSCMP_C 0 +# define HAVE_WCSCMP_Z13 1 +#else +# define WCSCMP_DEFAULT WCSCMP_C +# define HAVE_WCSCMP_C 1 +# define HAVE_WCSCMP_Z13 HAVE_WCSCMP_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCSCMP_C +# define WCSCMP_C __wcscmp_c +#else +# define WCSCMP_C NULL +#endif + +#if HAVE_WCSCMP_Z13 +# define WCSCMP_Z13 __wcscmp_vx +#else +# define WCSCMP_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 6cb75950c2..70162d0eaa 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcscmp wcscmp-vx wcscmp-c \ - wcsncmp wcsncmp-vx wcsncmp-c \ +sysdep_routines += wcsncmp wcsncmp-vx wcsncmp-c \ wcschr wcschr-vx wcschr-c \ wcschrnul wcschrnul-vx wcschrnul-c \ wcsrchr wcsrchr-vx wcsrchr-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 7b7b1e7497..f461063c80 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -54,6 +54,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -528,6 +529,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCSNCAT_IFUNC */ +#if HAVE_WCSCMP_IFUNC + IFUNC_IMPL (i, name, wcscmp, +# if HAVE_WCSCMP_Z13 + IFUNC_IMPL_ADD (array, i, wcscmp, + dl_hwcap & HWCAP_S390_VX, WCSCMP_Z13) +# endif +# if HAVE_WCSCMP_C + IFUNC_IMPL_ADD (array, i, wcscmp, 1, WCSCMP_C) +# endif + ) +#endif /* HAVE_WCSCMP_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -536,8 +549,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcscmp); - IFUNC_VX_IMPL (wcsncmp); IFUNC_VX_IMPL (wcschr); diff --git a/sysdeps/s390/multiarch/wcscmp-c.c b/sysdeps/s390/wcscmp-c.c similarity index 72% rename from sysdeps/s390/multiarch/wcscmp-c.c rename to sysdeps/s390/wcscmp-c.c index ce0817ae97..643ba7a682 100644 --- a/sysdeps/s390/multiarch/wcscmp-c.c +++ b/sysdeps/s390/wcscmp-c.c @@ -16,17 +16,19 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCSCMP __wcscmp_c +#include -# include -extern __typeof (wcscmp) __wcscmp_c; -# undef weak_alias -# define weak_alias(name, alias) -# ifdef SHARED -# undef libc_hidden_def -# define libc_hidden_def(name) \ +#if HAVE_WCSCMP_C +# if HAVE_WCSCMP_IFUNC +# define WCSCMP WCSCMP_C +# undef weak_alias +# define weak_alias(name, alias) +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_def +# define libc_hidden_def(name) \ __hidden_ver1 (__wcscmp_c, __GI___wcscmp, __wcscmp_c); -# endif /* SHARED */ +# endif +# endif + # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/wcscmp-vx.S b/sysdeps/s390/wcscmp-vx.S similarity index 92% rename from sysdeps/s390/multiarch/wcscmp-vx.S rename to sysdeps/s390/wcscmp-vx.S index 14267dbfc7..a2789d8a69 100644 --- a/sysdeps/s390/multiarch/wcscmp-vx.S +++ b/sysdeps/s390/wcscmp-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCSCMP_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -36,7 +37,7 @@ -v17=part of s2 -v18=index of unequal */ -ENTRY(__wcscmp_vx) +ENTRY(WCSCMP_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -127,5 +128,14 @@ ENTRY(__wcscmp_vx) .Lend_equal: lghi %r2,0 br %r14 -END(__wcscmp_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(WCSCMP_Z13) + +# if ! HAVE_WCSCMP_IFUNC +strong_alias (WCSCMP_Z13, __wcscmp) +weak_alias (__wcscmp, wcscmp) +# endif + +# if ! HAVE_WCSCMP_C && defined SHARED && IS_IN (libc) +strong_alias (WCSCMP_Z13, __GI___wcscmp) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcscmp.c b/sysdeps/s390/wcscmp.c similarity index 70% rename from sysdeps/s390/multiarch/wcscmp.c rename to sysdeps/s390/wcscmp.c index 5ee0fd4d88..769c73506e 100644 --- a/sysdeps/s390/multiarch/wcscmp.c +++ b/sysdeps/s390/wcscmp.c @@ -16,15 +16,26 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCSCMP_IFUNC # define __wcscmp __redirect___wcscmp # include # undef __wcscmp # include -s390_vx_libc_ifunc_redirected (__redirect___wcscmp, __wcscmp) -weak_alias (__wcscmp, wcscmp) +# if HAVE_WCSCMP_C +extern __typeof (__redirect___wcscmp) WCSCMP_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_WCSCMP_Z13 +extern __typeof (__redirect___wcscmp) WCSCMP_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect___wcscmp, __wcscmp, + (HAVE_WCSCMP_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCSCMP_Z13 + : WCSCMP_DEFAULT + ) +weak_alias (__wcscmp, wcscmp) +#endif From patchwork Fri Nov 30 15:58:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006044 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-97774-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="KGG/GDoH"; 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 435zhT3tSTz9sBZ for ; Sat, 1 Dec 2018 03:03:37 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=akkDjYzEcr3v/LP7BYD8QsjAqylJ6vc cnA9i2DemM3k28VD6MhnZJdDnEZVtJhIxJn0tadVoablGs2aEpylqvaILeCnRKkA jxWF5KOr3iB0wquBBnlwXU9zUXORDBjo2pvPnX6zCDAPuxg6Jc8Q0JtP6ABaM66h SAr9OcFozo58= 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=q3LBKEQApfCpzvY39ihx/c4q9qs=; b=KGG/G DoHRPp3fplIfhJwHPIeIRLG0E6euHHMTFoadIdbLFxzLuibGhPinr++Q4euQLirY 4Ph8Fndxo+NTuWhPyg1UNLjuw6/GWMv0NAFUSWQB9Ja4J0TKIuvFLS35WB+v7OOP PqP/Hj0hCe11wRWPabIRqigtzN6I+QrB5vGSS0= Received: (qmail 81979 invoked by alias); 30 Nov 2018 16:01:16 -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 38280 invoked by uid 89); 30 Nov 2018 16:00:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 45/56] S390: Refactor wcsncmp ifunc handling. Date: Fri, 30 Nov 2018 16:58:23 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0012-0000-0000-000002D2B61E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-0013-0000-0000-000021080474 Message-Id: <1543593514-10251-46-git-send-email-stli@linux.ibm.com> The ifunc handling for wcsncmp is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcsncmp variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcsncmp variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcsncmp. * sysdeps/s390/multiarch/wcsncmp-c.c: Move to ... * sysdeps/s390/wcsncmp-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcsncmp-vx.S: Move to ... * sysdeps/s390/wcsncmp-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcsncmp.c: Move to ... * sysdeps/s390/wcsncmp.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcsncmp.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcsncmp.h | 52 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcsncmp-c.c | 10 +++-- sysdeps/s390/{multiarch => }/wcsncmp-vx.S | 13 ++++-- sysdeps/s390/{multiarch => }/wcsncmp.c | 21 ++++++--- 7 files changed, 99 insertions(+), 18 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcsncmp.h rename sysdeps/s390/{multiarch => }/wcsncmp-c.c (85%) rename sysdeps/s390/{multiarch => }/wcsncmp-vx.S (97%) rename sysdeps/s390/{multiarch => }/wcsncmp.c (69%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 00398ba6c2..e1253c04be 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -91,5 +91,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \ wcpncpy wcpncpy-vx wcpncpy-c \ wcscat wcscat-vx wcscat-c \ wcsncat wcsncat-vx wcsncat-c \ - wcscmp wcscmp-vx wcscmp-c + wcscmp wcscmp-vx wcscmp-c \ + wcsncmp wcsncmp-vx wcsncmp-c endif diff --git a/sysdeps/s390/ifunc-wcsncmp.h b/sysdeps/s390/ifunc-wcsncmp.h new file mode 100644 index 0000000000..3a22bc9c12 --- /dev/null +++ b/sysdeps/s390/ifunc-wcsncmp.h @@ -0,0 +1,52 @@ +/* wcsncmp variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCSNCMP_IFUNC 1 +#else +# define HAVE_WCSNCMP_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCSNCMP_IFUNC_AND_VX_SUPPORT HAVE_WCSNCMP_IFUNC +#else +# define HAVE_WCSNCMP_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCSNCMP_DEFAULT WCSNCMP_Z13 +# define HAVE_WCSNCMP_C 0 +# define HAVE_WCSNCMP_Z13 1 +#else +# define WCSNCMP_DEFAULT WCSNCMP_C +# define HAVE_WCSNCMP_C 1 +# define HAVE_WCSNCMP_Z13 HAVE_WCSNCMP_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCSNCMP_C +# define WCSNCMP_C __wcsncmp_c +#else +# define WCSNCMP_C NULL +#endif + +#if HAVE_WCSNCMP_Z13 +# define WCSNCMP_Z13 __wcsncmp_vx +#else +# define WCSNCMP_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 70162d0eaa..d1740fa8e4 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcsncmp wcsncmp-vx wcsncmp-c \ - wcschr wcschr-vx wcschr-c \ +sysdep_routines += wcschr wcschr-vx wcschr-c \ wcschrnul wcschrnul-vx wcschrnul-c \ wcsrchr wcsrchr-vx wcsrchr-c \ wcsspn wcsspn-vx wcsspn-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index f461063c80..8c9e788ae5 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -55,6 +55,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -541,6 +542,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCSCMP_IFUNC */ +#if HAVE_WCSNCMP_IFUNC + IFUNC_IMPL (i, name, wcsncmp, +# if HAVE_WCSNCMP_Z13 + IFUNC_IMPL_ADD (array, i, wcsncmp, + dl_hwcap & HWCAP_S390_VX, WCSNCMP_Z13) +# endif +# if HAVE_WCSNCMP_C + IFUNC_IMPL_ADD (array, i, wcsncmp, 1, WCSNCMP_C) +# endif + ) +#endif /* HAVE_WCSNCMP_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -549,8 +562,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcsncmp); - IFUNC_VX_IMPL (wcschr); IFUNC_VX_IMPL (wcschrnul); diff --git a/sysdeps/s390/multiarch/wcsncmp-c.c b/sysdeps/s390/wcsncmp-c.c similarity index 85% rename from sysdeps/s390/multiarch/wcsncmp-c.c rename to sysdeps/s390/wcsncmp-c.c index 92ab5e8b50..a9ccb8de82 100644 --- a/sysdeps/s390/multiarch/wcsncmp-c.c +++ b/sysdeps/s390/wcsncmp-c.c @@ -16,10 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCSNCMP __wcsncmp_c +#include + +#if HAVE_WCSNCMP_C +# if HAVE_WCSNCMP_IFUNC +# define WCSNCMP WCSNCMP_C +# endif -# include -extern __typeof (wcsncmp) __wcsncmp_c; # include #endif diff --git a/sysdeps/s390/multiarch/wcsncmp-vx.S b/sysdeps/s390/wcsncmp-vx.S similarity index 97% rename from sysdeps/s390/multiarch/wcsncmp-vx.S rename to sysdeps/s390/wcsncmp-vx.S index 34c203bc90..9bdd21acef 100644 --- a/sysdeps/s390/multiarch/wcsncmp-vx.S +++ b/sysdeps/s390/wcsncmp-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCSNCMP_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -37,7 +38,7 @@ -v17=part of s2 -v18=index of unequal */ -ENTRY(__wcsncmp_vx) +ENTRY(WCSNCMP_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -173,5 +174,9 @@ ENTRY(__wcsncmp_vx) lghi %r1,-1 locgrl %r2,%r1 br %r14 -END(__wcsncmp_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(WCSNCMP_Z13) + +# if ! HAVE_WCSNCMP_IFUNC +strong_alias (WCSNCMP_Z13, wcsncmp) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcsncmp.c b/sysdeps/s390/wcsncmp.c similarity index 69% rename from sysdeps/s390/multiarch/wcsncmp.c rename to sysdeps/s390/wcsncmp.c index ee5f08c1e4..101db44591 100644 --- a/sysdeps/s390/multiarch/wcsncmp.c +++ b/sysdeps/s390/wcsncmp.c @@ -16,12 +16,23 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCSNCMP_IFUNC # include # include -s390_vx_libc_ifunc2 (__wcsncmp, wcsncmp) +# if HAVE_WCSNCMP_C +extern __typeof (wcsncmp) WCSNCMP_C attribute_hidden; +# endif + +# if HAVE_WCSNCMP_Z13 +extern __typeof (wcsncmp) WCSNCMP_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (wcsncmp, wcsncmp, + (HAVE_WCSNCMP_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCSNCMP_Z13 + : WCSNCMP_DEFAULT + ) +#endif From patchwork Fri Nov 30 15:58:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006056 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-97783-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="E9XYsLCV"; 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 435zkz5fg7z9s8r for ; Sat, 1 Dec 2018 03:05:47 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=t2zLeTbTczxJ+f6rKJFVBAMAaXTNn0h g8NHdMned+uVWbVn0tBhd5YEjnYqEoNZQChT09/UBvl3eDK9LAxIgtYepjXjkG+l mYjrikjkpqIVw6qM2SM9y0Y/LnXZqrbMY4GnW0rZLgExZcc2thPs8/lEPTlmtg8+ waQZqfRl9r6w= 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=bpzJ7buYpzsEmwV1S1+BTQuKp4A=; b=E9XYs LCV6WNw47omph6YmwenOgdAkhSFyNzEsk33Naa36jUpDOhvdodYBmeyytZHVWD4V 29ZEfg2muR7xiDe2v/MgpokhQ9ls2E79MNoyOyh1YdYeSpXACyFz7JnWX3zexFKf HIWHnNMi1apm7VLB/REA3DSmObAYsXWQ7ltuos= Received: (qmail 97008 invoked by alias); 30 Nov 2018 16:02:36 -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 96778 invoked by uid 89); 30 Nov 2018 16:02:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 46/56] S390: Refactor wcschr ifunc handling. Date: Fri, 30 Nov 2018 16:58:24 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0008-0000-0000-0000029B03A8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-0009-0000-0000-000022055466 Message-Id: <1543593514-10251-47-git-send-email-stli@linux.ibm.com> The ifunc handling for wcschr is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. Glibc internal calls will use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcschr variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcschr variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcschr. * sysdeps/s390/multiarch/wcschr-c.c: Move to ... * sysdeps/s390/wcschr-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcschr-vx.S: Move to ... * sysdeps/s390/wcschr-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcschr.c: Move to ... * sysdeps/s390/wcschr.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcschr.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcschr.h | 53 ++++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcschr-c.c | 39 ++++++++++------- sysdeps/s390/{multiarch => }/wcschr-vx.S | 22 +++++++--- sysdeps/s390/{multiarch => }/wcschr.c | 23 +++++++--- 7 files changed, 126 insertions(+), 32 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcschr.h rename sysdeps/s390/{multiarch => }/wcschr-c.c (61%) rename sysdeps/s390/{multiarch => }/wcschr-vx.S (88%) rename sysdeps/s390/{multiarch => }/wcschr.c (71%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index e1253c04be..982e5abfb2 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -92,5 +92,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \ wcscat wcscat-vx wcscat-c \ wcsncat wcsncat-vx wcsncat-c \ wcscmp wcscmp-vx wcscmp-c \ - wcsncmp wcsncmp-vx wcsncmp-c + wcsncmp wcsncmp-vx wcsncmp-c \ + wcschr wcschr-vx wcschr-c endif diff --git a/sysdeps/s390/ifunc-wcschr.h b/sysdeps/s390/ifunc-wcschr.h new file mode 100644 index 0000000000..2fe9110f7c --- /dev/null +++ b/sysdeps/s390/ifunc-wcschr.h @@ -0,0 +1,53 @@ +/* wcschr variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCSCHR_IFUNC 1 +#else +# define HAVE_WCSCHR_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCSCHR_IFUNC_AND_VX_SUPPORT HAVE_WCSCHR_IFUNC +#else +# define HAVE_WCSCHR_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCSCHR_DEFAULT WCSCHR_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WCSCHR_C 1 +# define HAVE_WCSCHR_Z13 1 +#else +# define WCSCHR_DEFAULT WCSCHR_C +# define HAVE_WCSCHR_C 1 +# define HAVE_WCSCHR_Z13 HAVE_WCSCHR_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCSCHR_C +# define WCSCHR_C __wcschr_c +#else +# define WCSCHR_C NULL +#endif + +#if HAVE_WCSCHR_Z13 +# define WCSCHR_Z13 __wcschr_vx +#else +# define WCSCHR_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index d1740fa8e4..b282613b47 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcschr wcschr-vx wcschr-c \ - wcschrnul wcschrnul-vx wcschrnul-c \ +sysdep_routines += wcschrnul wcschrnul-vx wcschrnul-c \ wcsrchr wcsrchr-vx wcsrchr-c \ wcsspn wcsspn-vx wcsspn-c \ wcspbrk wcspbrk-vx wcspbrk-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 8c9e788ae5..c69165465d 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -56,6 +56,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -554,6 +555,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCSNCMP_IFUNC */ +#if HAVE_WCSCHR_IFUNC + IFUNC_IMPL (i, name, wcschr, +# if HAVE_WCSCHR_Z13 + IFUNC_IMPL_ADD (array, i, wcschr, + dl_hwcap & HWCAP_S390_VX, WCSCHR_Z13) +# endif +# if HAVE_WCSCHR_C + IFUNC_IMPL_ADD (array, i, wcschr, 1, WCSCHR_C) +# endif + ) +#endif /* HAVE_WCSCHR_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -562,8 +575,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcschr); - IFUNC_VX_IMPL (wcschrnul); IFUNC_VX_IMPL (wcsrchr); diff --git a/sysdeps/s390/multiarch/wcschr-c.c b/sysdeps/s390/wcschr-c.c similarity index 61% rename from sysdeps/s390/multiarch/wcschr-c.c rename to sysdeps/s390/wcschr-c.c index 8d6679c7f2..4908492a0a 100644 --- a/sysdeps/s390/multiarch/wcschr-c.c +++ b/sysdeps/s390/wcschr-c.c @@ -16,22 +16,29 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCSCHR __wcschr_c - -# include -extern __typeof (__wcschr) __wcschr_c; -# undef weak_alias -# define weak_alias(name, alias) -# ifdef SHARED -# undef libc_hidden_def -# define libc_hidden_def(name) \ - __hidden_ver1 (__wcschr_c, __GI_wcschr, __wcschr_c); \ - strong_alias (__wcschr_c, __wcschr_c_1); \ +#include + +#if HAVE_WCSCHR_C +# if HAVE_WCSCHR_IFUNC || HAVE_WCSCHR_Z13 +# define WCSCHR WCSCHR_C + +# undef weak_alias +# define weak_alias(name, alias) + +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_weak +# define libc_hidden_weak(name) +# undef libc_hidden_def +# if ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define libc_hidden_def(name) \ + __hidden_ver1 (__wcschr_c, __GI_wcschr, __wcschr_c) __attribute__((weak)); \ + strong_alias (__wcschr_c, __wcschr_c_1); \ __hidden_ver1 (__wcschr_c_1, __GI___wcschr, __wcschr_c_1); -# undef libc_hidden_weak -# define libc_hidden_weak(name) -# endif /* SHARED */ +# else +# define libc_hidden_def(name) +# endif +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/wcschr-vx.S b/sysdeps/s390/wcschr-vx.S similarity index 88% rename from sysdeps/s390/multiarch/wcschr-vx.S rename to sysdeps/s390/wcschr-vx.S index 94e5df7f36..dd24998390 100644 --- a/sysdeps/s390/multiarch/wcschr-vx.S +++ b/sysdeps/s390/wcschr-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCSCHR_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -36,7 +37,7 @@ -v17=index of unequal -v18=replicated c */ -ENTRY(__wcschr_vx) +ENTRY(WCSCHR_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -98,6 +99,17 @@ ENTRY(__wcschr_vx) lghi %r2,0 /* Return null if character not found. */ br %r14 .Lfallback: - jg __wcschr_c -END(__wcschr_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WCSCHR_C +END(WCSCHR_Z13) + +# if ! HAVE_WCSCHR_IFUNC +strong_alias (WCSCHR_Z13, __wcschr) +weak_alias (__wcschr, wcschr) +# endif + +# if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT \ + && defined SHARED && IS_IN (libc) +strong_alias (WCSCHR_Z13, __GI___wcschr) +weak_alias (WCSCHR_Z13, __GI_wcschr) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcschr.c b/sysdeps/s390/wcschr.c similarity index 71% rename from sysdeps/s390/multiarch/wcschr.c rename to sysdeps/s390/wcschr.c index f44138f771..9923864ff8 100644 --- a/sysdeps/s390/multiarch/wcschr.c +++ b/sysdeps/s390/wcschr.c @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCSCHR_IFUNC # define wcschr __redirect_wcschr # define __wcschr __redirect___wcschr # include @@ -24,9 +26,18 @@ # undef __wcschr # include -s390_vx_libc_ifunc_redirected (__redirect___wcschr, __wcschr) -weak_alias (__wcschr, wcschr) +# if HAVE_WCSCHR_C +extern __typeof (__redirect___wcschr) WCSCHR_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_WCSCHR_Z13 +extern __typeof (__redirect___wcschr) WCSCHR_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect___wcschr, __wcschr, + (HAVE_WCSCHR_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCSCHR_Z13 + : WCSCHR_DEFAULT + ) +weak_alias (__wcschr, wcschr) +#endif From patchwork Fri Nov 30 15:58:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006063 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-97790-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="BHDLnTOt"; 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 435zmW1CPBz9s8r for ; Sat, 1 Dec 2018 03:07:06 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=r4xXVgw9C7Fu0Ti8H55uV8z4tH2o8Z6 gVsZf08aPmF+Fu42kotdRu3IXPLBtp03lh5dV4teHRpzV559zZxcPu8Sx2D3B1qb 1xTpd52GSRIBjkar8iMv0OB0ImsrD+RQCEQDDCriVCBGJoEZxBUggXXaknHF+VfQ Ybw+eu6qxDsc= 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=vkfs2nUcdylRJfY69MG4jHNYkQc=; b=BHDLn TOtqrBJfZZ30qiXVShGKmQ1UQ5gtPdcVvRKaCjURqgSPYvqiyxy/SOo7YybgOTka OQXjeUDxql+DVAJAfXgsQyL+5Gpm1vOmn5CxEda5dPuvDjYrcWLaOSPHZH+cYkjZ WNMukaFsKqDkdgMEn59apBJXwONyo/tDuxjccg= Received: (qmail 109698 invoked by alias); 30 Nov 2018 16:04:11 -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 109591 invoked by uid 89); 30 Nov 2018 16:04:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 47/56] S390: Refactor wcschrnul ifunc handling. Date: Fri, 30 Nov 2018 16:58:25 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-4275-0000-0000-000002E935DF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-4276-0000-0000-000037F67E7D Message-Id: <1543593514-10251-48-git-send-email-stli@linux.ibm.com> The ifunc handling for wcschrnul is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcschrnul variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcschrnul variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcschrnul. * sysdeps/s390/multiarch/wcschrnul-c.c: Move to ... * sysdeps/s390/wcschrnul-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcschrnul-vx.S: Move to ... * sysdeps/s390/wcschrnul-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcschrnul.c: Move to ... * sysdeps/s390/wcschrnul.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcschrnul.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcschrnul.h | 53 +++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 +++++- sysdeps/s390/{multiarch => }/wcschrnul-c.c | 10 ++-- sysdeps/s390/{multiarch => }/wcschrnul-vx.S | 16 +++++-- sysdeps/s390/{multiarch => }/wcschrnul.c | 23 ++++++--- 7 files changed, 103 insertions(+), 20 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcschrnul.h rename sysdeps/s390/{multiarch => }/wcschrnul-c.c (85%) rename sysdeps/s390/{multiarch => }/wcschrnul-vx.S (92%) rename sysdeps/s390/{multiarch => }/wcschrnul.c (68%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 982e5abfb2..a8cd264521 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -93,5 +93,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \ wcsncat wcsncat-vx wcsncat-c \ wcscmp wcscmp-vx wcscmp-c \ wcsncmp wcsncmp-vx wcsncmp-c \ - wcschr wcschr-vx wcschr-c + wcschr wcschr-vx wcschr-c \ + wcschrnul wcschrnul-vx wcschrnul-c endif diff --git a/sysdeps/s390/ifunc-wcschrnul.h b/sysdeps/s390/ifunc-wcschrnul.h new file mode 100644 index 0000000000..39d4120eb3 --- /dev/null +++ b/sysdeps/s390/ifunc-wcschrnul.h @@ -0,0 +1,53 @@ +/* wcschrnul variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCSCHRNUL_IFUNC 1 +#else +# define HAVE_WCSCHRNUL_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCSCHRNUL_IFUNC_AND_VX_SUPPORT HAVE_WCSCHRNUL_IFUNC +#else +# define HAVE_WCSCHRNUL_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCSCHRNUL_DEFAULT WCSCHRNUL_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WCSCHRNUL_C 1 +# define HAVE_WCSCHRNUL_Z13 1 +#else +# define WCSCHRNUL_DEFAULT WCSCHRNUL_C +# define HAVE_WCSCHRNUL_C 1 +# define HAVE_WCSCHRNUL_Z13 HAVE_WCSCHRNUL_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCSCHRNUL_C +# define WCSCHRNUL_C __wcschrnul_c +#else +# define WCSCHRNUL_C NULL +#endif + +#if HAVE_WCSCHRNUL_Z13 +# define WCSCHRNUL_Z13 __wcschrnul_vx +#else +# define WCSCHRNUL_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index b282613b47..0eb01d5d84 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcschrnul wcschrnul-vx wcschrnul-c \ - wcsrchr wcsrchr-vx wcsrchr-c \ +sysdep_routines += wcsrchr wcsrchr-vx wcsrchr-c \ wcsspn wcsspn-vx wcsspn-c \ wcspbrk wcspbrk-vx wcspbrk-c \ wcscspn wcscspn-vx wcscspn-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index c69165465d..553a76c39e 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -57,6 +57,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -567,6 +568,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCSCHR_IFUNC */ +#if HAVE_WCSCHRNUL_IFUNC + IFUNC_IMPL (i, name, wcschrnul, +# if HAVE_WCSCHRNUL_Z13 + IFUNC_IMPL_ADD (array, i, wcschrnul, + dl_hwcap & HWCAP_S390_VX, WCSCHRNUL_Z13) +# endif +# if HAVE_WCSCHRNUL_C + IFUNC_IMPL_ADD (array, i, wcschrnul, 1, WCSCHRNUL_C) +# endif + ) +#endif /* HAVE_WCSCHRNUL_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -575,8 +588,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcschrnul); - IFUNC_VX_IMPL (wcsrchr); IFUNC_VX_IMPL (wcsspn); diff --git a/sysdeps/s390/multiarch/wcschrnul-c.c b/sysdeps/s390/wcschrnul-c.c similarity index 85% rename from sysdeps/s390/multiarch/wcschrnul-c.c rename to sysdeps/s390/wcschrnul-c.c index 00e776a3ad..410cee1399 100644 --- a/sysdeps/s390/multiarch/wcschrnul-c.c +++ b/sysdeps/s390/wcschrnul-c.c @@ -16,10 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCSCHRNUL __wcschrnul_c +#include + +#if HAVE_WCSCHRNUL_C +# if HAVE_WCSCHRNUL_IFUNC || HAVE_WCSCHRNUL_Z13 +# define WCSCHRNUL WCSCHRNUL_C +# endif -# include -extern __typeof (__wcschrnul) __wcschrnul_c; # include #endif diff --git a/sysdeps/s390/multiarch/wcschrnul-vx.S b/sysdeps/s390/wcschrnul-vx.S similarity index 92% rename from sysdeps/s390/multiarch/wcschrnul-vx.S rename to sysdeps/s390/wcschrnul-vx.S index ebcd32b870..4ffb937c6b 100644 --- a/sysdeps/s390/multiarch/wcschrnul-vx.S +++ b/sysdeps/s390/wcschrnul-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCSCHRNUL_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -35,7 +36,7 @@ -v16=part of s -v18=vector with c replicated in every byte */ -ENTRY(__wcschrnul_vx) +ENTRY(WCSCHRNUL_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -92,6 +93,11 @@ ENTRY(__wcschrnul_vx) .Lend: br %r14 .Lfallback: - jg __wcschrnul_c -END(__wcschrnul_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WCSCHRNUL_C +END(WCSCHRNUL_Z13) + +# if ! HAVE_WCSCHRNUL_IFUNC +strong_alias (WCSCHRNUL_Z13, __wcschrnul) +weak_alias (__wcschrnul, wcschrnul) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcschrnul.c b/sysdeps/s390/wcschrnul.c similarity index 68% rename from sysdeps/s390/multiarch/wcschrnul.c rename to sysdeps/s390/wcschrnul.c index 807d7ee089..ab5aaf0402 100644 --- a/sysdeps/s390/multiarch/wcschrnul.c +++ b/sysdeps/s390/wcschrnul.c @@ -16,13 +16,24 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCSCHRNUL_IFUNC # include # include -s390_vx_libc_ifunc (__wcschrnul) -weak_alias (__wcschrnul, wcschrnul) +# if HAVE_WCSCHRNUL_C +extern __typeof (__wcschrnul) WCSCHRNUL_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_WCSCHRNUL_Z13 +extern __typeof (__wcschrnul) WCSCHRNUL_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__wcschrnul, __wcschrnul, + (HAVE_WCSCHRNUL_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCSCHRNUL_Z13 + : WCSCHRNUL_DEFAULT + ) +weak_alias (__wcschrnul, wcschrnul) +#endif From patchwork Fri Nov 30 15:58:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006068 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-97795-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="bfdddqyv"; 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 435znW2TKjz9s8r for ; Sat, 1 Dec 2018 03:07:59 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=hpEihN+DdqfIrRBiya3hDYTy/AdOZWO mOLMjX8Gzbh6RvGuOfPRSs1UOhmLY/q6PyUDUrqhy2xgiZZ+y94Q+IGZgsp32cX1 dLMgY5YLIOS4lhkAQBdYwcIQTnHV6gB12lXbfojI3B0m/i5SYI57X6mTidzTTq9z KafTT8OLfQBs= 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=DejbKCdF3Jm2AVFITBMJXjxvWHo=; b=bfddd qyvjP6plWw8yPvccLmRqooU1SfX/VEEuRUrs1o8BhzZVcSfwULdTeaey4u9JDqCd 3TqE0aKOX8Nb5rR5LZWgYmpYdpVeZFunj8uCIhaaS/2W1b9bKtukbmSBRPwjsgB3 NkvPAo/PGsBuSAtgf660xqUKTO3j5WKxrszxsE= Received: (qmail 111675 invoked by alias); 30 Nov 2018 16:04:25 -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 111516 invoked by uid 89); 30 Nov 2018 16:04:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 48/56] S390: Refactor wcsrchr ifunc handling. Date: Fri, 30 Nov 2018 16:58:26 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0020-0000-0000-000002F039C9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-0021-0000-0000-0000213FA046 Message-Id: <1543593514-10251-49-git-send-email-stli@linux.ibm.com> The ifunc handling for wcsrchr is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcsrchr variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcsrchr variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcsrchr. * sysdeps/s390/multiarch/wcsrchr-c.c: Move to ... * sysdeps/s390/wcsrchr-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcsrchr-vx.S: Move to ... * sysdeps/s390/wcsrchr-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcsrchr.c: Move to ... * sysdeps/s390/wcsrchr.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcsrchr.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcsrchr.h | 53 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcsrchr-c.c | 10 +++-- sysdeps/s390/{multiarch => }/wcsrchr-vx.S | 15 ++++--- sysdeps/s390/{multiarch => }/wcsrchr.c | 21 ++++++--- 7 files changed, 101 insertions(+), 19 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcsrchr.h rename sysdeps/s390/{multiarch => }/wcsrchr-c.c (85%) rename sysdeps/s390/{multiarch => }/wcsrchr-vx.S (97%) rename sysdeps/s390/{multiarch => }/wcsrchr.c (69%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index a8cd264521..a2c641e81f 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -94,5 +94,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \ wcscmp wcscmp-vx wcscmp-c \ wcsncmp wcsncmp-vx wcsncmp-c \ wcschr wcschr-vx wcschr-c \ - wcschrnul wcschrnul-vx wcschrnul-c + wcschrnul wcschrnul-vx wcschrnul-c \ + wcsrchr wcsrchr-vx wcsrchr-c endif diff --git a/sysdeps/s390/ifunc-wcsrchr.h b/sysdeps/s390/ifunc-wcsrchr.h new file mode 100644 index 0000000000..4eec0c1707 --- /dev/null +++ b/sysdeps/s390/ifunc-wcsrchr.h @@ -0,0 +1,53 @@ +/* wcsrchr variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCSRCHR_IFUNC 1 +#else +# define HAVE_WCSRCHR_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCSRCHR_IFUNC_AND_VX_SUPPORT HAVE_WCSRCHR_IFUNC +#else +# define HAVE_WCSRCHR_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCSRCHR_DEFAULT WCSRCHR_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WCSRCHR_C 1 +# define HAVE_WCSRCHR_Z13 1 +#else +# define WCSRCHR_DEFAULT WCSRCHR_C +# define HAVE_WCSRCHR_C 1 +# define HAVE_WCSRCHR_Z13 HAVE_WCSRCHR_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCSRCHR_C +# define WCSRCHR_C __wcsrchr_c +#else +# define WCSRCHR_C NULL +#endif + +#if HAVE_WCSRCHR_Z13 +# define WCSRCHR_Z13 __wcsrchr_vx +#else +# define WCSRCHR_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 0eb01d5d84..3d72cbb5f3 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcsrchr wcsrchr-vx wcsrchr-c \ - wcsspn wcsspn-vx wcsspn-c \ +sysdep_routines += wcsspn wcsspn-vx wcsspn-c \ wcspbrk wcspbrk-vx wcspbrk-c \ wcscspn wcscspn-vx wcscspn-c \ wmemchr wmemchr-vx wmemchr-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 553a76c39e..ffb4d5b687 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -58,6 +58,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -580,6 +581,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCSCHRNUL_IFUNC */ +#if HAVE_WCSRCHR_IFUNC + IFUNC_IMPL (i, name, wcsrchr, +# if HAVE_WCSRCHR_Z13 + IFUNC_IMPL_ADD (array, i, wcsrchr, + dl_hwcap & HWCAP_S390_VX, WCSRCHR_Z13) +# endif +# if HAVE_WCSRCHR_C + IFUNC_IMPL_ADD (array, i, wcsrchr, 1, WCSRCHR_C) +# endif + ) +#endif /* HAVE_WCSRCHR_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -588,8 +601,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcsrchr); - IFUNC_VX_IMPL (wcsspn); IFUNC_VX_IMPL (wcspbrk); diff --git a/sysdeps/s390/multiarch/wcsrchr-c.c b/sysdeps/s390/wcsrchr-c.c similarity index 85% rename from sysdeps/s390/multiarch/wcsrchr-c.c rename to sysdeps/s390/wcsrchr-c.c index 615250358b..65164a897f 100644 --- a/sysdeps/s390/multiarch/wcsrchr-c.c +++ b/sysdeps/s390/wcsrchr-c.c @@ -16,10 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCSRCHR __wcsrchr_c +#include + +#if HAVE_WCSRCHR_C +# if HAVE_WCSRCHR_IFUNC || HAVE_WCSRCHR_Z13 +# define WCSRCHR WCSRCHR_C +# endif -# include -extern __typeof (wcsrchr) __wcsrchr_c; # include #endif diff --git a/sysdeps/s390/multiarch/wcsrchr-vx.S b/sysdeps/s390/wcsrchr-vx.S similarity index 97% rename from sysdeps/s390/multiarch/wcsrchr-vx.S rename to sysdeps/s390/wcsrchr-vx.S index e40a554e5d..c7b6585bea 100644 --- a/sysdeps/s390/multiarch/wcsrchr-vx.S +++ b/sysdeps/s390/wcsrchr-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCSRCHR_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -39,7 +40,7 @@ -v19=part of s with last occurence of c. -v20=permute pattern */ -ENTRY(__wcsrchr_vx) +ENTRY(WCSRCHR_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -185,6 +186,10 @@ ENTRY(__wcsrchr_vx) .byte 0x0C,0x0D,0x0E,0x0F,0x08,0x09,0x0A,0x0B .byte 0x04,0x05,0x06,0x07,0x00,0x01,0x02,0x03 .Lfallback: - jg __wcsrchr_c -END(__wcsrchr_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WCSRCHR_C +END(WCSRCHR_Z13) + +# if ! HAVE_WCSRCHR_IFUNC +strong_alias (WCSRCHR_Z13, wcsrchr) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcsrchr.c b/sysdeps/s390/wcsrchr.c similarity index 69% rename from sysdeps/s390/multiarch/wcsrchr.c rename to sysdeps/s390/wcsrchr.c index aa0b8a8f82..eb70f27038 100644 --- a/sysdeps/s390/multiarch/wcsrchr.c +++ b/sysdeps/s390/wcsrchr.c @@ -16,12 +16,23 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCSRCHR_IFUNC # include # include -s390_vx_libc_ifunc2 (__wcsrchr, wcsrchr) +# if HAVE_WCSRCHR_C +extern __typeof (wcsrchr) WCSRCHR_C attribute_hidden; +# endif + +# if HAVE_WCSRCHR_Z13 +extern __typeof (wcsrchr) WCSRCHR_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (wcsrchr, wcsrchr, + (HAVE_WCSRCHR_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCSRCHR_Z13 + : WCSRCHR_DEFAULT + ) +#endif From patchwork Fri Nov 30 15:58:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006069 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-97796-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="gd1rZtM3"; 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 435znj2BPfz9s8r for ; Sat, 1 Dec 2018 03:08:09 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=kdczLRHciRxZ/0HoOS3ke+UzjZ0gRzX hM2DA6ni3cHkg4uNBs8J6uKmTavrs7LQXo1yyacLqft4sVcbLKiP4JyMBTGjnkRK xazCk+GEETb5FB1Jwhf6pFn/ltCDJLB7o1H7jnpXeLGTos4EaD0I8HLD/zEREGE2 l645mc2UXjM4= 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=0CIIt9XY07qMBM5nOOOy3TInusU=; b=gd1rZ tM3yJSwDJR5ZHh6CzpCryRSlZlyPsSHbgeHcUvt8hVsbjbRrV2ReVPXD4z6mcGw/ cKLHwvZrNKrG/t5NqWdxHIdttEegUDM2TVNWPh+aFG8xs6M0LD2XkK7L2C2g0ZYc WW1JMRzsPs0YRRT6j6n62cLNVRBMJhPKDYBO4g= Received: (qmail 111728 invoked by alias); 30 Nov 2018 16:04:26 -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 111607 invoked by uid 89); 30 Nov 2018 16:04:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 49/56] S390: Refactor wcsspn ifunc handling. Date: Fri, 30 Nov 2018 16:58:27 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0016-0000-0000-0000022F30C6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-0017-0000-0000-000032879BDF Message-Id: <1543593514-10251-50-git-send-email-stli@linux.ibm.com> The ifunc handling for wcsspn is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. Glibc internal calls will use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcsspn variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcsspn variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcsspn. * sysdeps/s390/multiarch/wcsspn-c.c: Move to ... * sysdeps/s390/wcsspn-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcsspn-vx.S: Move to ... * sysdeps/s390/wcsspn-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcsspn.c: Move to ... * sysdeps/s390/wcsspn.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcsspn.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcsspn.h | 53 ++++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcsspn-c.c | 24 +++++++---- sysdeps/s390/{multiarch => }/wcsspn-vx.S | 20 ++++++--- sysdeps/s390/{multiarch => }/wcsspn.c | 20 ++++++--- 7 files changed, 114 insertions(+), 24 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcsspn.h rename sysdeps/s390/{multiarch => }/wcsspn-c.c (72%) rename sysdeps/s390/{multiarch => }/wcsspn-vx.S (97%) rename sysdeps/s390/{multiarch => }/wcsspn.c (69%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index a2c641e81f..2e48900c68 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -95,5 +95,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \ wcsncmp wcsncmp-vx wcsncmp-c \ wcschr wcschr-vx wcschr-c \ wcschrnul wcschrnul-vx wcschrnul-c \ - wcsrchr wcsrchr-vx wcsrchr-c + wcsrchr wcsrchr-vx wcsrchr-c \ + wcsspn wcsspn-vx wcsspn-c endif diff --git a/sysdeps/s390/ifunc-wcsspn.h b/sysdeps/s390/ifunc-wcsspn.h new file mode 100644 index 0000000000..1189c6b93f --- /dev/null +++ b/sysdeps/s390/ifunc-wcsspn.h @@ -0,0 +1,53 @@ +/* wcsspn variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCSSPN_IFUNC 1 +#else +# define HAVE_WCSSPN_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCSSPN_IFUNC_AND_VX_SUPPORT HAVE_WCSSPN_IFUNC +#else +# define HAVE_WCSSPN_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCSSPN_DEFAULT WCSSPN_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WCSSPN_C 1 +# define HAVE_WCSSPN_Z13 1 +#else +# define WCSSPN_DEFAULT WCSSPN_C +# define HAVE_WCSSPN_C 1 +# define HAVE_WCSSPN_Z13 HAVE_WCSSPN_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCSSPN_C +# define WCSSPN_C __wcsspn_c +#else +# define WCSSPN_C NULL +#endif + +#if HAVE_WCSSPN_Z13 +# define WCSSPN_Z13 __wcsspn_vx +#else +# define WCSSPN_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 3d72cbb5f3..091f515084 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcsspn wcsspn-vx wcsspn-c \ - wcspbrk wcspbrk-vx wcspbrk-c \ +sysdep_routines += wcspbrk wcspbrk-vx wcspbrk-c \ wcscspn wcscspn-vx wcscspn-c \ wmemchr wmemchr-vx wmemchr-c \ wmemset wmemset-vx wmemset-c \ diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index ffb4d5b687..6f4de2845b 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -59,6 +59,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -593,6 +594,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCSRCHR_IFUNC */ +#if HAVE_WCSSPN_IFUNC + IFUNC_IMPL (i, name, wcsspn, +# if HAVE_WCSSPN_Z13 + IFUNC_IMPL_ADD (array, i, wcsspn, + dl_hwcap & HWCAP_S390_VX, WCSSPN_Z13) +# endif +# if HAVE_WCSSPN_C + IFUNC_IMPL_ADD (array, i, wcsspn, 1, WCSSPN_C) +# endif + ) +#endif /* HAVE_WCSSPN_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -601,8 +614,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcsspn); - IFUNC_VX_IMPL (wcspbrk); IFUNC_VX_IMPL (wcscspn); diff --git a/sysdeps/s390/multiarch/wcsspn-c.c b/sysdeps/s390/wcsspn-c.c similarity index 72% rename from sysdeps/s390/multiarch/wcsspn-c.c rename to sysdeps/s390/wcsspn-c.c index 2c0bd0f4e6..db3bdb9b9f 100644 --- a/sysdeps/s390/multiarch/wcsspn-c.c +++ b/sysdeps/s390/wcsspn-c.c @@ -16,16 +16,22 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCSSPN __wcsspn_c +#include -# include -extern __typeof (wcsspn) __wcsspn_c; -# ifdef SHARED -# undef libc_hidden_def -# define libc_hidden_def(name) \ +#if HAVE_WCSSPN_C +# if HAVE_WCSSPN_IFUNC || HAVE_WCSSPN_Z13 +# define WCSSPN WCSSPN_C + +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_def +# if ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define libc_hidden_def(name) \ __hidden_ver1 (__wcsspn_c, __GI_wcsspn, __wcsspn_c); -# endif /* SHARED */ +# else +# define libc_hidden_def(name) +# endif +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/wcsspn-vx.S b/sysdeps/s390/wcsspn-vx.S similarity index 97% rename from sysdeps/s390/multiarch/wcsspn-vx.S rename to sysdeps/s390/wcsspn-vx.S index 548f2ad164..61f7d6d090 100644 --- a/sysdeps/s390/multiarch/wcsspn-vx.S +++ b/sysdeps/s390/wcsspn-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCSSPN_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -57,7 +58,7 @@ otherwise =0; r9: loaded byte count of vlbb accept-string */ -ENTRY(__wcsspn_vx) +ENTRY(WCSSPN_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -265,6 +266,15 @@ ENTRY(__wcsspn_vx) j .Lslow_next_acc_notonbb /* ... and search for zero in fully loaded vreg again. */ .Lfallback: - jg __wcsspn_c -END(__wcsspn_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WCSSPN_C +END(WCSSPN_Z13) + +# if ! HAVE_WCSSPN_IFUNC +strong_alias (WCSSPN_Z13, wcsspn) +# endif + +# if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT \ + && defined SHARED && IS_IN (libc) +strong_alias (WCSSPN_Z13, __GI_wcsspn) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcsspn.c b/sysdeps/s390/wcsspn.c similarity index 69% rename from sysdeps/s390/multiarch/wcsspn.c rename to sysdeps/s390/wcsspn.c index 7743144a8c..e916b1e441 100644 --- a/sysdeps/s390/multiarch/wcsspn.c +++ b/sysdeps/s390/wcsspn.c @@ -16,14 +16,24 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCSSPN_IFUNC # define wcsspn __redirect_wcsspn # include # undef wcsspn # include +# if HAVE_WCSSPN_C +extern __typeof (__redirect_wcsspn) WCSSPN_C attribute_hidden; +# endif -s390_vx_libc_ifunc2_redirected (__redirect_wcsspn, __wcsspn, wcsspn) +# if HAVE_WCSSPN_Z13 +extern __typeof (__redirect_wcsspn) WCSSPN_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (__redirect_wcsspn, wcsspn, + (HAVE_WCSSPN_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCSSPN_Z13 + : WCSSPN_DEFAULT + ) +#endif From patchwork Fri Nov 30 15:58:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006059 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-97786-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="dzXQ1UNf"; 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 435zlg66TFz9s8r for ; Sat, 1 Dec 2018 03:06: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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=Cv5rS1xGYifsc/Zs6XFKUDo4PFHJ/YT LAiPPOO6wPDl/kUiC9rHjMSCJr8lgDPDZV2VMkJotppUBnqHoLoynAOIRUt15nHZ T0IfM503p+8D/nutrvLxR00scScamh/5rv80LCoXCBIrVypWHp3kTvfyi/mWfi8a v3BdbhFu6GsU= 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=6A9gOhsRqTC2bgAcaD8rg5RgjtE=; b=dzXQ1 UNfZSkmaILqYA/ZGM6QRSYOm9sAor/HzcyBYlxX/bgztIIj+yk15BmfswbRHfpPu ULkyI+JVUnXasFlybpk6+xZjEln9T+55p70xfpa5VJRImoc/iBEiXb9fxNhuDFZs 7LJn96iJ7P93PhH0XgWR17TV5YSf9eD1BED61E= Received: (qmail 108120 invoked by alias); 30 Nov 2018 16:04: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 107973 invoked by uid 89); 30 Nov 2018 16:03:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 50/56] S390: Refactor wcspbrk ifunc handling. Date: Fri, 30 Nov 2018 16:58:28 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0020-0000-0000-000002F039CB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-0021-0000-0000-0000213FA049 Message-Id: <1543593514-10251-51-git-send-email-stli@linux.ibm.com> The ifunc handling for wcspbrk is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. Glibc internal calls will use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcspbrk variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcspbrk variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcspbrk. * sysdeps/s390/multiarch/wcspbrk-c.c: Move to ... * sysdeps/s390/wcspbrk-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcspbrk-vx.S: Move to ... * sysdeps/s390/wcspbrk-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcspbrk.c: Move to ... * sysdeps/s390/wcspbrk.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcspbrk.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcspbrk.h | 53 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcspbrk-c.c | 24 ++++++---- sysdeps/s390/{multiarch => }/wcspbrk-vx.S | 20 ++++++--- sysdeps/s390/{multiarch => }/wcspbrk.c | 20 ++++++--- 7 files changed, 114 insertions(+), 24 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcspbrk.h rename sysdeps/s390/{multiarch => }/wcspbrk-c.c (72%) rename sysdeps/s390/{multiarch => }/wcspbrk-vx.S (97%) rename sysdeps/s390/{multiarch => }/wcspbrk.c (69%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 2e48900c68..4decbf8f0a 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -96,5 +96,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \ wcschr wcschr-vx wcschr-c \ wcschrnul wcschrnul-vx wcschrnul-c \ wcsrchr wcsrchr-vx wcsrchr-c \ - wcsspn wcsspn-vx wcsspn-c + wcsspn wcsspn-vx wcsspn-c \ + wcspbrk wcspbrk-vx wcspbrk-c endif diff --git a/sysdeps/s390/ifunc-wcspbrk.h b/sysdeps/s390/ifunc-wcspbrk.h new file mode 100644 index 0000000000..d3b9b7363a --- /dev/null +++ b/sysdeps/s390/ifunc-wcspbrk.h @@ -0,0 +1,53 @@ +/* wcspbrk variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCSPBRK_IFUNC 1 +#else +# define HAVE_WCSPBRK_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCSPBRK_IFUNC_AND_VX_SUPPORT HAVE_WCSPBRK_IFUNC +#else +# define HAVE_WCSPBRK_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCSPBRK_DEFAULT WCSPBRK_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WCSPBRK_C 1 +# define HAVE_WCSPBRK_Z13 1 +#else +# define WCSPBRK_DEFAULT WCSPBRK_C +# define HAVE_WCSPBRK_C 1 +# define HAVE_WCSPBRK_Z13 HAVE_WCSPBRK_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCSPBRK_C +# define WCSPBRK_C __wcspbrk_c +#else +# define WCSPBRK_C NULL +#endif + +#if HAVE_WCSPBRK_Z13 +# define WCSPBRK_Z13 __wcspbrk_vx +#else +# define WCSPBRK_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 091f515084..e1e2d9dc74 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcspbrk wcspbrk-vx wcspbrk-c \ - wcscspn wcscspn-vx wcscspn-c \ +sysdep_routines += wcscspn wcscspn-vx wcscspn-c \ wmemchr wmemchr-vx wmemchr-c \ wmemset wmemset-vx wmemset-c \ wmemcmp wmemcmp-vx wmemcmp-c diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 6f4de2845b..89d6e8ad7e 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -60,6 +60,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -606,6 +607,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCSSPN_IFUNC */ +#if HAVE_WCSPBRK_IFUNC + IFUNC_IMPL (i, name, wcspbrk, +# if HAVE_WCSPBRK_Z13 + IFUNC_IMPL_ADD (array, i, wcspbrk, + dl_hwcap & HWCAP_S390_VX, WCSPBRK_Z13) +# endif +# if HAVE_WCSPBRK_C + IFUNC_IMPL_ADD (array, i, wcspbrk, 1, WCSPBRK_C) +# endif + ) +#endif /* HAVE_WCSPBRK_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -614,8 +627,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcspbrk); - IFUNC_VX_IMPL (wcscspn); IFUNC_VX_IMPL (wmemchr); diff --git a/sysdeps/s390/multiarch/wcspbrk-c.c b/sysdeps/s390/wcspbrk-c.c similarity index 72% rename from sysdeps/s390/multiarch/wcspbrk-c.c rename to sysdeps/s390/wcspbrk-c.c index 6b6e7aade4..e79c6a8550 100644 --- a/sysdeps/s390/multiarch/wcspbrk-c.c +++ b/sysdeps/s390/wcspbrk-c.c @@ -16,16 +16,22 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCSPBRK __wcspbrk_c +#include -# include -extern __typeof (wcspbrk) __wcspbrk_c; -# ifdef SHARED -# undef libc_hidden_def -# define libc_hidden_def(name) \ +#if HAVE_WCSPBRK_C +# if HAVE_WCSPBRK_IFUNC || HAVE_WCSPBRK_Z13 +# define WCSPBRK WCSPBRK_C + +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_def +# if ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define libc_hidden_def(name) \ __hidden_ver1 (__wcspbrk_c, __GI_wcspbrk, __wcspbrk_c); -# endif /* SHARED */ +# else +# define libc_hidden_def(name) +# endif +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/wcspbrk-vx.S b/sysdeps/s390/wcspbrk-vx.S similarity index 97% rename from sysdeps/s390/multiarch/wcspbrk-vx.S rename to sysdeps/s390/wcspbrk-vx.S index 5c89ec5d33..5870c4684d 100644 --- a/sysdeps/s390/multiarch/wcspbrk-vx.S +++ b/sysdeps/s390/wcspbrk-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCSPBRK_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -59,7 +60,7 @@ otherwise =0; r9: loaded byte count of vlbb accept-string */ -ENTRY(__wcspbrk_vx) +ENTRY(WCSPBRK_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -310,6 +311,15 @@ ENTRY(__wcspbrk_vx) lgr %r2,%r1 br %r14 .Lfallback: - jg __wcspbrk_c -END(__wcspbrk_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WCSPBRK_C +END(WCSPBRK_Z13) + +# if ! HAVE_WCSPBRK_IFUNC +strong_alias (WCSPBRK_Z13, wcspbrk) +# endif + +# if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT \ + && defined SHARED && IS_IN (libc) +strong_alias (WCSPBRK_Z13, __GI_wcspbrk) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcspbrk.c b/sysdeps/s390/wcspbrk.c similarity index 69% rename from sysdeps/s390/multiarch/wcspbrk.c rename to sysdeps/s390/wcspbrk.c index 97876328b5..84ab911a24 100644 --- a/sysdeps/s390/multiarch/wcspbrk.c +++ b/sysdeps/s390/wcspbrk.c @@ -16,14 +16,24 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCSPBRK_IFUNC # define wcspbrk __redirect_wcspbrk # include # undef wcspbrk # include +# if HAVE_WCSPBRK_C +extern __typeof (__redirect_wcspbrk) WCSPBRK_C attribute_hidden; +# endif -s390_vx_libc_ifunc2_redirected (__redirect_wcspbrk, __wcspbrk, wcspbrk) +# if HAVE_WCSPBRK_Z13 +extern __typeof (__redirect_wcspbrk) WCSPBRK_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (__redirect_wcspbrk, wcspbrk, + (HAVE_WCSPBRK_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCSPBRK_Z13 + : WCSPBRK_DEFAULT + ) +#endif From patchwork Fri Nov 30 15:58:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006067 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-97794-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="IqI0a7I5"; 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 435znJ4HJsz9s8r for ; Sat, 1 Dec 2018 03:07:48 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=MtBGCcx1QJP6G8/oioOJPm71lpP80Ub lfiAf2aav4QTZvrgiQQQcsRB+z6IhjmanTyXXOCBQArFHSjxVnl2H3pZZkmajQeQ ptyVnrFa/GGy85dxMSIiYbJ/xVdP55NbyejcYEX0V6mVyjaqUdXNbRdulopCU/xg oNNJPiL5xRdw= 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=JL1izf/scCv6kVactGqgvnhKS9k=; b=IqI0a 7I5hllPHW35e/qF/nKy0xVnCDKJSGjlZuQIgFQkpXnPyHK+v+UN05GsPqcLLIIRa Bo1sz4DAMCTmIjwcz7khP29rq+qgGamwjLOJzXnEaYPFw4xM3eqe570sXEva4S38 p5EKcrNfLIMvazlnlOJzMMxcF9aUUjMuRM0lMo= Received: (qmail 111123 invoked by alias); 30 Nov 2018 16:04:22 -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 110764 invoked by uid 89); 30 Nov 2018 16:04:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 51/56] S390: Refactor wcscspn ifunc handling. Date: Fri, 30 Nov 2018 16:58:29 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0016-0000-0000-0000022F30CA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-0017-0000-0000-000032879BE3 Message-Id: <1543593514-10251-52-git-send-email-stli@linux.ibm.com> The ifunc handling for wcscspn is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wcscspn variants. * sysdeps/s390/Makefile (sysdep_routines): Add wcscspn variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wcscspn. * sysdeps/s390/multiarch/wcscspn-c.c: Move to ... * sysdeps/s390/wcscspn-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcscspn-vx.S: Move to ... * sysdeps/s390/wcscspn-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wcscspn.c: Move to ... * sysdeps/s390/wcscspn.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wcscspn.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wcscspn.h | 53 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wcscspn-c.c | 9 ++-- sysdeps/s390/{multiarch => }/wcscspn-vx.S | 15 ++++--- sysdeps/s390/{multiarch => }/wcscspn.c | 21 ++++++--- 7 files changed, 100 insertions(+), 19 deletions(-) create mode 100644 sysdeps/s390/ifunc-wcscspn.h rename sysdeps/s390/{multiarch => }/wcscspn-c.c (86%) rename sysdeps/s390/{multiarch => }/wcscspn-vx.S (98%) rename sysdeps/s390/{multiarch => }/wcscspn.c (69%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 4decbf8f0a..a9058047a9 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -97,5 +97,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \ wcschrnul wcschrnul-vx wcschrnul-c \ wcsrchr wcsrchr-vx wcsrchr-c \ wcsspn wcsspn-vx wcsspn-c \ - wcspbrk wcspbrk-vx wcspbrk-c + wcspbrk wcspbrk-vx wcspbrk-c \ + wcscspn wcscspn-vx wcscspn-c endif diff --git a/sysdeps/s390/ifunc-wcscspn.h b/sysdeps/s390/ifunc-wcscspn.h new file mode 100644 index 0000000000..23f3667ba3 --- /dev/null +++ b/sysdeps/s390/ifunc-wcscspn.h @@ -0,0 +1,53 @@ +/* wcscspn variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WCSCSPN_IFUNC 1 +#else +# define HAVE_WCSCSPN_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WCSCSPN_IFUNC_AND_VX_SUPPORT HAVE_WCSCSPN_IFUNC +#else +# define HAVE_WCSCSPN_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WCSCSPN_DEFAULT WCSCSPN_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WCSCSPN_C 1 +# define HAVE_WCSCSPN_Z13 1 +#else +# define WCSCSPN_DEFAULT WCSCSPN_C +# define HAVE_WCSCSPN_C 1 +# define HAVE_WCSCSPN_Z13 HAVE_WCSCSPN_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WCSCSPN_C +# define WCSCSPN_C __wcscspn_c +#else +# define WCSCSPN_C NULL +#endif + +#if HAVE_WCSCSPN_Z13 +# define WCSCSPN_Z13 __wcscspn_vx +#else +# define WCSCSPN_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index e1e2d9dc74..5be6355423 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wcscspn wcscspn-vx wcscspn-c \ - wmemchr wmemchr-vx wmemchr-c \ +sysdep_routines += wmemchr wmemchr-vx wmemchr-c \ wmemset wmemset-vx wmemset-c \ wmemcmp wmemcmp-vx wmemcmp-c endif diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 89d6e8ad7e..7d8031a069 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -61,6 +61,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -619,6 +620,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCSPBRK_IFUNC */ +#if HAVE_WCSCSPN_IFUNC + IFUNC_IMPL (i, name, wcscspn, +# if HAVE_WCSCSPN_Z13 + IFUNC_IMPL_ADD (array, i, wcscspn, + dl_hwcap & HWCAP_S390_VX, WCSCSPN_Z13) +# endif +# if HAVE_WCSCSPN_C + IFUNC_IMPL_ADD (array, i, wcscspn, 1, WCSCSPN_C) +# endif + ) +#endif /* HAVE_WCSCSPN_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -627,8 +640,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wcscspn); - IFUNC_VX_IMPL (wmemchr); IFUNC_VX_IMPL (wmemset); diff --git a/sysdeps/s390/multiarch/wcscspn-c.c b/sysdeps/s390/wcscspn-c.c similarity index 86% rename from sysdeps/s390/multiarch/wcscspn-c.c rename to sysdeps/s390/wcscspn-c.c index 161e52e686..d47cb6b75b 100644 --- a/sysdeps/s390/multiarch/wcscspn-c.c +++ b/sysdeps/s390/wcscspn-c.c @@ -16,11 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WCSCSPN __wcscspn_c +#include -# include -extern __typeof (wcscspn) __wcscspn_c; +#if HAVE_WCSCSPN_C +# if HAVE_WCSCSPN_IFUNC || HAVE_WCSCSPN_Z13 +# define WCSCSPN WCSCSPN_C +# endif # include #endif diff --git a/sysdeps/s390/multiarch/wcscspn-vx.S b/sysdeps/s390/wcscspn-vx.S similarity index 98% rename from sysdeps/s390/multiarch/wcscspn-vx.S rename to sysdeps/s390/wcscspn-vx.S index 06bc4e25d0..882cb93fb8 100644 --- a/sysdeps/s390/multiarch/wcscspn-vx.S +++ b/sysdeps/s390/wcscspn-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WCSCSPN_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -57,7 +58,7 @@ otherwise =0; r9: loaded byte count of vlbb reject-string */ -ENTRY(__wcscspn_vx) +ENTRY(WCSCSPN_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -288,6 +289,10 @@ ENTRY(__wcscspn_vx) vlgvg %r9,%v31,1 br %r14 .Lfallback: - jg __wcscspn_c -END(__wcscspn_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WCSCSPN_C +END(WCSCSPN_Z13) + +# if ! HAVE_WCSCSPN_IFUNC +strong_alias (WCSCSPN_Z13, wcscspn) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wcscspn.c b/sysdeps/s390/wcscspn.c similarity index 69% rename from sysdeps/s390/multiarch/wcscspn.c rename to sysdeps/s390/wcscspn.c index 707327522a..0ce31b8aab 100644 --- a/sysdeps/s390/multiarch/wcscspn.c +++ b/sysdeps/s390/wcscspn.c @@ -16,12 +16,23 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WCSCSPN_IFUNC # include # include -s390_vx_libc_ifunc2 (__wcscspn, wcscspn) +# if HAVE_WCSCSPN_C +extern __typeof (wcscspn) WCSCSPN_C attribute_hidden; +# endif + +# if HAVE_WCSCSPN_Z13 +extern __typeof (wcscspn) WCSCSPN_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (wcscspn, wcscspn, + (HAVE_WCSCSPN_Z13 && (hwcap & HWCAP_S390_VX)) + ? WCSCSPN_Z13 + : WCSCSPN_DEFAULT + ) +#endif From patchwork Fri Nov 30 15:58:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006066 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-97793-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="ea3OK1YK"; 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 435zn66rrBz9s8r for ; Sat, 1 Dec 2018 03:07:38 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=byanqw4layFYB4eeGTSuAKqTkkuQvsI yqrKp47Qbx/022KZaOyKHYRL7uwiDVTJbRb4/yGu37xNhw5TJP4f8BtzXdKJLQBY HjKSikEsYoT7x5yN5mZfCsLZDWxqBG2ZngNPeILLCVK1hKzyRHAGHdhGrLeD24lH D970y7AGh87g= 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=fMya9Frg0b2RPDxW/ExuHTQzBzE=; b=ea3OK 1YK95wtD0O1ahDVPRrkZ2y3q9NGZUnRT/SLQphKlGXjatTtaf0Ap4hEA0rzKDia7 qUZCk04BJxGmUdaBv6gMYvBr7H7m+lZqzLUqdAt3P+DeNozUo+oFpff32Wr5sP9p G1foPjfoOqT/+ppGpTH510mBiVd9rzUaFdCB0Q= Received: (qmail 110614 invoked by alias); 30 Nov 2018 16:04:18 -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 110493 invoked by uid 89); 30 Nov 2018 16:04:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 52/56] S390: Refactor wmemchr ifunc handling. Date: Fri, 30 Nov 2018 16:58:30 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0028-0000-0000-00000323FCBB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-0029-0000-0000-000023E01268 Message-Id: <1543593514-10251-53-git-send-email-stli@linux.ibm.com> The ifunc handling for wmemchr is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. Glibc internal calls will use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wmemchr variants. * sysdeps/s390/Makefile (sysdep_routines): Add wmemchr variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wmemchr. * sysdeps/s390/multiarch/wmemchr-c.c: Move to ... * sysdeps/s390/wmemchr-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wmemchr-vx.S: Move to ... * sysdeps/s390/wmemchr-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wmemchr.c: Move to ... * sysdeps/s390/wmemchr.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wmemchr.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wmemchr.h | 53 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wmemchr-c.c | 39 ++++++++++------- sysdeps/s390/{multiarch => }/wmemchr-vx.S | 22 +++++++--- sysdeps/s390/{multiarch => }/wmemchr.c | 23 +++++++--- 7 files changed, 126 insertions(+), 32 deletions(-) create mode 100644 sysdeps/s390/ifunc-wmemchr.h rename sysdeps/s390/{multiarch => }/wmemchr-c.c (59%) rename sysdeps/s390/{multiarch => }/wmemchr-vx.S (92%) rename sysdeps/s390/{multiarch => }/wmemchr.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index a9058047a9..17aabf328b 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -98,5 +98,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \ wcsrchr wcsrchr-vx wcsrchr-c \ wcsspn wcsspn-vx wcsspn-c \ wcspbrk wcspbrk-vx wcspbrk-c \ - wcscspn wcscspn-vx wcscspn-c + wcscspn wcscspn-vx wcscspn-c \ + wmemchr wmemchr-vx wmemchr-c endif diff --git a/sysdeps/s390/ifunc-wmemchr.h b/sysdeps/s390/ifunc-wmemchr.h new file mode 100644 index 0000000000..0610cfb5d4 --- /dev/null +++ b/sysdeps/s390/ifunc-wmemchr.h @@ -0,0 +1,53 @@ +/* wmemchr variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WMEMCHR_IFUNC 1 +#else +# define HAVE_WMEMCHR_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WMEMCHR_IFUNC_AND_VX_SUPPORT HAVE_WMEMCHR_IFUNC +#else +# define HAVE_WMEMCHR_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WMEMCHR_DEFAULT WMEMCHR_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WMEMCHR_C 1 +# define HAVE_WMEMCHR_Z13 1 +#else +# define WMEMCHR_DEFAULT WMEMCHR_C +# define HAVE_WMEMCHR_C 1 +# define HAVE_WMEMCHR_Z13 HAVE_WMEMCHR_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WMEMCHR_C +# define WMEMCHR_C __wmemchr_c +#else +# define WMEMCHR_C NULL +#endif + +#if HAVE_WMEMCHR_Z13 +# define WMEMCHR_Z13 __wmemchr_vx +#else +# define WMEMCHR_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 5be6355423..92e28dc45d 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wmemchr wmemchr-vx wmemchr-c \ - wmemset wmemset-vx wmemset-c \ +sysdep_routines += wmemset wmemset-vx wmemset-c \ wmemcmp wmemcmp-vx wmemcmp-c endif diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 7d8031a069..b5f55deb7f 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -62,6 +62,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -632,6 +633,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WCSCSPN_IFUNC */ +#if HAVE_WMEMCHR_IFUNC + IFUNC_IMPL (i, name, wmemchr, +# if HAVE_WMEMCHR_Z13 + IFUNC_IMPL_ADD (array, i, wmemchr, + dl_hwcap & HWCAP_S390_VX, WMEMCHR_Z13) +# endif +# if HAVE_WMEMCHR_C + IFUNC_IMPL_ADD (array, i, wmemchr, 1, WMEMCHR_C) +# endif + ) +#endif /* HAVE_WMEMCHR_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -640,8 +653,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wmemchr); - IFUNC_VX_IMPL (wmemset); IFUNC_VX_IMPL (wmemcmp); diff --git a/sysdeps/s390/multiarch/wmemchr-c.c b/sysdeps/s390/wmemchr-c.c similarity index 59% rename from sysdeps/s390/multiarch/wmemchr-c.c rename to sysdeps/s390/wmemchr-c.c index 089392b512..bb2526e76c 100644 --- a/sysdeps/s390/multiarch/wmemchr-c.c +++ b/sysdeps/s390/wmemchr-c.c @@ -16,22 +16,29 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WMEMCHR __wmemchr_c - -# include -extern __typeof (wmemchr) __wmemchr_c; -# undef weak_alias -# define weak_alias(name, alias) -# ifdef SHARED -# undef libc_hidden_def -# define libc_hidden_def(name) \ - __hidden_ver1 (__wmemchr_c, __GI___wmemchr, __wmemchr_c); -# undef libc_hidden_weak -# define libc_hidden_weak(name) \ +#include + +#if HAVE_WMEMCHR_C +# if HAVE_WMEMCHR_IFUNC || HAVE_WMEMCHR_Z13 +# define WMEMCHR WMEMCHR_C + +# undef weak_alias +# define weak_alias(name, alias) + +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_weak +# define libc_hidden_weak(name) +# undef libc_hidden_def +# if ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define libc_hidden_def(name) \ + __hidden_ver1 (__wmemchr_c, __GI_wmemchr, __wmemchr_c) __attribute__((weak)); \ strong_alias (__wmemchr_c, __wmemchr_c_1); \ - __hidden_ver1 (__wmemchr_c_1, __GI_wmemchr, __wmemchr_c_1); -# endif /* SHARED */ + __hidden_ver1 (__wmemchr_c_1, __GI___wmemchr, __wmemchr_c_1); +# else +# define libc_hidden_def(name) +# endif +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/wmemchr-vx.S b/sysdeps/s390/wmemchr-vx.S similarity index 92% rename from sysdeps/s390/multiarch/wmemchr-vx.S rename to sysdeps/s390/wmemchr-vx.S index db057b579a..72e9ef59af 100644 --- a/sysdeps/s390/multiarch/wmemchr-vx.S +++ b/sysdeps/s390/wmemchr-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WMEMCHR_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -38,7 +39,7 @@ -v17=index of found c -v18=c replicated */ -ENTRY(__wmemchr_vx) +ENTRY(WMEMCHR_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -161,6 +162,17 @@ ENTRY(__wmemchr_vx) j .Llt64 .Lfallback: - jg __wmemchr_c -END(__wmemchr_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WMEMCHR_C +END(WMEMCHR_Z13) + +# if ! HAVE_WMEMCHR_IFUNC +strong_alias (WMEMCHR_Z13, __wmemchr) +weak_alias (__wmemchr, wmemchr) +# endif + +# if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT \ + && defined SHARED && IS_IN (libc) +strong_alias (WMEMCHR_Z13, __GI___wmemchr) +weak_alias (WMEMCHR_Z13, __GI_wmemchr) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wmemchr.c b/sysdeps/s390/wmemchr.c similarity index 70% rename from sysdeps/s390/multiarch/wmemchr.c rename to sysdeps/s390/wmemchr.c index 6b55c1d7fa..0d2fbb22c6 100644 --- a/sysdeps/s390/multiarch/wmemchr.c +++ b/sysdeps/s390/wmemchr.c @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WMEMCHR_IFUNC # define wmemchr __redirect_wmemchr # define __wmemchr __redirect___wmemchr # include @@ -24,9 +26,18 @@ # undef __wmemchr # include -s390_vx_libc_ifunc_redirected (__redirect___wmemchr, __wmemchr) -weak_alias (__wmemchr, wmemchr) +# if HAVE_WMEMCHR_C +extern __typeof (__redirect___wmemchr) WMEMCHR_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_WMEMCHR_Z13 +extern __typeof (__redirect___wmemchr) WMEMCHR_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect___wmemchr, __wmemchr, + (HAVE_WMEMCHR_Z13 && (hwcap & HWCAP_S390_VX)) + ? WMEMCHR_Z13 + : WMEMCHR_DEFAULT + ) +weak_alias (__wmemchr, wmemchr) +#endif From patchwork Fri Nov 30 15:58:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006094 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-97806-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="ci5n4U42"; 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 43617H1Z6wz9sBQ for ; Sat, 1 Dec 2018 04:08:27 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=T9HbEP5QYxnsGXreXF9rbHiLD+1XDbb nN/RtokX6I0Jj3ZEyl12TzwcylACM0r5EA4ve47ga2d8po4jm5fc+LqUjc28NdZ4 3zwk9r43Nm2w+xouPIet4PPlN5ZmD1CpNCKpe6XITtzLtgHtEPwa484wfdqd5DOs 4PK42xj1Y7Zc= 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=AoSqJtw5DnnqwUKLVuvCAawGuzY=; b=ci5n4 U42ju9stzR2OtTWB3P7aQTTAj8o3p13+Glh0SYjj9Mq8bfou2s0CIkqWiIidUGtf QvOr8fEvnuYRj40xbbgEwk5XyJwyJ5poNEI2Y86kyMU1pKSgarV0Z5hJGyChCDFe rr4Jk9c1u9OJI/QH0uH2ahkIYFZCFfV73ewaQM= Received: (qmail 68489 invoked by alias); 30 Nov 2018 17:08:21 -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 68471 invoked by uid 89); 30 Nov 2018 17:08:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 53/56] S390: Refactor wmemset ifunc handling. Date: Fri, 30 Nov 2018 16:58:31 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0008-0000-0000-0000029B03AD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-0009-0000-0000-00002205546B Message-Id: <1543593514-10251-54-git-send-email-stli@linux.ibm.com> The ifunc handling for wmemset is adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Unfortunately the c ifunc variant can't be omitted at all as it is used by the z13 ifunc variant as fallback if the pointers are not 4-byte aligned. Glibc internal calls will use the "newer" ifunc variant. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wmemset variants. * sysdeps/s390/Makefile (sysdep_routines): Add wmemset variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wmemset. * sysdeps/s390/multiarch/wmemset-c.c: Move to ... * sysdeps/s390/wmemset-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wmemset-vx.S: Move to ... * sysdeps/s390/wmemset-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wmemset.c: Move to ... * sysdeps/s390/wmemset.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wmemset.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wmemset.h | 53 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 3 +- sysdeps/s390/multiarch/ifunc-impl-list.c | 15 ++++++- sysdeps/s390/{multiarch => }/wmemset-c.c | 39 ++++++++++------- sysdeps/s390/{multiarch => }/wmemset-vx.S | 22 +++++++--- sysdeps/s390/{multiarch => }/wmemset.c | 23 +++++++--- 7 files changed, 126 insertions(+), 32 deletions(-) create mode 100644 sysdeps/s390/ifunc-wmemset.h rename sysdeps/s390/{multiarch => }/wmemset-c.c (59%) rename sysdeps/s390/{multiarch => }/wmemset-vx.S (91%) rename sysdeps/s390/{multiarch => }/wmemset.c (70%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index 17aabf328b..ae2ae3d2ea 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -99,5 +99,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \ wcsspn wcsspn-vx wcsspn-c \ wcspbrk wcspbrk-vx wcspbrk-c \ wcscspn wcscspn-vx wcscspn-c \ - wmemchr wmemchr-vx wmemchr-c + wmemchr wmemchr-vx wmemchr-c \ + wmemset wmemset-vx wmemset-c endif diff --git a/sysdeps/s390/ifunc-wmemset.h b/sysdeps/s390/ifunc-wmemset.h new file mode 100644 index 0000000000..c9d1d17c3b --- /dev/null +++ b/sysdeps/s390/ifunc-wmemset.h @@ -0,0 +1,53 @@ +/* wmemset variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WMEMSET_IFUNC 1 +#else +# define HAVE_WMEMSET_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WMEMSET_IFUNC_AND_VX_SUPPORT HAVE_WMEMSET_IFUNC +#else +# define HAVE_WMEMSET_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WMEMSET_DEFAULT WMEMSET_Z13 +/* The z13 ifunc variant is using the common code variant as fallback! */ +# define HAVE_WMEMSET_C 1 +# define HAVE_WMEMSET_Z13 1 +#else +# define WMEMSET_DEFAULT WMEMSET_C +# define HAVE_WMEMSET_C 1 +# define HAVE_WMEMSET_Z13 HAVE_WMEMSET_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WMEMSET_C +# define WMEMSET_C __wmemset_c +#else +# define WMEMSET_C NULL +#endif + +#if HAVE_WMEMSET_Z13 +# define WMEMSET_Z13 __wmemset_vx +#else +# define WMEMSET_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index 92e28dc45d..cc6dd7adb1 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,6 +1,5 @@ ifeq ($(subdir),wcsmbs) -sysdep_routines += wmemset wmemset-vx wmemset-c \ - wmemcmp wmemcmp-vx wmemcmp-c +sysdep_routines += wmemcmp wmemcmp-vx wmemcmp-c endif ifeq ($(subdir),iconvdata) diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index b5f55deb7f..7040959269 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -63,6 +63,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -645,6 +646,18 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WMEMCHR_IFUNC */ +#if HAVE_WMEMSET_IFUNC + IFUNC_IMPL (i, name, wmemset, +# if HAVE_WMEMSET_Z13 + IFUNC_IMPL_ADD (array, i, wmemset, + dl_hwcap & HWCAP_S390_VX, WMEMSET_Z13) +# endif +# if HAVE_WMEMSET_C + IFUNC_IMPL_ADD (array, i, wmemset, 1, WMEMSET_C) +# endif + ) +#endif /* HAVE_WMEMSET_IFUNC */ + #ifdef HAVE_S390_VX_ASM_SUPPORT # define IFUNC_VX_IMPL(FUNC) \ @@ -653,8 +666,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __##FUNC##_vx) \ IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - IFUNC_VX_IMPL (wmemset); - IFUNC_VX_IMPL (wmemcmp); #endif /* HAVE_S390_VX_ASM_SUPPORT */ diff --git a/sysdeps/s390/multiarch/wmemset-c.c b/sysdeps/s390/wmemset-c.c similarity index 59% rename from sysdeps/s390/multiarch/wmemset-c.c rename to sysdeps/s390/wmemset-c.c index 1969cf93dc..01e625496d 100644 --- a/sysdeps/s390/multiarch/wmemset-c.c +++ b/sysdeps/s390/wmemset-c.c @@ -16,22 +16,29 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WMEMSET __wmemset_c - -# include -extern __typeof (__wmemset) __wmemset_c; -# undef weak_alias -# define weak_alias(name, alias) -# ifdef SHARED -# undef libc_hidden_def -# define libc_hidden_def(name) \ - __hidden_ver1 (__wmemset_c, __GI___wmemset, __wmemset_c); -# undef libc_hidden_weak -# define libc_hidden_weak(name) \ +#include + +#if HAVE_WMEMSET_C +# if HAVE_WMEMSET_IFUNC || HAVE_WMEMSET_Z13 +# define WMEMSET WMEMSET_C + +# undef weak_alias +# define weak_alias(name, alias) + +# if defined SHARED && IS_IN (libc) +# undef libc_hidden_weak +# define libc_hidden_weak(name) +# undef libc_hidden_def +# if ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define libc_hidden_def(name) \ + __hidden_ver1 (__wmemset_c, __GI_wmemset, __wmemset_c) __attribute__((weak)); \ strong_alias (__wmemset_c, __wmemset_c_1); \ - __hidden_ver1 (__wmemset_c_1, __GI_wmemset, __wmemset_c_1); -# endif /* SHARED */ + __hidden_ver1 (__wmemset_c_1, __GI___wmemset, __wmemset_c_1); +# else +# define libc_hidden_def(name) +# endif +# endif +# endif # include -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +#endif diff --git a/sysdeps/s390/multiarch/wmemset-vx.S b/sysdeps/s390/wmemset-vx.S similarity index 91% rename from sysdeps/s390/multiarch/wmemset-vx.S rename to sysdeps/s390/wmemset-vx.S index 0c2f6337b0..4b6050b5ac 100644 --- a/sysdeps/s390/multiarch/wmemset-vx.S +++ b/sysdeps/s390/wmemset-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WMEMSET_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -38,7 +39,7 @@ -v17,v18,v19=copy of v16 for vstm -v31=saved dest for return */ -ENTRY(__wmemset_vx) +ENTRY(WMEMSET_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -137,6 +138,17 @@ ENTRY(__wmemset_vx) br %r14 .Lfallback: srlg %r4,%r4,2 /* Convert byte-count to character-count. */ - jg __wmemset_c -END(__wmemset_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ + jg WMEMSET_C +END(WMEMSET_Z13) + +# if ! HAVE_WMEMSET_IFUNC +strong_alias (WMEMSET_Z13, __wmemset) +weak_alias (__wmemset, wmemset) +# endif + +# if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT \ + && defined SHARED && IS_IN (libc) +strong_alias (WMEMSET_Z13, __GI___wmemset) +weak_alias (WMEMSET_Z13, __GI_wmemset) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wmemset.c b/sysdeps/s390/wmemset.c similarity index 70% rename from sysdeps/s390/multiarch/wmemset.c rename to sysdeps/s390/wmemset.c index 149b481470..6118754d1d 100644 --- a/sysdeps/s390/multiarch/wmemset.c +++ b/sysdeps/s390/wmemset.c @@ -16,7 +16,9 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WMEMSET_IFUNC # define wmemset __redirect_wmemset # define __wmemset __redirect___wmemset # include @@ -24,9 +26,18 @@ # undef __wmemset # include -s390_vx_libc_ifunc_redirected (__redirect___wmemset, __wmemset) -weak_alias (__wmemset, wmemset) +# if HAVE_WMEMSET_C +extern __typeof (__redirect___wmemset) WMEMSET_C attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +# if HAVE_WMEMSET_Z13 +extern __typeof (__redirect___wmemset) WMEMSET_Z13 attribute_hidden; +# endif + +s390_libc_ifunc_expr (__redirect___wmemset, __wmemset, + (HAVE_WMEMSET_Z13 && (hwcap & HWCAP_S390_VX)) + ? WMEMSET_Z13 + : WMEMSET_DEFAULT + ) +weak_alias (__wmemset, wmemset) +#endif From patchwork Fri Nov 30 15:58:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006085 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-97802-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="q3Qp7SWW"; 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 4360vp2hHDz9rxp for ; Sat, 1 Dec 2018 03:58:30 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=DwsgPpQV0/W4o1QHKoa8kFl0dFpel+H imC6lc3DbkEh/EDj6eKAnjOrJPe7anI9DsaRLnK8jB9tmx8IyOfTzEZTD7ZNfNFu sQJtsiP/vDRaKUJjWMHZ8XtY82sXlCbz2aU6LkDShzp5r8hRgvnGtFNalvCXTTlr 0HbSQSeDdbgc= 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=Y3xSPFZDvRZPe5t8S9W7vj//Xj4=; b=q3Qp7 SWWb5u6ehjDeAAMut3fFsTXlWKI8LcoaROFsApjSwm5YnQhKUl3SQbczIC3Mjs1F siCB8mGW2xepDgnRzk8OZ62rvFYC6nQXd3dnIOZZuOAwwGvSI1VMspecQQdbh6t3 t2VqXMIWV83Oe+xXO+JGyRFRMVBHQHQ1um0e2Y= Received: (qmail 41794 invoked by alias); 30 Nov 2018 16:58:23 -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 41776 invoked by uid 89); 30 Nov 2018 16:58:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 54/56] S390: Refactor wmemcmp ifunc handling. Date: Fri, 30 Nov 2018 16:58:32 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0012-0000-0000-000002D2B628 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-0013-0000-0000-00002108047D Message-Id: <1543593514-10251-55-git-send-email-stli@linux.ibm.com> The ifunc handling for wmemcmp is adjusted in order to omit ifunc variants if those will never be used as the minimum architecture level already supports newer CPUs by default. ChangeLog: * sysdeps/s390/multiarch/Makefile (sysdep_routines): Remove wmemcmp variants. * sysdeps/s390/Makefile (sysdep_routines): Add wmemcmp variants. * sysdeps/s390/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list): Refactor ifunc handling for wmemcmp. * sysdeps/s390/multiarch/wmemcmp-c.c: Move to ... * sysdeps/s390/wmemcmp-c.c: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wmemcmp-vx.S: Move to ... * sysdeps/s390/wmemcmp-vx.S: ... here and adjust ifunc handling. * sysdeps/s390/multiarch/wmemcmp.c: Move to ... * sysdeps/s390/wmemcmp.c: ... here and adjust ifunc handling. * sysdeps/s390/ifunc-wmemcmp.h: New file. --- sysdeps/s390/Makefile | 3 +- sysdeps/s390/ifunc-wmemcmp.h | 52 +++++++++++++++++++++++ sysdeps/s390/multiarch/Makefile | 4 -- sysdeps/s390/multiarch/ifunc-impl-list.c | 23 +++++----- sysdeps/s390/{multiarch => }/wmemcmp-c.c | 9 ++-- sysdeps/s390/{multiarch => }/wmemcmp-vx.S | 13 ++++-- sysdeps/s390/{multiarch => }/wmemcmp.c | 21 ++++++--- 7 files changed, 96 insertions(+), 29 deletions(-) create mode 100644 sysdeps/s390/ifunc-wmemcmp.h rename sysdeps/s390/{multiarch => }/wmemcmp-c.c (85%) rename sysdeps/s390/{multiarch => }/wmemcmp-vx.S (95%) rename sysdeps/s390/{multiarch => }/wmemcmp.c (69%) diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile index ae2ae3d2ea..35fcf7e21d 100644 --- a/sysdeps/s390/Makefile +++ b/sysdeps/s390/Makefile @@ -100,5 +100,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \ wcspbrk wcspbrk-vx wcspbrk-c \ wcscspn wcscspn-vx wcscspn-c \ wmemchr wmemchr-vx wmemchr-c \ - wmemset wmemset-vx wmemset-c + wmemset wmemset-vx wmemset-c \ + wmemcmp wmemcmp-vx wmemcmp-c endif diff --git a/sysdeps/s390/ifunc-wmemcmp.h b/sysdeps/s390/ifunc-wmemcmp.h new file mode 100644 index 0000000000..1b38a01459 --- /dev/null +++ b/sysdeps/s390/ifunc-wmemcmp.h @@ -0,0 +1,52 @@ +/* wmemcmp variant information on S/390 version. + 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 + . */ + +#if defined USE_MULTIARCH && IS_IN (libc) \ + && ! defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define HAVE_WMEMCMP_IFUNC 1 +#else +# define HAVE_WMEMCMP_IFUNC 0 +#endif + +#ifdef HAVE_S390_VX_ASM_SUPPORT +# define HAVE_WMEMCMP_IFUNC_AND_VX_SUPPORT HAVE_WMEMCMP_IFUNC +#else +# define HAVE_WMEMCMP_IFUNC_AND_VX_SUPPORT 0 +#endif + +#if defined HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +# define WMEMCMP_DEFAULT WMEMCMP_Z13 +# define HAVE_WMEMCMP_C 0 +# define HAVE_WMEMCMP_Z13 1 +#else +# define WMEMCMP_DEFAULT WMEMCMP_C +# define HAVE_WMEMCMP_C 1 +# define HAVE_WMEMCMP_Z13 HAVE_WMEMCMP_IFUNC_AND_VX_SUPPORT +#endif + +#if HAVE_WMEMCMP_C +# define WMEMCMP_C __wmemcmp_c +#else +# define WMEMCMP_C NULL +#endif + +#if HAVE_WMEMCMP_Z13 +# define WMEMCMP_Z13 __wmemcmp_vx +#else +# define WMEMCMP_Z13 NULL +#endif diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile index cc6dd7adb1..fec3615304 100644 --- a/sysdeps/s390/multiarch/Makefile +++ b/sysdeps/s390/multiarch/Makefile @@ -1,7 +1,3 @@ -ifeq ($(subdir),wcsmbs) -sysdep_routines += wmemcmp wmemcmp-vx wmemcmp-c -endif - ifeq ($(subdir),iconvdata) override define generate-8bit-table $(make-target-directory) diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index 7040959269..177c5fd6fe 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -64,6 +64,7 @@ #include #include #include +#include /* Maximum number of IFUNC implementations. */ #define MAX_IFUNC 3 @@ -658,17 +659,17 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WMEMSET_IFUNC */ -#ifdef HAVE_S390_VX_ASM_SUPPORT - -# define IFUNC_VX_IMPL(FUNC) \ - IFUNC_IMPL (i, name, FUNC, \ - IFUNC_IMPL_ADD (array, i, FUNC, dl_hwcap & HWCAP_S390_VX, \ - __##FUNC##_vx) \ - IFUNC_IMPL_ADD (array, i, FUNC, 1, __##FUNC##_c)) - - IFUNC_VX_IMPL (wmemcmp); - -#endif /* HAVE_S390_VX_ASM_SUPPORT */ +#if HAVE_WMEMCMP_IFUNC + IFUNC_IMPL (i, name, wmemcmp, +# if HAVE_WMEMCMP_Z13 + IFUNC_IMPL_ADD (array, i, wmemcmp, + dl_hwcap & HWCAP_S390_VX, WMEMCMP_Z13) +# endif +# if HAVE_WMEMCMP_C + IFUNC_IMPL_ADD (array, i, wmemcmp, 1, WMEMCMP_C) +# endif + ) +#endif /* HAVE_WMEMCMP_IFUNC */ return i; } diff --git a/sysdeps/s390/multiarch/wmemcmp-c.c b/sysdeps/s390/wmemcmp-c.c similarity index 85% rename from sysdeps/s390/multiarch/wmemcmp-c.c rename to sysdeps/s390/wmemcmp-c.c index 2fd39d5013..0c73636add 100644 --- a/sysdeps/s390/multiarch/wmemcmp-c.c +++ b/sysdeps/s390/wmemcmp-c.c @@ -16,11 +16,12 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) -# define WMEMCMP __wmemcmp_c +#include -# include -extern __typeof (wmemcmp) __wmemcmp_c; +#if HAVE_WMEMCMP_C +# if HAVE_WMEMCMP_IFUNC +# define WMEMCMP WMEMCMP_C +# endif # include #endif diff --git a/sysdeps/s390/multiarch/wmemcmp-vx.S b/sysdeps/s390/wmemcmp-vx.S similarity index 95% rename from sysdeps/s390/multiarch/wmemcmp-vx.S rename to sysdeps/s390/wmemcmp-vx.S index e2fc21e419..87ae21b4f1 100644 --- a/sysdeps/s390/multiarch/wmemcmp-vx.S +++ b/sysdeps/s390/wmemcmp-vx.S @@ -16,7 +16,8 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include +#if HAVE_WMEMCMP_Z13 # include "sysdep.h" # include "asm-syntax.h" @@ -37,7 +38,7 @@ -v17=part of s2 -v18=index of unequal */ -ENTRY(__wmemcmp_vx) +ENTRY(WMEMCMP_Z13) .machine "z13" .machinemode "zarch_nohighgprs" @@ -145,5 +146,9 @@ ENTRY(__wmemcmp_vx) la %r2,0(%r5,%r2) la %r3,0(%r5,%r3) j .Lremaining -END(__wmemcmp_vx) -#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */ +END(WMEMCMP_Z13) + +# if ! HAVE_WMEMCMP_IFUNC +strong_alias (WMEMCMP_Z13, wmemcmp) +# endif +#endif diff --git a/sysdeps/s390/multiarch/wmemcmp.c b/sysdeps/s390/wmemcmp.c similarity index 69% rename from sysdeps/s390/multiarch/wmemcmp.c rename to sysdeps/s390/wmemcmp.c index a4cb440c45..6c8ca5f0e8 100644 --- a/sysdeps/s390/multiarch/wmemcmp.c +++ b/sysdeps/s390/wmemcmp.c @@ -16,12 +16,23 @@ License along with the GNU C Library; if not, see . */ -#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) +#include + +#if HAVE_WMEMCMP_IFUNC # include # include -s390_vx_libc_ifunc2 (__wmemcmp, wmemcmp) +# if HAVE_WMEMCMP_C +extern __typeof (wmemcmp) WMEMCMP_C attribute_hidden; +# endif + +# if HAVE_WMEMCMP_Z13 +extern __typeof (wmemcmp) WMEMCMP_Z13 attribute_hidden; +# endif -#else -# include -#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)) */ +s390_libc_ifunc_expr (wmemcmp, wmemcmp, + (HAVE_WMEMCMP_Z13 && (hwcap & HWCAP_S390_VX)) + ? WMEMCMP_Z13 + : WMEMCMP_DEFAULT + ) +#endif From patchwork Fri Nov 30 15:58:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006073 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-97799-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="PO6VhyVR"; 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 43605c07zTz9s8r for ; Sat, 1 Dec 2018 03:21:55 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=ZMWkEm3PeAokLhnl5/uc7CBG8LPFNza YTeEDyJf7kZGoP7qZXyv+GutJVbcmyBDMEjWBgeEhMBlzXOOOzCx+rd39jBYOmH0 nH5CxdUsH4YIvXZufdOLYfBALRFDzWOf7MALP7d5/OYnGaUKK8Byv8PzUgWzZcCc PSEztRaEcPps= 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=YdYTlox0xhS3P/pdAr/FvZogZaI=; b=PO6Vh yVRa/WXnsh8rrcMIjMypqP9XI+HQhBzcm8dTrfLWV+8SvphtMCisRm4ct54n5ezU KlH3TJ4gwUnYLu6JEJvrWqxYOwc0lE6L2VaUCKBqI9Zhsd2/IC0r+r0b+nz81bLe BMzaGCjtBiCdU6eZQYmZI+2W4td83H0MeTt0kQ= Received: (qmail 44358 invoked by alias); 30 Nov 2018 16:21: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 44342 invoked by uid 89); 30 Nov 2018 16:21:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 55/56] S390: Refactor gconv_simple ifunc handling. Date: Fri, 30 Nov 2018 16:58:33 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0012-0000-0000-000002D2B629 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-0013-0000-0000-00002108047E Message-Id: <1543593514-10251-56-git-send-email-stli@linux.ibm.com> The ifunc handling for various __gconv_transform_* functions which are using IFUNC on s390x are adjusted in order to omit ifunc if the minimum architecture level already supports newer CPUs by default. Instead those functions are just an alias to the vector variants. Furthermore the ifunc-macro s390_libc_ifunc_expr is now used instead of s390_vx_libc_ifunc. ChangeLog: * sysdeps/s390/multiarch/gconv_simple.c (ICONV_VX_IFUNC): Define macro dependent on HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT. --- sysdeps/s390/multiarch/gconv_simple.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/sysdeps/s390/multiarch/gconv_simple.c b/sysdeps/s390/multiarch/gconv_simple.c index aaa1ebf74a..078d992c13 100644 --- a/sysdeps/s390/multiarch/gconv_simple.c +++ b/sysdeps/s390/multiarch/gconv_simple.c @@ -27,17 +27,18 @@ # define ICONV_C_NAME(NAME) __##NAME##_c # define ICONV_VX_NAME(NAME) __##NAME##_vx -# define ICONV_VX_IFUNC(FUNC) \ - extern __typeof (ICONV_C_NAME (FUNC)) __##FUNC; \ - s390_vx_libc_ifunc (__##FUNC) \ - int FUNC (struct __gconv_step *step, struct __gconv_step_data *data, \ - const unsigned char **inptrp, const unsigned char *inend, \ - unsigned char **outbufstart, size_t *irreversible, \ - int do_flush, int consume_incomplete) \ - { \ - return __##FUNC (step, data, inptrp, inend,outbufstart, \ - irreversible, do_flush, consume_incomplete); \ - } +# ifdef HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT +/* We support z13 instructions by default -> Just use the vector variant. */ +# define ICONV_VX_IFUNC(FUNC) strong_alias (ICONV_VX_NAME (FUNC), FUNC) +# else +/* We have to use ifunc to determine if z13 instructions are supported. */ +# define ICONV_VX_IFUNC(FUNC) \ + s390_libc_ifunc_expr (ICONV_C_NAME (FUNC), FUNC, \ + (hwcap & HWCAP_S390_VX) \ + ? ICONV_VX_NAME (FUNC) \ + : ICONV_C_NAME (FUNC) \ + ) +# endif # define ICONV_VX_SINGLE(NAME) \ static __typeof (NAME##_single) __##NAME##_vx_single __attribute__((alias(#NAME "_single"))); From patchwork Fri Nov 30 15:58:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1006136 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-97813-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="MEr0Pxc1"; 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 4362f13p6bz9s8T for ; Sat, 1 Dec 2018 05:16:41 +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:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=l7hlrhCN3SSO3DBsbyOgdVYH2PYUtwM NEyjhTE2DRcDnbzvpJbhk97UB7RG6YtWLZ6D5pt4s20makf+I3CkIQNCNV2CzooQ c8LDuE4SaR9Q22sB2UstFMJoJI4XY/w4izXPO4RlztdaOMl27K98ZSi58hLGhYY+ W9cc6cSogBK4= 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=aq9Y313iYT1vPVJbpMPA+GmacYs=; b=MEr0P xc1If5IEZmwWTBTnF+TSy04LynUR61Z4zUUSayRpkDa/44VWu62VZ0nQqoF0cijW ONi3BhomMTMdNk/Ln4C26yP7O4qv3H/Nd9clKREg67AfNGYtweZhCh7BX5lh6qLE Wrj0tX19/pcxDLQIEXHJfBuyqA77JBKIHCF3GM= Received: (qmail 90840 invoked by alias); 30 Nov 2018 18:16:34 -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 90830 invoked by uid 89); 30 Nov 2018 18:16:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=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: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 56/56] S390: Cleanup ifunc-resolve.h. Date: Fri, 30 Nov 2018 16:58:34 +0100 In-Reply-To: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> References: <1543593514-10251-1-git-send-email-stli@linux.ibm.com> x-cbid: 18113016-0008-0000-0000-0000029B03AF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113016-0009-0000-0000-00002205546E Message-Id: <1543593514-10251-57-git-send-email-stli@linux.ibm.com> The ifunc macros s390_vx_libc* are no longer used and can be removed as all users are now relying on s390_libc_ifunc_expr. The same applies to s390_libc_ifunc. The macro s390_libc_ifunc_init is now renamed to s390_libc_ifunc_expr_stfle_init and the users are adjusted accordingly. ChangeLog: * sysdeps/s390/multiarch/ifunc-resolve.h (s390_vx_libc_ifunc, s390_vx_libc_ifunc_redirected, s390_vx_libc_ifunc2, s390_vx_libc_ifunc_init, s390_vx_libc_ifunc2_redirected, s390_libc_ifunc): Delete macro definition. (s390_libc_ifunc_init): Rename to s390_libc_ifunc_expr_stfle_init. * sysdeps/s390/bzero: Use s390_libc_ifunc_expr_stfle_init instead of s390_libc_ifunc_init. * sysdeps/s390/memcmp.c: Likewise. * sysdeps/s390/memcpy.c: Likewise. * sysdeps/s390/mempcpy.c: Likewise. * sysdeps/s390/memset.c: Likewise. --- sysdeps/s390/bzero.c | 2 +- sysdeps/s390/memcmp.c | 2 +- sysdeps/s390/memcpy.c | 2 +- sysdeps/s390/mempcpy.c | 2 +- sysdeps/s390/memset.c | 2 +- sysdeps/s390/multiarch/ifunc-resolve.h | 37 +------------------------- 6 files changed, 6 insertions(+), 41 deletions(-) diff --git a/sysdeps/s390/bzero.c b/sysdeps/s390/bzero.c index 9f8d95781b..6b5d471c40 100644 --- a/sysdeps/s390/bzero.c +++ b/sysdeps/s390/bzero.c @@ -35,7 +35,7 @@ extern __typeof (__bzero) BZERO_Z196 attribute_hidden; s390_libc_ifunc_expr (__bzero, __bzero, ({ - s390_libc_ifunc_init (); + s390_libc_ifunc_expr_stfle_init (); (HAVE_MEMSET_Z196 && S390_IS_Z196 (stfle_bits)) ? BZERO_Z196 : (HAVE_MEMSET_Z10 && S390_IS_Z10 (stfle_bits)) diff --git a/sysdeps/s390/memcmp.c b/sysdeps/s390/memcmp.c index 952ff6af73..6d9276320a 100644 --- a/sysdeps/s390/memcmp.c +++ b/sysdeps/s390/memcmp.c @@ -37,7 +37,7 @@ extern __typeof (__redirect_memcmp) MEMCMP_Z196 attribute_hidden; s390_libc_ifunc_expr (__redirect_memcmp, memcmp, ({ - s390_libc_ifunc_init (); + s390_libc_ifunc_expr_stfle_init (); (HAVE_MEMCMP_Z196 && S390_IS_Z196 (stfle_bits)) ? MEMCMP_Z196 : (HAVE_MEMCMP_Z10 && S390_IS_Z10 (stfle_bits)) diff --git a/sysdeps/s390/memcpy.c b/sysdeps/s390/memcpy.c index 90a53ac27d..0ff24f18cf 100644 --- a/sysdeps/s390/memcpy.c +++ b/sysdeps/s390/memcpy.c @@ -38,7 +38,7 @@ extern __typeof (__redirect_memcpy) MEMCPY_Z196 attribute_hidden; s390_libc_ifunc_expr (__redirect_memcpy, memcpy, ({ - s390_libc_ifunc_init (); + s390_libc_ifunc_expr_stfle_init (); (HAVE_MEMCPY_Z196 && S390_IS_Z196 (stfle_bits)) ? MEMCPY_Z196 : (HAVE_MEMCPY_Z10 && S390_IS_Z10 (stfle_bits)) diff --git a/sysdeps/s390/mempcpy.c b/sysdeps/s390/mempcpy.c index a6a2373126..b687b33620 100644 --- a/sysdeps/s390/mempcpy.c +++ b/sysdeps/s390/mempcpy.c @@ -42,7 +42,7 @@ extern __typeof (__redirect___mempcpy) MEMPCPY_Z196 attribute_hidden; s390_libc_ifunc_expr (__redirect___mempcpy, __mempcpy, ({ - s390_libc_ifunc_init (); + s390_libc_ifunc_expr_stfle_init (); (HAVE_MEMCPY_Z196 && S390_IS_Z196 (stfle_bits)) ? MEMPCPY_Z196 : (HAVE_MEMCPY_Z10 && S390_IS_Z10 (stfle_bits)) diff --git a/sysdeps/s390/memset.c b/sysdeps/s390/memset.c index 57a35aebc7..75b011f1a2 100644 --- a/sysdeps/s390/memset.c +++ b/sysdeps/s390/memset.c @@ -37,7 +37,7 @@ extern __typeof (__redirect_memset) MEMSET_Z196 attribute_hidden; s390_libc_ifunc_expr (__redirect_memset, memset, ({ - s390_libc_ifunc_init (); + s390_libc_ifunc_expr_stfle_init (); (HAVE_MEMSET_Z196 && S390_IS_Z196 (stfle_bits)) ? MEMSET_Z196 : (HAVE_MEMSET_Z10 && S390_IS_Z10 (stfle_bits)) diff --git a/sysdeps/s390/multiarch/ifunc-resolve.h b/sysdeps/s390/multiarch/ifunc-resolve.h index 6139bd39c5..e4b71c66f6 100644 --- a/sysdeps/s390/multiarch/ifunc-resolve.h +++ b/sysdeps/s390/multiarch/ifunc-resolve.h @@ -40,7 +40,7 @@ ".machine pop" "\n" \ : "=QS" (STFLE_BITS), "+d" (reg0) \ : : "cc"); -#define s390_libc_ifunc_init() \ +#define s390_libc_ifunc_expr_stfle_init() \ unsigned long long stfle_bits = 0ULL; \ if (__glibc_likely((hwcap & HWCAP_S390_STFLE) \ && (hwcap & HWCAP_S390_ZARCH) \ @@ -49,41 +49,6 @@ S390_STORE_STFLE (stfle_bits); \ } -#define s390_libc_ifunc(TYPE_FUNC, RESOLVERFUNC, FUNC) \ - /* Make the declarations of the optimized functions hidden in order - to prevent GOT slots being generated for them. */ \ - extern __typeof (TYPE_FUNC) RESOLVERFUNC##_z196 attribute_hidden; \ - extern __typeof (TYPE_FUNC) RESOLVERFUNC##_z10 attribute_hidden; \ - extern __typeof (TYPE_FUNC) RESOLVERFUNC##_default attribute_hidden; \ - __ifunc (TYPE_FUNC, FUNC, \ - __glibc_likely (S390_IS_Z196 (stfle_bits)) \ - ? RESOLVERFUNC##_z196 \ - : __glibc_likely (S390_IS_Z10 (stfle_bits)) \ - ? RESOLVERFUNC##_z10 \ - : RESOLVERFUNC##_default, \ - unsigned long int hwcap, s390_libc_ifunc_init); - -#define s390_vx_libc_ifunc(FUNC) \ - s390_vx_libc_ifunc2_redirected(FUNC, FUNC, FUNC) - -#define s390_vx_libc_ifunc_redirected(TYPE_FUNC, FUNC) \ - s390_vx_libc_ifunc2_redirected(TYPE_FUNC, FUNC, FUNC) - -#define s390_vx_libc_ifunc2(RESOLVERFUNC, FUNC) \ - s390_vx_libc_ifunc2_redirected(FUNC, RESOLVERFUNC, FUNC) - -#define s390_vx_libc_ifunc_init() -#define s390_vx_libc_ifunc2_redirected(TYPE_FUNC, RESOLVERFUNC, FUNC) \ - /* Make the declarations of the optimized functions hidden in order - to prevent GOT slots being generated for them. */ \ - extern __typeof (TYPE_FUNC) RESOLVERFUNC##_vx attribute_hidden; \ - extern __typeof (TYPE_FUNC) RESOLVERFUNC##_c attribute_hidden; \ - __ifunc (TYPE_FUNC, FUNC, \ - (hwcap & HWCAP_S390_VX) \ - ? RESOLVERFUNC##_vx \ - : RESOLVERFUNC##_c, \ - unsigned long int hwcap, s390_vx_libc_ifunc_init); - #define s390_libc_ifunc_expr_init() #define s390_libc_ifunc_expr(TYPE_FUNC, FUNC, EXPR) \ __ifunc (TYPE_FUNC, FUNC, EXPR, unsigned long int hwcap, \