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: 30422 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