You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1236 lines
42 KiB

From 67611d45bb5e464f2e80782ec37ce3548459cf57 Mon Sep 17 00:00:00 2001
From: Stefan Liebler <stli@linux.vnet.ibm.com>
Date: Thu, 8 Oct 2015 12:56:03 +0200
Subject: [PATCH 23/30] S390: Optimize strspn and wcsspn.
upstream-commit-id: f1ffad98be7ec4111fbd1cd1f58f3e3343257519
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00095.html
This patch provides optimized versions of strspn and wcsspn with the z13
vector instructions.
ChangeLog:
* sysdeps/s390/multiarch/strspn-c.c: New File.
* sysdeps/s390/multiarch/strspn-vx.S: Likewise.
* sysdeps/s390/multiarch/strspn.c: Likewise.
* sysdeps/s390/multiarch/wcsspn-c.c: Likewise.
* sysdeps/s390/multiarch/wcsspn-vx.S: Likewise.
* sysdeps/s390/multiarch/wcsspn.c: Likewise.
* wcsmbs/wcsspn.c: Use WCSSPN if defined.
* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add strspn and
wcsspn functions.
* sysdeps/s390/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Add ifunc test for strspn, wcsspn.
* string/test-strspn.c: Add wcsspn support.
* wcsmbs/test-wcsspn.c: New File.
* wcsmbs/Makefile (strop-tests): Add wcsspn.
* benchtests/bench-strspn.c: Add wcsspn support.
* benchtests/bench-wcsspn.c: New File.
* benchtests/Makefile (wcsmbs-bench): Add wcsspn.
---
benchtests/Makefile | 2 +-
benchtests/bench-strspn.c | 71 +++++---
benchtests/bench-wcsspn.c | 20 +++
string/strspn.c | 7 +-
string/test-strspn.c | 100 +++++++-----
sysdeps/s390/multiarch/Makefile | 6 +-
sysdeps/s390/multiarch/ifunc-impl-list.c | 3 +
sysdeps/s390/multiarch/strspn-c.c | 28 ++++
sysdeps/s390/multiarch/strspn-vx.S | 256 +++++++++++++++++++++++++++++
sysdeps/s390/multiarch/strspn.c | 27 ++++
sysdeps/s390/multiarch/wcsspn-c.c | 31 ++++
sysdeps/s390/multiarch/wcsspn-vx.S | 270 +++++++++++++++++++++++++++++++
sysdeps/s390/multiarch/wcsspn.c | 27 ++++
wcsmbs/Makefile | 2 +-
wcsmbs/test-wcsspn-ifunc.c | 20 +++
wcsmbs/test-wcsspn.c | 20 +++
wcsmbs/wcsspn.c | 3 +
17 files changed, 827 insertions(+), 66 deletions(-)
create mode 100644 benchtests/bench-wcsspn.c
create mode 100644 sysdeps/s390/multiarch/strspn-c.c
create mode 100644 sysdeps/s390/multiarch/strspn-vx.S
create mode 100644 sysdeps/s390/multiarch/strspn.c
create mode 100644 sysdeps/s390/multiarch/wcsspn-c.c
create mode 100644 sysdeps/s390/multiarch/wcsspn-vx.S
create mode 100644 sysdeps/s390/multiarch/wcsspn.c
create mode 100644 wcsmbs/test-wcsspn-ifunc.c
create mode 100644 wcsmbs/test-wcsspn.c
diff --git a/benchtests/Makefile b/benchtests/Makefile
index 6444394..337b2a1 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -39,7 +39,7 @@ string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
strspn strstr strcpy_chk stpcpy_chk memrchr strsep strtok
wcsmbs-bench := wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat \
- wcsncmp wcsncmp wcschr wcschrnul wcsrchr
+ wcsncmp wcsncmp wcschr wcschrnul wcsrchr wcsspn
string-bench-all := $(string-bench) ${wcsmbs-bench}
stdlib-bench := strtod
diff --git a/benchtests/bench-strspn.c b/benchtests/bench-strspn.c
index 634bca1..e1f2272 100644
--- a/benchtests/bench-strspn.c
+++ b/benchtests/bench-strspn.c
@@ -17,22 +17,47 @@
<http://www.gnu.org/licenses/>. */
#define TEST_MAIN
-#define TEST_NAME "strspn"
+#ifndef WIDE
+# define TEST_NAME "strspn"
+#else
+# define TEST_NAME "wcsspn"
+#endif /* WIDE */
#include "bench-string.h"
-typedef size_t (*proto_t) (const char *, const char *);
-size_t simple_strspn (const char *, const char *);
-size_t stupid_strspn (const char *, const char *);
-
-IMPL (stupid_strspn, 0)
-IMPL (simple_strspn, 0)
-IMPL (strspn, 1)
+#ifndef WIDE
+# define STRSPN strspn
+# define CHAR char
+# define SIMPLE_STRSPN simple_strspn
+# define STUPID_STRSPN stupid_strspn
+# define STRLEN strlen
+# define STRCHR strchr
+# define BIG_CHAR CHAR_MAX
+# define SMALL_CHAR 127
+#else
+# include <wchar.h>
+# define STRSPN wcsspn
+# define CHAR wchar_t
+# define SIMPLE_STRSPN simple_wcsspn
+# define STUPID_STRSPN stupid_wcsspn
+# define STRLEN wcslen
+# define STRCHR wcschr
+# define BIG_CHAR WCHAR_MAX
+# define SMALL_CHAR 1273
+#endif /* WIDE */
+
+typedef size_t (*proto_t) (const CHAR *, const CHAR *);
+size_t SIMPLE_STRSPN (const CHAR *, const CHAR *);
+size_t STUPID_STRSPN (const CHAR *, const CHAR *);
+
+IMPL (STUPID_STRSPN, 0)
+IMPL (SIMPLE_STRSPN, 0)
+IMPL (STRSPN, 1)
size_t
-simple_strspn (const char *s, const char *acc)
+SIMPLE_STRSPN (const CHAR *s, const CHAR *acc)
{
- const char *r, *str = s;
- char c;
+ const CHAR *r, *str = s;
+ CHAR c;
while ((c = *s++) != '\0')
{
@@ -46,9 +71,9 @@ simple_strspn (const char *s, const char *acc)
}
size_t
-stupid_strspn (const char *s, const char *acc)
+STUPID_STRSPN (const CHAR *s, const CHAR *acc)
{
- size_t ns = strlen (s), nacc = strlen (acc);
+ size_t ns = STRLEN (s), nacc = STRLEN (acc);
size_t i, j;
for (i = 0; i < ns; ++i)
@@ -63,7 +88,7 @@ stupid_strspn (const char *s, const char *acc)
}
static void
-do_one_test (impl_t *impl, const char *s, const char *acc, size_t exp_res)
+do_one_test (impl_t *impl, const CHAR *s, const CHAR *acc, size_t exp_res)
{
size_t res = CALL (impl, s, acc), i, iters = INNER_LOOP_ITERS;
timing_t start, stop, cur;
@@ -92,34 +117,34 @@ static void
do_test (size_t align, size_t pos, size_t len)
{
size_t i;
- char *acc, *s;
+ CHAR *acc, *s;
align &= 7;
- if (align + pos + 10 >= page_size || len > 240 || ! len)
+ if ((align + pos + 10) * sizeof (CHAR) >= page_size || len > 240 || ! len)
return;
- acc = (char *) (buf2 + (random () & 255));
- s = (char *) (buf1 + align);
+ acc = (CHAR *) (buf2) + (random () & BIG_CHAR);
+ s = (CHAR *) (buf1) + align;
for (i = 0; i < len; ++i)
{
- acc[i] = random () & 255;
+ acc[i] = random () & BIG_CHAR;
if (!acc[i])
- acc[i] = random () & 255;
+ acc[i] = random () & BIG_CHAR;
if (!acc[i])
- acc[i] = 1 + (random () & 127);
+ acc[i] = 1 + (random () & SMALL_CHAR);
}
acc[len] = '\0';
for (i = 0; i < pos; ++i)
s[i] = acc[random () % len];
- s[pos] = random () & 255;
+ s[pos] = random () & BIG_CHAR;
if (strchr (acc, s[pos]))
s[pos] = '\0';
else
{
for (i = pos + 1; i < pos + 10; ++i)
- s[i] = random () & 255;
+ s[i] = random () & BIG_CHAR;
s[i] = '\0';
}
diff --git a/benchtests/bench-wcsspn.c b/benchtests/bench-wcsspn.c
new file mode 100644
index 0000000..7bdef50
--- /dev/null
+++ b/benchtests/bench-wcsspn.c
@@ -0,0 +1,20 @@
+/* Measure wcsspn functions.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define WIDE 1
+#include "bench-strspn.c"
diff --git a/string/strspn.c b/string/strspn.c
index 48624aa..f0ac9db 100644
--- a/string/strspn.c
+++ b/string/strspn.c
@@ -18,13 +18,14 @@
#include <string.h>
#undef strspn
+#ifndef STRSPN
+#define STRSPN strspn
+#endif
/* Return the length of the maximum initial segment
of S which contains only characters in ACCEPT. */
size_t
-strspn (s, accept)
- const char *s;
- const char *accept;
+STRSPN (const char *s, const char *accept)
{
const char *p;
const char *a;
diff --git a/string/test-strspn.c b/string/test-strspn.c
index 0d6cd19..306958e 100644
--- a/string/test-strspn.c
+++ b/string/test-strspn.c
@@ -18,22 +18,49 @@
<http://www.gnu.org/licenses/>. */
#define TEST_MAIN
-#define TEST_NAME "strspn"
+#ifndef WIDE
+# define TEST_NAME "strspn"
+#else
+# define TEST_NAME "wcsspn"
+#endif /* WIDE */
#include "test-string.h"
-typedef size_t (*proto_t) (const char *, const char *);
-size_t simple_strspn (const char *, const char *);
-size_t stupid_strspn (const char *, const char *);
-
-IMPL (stupid_strspn, 0)
-IMPL (simple_strspn, 0)
-IMPL (strspn, 1)
+#ifndef WIDE
+# define STRSPN strspn
+# define CHAR char
+# define UCHAR unsigned char
+# define SIMPLE_STRSPN simple_strspn
+# define STUPID_STRSPN stupid_strspn
+# define STRLEN strlen
+# define STRCHR strchr
+# define BIG_CHAR CHAR_MAX
+# define SMALL_CHAR 127
+#else
+# include <wchar.h>
+# define STRSPN wcsspn
+# define CHAR wchar_t
+# define UCHAR wchar_t
+# define SIMPLE_STRSPN simple_wcsspn
+# define STUPID_STRSPN stupid_wcsspn
+# define STRLEN wcslen
+# define STRCHR wcschr
+# define BIG_CHAR WCHAR_MAX
+# define SMALL_CHAR 1273
+#endif /* WIDE */
+
+typedef size_t (*proto_t) (const CHAR *, const CHAR *);
+size_t SIMPLE_STRSPN (const CHAR *, const CHAR *);
+size_t STUPID_STRSPN (const CHAR *, const CHAR *);
+
+IMPL (STUPID_STRSPN, 0)
+IMPL (SIMPLE_STRSPN, 0)
+IMPL (STRSPN, 1)
size_t
-simple_strspn (const char *s, const char *acc)
+SIMPLE_STRSPN (const CHAR *s, const CHAR *acc)
{
- const char *r, *str = s;
- char c;
+ const CHAR *r, *str = s;
+ CHAR c;
while ((c = *s++) != '\0')
{
@@ -47,9 +74,9 @@ simple_strspn (const char *s, const char *acc)
}
size_t
-stupid_strspn (const char *s, const char *acc)
+STUPID_STRSPN (const CHAR *s, const CHAR *acc)
{
- size_t ns = strlen (s), nacc = strlen (acc);
+ size_t ns = STRLEN (s), nacc = STRLEN (acc);
size_t i, j;
for (i = 0; i < ns; ++i)
@@ -64,7 +91,7 @@ stupid_strspn (const char *s, const char *acc)
}
static void
-do_one_test (impl_t *impl, const char *s, const char *acc, size_t exp_res)
+do_one_test (impl_t *impl, const CHAR *s, const CHAR *acc, size_t exp_res)
{
size_t res = CALL (impl, s, acc);
if (res != exp_res)
@@ -80,34 +107,34 @@ static void
do_test (size_t align, size_t pos, size_t len)
{
size_t i;
- char *acc, *s;
+ CHAR *acc, *s;
align &= 7;
- if (align + pos + 10 >= page_size || len > 240 || ! len)
+ if ((align + pos + 10) * sizeof (CHAR) >= page_size || len > 240 || ! len)
return;
- acc = (char *) (buf2 + (random () & 255));
- s = (char *) (buf1 + align);
+ acc = (CHAR *) (buf2) + (random () & 255);
+ s = (CHAR *) (buf1) + align;
for (i = 0; i < len; ++i)
{
- acc[i] = random () & 255;
+ acc[i] = random () & BIG_CHAR;
if (!acc[i])
- acc[i] = random () & 255;
+ acc[i] = random () & BIG_CHAR;
if (!acc[i])
- acc[i] = 1 + (random () & 127);
+ acc[i] = 1 + (random () & SMALL_CHAR);
}
acc[len] = '\0';
for (i = 0; i < pos; ++i)
s[i] = acc[random () % len];
- s[pos] = random () & 255;
- if (strchr (acc, s[pos]))
+ s[pos] = random () & BIG_CHAR;
+ if (STRCHR (acc, s[pos]))
s[pos] = '\0';
else
{
for (i = pos + 1; i < pos + 10; ++i)
- s[i] = random () & 255;
+ s[i] = random () & BIG_CHAR;
s[i] = '\0';
}
@@ -119,8 +146,8 @@ static void
do_random_tests (void)
{
size_t i, j, n, align, pos, alen, len;
- unsigned char *p = buf1 + page_size - 512;
- unsigned char *acc;
+ UCHAR *p = (UCHAR *) (buf1 + page_size) - 512;
+ UCHAR *acc;
for (n = 0; n < ITERATIONS; n++)
{
@@ -138,14 +165,14 @@ do_random_tests (void)
len = random () & 511;
if (len + align >= 512)
len = 511 - align - (random () & 7);
- acc = buf2 + page_size - alen - 1 - (random () & 7);
+ acc = (UCHAR *) (buf2 + page_size) - alen - 1 - (random () & 7);
for (i = 0; i < alen; ++i)
{
- acc[i] = random () & 255;
+ acc[i] = random () & BIG_CHAR;
if (!acc[i])
- acc[i] = random () & 255;
+ acc[i] = random () & BIG_CHAR;
if (!acc[i])
- acc[i] = 1 + (random () & 127);
+ acc[i] = 1 + (random () & SMALL_CHAR);
}
acc[i] = '\0';
j = (pos > len ? pos : len) + align + 64;
@@ -158,26 +185,27 @@ do_random_tests (void)
p[i] = '\0';
else if (i == pos + align)
{
- p[i] = random () & 255;
- if (strchr ((char *) acc, p[i]))
+ p[i] = random () & BIG_CHAR;
+ if (STRCHR ((CHAR *) acc, p[i]))
p[i] = '\0';
}
else if (i < align || i > pos + align)
- p[i] = random () & 255;
+ p[i] = random () & BIG_CHAR;
else
p[i] = acc [random () % alen];
}
FOR_EACH_IMPL (impl, 1)
- if (CALL (impl, (char *) (p + align),
- (char *) acc) != (pos < len ? pos : len))
+ if (CALL (impl, (CHAR *) (p + align),
+ (CHAR *) acc) != (pos < len ? pos : len))
{
error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %p, %zd, %zd, %zd) %zd != %zd",
n, impl->name, align, acc, alen, pos, len,
- CALL (impl, (char *) (p + align), (char *) acc),
+ CALL (impl, (CHAR *) (p + align), (CHAR *) acc),
(pos < len ? pos : len));
ret = 1;
}
+
}
}
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
index b8b141e..9403169 100644
--- a/sysdeps/s390/multiarch/Makefile
+++ b/sysdeps/s390/multiarch/Makefile
@@ -11,7 +11,8 @@ sysdep_routines += strlen strlen-vx strlen-c \
strncmp strncmp-vx strncmp-c \
strchr strchr-vx strchr-c \
strchrnul strchrnul-vx strchrnul-c \
- strrchr strrchr-vx strrchr-c
+ strrchr strrchr-vx strrchr-c \
+ strspn strspn-vx strspn-c
endif
ifeq ($(subdir),wcsmbs)
@@ -27,5 +28,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \
wcsncmp wcsncmp-vx wcsncmp-c \
wcschr wcschr-vx wcschr-c \
wcschrnul wcschrnul-vx wcschrnul-c \
- wcsrchr wcsrchr-vx wcsrchr-c
+ wcsrchr wcsrchr-vx wcsrchr-c \
+ wcsspn wcsspn-vx wcsspn-c
endif
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
index ee84d80..cbedf64 100644
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
@@ -118,6 +118,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
IFUNC_VX_IMPL (strrchr);
IFUNC_VX_IMPL (wcsrchr);
+ IFUNC_VX_IMPL (strspn);
+ IFUNC_VX_IMPL (wcsspn);
+
#endif /* HAVE_S390_VX_ASM_SUPPORT */
return i;
diff --git a/sysdeps/s390/multiarch/strspn-c.c b/sysdeps/s390/multiarch/strspn-c.c
new file mode 100644
index 0000000..8a7d342
--- /dev/null
+++ b/sysdeps/s390/multiarch/strspn-c.c
@@ -0,0 +1,28 @@
+/* Default strspn implementation for S/390.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
+# define STRSPN __strspn_c
+# ifdef SHARED
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name) \
+ __hidden_ver1 (__strspn_c, __GI_strspn, __strspn_c);
+# endif /* SHARED */
+
+# include <string/strspn.c>
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
diff --git a/sysdeps/s390/multiarch/strspn-vx.S b/sysdeps/s390/multiarch/strspn-vx.S
new file mode 100644
index 0000000..df22347
--- /dev/null
+++ b/sysdeps/s390/multiarch/strspn-vx.S
@@ -0,0 +1,256 @@
+/* Vector optimized 32/64 bit S/390 version of strspn.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
+
+# include "sysdep.h"
+# include "asm-syntax.h"
+
+ .text
+
+/* size_t strspn (const char *s, const char * accept)
+ The strspn() function calculates the length of the initial segment
+ of s which consists entirely of characters in accept.
+
+ This method checks the length of accept string. If it fits entirely
+ in one vector register, a fast algorithm is used, which does not need
+ to check multiple parts of accept-string. Otherwise a slower full
+ check of accept-string is used.
+
+ register overview:
+ r3: pointer to start of accept-string
+ r2: pointer to start of search-string
+ r4: loaded byte count of vl search-string
+ r0: found byte index
+ r1: current return len of s
+ v16: search-string
+ v17: accept-string
+ v18: temp-vreg
+
+ ONLY FOR SLOW:
+ v19: first accept-string
+ v20: zero for preparing acc-vector
+ v21: global mask; 1 indicates a match between
+ search-string-vreg and any accept-character
+ v22: current mask; 1 indicates a match between
+ search-string-vreg and any accept-character in current acc-vreg
+ v30, v31: for re-/storing registers r6, r8, r9
+ r5: current len of accept-string
+ r6: zero-index in search-string or 16 if no zero
+ or min(zero-index, loaded byte count)
+ r8: >0, if former accept-string-part contains a zero,
+ otherwise =0;
+ r9: loaded byte count of vlbb accept-string
+*/
+ENTRY(__strspn_vx)
+ .machine "z13"
+ .machinemode "zarch_nohighgprs"
+
+ /*
+ Check if accept-string fits in one vreg:
+ ----------------------------------------
+ */
+ vlbb %v17,0(%r3),6 /* Load accept. */
+ lcbb %r4,0(%r3),6
+ jo .Lcheck_onbb /* Special case if accept lays
+ on block-boundary. */
+.Lcheck_notonbb:
+ vistrbs %v17,%v17 /* Fill with zeros after first zero. */
+ je .Lfast /* Zero found -> accept fits in one vreg. */
+ j .Lslow /* No zero -> accept exceeds one vreg. */
+
+.Lcheck_onbb:
+ /* Accept lays on block-boundary. */
+ vfenezb %v18,%v17,%v17 /* Search zero in loaded accept bytes. */
+ vlgvb %r0,%v18,7 /* Get index of zero or 16 if not found. */
+ clrjl %r0,%r4,.Lcheck_notonbb /* Zero index < loaded bytes count ->
+ Accept fits in one vreg;
+ Fill with zeros and proceed
+ with FAST. */
+ vl %v17,0(%r3) /* Load accept, which exceeds loaded bytes. */
+ j .Lcheck_notonbb /* Check if accept fits in one vreg. */
+
+
+ /*
+ Search s for accept in one vreg
+ -------------------------------
+ */
+.Lfast:
+ /* Complete accept-string is in v17 and remaining bytes are zero. */
+
+ vlbb %v16,0(%r2),6 /* Load s until next 4k-byte boundary. */
+ lcbb %r1,0(%r2),6 /* Get bytes to 4k-byte boundary or 16. */
+
+ vfaezbs %v16,%v16,%v17,8 /* Find first element in v16
+ unequal to any in v17
+ or first zero element. */
+ vlgvb %r0,%v16,7 /* Load byte index of found element. */
+ /* If found index is within loaded bytes (%r0 < %r1),
+ return with found element index (=equal count). */
+ clr %r0,%r1
+ locgrl %r2,%r0
+ blr %r14
+
+ /* Align s to 16 byte. */
+ risbgn %r4,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
+ lghi %r1,16 /* current_len = 16. */
+ slr %r1,%r4 /* Compute bytes to 16bytes boundary. */
+
+.Lfast_loop:
+ vl %v16,0(%r1,%r2) /* Load search-string. */
+ vfaezbs %v16,%v16,%v17,8 /* Find first element in v16
+ unequal to any in v17
+ or first zero element. */
+ jno .Lfast_loop_found
+ vl %v16,16(%r1,%r2)
+ vfaezbs %v16,%v16,%v17,8
+ jno .Lfast_loop_found16
+ vl %v16,32(%r1,%r2)
+ vfaezbs %v16,%v16,%v17,8
+ jno .Lfast_loop_found32
+ vl %v16,48(%r1,%r2)
+ vfaezbs %v16,%v16,%v17,8
+ jno .Lfast_loop_found48
+
+ aghi %r1,64
+ j .Lfast_loop /* Loop if no element was unequal to accept
+ and not zero. */
+
+ /* Found unequal or zero element. */
+.Lfast_loop_found48:
+ aghi %r1,16
+.Lfast_loop_found32:
+ aghi %r1,16
+.Lfast_loop_found16:
+ aghi %r1,16
+.Lfast_loop_found:
+ vlgvb %r0,%v16,7 /* Load byte index of found element. */
+ algrk %r2,%r1,%r0 /* And add it to current len. */
+ br %r14
+
+
+ /*
+ Search s for accept in multiple vregs
+ -------------------------------------
+ */
+.Lslow:
+ /* Save registers. */
+ vlvgg %v30,%r6,0
+ vlvgp %v31,%r8,%r9
+ lghi %r1,0 /* current_len = 0. */
+
+ /* Accept in v17 without zero. */
+ vlr %v19,%v17 /* Save first acc-part for a fast reload. */
+ vzero %v20 /* Zero for preparing acc-vector. */
+
+ /* Align s to 16 byte. */
+ risbg %r0,%r2,60,128+63,0 /* Test if s is aligned and
+ %r0 = bits 60-63 'and' 15 */
+ je .Lslow_loop_str /* If s is aligned, loop aligned */
+ lghi %r4,15
+ slr %r4,%r0 /* Compute highest index to load (15-x). */
+ vll %v16,%r4,0(%r2) /* Load up to 16byte boundary (vll needs
+ highest index, left bytes are 0). */
+ ahi %r4,1 /* Work with loaded byte count. */
+ vzero %v21 /* Zero out global mask. */
+ lghi %r5,0 /* Set current len of accept-string to zero. */
+ vfenezb %v18,%v16,%v16 /* Find zero in current string-part. */
+ lghi %r8,0 /* There is no zero in first accept-part. */
+ vlgvb %r6,%v18,7 /* Load byte index of zero or 16
+ if there is no zero. */
+ clr %r4,%r6 /* cc==1 if loaded byte count < zero-index. */
+ locrl %r6,%r4 /* Load on cc==1. */
+ j .Lslow_loop_acc
+
+ /* Process s in 16byte aligned loop. */
+.Lslow_next_str:
+ vlr %v17,%v19 /* Load first part of accept (no zero). */
+ algfr %r1,%r4 /* Add loaded byte count to current len. */
+.Lslow_loop_str:
+ vl %v16,0(%r1,%r2) /* Load search-string. */
+ lghi %r4,16 /* Loaded byte count is 16. */
+ vzero %v21 /* Zero out global mask. */
+ lghi %r5,0 /* Set current len of accept-string to zero. */
+ vfenezb %v18,%v16,%v16 /* Find zero in current string-part. */
+ lghi %r8,0 /* There is no zero in first accept-part. */
+ vlgvb %r6,%v18,7 /* Load byte index of zero or 16 if no zero. */
+
+.Lslow_loop_acc:
+ vfaeb %v22,%v16,%v17,4 /* Create matching-mask (1 in mask ->
+ character matches any accepted character in
+ this accept-string-part) IN=0, RT=1. */
+ vo %v21,%v21,%v22 /* global-mask = global- | matching-mask. */
+ vfenezb %v18,%v21,%v21 /* Find first zero in global-mask. */
+ vlgvb %r0,%v18,7 /* Get first found zero-index
+ (= first mismatch). */
+ clrjl %r0,%r6,.Lslow_next_acc /* Mismatch-index < min(lbc,zero-index)
+ -> Process this string-part
+ with next acc-part. */
+ clrjhe %r0,%r4,.Lslow_next_str /* Found-index >= loaded byte count
+ -> All loaded bytes are matching
+ any accept-character
+ and are not zero. */
+ /* All bytes are matching any characters in accept-string
+ and search-string is fully processed (found-index == zero-index) */
+.Lslow_add_lbc_end:
+ algrk %r2,%r1,%r0 /* Add matching characters to current_len. */
+ /* Restore registers. */
+ vlgvg %r6,%v30,0
+ vlgvg %r8,%v31,0
+ vlgvg %r9,%v31,1
+ br %r14
+
+
+
+.Lslow_next_acc:
+ clijh %r8,0,.Lslow_add_lbc_end /* There was a zero in last acc-part
+ -> Add found index to current len
+ and end. */
+ vlbb %v17,16(%r5,%r3),6 /* Load next accept part. */
+ aghi %r5,16 /* Add current_len of accept-string. */
+ lcbb %r9,0(%r5,%r3),6 /* Get loaded byte count of accept-string. */
+ jo .Lslow_next_acc_onbb /* Jump away if accept-string is
+ on block-boundary. */
+.Lslow_next_acc_notonbb:
+ vistrbs %v17,%v17 /* Fill with zeros after first zero. */
+ jo .Lslow_loop_acc /* No zero found -> no preparation needed. */
+
+.Lslow_next_acc_prepare_zero:
+ /* Zero in accept-part: fill zeros with first-accept-character. */
+ vlgvb %r8,%v17,0 /* Load first element of acc-part. */
+ clije %r8,0,.Lslow_add_lbc_end /* End if zero is first character
+ in this part of accept-string. */
+ /* r8>0 -> zero found in this acc-part. */
+ vrepb %v18,%v17,0 /* Replicate first char accross all chars. */
+ vceqb %v22,%v20,%v17 /* Create a mask (v22) of null chars
+ by comparing with 0 (v20). */
+ vsel %v17,%v18,%v17,%v22 /* Replace null chars with first char. */
+ j .Lslow_loop_acc /* Accept part is prepared -> process. */
+
+.Lslow_next_acc_onbb:
+ vfenezb %v18,%v17,%v17 /* Find zero in loaded bytes of accept part. */
+ vlgvb %r8,%v18,7 /* Load byte index of zero. */
+ clrjl %r8,%r9,.Lslow_next_acc_notonbb /* Found a zero in loaded bytes
+ -> Prepare vr. */
+ vl %v17,0(%r5,%r3) /* Load over boundary ... */
+ lghi %r8,0 /* r8=0 -> no zero in this part of acc,
+ Check for zero is in jump-target. */
+ j .Lslow_next_acc_notonbb /* ... and search for zero in
+ fully loaded vreg again. */
+END(__strspn_vx)
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
diff --git a/sysdeps/s390/multiarch/strspn.c b/sysdeps/s390/multiarch/strspn.c
new file mode 100644
index 0000000..48dd77b
--- /dev/null
+++ b/sysdeps/s390/multiarch/strspn.c
@@ -0,0 +1,27 @@
+/* Multiple versions of strspn.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
+# include <string.h>
+# include <ifunc-resolve.h>
+
+s390_vx_libc_ifunc2 (__strspn, strspn)
+
+#else
+# include <string/strspn.c>
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
diff --git a/sysdeps/s390/multiarch/wcsspn-c.c b/sysdeps/s390/multiarch/wcsspn-c.c
new file mode 100644
index 0000000..93af16c
--- /dev/null
+++ b/sysdeps/s390/multiarch/wcsspn-c.c
@@ -0,0 +1,31 @@
+/* Default wcsspn implementation for S/390.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
+# define WCSSPN __wcsspn_c
+
+# include <wchar.h>
+extern __typeof (wcsspn) __wcsspn_c;
+# ifdef SHARED
+# undef libc_hidden_def
+# define libc_hidden_def(name) \
+ __hidden_ver1 (__wcsspn_c, __GI_wcsspn, __wcsspn_c);
+# endif /* SHARED */
+
+# include <wcsmbs/wcsspn.c>
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
diff --git a/sysdeps/s390/multiarch/wcsspn-vx.S b/sysdeps/s390/multiarch/wcsspn-vx.S
new file mode 100644
index 0000000..4ed8e84
--- /dev/null
+++ b/sysdeps/s390/multiarch/wcsspn-vx.S
@@ -0,0 +1,270 @@
+/* Vector optimized 32/64 bit S/390 version of wcsspn.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
+
+# include "sysdep.h"
+# include "asm-syntax.h"
+
+ .text
+
+/* size_t wcsspn (const wchar_t *s, const wchar_t * accept)
+ The wcsspn() function calculates the length of the initial segment
+ of s which consists entirely of characters in accept.
+
+ This method checks the length of accept string. If it fits entirely
+ in one vector register, a fast algorithm is used, which does not need
+ to check multiple parts of accept-string. Otherwise a slower full
+ check of accept-string is used.
+
+ register overview:
+ r3: pointer to start of accept-string
+ r2: pointer to start of search-string
+ r4: loaded byte count of vl search-string
+ r0: found byte index
+ r1: current return len of s
+ v16: search-string
+ v17: accept-string
+ v18: temp-vreg
+
+ ONLY FOR SLOW:
+ v19: first accept-string
+ v20: zero for preparing acc-vector
+ v21: global mask; 1 indicates a match between
+ search-string-vreg and any accept-character
+ v22: current mask; 1 indicates a match between
+ search-string-vreg and any accept-character in current acc-vreg
+ v30, v31: for re-/storing registers r6, r8, r9
+ r5: current len of accept-string
+ r6: zero-index in search-string or 16 if no zero
+ or min(zero-index, loaded byte count)
+ r8: >0, if former accept-string-part contains a zero,
+ otherwise =0;
+ r9: loaded byte count of vlbb accept-string
+*/
+ENTRY(__wcsspn_vx)
+ .machine "z13"
+ .machinemode "zarch_nohighgprs"
+
+ tmll %r2,3 /* Test if s is 4-byte aligned? */
+ jne .Lfallback /* And use common-code variant if not. */
+
+ /*
+ Check if accept-string fits in one vreg:
+ ----------------------------------------
+ */
+ vlbb %v17,0(%r3),6 /* Load accept. */
+ lcbb %r4,0(%r3),6
+ jo .Lcheck_onbb /* Special case if accept lays
+ on block-boundary. */
+.Lcheck_notonbb:
+ vistrfs %v17,%v17 /* Fill with zeros after first zero. */
+ je .Lfast /* Zero found -> accept fits in one vreg. */
+ j .Lslow /* No zero -> accept exceeds one vreg. */
+
+.Lcheck_onbb:
+ /* Accept lays on block-boundary. */
+ nill %r4,65532 /* Recognize only fully loaded characters. */
+ je .Lcheck_onbb2 /* Reload vr if no full wchar_t. */
+ vfenezf %v18,%v17,%v17 /* Search zero in loaded accept bytes. */
+ vlgvb %r0,%v18,7 /* Get index of zero or 16 if not found. */
+ clrjl %r0,%r4,.Lcheck_notonbb /* Zero index < loaded bytes count ->
+ Accept fits in one vreg;
+ Fill with zeros and proceed
+ with FAST. */
+.Lcheck_onbb2:
+ vl %v17,0(%r3) /* Load accept, which exceeds loaded bytes. */
+ j .Lcheck_notonbb /* Check if accept fits in one vreg. */
+
+
+ /*
+ Search s for accept in one vreg
+ -------------------------------
+ */
+.Lfast:
+ /* Complete accept-string in v17 and remaining bytes are zero. */
+
+ vlbb %v16,0(%r2),6 /* Load s until next 4k-byte boundary. */
+ lcbb %r1,0(%r2),6 /* Get bytes to 4k-byte boundary or 16. */
+
+ vfaezfs %v16,%v16,%v17,8 /* Find first element in v16
+ unequal to any in v17
+ or first zero element. */
+
+ vlgvb %r0,%v16,7 /* Load byte index of found element. */
+ /* If found index is within loaded bytes (%r0 < %r1),
+ return with found element index (=equal count). */
+ clr %r0,%r1
+ srlg %r0,%r0,2 /* Convert byte-count to character-count. */
+ locgrl %r2,%r0
+ blr %r14
+
+ /* Align s to 16 byte. */
+ risbgn %r4,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
+ lghi %r1,16 /* current_len = 16. */
+ slr %r1,%r4 /* Compute bytes to 16bytes boundary. */
+
+.Lfast_loop:
+ vl %v16,0(%r1,%r2) /* Load search-string. */
+ vfaezfs %v16,%v16,%v17,8 /* Find first element in v16
+ unequal to any in v17
+ or first zero element. */
+ jno .Lfast_loop_found
+ vl %v16,16(%r1,%r2)
+ vfaezfs %v16,%v16,%v17,8
+ jno .Lfast_loop_found16
+ vl %v16,32(%r1,%r2)
+ vfaezfs %v16,%v16,%v17,8
+ jno .Lfast_loop_found32
+ vl %v16,48(%r1,%r2)
+ vfaezfs %v16,%v16,%v17,8
+ jno .Lfast_loop_found48
+
+ aghi %r1,64
+ j .Lfast_loop /* Loop if no element was unequal to accept
+ and not zero. */
+
+ /* Found unequal or zero element. */
+.Lfast_loop_found48:
+ aghi %r1,16
+.Lfast_loop_found32:
+ aghi %r1,16
+.Lfast_loop_found16:
+ aghi %r1,16
+.Lfast_loop_found:
+ vlgvb %r0,%v16,7 /* Load byte index of found element. */
+ algrk %r2,%r1,%r0 /* And add it to current len. */
+ srlg %r2,%r2,2 /* Convert byte-count to character-count. */
+ br %r14
+
+
+ /*
+ Search s for accept in multiple vregs
+ -------------------------------------
+ */
+.Lslow:
+ /* Save registers. */
+ vlvgg %v30,%r6,0
+ vlvgp %v31,%r8,%r9
+ lghi %r1,0 /* Zero out current len. */
+
+ /* accept in v17 without zero. */
+ vlr %v19,%v17 /* Save first acc-part for a fast reload. */
+ vzero %v20 /* Zero for preparing acc-vector. */
+
+ /* Align s to 16 byte. */
+ risbg %r0,%r2,60,128+63,0 /* Test if s is aligned and
+ %r0 = bits 60-63 'and' 15. */
+ je .Lslow_loop_str /* If s is aligned, loop aligned */
+ lghi %r4,15
+ slr %r4,%r0 /* Compute highest index to load (15-x). */
+ vll %v16,%r4,0(%r2) /* Load up to 16byte boundary (vll needs
+ highest index, remaining bytes are 0). */
+ aghi %r4,1 /* Work with loaded byte count. */
+ vzero %v21 /* Zero out global mask. */
+ lghi %r5,0 /* Set current len of accept-string to zero. */
+ vfenezf %v18,%v16,%v16 /* Find zero in current string-part. */
+ lghi %r8,0 /* There is no zero in first accept-part. */
+ vlgvb %r6,%v18,7 /* Load byte index of zero or 16
+ if there is no zero. */
+ clr %r4,%r6 /* cc==1 if loaded byte count < zero-index. */
+ locrl %r6,%r4 /* Load on cc==1. */
+ j .Lslow_loop_acc
+
+ /* Process s in 16byte aligned loop. */
+.Lslow_next_str:
+ vlr %v17,%v19 /* Load first part of accept (no zero). */
+ algfr %r1,%r4 /* Add loaded byte count to current len. */
+.Lslow_loop_str:
+ vl %v16,0(%r1,%r2) /* Load search-string. */
+ lghi %r4,16 /* Loaded byte count is 16. */
+ vzero %v21 /* Zero out global mask. */
+ lghi %r5,0 /* Set current len of accept-string to zero. */
+ vfenezf %v18,%v16,%v16 /* Find zero in current string-part. */
+ lghi %r8,0 /* There is no zero in first accept-part. */
+ vlgvb %r6,%v18,7 /* Load byte index of zero or 16 if no zero. */
+
+.Lslow_loop_acc:
+ vfaef %v22,%v16,%v17,4 /* Create matching-mask (1 in mask ->
+ character matches any accepted character in
+ this accept-string-part) IN=0, RT=1. */
+ vo %v21,%v21,%v22 /* global-mask = global- | matching-mask. */
+ vfenezf %v18,%v21,%v21 /* Find first zero in global-mask. */
+ vlgvb %r0,%v18,7 /* Get first found zero-index
+ (= first mismatch). */
+ clrjl %r0,%r6,.Lslow_next_acc /* Mismatch-index < min(lbc,zero-index)
+ -> Process this string-part
+ with next acc-part. */
+ clrjhe %r0,%r4,.Lslow_next_str /* Found-index >= loaded byte count
+ -> All loaded bytes are matching
+ any accept-character
+ and are not zero. */
+ /* All bytes are matching any characters in accept-string
+ and search-string is fully processed (found-index == zero-index). */
+.Lslow_add_lbc_end:
+ algrk %r2,%r1,%r0 /* Add matching characters to current len. */
+ srlg %r2,%r2,2 /* Convert byte-count to character-count. */
+ /* Restore registers. */
+ vlgvg %r6,%v30,0
+ vlgvg %r8,%v31,0
+ vlgvg %r9,%v31,1
+ br %r14
+
+.Lslow_next_acc:
+ clijh %r8,0,.Lslow_add_lbc_end /* There was a zero in last acc-part
+ -> Add found index to current len
+ and end. */
+ vlbb %v17,16(%r5,%r3),6 /* Load next accept part. */
+ aghi %r5,16 /* Increment current len of accept-string. */
+ lcbb %r9,0(%r5,%r3),6 /* Get loaded byte count of accept-string. */
+ jo .Lslow_next_acc_onbb /* Jump away if accept-string is
+ on block-boundary. */
+.Lslow_next_acc_notonbb:
+ vistrfs %v17,%v17 /* Fill with zeros after first zero. */
+ jo .Lslow_loop_acc /* No zero found -> no preparation needed. */
+
+.Lslow_next_acc_prepare_zero:
+ /* Zero in accept-part: fill zeros with first-accept-character. */
+ vlgvf %r8,%v17,0 /* Load first element of acc-part. */
+ clije %r8,0,.Lslow_add_lbc_end /* End if zero is first character
+ in this part of accept-string. */
+ /* r8>0 -> zero found in this acc-part. */
+ vrepf %v18,%v17,0 /* Replicate first char accross all chars. */
+ vceqf %v22,%v20,%v17 /* Create a mask (v22) of null chars
+ by comparing with 0 (v20). */
+ vsel %v17,%v18,%v17,%v22 /* Replace null chars with first char. */
+ j .Lslow_loop_acc /* Accept part is prepared -> process. */
+
+.Lslow_next_acc_onbb:
+ nill %r9,65532 /* Recognize only fully loaded characters. */
+ je .Lslow_next_acc_onbb2 /* Reload vr, if we loaded no full
+ wchar_t. */
+ vfenezf %v18,%v17,%v17 /* Find zero in loaded bytes of accept part. */
+ vlgvb %r8,%v18,7 /* Load byte index of zero. */
+ clrjl %r8,%r9,.Lslow_next_acc_notonbb /* Found a zero in loaded bytes
+ -> Prepare vreg. */
+.Lslow_next_acc_onbb2:
+ vl %v17,0(%r5,%r3) /* Load over boundary ... */
+ lghi %r8,0 /* r8=0 -> no zero in this part of acc,
+ check for zero is in jump-target. */
+ j .Lslow_next_acc_notonbb /* ... and search for zero in
+ fully loaded vreg again. */
+.Lfallback:
+ jg __wcsspn_c
+END(__wcsspn_vx)
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
diff --git a/sysdeps/s390/multiarch/wcsspn.c b/sysdeps/s390/multiarch/wcsspn.c
new file mode 100644
index 0000000..3b3041c
--- /dev/null
+++ b/sysdeps/s390/multiarch/wcsspn.c
@@ -0,0 +1,27 @@
+/* Multiple versions of wcsspn.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
+# include <wchar.h>
+# include <ifunc-resolve.h>
+
+s390_vx_libc_ifunc2 (__wcsspn, wcsspn)
+
+#else
+# include <wcsmbs/wcsspn.c>
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
index de3635d..843a23c 100644
--- a/wcsmbs/Makefile
+++ b/wcsmbs/Makefile
@@ -42,7 +42,7 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
mbrtoc16 c16rtomb
strop-tests := wcscmp wcsncmp wmemcmp wcslen wcschr wcsrchr wcscpy wcsnlen \
- wcpcpy wcsncpy wcpncpy wcscat wcsncat wcschrnul
+ wcpcpy wcsncpy wcpncpy wcscat wcsncat wcschrnul wcsspn
tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen tst-btowc tst-mbrtowc \
tst-wcrtomb tst-wcpncpy tst-mbsrtowcs tst-wchar-h tst-mbrtowc2 \
tst-c16c32-1 wcsatcliff $(addprefix test-,$(strop-tests))
diff --git a/wcsmbs/test-wcsspn-ifunc.c b/wcsmbs/test-wcsspn-ifunc.c
new file mode 100644
index 0000000..73f288f
--- /dev/null
+++ b/wcsmbs/test-wcsspn-ifunc.c
@@ -0,0 +1,20 @@
+/* Test and measure IFUNC implementations of wcsspn function.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define TEST_IFUNC 1
+#include "test-wcsspn.c"
diff --git a/wcsmbs/test-wcsspn.c b/wcsmbs/test-wcsspn.c
new file mode 100644
index 0000000..171043c
--- /dev/null
+++ b/wcsmbs/test-wcsspn.c
@@ -0,0 +1,20 @@
+/* Test wcsspn functions.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define WIDE 1
+#include "../string/test-strspn.c"
diff --git a/wcsmbs/wcsspn.c b/wcsmbs/wcsspn.c
index dad72b4..3e84726 100644
--- a/wcsmbs/wcsspn.c
+++ b/wcsmbs/wcsspn.c
@@ -18,6 +18,9 @@
#include <wchar.h>
+#ifdef WCSSPN
+# define wcsspn WCSSPN
+#endif
/* Return the length of the maximum initial segment
of WCS which contains only wide-characters in ACCEPT. */
--
2.3.0