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