arrfab / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1268008-28.patch

147e83
From f0954299ecdccf6a70cf904b8f499d15a5af3928 Mon Sep 17 00:00:00 2001
147e83
From: Stefan Liebler <stli@linux.vnet.ibm.com>
147e83
Date: Thu, 8 Oct 2015 13:22:47 +0200
147e83
Subject: [PATCH 28/30] S390: Optimize wmemset.
147e83
147e83
upstream-commit-id: 2e9e166761fed5dfaa53480412bef0656f1b5306
147e83
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00078.html
147e83
147e83
This patch provides optimized version of wmemset with the z13 vector
147e83
instructions.
147e83
147e83
ChangeLog:
147e83
147e83
	* sysdeps/s390/multiarch/wmemset-c.c: New File.
147e83
	* sysdeps/s390/multiarch/wmemset-vx.S: Likewise.
147e83
	* sysdeps/s390/multiarch/wmemset.c: Likewise.
147e83
	* sysdeps/s390/multiarch/Makefile
147e83
	(sysdep_routines): Add wmemset functions.
147e83
	* sysdeps/s390/multiarch/ifunc-impl-list-common.c
147e83
	(__libc_ifunc_impl_list_common): Add ifunc test for wmemset.
147e83
	* wcsmbs/wmemset.c: Use WMEMSET if defined.
147e83
	* string/test-memset.c: Add wmemset support.
147e83
	* wcsmbs/test-wmemset.c: New File.
147e83
	* wcsmbs/Makefile (strop-tests): Add wmemset.
147e83
	* benchtests/bench-memset.c: Add wmemset support.
147e83
	* benchtests/bench-wmemset.c: New File.
147e83
	* benchtests/Makefile (wcsmbs-bench): Add wmemset.
147e83
---
147e83
 benchtests/Makefile                      |   2 +-
147e83
 benchtests/bench-memset.c                |  63 +++++++++-----
147e83
 benchtests/bench-wmemset.c               |  20 +++++
147e83
 string/test-memset.c                     |  88 ++++++++++++-------
147e83
 sysdeps/s390/multiarch/Makefile          |   3 +-
147e83
 sysdeps/s390/multiarch/ifunc-impl-list.c |   2 +
147e83
 sysdeps/s390/multiarch/wmemset-c.c       |  31 +++++++
147e83
 sysdeps/s390/multiarch/wmemset-vx.S      | 142 +++++++++++++++++++++++++++++++
147e83
 sysdeps/s390/multiarch/wmemset.c         |  27 ++++++
147e83
 wcsmbs/Makefile                          |   2 +-
147e83
 wcsmbs/test-wmemset-ifunc.c              |  20 +++++
147e83
 wcsmbs/test-wmemset.c                    |  20 +++++
147e83
 wcsmbs/wmemset.c                         |   3 +
147e83
 13 files changed, 368 insertions(+), 55 deletions(-)
147e83
 create mode 100644 benchtests/bench-wmemset.c
147e83
 create mode 100644 sysdeps/s390/multiarch/wmemset-c.c
147e83
 create mode 100644 sysdeps/s390/multiarch/wmemset-vx.S
147e83
 create mode 100644 sysdeps/s390/multiarch/wmemset.c
147e83
 create mode 100644 wcsmbs/test-wmemset-ifunc.c
147e83
 create mode 100644 wcsmbs/test-wmemset.c
147e83
147e83
diff --git a/benchtests/Makefile b/benchtests/Makefile
147e83
index b4b3127..b5edfdd 100644
147e83
--- a/benchtests/Makefile
147e83
+++ b/benchtests/Makefile
147e83
@@ -40,7 +40,7 @@ string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
147e83
 		strspn strstr strcpy_chk stpcpy_chk memrchr strsep strtok
147e83
 wcsmbs-bench := wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat \
147e83
 		wcsncmp wcsncmp wcschr wcschrnul wcsrchr wcsspn wcspbrk wcscspn \
147e83
-		wmemchr
147e83
+		wmemchr wmemset
147e83
 string-bench-all := $(string-bench) ${wcsmbs-bench}
147e83
 
147e83
 stdlib-bench := strtod
147e83
diff --git a/benchtests/bench-memset.c b/benchtests/bench-memset.c
147e83
index 9786ce7..66c3c45 100644
147e83
--- a/benchtests/bench-memset.c
147e83
+++ b/benchtests/bench-memset.c
147e83
@@ -20,12 +20,29 @@
147e83
 #ifdef TEST_BZERO
147e83
 # define TEST_NAME "bzero"
147e83
 #else
147e83
-# define TEST_NAME "memset"
147e83
-#endif
147e83
+# ifndef WIDE
147e83
+#  define TEST_NAME "memset"
147e83
+# else
147e83
+#  define TEST_NAME "wmemset"
147e83
+# endif /* WIDE */
147e83
+#endif /* !TEST_BZERO */
147e83
 #define MIN_PAGE_SIZE 131072
147e83
 #include "bench-string.h"
147e83
 
147e83
-char *simple_memset (char *, int, size_t);
147e83
+#ifndef WIDE
147e83
+# define MEMSET memset
147e83
+# define CHAR char
147e83
+# define SIMPLE_MEMSET simple_memset
147e83
+# define MEMCMP memcmp
147e83
+#else
147e83
+# include <wchar.h>
147e83
+# define MEMSET wmemset
147e83
+# define CHAR wchar_t
147e83
+# define SIMPLE_MEMSET simple_wmemset
147e83
+# define MEMCMP wmemcmp
147e83
+#endif /* WIDE */
147e83
+
147e83
+CHAR *SIMPLE_MEMSET (CHAR *, int, size_t);
147e83
 
147e83
 #ifdef TEST_BZERO
147e83
 typedef void (*proto_t) (char *, size_t);
147e83
@@ -39,7 +56,7 @@ IMPL (bzero, 1)
147e83
 void
147e83
 simple_bzero (char *s, size_t n)
147e83
 {
147e83
-  simple_memset (s, 0, n);
147e83
+  SIMPLE_MEMSET (s, 0, n);
147e83
 }
147e83
 
147e83
 void
147e83
@@ -48,46 +65,50 @@ builtin_bzero (char *s, size_t n)
147e83
   __builtin_bzero (s, n);
147e83
 }
147e83
 #else
147e83
-typedef char *(*proto_t) (char *, int, size_t);
147e83
-char *builtin_memset (char *, int, size_t);
147e83
+typedef CHAR *(*proto_t) (CHAR *, int, size_t);
147e83
 
147e83
-IMPL (simple_memset, 0)
147e83
+IMPL (SIMPLE_MEMSET, 0)
147e83
+# ifndef WIDE
147e83
+char *builtin_memset (char *, int, size_t);
147e83
 IMPL (builtin_memset, 0)
147e83
-IMPL (memset, 1)
147e83
+# endif /* !WIDE */
147e83
+IMPL (MEMSET, 1)
147e83
 
147e83
+# ifndef WIDE
147e83
 char *
147e83
 builtin_memset (char *s, int c, size_t n)
147e83
 {
147e83
   return __builtin_memset (s, c, n);
147e83
 }
147e83
-#endif
147e83
+# endif /* !WIDE */
147e83
+#endif /* !TEST_BZERO */
147e83
 
147e83
-char *
147e83
+CHAR *
147e83
 inhibit_loop_to_libcall
147e83
-simple_memset (char *s, int c, size_t n)
147e83
+SIMPLE_MEMSET (CHAR *s, int c, size_t n)
147e83
 {
147e83
-  char *r = s, *end = s + n;
147e83
+  CHAR *r = s, *end = s + n;
147e83
   while (r < end)
147e83
     *r++ = c;
147e83
   return s;
147e83
 }
147e83
 
147e83
 static void
147e83
-do_one_test (impl_t *impl, char *s, int c __attribute ((unused)), size_t n)
147e83
+do_one_test (impl_t *impl, CHAR *s, int c __attribute ((unused)), size_t n)
147e83
 {
147e83
   size_t i, iters = INNER_LOOP_ITERS;
147e83
   timing_t start, stop, cur;
147e83
-  char tstbuf[n];
147e83
+  CHAR tstbuf[n];
147e83
 #ifdef TEST_BZERO
147e83
   simple_bzero (tstbuf, n);
147e83
   CALL (impl, s, n);
147e83
   if (memcmp (s, tstbuf, n) != 0)
147e83
 #else
147e83
-  char *res = CALL (impl, s, c, n);
147e83
+  CHAR *res = CALL (impl, s, c, n);
147e83
   if (res != s
147e83
-      || simple_memset (tstbuf, c, n) != tstbuf
147e83
-      || memcmp (s, tstbuf, n) != 0)
147e83
-#endif
147e83
+      || SIMPLE_MEMSET (tstbuf, c, n) != tstbuf
147e83
+      || MEMCMP (s, tstbuf, n) != 0)
147e83
+#endif /* !TEST_BZERO */
147e83
     {
147e83
       error (0, 0, "Wrong result in function %s", impl->name);
147e83
       ret = 1;
147e83
@@ -101,7 +122,7 @@ do_one_test (impl_t *impl, char *s, int c __attribute ((unused)), size_t n)
147e83
       CALL (impl, s, n);
147e83
 #else
147e83
       CALL (impl, s, c, n);
147e83
-#endif
147e83
+#endif /* !TEST_BZERO */
147e83
     }
147e83
   TIMING_NOW (stop);
147e83
 
147e83
@@ -114,13 +135,13 @@ static void
147e83
 do_test (size_t align, int c, size_t len)
147e83
 {
147e83
   align &= 7;
147e83
-  if (align + len > page_size)
147e83
+  if ((align + len) * sizeof (CHAR) > page_size)
147e83
     return;
147e83
 
147e83
   printf ("Length %4zd, alignment %2zd, c %2d:", len, align, c);
147e83
 
147e83
   FOR_EACH_IMPL (impl, 0)
147e83
-    do_one_test (impl, (char *) buf1 + align, c, len);
147e83
+    do_one_test (impl, (CHAR *) (buf1) + align, c, len);
147e83
 
147e83
   putchar ('\n');
147e83
 }
147e83
diff --git a/benchtests/bench-wmemset.c b/benchtests/bench-wmemset.c
147e83
new file mode 100644
147e83
index 0000000..540829c
147e83
--- /dev/null
147e83
+++ b/benchtests/bench-wmemset.c
147e83
@@ -0,0 +1,20 @@
147e83
+/* Measure wmemset functions.
147e83
+   Copyright (C) 2015 Free Software Foundation, Inc.
147e83
+   This file is part of the GNU C Library.
147e83
+
147e83
+   The GNU C Library is free software; you can redistribute it and/or
147e83
+   modify it under the terms of the GNU Lesser General Public
147e83
+   License as published by the Free Software Foundation; either
147e83
+   version 2.1 of the License, or (at your option) any later version.
147e83
+
147e83
+   The GNU C Library is distributed in the hope that it will be useful,
147e83
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
147e83
+   Lesser General Public License for more details.
147e83
+
147e83
+   You should have received a copy of the GNU Lesser General Public
147e83
+   License along with the GNU C Library; if not, see
147e83
+   <http://www.gnu.org/licenses/>.  */
147e83
+
147e83
+#define WIDE 1
147e83
+#include "bench-memset.c"
147e83
diff --git a/string/test-memset.c b/string/test-memset.c
147e83
index e556a88..99fc282 100644
147e83
--- a/string/test-memset.c
147e83
+++ b/string/test-memset.c
147e83
@@ -21,12 +21,33 @@
147e83
 #ifdef TEST_BZERO
147e83
 # define TEST_NAME "bzero"
147e83
 #else
147e83
-# define TEST_NAME "memset"
147e83
-#endif
147e83
+# ifndef WIDE
147e83
+#  define TEST_NAME "memset"
147e83
+# else
147e83
+#  define TEST_NAME "wmemset"
147e83
+# endif /* WIDE */
147e83
+#endif /* !TEST_BZERO */
147e83
 #define MIN_PAGE_SIZE 131072
147e83
 #include "test-string.h"
147e83
 
147e83
-char *simple_memset (char *, int, size_t);
147e83
+#ifndef WIDE
147e83
+# define MEMSET memset
147e83
+# define CHAR char
147e83
+# define UCHAR unsigned char
147e83
+# define SIMPLE_MEMSET simple_memset
147e83
+# define MEMCMP memcmp
147e83
+# define BIG_CHAR CHAR_MAX
147e83
+#else
147e83
+# include <wchar.h>
147e83
+# define MEMSET wmemset
147e83
+# define CHAR wchar_t
147e83
+# define UCHAR wchar_t
147e83
+# define SIMPLE_MEMSET simple_wmemset
147e83
+# define MEMCMP wmemcmp
147e83
+# define BIG_CHAR WCHAR_MAX
147e83
+#endif /* WIDE */
147e83
+
147e83
+CHAR *SIMPLE_MEMSET (CHAR *, int, size_t);
147e83
 
147e83
 #ifdef TEST_BZERO
147e83
 typedef void (*proto_t) (char *, size_t);
147e83
@@ -40,7 +61,7 @@ IMPL (bzero, 1)
147e83
 void
147e83
 simple_bzero (char *s, size_t n)
147e83
 {
147e83
-  simple_memset (s, 0, n);
147e83
+  SIMPLE_MEMSET (s, 0, n);
147e83
 }
147e83
 
147e83
 void
147e83
@@ -49,44 +70,48 @@ builtin_bzero (char *s, size_t n)
147e83
   __builtin_bzero (s, n);
147e83
 }
147e83
 #else
147e83
-typedef char *(*proto_t) (char *, int, size_t);
147e83
-char *builtin_memset (char *, int, size_t);
147e83
+typedef CHAR *(*proto_t) (CHAR *, int, size_t);
147e83
 
147e83
-IMPL (simple_memset, 0)
147e83
+IMPL (SIMPLE_MEMSET, 0)
147e83
+# ifndef WIDE
147e83
+char *builtin_memset (char *, int, size_t);
147e83
 IMPL (builtin_memset, 0)
147e83
-IMPL (memset, 1)
147e83
+# endif /* !WIDE */
147e83
+IMPL (MEMSET, 1)
147e83
 
147e83
+# ifndef WIDE
147e83
 char *
147e83
 builtin_memset (char *s, int c, size_t n)
147e83
 {
147e83
   return __builtin_memset (s, c, n);
147e83
 }
147e83
-#endif
147e83
+# endif /* !WIDE */
147e83
+#endif /* !TEST_BZERO */
147e83
 
147e83
-char *
147e83
+CHAR *
147e83
 inhibit_loop_to_libcall
147e83
-simple_memset (char *s, int c, size_t n)
147e83
+SIMPLE_MEMSET (CHAR *s, int c, size_t n)
147e83
 {
147e83
-  char *r = s, *end = s + n;
147e83
+  CHAR *r = s, *end = s + n;
147e83
   while (r < end)
147e83
     *r++ = c;
147e83
   return s;
147e83
 }
147e83
 
147e83
 static void
147e83
-do_one_test (impl_t *impl, char *s, int c __attribute ((unused)), size_t n)
147e83
+do_one_test (impl_t *impl, CHAR *s, int c __attribute ((unused)), size_t n)
147e83
 {
147e83
-  char tstbuf[n];
147e83
+  CHAR tstbuf[n];
147e83
 #ifdef TEST_BZERO
147e83
   simple_bzero (tstbuf, n);
147e83
   CALL (impl, s, n);
147e83
   if (memcmp (s, tstbuf, n) != 0)
147e83
 #else
147e83
-  char *res = CALL (impl, s, c, n);
147e83
+  CHAR *res = CALL (impl, s, c, n);
147e83
   if (res != s
147e83
-      || simple_memset (tstbuf, c, n) != tstbuf
147e83
-      || memcmp (s, tstbuf, n) != 0)
147e83
-#endif
147e83
+      || SIMPLE_MEMSET (tstbuf, c, n) != tstbuf
147e83
+      || MEMCMP (s, tstbuf, n) != 0)
147e83
+#endif /* !TEST_BZERO */
147e83
     {
147e83
       error (0, 0, "Wrong result in function %s", impl->name);
147e83
       ret = 1;
147e83
@@ -98,11 +123,11 @@ static void
147e83
 do_test (size_t align, int c, size_t len)
147e83
 {
147e83
   align &= 7;
147e83
-  if (align + len > page_size)
147e83
+  if ((align + len) * sizeof (CHAR) > page_size)
147e83
     return;
147e83
 
147e83
   FOR_EACH_IMPL (impl, 0)
147e83
-    do_one_test (impl, (char *) buf1 + align, c, len);
147e83
+    do_one_test (impl, (CHAR *) (buf1) + align, c, len);
147e83
 }
147e83
 
147e83
 #ifndef TEST_BZERO
147e83
@@ -111,18 +136,19 @@ do_random_tests (void)
147e83
 {
147e83
   size_t i, j, k, n, align, len, size;
147e83
   int c, o;
147e83
-  unsigned char *p, *res;
147e83
+  UCHAR *p, *res;
147e83
+  UCHAR *p2 = (UCHAR *) buf2;
147e83
 
147e83
-  for (i = 0; i < 65536; ++i)
147e83
-    buf2[i] = random () & 255;
147e83
+  for (i = 0; i < 65536 / sizeof (CHAR); ++i)
147e83
+    p2[i] = random () & BIG_CHAR;
147e83
 
147e83
   for (n = 0; n < ITERATIONS; n++)
147e83
     {
147e83
       if ((random () & 31) == 0)
147e83
-	size = 65536;
147e83
+	size = 65536 / sizeof (CHAR);
147e83
       else
147e83
 	size = 512;
147e83
-      p = buf1 + page_size - size;
147e83
+      p = (UCHAR *) (buf1 + page_size) - size;
147e83
       len = random () & (size - 1);
147e83
       align = size - len - (random () & 31);
147e83
       if (align > size)
147e83
@@ -132,10 +158,10 @@ do_random_tests (void)
147e83
       if ((random () & 7) == 0)
147e83
 	c = 0;
147e83
       else
147e83
-	c = random () & 255;
147e83
-      o = random () & 255;
147e83
+	c = random () & BIG_CHAR;
147e83
+      o = random () & BIG_CHAR;
147e83
       if (o == c)
147e83
-        o = (c + 1) & 255;
147e83
+	o = (c + 1) & BIG_CHAR;
147e83
       j = len + align + 128;
147e83
       if (j > size)
147e83
 	j = size;
147e83
@@ -152,11 +178,11 @@ do_random_tests (void)
147e83
 	{
147e83
 	  for (i = 0; i < len; ++i)
147e83
 	    {
147e83
-	      p[i + align] = buf2[i];
147e83
+	      p[i + align] = p2[i];
147e83
 	      if (p[i + align] == c)
147e83
 		p[i + align] = o;
147e83
 	    }
147e83
-	  res = (unsigned char *) CALL (impl, (char *) p + align, c, len);
147e83
+	  res = (UCHAR *) CALL (impl, (CHAR *) p + align, c, len);
147e83
 	  if (res != p + align)
147e83
 	    {
147e83
 	      error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %d, %zd) %p != %p",
147e83
@@ -190,7 +216,7 @@ do_random_tests (void)
147e83
 	}
147e83
     }
147e83
 }
147e83
-#endif
147e83
+#endif /* !TEST_BZERO */
147e83
 
147e83
 int
147e83
 test_main (void)
147e83
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
147e83
index 87dff0f..eac88e0 100644
147e83
--- a/sysdeps/s390/multiarch/Makefile
147e83
+++ b/sysdeps/s390/multiarch/Makefile
147e83
@@ -37,5 +37,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \
147e83
 		   wcsspn wcsspn-vx wcsspn-c \
147e83
 		   wcspbrk wcspbrk-vx wcspbrk-c \
147e83
 		   wcscspn wcscspn-vx wcscspn-c \
147e83
-		   wmemchr wmemchr-vx wmemchr-c
147e83
+		   wmemchr wmemchr-vx wmemchr-c \
147e83
+		   wmemset wmemset-vx wmemset-c
147e83
 endif
147e83
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
147e83
index c90fb6b..44d534b 100644
147e83
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
147e83
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
147e83
@@ -133,6 +133,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
147e83
 
147e83
   IFUNC_VX_IMPL (memccpy);
147e83
 
147e83
+  IFUNC_VX_IMPL (wmemset);
147e83
+
147e83
 #endif /* HAVE_S390_VX_ASM_SUPPORT */
147e83
 
147e83
   return i;
147e83
diff --git a/sysdeps/s390/multiarch/wmemset-c.c b/sysdeps/s390/multiarch/wmemset-c.c
147e83
new file mode 100644
147e83
index 0000000..59c9a7e
147e83
--- /dev/null
147e83
+++ b/sysdeps/s390/multiarch/wmemset-c.c
147e83
@@ -0,0 +1,31 @@
147e83
+/* Default wmemset implementation for S/390.
147e83
+   Copyright (C) 2015 Free Software Foundation, Inc.
147e83
+   This file is part of the GNU C Library.
147e83
+
147e83
+   The GNU C Library is free software; you can redistribute it and/or
147e83
+   modify it under the terms of the GNU Lesser General Public
147e83
+   License as published by the Free Software Foundation; either
147e83
+   version 2.1 of the License, or (at your option) any later version.
147e83
+
147e83
+   The GNU C Library is distributed in the hope that it will be useful,
147e83
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
147e83
+   Lesser General Public License for more details.
147e83
+
147e83
+   You should have received a copy of the GNU Lesser General Public
147e83
+   License along with the GNU C Library; if not, see
147e83
+   <http://www.gnu.org/licenses/>.  */
147e83
+
147e83
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
147e83
+# define WMEMSET  __wmemset_c
147e83
+
147e83
+# include <wchar.h>
147e83
+extern __typeof (wmemset) __wmemset_c;
147e83
+# ifdef SHARED
147e83
+#  undef libc_hidden_def
147e83
+#  define libc_hidden_def(name)					\
147e83
+  __hidden_ver1 (__wmemset_c, __GI_wmemset, __wmemset_c);
147e83
+# endif /* SHARED */
147e83
+
147e83
+# include <wcsmbs/wmemset.c>
147e83
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
147e83
diff --git a/sysdeps/s390/multiarch/wmemset-vx.S b/sysdeps/s390/multiarch/wmemset-vx.S
147e83
new file mode 100644
147e83
index 0000000..dae2c29
147e83
--- /dev/null
147e83
+++ b/sysdeps/s390/multiarch/wmemset-vx.S
147e83
@@ -0,0 +1,142 @@
147e83
+/* Vector Optimized 32/64 bit S/390 version of wmemset.
147e83
+   Copyright (C) 2015 Free Software Foundation, Inc.
147e83
+   This file is part of the GNU C Library.
147e83
+
147e83
+   The GNU C Library is free software; you can redistribute it and/or
147e83
+   modify it under the terms of the GNU Lesser General Public
147e83
+   License as published by the Free Software Foundation; either
147e83
+   version 2.1 of the License, or (at your option) any later version.
147e83
+
147e83
+   The GNU C Library is distributed in the hope that it will be useful,
147e83
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
147e83
+   Lesser General Public License for more details.
147e83
+
147e83
+   You should have received a copy of the GNU Lesser General Public
147e83
+   License along with the GNU C Library; if not, see
147e83
+   <http://www.gnu.org/licenses/>.  */
147e83
+
147e83
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
147e83
+
147e83
+# include "sysdep.h"
147e83
+# include "asm-syntax.h"
147e83
+
147e83
+	.text
147e83
+
147e83
+/* wchar_t *wmemset(wchar_t *dest, wchar_t wc, size_t n)
147e83
+   Fill an array of wide-characters with a constant wide character
147e83
+   and returns dest.
147e83
+
147e83
+   Register usage:
147e83
+   -r0=tmp
147e83
+   -r1=tmp
147e83
+   -r2=dest or current-pointer
147e83
+   -r3=wc
147e83
+   -r4=n
147e83
+   -r5=tmp
147e83
+   -v16=replicated wc
147e83
+   -v17,v18,v19=copy of v16 for vstm
147e83
+   -v31=saved dest for return
147e83
+*/
147e83
+ENTRY(__wmemset_vx)
147e83
+	.machine "z13"
147e83
+	.machinemode "zarch_nohighgprs"
147e83
+
147e83
+# if !defined __s390x__
147e83
+	llgfr	%r4,%r4
147e83
+# endif /* !defined __s390x__ */
147e83
+
147e83
+	vlvgg	%v31,%r2,0	/* Save destination pointer for return.  */
147e83
+	clgije	%r4,0,.Lend
147e83
+
147e83
+	vlvgf	%v16,%r3,0	/* Generate vector with wchar_t wc.  */
147e83
+	vrepf	%v16,%v16,0
147e83
+
147e83
+	/* Check range of maxlen and convert to byte-count.  */
147e83
+# ifdef __s390x__
147e83
+	tmhh	%r4,49152	/* Test bit 0 or 1 of maxlen.  */
147e83
+	lghi	%r5,-4		/* Max byte-count is 18446744073709551612.  */
147e83
+# else
147e83
+	tmlh	%r4,49152	/* Test bit 0 or 1 of maxlen.  */
147e83
+	llilf	%r5,4294967292	/* Max byte-count is 4294967292.  */
147e83
+# endif /* !__s390x__ */
147e83
+	sllg	%r4,%r4,2	/* Convert character-count to byte-count.  */
147e83
+	locgrne	%r4,%r5		/* Use max byte-count, if bit 0/1 was one.  */
147e83
+
147e83
+	/* Align dest to 16 byte.  */
147e83
+	risbg	%r0,%r2,60,128+63,0 /* Test if s is aligned and
147e83
+				       %r3 = bits 60-63 'and' 15.  */
147e83
+	je	.Lpreloop	/* If s is aligned, loop aligned.  */
147e83
+	tmll	%r2,3		/* Test if s is 4-byte aligned?  */
147e83
+	jne	.Lfallback	/* And use common-code variant if not.  */
147e83
+	lghi	%r1,16
147e83
+	slr	%r1,%r0		/* Compute byte count to load (16-x).  */
147e83
+	clgr	%r1,%r4
147e83
+	locgrh	%r1,%r4		/* min (byte count, n)  */
147e83
+	aghik	%r5,%r1,-1	/* vstl needs highest index.  */
147e83
+	vstl	%v16,%r5,0(%r2)	/* Store remaining bytes.  */
147e83
+	clgrje	%r1,%r4,.Lend	/* Return if n bytes where set.  */
147e83
+	slgr	%r4,%r1		/* Compute remaining byte count.  */
147e83
+	la	%r2,0(%r1,%r2)
147e83
+
147e83
+.Lpreloop:
147e83
+	/* Now we are 16-byte aligned.  */
147e83
+	clgijl	%r4,17,.Lremaining
147e83
+	srlg	%r1,%r4,8	/* Split into 256byte blocks */
147e83
+	clgije	%r1,0,.Lpreloop64
147e83
+	vlr	%v17,%v16
147e83
+	vlr	%v18,%v16
147e83
+	vlr	%v19,%v16
147e83
+
147e83
+.Lloop256:
147e83
+	vstm	%v16,%v19,0(%r2)
147e83
+	vstm	%v16,%v19,64(%r2)
147e83
+	vstm	%v16,%v19,128(%r2)
147e83
+	vstm	%v16,%v19,192(%r2)
147e83
+	la	%r2,256(%r2)
147e83
+	brctg	%r1,.Lloop256	/* Loop until all blocks are processed.  */
147e83
+
147e83
+	llgfr	%r4,%r4
147e83
+	nilf	%r4,255		/* Get remaining bytes */
147e83
+	je	.Lend		/* Skip store remaining bytes if zero.  */
147e83
+
147e83
+.Lpreloop64:
147e83
+	clgijl	%r4,17,.Lremaining
147e83
+	clgijl	%r4,33,.Lpreloop16
147e83
+	srlg	%r1,%r4,5	/* Split into 32byte blocks */
147e83
+
147e83
+.Lloop32:
147e83
+	vst	%v16,0(%r2)
147e83
+	vst	%v16,16(%r2)
147e83
+	la	%r2,32(%r2)
147e83
+	brctg	%r1,.Lloop32	/* Loop until all blocks are processed.  */
147e83
+
147e83
+	llgfr	%r4,%r4
147e83
+	nilf	%r4,31		/* Get remaining bytes */
147e83
+	je	.Lend		/* Skip store remaining bytes if zero.  */
147e83
+
147e83
+.Lpreloop16:
147e83
+	clgijl	%r4,17,.Lremaining
147e83
+	srlg	%r1,%r4,4	/* Split into 16byte blocks */
147e83
+
147e83
+.Lloop16:
147e83
+	vst	%v16,0(%r2)
147e83
+	la	%r2,16(%r2)
147e83
+	brctg	%r1,.Lloop16	/* Loop until all blocks are processed.  */
147e83
+
147e83
+	llgfr	%r4,%r4
147e83
+	nilf	%r4,15		/* Get remaining bytes */
147e83
+	je	.Lend		/* Skip store remaining bytes if zero.  */
147e83
+
147e83
+.Lremaining:
147e83
+	aghi	%r4,-1		/* vstl needs highest index.  */
147e83
+	vstl	%v16,%r4,0(%r2)
147e83
+
147e83
+.Lend:
147e83
+	vlgvg	%r2,%v31,0	/* Load saved dest for return value.  */
147e83
+	br	%r14
147e83
+.Lfallback:
147e83
+	srlg	%r4,%r4,2	/* Convert byte-count to character-count.  */
147e83
+	jg	__wmemset_c
147e83
+END(__wmemset_vx)
147e83
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
147e83
diff --git a/sysdeps/s390/multiarch/wmemset.c b/sysdeps/s390/multiarch/wmemset.c
147e83
new file mode 100644
147e83
index 0000000..1225fc1
147e83
--- /dev/null
147e83
+++ b/sysdeps/s390/multiarch/wmemset.c
147e83
@@ -0,0 +1,27 @@
147e83
+/* Multiple versions of wmemset.
147e83
+   Copyright (C) 2015 Free Software Foundation, Inc.
147e83
+   This file is part of the GNU C Library.
147e83
+
147e83
+   The GNU C Library is free software; you can redistribute it and/or
147e83
+   modify it under the terms of the GNU Lesser General Public
147e83
+   License as published by the Free Software Foundation; either
147e83
+   version 2.1 of the License, or (at your option) any later version.
147e83
+
147e83
+   The GNU C Library is distributed in the hope that it will be useful,
147e83
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
147e83
+   Lesser General Public License for more details.
147e83
+
147e83
+   You should have received a copy of the GNU Lesser General Public
147e83
+   License along with the GNU C Library; if not, see
147e83
+   <http://www.gnu.org/licenses/>.  */
147e83
+
147e83
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
147e83
+# include <wchar.h>
147e83
+# include <ifunc-resolve.h>
147e83
+
147e83
+s390_vx_libc_ifunc2 (__wmemset, wmemset)
147e83
+
147e83
+#else
147e83
+# include <wcsmbs/wmemset.c>
147e83
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
147e83
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
147e83
index f8bc401..1ca3ace 100644
147e83
--- a/wcsmbs/Makefile
147e83
+++ b/wcsmbs/Makefile
147e83
@@ -43,7 +43,7 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
147e83
 
147e83
 strop-tests :=  wcscmp wcsncmp wmemcmp wcslen wcschr wcsrchr wcscpy wcsnlen \
147e83
 		wcpcpy wcsncpy wcpncpy wcscat wcsncat wcschrnul wcsspn wcspbrk \
147e83
-		wcscspn wmemchr
147e83
+		wcscspn wmemchr wmemset
147e83
 tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen tst-btowc tst-mbrtowc \
147e83
 	 tst-wcrtomb tst-wcpncpy tst-mbsrtowcs tst-wchar-h tst-mbrtowc2 \
147e83
 	 tst-c16c32-1 wcsatcliff $(addprefix test-,$(strop-tests))
147e83
diff --git a/wcsmbs/test-wmemset-ifunc.c b/wcsmbs/test-wmemset-ifunc.c
147e83
new file mode 100644
147e83
index 0000000..b58b6bd
147e83
--- /dev/null
147e83
+++ b/wcsmbs/test-wmemset-ifunc.c
147e83
@@ -0,0 +1,20 @@
147e83
+/* Test and measure IFUNC implementations of wmemset function.
147e83
+   Copyright (C) 2015 Free Software Foundation, Inc.
147e83
+   This file is part of the GNU C Library.
147e83
+
147e83
+   The GNU C Library is free software; you can redistribute it and/or
147e83
+   modify it under the terms of the GNU Lesser General Public
147e83
+   License as published by the Free Software Foundation; either
147e83
+   version 2.1 of the License, or (at your option) any later version.
147e83
+
147e83
+   The GNU C Library is distributed in the hope that it will be useful,
147e83
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
147e83
+   Lesser General Public License for more details.
147e83
+
147e83
+   You should have received a copy of the GNU Lesser General Public
147e83
+   License along with the GNU C Library; if not, see
147e83
+   <http://www.gnu.org/licenses/>.  */
147e83
+
147e83
+#define TEST_IFUNC 1
147e83
+#include "test-wmemset.c"
147e83
diff --git a/wcsmbs/test-wmemset.c b/wcsmbs/test-wmemset.c
147e83
new file mode 100644
147e83
index 0000000..c03c759
147e83
--- /dev/null
147e83
+++ b/wcsmbs/test-wmemset.c
147e83
@@ -0,0 +1,20 @@
147e83
+/* Test wmemset functions.
147e83
+   Copyright (C) 2015 Free Software Foundation, Inc.
147e83
+   This file is part of the GNU C Library.
147e83
+
147e83
+   The GNU C Library is free software; you can redistribute it and/or
147e83
+   modify it under the terms of the GNU Lesser General Public
147e83
+   License as published by the Free Software Foundation; either
147e83
+   version 2.1 of the License, or (at your option) any later version.
147e83
+
147e83
+   The GNU C Library is distributed in the hope that it will be useful,
147e83
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
147e83
+   Lesser General Public License for more details.
147e83
+
147e83
+   You should have received a copy of the GNU Lesser General Public
147e83
+   License along with the GNU C Library; if not, see
147e83
+   <http://www.gnu.org/licenses/>.  */
147e83
+
147e83
+#define WIDE 1
147e83
+#include "../string/test-memset.c"
147e83
diff --git a/wcsmbs/wmemset.c b/wcsmbs/wmemset.c
147e83
index cc9a725..8049bb8 100644
147e83
--- a/wcsmbs/wmemset.c
147e83
+++ b/wcsmbs/wmemset.c
147e83
@@ -18,6 +18,9 @@
147e83
 
147e83
 #include <wchar.h>
147e83
 
147e83
+#ifdef WMEMSET
147e83
+# define wmemset WMEMSET
147e83
+#endif
147e83
 
147e83
 wchar_t *
147e83
 wmemset (s, c, n)
147e83
-- 
147e83
2.3.0
147e83