Blame SOURCES/glibc-rh1268008-25.patch

147e83
From 6be435ec4f615266351487da396333f3ff026c03 Mon Sep 17 00:00:00 2001
147e83
From: Stefan Liebler <stli@linux.vnet.ibm.com>
147e83
Date: Thu, 8 Oct 2015 13:02:41 +0200
147e83
Subject: [PATCH 25/30] S390: Optimize strcspn and wcscspn.
147e83
147e83
upstream-commit-id: b4c21601b147efc3c2b0e679e4ffc554b3987f0b
147e83
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00099.html
147e83
147e83
This patch provides optimized versions of strcspn and wcscspn with the z13
147e83
vector instructions.
147e83
147e83
ChangeLog:
147e83
147e83
	* sysdeps/s390/multiarch/strcspn-c.c: New File.
147e83
	* sysdeps/s390/multiarch/strcspn-vx.S: Likewise.
147e83
	* sysdeps/s390/multiarch/strcspn.c: Likewise.
147e83
	* sysdeps/s390/multiarch/wcscspn-c.c: Likewise.
147e83
	* sysdeps/s390/multiarch/wcscspn-vx.S: Likewise.
147e83
	* sysdeps/s390/multiarch/wcscspn.c: Likewise.
147e83
	* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add strcspn and
147e83
	wcscspn functions.
147e83
	* sysdeps/s390/multiarch/ifunc-impl-list.c
147e83
	(__libc_ifunc_impl_list): Add ifunc test for strcspn, wcscspn.
147e83
	* wcsmbs/wcscspn.c: Use WCSCSPN if defined.
147e83
	* string/test-strcspn.c: Add wcscspn support.
147e83
	* wcsmbs/test-wcscspn.c: New File.
147e83
	* wcsmbs/Makefile (strop-tests): Add wcscspn.
147e83
	* benchtests/bench-strcspn.c: Add wcscspn support.
147e83
	* benchtests/bench-wcscspn.c: New File.
147e83
	* benchtests/Makefile (wcsmbs-bench): Add wcscspn.
147e83
---
147e83
 benchtests/Makefile                      |   2 +-
147e83
 benchtests/bench-strcspn.c               |  45 +++--
147e83
 benchtests/bench-wcscspn.c               |  20 +++
147e83
 string/strcspn.c                         |   8 +-
147e83
 string/test-strcspn.c                    |  45 +++--
147e83
 sysdeps/s390/multiarch/Makefile          |   6 +-
147e83
 sysdeps/s390/multiarch/ifunc-impl-list.c |   3 +
147e83
 sysdeps/s390/multiarch/strcspn-c.c       |  28 +++
147e83
 sysdeps/s390/multiarch/strcspn-vx.S      | 281 +++++++++++++++++++++++++++++
147e83
 sysdeps/s390/multiarch/strcspn.c         |  27 +++
147e83
 sysdeps/s390/multiarch/wcscspn-c.c       |  26 +++
147e83
 sysdeps/s390/multiarch/wcscspn-vx.S      | 293 +++++++++++++++++++++++++++++++
147e83
 sysdeps/s390/multiarch/wcscspn.c         |  27 +++
147e83
 wcsmbs/Makefile                          |   3 +-
147e83
 wcsmbs/test-wcscspn-ifunc.c              |  20 +++
147e83
 wcsmbs/test-wcscspn.c                    |  20 +++
147e83
 wcsmbs/wcscspn.c                         |   3 +
147e83
 17 files changed, 826 insertions(+), 31 deletions(-)
147e83
 create mode 100644 benchtests/bench-wcscspn.c
147e83
 create mode 100644 sysdeps/s390/multiarch/strcspn-c.c
147e83
 create mode 100644 sysdeps/s390/multiarch/strcspn-vx.S
147e83
 create mode 100644 sysdeps/s390/multiarch/strcspn.c
147e83
 create mode 100644 sysdeps/s390/multiarch/wcscspn-c.c
147e83
 create mode 100644 sysdeps/s390/multiarch/wcscspn-vx.S
147e83
 create mode 100644 sysdeps/s390/multiarch/wcscspn.c
147e83
 create mode 100644 wcsmbs/test-wcscspn-ifunc.c
147e83
 create mode 100644 wcsmbs/test-wcscspn.c
147e83
147e83
diff --git a/benchtests/Makefile b/benchtests/Makefile
147e83
index 015b5d6..4e811a9 100644
147e83
--- a/benchtests/Makefile
147e83
+++ b/benchtests/Makefile
147e83
@@ -39,7 +39,7 @@ string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
147e83
 		strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
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
147e83
+		wcsncmp wcsncmp wcschr wcschrnul wcsrchr wcsspn wcspbrk wcscspn
147e83
 string-bench-all := $(string-bench) ${wcsmbs-bench}
147e83
 
147e83
 stdlib-bench := strtod
147e83
diff --git a/benchtests/bench-strcspn.c b/benchtests/bench-strcspn.c
147e83
index 22b3b84..25de640 100644
147e83
--- a/benchtests/bench-strcspn.c
147e83
+++ b/benchtests/bench-strcspn.c
147e83
@@ -19,22 +19,41 @@
147e83
 #define STRPBRK_RESULT(s, pos) (pos)
147e83
 #define RES_TYPE size_t
147e83
 #define TEST_MAIN
147e83
-#define TEST_NAME "strcspn"
147e83
+#ifndef WIDE
147e83
+# define TEST_NAME "strcspn"
147e83
+#else
147e83
+# define TEST_NAME "wcscspn"
147e83
+#endif /* WIDE */
147e83
 #include "bench-string.h"
147e83
 
147e83
-typedef size_t (*proto_t) (const char *, const char *);
147e83
-size_t simple_strcspn (const char *, const char *);
147e83
-size_t stupid_strcspn (const char *, const char *);
147e83
+#ifndef WIDE
147e83
+# define STRCSPN strcspn
147e83
+# define CHAR char
147e83
+# define SIMPLE_STRCSPN simple_strcspn
147e83
+# define STUPID_STRCSPN stupid_strcspn
147e83
+# define STRLEN strlen
147e83
+#else
147e83
+# include <wchar.h>
147e83
+# define STRCSPN wcscspn
147e83
+# define CHAR wchar_t
147e83
+# define SIMPLE_STRCSPN simple_wcscspn
147e83
+# define STUPID_STRCSPN stupid_wcscspn
147e83
+# define STRLEN wcslen
147e83
+#endif /* WIDE */
147e83
 
147e83
-IMPL (stupid_strcspn, 0)
147e83
-IMPL (simple_strcspn, 0)
147e83
-IMPL (strcspn, 1)
147e83
+typedef size_t (*proto_t) (const CHAR *, const CHAR *);
147e83
+size_t SIMPLE_STRCSPN (const CHAR *, const CHAR *);
147e83
+size_t STUPID_STRCSPN (const CHAR *, const CHAR *);
147e83
+
147e83
+IMPL (STUPID_STRCSPN, 0)
147e83
+IMPL (SIMPLE_STRCSPN, 0)
147e83
+IMPL (STRCSPN, 1)
147e83
 
147e83
 size_t
147e83
-simple_strcspn (const char *s, const char *rej)
147e83
+SIMPLE_STRCSPN (const CHAR *s, const CHAR *rej)
147e83
 {
147e83
-  const char *r, *str = s;
147e83
-  char c;
147e83
+  const CHAR *r, *str = s;
147e83
+  CHAR c;
147e83
 
147e83
   while ((c = *s++) != '\0')
147e83
     for (r = rej; *r != '\0'; ++r)
147e83
@@ -44,9 +63,9 @@ simple_strcspn (const char *s, const char *rej)
147e83
 }
147e83
 
147e83
 size_t
147e83
-stupid_strcspn (const char *s, const char *rej)
147e83
+STUPID_STRCSPN (const CHAR *s, const CHAR *rej)
147e83
 {
147e83
-  size_t ns = strlen (s), nrej = strlen (rej);
147e83
+  size_t ns = STRLEN (s), nrej = STRLEN (rej);
147e83
   size_t i, j;
147e83
 
147e83
   for (i = 0; i < ns; ++i)
147e83
@@ -56,4 +75,6 @@ stupid_strcspn (const char *s, const char *rej)
147e83
   return i;
147e83
 }
147e83
 
147e83
+#undef CHAR
147e83
+#undef STRLEN
147e83
 #include "bench-strpbrk.c"
147e83
diff --git a/benchtests/bench-wcscspn.c b/benchtests/bench-wcscspn.c
147e83
new file mode 100644
147e83
index 0000000..3991951
147e83
--- /dev/null
147e83
+++ b/benchtests/bench-wcscspn.c
147e83
@@ -0,0 +1,20 @@
147e83
+/* Measure wcscspn 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-strcspn.c"
147e83
diff --git a/string/strcspn.c b/string/strcspn.c
147e83
index 6290429..0c750a8 100644
147e83
--- a/string/strcspn.c
147e83
+++ b/string/strcspn.c
147e83
@@ -30,12 +30,14 @@
147e83
 
147e83
 #undef strcspn
147e83
 
147e83
+#ifndef STRCSPN
147e83
+# define STRCSPN strcspn
147e83
+#endif
147e83
+
147e83
 /* Return the length of the maximum initial segment of S
147e83
    which contains no characters from REJECT.  */
147e83
 size_t
147e83
-strcspn (s, reject)
147e83
-     const char *s;
147e83
-     const char *reject;
147e83
+STRCSPN (const char *s, const char *reject)
147e83
 {
147e83
   size_t count = 0;
147e83
 
147e83
diff --git a/string/test-strcspn.c b/string/test-strcspn.c
147e83
index e2863c7..3443425 100644
147e83
--- a/string/test-strcspn.c
147e83
+++ b/string/test-strcspn.c
147e83
@@ -20,22 +20,41 @@
147e83
 #define STRPBRK_RESULT(s, pos) (pos)
147e83
 #define RES_TYPE size_t
147e83
 #define TEST_MAIN
147e83
-#define TEST_NAME "strcspn"
147e83
+#ifndef WIDE
147e83
+# define TEST_NAME "strcspn"
147e83
+#else
147e83
+# define TEST_NAME "wcscspn"
147e83
+#endif /* WIDE */
147e83
 #include "test-string.h"
147e83
 
147e83
-typedef size_t (*proto_t) (const char *, const char *);
147e83
-size_t simple_strcspn (const char *, const char *);
147e83
-size_t stupid_strcspn (const char *, const char *);
147e83
+#ifndef WIDE
147e83
+# define STRCSPN strcspn
147e83
+# define CHAR char
147e83
+# define SIMPLE_STRCSPN simple_strcspn
147e83
+# define STUPID_STRCSPN stupid_strcspn
147e83
+# define STRLEN strlen
147e83
+#else
147e83
+# include <wchar.h>
147e83
+# define STRCSPN wcscspn
147e83
+# define CHAR wchar_t
147e83
+# define SIMPLE_STRCSPN simple_wcscspn
147e83
+# define STUPID_STRCSPN stupid_wcscspn
147e83
+# define STRLEN wcslen
147e83
+#endif /* WIDE */
147e83
 
147e83
-IMPL (stupid_strcspn, 0)
147e83
-IMPL (simple_strcspn, 0)
147e83
-IMPL (strcspn, 1)
147e83
+typedef size_t (*proto_t) (const CHAR *, const CHAR *);
147e83
+size_t SIMPLE_STRCSPN (const CHAR *, const CHAR *);
147e83
+size_t STUPID_STRCSPN (const CHAR *, const CHAR *);
147e83
+
147e83
+IMPL (STUPID_STRCSPN, 0)
147e83
+IMPL (SIMPLE_STRCSPN, 0)
147e83
+IMPL (STRCSPN, 1)
147e83
 
147e83
 size_t
147e83
-simple_strcspn (const char *s, const char *rej)
147e83
+SIMPLE_STRCSPN (const CHAR *s, const CHAR *rej)
147e83
 {
147e83
-  const char *r, *str = s;
147e83
-  char c;
147e83
+  const CHAR *r, *str = s;
147e83
+  CHAR c;
147e83
 
147e83
   while ((c = *s++) != '\0')
147e83
     for (r = rej; *r != '\0'; ++r)
147e83
@@ -45,9 +64,9 @@ simple_strcspn (const char *s, const char *rej)
147e83
 }
147e83
 
147e83
 size_t
147e83
-stupid_strcspn (const char *s, const char *rej)
147e83
+STUPID_STRCSPN (const CHAR *s, const CHAR *rej)
147e83
 {
147e83
-  size_t ns = strlen (s), nrej = strlen (rej);
147e83
+  size_t ns = STRLEN (s), nrej = STRLEN (rej);
147e83
   size_t i, j;
147e83
 
147e83
   for (i = 0; i < ns; ++i)
147e83
@@ -57,4 +76,6 @@ stupid_strcspn (const char *s, const char *rej)
147e83
   return i;
147e83
 }
147e83
 
147e83
+#undef CHAR
147e83
+#undef STRLEN
147e83
 #include "test-strpbrk.c"
147e83
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
147e83
index 5765a8c..2c1fce0 100644
147e83
--- a/sysdeps/s390/multiarch/Makefile
147e83
+++ b/sysdeps/s390/multiarch/Makefile
147e83
@@ -13,7 +13,8 @@ sysdep_routines += strlen strlen-vx strlen-c \
147e83
 		   strchrnul strchrnul-vx strchrnul-c \
147e83
 		   strrchr strrchr-vx strrchr-c \
147e83
 		   strspn strspn-vx strspn-c \
147e83
-		   strpbrk strpbrk-vx strpbrk-c
147e83
+		   strpbrk strpbrk-vx strpbrk-c \
147e83
+		   strcspn strcspn-vx strcspn-c
147e83
 endif
147e83
 
147e83
 ifeq ($(subdir),wcsmbs)
147e83
@@ -31,5 +32,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \
147e83
 		   wcschrnul wcschrnul-vx wcschrnul-c \
147e83
 		   wcsrchr wcsrchr-vx wcsrchr-c \
147e83
 		   wcsspn wcsspn-vx wcsspn-c \
147e83
-		   wcspbrk wcspbrk-vx wcspbrk-c
147e83
+		   wcspbrk wcspbrk-vx wcspbrk-c \
147e83
+		   wcscspn wcscspn-vx wcscspn-c
147e83
 endif
147e83
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
147e83
index b39a5c5..7f62e49 100644
147e83
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
147e83
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
147e83
@@ -124,6 +124,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
147e83
   IFUNC_VX_IMPL (strpbrk);
147e83
   IFUNC_VX_IMPL (wcspbrk);
147e83
 
147e83
+  IFUNC_VX_IMPL (strcspn);
147e83
+  IFUNC_VX_IMPL (wcscspn);
147e83
+
147e83
 #endif /* HAVE_S390_VX_ASM_SUPPORT */
147e83
 
147e83
   return i;
147e83
diff --git a/sysdeps/s390/multiarch/strcspn-c.c b/sysdeps/s390/multiarch/strcspn-c.c
147e83
new file mode 100644
147e83
index 0000000..af04b4e
147e83
--- /dev/null
147e83
+++ b/sysdeps/s390/multiarch/strcspn-c.c
147e83
@@ -0,0 +1,28 @@
147e83
+/* Default strcspn 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 STRCSPN  __strcspn_c
147e83
+# ifdef SHARED
147e83
+#  undef libc_hidden_builtin_def
147e83
+#  define libc_hidden_builtin_def(name)				\
147e83
+     __hidden_ver1 (__strcspn_c, __GI_strcspn, __strcspn_c);
147e83
+# endif /* SHARED */
147e83
+
147e83
+# include <string/strcspn.c>
147e83
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
147e83
diff --git a/sysdeps/s390/multiarch/strcspn-vx.S b/sysdeps/s390/multiarch/strcspn-vx.S
147e83
new file mode 100644
147e83
index 0000000..c7113c4
147e83
--- /dev/null
147e83
+++ b/sysdeps/s390/multiarch/strcspn-vx.S
147e83
@@ -0,0 +1,281 @@
147e83
+/* Vector optimized 32/64 bit S/390 version of strcspn.
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
+/* size_t strcspn (const char *s, const char * reject)
147e83
+   The strcspn() function calculates the length of the initial segment
147e83
+   of s which consists entirely of characters not in reject.
147e83
+
147e83
+   This method checks the length of reject string. If it fits entirely
147e83
+   in one vector register, a fast algorithm is used, which does not need
147e83
+   to check multiple parts of accept-string. Otherwise a slower full
147e83
+   check of accept-string is used.
147e83
+
147e83
+   register overview:
147e83
+   r3:  pointer to start of reject-string
147e83
+   r2:  pointer to start of search-string
147e83
+   r0:  loaded byte count of vlbb search-string
147e83
+   r4:  found byte index
147e83
+   r1:  current return len
147e83
+   v16: search-string
147e83
+   v17: reject-string
147e83
+   v18: temp-vreg
147e83
+
147e83
+   ONLY FOR SLOW:
147e83
+   v19: first reject-string
147e83
+   v20: zero for preparing acc-vector
147e83
+   v21: global mask; 1 indicates a match between
147e83
+	search-string-vreg and any reject-character
147e83
+   v22: current mask; 1 indicates a match between
147e83
+	search-string-vreg and any reject-character in current acc-vreg
147e83
+   v24: one for result-checking of former string-part
147e83
+   v30, v31: for re-/storing registers r6, r8, r9
147e83
+   r5:  current len of reject-string
147e83
+   r6:  zero-index in search-string or 16 if no zero
147e83
+	or min(zero-index, loaded byte count)
147e83
+   r8:  >0, if former reject-string-part contains a zero,
147e83
+			otherwise =0;
147e83
+   r9:  loaded byte count of vlbb reject-string
147e83
+*/
147e83
+ENTRY(__strcspn_vx)
147e83
+	.machine "z13"
147e83
+	.machinemode "zarch_nohighgprs"
147e83
+
147e83
+	/*
147e83
+	  Check if reject-string fits in one vreg:
147e83
+	  ----------------------------------------
147e83
+	*/
147e83
+	vlbb	%v17,0(%r3),6	/* Load reject.  */
147e83
+	lghi	%r1,0		/* Zero out current len.  */
147e83
+	lcbb	%r0,0(%r3),6
147e83
+	jo	.Lcheck_onbb	/* Special case if reject
147e83
+				   lays on block-boundary.  */
147e83
+.Lcheck_notonbb:
147e83
+	vistrbs	%v17,%v17	/* Fill with zeros after first zero.  */
147e83
+	je	.Lfast		/* Zero found -> reject fits in one vreg.  */
147e83
+	j	.Lslow		/* No zero -> reject exceeds one vreg.  */
147e83
+
147e83
+
147e83
+.Lcheck_onbb:
147e83
+	/* Reject lays on block-boundary.  */
147e83
+	vfenezb	%v18,%v17,%v17	/* Search zero in loaded reject bytes.  */
147e83
+	vlgvb	%r4,%v18,7	/* Get index of zero or 16 if not found.  */
147e83
+	clrjl	%r4,%r0,.Lcheck_notonbb /* Zero index < loaded bytes count ->
147e83
+					    Reject fits in one vreg;
147e83
+					    Fill with zeros and proceed
147e83
+					    with FAST.  */
147e83
+	vl	%v17,0(%r3)	/* Load reject, which exceeds loaded bytes.  */
147e83
+	j	.Lcheck_notonbb /* Check if reject fits in one vreg.  */
147e83
+
147e83
+
147e83
+	/*
147e83
+	  Search s for reject in one vreg
147e83
+	  -------------------------------
147e83
+	*/
147e83
+.Lfast:
147e83
+	/* Complete reject-string in v17 and remaining bytes are zero.  */
147e83
+
147e83
+	vlbb	%v16,0(%r2),6	/* Load s until next 4k-byte boundary.  */
147e83
+	lcbb	%r0,0(%r2),6	/* Get bytes to 4k-byte boundary or 16.  */
147e83
+
147e83
+	vfaezbs	%v18,%v16,%v17,0 /* Find first element in v16
147e83
+				    unequal to any in v17
147e83
+				    or first zero element.  */
147e83
+
147e83
+	vlgvb	%r4,%v18,7	/* Load byte index of found element.  */
147e83
+	clrjl	%r4,%r0,.Lfast_loop_found2 /* If found index is within loaded
147e83
+					       bytes, return with found element
147e83
+					       index (=equal count).  */
147e83
+
147e83
+	/* Align s to 16 byte.  */
147e83
+	risbgn	%r4,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15.  */
147e83
+	lghi	%r1,16		/* current_len = 16.  */
147e83
+	slr	%r1,%r4		/* Compute bytes to 16bytes boundary.  */
147e83
+
147e83
+	/* Process s in 16byte aligned loop.  */
147e83
+.Lfast_loop:
147e83
+	vl	%v16,0(%r1,%r2)	/* Load search-string.  */
147e83
+	vfaezbs	%v18,%v16,%v17,0 /* Find first element in v16 equal to any
147e83
+				    in v17 or first zero element.  */
147e83
+	jno	.Lfast_loop_found
147e83
+
147e83
+	vl	%v16,16(%r1,%r2)
147e83
+	vfaezbs	%v18,%v16,%v17,0
147e83
+	jno	.Lfast_loop_found16
147e83
+
147e83
+	vl	%v16,32(%r1,%r2)
147e83
+	vfaezbs	%v18,%v16,%v17,0
147e83
+	jno	.Lfast_loop_found32
147e83
+
147e83
+	vl	%v16,48(%r1,%r2)
147e83
+	vfaezbs	%v18,%v16,%v17,0
147e83
+	jno	.Lfast_loop_found48
147e83
+
147e83
+	aghi	%r1,64
147e83
+	j	.Lfast_loop	/* Loop if no element was unequal to reject
147e83
+				   and not zero.  */
147e83
+
147e83
+	/* Found equal or zero element.  */
147e83
+.Lfast_loop_found48:
147e83
+	aghi	%r1,16
147e83
+.Lfast_loop_found32:
147e83
+	aghi	%r1,16
147e83
+.Lfast_loop_found16:
147e83
+	aghi	%r1,16
147e83
+.Lfast_loop_found:
147e83
+	vlgvb	%r4,%v18,7	/* Load byte index of found element or zero.  */
147e83
+.Lfast_loop_found2:
147e83
+	algrk	%r2,%r1,%r4	/* Add found index to current len.  */
147e83
+	br	%r14
147e83
+
147e83
+
147e83
+
147e83
+	/*
147e83
+	  Search s for reject in multiple vregs
147e83
+	  -------------------------------------
147e83
+	*/
147e83
+.Lslow:
147e83
+	/* Save registers.  */
147e83
+	vlvgg	%v30,%r6,0
147e83
+	vlvgp	%v31,%r8,%r9
147e83
+
147e83
+	/* Reject in v17 without zero.  */
147e83
+	vlr	%v19,%v17	/* Save first acc-part for a fast reload.  */
147e83
+	vzero	%v20		/* Zero for preparing acc-vector.  */
147e83
+	vone	%v24		/* One for checking result of former
147e83
+				   string-part.  */
147e83
+
147e83
+	/* Align s to 16 byte.  */
147e83
+	risbg	%r4,%r2,60,128+63,0 /* Test if s is aligned and
147e83
+				       %r4 = bits 60-63 'and' 15.   */
147e83
+	je	.Lslow_loop_str /* If s is aligned, loop aligned.  */
147e83
+	lghi	%r0,15
147e83
+	slr	%r0,%r4		/* Compute highest index to load (15-x).  */
147e83
+	vll	%v16,%r0,0(%r2) /* Load up to 16 byte boundary (vll needs
147e83
+				   highest index, remaining bytes are 0).  */
147e83
+	ahi	%r0,1		/* Work with loaded byte count.  */
147e83
+	vzero	%v21		/* Zero out global mask.  */
147e83
+	lghi	%r5,0		/* Set current len of reject-string to zero.  */
147e83
+	vfenezb	%v18,%v16,%v16	/* Find zero in current string-part.  */
147e83
+	lghi	%r8,0		/* There is no zero in first reject-part.  */
147e83
+	vlgvb	%r6,%v18,7	/* Load byte index of zero or 16 if no zero.  */
147e83
+	clije	%r6,0,.Lslow_end /* If first element is zero -> return 0.  */
147e83
+	clr	%r0,%r6		/* cc==1 if loaded byte count < zero-index.  */
147e83
+	locrl	%r6,%r0		/* Load on cc==1; zero-index = lbc.  */
147e83
+	j	.Lslow_loop_acc
147e83
+
147e83
+
147e83
+	/* Process s in 16byte aligned loop.  */
147e83
+.Lslow_next_str:
147e83
+	/* Check results of former processed str-part.  */
147e83
+	vfeeb	%v18,%v21,%v24	/* Find first equal match in global mask
147e83
+				   (ones in element).  */
147e83
+	vlgvb	%r4,%v18,7	/* Get index of first one (=equal) or 16.  */
147e83
+	/* Equal-index < min(zero-index, loaded byte count)
147e83
+	   -> Return pointer to equal element.  */
147e83
+	clrjl	%r4,%r6,.Lslow_index_found
147e83
+	/* Zero-index < loaded byte count
147e83
+	   -> Former str-part was last str-part
147e83
+	   -> Return null */
147e83
+	clrjl	%r6,%r0,.Lslow_end_not_found
147e83
+
147e83
+	/* All elements are zero (=no match) -> Proceed with next str-part.  */
147e83
+	vlr	%v17,%v19	/* Load first part of reject (no zero).  */
147e83
+	algfr	%r1,%r0		/* Add loaded byte count to current len.  */
147e83
+
147e83
+.Lslow_loop_str:
147e83
+	vl	%v16,0(%r1,%r2)	/* Load search-string.  */
147e83
+	lghi	%r0,16		/* Loaded byte count is 16.  */
147e83
+	vzero	%v21		/* Zero out global mask.  */
147e83
+	lghi	%r5,0		/* Set current len of reject to zero.  */
147e83
+	vfenezb	%v18,%v16,%v16	/* Find zero in current string-part.  */
147e83
+	lghi	%r8,0		/* There is no zero in first reject-part.  */
147e83
+	vlgvb	%r6,%v18,7	/* Load byte index of zero or 16 if no zero.  */
147e83
+	clije	%r6,0,.Lslow_end /* If first element is zero (end of string)
147e83
+				     -> Return current length.  */
147e83
+
147e83
+.Lslow_loop_acc:
147e83
+	vfaeb	%v22,%v16,%v17,4 /* Create matching-mask (1 in mask ->
147e83
+				    Character matches any rejected character in
147e83
+				    this reject-string-part) IN=0, RT=1.  */
147e83
+	vlgvb	%r4,%v22,0	/* Get result of first element.  */
147e83
+	/* First element is equal to any rejected characters?
147e83
+	   (all other parts of reject cannot lead to a match before this one)
147e83
+	   -> Return current len, which is pointing to this element.  */
147e83
+	clijh	%r4,0,.Lslow_end
147e83
+	vo	%v21,%v21,%v22	/* Global-mask = global-|matching-mask.  */
147e83
+	/* Proceed with next acc until end of acc is reached.  */
147e83
+
147e83
+
147e83
+.Lslow_next_acc:
147e83
+	clijh	%r8,0,.Lslow_next_str /* There was a zero in last reject-part
147e83
+					  -> Add found index to current len
147e83
+					     and end.  */
147e83
+	vlbb	%v17,16(%r5,%r3),6 /* Load next reject part.  */
147e83
+	aghi	%r5,16		/* Increment current len of reject-string.  */
147e83
+	lcbb	%r9,0(%r5,%r3),6 /* Get loaded byte count of reject-string.  */
147e83
+	jo	.Lslow_next_acc_onbb /* Jump away if reject-string is
147e83
+					 on block-boundary.  */
147e83
+.Lslow_next_acc_notonbb:
147e83
+	vistrbs	%v17,%v17	/* Fill with zeros after first zero.  */
147e83
+	jo	.Lslow_loop_acc /* No zero found -> no preparation needed.  */
147e83
+
147e83
+.Lslow_next_acc_prepare_zero:
147e83
+	/* Zero in reject-part: fill zeros with first-reject-character.  */
147e83
+	vlgvb	%r8,%v17,0	/* Load first element of reject-part.  */
147e83
+	clije	%r8,0,.Lslow_next_str /* Process next str-part if first
147e83
+					  character in this part of reject
147e83
+					  is a zero.  */
147e83
+	/* r8>0 -> zero found in this acc-part.  */
147e83
+	vrepb	%v18,%v17,0	/* Replicate first char accross all chars.  */
147e83
+	vceqb	%v22,%v20,%v17	/* Create a mask (v22) of null chars
147e83
+				   by comparing with 0 (v20).  */
147e83
+	vsel	%v17,%v18,%v17,%v22 /* Replace null chars with first char.  */
147e83
+	j	.Lslow_loop_acc /* Reject-string part is prepared.  */
147e83
+
147e83
+.Lslow_next_acc_onbb:
147e83
+	vfenezb	%v18,%v17,%v17	/* Find zero in loaded bytes of reject part.  */
147e83
+	vlgvb	%r8,%v18,7	/* Load byte index of zero.  */
147e83
+	clrjl	%r8,%r9,.Lslow_next_acc_notonbb /* Found a zero in loaded bytes
147e83
+						    -> Prepare vreg.  */
147e83
+	vl	%v17,0(%r5,%r3)	/* Load over boundary ...  */
147e83
+	lghi	%r8,0		/* r8=0 -> no zero in this part of acc,
147e83
+				   check for zero is in jump-target.  */
147e83
+	j	.Lslow_next_acc_notonbb /* ... and search for zero in
147e83
+					    fully loaded vreg again.  */
147e83
+
147e83
+.Lslow_end_not_found:
147e83
+	algfr	%r1,%r6		/* Add zero-index to current len.  */
147e83
+	j	.Lslow_end
147e83
+.Lslow_index_found:
147e83
+	algfr	%r1,%r4		/* Add found index of char to current len.  */
147e83
+.Lslow_end:
147e83
+	lgr	%r2,%r1
147e83
+	/* Restore registers.  */
147e83
+	vlgvg	%r6,%v30,0
147e83
+	vlgvg	%r8,%v31,0
147e83
+	vlgvg	%r9,%v31,1
147e83
+	br	%r14
147e83
+END(__strcspn_vx)
147e83
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
147e83
diff --git a/sysdeps/s390/multiarch/strcspn.c b/sysdeps/s390/multiarch/strcspn.c
147e83
new file mode 100644
147e83
index 0000000..32b46c4
147e83
--- /dev/null
147e83
+++ b/sysdeps/s390/multiarch/strcspn.c
147e83
@@ -0,0 +1,27 @@
147e83
+/* Multiple versions of strcspn.
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 <string.h>
147e83
+# include <ifunc-resolve.h>
147e83
+
147e83
+s390_vx_libc_ifunc2 (__strcspn, strcspn)
147e83
+
147e83
+#else
147e83
+# include <string/strcspn.c>
147e83
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
147e83
diff --git a/sysdeps/s390/multiarch/wcscspn-c.c b/sysdeps/s390/multiarch/wcscspn-c.c
147e83
new file mode 100644
147e83
index 0000000..95e76ae
147e83
--- /dev/null
147e83
+++ b/sysdeps/s390/multiarch/wcscspn-c.c
147e83
@@ -0,0 +1,26 @@
147e83
+/* Default wcscscpn 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 WCSCSPN  __wcscspn_c
147e83
+
147e83
+# include <wchar.h>
147e83
+extern __typeof (wcscspn) __wcscspn_c;
147e83
+
147e83
+# include <wcsmbs/wcscspn.c>
147e83
+#endif
147e83
diff --git a/sysdeps/s390/multiarch/wcscspn-vx.S b/sysdeps/s390/multiarch/wcscspn-vx.S
147e83
new file mode 100644
147e83
index 0000000..aa581ce
147e83
--- /dev/null
147e83
+++ b/sysdeps/s390/multiarch/wcscspn-vx.S
147e83
@@ -0,0 +1,293 @@
147e83
+/* Vector optimized 32/64 bit S/390 version of wcscspn.
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
+/* size_t wcscspn (const wchar_t *s, const wchar_t * reject)
147e83
+   The wcscspn() function calculates the length of the initial segment
147e83
+   of s which consists entirely of characters not in reject.
147e83
+
147e83
+   This method checks the length of reject string. If it fits entirely
147e83
+   in one vector register, a fast algorithm is used, which does not need
147e83
+   to check multiple parts of accept-string. Otherwise a slower full
147e83
+   check of accept-string is used.
147e83
+
147e83
+   register overview:
147e83
+   r3:  pointer to start of reject-string
147e83
+   r2:  pointer to start of search-string
147e83
+   r0:  loaded byte count of vlbb search-string
147e83
+   r4:  found byte index
147e83
+   r1:  current return len
147e83
+   v16: search-string
147e83
+   v17: reject-string
147e83
+   v18: temp-vreg
147e83
+
147e83
+   ONLY FOR SLOW:
147e83
+   v19: first reject-string
147e83
+   v20: zero for preparing acc-vector
147e83
+   v21: global mask; 1 indicates a match between
147e83
+	search-string-vreg and any reject-character
147e83
+   v22: current mask; 1 indicates a match between
147e83
+	search-string-vreg and any reject-character in current acc-vreg
147e83
+   v30, v31: for re-/storing registers r6, r8, r9
147e83
+   r5:  current len of reject-string
147e83
+   r6:  zero-index in search-string or 16 if no zero
147e83
+	or min(zero-index, loaded byte count)
147e83
+   r8:  >0, if former reject-string-part contains a zero,
147e83
+			otherwise =0;
147e83
+   r9:  loaded byte count of vlbb reject-string
147e83
+*/
147e83
+ENTRY(__wcscspn_vx)
147e83
+	.machine "z13"
147e83
+	.machinemode "zarch_nohighgprs"
147e83
+
147e83
+	tmll	%r2,3		/* Test if s is 4-byte aligned?  */
147e83
+	jne	.Lfallback	/* And use common-code variant if not.  */
147e83
+
147e83
+	/*
147e83
+	  Check if reject-string fits in one vreg:
147e83
+	  ----------------------------------------
147e83
+	*/
147e83
+	vlbb	%v17,0(%r3),0	/* Load reject.  */
147e83
+	lcbb	%r0,0(%r3),0
147e83
+	jo	.Lcheck_onbb	/* Special case if reject
147e83
+				   lays on block-boundary.  */
147e83
+
147e83
+.Lcheck_notonbb:
147e83
+	lghi	%r1,0		/* Zero out current len.  */
147e83
+	vistrfs	%v17,%v17	/* Fill with zeros after first zero.  */
147e83
+	je	.Lfast		/* Zero found -> reject fits in one vreg.  */
147e83
+	j	.Lslow		/* No zero -> reject exceeds one vreg.  */
147e83
+
147e83
+
147e83
+.Lcheck_onbb:
147e83
+	/* Reject lays on block-boundary.  */
147e83
+	nill	%r0,65532	/* Recognize only fully loaded characters.  */
147e83
+	je	.Lcheck_onbb2	/* Reload vr, if we loaded no full wchar_t.  */
147e83
+	vfenezf	%v18,%v17,%v17	/* Search zero in loaded reject bytes.  */
147e83
+	vlgvb	%r4,%v18,7	/* Get index of zero or 16 if not found.  */
147e83
+	clrjl	%r4,%r0,.Lcheck_notonbb /* Zero index < loaded bytes count ->
147e83
+					    Reject fits in one vreg;
147e83
+					    Fill with zeros and proceed
147e83
+					    with FAST.  */
147e83
+.Lcheck_onbb2:
147e83
+	vl	%v17,0(%r3)	/* Load reject, which exceeds loaded bytes.  */
147e83
+	j	.Lcheck_notonbb /* Check if reject fits in one vreg.  */
147e83
+
147e83
+
147e83
+	/*
147e83
+	  Search s for reject in one vreg
147e83
+	  -------------------------------
147e83
+	*/
147e83
+.Lfast:
147e83
+	/* Complete reject-string in v17 and remaining bytes are zero.  */
147e83
+
147e83
+	vlbb	%v16,0(%r2),6	/* Load s until next 4k-byte boundary.  */
147e83
+	lcbb	%r0,0(%r2),6	/* Get bytes to 4k-byte boundary or 16.  */
147e83
+
147e83
+	vfaezfs	%v18,%v16,%v17,0 /* Find first element in v16
147e83
+				    unequal to any in v17
147e83
+				    or first zero element.  */
147e83
+	vlgvb	%r4,%v18,7	/* Load byte index of found element.  */
147e83
+	clrjl	%r4,%r0,.Lfast_loop_found2 /* If found index is within loaded
147e83
+					       bytes, return with found element
147e83
+					       index (=equal count).  */
147e83
+
147e83
+	/* Align s to 16 byte.  */
147e83
+	risbgn	%r4,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15.  */
147e83
+	lghi	%r1,16		/* current_len = 16.  */
147e83
+	slr	%r1,%r4		/* Compute bytes to 16bytes boundary.  */
147e83
+
147e83
+	/* Process s in 16byte aligned loop.  */
147e83
+.Lfast_loop:
147e83
+	vl	%v16,0(%r1,%r2)	/* Load search-string.  */
147e83
+	vfaezfs	%v18,%v16,%v17,0 /* Find first element in v16 equal to any
147e83
+				    in v17 or first zero element.  */
147e83
+	jno	.Lfast_loop_found
147e83
+
147e83
+	vl	%v16,16(%r1,%r2)
147e83
+	vfaezfs	%v18,%v16,%v17,0
147e83
+	jno	.Lfast_loop_found16
147e83
+
147e83
+	vl	%v16,32(%r1,%r2)
147e83
+	vfaezfs	%v18,%v16,%v17,0
147e83
+	jno	.Lfast_loop_found32
147e83
+
147e83
+	vl	%v16,48(%r1,%r2)
147e83
+	vfaezfs	%v18,%v16,%v17,0
147e83
+	jno	.Lfast_loop_found48
147e83
+
147e83
+	aghi	%r1,64
147e83
+	j	.Lfast_loop	/* Loop if no element was unequal to reject
147e83
+				   and not zero.  */
147e83
+
147e83
+	/* Found equal or zero element.  */
147e83
+.Lfast_loop_found48:
147e83
+	aghi	%r1,16
147e83
+.Lfast_loop_found32:
147e83
+	aghi	%r1,16
147e83
+.Lfast_loop_found16:
147e83
+	aghi	%r1,16
147e83
+.Lfast_loop_found:
147e83
+	vlgvb	%r4,%v18,7	/* Load byte index of found element or zero.  */
147e83
+.Lfast_loop_found2:
147e83
+	algrk	%r2,%r1,%r4	/* Add found index to current len.  */
147e83
+	srlg	%r2,%r2,2	/* Convert byte-count to character-count.  */
147e83
+	br	%r14
147e83
+
147e83
+
147e83
+
147e83
+	/*
147e83
+	  Search s for reject in multiple vregs
147e83
+	  -------------------------------------
147e83
+	*/
147e83
+.Lslow:
147e83
+	/* Save registers.  */
147e83
+	vlvgg	%v30,%r6,0
147e83
+	vlvgp	%v31,%r8,%r9
147e83
+
147e83
+	/* Reject in v17 without zero.  */
147e83
+	vlr	%v19,%v17	/* Save first acc-part for a fast reload.  */
147e83
+	vzero	%v20		/* Zero for preparing acc-vector.  */
147e83
+	vone	%v24		/* One for checking result of former
147e83
+				   string-part.  */
147e83
+
147e83
+	/* Align s to 16 byte.  */
147e83
+	risbg	%r4,%r2,60,128+63,0 /* Test if s is aligned and
147e83
+				       %r4 = bits 60-63 'and' 15.   */
147e83
+	je	.Lslow_loop_str /* If s is aligned, loop aligned.  */
147e83
+	lghi	%r0,15
147e83
+	slr	%r0,%r4		/* Compute highest index to load (15-x).  */
147e83
+	vll	%v16,%r0,0(%r2) /* Load up to 16byte boundary (vll needs
147e83
+				   highest index, remaining bytes are 0).  */
147e83
+	ahi	%r0,1		/* Work with loaded byte count.  */
147e83
+	vzero	%v21		/* Zero out global mask.  */
147e83
+	lghi	%r5,0		/* Set current len of reject-string to zero.  */
147e83
+	vfenezf	%v18,%v16,%v16	/* Find zero in current string-part.  */
147e83
+	lghi	%r8,0		/* There is no zero in first reject-part.  */
147e83
+	vlgvb	%r6,%v18,7	/* Load byte index of zero or 16 if no zero.  */
147e83
+	clije	%r6,0,.Lslow_end /* If first element is zero -> return 0.  */
147e83
+	clr	%r0,%r6		/* cc==1 if loaded byte count < zero-index.  */
147e83
+	locrl	%r6,%r0		/* Load on cc==1; zero-index = lbc.  */
147e83
+	j	.Lslow_loop_acc
147e83
+
147e83
+
147e83
+	/* Process s in 16byte aligned loop.  */
147e83
+.Lslow_next_str:
147e83
+	/* Check results of former processed str-part.  */
147e83
+	vfeef	%v18,%v21,%v24	/* Find first equal match in global mask
147e83
+				   (ones in element).  */
147e83
+	vlgvb	%r4,%v18,7	/* Get index of first one (=equal) or 16.  */
147e83
+	/* Equal-index < min(zero-index, loaded byte count)
147e83
+	   -> Return pointer to equal element.  */
147e83
+	clrjl	%r4,%r6,.Lslow_index_found
147e83
+	/* Zero-index < loaded byte count
147e83
+	   -> Former str-part was last str-part
147e83
+	   -> Return null  */
147e83
+	clrjl	%r6,%r0,.Lslow_end_not_found
147e83
+
147e83
+	/* All elements are zero (=no match) -> proceed with next str-part.  */
147e83
+	vlr	%v17,%v19	/* Load first part of reject (no zero).  */
147e83
+	algfr	%r1,%r0		/* Add loaded byte count to current len.  */
147e83
+
147e83
+.Lslow_loop_str:
147e83
+	vl	%v16,0(%r1,%r2)	/* Load search-string.  */
147e83
+	lghi	%r0,16		/* Loaded byte count is 16.  */
147e83
+	vzero	%v21		/* Zero out global mask.  */
147e83
+	lghi	%r5,0		/* Set current len of reject to zero.  */
147e83
+	vfenezf	%v18,%v16,%v16	/* Find zero in current string-part.  */
147e83
+	lghi	%r8,0		/* There is no zero in first reject-part.  */
147e83
+	vlgvb	%r6,%v18,7	/* Load byte index of zero or 16 if no zero.  */
147e83
+	clije	%r6,0,.Lslow_end /* If first element is zero (end of string)
147e83
+				     -> Return current length.  */
147e83
+
147e83
+.Lslow_loop_acc:
147e83
+	vfaef	%v22,%v16,%v17,4 /* Create matching-mask (1 in mask ->
147e83
+				    Character matches any rejected character in
147e83
+				    this reject-string-part) IN=0, RT=1.  */
147e83
+	vlgvf	%r4,%v22,0	/* Get result of first element.  */
147e83
+	/* First element is equal to any rejected characters?
147e83
+	   (All other parts of reject cannot lead to a match before this one)
147e83
+	   -> Return current len, which is pointing to this element.  */
147e83
+	clijh	%r4,0,.Lslow_end
147e83
+	vo	%v21,%v21,%v22	/* Global-mask = global-|matching-mask.  */
147e83
+	/* Proceed with next acc until end of acc is reached.  */
147e83
+
147e83
+
147e83
+.Lslow_next_acc:
147e83
+	clijh	%r8,0,.Lslow_next_str /* There was a zero in last reject-part
147e83
+					  -> Add found index to current len
147e83
+					     and end.  */
147e83
+	vlbb	%v17,16(%r5,%r3),6 /* Load next reject part.  */
147e83
+	aghi	%r5,16		/* Increment current len of reject-string.  */
147e83
+	lcbb	%r9,0(%r5,%r3),6 /* Get loaded byte count of reject-string.  */
147e83
+	jo	.Lslow_next_acc_onbb /* Jump away if reject-string is
147e83
+					 on block-boundary.  */
147e83
+.Lslow_next_acc_notonbb:
147e83
+	vistrfs	%v17,%v17	/* Fill with zeros after first zero.  */
147e83
+	jo	.Lslow_loop_acc /* No zero found -> no preparation needed.  */
147e83
+
147e83
+.Lslow_next_acc_prepare_zero:
147e83
+	/* Zero in reject-part: fill zeros with first-reject-character.  */
147e83
+	vlgvf	%r8,%v17,0	/* Load first element of reject-part.  */
147e83
+	clije	%r8,0,.Lslow_next_str /* Process next str-part if first
147e83
+					  character in this part of reject
147e83
+					  is a zero.  */
147e83
+	/* r8>0 -> zero found in this acc-part.  */
147e83
+	vrepf	%v18,%v17,0	/* Replicate first char accross all chars.  */
147e83
+	vceqf	%v22,%v20,%v17	/* Create a mask (v22) of null chars
147e83
+				   by comparing with 0 (v20).  */
147e83
+	vsel	%v17,%v18,%v17,%v22 /* Replace null chars with first char.  */
147e83
+	j	.Lslow_loop_acc /* Reject-string part is prepared.  */
147e83
+
147e83
+.Lslow_next_acc_onbb:
147e83
+	nill	%r9,65532	/* Recognize only fully loaded characters.  */
147e83
+	je	.Lslow_next_acc_onbb2 /* Reload vr, if no full wchar_t
147e83
+					  loaded.  */
147e83
+	vfenezf	%v18,%v17,%v17	/* Find zero in loaded bytes of reject part.  */
147e83
+	vlgvb	%r8,%v18,7	/* Load byte index of zero.  */
147e83
+	clrjl	%r8,%r9,.Lslow_next_acc_notonbb /* Found a zero in loaded bytes
147e83
+						    -> Prepare vreg.  */
147e83
+.Lslow_next_acc_onbb2:
147e83
+	vl	%v17,0(%r5,%r3)	/* Load over boundary ...  */
147e83
+	lghi	%r8,0		/* r8=0 -> no zero in this part of acc,
147e83
+				   check for zero is in jump-target.  */
147e83
+	j	.Lslow_next_acc_notonbb /* ... and search for zero in
147e83
+					    fully loaded vreg again.  */
147e83
+
147e83
+.Lslow_end_not_found:
147e83
+	algfr	%r1,%r6		/* Add zero-index to current len.  */
147e83
+	j	.Lslow_end
147e83
+.Lslow_index_found:
147e83
+	algfr	%r1,%r4		/* Add found index of char to current len.  */
147e83
+.Lslow_end:
147e83
+	srlg	%r2,%r1,2	/* Convert byte-count to character-count.  */
147e83
+	/* Restore registers.  */
147e83
+	vlgvg	%r6,%v30,0
147e83
+	vlgvg	%r8,%v31,0
147e83
+	vlgvg	%r9,%v31,1
147e83
+	br	%r14
147e83
+.Lfallback:
147e83
+	jg	__wcscspn_c
147e83
+END(__wcscspn_vx)
147e83
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
147e83
diff --git a/sysdeps/s390/multiarch/wcscspn.c b/sysdeps/s390/multiarch/wcscspn.c
147e83
new file mode 100644
147e83
index 0000000..3cb4516
147e83
--- /dev/null
147e83
+++ b/sysdeps/s390/multiarch/wcscspn.c
147e83
@@ -0,0 +1,27 @@
147e83
+/* Multiple versions of wcscspn.
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 (__wcscspn, wcscspn)
147e83
+
147e83
+#else
147e83
+# include <wcsmbs/wcscspn.c>
147e83
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
147e83
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
147e83
index 7ecff8b..9730b00 100644
147e83
--- a/wcsmbs/Makefile
147e83
+++ b/wcsmbs/Makefile
147e83
@@ -42,7 +42,8 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
147e83
 	    mbrtoc16 c16rtomb
147e83
 
147e83
 strop-tests :=  wcscmp wcsncmp wmemcmp wcslen wcschr wcsrchr wcscpy wcsnlen \
147e83
-		wcpcpy wcsncpy wcpncpy wcscat wcsncat wcschrnul wcsspn wcspbrk
147e83
+		wcpcpy wcsncpy wcpncpy wcscat wcsncat wcschrnul wcsspn wcspbrk \
147e83
+		wcscspn
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-wcscspn-ifunc.c b/wcsmbs/test-wcscspn-ifunc.c
147e83
new file mode 100644
147e83
index 0000000..e5dcdaf
147e83
--- /dev/null
147e83
+++ b/wcsmbs/test-wcscspn-ifunc.c
147e83
@@ -0,0 +1,20 @@
147e83
+/* Test and measure IFUNC implementations of wcscspn 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-wcscspn.c"
147e83
diff --git a/wcsmbs/test-wcscspn.c b/wcsmbs/test-wcscspn.c
147e83
new file mode 100644
147e83
index 0000000..d09cd3d
147e83
--- /dev/null
147e83
+++ b/wcsmbs/test-wcscspn.c
147e83
@@ -0,0 +1,20 @@
147e83
+/* Test wcscspn 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-strcspn.c"
147e83
diff --git a/wcsmbs/wcscspn.c b/wcsmbs/wcscspn.c
147e83
index 5d38d07..9e84226 100644
147e83
--- a/wcsmbs/wcscspn.c
147e83
+++ b/wcsmbs/wcscspn.c
147e83
@@ -18,6 +18,9 @@
147e83
 
147e83
 #include <wchar.h>
147e83
 
147e83
+#ifdef WCSCSPN
147e83
+# define wcscspn WCSCSPN
147e83
+#endif
147e83
 
147e83
 /* Return the length of the maximum initial segment
147e83
    of WCS which contains only wide-characters not in REJECT.  */
147e83
-- 
147e83
2.3.0
147e83