00db10
From 1a569200bc2875ffc474587fb6ec599aac4bad9b Mon Sep 17 00:00:00 2001
00db10
From: Stefan Liebler <stli@linux.vnet.ibm.com>
00db10
Date: Thu, 8 Oct 2015 10:56:59 +0200
00db10
Subject: [PATCH 11/30] S390: Optimize strnlen and wcsnlen.
00db10
00db10
upstream-commit-id: fcf40ebe2682fd65d64f94d69a3df798960cf1b7
00db10
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00082.html
00db10
00db10
This patch provides optimized versions of strnlen and wcsnlen with the z13
00db10
vector instructions.
00db10
00db10
ChangeLog:
00db10
00db10
	* sysdeps/s390/multiarch/strnlen-c.c: New File.
00db10
	* sysdeps/s390/multiarch/strnlen-vx.S: Likewise.
00db10
	* sysdeps/s390/multiarch/strnlen.c: Likewise.
00db10
	* sysdeps/s390/multiarch/wcsnlen-c.c: Likewise.
00db10
	* sysdeps/s390/multiarch/wcsnlen-vx.S: Likewise.
00db10
	* sysdeps/s390/multiarch/wcsnlen.c: Likewise.
00db10
	* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add strnlen and
00db10
	wcsnlen functions.
00db10
	* sysdeps/s390/multiarch/ifunc-impl-list.c
00db10
	(__libc_ifunc_impl_list): Add ifunc test for strnlen, wcsnlen.
00db10
	* wcsmbs/wcsnlen.c: Use WCSNLEN if defined.
00db10
	* string/test-strnlen.c: Add wcsnlen support.
00db10
	* wcsmbs/test-wcsnlen.c: New File.
00db10
	* wcsmbs/Makefile (strop-tests): Add wcsnlen.
00db10
	* benchtests/bench-strnlen.c: Add wcsnlen support.
00db10
	* benchtests/bench-wcsnlen.c: New File.
00db10
	* benchtests/Makefile (wcsmbs-bench): Add wcsnlen.
00db10
---
00db10
 benchtests/Makefile                      |   2 +-
00db10
 benchtests/bench-strnlen.c               |  73 +++++++++------
00db10
 benchtests/bench-wcsnlen.c               |  20 ++++
00db10
 string/test-strnlen.c                    |  87 +++++++++++-------
00db10
 sysdeps/s390/multiarch/Makefile          |   6 +-
00db10
 sysdeps/s390/multiarch/ifunc-impl-list.c |   3 +
00db10
 sysdeps/s390/multiarch/strnlen-c.c       |  28 ++++++
00db10
 sysdeps/s390/multiarch/strnlen-vx.S      | 134 +++++++++++++++++++++++++++
00db10
 sysdeps/s390/multiarch/strnlen.c         |  29 ++++++
00db10
 sysdeps/s390/multiarch/wcsnlen-c.c       |  25 +++++
00db10
 sysdeps/s390/multiarch/wcsnlen-vx.S      | 151 +++++++++++++++++++++++++++++++
00db10
 sysdeps/s390/multiarch/wcsnlen.c         |  28 ++++++
00db10
 wcsmbs/Makefile                          |   2 +-
00db10
 wcsmbs/test-wcsnlen-ifunc.c              |  20 ++++
00db10
 wcsmbs/test-wcsnlen.c                    |  20 ++++
00db10
 wcsmbs/wcsnlen.c                         |   7 +-
00db10
 16 files changed, 571 insertions(+), 64 deletions(-)
00db10
 create mode 100644 benchtests/bench-wcsnlen.c
00db10
 create mode 100644 sysdeps/s390/multiarch/strnlen-c.c
00db10
 create mode 100644 sysdeps/s390/multiarch/strnlen-vx.S
00db10
 create mode 100644 sysdeps/s390/multiarch/strnlen.c
00db10
 create mode 100644 sysdeps/s390/multiarch/wcsnlen-c.c
00db10
 create mode 100644 sysdeps/s390/multiarch/wcsnlen-vx.S
00db10
 create mode 100644 sysdeps/s390/multiarch/wcsnlen.c
00db10
 create mode 100644 wcsmbs/test-wcsnlen-ifunc.c
00db10
 create mode 100644 wcsmbs/test-wcsnlen.c
00db10
00db10
diff --git a/benchtests/Makefile b/benchtests/Makefile
00db10
index 09ab87f..7bb2eef 100644
00db10
--- a/benchtests/Makefile
00db10
+++ b/benchtests/Makefile
00db10
@@ -38,7 +38,7 @@ string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
00db10
 		strcat strchr strchrnul strcmp strcpy strcspn strlen \
00db10
 		strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
00db10
 		strspn strstr strcpy_chk stpcpy_chk memrchr strsep strtok
00db10
-wcsmbs-bench := wcslen
00db10
+wcsmbs-bench := wcslen wcsnlen
00db10
 string-bench-all := $(string-bench) ${wcsmbs-bench}
00db10
 
00db10
 stdlib-bench := strtod
00db10
diff --git a/benchtests/bench-strnlen.c b/benchtests/bench-strnlen.c
00db10
index 793f9be..cbdce75 100644
00db10
--- a/benchtests/bench-strnlen.c
00db10
+++ b/benchtests/bench-strnlen.c
00db10
@@ -1,5 +1,5 @@
00db10
 /* Measure strlen functions.
00db10
-   Copyright (C) 2013 Free Software Foundation, Inc.
00db10
+   Copyright (C) 2013-2015 Free Software Foundation, Inc.
00db10
    This file is part of the GNU C Library.
00db10
 
00db10
    The GNU C Library is free software; you can redistribute it and/or
00db10
@@ -17,17 +17,36 @@
00db10
    <http://www.gnu.org/licenses/>.  */
00db10
 
00db10
 #define TEST_MAIN
00db10
-#define TEST_NAME "strnlen"
00db10
+#ifndef WIDE
00db10
+# define TEST_NAME "strnlen"
00db10
+#else
00db10
+# define TEST_NAME "wcsnlen"
00db10
+#endif /* WIDE */
00db10
 #include "bench-string.h"
00db10
 
00db10
-typedef size_t (*proto_t) (const char *, size_t);
00db10
-size_t simple_strnlen (const char *, size_t);
00db10
-
00db10
-IMPL (simple_strnlen, 0)
00db10
-IMPL (strnlen, 1)
00db10
+#ifndef WIDE
00db10
+# define STRNLEN strnlen
00db10
+# define CHAR char
00db10
+# define BIG_CHAR CHAR_MAX
00db10
+# define MIDDLE_CHAR 127
00db10
+# define SIMPLE_STRNLEN simple_strnlen
00db10
+#else
00db10
+# include <wchar.h>
00db10
+# define STRNLEN wcsnlen
00db10
+# define CHAR wchar_t
00db10
+# define BIG_CHAR WCHAR_MAX
00db10
+# define MIDDLE_CHAR 1121
00db10
+# define SIMPLE_STRNLEN simple_wcsnlen
00db10
+#endif /* WIDE */
00db10
+
00db10
+typedef size_t (*proto_t) (const CHAR *, size_t);
00db10
+size_t SIMPLE_STRNLEN (const CHAR *, size_t);
00db10
+
00db10
+IMPL (SIMPLE_STRNLEN, 0)
00db10
+IMPL (STRNLEN, 1)
00db10
 
00db10
 size_t
00db10
-simple_strnlen (const char *s, size_t maxlen)
00db10
+SIMPLE_STRNLEN (const CHAR *s, size_t maxlen)
00db10
 {
00db10
   size_t i;
00db10
 
00db10
@@ -36,7 +55,7 @@ simple_strnlen (const char *s, size_t maxlen)
00db10
 }
00db10
 
00db10
 static void
00db10
-do_one_test (impl_t *impl, const char *s, size_t maxlen, size_t exp_len)
00db10
+do_one_test (impl_t *impl, const CHAR *s, size_t maxlen, size_t exp_len)
00db10
 {
00db10
   size_t len = CALL (impl, s, maxlen), i, iters = INNER_LOOP_ITERS;
00db10
   timing_t start, stop, cur;
00db10
@@ -66,18 +85,20 @@ do_test (size_t align, size_t len, size_t maxlen, int max_char)
00db10
 {
00db10
   size_t i;
00db10
 
00db10
-  align &= 7;
00db10
-  if (align + len >= page_size)
00db10
+  align &= 63;
00db10
+  if ((align + len) * sizeof (CHAR) >= page_size)
00db10
     return;
00db10
 
00db10
+  CHAR *buf = (CHAR *) (buf1);
00db10
+
00db10
   for (i = 0; i < len; ++i)
00db10
-    buf1[align + i] = 1 + 7 * i % max_char;
00db10
-  buf1[align + len] = 0;
00db10
+    buf[align + i] = 1 + 7 * i % max_char;
00db10
+  buf[align + len] = 0;
00db10
 
00db10
   printf ("Length %4zd, alignment %2zd:", len, align);
00db10
 
00db10
   FOR_EACH_IMPL (impl, 0)
00db10
-    do_one_test (impl, (char *) (buf1 + align), maxlen, MIN (len, maxlen));
00db10
+    do_one_test (impl, (CHAR *) (buf + align), maxlen, MIN (len, maxlen));
00db10
 
00db10
   putchar ('\n');
00db10
 }
00db10
@@ -96,34 +117,34 @@ test_main (void)
00db10
 
00db10
   for (i = 1; i < 8; ++i)
00db10
     {
00db10
-      do_test (0, i, i - 1, 127);
00db10
-      do_test (0, i, i, 127);
00db10
-      do_test (0, i, i + 1, 127);
00db10
+      do_test (0, i, i - 1, MIDDLE_CHAR);
00db10
+      do_test (0, i, i, MIDDLE_CHAR);
00db10
+      do_test (0, i, i + 1, MIDDLE_CHAR);
00db10
     }
00db10
 
00db10
   for (i = 1; i < 8; ++i)
00db10
     {
00db10
-      do_test (i, i, i - 1, 127);
00db10
-      do_test (i, i, i, 127);
00db10
-      do_test (i, i, i + 1, 127);
00db10
+      do_test (i, i, i - 1, MIDDLE_CHAR);
00db10
+      do_test (i, i, i, MIDDLE_CHAR);
00db10
+      do_test (i, i, i + 1, MIDDLE_CHAR);
00db10
     }
00db10
 
00db10
   for (i = 2; i <= 10; ++i)
00db10
     {
00db10
-      do_test (0, 1 << i, 5000, 127);
00db10
-      do_test (1, 1 << i, 5000, 127);
00db10
+      do_test (0, 1 << i, 5000, MIDDLE_CHAR);
00db10
+      do_test (1, 1 << i, 5000, MIDDLE_CHAR);
00db10
     }
00db10
 
00db10
   for (i = 1; i < 8; ++i)
00db10
-    do_test (0, i, 5000, 255);
00db10
+    do_test (0, i, 5000, BIG_CHAR);
00db10
 
00db10
   for (i = 1; i < 8; ++i)
00db10
-    do_test (i, i, 5000, 255);
00db10
+    do_test (i, i, 5000, BIG_CHAR);
00db10
 
00db10
   for (i = 2; i <= 10; ++i)
00db10
     {
00db10
-      do_test (0, 1 << i, 5000, 255);
00db10
-      do_test (1, 1 << i, 5000, 255);
00db10
+      do_test (0, 1 << i, 5000, BIG_CHAR);
00db10
+      do_test (1, 1 << i, 5000, BIG_CHAR);
00db10
     }
00db10
 
00db10
   return ret;
00db10
diff --git a/benchtests/bench-wcsnlen.c b/benchtests/bench-wcsnlen.c
00db10
new file mode 100644
00db10
index 0000000..2b5a51c
00db10
--- /dev/null
00db10
+++ b/benchtests/bench-wcsnlen.c
00db10
@@ -0,0 +1,20 @@
00db10
+/* Measure wcsnlen functions.
00db10
+   Copyright (C) 2015 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#define WIDE 1
00db10
+#include "bench-strnlen.c"
00db10
diff --git a/string/test-strnlen.c b/string/test-strnlen.c
00db10
index ae959bf..43db896 100644
00db10
--- a/string/test-strnlen.c
00db10
+++ b/string/test-strnlen.c
00db10
@@ -1,5 +1,5 @@
00db10
 /* Test and measure strlen functions.
00db10
-   Copyright (C) 1999-2012 Free Software Foundation, Inc.
00db10
+   Copyright (C) 1999-2015 Free Software Foundation, Inc.
00db10
    This file is part of the GNU C Library.
00db10
    Written by Jakub Jelinek <jakub@redhat.com>, 1999.
00db10
 
00db10
@@ -18,17 +18,36 @@
00db10
    <http://www.gnu.org/licenses/>.  */
00db10
 
00db10
 #define TEST_MAIN
00db10
-#define TEST_NAME "strnlen"
00db10
+#ifndef WIDE
00db10
+# define TEST_NAME "strnlen"
00db10
+#else
00db10
+# define TEST_NAME "wcsnlen"
00db10
+#endif /* !WIDE */
00db10
 #include "test-string.h"
00db10
 
00db10
-typedef size_t (*proto_t) (const char *, size_t);
00db10
-size_t simple_strnlen (const char *, size_t);
00db10
-
00db10
-IMPL (simple_strnlen, 0)
00db10
-IMPL (strnlen, 1)
00db10
+#ifndef WIDE
00db10
+# define STRNLEN strnlen
00db10
+# define CHAR char
00db10
+# define BIG_CHAR CHAR_MAX
00db10
+# define MIDDLE_CHAR 127
00db10
+# define SIMPLE_STRNLEN simple_strnlen
00db10
+#else
00db10
+# include <wchar.h>
00db10
+# define STRNLEN wcsnlen
00db10
+# define CHAR wchar_t
00db10
+# define BIG_CHAR WCHAR_MAX
00db10
+# define MIDDLE_CHAR 1121
00db10
+# define SIMPLE_STRNLEN simple_wcsnlen
00db10
+#endif /* !WIDE */
00db10
+
00db10
+typedef size_t (*proto_t) (const CHAR *, size_t);
00db10
+size_t SIMPLE_STRNLEN (const CHAR *, size_t);
00db10
+
00db10
+IMPL (SIMPLE_STRNLEN, 0)
00db10
+IMPL (STRNLEN, 1)
00db10
 
00db10
 size_t
00db10
-simple_strnlen (const char *s, size_t maxlen)
00db10
+SIMPLE_STRNLEN (const CHAR *s, size_t maxlen)
00db10
 {
00db10
   size_t i;
00db10
 
00db10
@@ -37,7 +56,7 @@ simple_strnlen (const char *s, size_t maxlen)
00db10
 }
00db10
 
00db10
 static void
00db10
-do_one_test (impl_t *impl, const char *s, size_t maxlen, size_t exp_len)
00db10
+do_one_test (impl_t *impl, const CHAR *s, size_t maxlen, size_t exp_len)
00db10
 {
00db10
   size_t len = CALL (impl, s, maxlen);
00db10
   if (len != exp_len)
00db10
@@ -54,23 +73,25 @@ do_test (size_t align, size_t len, size_t maxlen, int max_char)
00db10
 {
00db10
   size_t i;
00db10
 
00db10
-  align &= 7;
00db10
-  if (align + len >= page_size)
00db10
+  align &= 63;
00db10
+  if ((align + len) * sizeof (CHAR) >= page_size)
00db10
     return;
00db10
 
00db10
+  CHAR *buf = (CHAR *) (buf1);
00db10
+
00db10
   for (i = 0; i < len; ++i)
00db10
-    buf1[align + i] = 1 + 7 * i % max_char;
00db10
-  buf1[align + len] = 0;
00db10
+    buf[align + i] = 1 + 7 * i % max_char;
00db10
+  buf[align + len] = 0;
00db10
 
00db10
   FOR_EACH_IMPL (impl, 0)
00db10
-    do_one_test (impl, (char *) (buf1 + align), maxlen, MIN (len, maxlen));
00db10
+    do_one_test (impl, (CHAR *) (buf + align), maxlen, MIN (len, maxlen));
00db10
 }
00db10
 
00db10
 static void
00db10
 do_random_tests (void)
00db10
 {
00db10
   size_t i, j, n, align, len;
00db10
-  unsigned char *p = buf1 + page_size - 512;
00db10
+  CHAR *p = (CHAR *) (buf1 + page_size - 512 * sizeof (CHAR));
00db10
 
00db10
   for (n = 0; n < ITERATIONS; n++)
00db10
     {
00db10
@@ -97,25 +118,25 @@ do_random_tests (void)
00db10
       FOR_EACH_IMPL (impl, 1)
00db10
 	{
00db10
 	  if (len > 0
00db10
-	      && CALL (impl, (char *) (p + align), len - 1) != len - 1)
00db10
+	      && CALL (impl, (CHAR *) (p + align), len - 1) != len - 1)
00db10
 	    {
00db10
 	      error (0, 0, "Iteration %zd (limited) - wrong result in function %s (%zd) %zd != %zd, p %p",
00db10
 		     n, impl->name, align,
00db10
-		     CALL (impl, (char *) (p + align), len - 1), len - 1, p);
00db10
+		     CALL (impl, (CHAR *) (p + align), len - 1), len - 1, p);
00db10
 	      ret = 1;
00db10
 	    }
00db10
-	  if (CALL (impl, (char *) (p + align), len) != len)
00db10
+	  if (CALL (impl, (CHAR *) (p + align), len) != len)
00db10
 	    {
00db10
 	      error (0, 0, "Iteration %zd (exact) - wrong result in function %s (%zd) %zd != %zd, p %p",
00db10
 		     n, impl->name, align,
00db10
-		     CALL (impl, (char *) (p + align), len), len, p);
00db10
+		     CALL (impl, (CHAR *) (p + align), len), len, p);
00db10
 	      ret = 1;
00db10
 	    }
00db10
-	  if (CALL (impl, (char *) (p + align), len + 1) != len)
00db10
+	  if (CALL (impl, (CHAR *) (p + align), len + 1) != len)
00db10
 	    {
00db10
 	      error (0, 0, "Iteration %zd (long) - wrong result in function %s (%zd) %zd != %zd, p %p",
00db10
 		     n, impl->name, align,
00db10
-		     CALL (impl, (char *) (p + align), len + 1), len, p);
00db10
+		     CALL (impl, (CHAR *) (p + align), len + 1), len, p);
00db10
 	      ret = 1;
00db10
 	    }
00db10
 	}
00db10
@@ -136,34 +157,34 @@ test_main (void)
00db10
 
00db10
   for (i = 1; i < 8; ++i)
00db10
     {
00db10
-      do_test (0, i, i - 1, 127);
00db10
-      do_test (0, i, i, 127);
00db10
-      do_test (0, i, i + 1, 127);
00db10
+      do_test (0, i, i - 1, MIDDLE_CHAR);
00db10
+      do_test (0, i, i, MIDDLE_CHAR);
00db10
+      do_test (0, i, i + 1, MIDDLE_CHAR);
00db10
     }
00db10
 
00db10
   for (i = 1; i < 8; ++i)
00db10
     {
00db10
-      do_test (i, i, i - 1, 127);
00db10
-      do_test (i, i, i, 127);
00db10
-      do_test (i, i, i + 1, 127);
00db10
+      do_test (i, i, i - 1, MIDDLE_CHAR);
00db10
+      do_test (i, i, i, MIDDLE_CHAR);
00db10
+      do_test (i, i, i + 1, MIDDLE_CHAR);
00db10
     }
00db10
 
00db10
   for (i = 2; i <= 10; ++i)
00db10
     {
00db10
-      do_test (0, 1 << i, 5000, 127);
00db10
-      do_test (1, 1 << i, 5000, 127);
00db10
+      do_test (0, 1 << i, 5000, MIDDLE_CHAR);
00db10
+      do_test (1, 1 << i, 5000, MIDDLE_CHAR);
00db10
     }
00db10
 
00db10
   for (i = 1; i < 8; ++i)
00db10
-    do_test (0, i, 5000, 255);
00db10
+    do_test (0, i, 5000, BIG_CHAR);
00db10
 
00db10
   for (i = 1; i < 8; ++i)
00db10
-    do_test (i, i, 5000, 255);
00db10
+    do_test (i, i, 5000, BIG_CHAR);
00db10
 
00db10
   for (i = 2; i <= 10; ++i)
00db10
     {
00db10
-      do_test (0, 1 << i, 5000, 255);
00db10
-      do_test (1, 1 << i, 5000, 255);
00db10
+      do_test (0, 1 << i, 5000, BIG_CHAR);
00db10
+      do_test (1, 1 << i, 5000, BIG_CHAR);
00db10
     }
00db10
 
00db10
   do_random_tests ();
00db10
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
00db10
index 3a98098..3397f24 100644
00db10
--- a/sysdeps/s390/multiarch/Makefile
00db10
+++ b/sysdeps/s390/multiarch/Makefile
00db10
@@ -1,7 +1,9 @@
00db10
 ifeq ($(subdir),string)
00db10
-sysdep_routines += strlen strlen-vx strlen-c
00db10
+sysdep_routines += strlen strlen-vx strlen-c \
00db10
+		   strnlen strnlen-vx strnlen-c
00db10
 endif
00db10
 
00db10
 ifeq ($(subdir),wcsmbs)
00db10
-sysdep_routines += wcslen wcslen-vx wcslen-c
00db10
+sysdep_routines += wcslen wcslen-vx wcslen-c \
00db10
+		   wcsnlen wcsnlen-vx wcsnlen-c
00db10
 endif
00db10
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
00db10
index e9639ef..bc17c59 100644
00db10
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
00db10
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
00db10
@@ -82,6 +82,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
00db10
   IFUNC_VX_IMPL (strlen);
00db10
   IFUNC_VX_IMPL (wcslen);
00db10
 
00db10
+  IFUNC_VX_IMPL (strnlen);
00db10
+  IFUNC_VX_IMPL (wcsnlen);
00db10
+
00db10
 #endif /* HAVE_S390_VX_ASM_SUPPORT */
00db10
 
00db10
   return i;
00db10
diff --git a/sysdeps/s390/multiarch/strnlen-c.c b/sysdeps/s390/multiarch/strnlen-c.c
00db10
new file mode 100644
00db10
index 0000000..50fc688
00db10
--- /dev/null
00db10
+++ b/sysdeps/s390/multiarch/strnlen-c.c
00db10
@@ -0,0 +1,28 @@
00db10
+/* Default strnlen implementation for S/390.
00db10
+   Copyright (C) 2015 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
00db10
+# define STRNLEN  __strnlen_c
00db10
+# ifdef SHARED
00db10
+#  undef libc_hidden_def
00db10
+#  define libc_hidden_def(name)					\
00db10
+  __hidden_ver1 (__strnlen_c, __GI_strnlen, __strnlen_c);
00db10
+# endif /* SHARED */
00db10
+
00db10
+# include <string/strnlen.c>
00db10
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
00db10
diff --git a/sysdeps/s390/multiarch/strnlen-vx.S b/sysdeps/s390/multiarch/strnlen-vx.S
00db10
new file mode 100644
00db10
index 0000000..8c15621
00db10
--- /dev/null
00db10
+++ b/sysdeps/s390/multiarch/strnlen-vx.S
00db10
@@ -0,0 +1,134 @@
00db10
+/* Vector optimized 32/64 bit S/390 version of strnlen.
00db10
+   Copyright (C) 2015 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
00db10
+
00db10
+# include "sysdep.h"
00db10
+# include "asm-syntax.h"
00db10
+
00db10
+	.text
00db10
+
00db10
+/* size_t strnlen (const char *s, size_t maxlen)
00db10
+   Returns the number of characters in s or at most maxlen.
00db10
+
00db10
+   Register usage:
00db10
+   -r1=tmp
00db10
+   -r2=address of string
00db10
+   -r3=maxlen (number of characters to be read)
00db10
+   -r4=tmp
00db10
+   -r5=current_len and return_value
00db10
+   -v16=part of s
00db10
+*/
00db10
+ENTRY(__strnlen_vx)
00db10
+	.machine "z13"
00db10
+	.machinemode "zarch_nohighgprs"
00db10
+
00db10
+# if !defined __s390x__
00db10
+	llgfr	%r3,%r3
00db10
+# endif /* !defined __s390x__ */
00db10
+
00db10
+	clgfi	%r3,0		/* if maxlen == 0, return 0.  */
00db10
+	locgre	%r2,%r3
00db10
+	ber	%r14
00db10
+
00db10
+	vlbb	%v16,0(%r2),6	/* Load s until next 4k-byte boundary.  */
00db10
+	lcbb	%r1,0(%r2),6	/* Get bytes to 4k-byte boundary or 16.  */
00db10
+	llgfr	%r1,%r1		/* Convert 32bit to 64bit.  */
00db10
+
00db10
+	vfenezb	%v16,%v16,%v16	/* Find element not equal with zero search.  */
00db10
+	clgr	%r1,%r3
00db10
+	locgrh	%r1,%r3		/* loaded_byte_count
00db10
+				   = min (loaded_byte_count, maxlen)  */
00db10
+
00db10
+	vlgvb	%r5,%v16,7	/* Load zero index or 16 if not found.  */
00db10
+	clr	%r5,%r1		/* If found zero within loaded bytes?  */
00db10
+	locgrl	%r2,%r5		/* Then copy return value.  */
00db10
+	blr	%r14		/* And return.  */
00db10
+
00db10
+	clgr	%r1,%r3		/* If loaded_byte_count == maxlen?  */
00db10
+	locgre	%r2,%r3		/* Then copy return value.  */
00db10
+	ber	%r14		/* And return.  */
00db10
+
00db10
+	/* Align s to 16 byte.  */
00db10
+	risbgn	%r4,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15.  */
00db10
+	lghi	%r5,16		/* current_len = 16.  */
00db10
+	slr	%r5,%r4		/* Compute bytes to 16bytes boundary.  */
00db10
+
00db10
+	lgr	%r1,%r5		/* If %r5 + 64 < maxlen? -> loop64.  */
00db10
+	aghi	%r1,64
00db10
+	clgrjl	%r1,%r3,.Lloop64
00db10
+
00db10
+	/* Find zero in max 64byte with aligned s.  */
00db10
+.Llt64:
00db10
+	vl	%v16,0(%r5,%r2) /* Load s.  */
00db10
+	vfenezbs %v16,%v16,%v16	/* Find element not equal with zero search.  */
00db10
+	je	.Lfound		/* Jump away if zero was found.  */
00db10
+	aghi	%r5,16
00db10
+	clgrjhe	%r5,%r3,.Lfound /* current_len >= maxlen -> end.  */
00db10
+	vl	%v16,0(%r5,%r2)
00db10
+	vfenezbs %v16,%v16,%v16
00db10
+	je	.Lfound
00db10
+	aghi	%r5,16
00db10
+	clgrjhe	%r5,%r3,.Lfound
00db10
+	vl	%v16,0(%r5,%r2)
00db10
+	vfenezbs %v16,%v16,%v16
00db10
+	je	.Lfound
00db10
+	aghi	%r5,16
00db10
+	clgrjhe	%r5,%r3,.Lfound
00db10
+	vl	%v16,0(%r5,%r2)
00db10
+	vfenezbs %v16,%v16,%v16
00db10
+	j	.Lfound
00db10
+
00db10
+.Lfound48:
00db10
+	aghi	%r5,16
00db10
+.Lfound32:
00db10
+	aghi	%r5,16
00db10
+.Lfound16:
00db10
+	aghi	%r5,16
00db10
+.Lfound:
00db10
+	vlgvb	%r4,%v16,7	/* Load byte index of zero or 16 if no zero.  */
00db10
+	algr	%r5,%r4
00db10
+
00db10
+	clgr	%r5,%r3
00db10
+	locgrh	%r5,%r3		/* Return min (current_len, maxlen).  */
00db10
+	lgr	%r2,%r5
00db10
+	br	%r14
00db10
+
00db10
+	/* Find zero in 16 byte aligned loop.  */
00db10
+.Lloop64:
00db10
+	vl	%v16,0(%r5,%r2) /* Load s.  */
00db10
+	vfenezbs %v16,%v16,%v16	/* Find element not equal with zero search.  */
00db10
+	je	.Lfound		/* Jump away if zero was found.  */
00db10
+	vl	%v16,16(%r5,%r2)
00db10
+	vfenezbs %v16,%v16,%v16
00db10
+	je	.Lfound16
00db10
+	vl	%v16,32(%r5,%r2)
00db10
+	vfenezbs %v16,%v16,%v16
00db10
+	je	.Lfound32
00db10
+	vl	%v16,48(%r5,%r2)
00db10
+	vfenezbs %v16,%v16,%v16
00db10
+	je	.Lfound48
00db10
+
00db10
+	aghi	%r5,64
00db10
+	lgr	%r1,%r5		/* If %r5 + 64 < maxlen? -> loop64.  */
00db10
+	aghi	%r1,64
00db10
+	clgrjl	%r1,%r3,.Lloop64
00db10
+
00db10
+	j	.Llt64
00db10
+END(__strnlen_vx)
00db10
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
00db10
diff --git a/sysdeps/s390/multiarch/strnlen.c b/sysdeps/s390/multiarch/strnlen.c
00db10
new file mode 100644
00db10
index 0000000..f036fcd
00db10
--- /dev/null
00db10
+++ b/sysdeps/s390/multiarch/strnlen.c
00db10
@@ -0,0 +1,29 @@
00db10
+/* Multiple versions of strnlen.
00db10
+   Copyright (C) 2015 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
00db10
+# include <string.h>
00db10
+# include <ifunc-resolve.h>
00db10
+
00db10
+s390_vx_libc_ifunc (__strnlen)
00db10
+weak_alias (__strnlen, strnlen)
00db10
+libc_hidden_def (strnlen)
00db10
+
00db10
+#else
00db10
+# include <string/strnlen.c>
00db10
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
00db10
diff --git a/sysdeps/s390/multiarch/wcsnlen-c.c b/sysdeps/s390/multiarch/wcsnlen-c.c
00db10
new file mode 100644
00db10
index 0000000..6d8b537
00db10
--- /dev/null
00db10
+++ b/sysdeps/s390/multiarch/wcsnlen-c.c
00db10
@@ -0,0 +1,25 @@
00db10
+/* Default wcsnlen implementation for S/390.
00db10
+   Copyright (C) 2015 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
00db10
+# define WCSNLEN  __wcsnlen_c
00db10
+
00db10
+# include <wchar.h>
00db10
+extern __typeof (__wcsnlen) __wcsnlen_c;
00db10
+# include <wcsmbs/wcsnlen.c>
00db10
+#endif
00db10
diff --git a/sysdeps/s390/multiarch/wcsnlen-vx.S b/sysdeps/s390/multiarch/wcsnlen-vx.S
00db10
new file mode 100644
00db10
index 0000000..8c21630
00db10
--- /dev/null
00db10
+++ b/sysdeps/s390/multiarch/wcsnlen-vx.S
00db10
@@ -0,0 +1,151 @@
00db10
+/* Vector optimized 32/64 bit S/390 version of wcsnlen.
00db10
+   Copyright (C) 2015 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
00db10
+
00db10
+# include "sysdep.h"
00db10
+# include "asm-syntax.h"
00db10
+
00db10
+	.text
00db10
+
00db10
+/* size_t wcsnlen (const wchar_t *s, size_t maxlen)
00db10
+   Returns the number of characters in s or at most maxlen.
00db10
+
00db10
+   Register usage:
00db10
+   -r1=tmp
00db10
+   -r2=address of string
00db10
+   -r3=maxlen (number of characters to be read)
00db10
+   -r4=tmp
00db10
+   -r5=current_len and return_value
00db10
+   -v16=part of s
00db10
+*/
00db10
+ENTRY(__wcsnlen_vx)
00db10
+
00db10
+	.machine "z13"
00db10
+	.machinemode "zarch_nohighgprs"
00db10
+
00db10
+# if !defined __s390x__
00db10
+	llgfr	%r3,%r3
00db10
+# endif /* !defined __s390x__ */
00db10
+
00db10
+	clgfi	%r3,0		/* if maxlen == 0, return 0.  */
00db10
+	locgre	%r2,%r3
00db10
+	ber	%r14
00db10
+
00db10
+	vlbb	%v16,0(%r2),6	/* Load s until next 4k-byte boundary.  */
00db10
+	lcbb	%r1,0(%r2),6	/* Get bytes to 4k-byte boundary or 16.  */
00db10
+	llgfr	%r1,%r1		/* Convert 32bit to 64bit.  */
00db10
+
00db10
+	tmll	%r2,3		/* Test if s is 4-byte aligned?  */
00db10
+	jne	.Lfallback	/* And use common-code variant if not.  */
00db10
+
00db10
+	/* Check range of maxlen and convert to byte-count.  */
00db10
+# ifdef __s390x__
00db10
+	tmhh	%r3,49152	/* Test bit 0 or 1 of maxlen.  */
00db10
+	lghi	%r4,-4		/* Max byte-count is 18446744073709551612.  */
00db10
+# else
00db10
+	tmlh	%r3,49152	/* Test bit 0 or 1 of maxlen.  */
00db10
+	llilf	%r4,4294967292	/* Max byte-count is 4294967292.  */
00db10
+# endif /* !__s390x__ */
00db10
+	sllg	%r3,%r3,2	/* Convert character-count to byte-count.  */
00db10
+	locgrne	%r3,%r4		/* Use max byte-count, if bit 0/1 was one.  */
00db10
+
00db10
+	vfenezf	%v16,%v16,%v16	/* Find element not equal with zero search.  */
00db10
+	clgr	%r1,%r3
00db10
+	locgrh	%r1,%r3		/* loaded_byte_count
00db10
+				   = min (loaded_byte_count, maxlen)  */
00db10
+
00db10
+	vlgvb	%r5,%v16,7	/* Load zero index or 16 if not found.  */
00db10
+	clrjl	%r5,%r1,.Lend	/* Found zero within loaded bytes -> return.  */
00db10
+
00db10
+	clgr	%r1,%r3		/* If loaded_byte_count == maxlen -> end.  */
00db10
+	locgre	%r5,%r3
00db10
+	je	.Lend
00db10
+
00db10
+	/* Align s to 16 byte.  */
00db10
+	risbgn	%r4,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15.  */
00db10
+	lghi	%r5,16		/* current_len = 16.  */
00db10
+	slr	%r5,%r4		/* Compute bytes to 16bytes boundary.  */
00db10
+
00db10
+	lgr	%r1,%r5		/* If %r5 + 64 < maxlen? -> loop64.  */
00db10
+	aghi	%r1,64
00db10
+	clgrjl	%r1,%r3,.Lloop64
00db10
+
00db10
+	/* Find zero in max 64byte with aligned s.  */
00db10
+.Llt64:
00db10
+	vl	%v16,0(%r5,%r2)	/* Load s.  */
00db10
+	vfenezfs %v16,%v16,%v16	/* Find element not equal with zero search.  */
00db10
+	je	.Lfound		/* Jump away if zero was found.  */
00db10
+	aghi	%r5,16
00db10
+	clgrjhe	%r5,%r3,.Lfound /* If current_len >= maxlen -> end.  */
00db10
+	vl	%v16,0(%r5,%r2)
00db10
+	vfenezfs %v16,%v16,%v16
00db10
+	je	.Lfound
00db10
+	aghi	%r5,16
00db10
+	clgrjhe	%r5,%r3,.Lfound
00db10
+	vl	%v16,0(%r5,%r2)
00db10
+	vfenezfs %v16,%v16,%v16
00db10
+	je	.Lfound
00db10
+	aghi	%r5,16
00db10
+	clgrjhe	%r5,%r3,.Lfound
00db10
+	vl	%v16,0(%r5,%r2)
00db10
+	vfenezfs %v16,%v16,%v16
00db10
+	j	.Lfound
00db10
+
00db10
+.Lfound48:
00db10
+	aghi	%r5,16
00db10
+.Lfound32:
00db10
+	aghi	%r5,16
00db10
+.Lfound16:
00db10
+	aghi	%r5,16
00db10
+.Lfound:
00db10
+	vlgvb	%r4,%v16,7	/* Load byte index of zero or 16 if no zero.  */
00db10
+	algr	%r5,%r4
00db10
+
00db10
+	clgr	%r5,%r3
00db10
+	locgrh	%r5,%r3		/* Return min (current_len, maxlen).  */
00db10
+.Lend:
00db10
+	srlg	%r2,%r5,2	/* Convert byte-count to character-count.  */
00db10
+	br	%r14
00db10
+
00db10
+	/* Find zero in 16byte aligned loop.  */
00db10
+.Lloop64:
00db10
+	vl	%v16,0(%r5,%r2)	/* Load s.  */
00db10
+	vfenezfs %v16,%v16,%v16	/* Find element not equal with zero search.  */
00db10
+	je	.Lfound		/* Jump away if zero was found.  */
00db10
+	vl	%v16,16(%r5,%r2)
00db10
+	vfenezfs %v16,%v16,%v16
00db10
+	je	.Lfound16
00db10
+	vl	%v16,32(%r5,%r2)
00db10
+	vfenezfs %v16,%v16,%v16
00db10
+	je	.Lfound32
00db10
+	vl	%v16,48(%r5,%r2)
00db10
+	vfenezfs %v16,%v16,%v16
00db10
+	je	.Lfound48
00db10
+
00db10
+	aghi	%r5,64
00db10
+	lgr	%r1,%r5		/* If %r5 + 64 < maxlen? -> loop64.  */
00db10
+	aghi	%r1,64
00db10
+	clgrjl	%r1,%r3,.Lloop64
00db10
+
00db10
+	j	.Llt64
00db10
+
00db10
+.Lfallback:
00db10
+	jg	__wcsnlen_c
00db10
+END(__wcsnlen_vx)
00db10
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
00db10
diff --git a/sysdeps/s390/multiarch/wcsnlen.c b/sysdeps/s390/multiarch/wcsnlen.c
00db10
new file mode 100644
00db10
index 0000000..fbb0cab
00db10
--- /dev/null
00db10
+++ b/sysdeps/s390/multiarch/wcsnlen.c
00db10
@@ -0,0 +1,28 @@
00db10
+/* Multiple versions of wcsnlen.
00db10
+   Copyright (C) 2015 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
00db10
+# include <wchar.h>
00db10
+# include <ifunc-resolve.h>
00db10
+
00db10
+s390_vx_libc_ifunc (__wcsnlen)
00db10
+weak_alias (__wcsnlen, wcsnlen)
00db10
+
00db10
+#else
00db10
+# include <wcsmbs/wcsnlen.c>
00db10
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
00db10
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
00db10
index 54994e2..ec0b050 100644
00db10
--- a/wcsmbs/Makefile
00db10
+++ b/wcsmbs/Makefile
00db10
@@ -41,7 +41,7 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
00db10
 	    isoc99_swscanf isoc99_vswscanf \
00db10
 	    mbrtoc16 c16rtomb
00db10
 
00db10
-strop-tests :=  wcscmp wmemcmp wcslen wcschr wcsrchr wcscpy
00db10
+strop-tests :=  wcscmp wmemcmp wcslen wcschr wcsrchr wcscpy wcsnlen
00db10
 tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen tst-btowc tst-mbrtowc \
00db10
 	 tst-wcrtomb tst-wcpncpy tst-mbsrtowcs tst-wchar-h tst-mbrtowc2 \
00db10
 	 tst-c16c32-1 wcsatcliff $(addprefix test-,$(strop-tests))
00db10
diff --git a/wcsmbs/test-wcsnlen-ifunc.c b/wcsmbs/test-wcsnlen-ifunc.c
00db10
new file mode 100644
00db10
index 0000000..8aa528e
00db10
--- /dev/null
00db10
+++ b/wcsmbs/test-wcsnlen-ifunc.c
00db10
@@ -0,0 +1,20 @@
00db10
+/* Test and measure IFUNC implementations of wcsnlen function.
00db10
+   Copyright (C) 2015 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#define TEST_IFUNC 1
00db10
+#include "test-wcsnlen.c"
00db10
diff --git a/wcsmbs/test-wcsnlen.c b/wcsmbs/test-wcsnlen.c
00db10
new file mode 100644
00db10
index 0000000..262ab30
00db10
--- /dev/null
00db10
+++ b/wcsmbs/test-wcsnlen.c
00db10
@@ -0,0 +1,20 @@
00db10
+/* Test wcsnlen function.
00db10
+   Copyright (C) 2015 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#define WIDE 1
00db10
+#include "../string/test-strnlen.c"
00db10
diff --git a/wcsmbs/wcsnlen.c b/wcsmbs/wcsnlen.c
00db10
index dff1b45..e803920 100644
00db10
--- a/wcsmbs/wcsnlen.c
00db10
+++ b/wcsmbs/wcsnlen.c
00db10
@@ -18,8 +18,11 @@
00db10
 
00db10
 #include <wchar.h>
00db10
 
00db10
+#ifdef WCSNLEN
00db10
+# define __wcsnlen WCSNLEN
00db10
+#endif
00db10
 
00db10
-/* Copy SRC to DEST.  */
00db10
+/* Return length of string S at most maxlen.  */
00db10
 size_t
00db10
 __wcsnlen (s, maxlen)
00db10
      const wchar_t *s;
00db10
@@ -44,4 +47,6 @@ __wcsnlen (s, maxlen)
00db10
 
00db10
   return len;
00db10
 }
00db10
+#ifndef WCSNLEN
00db10
 weak_alias (__wcsnlen, wcsnlen)
00db10
+#endif
00db10
-- 
00db10
2.3.0
00db10