|
|
147e83 |
From 6bad9c03df10e4bca1840eff95ef9036e5261436 Mon Sep 17 00:00:00 2001
|
|
|
147e83 |
From: Stefan Liebler <stli@linux.vnet.ibm.com>
|
|
|
147e83 |
Date: Thu, 8 Oct 2015 13:20:09 +0200
|
|
|
147e83 |
Subject: [PATCH 26/30] S390: Optimize memchr, rawmemchr and wmemchr.
|
|
|
147e83 |
|
|
|
147e83 |
upstream-commit-id: 88eefd344b3cf4a41284a1dfdaca61667e3a1b4b
|
|
|
147e83 |
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00093.html
|
|
|
147e83 |
|
|
|
147e83 |
This patch provides optimized versions of memchr, rawmemchr and wmemchr with the
|
|
|
147e83 |
z13 vector instructions.
|
|
|
147e83 |
|
|
|
147e83 |
ChangeLog:
|
|
|
147e83 |
|
|
|
147e83 |
* sysdeps/s390/multiarch/memchr-vx.S: New File.
|
|
|
147e83 |
* sysdeps/s390/multiarch/memchr.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/rawmemchr-c.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/rawmemchr-vx.S: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/rawmemchr.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/wmemchr-c.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/wmemchr-vx.S: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/wmemchr.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/s390-32/multiarch/memchr.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/s390-64/multiarch/memchr.c: Likewise.
|
|
|
147e83 |
* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add memchr, wmemchr
|
|
|
147e83 |
and rawmemchr functions.
|
|
|
147e83 |
* sysdeps/s390/multiarch/ifunc-impl-list-common.c
|
|
|
147e83 |
(__libc_ifunc_impl_list_common): Add ifunc test for memchr, rawmemchr
|
|
|
147e83 |
and wmemchr.
|
|
|
147e83 |
* wcsmbs/wmemchr.c: Use WMEMCHR if defined.
|
|
|
147e83 |
* string/test-memchr.c: Add wmemchr support.
|
|
|
147e83 |
* wcsmbs/test-wmemchr.c: New File.
|
|
|
147e83 |
* wcsmbs/Makefile (strop-tests): Add wmemchr.
|
|
|
147e83 |
* benchtests/bench-memchr.c: Add wmemchr support.
|
|
|
147e83 |
* benchtests/bench-wmemchr.c: New File.
|
|
|
147e83 |
* benchtests/Makefile (wcsmbs-bench): wmemchr.
|
|
|
147e83 |
---
|
|
|
147e83 |
benchtests/Makefile | 3 +-
|
|
|
147e83 |
benchtests/bench-memchr.c | 68 ++++++++-----
|
|
|
147e83 |
benchtests/bench-wmemchr.c | 20 ++++
|
|
|
147e83 |
string/test-memchr.c | 89 +++++++++++------
|
|
|
147e83 |
sysdeps/s390/multiarch/Makefile | 7 +-
|
|
|
147e83 |
sysdeps/s390/multiarch/ifunc-impl-list.c | 4 +
|
|
|
147e83 |
sysdeps/s390/multiarch/memchr-vx.S | 159 +++++++++++++++++++++++++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/memchr.c | 24 +++++
|
|
|
147e83 |
sysdeps/s390/multiarch/rawmemchr-c.c | 34 +++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/rawmemchr-vx.S | 92 +++++++++++++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/rawmemchr.c | 28 ++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/wmemchr-c.c | 31 ++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/wmemchr-vx.S | 166 +++++++++++++++++++++++++++++++
|
|
|
147e83 |
sysdeps/s390/multiarch/wmemchr.c | 27 +++++
|
|
|
147e83 |
sysdeps/s390/s390-32/multiarch/memchr.c | 21 ++++
|
|
|
147e83 |
sysdeps/s390/s390-64/multiarch/memchr.c | 21 ++++
|
|
|
147e83 |
wcsmbs/Makefile | 2 +-
|
|
|
147e83 |
wcsmbs/test-wmemchr-ifunc.c | 20 ++++
|
|
|
147e83 |
wcsmbs/test-wmemchr.c | 20 ++++
|
|
|
147e83 |
wcsmbs/wmemchr.c | 4 +
|
|
|
147e83 |
20 files changed, 780 insertions(+), 60 deletions(-)
|
|
|
147e83 |
create mode 100644 benchtests/bench-wmemchr.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/memchr-vx.S
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/memchr.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/rawmemchr-c.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/rawmemchr-vx.S
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/rawmemchr.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/wmemchr-c.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/wmemchr-vx.S
|
|
|
147e83 |
create mode 100644 sysdeps/s390/multiarch/wmemchr.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/s390-32/multiarch/memchr.c
|
|
|
147e83 |
create mode 100644 sysdeps/s390/s390-64/multiarch/memchr.c
|
|
|
147e83 |
create mode 100644 wcsmbs/test-wmemchr-ifunc.c
|
|
|
147e83 |
create mode 100644 wcsmbs/test-wmemchr.c
|
|
|
147e83 |
|
|
|
147e83 |
diff --git a/benchtests/Makefile b/benchtests/Makefile
|
|
|
147e83 |
index 4e811a9..b4b3127 100644
|
|
|
147e83 |
--- a/benchtests/Makefile
|
|
|
147e83 |
+++ b/benchtests/Makefile
|
|
|
147e83 |
@@ -39,7 +39,8 @@ 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 wcscspn
|
|
|
147e83 |
+ wcsncmp wcsncmp wcschr wcschrnul wcsrchr wcsspn wcspbrk wcscspn \
|
|
|
147e83 |
+ wmemchr
|
|
|
147e83 |
string-bench-all := $(string-bench) ${wcsmbs-bench}
|
|
|
147e83 |
|
|
|
147e83 |
stdlib-bench := strtod
|
|
|
147e83 |
diff --git a/benchtests/bench-memchr.c b/benchtests/bench-memchr.c
|
|
|
147e83 |
index 30c472c..84a90b4 100644
|
|
|
147e83 |
--- a/benchtests/bench-memchr.c
|
|
|
147e83 |
+++ b/benchtests/bench-memchr.c
|
|
|
147e83 |
@@ -16,31 +16,51 @@
|
|
|
147e83 |
License along with the GNU C Library; if not, see
|
|
|
147e83 |
<http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
|
|
|
147e83 |
+#ifndef WIDE
|
|
|
147e83 |
+# define CHAR char
|
|
|
147e83 |
+# define SMALL_CHAR 127
|
|
|
147e83 |
+#else
|
|
|
147e83 |
+# include <wchar.h>
|
|
|
147e83 |
+# define CHAR wchar_t
|
|
|
147e83 |
+# define SMALL_CHAR 1273
|
|
|
147e83 |
+#endif /* WIDE */
|
|
|
147e83 |
#ifndef USE_AS_MEMRCHR
|
|
|
147e83 |
# define TEST_MAIN
|
|
|
147e83 |
-# define TEST_NAME "memchr"
|
|
|
147e83 |
+# ifndef WIDE
|
|
|
147e83 |
+# define TEST_NAME "memchr"
|
|
|
147e83 |
+# else
|
|
|
147e83 |
+# define TEST_NAME "wmemchr"
|
|
|
147e83 |
+# endif /* WIDE */
|
|
|
147e83 |
# include "bench-string.h"
|
|
|
147e83 |
|
|
|
147e83 |
-typedef char *(*proto_t) (const char *, int, size_t);
|
|
|
147e83 |
-char *simple_memchr (const char *, int, size_t);
|
|
|
147e83 |
+# ifndef WIDE
|
|
|
147e83 |
+# define MEMCHR memchr
|
|
|
147e83 |
+# define SIMPLE_MEMCHR simple_memchr
|
|
|
147e83 |
+# else
|
|
|
147e83 |
+# define MEMCHR wmemchr
|
|
|
147e83 |
+# define SIMPLE_MEMCHR simple_wmemchr
|
|
|
147e83 |
+# endif /* WIDE */
|
|
|
147e83 |
|
|
|
147e83 |
-IMPL (simple_memchr, 0)
|
|
|
147e83 |
-IMPL (memchr, 1)
|
|
|
147e83 |
+typedef CHAR *(*proto_t) (const CHAR *, int, size_t);
|
|
|
147e83 |
+CHAR *SIMPLE_MEMCHR (const CHAR *, int, size_t);
|
|
|
147e83 |
|
|
|
147e83 |
-char *
|
|
|
147e83 |
-simple_memchr (const char *s, int c, size_t n)
|
|
|
147e83 |
+IMPL (SIMPLE_MEMCHR, 0)
|
|
|
147e83 |
+IMPL (MEMCHR, 1)
|
|
|
147e83 |
+
|
|
|
147e83 |
+CHAR *
|
|
|
147e83 |
+SIMPLE_MEMCHR (const CHAR *s, int c, size_t n)
|
|
|
147e83 |
{
|
|
|
147e83 |
while (n--)
|
|
|
147e83 |
- if (*s++ == (char) c)
|
|
|
147e83 |
- return (char *) s - 1;
|
|
|
147e83 |
+ if (*s++ == (CHAR) c)
|
|
|
147e83 |
+ return (CHAR *) s - 1;
|
|
|
147e83 |
return NULL;
|
|
|
147e83 |
}
|
|
|
147e83 |
-#endif
|
|
|
147e83 |
+#endif /* !USE_AS_MEMRCHR */
|
|
|
147e83 |
|
|
|
147e83 |
static void
|
|
|
147e83 |
-do_one_test (impl_t *impl, const char *s, int c, size_t n, char *exp_res)
|
|
|
147e83 |
+do_one_test (impl_t *impl, const CHAR *s, int c, size_t n, CHAR *exp_res)
|
|
|
147e83 |
{
|
|
|
147e83 |
- char *res = CALL (impl, s, c, n);
|
|
|
147e83 |
+ CHAR *res = CALL (impl, s, c, n);
|
|
|
147e83 |
size_t i, iters = INNER_LOOP_ITERS;
|
|
|
147e83 |
timing_t start, stop, cur;
|
|
|
147e83 |
|
|
|
147e83 |
@@ -68,36 +88,38 @@ static void
|
|
|
147e83 |
do_test (size_t align, size_t pos, size_t len, int seek_char)
|
|
|
147e83 |
{
|
|
|
147e83 |
size_t i;
|
|
|
147e83 |
- char *result;
|
|
|
147e83 |
+ CHAR *result;
|
|
|
147e83 |
|
|
|
147e83 |
align &= 7;
|
|
|
147e83 |
- if (align + len >= page_size)
|
|
|
147e83 |
+ if ((align + len) * sizeof (CHAR) >= page_size)
|
|
|
147e83 |
return;
|
|
|
147e83 |
|
|
|
147e83 |
+ CHAR *buf = (CHAR *) (buf1);
|
|
|
147e83 |
+
|
|
|
147e83 |
for (i = 0; i < len; ++i)
|
|
|
147e83 |
{
|
|
|
147e83 |
- buf1[align + i] = 1 + 23 * i % 127;
|
|
|
147e83 |
- if (buf1[align + i] == seek_char)
|
|
|
147e83 |
- buf1[align + i] = seek_char + 1;
|
|
|
147e83 |
+ buf[align + i] = 1 + 23 * i % SMALL_CHAR;
|
|
|
147e83 |
+ if (buf[align + i] == seek_char)
|
|
|
147e83 |
+ buf[align + i] = seek_char + 1;
|
|
|
147e83 |
}
|
|
|
147e83 |
- buf1[align + len] = 0;
|
|
|
147e83 |
+ buf[align + len] = 0;
|
|
|
147e83 |
|
|
|
147e83 |
if (pos < len)
|
|
|
147e83 |
{
|
|
|
147e83 |
- buf1[align + pos] = seek_char;
|
|
|
147e83 |
- buf1[align + len] = -seek_char;
|
|
|
147e83 |
- result = (char *) (buf1 + align + pos);
|
|
|
147e83 |
+ buf[align + pos] = seek_char;
|
|
|
147e83 |
+ buf[align + len] = -seek_char;
|
|
|
147e83 |
+ result = (CHAR *) (buf1 + align + pos);
|
|
|
147e83 |
}
|
|
|
147e83 |
else
|
|
|
147e83 |
{
|
|
|
147e83 |
result = NULL;
|
|
|
147e83 |
- buf1[align + len] = seek_char;
|
|
|
147e83 |
+ buf[align + len] = seek_char;
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
printf ("Length %4zd, alignment %2zd:", pos, align);
|
|
|
147e83 |
|
|
|
147e83 |
FOR_EACH_IMPL (impl, 0)
|
|
|
147e83 |
- do_one_test (impl, (char *) (buf1 + align), seek_char, len, result);
|
|
|
147e83 |
+ do_one_test (impl, (CHAR *) (buf + align), seek_char, len, result);
|
|
|
147e83 |
|
|
|
147e83 |
putchar ('\n');
|
|
|
147e83 |
}
|
|
|
147e83 |
diff --git a/benchtests/bench-wmemchr.c b/benchtests/bench-wmemchr.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..d796a69
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/benchtests/bench-wmemchr.c
|
|
|
147e83 |
@@ -0,0 +1,20 @@
|
|
|
147e83 |
+/* Measure wmemchr 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-memchr.c"
|
|
|
147e83 |
diff --git a/string/test-memchr.c b/string/test-memchr.c
|
|
|
147e83 |
index cdcceeb..058a837 100644
|
|
|
147e83 |
--- a/string/test-memchr.c
|
|
|
147e83 |
+++ b/string/test-memchr.c
|
|
|
147e83 |
@@ -18,28 +18,49 @@
|
|
|
147e83 |
<http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
|
|
|
147e83 |
#define TEST_MAIN
|
|
|
147e83 |
-#define TEST_NAME "memchr"
|
|
|
147e83 |
+#ifndef WIDE
|
|
|
147e83 |
+# define TEST_NAME "memchr"
|
|
|
147e83 |
+#else
|
|
|
147e83 |
+# define TEST_NAME "wmemchr"
|
|
|
147e83 |
+#endif /* WIDE */
|
|
|
147e83 |
#include "test-string.h"
|
|
|
147e83 |
|
|
|
147e83 |
-typedef char *(*proto_t) (const char *, int, size_t);
|
|
|
147e83 |
-char *simple_memchr (const char *, int, size_t);
|
|
|
147e83 |
-
|
|
|
147e83 |
-IMPL (simple_memchr, 0)
|
|
|
147e83 |
-IMPL (memchr, 1)
|
|
|
147e83 |
-
|
|
|
147e83 |
-char *
|
|
|
147e83 |
-simple_memchr (const char *s, int c, size_t n)
|
|
|
147e83 |
+#ifndef WIDE
|
|
|
147e83 |
+# define MEMCHR memchr
|
|
|
147e83 |
+# define CHAR char
|
|
|
147e83 |
+# define UCHAR unsigned char
|
|
|
147e83 |
+# define SIMPLE_MEMCHR simple_memchr
|
|
|
147e83 |
+# define BIG_CHAR CHAR_MAX
|
|
|
147e83 |
+# define SMALL_CHAR 127
|
|
|
147e83 |
+#else
|
|
|
147e83 |
+# include <wchar.h>
|
|
|
147e83 |
+# define MEMCHR wmemchr
|
|
|
147e83 |
+# define CHAR wchar_t
|
|
|
147e83 |
+# define UCHAR wchar_t
|
|
|
147e83 |
+# define SIMPLE_MEMCHR simple_wmemchr
|
|
|
147e83 |
+# define BIG_CHAR WCHAR_MAX
|
|
|
147e83 |
+# define SMALL_CHAR 1273
|
|
|
147e83 |
+#endif /* WIDE */
|
|
|
147e83 |
+
|
|
|
147e83 |
+typedef CHAR *(*proto_t) (const CHAR *, int, size_t);
|
|
|
147e83 |
+CHAR *SIMPLE_MEMCHR (const CHAR *, int, size_t);
|
|
|
147e83 |
+
|
|
|
147e83 |
+IMPL (SIMPLE_MEMCHR, 0)
|
|
|
147e83 |
+IMPL (MEMCHR, 1)
|
|
|
147e83 |
+
|
|
|
147e83 |
+CHAR *
|
|
|
147e83 |
+SIMPLE_MEMCHR (const CHAR *s, int c, size_t n)
|
|
|
147e83 |
{
|
|
|
147e83 |
while (n--)
|
|
|
147e83 |
- if (*s++ == (char) c)
|
|
|
147e83 |
- return (char *) s - 1;
|
|
|
147e83 |
+ if (*s++ == (CHAR) c)
|
|
|
147e83 |
+ return (CHAR *) s - 1;
|
|
|
147e83 |
return NULL;
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
static void
|
|
|
147e83 |
-do_one_test (impl_t *impl, const char *s, int c, size_t n, char *exp_res)
|
|
|
147e83 |
+do_one_test (impl_t *impl, const CHAR *s, int c, size_t n, CHAR *exp_res)
|
|
|
147e83 |
{
|
|
|
147e83 |
- char *res = CALL (impl, s, c, n);
|
|
|
147e83 |
+ CHAR *res = CALL (impl, s, c, n);
|
|
|
147e83 |
if (res != exp_res)
|
|
|
147e83 |
{
|
|
|
147e83 |
error (0, 0, "Wrong result in function %s %p %p", impl->name,
|
|
|
147e83 |
@@ -53,34 +74,36 @@ static void
|
|
|
147e83 |
do_test (size_t align, size_t pos, size_t len, int seek_char)
|
|
|
147e83 |
{
|
|
|
147e83 |
size_t i;
|
|
|
147e83 |
- char *result;
|
|
|
147e83 |
+ CHAR *result;
|
|
|
147e83 |
|
|
|
147e83 |
align &= 7;
|
|
|
147e83 |
- if (align + len >= page_size)
|
|
|
147e83 |
+ if ((align + len) * sizeof (CHAR) >= page_size)
|
|
|
147e83 |
return;
|
|
|
147e83 |
|
|
|
147e83 |
+ CHAR *buf = (CHAR *) (buf1);
|
|
|
147e83 |
+
|
|
|
147e83 |
for (i = 0; i < len; ++i)
|
|
|
147e83 |
{
|
|
|
147e83 |
- buf1[align + i] = 1 + 23 * i % 127;
|
|
|
147e83 |
- if (buf1[align + i] == seek_char)
|
|
|
147e83 |
- buf1[align + i] = seek_char + 1;
|
|
|
147e83 |
+ buf[align + i] = 1 + 23 * i % SMALL_CHAR;
|
|
|
147e83 |
+ if (buf[align + i] == seek_char)
|
|
|
147e83 |
+ buf[align + i] = seek_char + 1;
|
|
|
147e83 |
}
|
|
|
147e83 |
- buf1[align + len] = 0;
|
|
|
147e83 |
+ buf[align + len] = 0;
|
|
|
147e83 |
|
|
|
147e83 |
if (pos < len)
|
|
|
147e83 |
{
|
|
|
147e83 |
- buf1[align + pos] = seek_char;
|
|
|
147e83 |
- buf1[align + len] = -seek_char;
|
|
|
147e83 |
- result = (char *) (buf1 + align + pos);
|
|
|
147e83 |
+ buf[align + pos] = seek_char;
|
|
|
147e83 |
+ buf[align + len] = -seek_char;
|
|
|
147e83 |
+ result = (CHAR *) (buf + align + pos);
|
|
|
147e83 |
}
|
|
|
147e83 |
else
|
|
|
147e83 |
{
|
|
|
147e83 |
result = NULL;
|
|
|
147e83 |
- buf1[align + len] = seek_char;
|
|
|
147e83 |
+ buf[align + len] = seek_char;
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
FOR_EACH_IMPL (impl, 0)
|
|
|
147e83 |
- do_one_test (impl, (char *) (buf1 + align), seek_char, len, result);
|
|
|
147e83 |
+ do_one_test (impl, (CHAR *) (buf + align), seek_char, len, result);
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
static void
|
|
|
147e83 |
@@ -88,8 +111,8 @@ do_random_tests (void)
|
|
|
147e83 |
{
|
|
|
147e83 |
size_t i, j, n, align, pos, len;
|
|
|
147e83 |
int seek_char;
|
|
|
147e83 |
- char *result;
|
|
|
147e83 |
- unsigned char *p = buf1 + page_size - 512;
|
|
|
147e83 |
+ CHAR *result;
|
|
|
147e83 |
+ UCHAR *p = (UCHAR *) (buf1 + page_size) - 512;
|
|
|
147e83 |
|
|
|
147e83 |
for (n = 0; n < ITERATIONS; n++)
|
|
|
147e83 |
{
|
|
|
147e83 |
@@ -101,11 +124,11 @@ do_random_tests (void)
|
|
|
147e83 |
if (pos >= len)
|
|
|
147e83 |
len = pos + (random () & 7);
|
|
|
147e83 |
if (len + align >= 512)
|
|
|
147e83 |
- len = 512 - align - (random () & 7);
|
|
|
147e83 |
- seek_char = random () & 255;
|
|
|
147e83 |
+ len = 512 - align - (random () & 7);
|
|
|
147e83 |
+ seek_char = random () & BIG_CHAR;
|
|
|
147e83 |
j = len + align + 64;
|
|
|
147e83 |
if (j > 512)
|
|
|
147e83 |
- j = 512;
|
|
|
147e83 |
+ j = 512;
|
|
|
147e83 |
|
|
|
147e83 |
for (i = 0; i < j; i++)
|
|
|
147e83 |
{
|
|
|
147e83 |
@@ -113,7 +136,7 @@ do_random_tests (void)
|
|
|
147e83 |
p[i] = seek_char;
|
|
|
147e83 |
else
|
|
|
147e83 |
{
|
|
|
147e83 |
- p[i] = random () & 255;
|
|
|
147e83 |
+ p[i] = random () & BIG_CHAR;
|
|
|
147e83 |
if (i < pos + align && p[i] == seek_char)
|
|
|
147e83 |
p[i] = seek_char + 13;
|
|
|
147e83 |
}
|
|
|
147e83 |
@@ -124,17 +147,17 @@ do_random_tests (void)
|
|
|
147e83 |
size_t r = random ();
|
|
|
147e83 |
if ((r & 31) == 0)
|
|
|
147e83 |
len = ~(uintptr_t) (p + align) - ((r >> 5) & 31);
|
|
|
147e83 |
- result = (char *) (p + pos + align);
|
|
|
147e83 |
+ result = (CHAR *) (p + pos + align);
|
|
|
147e83 |
}
|
|
|
147e83 |
else
|
|
|
147e83 |
result = NULL;
|
|
|
147e83 |
|
|
|
147e83 |
FOR_EACH_IMPL (impl, 1)
|
|
|
147e83 |
- if (CALL (impl, (char *) (p + align), seek_char, len) != result)
|
|
|
147e83 |
+ if (CALL (impl, (CHAR *) (p + align), seek_char, len) != result)
|
|
|
147e83 |
{
|
|
|
147e83 |
error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %d, %zd, %zd) %p != %p, p %p",
|
|
|
147e83 |
n, impl->name, align, seek_char, len, pos,
|
|
|
147e83 |
- CALL (impl, (char *) (p + align), seek_char, len),
|
|
|
147e83 |
+ CALL (impl, (CHAR *) (p + align), seek_char, len),
|
|
|
147e83 |
result, p);
|
|
|
147e83 |
ret = 1;
|
|
|
147e83 |
}
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
|
|
|
147e83 |
index 2c1fce0..4a04c34 100644
|
|
|
147e83 |
--- a/sysdeps/s390/multiarch/Makefile
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/Makefile
|
|
|
147e83 |
@@ -14,7 +14,9 @@ sysdep_routines += strlen strlen-vx strlen-c \
|
|
|
147e83 |
strrchr strrchr-vx strrchr-c \
|
|
|
147e83 |
strspn strspn-vx strspn-c \
|
|
|
147e83 |
strpbrk strpbrk-vx strpbrk-c \
|
|
|
147e83 |
- strcspn strcspn-vx strcspn-c
|
|
|
147e83 |
+ strcspn strcspn-vx strcspn-c \
|
|
|
147e83 |
+ memchr memchr-vx \
|
|
|
147e83 |
+ rawmemchr rawmemchr-vx rawmemchr-c
|
|
|
147e83 |
endif
|
|
|
147e83 |
|
|
|
147e83 |
ifeq ($(subdir),wcsmbs)
|
|
|
147e83 |
@@ -33,5 +35,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \
|
|
|
147e83 |
wcsrchr wcsrchr-vx wcsrchr-c \
|
|
|
147e83 |
wcsspn wcsspn-vx wcsspn-c \
|
|
|
147e83 |
wcspbrk wcspbrk-vx wcspbrk-c \
|
|
|
147e83 |
- wcscspn wcscspn-vx wcscspn-c
|
|
|
147e83 |
+ wcscspn wcscspn-vx wcscspn-c \
|
|
|
147e83 |
+ wmemchr wmemchr-vx wmemchr-c
|
|
|
147e83 |
endif
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
147e83 |
index 7f62e49..d4c7c0d 100644
|
|
|
147e83 |
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
147e83 |
@@ -127,6 +127,10 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
147e83 |
IFUNC_VX_IMPL (strcspn);
|
|
|
147e83 |
IFUNC_VX_IMPL (wcscspn);
|
|
|
147e83 |
|
|
|
147e83 |
+ IFUNC_VX_IMPL (memchr);
|
|
|
147e83 |
+ IFUNC_VX_IMPL (wmemchr);
|
|
|
147e83 |
+ IFUNC_VX_IMPL (rawmemchr);
|
|
|
147e83 |
+
|
|
|
147e83 |
#endif /* HAVE_S390_VX_ASM_SUPPORT */
|
|
|
147e83 |
|
|
|
147e83 |
return i;
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/memchr-vx.S b/sysdeps/s390/multiarch/memchr-vx.S
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..5c98fd9
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/memchr-vx.S
|
|
|
147e83 |
@@ -0,0 +1,159 @@
|
|
|
147e83 |
+/* Vector optimized 32/64 bit S/390 version of memchr.
|
|
|
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 |
+/* void *memchr (const void *s, int c, size_t n)
|
|
|
147e83 |
+ Scans memory for character c
|
|
|
147e83 |
+ and returns pointer to first c.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ Register usage:
|
|
|
147e83 |
+ -r0=tmp
|
|
|
147e83 |
+ -r1=tmp
|
|
|
147e83 |
+ -r2=s
|
|
|
147e83 |
+ -r3=c
|
|
|
147e83 |
+ -r4=n
|
|
|
147e83 |
+ -r5=current_len
|
|
|
147e83 |
+ -v16=part of s
|
|
|
147e83 |
+ -v17=index of found c
|
|
|
147e83 |
+ -v18=c replicated
|
|
|
147e83 |
+*/
|
|
|
147e83 |
+ENTRY(__memchr_vx)
|
|
|
147e83 |
+
|
|
|
147e83 |
+ .machine "z13"
|
|
|
147e83 |
+ .machinemode "zarch_nohighgprs"
|
|
|
147e83 |
+
|
|
|
147e83 |
+# if !defined __s390x__
|
|
|
147e83 |
+ llgfr %r4,%r4
|
|
|
147e83 |
+# endif /* !defined __s390x__ */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ clgije %r4,0,.Lnf_end /* If len == 0 then exit. */
|
|
|
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 |
+ llgfr %r0,%r0 /* Convert 32bit to 64bit. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vlvgb %v18,%r3,0 /* Generate vector which elements are all c.
|
|
|
147e83 |
+ if c > 255, c will be truncated. */
|
|
|
147e83 |
+ vrepb %v18,%v18,0
|
|
|
147e83 |
+ lghi %r5,16 /* current_len = 16. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ clgrjhe %r0,%r4,.Llastcmp /* If (bytes to boundary) >= n,
|
|
|
147e83 |
+ jump to lastcmp. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vfeebs %v17,%v16,%v18 /* Find c. */
|
|
|
147e83 |
+ vlgvb %r1,%v17,7 /* Load byte index of c. */
|
|
|
147e83 |
+ clgrjl %r1,%r0,.Lfound2 /* Found c is within loaded bytes. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Align s to 16 byte. */
|
|
|
147e83 |
+ risbgn %r1,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
|
|
|
147e83 |
+ slr %r5,%r1 /* Compute bytes to 16bytes boundary. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ lgr %r0,%r5 /* If %r5 + 64 < n? -> loop64. */
|
|
|
147e83 |
+ aghi %r0,64
|
|
|
147e83 |
+ clgrjl %r0,%r4,.Lloop64
|
|
|
147e83 |
+.Llt64:
|
|
|
147e83 |
+ vl %v16,0(%r5,%r2)
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+ clgrjhe %r5,%r4,.Llastcmp /* Do last compare if curr-len >= n. */
|
|
|
147e83 |
+ vfeebs %v17,%v16,%v18 /* Find c. */
|
|
|
147e83 |
+ jl .Lfound /* Jump away if c was found. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vl %v16,0(%r5,%r2)
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+ clgrjhe %r5,%r4,.Llastcmp
|
|
|
147e83 |
+ vfeebs %v17,%v16,%v18
|
|
|
147e83 |
+ jl .Lfound
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vl %v16,0(%r5,%r2)
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+ clgrjhe %r5,%r4,.Llastcmp
|
|
|
147e83 |
+ vfeebs %v17,%v16,%v18
|
|
|
147e83 |
+ jl .Lfound
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vl %v16,0(%r5,%r2)
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Llastcmp:
|
|
|
147e83 |
+ /* Use comparision result only if located within first n characters.
|
|
|
147e83 |
+ %r5: current_len;
|
|
|
147e83 |
+ %r4: n;
|
|
|
147e83 |
+ (current_len - n): [0...16[
|
|
|
147e83 |
+ first ignored match index: vr-width - (current_len - n) ]0...16]
|
|
|
147e83 |
+ */
|
|
|
147e83 |
+ vfeebs %v17,%v16,%v18 /* Find c. */
|
|
|
147e83 |
+ slgrk %r4,%r5,%r4 /* %r5 = current_len - n. */
|
|
|
147e83 |
+ lghi %r0,16 /* Register width = 16. */
|
|
|
147e83 |
+ vlgvb %r1,%v17,7 /* Extract found index or 16 if all equal. */
|
|
|
147e83 |
+ slr %r0,%r4 /* %r0 = first ignored match index. */
|
|
|
147e83 |
+ clrjl %r1,%r0,.Lfound2 /* Go away if miscompare is below n bytes. */
|
|
|
147e83 |
+ /* c not found within n-bytes. */
|
|
|
147e83 |
+.Lnf_end:
|
|
|
147e83 |
+ lghi %r2,0 /* Return null. */
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lfound48:
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+.Lfound32:
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+.Lfound16:
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+.Lfound0:
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+.Lfound:
|
|
|
147e83 |
+ vlgvb %r1,%v17,7 /* Load byte index of c. */
|
|
|
147e83 |
+.Lfound2:
|
|
|
147e83 |
+ slgfi %r5,16 /* current_len -=16 */
|
|
|
147e83 |
+ algr %r5,%r1 /* Zero byte index is added to current len. */
|
|
|
147e83 |
+ la %r2,0(%r5,%r2) /* Return pointer to c. */
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lloop64:
|
|
|
147e83 |
+ vl %v16,0(%r5,%r2)
|
|
|
147e83 |
+ vfeebs %v17,%v16,%v18 /* Find c. */
|
|
|
147e83 |
+ jl .Lfound0 /* Jump away if c was found. */
|
|
|
147e83 |
+ vl %v16,16(%r5,%r2)
|
|
|
147e83 |
+ vfeebs %v17,%v16,%v18
|
|
|
147e83 |
+ jl .Lfound16
|
|
|
147e83 |
+ vl %v16,32(%r5,%r2)
|
|
|
147e83 |
+ vfeebs %v17,%v16,%v18
|
|
|
147e83 |
+ jl .Lfound32
|
|
|
147e83 |
+ vl %v16,48(%r5,%r2)
|
|
|
147e83 |
+ vfeebs %v17,%v16,%v18
|
|
|
147e83 |
+ jl .Lfound48
|
|
|
147e83 |
+
|
|
|
147e83 |
+ aghi %r5,64
|
|
|
147e83 |
+ lgr %r0,%r5 /* If %r5 + 64 < n? -> loop64. */
|
|
|
147e83 |
+ aghi %r0,64
|
|
|
147e83 |
+ clgrjl %r0,%r4,.Lloop64
|
|
|
147e83 |
+
|
|
|
147e83 |
+ j .Llt64
|
|
|
147e83 |
+END(__memchr_vx)
|
|
|
147e83 |
+
|
|
|
147e83 |
+# define memchr __memchr_c
|
|
|
147e83 |
+# undef libc_hidden_builtin_def
|
|
|
147e83 |
+# define libc_hidden_builtin_def(name) strong_alias(__memchr_c, __GI_memchr)
|
|
|
147e83 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#include <memchr.S>
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/memchr.c b/sysdeps/s390/multiarch/memchr.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..6624765
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/memchr.c
|
|
|
147e83 |
@@ -0,0 +1,24 @@
|
|
|
147e83 |
+/* Multiple versions of memchr.
|
|
|
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 (__memchr, memchr)
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/rawmemchr-c.c b/sysdeps/s390/multiarch/rawmemchr-c.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..f652133
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/rawmemchr-c.c
|
|
|
147e83 |
@@ -0,0 +1,34 @@
|
|
|
147e83 |
+/* Default rawmemchr 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 |
+# include <string.h>
|
|
|
147e83 |
+
|
|
|
147e83 |
+# define RAWMEMCHR __rawmemchr_c
|
|
|
147e83 |
+# undef weak_alias
|
|
|
147e83 |
+# define weak_alias(a, b)
|
|
|
147e83 |
+# ifdef SHARED
|
|
|
147e83 |
+# undef libc_hidden_def
|
|
|
147e83 |
+# define libc_hidden_def(name) \
|
|
|
147e83 |
+ __hidden_ver1 (__rawmemchr_c, __GI___rawmemchr, __rawmemchr_c);
|
|
|
147e83 |
+# endif /* SHARED */
|
|
|
147e83 |
+
|
|
|
147e83 |
+extern __typeof (rawmemchr) __rawmemchr_c attribute_hidden;
|
|
|
147e83 |
+
|
|
|
147e83 |
+# include <string/rawmemchr.c>
|
|
|
147e83 |
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/rawmemchr-vx.S b/sysdeps/s390/multiarch/rawmemchr-vx.S
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..2af4570
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/rawmemchr-vx.S
|
|
|
147e83 |
@@ -0,0 +1,92 @@
|
|
|
147e83 |
+/* Vector optimized 32/64 bit S/390 version of rawmemchr.
|
|
|
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 |
+/* void *rawmemchr (const void *s, int c)
|
|
|
147e83 |
+ Scans memory for character c
|
|
|
147e83 |
+ and returns pointer to first c.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ Register usage:
|
|
|
147e83 |
+ -r1=tmp
|
|
|
147e83 |
+ -r2=s
|
|
|
147e83 |
+ -r3=c
|
|
|
147e83 |
+ -r4=tmp
|
|
|
147e83 |
+ -r5=current_len
|
|
|
147e83 |
+ -v16=part of s
|
|
|
147e83 |
+ -v17=index of unequal
|
|
|
147e83 |
+ -v18=c replicated
|
|
|
147e83 |
+*/
|
|
|
147e83 |
+ENTRY(__rawmemchr_vx)
|
|
|
147e83 |
+ .machine "z13"
|
|
|
147e83 |
+ .machinemode "zarch_nohighgprs"
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vlbb %v16,0(%r2),6 /* Load s until next 4k-byte boundary. */
|
|
|
147e83 |
+ lcbb %r1,0(%r2),6 /* Get bytes to 4k-byte boundary or 16. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vlvgb %v18,%r3,0 /* Generate vector which elements are all c.
|
|
|
147e83 |
+ If c > 255, c will be truncated. */
|
|
|
147e83 |
+ vrepb %v18,%v18,0
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vfeeb %v17,%v16,%v18 /* Vector find element equal. */
|
|
|
147e83 |
+ vlgvb %r5,%v17,7 /* Load byte index of character or zero. */
|
|
|
147e83 |
+ clrjl %r5,%r1,.Lend_found /* If found c is in loaded bytes, end. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Align s to 16 byte. */
|
|
|
147e83 |
+ risbgn %r1,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
|
|
|
147e83 |
+ lghi %r5,16
|
|
|
147e83 |
+ slr %r5,%r1 /* Compute bytes to 16bytes boundary. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Find c in a 16byte aligned loop. */
|
|
|
147e83 |
+.Lloop:
|
|
|
147e83 |
+ vl %v16,0(%r5,%r2) /* Load s. */
|
|
|
147e83 |
+ vfeebs %v17,%v16,%v18 /* Vector find element equal. */
|
|
|
147e83 |
+ jno .Lcharacter /* Jump away if element found. */
|
|
|
147e83 |
+ vl %v16,16(%r5,%r2)
|
|
|
147e83 |
+ vfeebs %v17,%v16,%v18
|
|
|
147e83 |
+ jno .Lcharacter16
|
|
|
147e83 |
+ vl %v16,32(%r5,%r2)
|
|
|
147e83 |
+ vfeebs %v17,%v16,%v18
|
|
|
147e83 |
+ jno .Lcharacter32
|
|
|
147e83 |
+ vl %v16,48(%r5,%r2)
|
|
|
147e83 |
+ vfeebs %v17,%v16,%v18
|
|
|
147e83 |
+ jno .Lcharacter48
|
|
|
147e83 |
+
|
|
|
147e83 |
+ aghi %r5,64
|
|
|
147e83 |
+ j .Lloop /* No character found -> loop. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Found character. */
|
|
|
147e83 |
+.Lcharacter48:
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+.Lcharacter32:
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+.Lcharacter16:
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+.Lcharacter:
|
|
|
147e83 |
+ vlgvb %r1,%v17,7 /* Load byte index of character. */
|
|
|
147e83 |
+ algr %r5,%r1
|
|
|
147e83 |
+.Lend_found:
|
|
|
147e83 |
+ la %r2,0(%r5,%r2) /* Return pointer to character. */
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+END(__rawmemchr_vx)
|
|
|
147e83 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/rawmemchr.c b/sysdeps/s390/multiarch/rawmemchr.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..2335289
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/rawmemchr.c
|
|
|
147e83 |
@@ -0,0 +1,28 @@
|
|
|
147e83 |
+/* Multiple versions of rawmemchr.
|
|
|
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_ifunc (__rawmemchr)
|
|
|
147e83 |
+weak_alias (__rawmemchr, rawmemchr)
|
|
|
147e83 |
+
|
|
|
147e83 |
+#else
|
|
|
147e83 |
+# include <string/rawmemchr.c>
|
|
|
147e83 |
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT &&!defined NOT_IN_libc ) */
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/wmemchr-c.c b/sysdeps/s390/multiarch/wmemchr-c.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..d4abeb4
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/wmemchr-c.c
|
|
|
147e83 |
@@ -0,0 +1,31 @@
|
|
|
147e83 |
+/* Default wmemchr 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 WMEMCHR __wmemchr_c
|
|
|
147e83 |
+
|
|
|
147e83 |
+# include <wchar.h>
|
|
|
147e83 |
+extern __typeof (wmemchr) __wmemchr_c;
|
|
|
147e83 |
+# ifdef SHARED
|
|
|
147e83 |
+# undef libc_hidden_def
|
|
|
147e83 |
+# define libc_hidden_def(name) \
|
|
|
147e83 |
+ __hidden_ver1 (__wmemchr_c, __GI_wmemchr, __wmemchr_c);
|
|
|
147e83 |
+# endif /* SHARED */
|
|
|
147e83 |
+
|
|
|
147e83 |
+# include <wcsmbs/wmemchr.c>
|
|
|
147e83 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/wmemchr-vx.S b/sysdeps/s390/multiarch/wmemchr-vx.S
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..4df08d2
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/wmemchr-vx.S
|
|
|
147e83 |
@@ -0,0 +1,166 @@
|
|
|
147e83 |
+/* Vector optimized 32/64 bit S/390 version of wmemchr.
|
|
|
147e83 |
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
147e83 |
+ This file is part of the GNU C Library.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
+ License as published by the Free Software Foundation; either
|
|
|
147e83 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
+ Lesser General Public License for more details.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
+ License along with the GNU C Library; if not, see
|
|
|
147e83 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+#if defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc
|
|
|
147e83 |
+
|
|
|
147e83 |
+# include "sysdep.h"
|
|
|
147e83 |
+# include "asm-syntax.h"
|
|
|
147e83 |
+
|
|
|
147e83 |
+ .text
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* wchar_t *wmemchr (const wchar_t *s, wchar_t c, size_t n)
|
|
|
147e83 |
+ Scans memory for character c
|
|
|
147e83 |
+ and returns pointer to first c.
|
|
|
147e83 |
+
|
|
|
147e83 |
+ Register usage:
|
|
|
147e83 |
+ -r0=tmp
|
|
|
147e83 |
+ -r1=tmp
|
|
|
147e83 |
+ -r2=s
|
|
|
147e83 |
+ -r3=c
|
|
|
147e83 |
+ -r4=n
|
|
|
147e83 |
+ -r5=current_len
|
|
|
147e83 |
+ -v16=part of s
|
|
|
147e83 |
+ -v17=index of found c
|
|
|
147e83 |
+ -v18=c replicated
|
|
|
147e83 |
+*/
|
|
|
147e83 |
+ENTRY(__wmemchr_vx)
|
|
|
147e83 |
+ .machine "z13"
|
|
|
147e83 |
+ .machinemode "zarch_nohighgprs"
|
|
|
147e83 |
+
|
|
|
147e83 |
+# if !defined __s390x__
|
|
|
147e83 |
+ llgfr %r4,%r4
|
|
|
147e83 |
+# endif /* !defined __s390x__ */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ clgije %r4,0,.Lnf_end /* If len == 0 then exit. */
|
|
|
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 |
+ llgfr %r0,%r0 /* Convert 32bit to 64bit. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ tmll %r2,3 /* Test if s is 4-byte aligned? */
|
|
|
147e83 |
+ jne .Lfallback /* And use common-code variant if not. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vlvgf %v18,%r3,0 /* Generate vector which elements are all c. */
|
|
|
147e83 |
+ vrepf %v18,%v18,0
|
|
|
147e83 |
+ lghi %r5,16 /* current_len = 16. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Check range of maxlen and convert to byte-count. */
|
|
|
147e83 |
+# ifdef __s390x__
|
|
|
147e83 |
+ tmhh %r4,49152 /* Test bit 0 or 1 of maxlen. */
|
|
|
147e83 |
+ lghi %r1,-4 /* Max byte-count is 18446744073709551612. */
|
|
|
147e83 |
+# else
|
|
|
147e83 |
+ tmlh %r4,49152 /* Test bit 0 or 1 of maxlen. */
|
|
|
147e83 |
+ llilf %r1,4294967292 /* Max byte-count is 4294967292. */
|
|
|
147e83 |
+# endif /* !__s390x__ */
|
|
|
147e83 |
+ sllg %r4,%r4,2 /* Convert character-count to byte-count. */
|
|
|
147e83 |
+ locgrne %r4,%r1 /* Use max byte-count, if bit 0/1 was one. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ clgrjhe %r0,%r4,.Llastcmp /* If (bytes to boundary) >= n,
|
|
|
147e83 |
+ jump to lastcmp. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vfeefs %v17,%v16,%v18 /* Find c. */
|
|
|
147e83 |
+ vlgvb %r1,%v17,7 /* Load byte index of c. */
|
|
|
147e83 |
+ clgrjl %r1,%r0,.Lfound2 /* Found c is within loaded bytes. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Align s to 16 byte. */
|
|
|
147e83 |
+ risbgn %r1,%r2,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
|
|
|
147e83 |
+ slr %r5,%r1 /* Compute bytes to 16bytes boundary. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ lgr %r0,%r5 /* If %r5 + 64 < n? -> loop64. */
|
|
|
147e83 |
+ aghi %r0,64
|
|
|
147e83 |
+ clgrjl %r0,%r4,.Lloop64
|
|
|
147e83 |
+.Llt64:
|
|
|
147e83 |
+ vl %v16,0(%r5,%r2)
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+ clgrjhe %r5,%r4,.Llastcmp /* Do last compare if curr-len >= n. */
|
|
|
147e83 |
+ vfeefs %v17,%v16,%v18 /* Find c. */
|
|
|
147e83 |
+ jl .Lfound /* Jump away if c was found. */
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vl %v16,0(%r5,%r2)
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+ clgrjhe %r5,%r4,.Llastcmp
|
|
|
147e83 |
+ vfeefs %v17,%v16,%v18
|
|
|
147e83 |
+ jl .Lfound
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vl %v16,0(%r5,%r2)
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+ clgrjhe %r5,%r4,.Llastcmp
|
|
|
147e83 |
+ vfeefs %v17,%v16,%v18
|
|
|
147e83 |
+ jl .Lfound
|
|
|
147e83 |
+
|
|
|
147e83 |
+ vl %v16,0(%r5,%r2)
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Llastcmp:
|
|
|
147e83 |
+ /* Use comparision result only if located within first n characters.
|
|
|
147e83 |
+ %r5: current_len;
|
|
|
147e83 |
+ %r4: n;
|
|
|
147e83 |
+ (current_len - n): [0...16[
|
|
|
147e83 |
+ first ignored match index = vr-width - (current_len - n) ]0...16]
|
|
|
147e83 |
+ */
|
|
|
147e83 |
+ vfeefs %v17,%v16,%v18 /* Find c. */
|
|
|
147e83 |
+ slgrk %r4,%r5,%r4 /* %r5 = current_len - n. */
|
|
|
147e83 |
+ lghi %r0,16 /* Register width = 16. */
|
|
|
147e83 |
+ vlgvb %r1,%v17,7 /* Extract found index or 16 if all equal. */
|
|
|
147e83 |
+ slr %r0,%r4 /* %r0 = first ignored match index. */
|
|
|
147e83 |
+ clrjl %r1,%r0,.Lfound2 /* Go away if miscompare is below n bytes. */
|
|
|
147e83 |
+ /* c not found within n-bytes. */
|
|
|
147e83 |
+.Lnf_end:
|
|
|
147e83 |
+ lghi %r2,0 /* Return null. */
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lfound48:
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+.Lfound32:
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+.Lfound16:
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+.Lfound0:
|
|
|
147e83 |
+ aghi %r5,16
|
|
|
147e83 |
+.Lfound:
|
|
|
147e83 |
+ vlgvb %r1,%v17,7 /* Load byte index of c. */
|
|
|
147e83 |
+.Lfound2:
|
|
|
147e83 |
+ slgfi %r5,16 /* current_len -=16 */
|
|
|
147e83 |
+ algr %r5,%r1 /* Zero byte index is added to current len. */
|
|
|
147e83 |
+ la %r2,0(%r5,%r2) /* Return pointer to c. */
|
|
|
147e83 |
+ br %r14
|
|
|
147e83 |
+
|
|
|
147e83 |
+.Lloop64:
|
|
|
147e83 |
+ vl %v16,0(%r5,%r2)
|
|
|
147e83 |
+ vfeefs %v17,%v16,%v18 /* Find c. */
|
|
|
147e83 |
+ jl .Lfound0 /* Jump away if c was found. */
|
|
|
147e83 |
+ vl %v16,16(%r5,%r2)
|
|
|
147e83 |
+ vfeefs %v17,%v16,%v18
|
|
|
147e83 |
+ jl .Lfound16
|
|
|
147e83 |
+ vl %v16,32(%r5,%r2)
|
|
|
147e83 |
+ vfeefs %v17,%v16,%v18
|
|
|
147e83 |
+ jl .Lfound32
|
|
|
147e83 |
+ vl %v16,48(%r5,%r2)
|
|
|
147e83 |
+ vfeefs %v17,%v16,%v18
|
|
|
147e83 |
+ jl .Lfound48
|
|
|
147e83 |
+
|
|
|
147e83 |
+ aghi %r5,64
|
|
|
147e83 |
+ lgr %r0,%r5 /* If %r5 + 64 < n? -> loop64. */
|
|
|
147e83 |
+ aghi %r0,64
|
|
|
147e83 |
+ clgrjl %r0,%r4,.Lloop64
|
|
|
147e83 |
+
|
|
|
147e83 |
+ j .Llt64
|
|
|
147e83 |
+.Lfallback:
|
|
|
147e83 |
+ jg __wmemchr_c
|
|
|
147e83 |
+END(__wmemchr_vx)
|
|
|
147e83 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
147e83 |
diff --git a/sysdeps/s390/multiarch/wmemchr.c b/sysdeps/s390/multiarch/wmemchr.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..b8b0e83
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/multiarch/wmemchr.c
|
|
|
147e83 |
@@ -0,0 +1,27 @@
|
|
|
147e83 |
+/* Multiple versions of wmemchr.
|
|
|
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 (__wmemchr, wmemchr)
|
|
|
147e83 |
+
|
|
|
147e83 |
+#else
|
|
|
147e83 |
+# include <wcsmbs/wmemchr.c>
|
|
|
147e83 |
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
|
|
|
147e83 |
diff --git a/sysdeps/s390/s390-32/multiarch/memchr.c b/sysdeps/s390/s390-32/multiarch/memchr.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..00958cd
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/s390-32/multiarch/memchr.c
|
|
|
147e83 |
@@ -0,0 +1,21 @@
|
|
|
147e83 |
+/* Multiple versions of memchr.
|
|
|
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 |
+/* This wrapper-file is needed, because otherwise file
|
|
|
147e83 |
+ sysdeps/s390/s390-[32|64]/memchr.S will be used. */
|
|
|
147e83 |
+#include <sysdeps/s390/multiarch/memchr.c>
|
|
|
147e83 |
diff --git a/sysdeps/s390/s390-64/multiarch/memchr.c b/sysdeps/s390/s390-64/multiarch/memchr.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..00958cd
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/sysdeps/s390/s390-64/multiarch/memchr.c
|
|
|
147e83 |
@@ -0,0 +1,21 @@
|
|
|
147e83 |
+/* Multiple versions of memchr.
|
|
|
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 |
+/* This wrapper-file is needed, because otherwise file
|
|
|
147e83 |
+ sysdeps/s390/s390-[32|64]/memchr.S will be used. */
|
|
|
147e83 |
+#include <sysdeps/s390/multiarch/memchr.c>
|
|
|
147e83 |
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
|
|
|
147e83 |
index 9730b00..f8bc401 100644
|
|
|
147e83 |
--- a/wcsmbs/Makefile
|
|
|
147e83 |
+++ b/wcsmbs/Makefile
|
|
|
147e83 |
@@ -43,7 +43,7 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
|
|
|
147e83 |
|
|
|
147e83 |
strop-tests := wcscmp wcsncmp wmemcmp wcslen wcschr wcsrchr wcscpy wcsnlen \
|
|
|
147e83 |
wcpcpy wcsncpy wcpncpy wcscat wcsncat wcschrnul wcsspn wcspbrk \
|
|
|
147e83 |
- wcscspn
|
|
|
147e83 |
+ wcscspn wmemchr
|
|
|
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-wmemchr-ifunc.c b/wcsmbs/test-wmemchr-ifunc.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..4b40871
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/wcsmbs/test-wmemchr-ifunc.c
|
|
|
147e83 |
@@ -0,0 +1,20 @@
|
|
|
147e83 |
+/* Test and measure IFUNC implementations of wmemchr 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-wmemchr.c"
|
|
|
147e83 |
diff --git a/wcsmbs/test-wmemchr.c b/wcsmbs/test-wmemchr.c
|
|
|
147e83 |
new file mode 100644
|
|
|
147e83 |
index 0000000..90c7f68
|
|
|
147e83 |
--- /dev/null
|
|
|
147e83 |
+++ b/wcsmbs/test-wmemchr.c
|
|
|
147e83 |
@@ -0,0 +1,20 @@
|
|
|
147e83 |
+/* Test wmemchr 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-memchr.c"
|
|
|
147e83 |
diff --git a/wcsmbs/wmemchr.c b/wcsmbs/wmemchr.c
|
|
|
147e83 |
index 99ebed4..905a321 100644
|
|
|
147e83 |
--- a/wcsmbs/wmemchr.c
|
|
|
147e83 |
+++ b/wcsmbs/wmemchr.c
|
|
|
147e83 |
@@ -18,6 +18,10 @@
|
|
|
147e83 |
|
|
|
147e83 |
#include <wchar.h>
|
|
|
147e83 |
|
|
|
147e83 |
+#ifdef WMEMCHR
|
|
|
147e83 |
+# define wmemchr WMEMCHR
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
+
|
|
|
147e83 |
wchar_t *
|
|
|
147e83 |
wmemchr (s, c, n)
|
|
|
147e83 |
register const wchar_t *s;
|
|
|
147e83 |
--
|
|
|
147e83 |
2.3.0
|
|
|
147e83 |
|