bdc76f
commit 712a254a97ade7f48fb7a434339faa05c048ce1f
bdc76f
Author: Stefan Liebler <stli@linux.ibm.com>
bdc76f
Date:   Tue Dec 18 13:57:04 2018 +0100
bdc76f
bdc76f
    S390: Refactor memset ifunc handling.
bdc76f
    
bdc76f
    This patch moves all ifunc variants for memset
bdc76f
    to sysdeps/s390/memset-z900.S. The configure-check/preprocessor logic
bdc76f
    in sysdeps/s390/ifunc-memset.h decides if ifunc is needed at all
bdc76f
    and which ifunc variants should be available.
bdc76f
    E.g. if the compiler/assembler already supports z196 by default,
bdc76f
    the older ifunc variants are not included.
bdc76f
    If we only need the newest ifunc variant,
bdc76f
    then we can skip ifunc at all.
bdc76f
    
bdc76f
    Therefore the ifunc-resolvers and __libc_ifunc_impl_list are adjusted
bdc76f
    in order to handle only the available ifunc variants.
bdc76f
    
bdc76f
    ChangeLog:
bdc76f
    
bdc76f
            * sysdeps/s390/ifunc-memset.h: New File.
bdc76f
            * sysdeps/s390/memset.S: Move to ...
bdc76f
            * sysdeps/s390/memset-z900.S ... here.
bdc76f
            Move implementations from memset-s390x.s to here.
bdc76f
            * sysdeps/s390/multiarch/memset-s390x.S: Delete File.
bdc76f
            * sysdeps/s390/multiarch/Makefile (sysdep_routines):
bdc76f
            Remove memset variants.
bdc76f
            * sysdeps/s390/Makefile (sysdep_routines):
bdc76f
            Add memset variants.
bdc76f
            * sysdeps/s390/multiarch/ifunc-impl-list.c
bdc76f
            (__libc_ifunc_impl_list): Adjust ifunc variants for
bdc76f
            memset.
bdc76f
            * sysdeps/s390/multiarch/memset.c: Move ifunc resolver
bdc76f
            to ...
bdc76f
            * sysdeps/s390/memset.c: ... here.
bdc76f
            Adjust ifunc variants for memset.
bdc76f
bdc76f
Conflicts:
bdc76f
	sysdeps/s390/Makefile
bdc76f
	  Missing backport of commit 69e2444ab1444ab8210598abbcb4822701d368b9
bdc76f
          ("S390: Test that lazy binding does not clobber R0").
bdc76f
bdc76f
diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile
bdc76f
index 8a54f88cd7ac880e..360838e172f4ca37 100644
bdc76f
--- a/sysdeps/s390/Makefile
bdc76f
+++ b/sysdeps/s390/Makefile
bdc76f
@@ -29,3 +29,7 @@ $(inst_gconvdir)/%.so: $(objpfx)%.so $(+force)
bdc76f
 
bdc76f
 sysdeps-gconv-modules = ../sysdeps/s390/gconv-modules
bdc76f
 endif
bdc76f
+
bdc76f
+ifeq ($(subdir),string)
bdc76f
+sysdep_routines += memset memset-z900
bdc76f
+endif
bdc76f
diff --git a/sysdeps/s390/ifunc-memset.h b/sysdeps/s390/ifunc-memset.h
bdc76f
new file mode 100644
bdc76f
index 0000000000000000..9a13b1001fed9979
bdc76f
--- /dev/null
bdc76f
+++ b/sysdeps/s390/ifunc-memset.h
bdc76f
@@ -0,0 +1,65 @@
bdc76f
+/* memset variant information on S/390 version.
bdc76f
+   Copyright (C) 2018 Free Software Foundation, Inc.
bdc76f
+   This file is part of the GNU C Library.
bdc76f
+
bdc76f
+   The GNU C Library is free software; you can redistribute it and/or
bdc76f
+   modify it under the terms of the GNU Lesser General Public
bdc76f
+   License as published by the Free Software Foundation; either
bdc76f
+   version 2.1 of the License, or (at your option) any later version.
bdc76f
+
bdc76f
+   The GNU C Library is distributed in the hope that it will be useful,
bdc76f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
bdc76f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bdc76f
+   Lesser General Public License for more details.
bdc76f
+
bdc76f
+   You should have received a copy of the GNU Lesser General Public
bdc76f
+   License along with the GNU C Library; if not, see
bdc76f
+   <http://www.gnu.org/licenses/>.  */
bdc76f
+
bdc76f
+#if defined USE_MULTIARCH && IS_IN (libc)	\
bdc76f
+  && ! defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
bdc76f
+# define HAVE_MEMSET_IFUNC	1
bdc76f
+#else
bdc76f
+# define HAVE_MEMSET_IFUNC	0
bdc76f
+#endif
bdc76f
+
bdc76f
+#if defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
bdc76f
+# define MEMSET_DEFAULT		MEMSET_Z196
bdc76f
+# define HAVE_MEMSET_Z900_G5	0
bdc76f
+# define HAVE_MEMSET_Z10	0
bdc76f
+# define HAVE_MEMSET_Z196	1
bdc76f
+#elif defined HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT
bdc76f
+# define MEMSET_DEFAULT		MEMSET_Z10
bdc76f
+# define HAVE_MEMSET_Z900_G5	0
bdc76f
+# define HAVE_MEMSET_Z10	1
bdc76f
+# define HAVE_MEMSET_Z196	HAVE_MEMSET_IFUNC
bdc76f
+#else
bdc76f
+# define MEMSET_DEFAULT		MEMSET_Z900_G5
bdc76f
+# define HAVE_MEMSET_Z900_G5	1
bdc76f
+# define HAVE_MEMSET_Z10	HAVE_MEMSET_IFUNC
bdc76f
+# define HAVE_MEMSET_Z196	HAVE_MEMSET_IFUNC
bdc76f
+#endif
bdc76f
+
bdc76f
+#if HAVE_MEMSET_Z10 || HAVE_MEMSET_Z196
bdc76f
+# define HAVE_MEMSET_MVCLE	1
bdc76f
+#else
bdc76f
+# define HAVE_MEMSET_MVCLE	0
bdc76f
+#endif
bdc76f
+
bdc76f
+#if HAVE_MEMSET_Z900_G5
bdc76f
+# define MEMSET_Z900_G5		__memset_default
bdc76f
+#else
bdc76f
+# define MEMSET_Z900_G5		NULL
bdc76f
+#endif
bdc76f
+
bdc76f
+#if HAVE_MEMSET_Z10
bdc76f
+# define MEMSET_Z10		__memset_z10
bdc76f
+#else
bdc76f
+# define MEMSET_Z10		NULL
bdc76f
+#endif
bdc76f
+
bdc76f
+#if HAVE_MEMSET_Z196
bdc76f
+# define MEMSET_Z196		__memset_z196
bdc76f
+#else
bdc76f
+# define MEMSET_Z196		NULL
bdc76f
+#endif
bdc76f
diff --git a/sysdeps/s390/multiarch/memset-s390x.S b/sysdeps/s390/memset-z900.S
bdc76f
similarity index 57%
bdc76f
rename from sysdeps/s390/multiarch/memset-s390x.S
bdc76f
rename to sysdeps/s390/memset-z900.S
bdc76f
index aca3ac3fda1dd228..eaf13402bd3e251d 100644
bdc76f
--- a/sysdeps/s390/multiarch/memset-s390x.S
bdc76f
+++ b/sysdeps/s390/memset-z900.S
bdc76f
@@ -1,5 +1,6 @@
bdc76f
 /* Set a block of memory to some byte value.  31/64 bit S/390 version.
bdc76f
-   Copyright (C) 2012-2018 Free Software Foundation, Inc.
bdc76f
+   Copyright (C) 2001-2018 Free Software Foundation, Inc.
bdc76f
+   Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
bdc76f
    This file is part of the GNU C Library.
bdc76f
 
bdc76f
    The GNU C Library is free software; you can redistribute it and/or
bdc76f
@@ -17,8 +18,9 @@
bdc76f
    <http://www.gnu.org/licenses/>.  */
bdc76f
 
bdc76f
 
bdc76f
-#include "sysdep.h"
bdc76f
+#include <sysdep.h>
bdc76f
 #include "asm-syntax.h"
bdc76f
+#include <ifunc-memset.h>
bdc76f
 
bdc76f
 /* INPUT PARAMETERS
bdc76f
      %r2 = address of memory area
bdc76f
@@ -27,43 +29,68 @@
bdc76f
 
bdc76f
        .text
bdc76f
 
bdc76f
-#if IS_IN (libc)
bdc76f
+#if HAVE_MEMSET_Z900_G5
bdc76f
+# if defined __s390x__
bdc76f
+#  define LTGR	ltgr
bdc76f
+#  define CGHI	cghi
bdc76f
+#  define LGR	lgr
bdc76f
+#  define AGHI	aghi
bdc76f
+#  define BRCTG	brctg
bdc76f
+# else
bdc76f
+#  define LTGR	ltr
bdc76f
+#  define CGHI	chi
bdc76f
+#  define LGR	lr
bdc76f
+#  define AGHI	ahi
bdc76f
+#  define BRCTG	brct
bdc76f
+# endif /* ! defined __s390x__  */
bdc76f
 
bdc76f
-ENTRY(__memset_z196)
bdc76f
-	.machine "z196"
bdc76f
-	.machinemode "zarch_nohighgprs"
bdc76f
-# if !defined __s390x__
bdc76f
-	llgfr	%r4,%r4
bdc76f
-# endif /* !defined __s390x__  */
bdc76f
-	ltgr    %r4,%r4
bdc76f
-	je      .L_Z196_4
bdc76f
+ENTRY(MEMSET_Z900_G5)
bdc76f
+#if defined __s390x__
bdc76f
+	.machine "z900"
bdc76f
+#else
bdc76f
+	.machine "g5"
bdc76f
+#endif /* ! defined __s390x__  */
bdc76f
+	LTGR    %r4,%r4
bdc76f
+	je      .L_Z900_G5_4
bdc76f
 	stc     %r3,0(%r2)
bdc76f
-	lgr     %r1,%r2
bdc76f
-	cghi    %r4,1
bdc76f
-	je      .L_Z196_4
bdc76f
-	aghi    %r4,-2
bdc76f
-	srlg    %r5,%r4,8
bdc76f
-	ltgr    %r5,%r5
bdc76f
-	jne     .L_Z196_1
bdc76f
-.L_Z196_3:
bdc76f
-	exrl    %r4,.L_Z196_17
bdc76f
-.L_Z196_4:
bdc76f
+	CGHI    %r4,1
bdc76f
+	LGR     %r1,%r2
bdc76f
+	je      .L_Z900_G5_4
bdc76f
+	AGHI    %r4,-2
bdc76f
+#if defined __s390x__
bdc76f
+	larl    %r5,.L_Z900_G5_18
bdc76f
+	srlg    %r3,%r4,8
bdc76f
+# define Z900_G5_EX_D 0
bdc76f
+#else
bdc76f
+	basr    %r5,0
bdc76f
+.L_Z900_G5_19:
bdc76f
+# define Z900_G5_EX_D .L_Z900_G5_18-.L_Z900_G5_19
bdc76f
+	lr      %r3,%r4
bdc76f
+	srl     %r3,8
bdc76f
+#endif /* ! defined __s390x__  */
bdc76f
+	LTGR    %r3,%r3
bdc76f
+	jne     .L_Z900_G5_14
bdc76f
+.L_Z900_G5_3:
bdc76f
+	ex      %r4,Z900_G5_EX_D(%r5)
bdc76f
+.L_Z900_G5_4:
bdc76f
 	br      %r14
bdc76f
-.L_Z196_1:
bdc76f
-	cgfi	%r5,1048576
bdc76f
-	jh	__memset_mvcle	   # Switch to mvcle for >256MB
bdc76f
-.L_Z196_2:
bdc76f
-	pfd     2,1024(%r1)
bdc76f
+.L_Z900_G5_14:
bdc76f
 	mvc     1(256,%r1),0(%r1)
bdc76f
-	aghi    %r5,-1
bdc76f
 	la      %r1,256(%r1)
bdc76f
-	jne     .L_Z196_2
bdc76f
-	j       .L_Z196_3
bdc76f
-.L_Z196_17:
bdc76f
+	BRCTG   %r3,.L_Z900_G5_14
bdc76f
+	j       .L_Z900_G5_3
bdc76f
+.L_Z900_G5_18:
bdc76f
 	mvc     1(1,%r1),0(%r1)
bdc76f
-END(__memset_z196)
bdc76f
+END(MEMSET_Z900_G5)
bdc76f
+# undef LTGR
bdc76f
+# undef CGHI
bdc76f
+# undef LGR
bdc76f
+# undef AGHI
bdc76f
+# undef BRCTG
bdc76f
+#endif /*  HAVE_MEMSET_Z900_G5  */
bdc76f
 
bdc76f
-ENTRY(__memset_z10)
bdc76f
+#if HAVE_MEMSET_Z10
bdc76f
+ENTRY(MEMSET_Z10)
bdc76f
 	.machine "z10"
bdc76f
 	.machinemode "zarch_nohighgprs"
bdc76f
 # if !defined __s390x__
bdc76f
@@ -91,8 +118,46 @@ ENTRY(__memset_z10)
bdc76f
 	j       .L_Z10_3
bdc76f
 .L_Z10_18:
bdc76f
 	mvc     1(1,%r1),0(%r1)
bdc76f
-END(__memset_z10)
bdc76f
+END(MEMSET_Z10)
bdc76f
+#endif /* HAVE_MEMSET_Z10  */
bdc76f
+
bdc76f
+#if HAVE_MEMSET_Z196
bdc76f
+ENTRY(MEMSET_Z196)
bdc76f
+	.machine "z196"
bdc76f
+	.machinemode "zarch_nohighgprs"
bdc76f
+# if !defined __s390x__
bdc76f
+	llgfr	%r4,%r4
bdc76f
+# endif /* !defined __s390x__  */
bdc76f
+	ltgr    %r4,%r4
bdc76f
+	je      .L_Z196_4
bdc76f
+	stc     %r3,0(%r2)
bdc76f
+	lgr     %r1,%r2
bdc76f
+	cghi    %r4,1
bdc76f
+	je      .L_Z196_4
bdc76f
+	aghi    %r4,-2
bdc76f
+	srlg    %r5,%r4,8
bdc76f
+	ltgr    %r5,%r5
bdc76f
+	jne     .L_Z196_1
bdc76f
+.L_Z196_3:
bdc76f
+	exrl    %r4,.L_Z196_17
bdc76f
+.L_Z196_4:
bdc76f
+	br      %r14
bdc76f
+.L_Z196_1:
bdc76f
+	cgfi	%r5,1048576
bdc76f
+	jh	__memset_mvcle	   # Switch to mvcle for >256MB
bdc76f
+.L_Z196_2:
bdc76f
+	pfd     2,1024(%r1)
bdc76f
+	mvc     1(256,%r1),0(%r1)
bdc76f
+	aghi    %r5,-1
bdc76f
+	la      %r1,256(%r1)
bdc76f
+	jne     .L_Z196_2
bdc76f
+	j       .L_Z196_3
bdc76f
+.L_Z196_17:
bdc76f
+	mvc     1(1,%r1),0(%r1)
bdc76f
+END(MEMSET_Z196)
bdc76f
+#endif /* HAVE_MEMSET_Z196  */
bdc76f
 
bdc76f
+#if HAVE_MEMSET_MVCLE
bdc76f
 ENTRY(__memset_mvcle)
bdc76f
 	aghi	%r4,2               # take back the change done by the caller
bdc76f
 	lgr	%r0,%r2		    # save source address
bdc76f
@@ -106,15 +171,16 @@ ENTRY(__memset_mvcle)
bdc76f
 .L1:
bdc76f
 	br	%r14
bdc76f
 END(__memset_mvcle)
bdc76f
+#endif /* HAVE_MEMSET_MVCLE  */
bdc76f
 
bdc76f
-#endif /* IS_IN (libc) */
bdc76f
-
bdc76f
-#include "../memset.S"
bdc76f
+#if ! HAVE_MEMSET_IFUNC
bdc76f
+/* If we don't use ifunc, define an alias for memset here.
bdc76f
+   Otherwise see sysdeps/s390/memset.c.  */
bdc76f
+strong_alias (MEMSET_DEFAULT, memset)
bdc76f
+#endif
bdc76f
 
bdc76f
-#if !IS_IN (libc)
bdc76f
-.globl   memset
bdc76f
-.set     memset,__memset_default
bdc76f
-#elif defined SHARED && IS_IN (libc)
bdc76f
-.globl   __GI_memset
bdc76f
-.set     __GI_memset,__memset_default
bdc76f
+#if defined SHARED && IS_IN (libc)
bdc76f
+/* Defines the internal symbol.
bdc76f
+   Compare to libc_hidden_builtin_def (memset) in string/memset.c.  */
bdc76f
+strong_alias (MEMSET_DEFAULT, __GI_memset)
bdc76f
 #endif
bdc76f
diff --git a/sysdeps/s390/memset.S b/sysdeps/s390/memset.S
bdc76f
deleted file mode 100644
bdc76f
index 72e7c5a42efbaf6c..0000000000000000
bdc76f
--- a/sysdeps/s390/memset.S
bdc76f
+++ /dev/null
bdc76f
@@ -1,97 +0,0 @@
bdc76f
-/* Set a block of memory to some byte value.  31/64 bit S/390 version.
bdc76f
-   Copyright (C) 2001-2018 Free Software Foundation, Inc.
bdc76f
-   Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
bdc76f
-   This file is part of the GNU C Library.
bdc76f
-
bdc76f
-   The GNU C Library is free software; you can redistribute it and/or
bdc76f
-   modify it under the terms of the GNU Lesser General Public
bdc76f
-   License as published by the Free Software Foundation; either
bdc76f
-   version 2.1 of the License, or (at your option) any later version.
bdc76f
-
bdc76f
-   The GNU C Library is distributed in the hope that it will be useful,
bdc76f
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
bdc76f
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bdc76f
-   Lesser General Public License for more details.
bdc76f
-
bdc76f
-   You should have received a copy of the GNU Lesser General Public
bdc76f
-   License along with the GNU C Library; if not, see
bdc76f
-   <http://www.gnu.org/licenses/>.  */
bdc76f
-
bdc76f
-
bdc76f
-#include <sysdep.h>
bdc76f
-#include "asm-syntax.h"
bdc76f
-
bdc76f
-/* INPUT PARAMETERS
bdc76f
-     %r2 = address of memory area
bdc76f
-     %r3 = byte to fill memory with
bdc76f
-     %r4 = number of bytes to fill.  */
bdc76f
-
bdc76f
-       .text
bdc76f
-
bdc76f
-#if defined __s390x__
bdc76f
-# define LTGR	ltgr
bdc76f
-# define CGHI	cghi
bdc76f
-# define LGR	lgr
bdc76f
-# define AGHI	aghi
bdc76f
-# define BRCTG	brctg
bdc76f
-#else
bdc76f
-# define LTGR	ltr
bdc76f
-# define CGHI	chi
bdc76f
-# define LGR	lr
bdc76f
-# define AGHI	ahi
bdc76f
-# define BRCTG	brct
bdc76f
-#endif /* ! defined __s390x__  */
bdc76f
-
bdc76f
-#ifdef USE_MULTIARCH
bdc76f
-ENTRY(__memset_default)
bdc76f
-#else
bdc76f
-ENTRY(memset)
bdc76f
-#endif
bdc76f
-#if defined __s390x__
bdc76f
-	.machine "z900"
bdc76f
-#else
bdc76f
-	.machine "g5"
bdc76f
-#endif /* ! defined __s390x__  */
bdc76f
-	LTGR    %r4,%r4
bdc76f
-	je      .L_Z900_G5_4
bdc76f
-	stc     %r3,0(%r2)
bdc76f
-	CGHI    %r4,1
bdc76f
-	LGR     %r1,%r2
bdc76f
-	je      .L_Z900_G5_4
bdc76f
-	AGHI    %r4,-2
bdc76f
-#if defined __s390x__
bdc76f
-	larl    %r5,.L_Z900_G5_18
bdc76f
-	srlg    %r3,%r4,8
bdc76f
-# define Z900_G5_EX_D 0
bdc76f
-#else
bdc76f
-	basr    %r5,0
bdc76f
-.L_Z900_G5_19:
bdc76f
-# define Z900_G5_EX_D .L_Z900_G5_18-.L_Z900_G5_19
bdc76f
-	lr      %r3,%r4
bdc76f
-	srl     %r3,8
bdc76f
-#endif /* ! defined __s390x__  */
bdc76f
-	LTGR    %r3,%r3
bdc76f
-	jne     .L_Z900_G5_14
bdc76f
-.L_Z900_G5_3:
bdc76f
-	ex      %r4,Z900_G5_EX_D(%r5)
bdc76f
-.L_Z900_G5_4:
bdc76f
-	br      %r14
bdc76f
-.L_Z900_G5_14:
bdc76f
-	mvc     1(256,%r1),0(%r1)
bdc76f
-	la      %r1,256(%r1)
bdc76f
-	BRCTG   %r3,.L_Z900_G5_14
bdc76f
-	j       .L_Z900_G5_3
bdc76f
-.L_Z900_G5_18:
bdc76f
-	mvc     1(1,%r1),0(%r1)
bdc76f
-#ifdef USE_MULTIARCH
bdc76f
-END(__memset_default)
bdc76f
-#else
bdc76f
-END(memset)
bdc76f
-libc_hidden_builtin_def (memset)
bdc76f
-#endif
bdc76f
-
bdc76f
-#undef LTGR
bdc76f
-#undef CGHI
bdc76f
-#undef LGR
bdc76f
-#undef AGHI
bdc76f
-#undef BRCTG
bdc76f
diff --git a/sysdeps/s390/multiarch/memset.c b/sysdeps/s390/memset.c
bdc76f
similarity index 60%
bdc76f
rename from sysdeps/s390/multiarch/memset.c
bdc76f
rename to sysdeps/s390/memset.c
bdc76f
index 760b3e9df201b8b4..57a35aebc7d3c794 100644
bdc76f
--- a/sysdeps/s390/multiarch/memset.c
bdc76f
+++ b/sysdeps/s390/memset.c
bdc76f
@@ -16,11 +16,33 @@
bdc76f
    License along with the GNU C Library; if not, see
bdc76f
    <http://www.gnu.org/licenses/>.  */
bdc76f
 
bdc76f
-#if IS_IN (libc)
bdc76f
+#include <ifunc-memset.h>
bdc76f
+#if HAVE_MEMSET_IFUNC
bdc76f
 # define memset __redirect_memset
bdc76f
 # include <string.h>
bdc76f
 # undef memset
bdc76f
 # include <ifunc-resolve.h>
bdc76f
 
bdc76f
-s390_libc_ifunc (__redirect_memset, __memset, memset)
bdc76f
+# if HAVE_MEMSET_Z900_G5
bdc76f
+extern __typeof (__redirect_memset) MEMSET_Z900_G5 attribute_hidden;
bdc76f
+# endif
bdc76f
+
bdc76f
+# if HAVE_MEMSET_Z10
bdc76f
+extern __typeof (__redirect_memset) MEMSET_Z10 attribute_hidden;
bdc76f
+# endif
bdc76f
+
bdc76f
+# if HAVE_MEMSET_Z196
bdc76f
+extern __typeof (__redirect_memset) MEMSET_Z196 attribute_hidden;
bdc76f
+# endif
bdc76f
+
bdc76f
+s390_libc_ifunc_expr (__redirect_memset, memset,
bdc76f
+		      ({
bdc76f
+			s390_libc_ifunc_init ();
bdc76f
+			(HAVE_MEMSET_Z196 && S390_IS_Z196 (stfle_bits))
bdc76f
+			  ? MEMSET_Z196
bdc76f
+			  : (HAVE_MEMSET_Z10 && S390_IS_Z10 (stfle_bits))
bdc76f
+			  ? MEMSET_Z10
bdc76f
+			  : MEMSET_DEFAULT;
bdc76f
+		      })
bdc76f
+		      )
bdc76f
 #endif
bdc76f
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
bdc76f
index 93ad21bfa2686ee5..c893ebc5659fd4ae 100644
bdc76f
--- a/sysdeps/s390/multiarch/Makefile
bdc76f
+++ b/sysdeps/s390/multiarch/Makefile
bdc76f
@@ -19,8 +19,7 @@ sysdep_routines += strlen strlen-vx strlen-c \
bdc76f
 		   rawmemchr rawmemchr-vx rawmemchr-c \
bdc76f
 		   memccpy memccpy-vx memccpy-c \
bdc76f
 		   memrchr memrchr-vx memrchr-c \
bdc76f
-		   mempcpy \
bdc76f
-		   memset memset-s390x
bdc76f
+		   mempcpy
bdc76f
 endif
bdc76f
 
bdc76f
 ifeq ($(subdir),wcsmbs)
bdc76f
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
bdc76f
index ec3373ae2653d66e..2f671eac1f4f1ffd 100644
bdc76f
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
bdc76f
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
bdc76f
@@ -21,6 +21,7 @@
bdc76f
 #include <wchar.h>
bdc76f
 #include <ifunc-impl-list.h>
bdc76f
 #include <ifunc-resolve.h>
bdc76f
+#include <ifunc-memset.h>
bdc76f
 
bdc76f
 /* Maximum number of IFUNC implementations.  */
bdc76f
 #define MAX_IFUNC	3
bdc76f
@@ -46,12 +47,21 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
bdc76f
       S390_STORE_STFLE (stfle_bits);
bdc76f
     }
bdc76f
 
bdc76f
+#if HAVE_MEMSET_IFUNC
bdc76f
   IFUNC_IMPL (i, name, memset,
bdc76f
+# if HAVE_MEMSET_Z196
bdc76f
 	      IFUNC_IMPL_ADD (array, i, memset,
bdc76f
-			      S390_IS_Z196 (stfle_bits), __memset_z196)
bdc76f
+			      S390_IS_Z196 (stfle_bits), MEMSET_Z196)
bdc76f
+# endif
bdc76f
+# if HAVE_MEMSET_Z10
bdc76f
 	      IFUNC_IMPL_ADD (array, i, memset,
bdc76f
-			      S390_IS_Z10 (stfle_bits), __memset_z10)
bdc76f
-	      IFUNC_IMPL_ADD (array, i, memset, 1, __memset_default))
bdc76f
+			      S390_IS_Z10 (stfle_bits), MEMSET_Z10)
bdc76f
+# endif
bdc76f
+# if HAVE_MEMSET_Z900_G5
bdc76f
+	      IFUNC_IMPL_ADD (array, i, memset, 1, MEMSET_Z900_G5)
bdc76f
+# endif
bdc76f
+	      )
bdc76f
+#endif /* HAVE_MEMSET_IFUNC */
bdc76f
 
bdc76f
   IFUNC_IMPL (i, name, memcmp,
bdc76f
 	      IFUNC_IMPL_ADD (array, i, memcmp,