077c9d
commit 18eb862d454a41012ccdd5127715ef7cd2a711ec
077c9d
Author: Stefan Liebler <stli@linux.ibm.com>
077c9d
Date:   Tue Dec 18 13:57:06 2018 +0100
077c9d
077c9d
    S390: Refactor memcpy/mempcpy ifunc handling.
077c9d
    
077c9d
    This patch moves all ifunc variants for memcpy/mempcpy
077c9d
    to sysdeps/s390/memcpy-z900.S. The configure-check/preprocessor logic
077c9d
    in sysdeps/s390/ifunc-memcpy.h decides if ifunc is needed at all
077c9d
    and which ifunc variants should be available.
077c9d
    E.g. if the compiler/assembler already supports z196 by default,
077c9d
    the older ifunc variants are not included.
077c9d
    If we only need the newest ifunc variant,
077c9d
    then we can skip ifunc at all.
077c9d
    
077c9d
    Therefore the ifunc-resolvers and __libc_ifunc_impl_list are adjusted
077c9d
    in order to handle only the available ifunc variants.
077c9d
    
077c9d
    ChangeLog:
077c9d
    
077c9d
            * sysdeps/s390/ifunc-memcpy.h: New File.
077c9d
            * sysdeps/s390/memcpy.S: Move to ...
077c9d
            * sysdeps/s390/memcpy-z900.S ... here.
077c9d
            Move implementations from memcpy-s390x.s to here.
077c9d
            * sysdeps/s390/multiarch/memcpy-s390x.S: Delete File.
077c9d
            * sysdeps/s390/multiarch/Makefile (sysdep_routines):
077c9d
            Remove memcpy/mempcpy variants.
077c9d
            * sysdeps/s390/Makefile (sysdep_routines):
077c9d
            Add memcpy/mempcpy variants.
077c9d
            * sysdeps/s390/multiarch/ifunc-impl-list.c
077c9d
            (__libc_ifunc_impl_list): Adjust ifunc variants for
077c9d
            memcpy and mempcpy.
077c9d
            * sysdeps/s390/multiarch/memcpy.c: Move ifunc resolver
077c9d
            to ...
077c9d
            * sysdeps/s390/memcpy.c: ... here.
077c9d
            Adjust ifunc variants for memcpy.
077c9d
            * sysdeps/s390/multiarch/mempcpy.c: Move to ...
077c9d
            * sysdeps/s390/mempcpy.c: ... here.
077c9d
            Adjust ifunc variants for mempcpy.
077c9d
            * sysdeps/s390/mempcpy.S: Delete file.
077c9d
077c9d
diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile
077c9d
index c59cbdc25aad408a..838950a5ab958e31 100644
077c9d
--- a/sysdeps/s390/Makefile
077c9d
+++ b/sysdeps/s390/Makefile
077c9d
@@ -32,5 +32,6 @@ endif
077c9d
 
077c9d
 ifeq ($(subdir),string)
077c9d
 sysdep_routines += bzero memset memset-z900 \
077c9d
-		   memcmp memcmp-z900
077c9d
+		   memcmp memcmp-z900 \
077c9d
+		   mempcpy memcpy memcpy-z900
077c9d
 endif
077c9d
diff --git a/sysdeps/s390/ifunc-memcpy.h b/sysdeps/s390/ifunc-memcpy.h
077c9d
new file mode 100644
077c9d
index 0000000000000000..51c71baa2c0b0452
077c9d
--- /dev/null
077c9d
+++ b/sysdeps/s390/ifunc-memcpy.h
077c9d
@@ -0,0 +1,68 @@
077c9d
+/* memcpy variant information on S/390 version.
077c9d
+   Copyright (C) 2018 Free Software Foundation, Inc.
077c9d
+   This file is part of the GNU C Library.
077c9d
+
077c9d
+   The GNU C Library is free software; you can redistribute it and/or
077c9d
+   modify it under the terms of the GNU Lesser General Public
077c9d
+   License as published by the Free Software Foundation; either
077c9d
+   version 2.1 of the License, or (at your option) any later version.
077c9d
+
077c9d
+   The GNU C Library is distributed in the hope that it will be useful,
077c9d
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
077c9d
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
077c9d
+   Lesser General Public License for more details.
077c9d
+
077c9d
+   You should have received a copy of the GNU Lesser General Public
077c9d
+   License along with the GNU C Library; if not, see
077c9d
+   <http://www.gnu.org/licenses/>.  */
077c9d
+
077c9d
+#if defined SHARED && defined USE_MULTIARCH && IS_IN (libc)	\
077c9d
+  && ! defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
077c9d
+# define HAVE_MEMCPY_IFUNC	1
077c9d
+#else
077c9d
+# define HAVE_MEMCPY_IFUNC	0
077c9d
+#endif
077c9d
+
077c9d
+#if defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
077c9d
+# define MEMCPY_DEFAULT		MEMCPY_Z196
077c9d
+# define MEMPCPY_DEFAULT	MEMPCPY_Z196
077c9d
+# define HAVE_MEMCPY_Z900_G5	0
077c9d
+# define HAVE_MEMCPY_Z10	0
077c9d
+# define HAVE_MEMCPY_Z196	1
077c9d
+#elif defined HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT
077c9d
+# define MEMCPY_DEFAULT		MEMCPY_Z10
077c9d
+# define MEMPCPY_DEFAULT	MEMPCPY_Z10
077c9d
+# define HAVE_MEMCPY_Z900_G5	0
077c9d
+# define HAVE_MEMCPY_Z10	1
077c9d
+# define HAVE_MEMCPY_Z196	HAVE_MEMCPY_IFUNC
077c9d
+#else
077c9d
+# define MEMCPY_DEFAULT		MEMCPY_Z900_G5
077c9d
+# define MEMPCPY_DEFAULT	MEMPCPY_Z900_G5
077c9d
+# define HAVE_MEMCPY_Z900_G5	1
077c9d
+# define HAVE_MEMCPY_Z10	HAVE_MEMCPY_IFUNC
077c9d
+# define HAVE_MEMCPY_Z196	HAVE_MEMCPY_IFUNC
077c9d
+#endif
077c9d
+
077c9d
+#if HAVE_MEMCPY_Z900_G5
077c9d
+# define MEMCPY_Z900_G5		__memcpy_default
077c9d
+# define MEMPCPY_Z900_G5	__mempcpy_default
077c9d
+#else
077c9d
+# define MEMCPY_Z900_G5		NULL
077c9d
+# define MEMPCPY_Z900_G5	NULL
077c9d
+#endif
077c9d
+
077c9d
+#if HAVE_MEMCPY_Z10
077c9d
+# define MEMCPY_Z10		__memcpy_z10
077c9d
+# define MEMPCPY_Z10		__mempcpy_z10
077c9d
+#else
077c9d
+# define MEMCPY_Z10		NULL
077c9d
+# define MEMPCPY_Z10		NULL
077c9d
+#endif
077c9d
+
077c9d
+#if HAVE_MEMCPY_Z196
077c9d
+# define MEMCPY_Z196		__memcpy_z196
077c9d
+# define MEMPCPY_Z196		__mempcpy_z196
077c9d
+#else
077c9d
+# define MEMCPY_Z196		NULL
077c9d
+# define MEMPCPY_Z196		NULL
077c9d
+#endif
077c9d
diff --git a/sysdeps/s390/memcpy.S b/sysdeps/s390/memcpy-z900.S
077c9d
similarity index 50%
077c9d
rename from sysdeps/s390/memcpy.S
077c9d
rename to sysdeps/s390/memcpy-z900.S
077c9d
index 2a6c6b750377c7bb..3a50cf44d85d2417 100644
077c9d
--- a/sysdeps/s390/memcpy.S
077c9d
+++ b/sysdeps/s390/memcpy-z900.S
077c9d
@@ -19,6 +19,7 @@
077c9d
 
077c9d
 #include <sysdep.h>
077c9d
 #include "asm-syntax.h"
077c9d
+#include <ifunc-memcpy.h>
077c9d
 
077c9d
 /* INPUT PARAMETERS
077c9d
      %r2 = address of destination memory area
077c9d
@@ -41,50 +42,46 @@
077c9d
 # define BRCTG	brct
077c9d
 #endif /* ! defined __s390x__  */
077c9d
 
077c9d
-ENTRY(__mempcpy)
077c9d
-#if defined __s390x__
077c9d
+#if HAVE_MEMCPY_Z900_G5
077c9d
+ENTRY(MEMPCPY_Z900_G5)
077c9d
+# if defined __s390x__
077c9d
 	.machine "z900"
077c9d
-#else
077c9d
+# else
077c9d
 	.machine "g5"
077c9d
-#endif /* ! defined __s390x__  */
077c9d
+# endif /* ! defined __s390x__  */
077c9d
 	LGR     %r1,%r2             # Use as dest
077c9d
 	la      %r2,0(%r4,%r2)      # Return dest + n
077c9d
 	j	.L_Z900_G5_start
077c9d
-END(__mempcpy)
077c9d
-#ifndef USE_MULTIARCH
077c9d
-libc_hidden_def (__mempcpy)
077c9d
-weak_alias (__mempcpy, mempcpy)
077c9d
-libc_hidden_builtin_def (mempcpy)
077c9d
-#endif
077c9d
+END(MEMPCPY_Z900_G5)
077c9d
 
077c9d
-ENTRY(memcpy)
077c9d
-#if defined __s390x__
077c9d
+ENTRY(MEMCPY_Z900_G5)
077c9d
+# if defined __s390x__
077c9d
 	.machine "z900"
077c9d
-#else
077c9d
+# else
077c9d
 	.machine "g5"
077c9d
-#endif /* ! defined __s390x__  */
077c9d
+# endif /* ! defined __s390x__  */
077c9d
 	LGR     %r1,%r2             # r1: Use as dest ; r2: Return dest
077c9d
 .L_Z900_G5_start:
077c9d
 	LTGR    %r4,%r4
077c9d
 	je      .L_Z900_G5_4
077c9d
 	AGHI    %r4,-1
077c9d
-#if defined __s390x__
077c9d
+# if defined __s390x__
077c9d
 	srlg	%r5,%r4,8
077c9d
-#else
077c9d
+# else
077c9d
 	lr	%r5,%r4
077c9d
 	srl	%r5,8
077c9d
-#endif /* ! defined __s390x__  */
077c9d
+# endif /* ! defined __s390x__  */
077c9d
 	LTGR    %r5,%r5
077c9d
 	jne     .L_Z900_G5_13
077c9d
 .L_Z900_G5_3:
077c9d
-#if defined __s390x__
077c9d
+# if defined __s390x__
077c9d
 	larl    %r5,.L_Z900_G5_15
077c9d
-# define Z900_G5_EX_D 0
077c9d
-#else
077c9d
+#  define Z900_G5_EX_D 0
077c9d
+# else
077c9d
 	basr    %r5,0
077c9d
 .L_Z900_G5_14:
077c9d
-# define Z900_G5_EX_D .L_Z900_G5_15-.L_Z900_G5_14
077c9d
-#endif /* ! defined __s390x__  */
077c9d
+#  define Z900_G5_EX_D .L_Z900_G5_15-.L_Z900_G5_14
077c9d
+# endif /* ! defined __s390x__  */
077c9d
 	ex      %r4,Z900_G5_EX_D(%r5)
077c9d
 .L_Z900_G5_4:
077c9d
 	br      %r14
077c9d
@@ -99,10 +96,8 @@ ENTRY(memcpy)
077c9d
 	j       .L_Z900_G5_3
077c9d
 .L_Z900_G5_15:
077c9d
 	mvc     0(1,%r1),0(%r3)
077c9d
-END(memcpy)
077c9d
-#ifndef USE_MULTIARCH
077c9d
-libc_hidden_builtin_def (memcpy)
077c9d
-#endif
077c9d
+END(MEMCPY_Z900_G5)
077c9d
+#endif /* HAVE_MEMCPY_Z900_G5  */
077c9d
 
077c9d
 ENTRY(__memcpy_mvcle)
077c9d
 	# Using as standalone function will result in unexpected
077c9d
@@ -126,3 +121,104 @@ END(__memcpy_mvcle)
077c9d
 #undef LGR
077c9d
 #undef AGHI
077c9d
 #undef BRCTG
077c9d
+
077c9d
+#if HAVE_MEMCPY_Z10
077c9d
+ENTRY(MEMPCPY_Z10)
077c9d
+	.machine "z10"
077c9d
+	.machinemode "zarch_nohighgprs"
077c9d
+	lgr     %r1,%r2         # Use as dest
077c9d
+	la      %r2,0(%r4,%r2)  # Return dest + n
077c9d
+	j	.L_Z10_start
077c9d
+END(MEMPCPY_Z10)
077c9d
+
077c9d
+ENTRY(MEMCPY_Z10)
077c9d
+	.machine "z10"
077c9d
+	.machinemode "zarch_nohighgprs"
077c9d
+	lgr     %r1,%r2         # r1: Use as dest ; r2: Return dest
077c9d
+.L_Z10_start:
077c9d
+# if !defined __s390x__
077c9d
+	llgfr	%r4,%r4
077c9d
+# endif /* !defined __s390x__  */
077c9d
+	cgije   %r4,0,.L_Z10_4
077c9d
+	aghi    %r4,-1
077c9d
+	srlg    %r5,%r4,8
077c9d
+	cgijlh  %r5,0,.L_Z10_13
077c9d
+.L_Z10_3:
077c9d
+	exrl    %r4,.L_Z10_15
077c9d
+.L_Z10_4:
077c9d
+	br      %r14
077c9d
+.L_Z10_13:
077c9d
+	cgfi    %r5,65535	# Switch to mvcle for copies >16MB
077c9d
+	jh      __memcpy_mvcle
077c9d
+.L_Z10_12:
077c9d
+	pfd     1,768(%r3)
077c9d
+	pfd     2,768(%r1)
077c9d
+	mvc     0(256,%r1),0(%r3)
077c9d
+	la      %r1,256(%r1)
077c9d
+	la      %r3,256(%r3)
077c9d
+	brctg   %r5,.L_Z10_12
077c9d
+	j       .L_Z10_3
077c9d
+.L_Z10_15:
077c9d
+	mvc     0(1,%r1),0(%r3)
077c9d
+END(MEMCPY_Z10)
077c9d
+#endif /* HAVE_MEMCPY_Z10  */
077c9d
+
077c9d
+#if HAVE_MEMCPY_Z196
077c9d
+ENTRY(MEMPCPY_Z196)
077c9d
+	.machine "z196"
077c9d
+	.machinemode "zarch_nohighgprs"
077c9d
+	lgr     %r1,%r2         # Use as dest
077c9d
+	la      %r2,0(%r4,%r2)  # Return dest + n
077c9d
+	j	.L_Z196_start
077c9d
+END(MEMPCPY_Z196)
077c9d
+
077c9d
+ENTRY(MEMCPY_Z196)
077c9d
+	.machine "z196"
077c9d
+	.machinemode "zarch_nohighgprs"
077c9d
+	lgr     %r1,%r2         # r1: Use as dest ; r2: Return dest
077c9d
+.L_Z196_start:
077c9d
+# if !defined __s390x__
077c9d
+	llgfr	%r4,%r4
077c9d
+# endif /* !defined __s390x__  */
077c9d
+	ltgr    %r4,%r4
077c9d
+	je      .L_Z196_4
077c9d
+	aghi    %r4,-1
077c9d
+	srlg    %r5,%r4,8
077c9d
+	ltgr    %r5,%r5
077c9d
+	jne     .L_Z196_5
077c9d
+.L_Z196_3:
077c9d
+	exrl    %r4,.L_Z196_14
077c9d
+.L_Z196_4:
077c9d
+	br      %r14
077c9d
+.L_Z196_5:
077c9d
+	cgfi    %r5,262144      # Switch to mvcle for copies >64MB
077c9d
+	jh      __memcpy_mvcle
077c9d
+.L_Z196_2:
077c9d
+	pfd     1,768(%r3)
077c9d
+	pfd     2,768(%r1)
077c9d
+	mvc     0(256,%r1),0(%r3)
077c9d
+	aghi    %r5,-1
077c9d
+	la      %r1,256(%r1)
077c9d
+	la      %r3,256(%r3)
077c9d
+	jne     .L_Z196_2
077c9d
+	j       .L_Z196_3
077c9d
+.L_Z196_14:
077c9d
+	mvc     0(1,%r1),0(%r3)
077c9d
+END(MEMCPY_Z196)
077c9d
+#endif /* HAVE_MEMCPY_Z196  */
077c9d
+
077c9d
+#if ! HAVE_MEMCPY_IFUNC
077c9d
+/* If we don't use ifunc, define an alias for mem[p]cpy here.
077c9d
+   Otherwise see sysdeps/s390/mem[p]cpy.c.  */
077c9d
+strong_alias (MEMCPY_DEFAULT, memcpy)
077c9d
+strong_alias (MEMPCPY_DEFAULT, __mempcpy)
077c9d
+weak_alias (__mempcpy, mempcpy)
077c9d
+#endif
077c9d
+
077c9d
+#if defined SHARED && IS_IN (libc)
077c9d
+/* Defines the internal symbols.
077c9d
+   Compare to libc_hidden_[builtin_]def (mem[p]cpy) in string/mem[p]cpy.c.  */
077c9d
+strong_alias (MEMCPY_DEFAULT, __GI_memcpy)
077c9d
+strong_alias (MEMPCPY_DEFAULT, __GI_mempcpy)
077c9d
+strong_alias (MEMPCPY_DEFAULT, __GI___mempcpy)
077c9d
+#endif
077c9d
diff --git a/sysdeps/s390/multiarch/memcpy.c b/sysdeps/s390/memcpy.c
077c9d
similarity index 60%
077c9d
rename from sysdeps/s390/multiarch/memcpy.c
077c9d
rename to sysdeps/s390/memcpy.c
077c9d
index c9577a854a0c7e68..90a53ac27d4be755 100644
077c9d
--- a/sysdeps/s390/multiarch/memcpy.c
077c9d
+++ b/sysdeps/s390/memcpy.c
077c9d
@@ -16,12 +16,34 @@
077c9d
    License along with the GNU C Library; if not, see
077c9d
    <http://www.gnu.org/licenses/>.  */
077c9d
 
077c9d
-/* In the static lib memcpy is needed before the reloc is resolved.  */
077c9d
-#if defined SHARED && IS_IN (libc)
077c9d
+#include <ifunc-memcpy.h>
077c9d
+
077c9d
+#if HAVE_MEMCPY_IFUNC
077c9d
 # define memcpy __redirect_memcpy
077c9d
 # include <string.h>
077c9d
 # undef memcpy
077c9d
 # include <ifunc-resolve.h>
077c9d
 
077c9d
-s390_libc_ifunc (__redirect_memcpy, __memcpy, memcpy)
077c9d
+# if HAVE_MEMCPY_Z900_G5
077c9d
+extern __typeof (__redirect_memcpy) MEMCPY_Z900_G5 attribute_hidden;
077c9d
+# endif
077c9d
+
077c9d
+# if HAVE_MEMCPY_Z10
077c9d
+extern __typeof (__redirect_memcpy) MEMCPY_Z10 attribute_hidden;
077c9d
+# endif
077c9d
+
077c9d
+# if HAVE_MEMCPY_Z196
077c9d
+extern __typeof (__redirect_memcpy) MEMCPY_Z196 attribute_hidden;
077c9d
+# endif
077c9d
+
077c9d
+s390_libc_ifunc_expr (__redirect_memcpy, memcpy,
077c9d
+		      ({
077c9d
+			s390_libc_ifunc_init ();
077c9d
+			(HAVE_MEMCPY_Z196 && S390_IS_Z196 (stfle_bits))
077c9d
+			  ? MEMCPY_Z196
077c9d
+			  : (HAVE_MEMCPY_Z10 && S390_IS_Z10 (stfle_bits))
077c9d
+			  ? MEMCPY_Z10
077c9d
+			  : MEMCPY_DEFAULT;
077c9d
+		      })
077c9d
+		      )
077c9d
 #endif
077c9d
diff --git a/sysdeps/s390/mempcpy.S b/sysdeps/s390/mempcpy.S
077c9d
deleted file mode 100644
077c9d
index 18ef29213e26e76d..0000000000000000
077c9d
--- a/sysdeps/s390/mempcpy.S
077c9d
+++ /dev/null
077c9d
@@ -1,19 +0,0 @@
077c9d
-/* CPU specific mempcpy without multiarch - 32/64 bit S/390 version.
077c9d
-   Copyright (C) 2016-2018 Free Software Foundation, Inc.
077c9d
-   This file is part of the GNU C Library.
077c9d
-
077c9d
-   The GNU C Library is free software; you can redistribute it and/or
077c9d
-   modify it under the terms of the GNU Lesser General Public
077c9d
-   License as published by the Free Software Foundation; either
077c9d
-   version 2.1 of the License, or (at your option) any later version.
077c9d
-
077c9d
-   The GNU C Library is distributed in the hope that it will be useful,
077c9d
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
077c9d
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
077c9d
-   Lesser General Public License for more details.
077c9d
-
077c9d
-   You should have received a copy of the GNU Lesser General Public
077c9d
-   License along with the GNU C Library; if not, see
077c9d
-   <http://www.gnu.org/licenses/>.  */
077c9d
-
077c9d
-/* mempcpy is implemented in memcpy.S.  */
077c9d
diff --git a/sysdeps/s390/multiarch/mempcpy.c b/sysdeps/s390/mempcpy.c
077c9d
similarity index 63%
077c9d
rename from sysdeps/s390/multiarch/mempcpy.c
077c9d
rename to sysdeps/s390/mempcpy.c
077c9d
index 363fe47aefb80978..a6a237312659c2c1 100644
077c9d
--- a/sysdeps/s390/multiarch/mempcpy.c
077c9d
+++ b/sysdeps/s390/mempcpy.c
077c9d
@@ -16,8 +16,9 @@
077c9d
    License along with the GNU C Library; if not, see
077c9d
    <http://www.gnu.org/licenses/>.  */
077c9d
 
077c9d
+#include <ifunc-memcpy.h>
077c9d
 
077c9d
-#if defined SHARED && IS_IN (libc)
077c9d
+#if HAVE_MEMCPY_IFUNC
077c9d
 # define mempcpy __redirect_mempcpy
077c9d
 # define __mempcpy __redirect___mempcpy
077c9d
 # define __NO_STRING_INLINES
077c9d
@@ -27,6 +28,27 @@
077c9d
 # undef __mempcpy
077c9d
 # include <ifunc-resolve.h>
077c9d
 
077c9d
-s390_libc_ifunc (__redirect___mempcpy, ____mempcpy, __mempcpy)
077c9d
+# if HAVE_MEMCPY_Z900_G5
077c9d
+extern __typeof (__redirect___mempcpy) MEMPCPY_Z900_G5 attribute_hidden;
077c9d
+# endif
077c9d
+
077c9d
+# if HAVE_MEMCPY_Z10
077c9d
+extern __typeof (__redirect___mempcpy) MEMPCPY_Z10 attribute_hidden;
077c9d
+# endif
077c9d
+
077c9d
+# if HAVE_MEMCPY_Z196
077c9d
+extern __typeof (__redirect___mempcpy) MEMPCPY_Z196 attribute_hidden;
077c9d
+# endif
077c9d
+
077c9d
+s390_libc_ifunc_expr (__redirect___mempcpy, __mempcpy,
077c9d
+		      ({
077c9d
+			s390_libc_ifunc_init ();
077c9d
+			(HAVE_MEMCPY_Z196 && S390_IS_Z196 (stfle_bits))
077c9d
+			  ? MEMPCPY_Z196
077c9d
+			  : (HAVE_MEMCPY_Z10 && S390_IS_Z10 (stfle_bits))
077c9d
+			  ? MEMPCPY_Z10
077c9d
+			  : MEMPCPY_DEFAULT;
077c9d
+		      })
077c9d
+		      )
077c9d
 weak_alias (__mempcpy, mempcpy);
077c9d
 #endif
077c9d
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
077c9d
index 3cbd5fad69e355a5..24949cd3a88b8015 100644
077c9d
--- a/sysdeps/s390/multiarch/Makefile
077c9d
+++ b/sysdeps/s390/multiarch/Makefile
077c9d
@@ -18,8 +18,7 @@ sysdep_routines += strlen strlen-vx strlen-c \
077c9d
 		   memchr memchr-vx \
077c9d
 		   rawmemchr rawmemchr-vx rawmemchr-c \
077c9d
 		   memccpy memccpy-vx memccpy-c \
077c9d
-		   memrchr memrchr-vx memrchr-c \
077c9d
-		   mempcpy memcpy memcpy-s390x
077c9d
+		   memrchr memrchr-vx memrchr-c
077c9d
 endif
077c9d
 
077c9d
 ifeq ($(subdir),wcsmbs)
077c9d
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
077c9d
index 2e57d01abc21522e..6969c480cc40e0e2 100644
077c9d
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
077c9d
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
077c9d
@@ -23,6 +23,7 @@
077c9d
 #include <ifunc-resolve.h>
077c9d
 #include <ifunc-memset.h>
077c9d
 #include <ifunc-memcmp.h>
077c9d
+#include <ifunc-memcpy.h>
077c9d
 
077c9d
 /* Maximum number of IFUNC implementations.  */
077c9d
 #define MAX_IFUNC	3
077c9d
@@ -95,23 +96,35 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
077c9d
 	      )
077c9d
 #endif /* HAVE_MEMCMP_IFUNC */
077c9d
 
077c9d
-#ifdef SHARED
077c9d
-
077c9d
+#if HAVE_MEMCPY_IFUNC
077c9d
   IFUNC_IMPL (i, name, memcpy,
077c9d
+# if HAVE_MEMCPY_Z196
077c9d
 	      IFUNC_IMPL_ADD (array, i, memcpy,
077c9d
-			      S390_IS_Z196 (stfle_bits), __memcpy_z196)
077c9d
+			      S390_IS_Z196 (stfle_bits), MEMCPY_Z196)
077c9d
+# endif
077c9d
+# if HAVE_MEMCPY_Z10
077c9d
 	      IFUNC_IMPL_ADD (array, i, memcpy,
077c9d
-			      S390_IS_Z10 (stfle_bits), __memcpy_z10)
077c9d
-	      IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_default))
077c9d
+			      S390_IS_Z10 (stfle_bits), MEMCPY_Z10)
077c9d
+# endif
077c9d
+# if HAVE_MEMCPY_Z900_G5
077c9d
+	      IFUNC_IMPL_ADD (array, i, memcpy, 1, MEMCPY_Z900_G5)
077c9d
+# endif
077c9d
+	      )
077c9d
 
077c9d
   IFUNC_IMPL (i, name, mempcpy,
077c9d
+# if HAVE_MEMCPY_Z196
077c9d
 	      IFUNC_IMPL_ADD (array, i, mempcpy,
077c9d
-			      S390_IS_Z196 (stfle_bits), ____mempcpy_z196)
077c9d
+			      S390_IS_Z196 (stfle_bits), MEMPCPY_Z196)
077c9d
+# endif
077c9d
+# if HAVE_MEMCPY_Z10
077c9d
 	      IFUNC_IMPL_ADD (array, i, mempcpy,
077c9d
-			      S390_IS_Z10 (stfle_bits), ____mempcpy_z10)
077c9d
-	      IFUNC_IMPL_ADD (array, i, mempcpy, 1, ____mempcpy_default))
077c9d
-
077c9d
-#endif /* SHARED */
077c9d
+			      S390_IS_Z10 (stfle_bits), MEMPCPY_Z10)
077c9d
+# endif
077c9d
+# if HAVE_MEMCPY_Z900_G5
077c9d
+	      IFUNC_IMPL_ADD (array, i, mempcpy, 1, MEMPCPY_Z900_G5)
077c9d
+# endif
077c9d
+	      )
077c9d
+#endif /* HAVE_MEMCPY_IFUNC  */
077c9d
 
077c9d
 #ifdef HAVE_S390_VX_ASM_SUPPORT
077c9d
 
077c9d
diff --git a/sysdeps/s390/multiarch/memcpy-s390x.S b/sysdeps/s390/multiarch/memcpy-s390x.S
077c9d
deleted file mode 100644
077c9d
index b38caac72b8742e6..0000000000000000
077c9d
--- a/sysdeps/s390/multiarch/memcpy-s390x.S
077c9d
+++ /dev/null
077c9d
@@ -1,132 +0,0 @@
077c9d
-/* CPU specific memcpy implementations.  31/64 bit S/390 version.
077c9d
-   Copyright (C) 2012-2018 Free Software Foundation, Inc.
077c9d
-   This file is part of the GNU C Library.
077c9d
-
077c9d
-   The GNU C Library is free software; you can redistribute it and/or
077c9d
-   modify it under the terms of the GNU Lesser General Public
077c9d
-   License as published by the Free Software Foundation; either
077c9d
-   version 2.1 of the License, or (at your option) any later version.
077c9d
-
077c9d
-   The GNU C Library is distributed in the hope that it will be useful,
077c9d
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
077c9d
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
077c9d
-   Lesser General Public License for more details.
077c9d
-
077c9d
-   You should have received a copy of the GNU Lesser General Public
077c9d
-   License along with the GNU C Library; if not, see
077c9d
-   <http://www.gnu.org/licenses/>.  */
077c9d
-
077c9d
-
077c9d
-#include "sysdep.h"
077c9d
-#include "asm-syntax.h"
077c9d
-
077c9d
-/* INPUT PARAMETERS
077c9d
-     %r2 = target operands address
077c9d
-     %r3 = source operands address
077c9d
-     %r4 = number of bytes to copy.  */
077c9d
-
077c9d
-       .text
077c9d
-
077c9d
-#if defined SHARED && IS_IN (libc)
077c9d
-
077c9d
-ENTRY(____mempcpy_z196)
077c9d
-	.machine "z196"
077c9d
-	.machinemode "zarch_nohighgprs"
077c9d
-	lgr     %r1,%r2         # Use as dest
077c9d
-	la      %r2,0(%r4,%r2)  # Return dest + n
077c9d
-	j	.L_Z196_start
077c9d
-END(____mempcpy_z196)
077c9d
-
077c9d
-ENTRY(__memcpy_z196)
077c9d
-	.machine "z196"
077c9d
-	.machinemode "zarch_nohighgprs"
077c9d
-	lgr     %r1,%r2         # r1: Use as dest ; r2: Return dest
077c9d
-.L_Z196_start:
077c9d
-# if !defined __s390x__
077c9d
-	llgfr	%r4,%r4
077c9d
-# endif /* !defined __s390x__  */
077c9d
-	ltgr    %r4,%r4
077c9d
-	je      .L_Z196_4
077c9d
-	aghi    %r4,-1
077c9d
-	srlg    %r5,%r4,8
077c9d
-	ltgr    %r5,%r5
077c9d
-	jne     .L_Z196_5
077c9d
-.L_Z196_3:
077c9d
-	exrl    %r4,.L_Z196_14
077c9d
-.L_Z196_4:
077c9d
-	br      %r14
077c9d
-.L_Z196_5:
077c9d
-	cgfi    %r5,262144      # Switch to mvcle for copies >64MB
077c9d
-	jh      __memcpy_mvcle
077c9d
-.L_Z196_2:
077c9d
-	pfd     1,768(%r3)
077c9d
-	pfd     2,768(%r1)
077c9d
-	mvc     0(256,%r1),0(%r3)
077c9d
-	aghi    %r5,-1
077c9d
-	la      %r1,256(%r1)
077c9d
-	la      %r3,256(%r3)
077c9d
-	jne     .L_Z196_2
077c9d
-	j       .L_Z196_3
077c9d
-.L_Z196_14:
077c9d
-	mvc     0(1,%r1),0(%r3)
077c9d
-END(__memcpy_z196)
077c9d
-
077c9d
-ENTRY(____mempcpy_z10)
077c9d
-	.machine "z10"
077c9d
-	.machinemode "zarch_nohighgprs"
077c9d
-	lgr     %r1,%r2         # Use as dest
077c9d
-	la      %r2,0(%r4,%r2)  # Return dest + n
077c9d
-	j	.L_Z10_start
077c9d
-END(____mempcpy_z10)
077c9d
-
077c9d
-ENTRY(__memcpy_z10)
077c9d
-	.machine "z10"
077c9d
-	.machinemode "zarch_nohighgprs"
077c9d
-	lgr     %r1,%r2         # r1: Use as dest ; r2: Return dest
077c9d
-.L_Z10_start:
077c9d
-# if !defined __s390x__
077c9d
-	llgfr	%r4,%r4
077c9d
-# endif /* !defined __s390x__  */
077c9d
-	cgije   %r4,0,.L_Z10_4
077c9d
-	aghi    %r4,-1
077c9d
-	srlg    %r5,%r4,8
077c9d
-	cgijlh  %r5,0,.L_Z10_13
077c9d
-.L_Z10_3:
077c9d
-	exrl    %r4,.L_Z10_15
077c9d
-.L_Z10_4:
077c9d
-	br      %r14
077c9d
-.L_Z10_13:
077c9d
-	cgfi    %r5,65535	# Switch to mvcle for copies >16MB
077c9d
-	jh      __memcpy_mvcle
077c9d
-.L_Z10_12:
077c9d
-	pfd     1,768(%r3)
077c9d
-	pfd     2,768(%r1)
077c9d
-	mvc     0(256,%r1),0(%r3)
077c9d
-	la      %r1,256(%r1)
077c9d
-	la      %r3,256(%r3)
077c9d
-	brctg   %r5,.L_Z10_12
077c9d
-	j       .L_Z10_3
077c9d
-.L_Z10_15:
077c9d
-	mvc     0(1,%r1),0(%r3)
077c9d
-END(__memcpy_z10)
077c9d
-
077c9d
-# define __mempcpy ____mempcpy_default
077c9d
-#endif /* SHARED && IS_IN (libc) */
077c9d
-
077c9d
-#define memcpy __memcpy_default
077c9d
-#include "../memcpy.S"
077c9d
-#undef memcpy
077c9d
-
077c9d
-#if defined SHARED && IS_IN (libc)
077c9d
-.globl   __GI_memcpy
077c9d
-.set     __GI_memcpy,__memcpy_default
077c9d
-.globl   __GI_mempcpy
077c9d
-.set     __GI_mempcpy,____mempcpy_default
077c9d
-.globl   __GI___mempcpy
077c9d
-.set     __GI___mempcpy,____mempcpy_default
077c9d
-#else
077c9d
-.globl   memcpy
077c9d
-.set     memcpy,__memcpy_default
077c9d
-.weak    mempcpy
077c9d
-.set     mempcpy,__mempcpy
077c9d
-#endif