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