|
|
bca718 |
From 712d46fa89e1341b3bffc27ca2ab5d892e4b14e1 Mon Sep 17 00:00:00 2001
|
|
|
bca718 |
From: Stefan Liebler <stli@linux.vnet.ibm.com>
|
|
|
bca718 |
Date: Thu, 8 Oct 2015 11:16:05 +0200
|
|
|
bca718 |
Subject: [PATCH 17/30] S390: Optimize strncat wcsncat.
|
|
|
bca718 |
|
|
|
bca718 |
upstream-commit-id: e1fe91180e4e29549f35f8ecd705b0bb4f208606
|
|
|
bca718 |
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00162.html
|
|
|
bca718 |
|
|
|
bca718 |
This patch provides optimized versions of strncat and wcsncat with the z13
|
|
|
bca718 |
vector instructions.
|
|
|
bca718 |
|
|
|
bca718 |
ChangeLog:
|
|
|
bca718 |
|
|
|
bca718 |
* sysdeps/s390/multiarch/strncat-c.c: New File.
|
|
|
bca718 |
* sysdeps/s390/multiarch/strncat-vx.S: Likewise.
|
|
|
bca718 |
* sysdeps/s390/multiarch/strncat.c: Likewise.
|
|
|
bca718 |
* sysdeps/s390/multiarch/wcsncat-c.c: Likewise.
|
|
|
bca718 |
* sysdeps/s390/multiarch/wcsncat-vx.S: Likewise.
|
|
|
bca718 |
* sysdeps/s390/multiarch/wcsncat.c: Likewise.
|
|
|
bca718 |
* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add strncat and
|
|
|
bca718 |
wcsncat functions.
|
|
|
bca718 |
* sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bca718 |
(__libc_ifunc_impl_list): Add ifunc test for strncat, wcsncat.
|
|
|
bca718 |
* wcsmbs/wcsncat.c (WCSNCAT): Define and use macro.
|
|
|
bca718 |
* string/test-strncat.c: Add wcsncat support.
|
|
|
bca718 |
* wcsmbs/test-wcsncat.c: New File.
|
|
|
bca718 |
* wcsmbs/Makefile (strop-tests): Add wcsncat.
|
|
|
bca718 |
* benchtests/bench-strncat.c: Add wcsncat support.
|
|
|
bca718 |
* benchtests/bench-wcsncat.c: New File.
|
|
|
bca718 |
* benchtests/Makefile (wcsmbs-bench): Add wcsncat.
|
|
|
bca718 |
---
|
|
|
bca718 |
benchtests/Makefile | 2 +-
|
|
|
bca718 |
benchtests/bench-strncat.c | 99 +++++++-----
|
|
|
bca718 |
benchtests/bench-wcsncat.c | 20 +++
|
|
|
bca718 |
string/test-strncat.c | 132 +++++++++------
|
|
|
bca718 |
sysdeps/s390/multiarch/Makefile | 6 +-
|
|
|
bca718 |
sysdeps/s390/multiarch/ifunc-impl-list.c | 3 +
|
|
|
bca718 |
sysdeps/s390/multiarch/strncat-c.c | 23 +++
|
|
|
bca718 |
sysdeps/s390/multiarch/strncat-vx.S | 239 ++++++++++++++++++++++++++++
|
|
|
bca718 |
sysdeps/s390/multiarch/strncat.c | 27 ++++
|
|
|
bca718 |
sysdeps/s390/multiarch/wcsncat-c.c | 25 +++
|
|
|
bca718 |
sysdeps/s390/multiarch/wcsncat-vx.S | 265 +++++++++++++++++++++++++++++++
|
|
|
bca718 |
sysdeps/s390/multiarch/wcsncat.c | 27 ++++
|
|
|
bca718 |
wcsmbs/Makefile | 2 +-
|
|
|
bca718 |
wcsmbs/test-wcsncat-ifunc.c | 20 +++
|
|
|
bca718 |
wcsmbs/test-wcsncat.c | 20 +++
|
|
|
bca718 |
wcsmbs/wcsncat.c | 5 +-
|
|
|
bca718 |
16 files changed, 823 insertions(+), 92 deletions(-)
|
|
|
bca718 |
create mode 100644 benchtests/bench-wcsncat.c
|
|
|
bca718 |
create mode 100644 sysdeps/s390/multiarch/strncat-c.c
|
|
|
bca718 |
create mode 100644 sysdeps/s390/multiarch/strncat-vx.S
|
|
|
bca718 |
create mode 100644 sysdeps/s390/multiarch/strncat.c
|
|
|
bca718 |
create mode 100644 sysdeps/s390/multiarch/wcsncat-c.c
|
|
|
bca718 |
create mode 100644 sysdeps/s390/multiarch/wcsncat-vx.S
|
|
|
bca718 |
create mode 100644 sysdeps/s390/multiarch/wcsncat.c
|
|
|
bca718 |
create mode 100644 wcsmbs/test-wcsncat-ifunc.c
|
|
|
bca718 |
create mode 100644 wcsmbs/test-wcsncat.c
|
|
|
bca718 |
|
|
|
bca718 |
diff --git a/benchtests/Makefile b/benchtests/Makefile
|
|
|
bca718 |
index 91db23c..fd8b7ee 100644
|
|
|
bca718 |
--- a/benchtests/Makefile
|
|
|
bca718 |
+++ b/benchtests/Makefile
|
|
|
bca718 |
@@ -38,7 +38,7 @@ string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
|
|
|
bca718 |
strcat strchr strchrnul strcmp strcpy strcspn strlen \
|
|
|
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
|
|
|
bca718 |
+wcsmbs-bench := wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat
|
|
|
bca718 |
string-bench-all := $(string-bench) ${wcsmbs-bench}
|
|
|
bca718 |
|
|
|
bca718 |
stdlib-bench := strtod
|
|
|
bca718 |
diff --git a/benchtests/bench-strncat.c b/benchtests/bench-strncat.c
|
|
|
bca718 |
index 2a17817..8f3339d 100644
|
|
|
bca718 |
--- a/benchtests/bench-strncat.c
|
|
|
bca718 |
+++ b/benchtests/bench-strncat.c
|
|
|
bca718 |
@@ -1,5 +1,5 @@
|
|
|
bca718 |
/* Measure strncat functions.
|
|
|
bca718 |
- Copyright (C) 2013 Free Software Foundation, Inc.
|
|
|
bca718 |
+ Copyright (C) 2013-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 |
@@ -17,33 +17,58 @@
|
|
|
bca718 |
<http://www.gnu.org/licenses/>. */
|
|
|
bca718 |
|
|
|
bca718 |
#define TEST_MAIN
|
|
|
bca718 |
-#define TEST_NAME "strncat"
|
|
|
bca718 |
+#ifndef WIDE
|
|
|
bca718 |
+# define TEST_NAME "strncat"
|
|
|
bca718 |
+#else
|
|
|
bca718 |
+# define TEST_NAME "wcsncat"
|
|
|
bca718 |
+#endif /* WIDE */
|
|
|
bca718 |
#include "bench-string.h"
|
|
|
bca718 |
|
|
|
bca718 |
-typedef char *(*proto_t) (char *, const char *, size_t);
|
|
|
bca718 |
-char *stupid_strncat (char *, const char *, size_t);
|
|
|
bca718 |
-char *simple_strncat (char *, const char *, size_t);
|
|
|
bca718 |
-
|
|
|
bca718 |
-IMPL (stupid_strncat, 0)
|
|
|
bca718 |
-IMPL (strncat, 2)
|
|
|
bca718 |
-
|
|
|
bca718 |
-char *
|
|
|
bca718 |
-stupid_strncat (char *dst, const char *src, size_t n)
|
|
|
bca718 |
+#ifndef WIDE
|
|
|
bca718 |
+# define STRNCAT strncat
|
|
|
bca718 |
+# define CHAR char
|
|
|
bca718 |
+# define SIMPLE_STRNCAT simple_strncat
|
|
|
bca718 |
+# define STUPID_STRNCAT stupid_strncat
|
|
|
bca718 |
+# define STRLEN strlen
|
|
|
bca718 |
+# define MEMCMP memcmp
|
|
|
bca718 |
+# define BIG_CHAR CHAR_MAX
|
|
|
bca718 |
+# define SMALL_CHAR 127
|
|
|
bca718 |
+#else
|
|
|
bca718 |
+# include <wchar.h>
|
|
|
bca718 |
+# define STRNCAT wcsncat
|
|
|
bca718 |
+# define CHAR wchar_t
|
|
|
bca718 |
+# define SIMPLE_STRNCAT simple_wcsncat
|
|
|
bca718 |
+# define STUPID_STRNCAT stupid_wcsncat
|
|
|
bca718 |
+# define STRLEN wcslen
|
|
|
bca718 |
+# define MEMCMP wmemcmp
|
|
|
bca718 |
+# define BIG_CHAR WCHAR_MAX
|
|
|
bca718 |
+# define SMALL_CHAR 1273
|
|
|
bca718 |
+#endif /* WIDE */
|
|
|
bca718 |
+
|
|
|
bca718 |
+typedef CHAR *(*proto_t) (CHAR *, const CHAR *, size_t);
|
|
|
bca718 |
+CHAR *STUPID_STRNCAT (CHAR *, const CHAR *, size_t);
|
|
|
bca718 |
+CHAR *SIMPLE_STRNCAT (CHAR *, const CHAR *, size_t);
|
|
|
bca718 |
+
|
|
|
bca718 |
+IMPL (STUPID_STRNCAT, 0)
|
|
|
bca718 |
+IMPL (STRNCAT, 2)
|
|
|
bca718 |
+
|
|
|
bca718 |
+CHAR *
|
|
|
bca718 |
+STUPID_STRNCAT (CHAR *dst, const CHAR *src, size_t n)
|
|
|
bca718 |
{
|
|
|
bca718 |
- char *ret = dst;
|
|
|
bca718 |
+ CHAR *ret = dst;
|
|
|
bca718 |
while (*dst++ != '\0');
|
|
|
bca718 |
--dst;
|
|
|
bca718 |
while (n--)
|
|
|
bca718 |
- if ( (*dst++ = *src++) == '\0')
|
|
|
bca718 |
+ if ((*dst++ = *src++) == '\0')
|
|
|
bca718 |
return ret;
|
|
|
bca718 |
*dst = '\0';
|
|
|
bca718 |
return ret;
|
|
|
bca718 |
}
|
|
|
bca718 |
|
|
|
bca718 |
static void
|
|
|
bca718 |
-do_one_test (impl_t *impl, char *dst, const char *src, size_t n)
|
|
|
bca718 |
+do_one_test (impl_t *impl, CHAR *dst, const CHAR *src, size_t n)
|
|
|
bca718 |
{
|
|
|
bca718 |
- size_t k = strlen (dst), i, iters = INNER_LOOP_ITERS;
|
|
|
bca718 |
+ size_t k = STRLEN (dst), i, iters = INNER_LOOP_ITERS;
|
|
|
bca718 |
timing_t start, stop, cur;
|
|
|
bca718 |
|
|
|
bca718 |
if (CALL (impl, dst, src, n) != dst)
|
|
|
bca718 |
@@ -54,10 +79,10 @@ do_one_test (impl_t *impl, char *dst, const char *src, size_t n)
|
|
|
bca718 |
return;
|
|
|
bca718 |
}
|
|
|
bca718 |
|
|
|
bca718 |
- size_t len = strlen (src);
|
|
|
bca718 |
- if (memcmp (dst + k, src, len + 1 > n ? n : len + 1) != 0)
|
|
|
bca718 |
+ size_t len = STRLEN (src);
|
|
|
bca718 |
+ if (MEMCMP (dst + k, src, len + 1 > n ? n : len + 1) != 0)
|
|
|
bca718 |
{
|
|
|
bca718 |
- error (0, 0, "Incorrect cancatination in function %s",
|
|
|
bca718 |
+ error (0, 0, "Incorrect concatenation in function %s",
|
|
|
bca718 |
impl->name);
|
|
|
bca718 |
ret = 1;
|
|
|
bca718 |
return;
|
|
|
bca718 |
@@ -88,20 +113,20 @@ do_test (size_t align1, size_t align2, size_t len1, size_t len2,
|
|
|
bca718 |
size_t n, int max_char)
|
|
|
bca718 |
{
|
|
|
bca718 |
size_t i;
|
|
|
bca718 |
- char *s1, *s2;
|
|
|
bca718 |
+ CHAR *s1, *s2;
|
|
|
bca718 |
|
|
|
bca718 |
align1 &= 7;
|
|
|
bca718 |
- if (align1 + len1 >= page_size)
|
|
|
bca718 |
+ if ((align1 + len1) * sizeof (CHAR) >= page_size)
|
|
|
bca718 |
return;
|
|
|
bca718 |
- if (align1 + n > page_size)
|
|
|
bca718 |
+ if ((align1 + n) * sizeof (CHAR) > page_size)
|
|
|
bca718 |
return;
|
|
|
bca718 |
align2 &= 7;
|
|
|
bca718 |
- if (align2 + len1 + len2 >= page_size)
|
|
|
bca718 |
+ if ((align2 + len1 + len2) * sizeof (CHAR) >= page_size)
|
|
|
bca718 |
return;
|
|
|
bca718 |
- if (align2 + len1 + n > page_size)
|
|
|
bca718 |
+ if ((align2 + len1 + n) * sizeof (CHAR) > page_size)
|
|
|
bca718 |
return;
|
|
|
bca718 |
- s1 = (char *) (buf1 + align1);
|
|
|
bca718 |
- s2 = (char *) (buf2 + align2);
|
|
|
bca718 |
+ s1 = (CHAR *) (buf1) + align1;
|
|
|
bca718 |
+ s2 = (CHAR *) (buf2) + align2;
|
|
|
bca718 |
|
|
|
bca718 |
for (i = 0; i < len1; ++i)
|
|
|
bca718 |
s1[i] = 32 + 23 * i % (max_char - 32);
|
|
|
bca718 |
@@ -136,25 +161,25 @@ main (void)
|
|
|
bca718 |
|
|
|
bca718 |
for (n = 2; n <= 2048; n*=4)
|
|
|
bca718 |
{
|
|
|
bca718 |
- do_test (0, 2, 2, 2, n, 127);
|
|
|
bca718 |
- do_test (0, 0, 4, 4, n, 127);
|
|
|
bca718 |
- do_test (4, 0, 4, 4, n, 255);
|
|
|
bca718 |
- do_test (0, 0, 8, 8, n, 127);
|
|
|
bca718 |
- do_test (0, 8, 8, 8, n, 127);
|
|
|
bca718 |
+ do_test (0, 2, 2, 2, n, SMALL_CHAR);
|
|
|
bca718 |
+ do_test (0, 0, 4, 4, n, SMALL_CHAR);
|
|
|
bca718 |
+ do_test (4, 0, 4, 4, n, BIG_CHAR);
|
|
|
bca718 |
+ do_test (0, 0, 8, 8, n, SMALL_CHAR);
|
|
|
bca718 |
+ do_test (0, 8, 8, 8, n, SMALL_CHAR);
|
|
|
bca718 |
|
|
|
bca718 |
for (i = 1; i < 8; ++i)
|
|
|
bca718 |
{
|
|
|
bca718 |
- do_test (0, 0, 8 << i, 8 << i, n, 127);
|
|
|
bca718 |
- do_test (8 - i, 2 * i, 8 << i, 8 << i, n, 127);
|
|
|
bca718 |
- do_test (0, 0, 8 << i, 2 << i, n, 127);
|
|
|
bca718 |
- do_test (8 - i, 2 * i, 8 << i, 2 << i, n, 127);
|
|
|
bca718 |
+ do_test (0, 0, 8 << i, 8 << i, n, SMALL_CHAR);
|
|
|
bca718 |
+ do_test (8 - i, 2 * i, 8 << i, 8 << i, n, SMALL_CHAR);
|
|
|
bca718 |
+ do_test (0, 0, 8 << i, 2 << i, n, SMALL_CHAR);
|
|
|
bca718 |
+ do_test (8 - i, 2 * i, 8 << i, 2 << i, n, SMALL_CHAR);
|
|
|
bca718 |
}
|
|
|
bca718 |
|
|
|
bca718 |
for (i = 1; i < 8; ++i)
|
|
|
bca718 |
{
|
|
|
bca718 |
- do_test (i, 2 * i, 8 << i, 1, n, 127);
|
|
|
bca718 |
- do_test (2 * i, i, 8 << i, 1, n, 255);
|
|
|
bca718 |
- do_test (i, i, 8 << i, 10, n, 127);
|
|
|
bca718 |
+ do_test (i, 2 * i, 8 << i, 1, n, SMALL_CHAR);
|
|
|
bca718 |
+ do_test (2 * i, i, 8 << i, 1, n, BIG_CHAR);
|
|
|
bca718 |
+ do_test (i, i, 8 << i, 10, n, SMALL_CHAR);
|
|
|
bca718 |
}
|
|
|
bca718 |
}
|
|
|
bca718 |
|
|
|
bca718 |
diff --git a/benchtests/bench-wcsncat.c b/benchtests/bench-wcsncat.c
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..b9d7c3f
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/benchtests/bench-wcsncat.c
|
|
|
bca718 |
@@ -0,0 +1,20 @@
|
|
|
bca718 |
+/* Measure wcsncat 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-strncat.c"
|
|
|
bca718 |
diff --git a/string/test-strncat.c b/string/test-strncat.c
|
|
|
bca718 |
index 2bfe25f..790d8aa 100644
|
|
|
bca718 |
--- a/string/test-strncat.c
|
|
|
bca718 |
+++ b/string/test-strncat.c
|
|
|
bca718 |
@@ -17,33 +17,64 @@
|
|
|
bca718 |
<http://www.gnu.org/licenses/>. */
|
|
|
bca718 |
|
|
|
bca718 |
#define TEST_MAIN
|
|
|
bca718 |
-#define TEST_NAME "strncat"
|
|
|
bca718 |
+#ifndef WIDE
|
|
|
bca718 |
+# define TEST_NAME "strncat"
|
|
|
bca718 |
+#else
|
|
|
bca718 |
+# define TEST_NAME "wcsncat"
|
|
|
bca718 |
+#endif /* WIDE */
|
|
|
bca718 |
#include "test-string.h"
|
|
|
bca718 |
|
|
|
bca718 |
-typedef char *(*proto_t) (char *, const char *, size_t);
|
|
|
bca718 |
-char *stupid_strncat (char *, const char *, size_t);
|
|
|
bca718 |
-char *simple_strncat (char *, const char *, size_t);
|
|
|
bca718 |
+#ifndef WIDE
|
|
|
bca718 |
+# define STRNCAT strncat
|
|
|
bca718 |
+# define CHAR char
|
|
|
bca718 |
+# define UCHAR unsigned char
|
|
|
bca718 |
+# define SIMPLE_STRNCAT simple_strncat
|
|
|
bca718 |
+# define STUPID_STRNCAT stupid_strncat
|
|
|
bca718 |
+# define STRLEN strlen
|
|
|
bca718 |
+# define MEMSET memset
|
|
|
bca718 |
+# define MEMCPY memcpy
|
|
|
bca718 |
+# define MEMCMP memcmp
|
|
|
bca718 |
+# define BIG_CHAR CHAR_MAX
|
|
|
bca718 |
+# define SMALL_CHAR 127
|
|
|
bca718 |
+#else
|
|
|
bca718 |
+# include <wchar.h>
|
|
|
bca718 |
+# define STRNCAT wcsncat
|
|
|
bca718 |
+# define CHAR wchar_t
|
|
|
bca718 |
+# define UCHAR wchar_t
|
|
|
bca718 |
+# define SIMPLE_STRNCAT simple_wcsncat
|
|
|
bca718 |
+# define STUPID_STRNCAT stupid_wcsncat
|
|
|
bca718 |
+# define STRLEN wcslen
|
|
|
bca718 |
+# define MEMSET wmemset
|
|
|
bca718 |
+# define MEMCPY wmemcpy
|
|
|
bca718 |
+# define MEMCMP wmemcmp
|
|
|
bca718 |
+# define BIG_CHAR WCHAR_MAX
|
|
|
bca718 |
+# define SMALL_CHAR 1273
|
|
|
bca718 |
+#endif /* WIDE */
|
|
|
bca718 |
|
|
|
bca718 |
-IMPL (stupid_strncat, 0)
|
|
|
bca718 |
-IMPL (strncat, 2)
|
|
|
bca718 |
+typedef CHAR *(*proto_t) (CHAR *, const CHAR *, size_t);
|
|
|
bca718 |
+CHAR *STUPID_STRNCAT (CHAR *, const CHAR *, size_t);
|
|
|
bca718 |
+CHAR *SIMPLE_STRNCAT (CHAR *, const CHAR *, size_t);
|
|
|
bca718 |
|
|
|
bca718 |
-char *
|
|
|
bca718 |
-stupid_strncat (char *dst, const char *src, size_t n)
|
|
|
bca718 |
+IMPL (STUPID_STRNCAT, 0)
|
|
|
bca718 |
+IMPL (STRNCAT, 2)
|
|
|
bca718 |
+
|
|
|
bca718 |
+CHAR *
|
|
|
bca718 |
+STUPID_STRNCAT (CHAR *dst, const CHAR *src, size_t n)
|
|
|
bca718 |
{
|
|
|
bca718 |
- char *ret = dst;
|
|
|
bca718 |
+ CHAR *ret = dst;
|
|
|
bca718 |
while (*dst++ != '\0');
|
|
|
bca718 |
--dst;
|
|
|
bca718 |
while (n--)
|
|
|
bca718 |
- if ( (*dst++ = *src++) == '\0')
|
|
|
bca718 |
+ if ((*dst++ = *src++) == '\0')
|
|
|
bca718 |
return ret;
|
|
|
bca718 |
*dst = '\0';
|
|
|
bca718 |
return ret;
|
|
|
bca718 |
}
|
|
|
bca718 |
|
|
|
bca718 |
static void
|
|
|
bca718 |
-do_one_test (impl_t *impl, char *dst, const char *src, size_t n)
|
|
|
bca718 |
+do_one_test (impl_t *impl, CHAR *dst, const CHAR *src, size_t n)
|
|
|
bca718 |
{
|
|
|
bca718 |
- size_t k = strlen (dst);
|
|
|
bca718 |
+ size_t k = STRLEN (dst);
|
|
|
bca718 |
if (CALL (impl, dst, src, n) != dst)
|
|
|
bca718 |
{
|
|
|
bca718 |
error (0, 0, "Wrong result in function %s %p != %p", impl->name,
|
|
|
bca718 |
@@ -52,10 +83,10 @@ do_one_test (impl_t *impl, char *dst, const char *src, size_t n)
|
|
|
bca718 |
return;
|
|
|
bca718 |
}
|
|
|
bca718 |
|
|
|
bca718 |
- size_t len = strlen (src);
|
|
|
bca718 |
- if (memcmp (dst + k, src, len + 1 > n ? n : len + 1) != 0)
|
|
|
bca718 |
+ size_t len = STRLEN (src);
|
|
|
bca718 |
+ if (MEMCMP (dst + k, src, len + 1 > n ? n : len + 1) != 0)
|
|
|
bca718 |
{
|
|
|
bca718 |
- error (0, 0, "Incorrect cancatination in function %s",
|
|
|
bca718 |
+ error (0, 0, "Incorrect concatenation in function %s",
|
|
|
bca718 |
impl->name);
|
|
|
bca718 |
ret = 1;
|
|
|
bca718 |
return;
|
|
|
bca718 |
@@ -74,20 +105,20 @@ do_test (size_t align1, size_t align2, size_t len1, size_t len2,
|
|
|
bca718 |
size_t n, int max_char)
|
|
|
bca718 |
{
|
|
|
bca718 |
size_t i;
|
|
|
bca718 |
- char *s1, *s2;
|
|
|
bca718 |
+ CHAR *s1, *s2;
|
|
|
bca718 |
|
|
|
bca718 |
align1 &= 7;
|
|
|
bca718 |
- if (align1 + len1 >= page_size)
|
|
|
bca718 |
+ if ((align1 + len1) * sizeof (CHAR) >= page_size)
|
|
|
bca718 |
return;
|
|
|
bca718 |
- if (align1 + n > page_size)
|
|
|
bca718 |
+ if ((align1 + n) * sizeof (CHAR) > page_size)
|
|
|
bca718 |
return;
|
|
|
bca718 |
align2 &= 7;
|
|
|
bca718 |
- if (align2 + len1 + len2 >= page_size)
|
|
|
bca718 |
+ if ((align2 + len1 + len2) * sizeof (CHAR) >= page_size)
|
|
|
bca718 |
return;
|
|
|
bca718 |
- if (align2 + len1 + n > page_size)
|
|
|
bca718 |
+ if ((align2 + len1 + n) * sizeof (CHAR) > page_size)
|
|
|
bca718 |
return;
|
|
|
bca718 |
- s1 = (char *) (buf1 + align1);
|
|
|
bca718 |
- s2 = (char *) (buf2 + align2);
|
|
|
bca718 |
+ s1 = (CHAR *) (buf1) + align1;
|
|
|
bca718 |
+ s2 = (CHAR *) (buf2) + align2;
|
|
|
bca718 |
|
|
|
bca718 |
for (i = 0; i < len1; ++i)
|
|
|
bca718 |
s1[i] = 32 + 23 * i % (max_char - 32);
|
|
|
bca718 |
@@ -107,9 +138,10 @@ static void
|
|
|
bca718 |
do_random_tests (void)
|
|
|
bca718 |
{
|
|
|
bca718 |
size_t i, j, n, align1, align2, len1, len2, N;
|
|
|
bca718 |
- unsigned char *p1 = buf1 + page_size - 512;
|
|
|
bca718 |
- unsigned char *p2 = buf2 + page_size - 512;
|
|
|
bca718 |
- unsigned char *res;
|
|
|
bca718 |
+ UCHAR *p1 = (UCHAR *) (buf1 + page_size) - 512;
|
|
|
bca718 |
+ UCHAR *p2 = (UCHAR *) (buf2 + page_size) - 512;
|
|
|
bca718 |
+ UCHAR *p3 = (UCHAR *) buf1;
|
|
|
bca718 |
+ UCHAR *res;
|
|
|
bca718 |
fprintf (stdout, "Number of iterations in random test = %zd\n",
|
|
|
bca718 |
ITERATIONS);
|
|
|
bca718 |
for (n = 0; n < ITERATIONS; n++)
|
|
|
bca718 |
@@ -148,26 +180,26 @@ do_random_tests (void)
|
|
|
bca718 |
p1[i] = 0;
|
|
|
bca718 |
else
|
|
|
bca718 |
{
|
|
|
bca718 |
- p1[i] = random () & 255;
|
|
|
bca718 |
+ p1[i] = random () & BIG_CHAR;
|
|
|
bca718 |
if (i >= align1 && i < len1 + align1 && !p1[i])
|
|
|
bca718 |
- p1[i] = (random () & 127) + 3;
|
|
|
bca718 |
+ p1[i] = (random () & SMALL_CHAR) + 3;
|
|
|
bca718 |
}
|
|
|
bca718 |
}
|
|
|
bca718 |
for (i = 0; i < len2; i++)
|
|
|
bca718 |
{
|
|
|
bca718 |
- buf1[i] = random () & 255;
|
|
|
bca718 |
- if (!buf1[i])
|
|
|
bca718 |
- buf1[i] = (random () & 127) + 3;
|
|
|
bca718 |
+ p3[i] = random () & BIG_CHAR;
|
|
|
bca718 |
+ if (!p3[i])
|
|
|
bca718 |
+ p3[i] = (random () & SMALL_CHAR) + 3;
|
|
|
bca718 |
}
|
|
|
bca718 |
- buf1[len2] = 0;
|
|
|
bca718 |
+ p3[len2] = 0;
|
|
|
bca718 |
|
|
|
bca718 |
FOR_EACH_IMPL (impl, 1)
|
|
|
bca718 |
{
|
|
|
bca718 |
- memset (p2 - 64, '\1', align2 + 64);
|
|
|
bca718 |
- memset (p2 + align2 + len2 + 1, '\1', 512 - align2 - len2 - 1);
|
|
|
bca718 |
- memcpy (p2 + align2, buf1, len2 + 1);
|
|
|
bca718 |
- res = (unsigned char *) CALL (impl, (char *) (p2 + align2),
|
|
|
bca718 |
- (char *) (p1 + align1), N);
|
|
|
bca718 |
+ MEMSET (p2 - 64, '\1', align2 + 64);
|
|
|
bca718 |
+ MEMSET (p2 + align2 + len2 + 1, '\1', 512 - align2 - len2 - 1);
|
|
|
bca718 |
+ MEMCPY (p2 + align2, p3, len2 + 1);
|
|
|
bca718 |
+ res = (UCHAR *) CALL (impl, (CHAR *) (p2 + align2),
|
|
|
bca718 |
+ (CHAR *) (p1 + align1), N);
|
|
|
bca718 |
if (res != p2 + align2)
|
|
|
bca718 |
{
|
|
|
bca718 |
error (0, 0, "Iteration %zd - wrong result in function %s "
|
|
|
bca718 |
@@ -187,7 +219,7 @@ do_random_tests (void)
|
|
|
bca718 |
break;
|
|
|
bca718 |
}
|
|
|
bca718 |
}
|
|
|
bca718 |
- if (memcmp (p2 + align2, buf1, len2))
|
|
|
bca718 |
+ if (MEMCMP (p2 + align2, p3, len2))
|
|
|
bca718 |
{
|
|
|
bca718 |
error (0, 0, "Iteration %zd - garbage in string before, %s "
|
|
|
bca718 |
"(%zd, %zd, %zd, %zd, %zd)",
|
|
|
bca718 |
@@ -220,7 +252,7 @@ do_random_tests (void)
|
|
|
bca718 |
ret = 1;
|
|
|
bca718 |
}
|
|
|
bca718 |
}
|
|
|
bca718 |
- if (memcmp (p1 + align1, p2 + align2 + len2,
|
|
|
bca718 |
+ if (MEMCMP (p1 + align1, p2 + align2 + len2,
|
|
|
bca718 |
(len1 + 1) > N ? N : len1 + 1))
|
|
|
bca718 |
{
|
|
|
bca718 |
error (0, 0, "Iteration %zd - different strings, %s "
|
|
|
bca718 |
@@ -246,25 +278,25 @@ main (void)
|
|
|
bca718 |
|
|
|
bca718 |
for (n = 2; n <= 2048; n*=4)
|
|
|
bca718 |
{
|
|
|
bca718 |
- do_test (0, 2, 2, 2, n, 127);
|
|
|
bca718 |
- do_test (0, 0, 4, 4, n, 127);
|
|
|
bca718 |
- do_test (4, 0, 4, 4, n, 255);
|
|
|
bca718 |
- do_test (0, 0, 8, 8, n, 127);
|
|
|
bca718 |
- do_test (0, 8, 8, 8, n, 127);
|
|
|
bca718 |
+ do_test (0, 2, 2, 2, n, SMALL_CHAR);
|
|
|
bca718 |
+ do_test (0, 0, 4, 4, n, SMALL_CHAR);
|
|
|
bca718 |
+ do_test (4, 0, 4, 4, n, BIG_CHAR);
|
|
|
bca718 |
+ do_test (0, 0, 8, 8, n, SMALL_CHAR);
|
|
|
bca718 |
+ do_test (0, 8, 8, 8, n, SMALL_CHAR);
|
|
|
bca718 |
|
|
|
bca718 |
for (i = 1; i < 8; ++i)
|
|
|
bca718 |
{
|
|
|
bca718 |
- do_test (0, 0, 8 << i, 8 << i, n, 127);
|
|
|
bca718 |
- do_test (8 - i, 2 * i, 8 << i, 8 << i, n, 127);
|
|
|
bca718 |
- do_test (0, 0, 8 << i, 2 << i, n, 127);
|
|
|
bca718 |
- do_test (8 - i, 2 * i, 8 << i, 2 << i, n, 127);
|
|
|
bca718 |
+ do_test (0, 0, 8 << i, 8 << i, n, SMALL_CHAR);
|
|
|
bca718 |
+ do_test (8 - i, 2 * i, 8 << i, 8 << i, n, SMALL_CHAR);
|
|
|
bca718 |
+ do_test (0, 0, 8 << i, 2 << i, n, SMALL_CHAR);
|
|
|
bca718 |
+ do_test (8 - i, 2 * i, 8 << i, 2 << i, n, SMALL_CHAR);
|
|
|
bca718 |
}
|
|
|
bca718 |
|
|
|
bca718 |
for (i = 1; i < 8; ++i)
|
|
|
bca718 |
{
|
|
|
bca718 |
- do_test (i, 2 * i, 8 << i, 1, n, 127);
|
|
|
bca718 |
- do_test (2 * i, i, 8 << i, 1, n, 255);
|
|
|
bca718 |
- do_test (i, i, 8 << i, 10, n, 127);
|
|
|
bca718 |
+ do_test (i, 2 * i, 8 << i, 1, n, SMALL_CHAR);
|
|
|
bca718 |
+ do_test (2 * i, i, 8 << i, 1, n, BIG_CHAR);
|
|
|
bca718 |
+ do_test (i, i, 8 << i, 10, n, SMALL_CHAR);
|
|
|
bca718 |
}
|
|
|
bca718 |
}
|
|
|
bca718 |
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/Makefile b/sysdeps/s390/multiarch/Makefile
|
|
|
bca718 |
index 6283999..33c1398 100644
|
|
|
bca718 |
--- a/sysdeps/s390/multiarch/Makefile
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/Makefile
|
|
|
bca718 |
@@ -5,7 +5,8 @@ sysdep_routines += strlen strlen-vx strlen-c \
|
|
|
bca718 |
stpcpy stpcpy-vx stpcpy-c \
|
|
|
bca718 |
strncpy strncpy-vx \
|
|
|
bca718 |
stpncpy stpncpy-vx stpncpy-c \
|
|
|
bca718 |
- strcat strcat-vx strcat-c
|
|
|
bca718 |
+ strcat strcat-vx strcat-c \
|
|
|
bca718 |
+ strncat strncat-vx strncat-c
|
|
|
bca718 |
endif
|
|
|
bca718 |
|
|
|
bca718 |
ifeq ($(subdir),wcsmbs)
|
|
|
bca718 |
@@ -15,5 +16,6 @@ sysdep_routines += wcslen wcslen-vx wcslen-c \
|
|
|
bca718 |
wcpcpy wcpcpy-vx wcpcpy-c \
|
|
|
bca718 |
wcsncpy wcsncpy-vx wcsncpy-c \
|
|
|
bca718 |
wcpncpy wcpncpy-vx wcpncpy-c \
|
|
|
bca718 |
- wcscat wcscat-vx wcscat-c
|
|
|
bca718 |
+ wcscat wcscat-vx wcscat-c \
|
|
|
bca718 |
+ wcsncat wcsncat-vx wcsncat-c
|
|
|
bca718 |
endif
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bca718 |
index ccf4dea..1e57c0e 100644
|
|
|
bca718 |
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
|
|
|
bca718 |
@@ -100,6 +100,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
bca718 |
IFUNC_VX_IMPL (strcat);
|
|
|
bca718 |
IFUNC_VX_IMPL (wcscat);
|
|
|
bca718 |
|
|
|
bca718 |
+ IFUNC_VX_IMPL (strncat);
|
|
|
bca718 |
+ IFUNC_VX_IMPL (wcsncat);
|
|
|
bca718 |
+
|
|
|
bca718 |
#endif /* HAVE_S390_VX_ASM_SUPPORT */
|
|
|
bca718 |
|
|
|
bca718 |
return i;
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/strncat-c.c b/sysdeps/s390/multiarch/strncat-c.c
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..f90f0e0
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/strncat-c.c
|
|
|
bca718 |
@@ -0,0 +1,23 @@
|
|
|
bca718 |
+/* Default strncat 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 STRNCAT __strncat_c
|
|
|
bca718 |
+
|
|
|
bca718 |
+# include <string/strncat.c>
|
|
|
bca718 |
+#endif
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/strncat-vx.S b/sysdeps/s390/multiarch/strncat-vx.S
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..7f35696
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/strncat-vx.S
|
|
|
bca718 |
@@ -0,0 +1,239 @@
|
|
|
bca718 |
+/* Vector optimized 32/64 bit S/390 version of strncat.
|
|
|
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 |
+/* char * strncat (const char *dest, const char *src, size_t n)
|
|
|
bca718 |
+ Concatenate two strings - at most n characters of src.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ Register usage:
|
|
|
bca718 |
+ -r0=saved dest pointer for return
|
|
|
bca718 |
+ -r1=tmp
|
|
|
bca718 |
+ -r2=dest
|
|
|
bca718 |
+ -r3=src
|
|
|
bca718 |
+ -r4=n
|
|
|
bca718 |
+ -r5=current_len
|
|
|
bca718 |
+ -r6=tmp
|
|
|
bca718 |
+ -r7=tmp
|
|
|
bca718 |
+ -v16=part of src
|
|
|
bca718 |
+ -v17=index of zero
|
|
|
bca718 |
+ -v18=part of src
|
|
|
bca718 |
+ -v31=register save area for r6, r7
|
|
|
bca718 |
+*/
|
|
|
bca718 |
+ENTRY(__strncat_vx)
|
|
|
bca718 |
+ .machine "z13"
|
|
|
bca718 |
+ .machinemode "zarch_nohighgprs"
|
|
|
bca718 |
+
|
|
|
bca718 |
+# if !defined __s390x__
|
|
|
bca718 |
+ llgfr %r4,%r4
|
|
|
bca718 |
+# endif /* !defined __s390x__ */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ clgfi %r4,0
|
|
|
bca718 |
+ ber %r14 /* Nothing to do, if n == 0. */
|
|
|
bca718 |
+ lgr %r0,%r2 /* Save destination pointer for return. */
|
|
|
bca718 |
+ vlvgp %v31,%r6,%r7 /* Save registers. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* STRLEN
|
|
|
bca718 |
+ %r1 = loaded bytes (tmp)
|
|
|
bca718 |
+ %r6 = zero byte index (tmp)
|
|
|
bca718 |
+ %r2 = dst
|
|
|
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 |
+ vfenezb %v16,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ vlgvb %r5,%v16,7 /* Load zero index or 16 if not found. */
|
|
|
bca718 |
+ clrjl %r5,%r1,.Llen_end /* Found zero within 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 /* current_len = 16. */
|
|
|
bca718 |
+ slr %r5,%r1 /* Compute bytes to 16bytes boundary. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* Find zero in 16byte aligned loop. */
|
|
|
bca718 |
+.Llen_loop:
|
|
|
bca718 |
+ vl %v16,0(%r5,%r2) /* Load s. */
|
|
|
bca718 |
+ vfenezbs %v16,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ je .Llen_found /* Jump away if zero was found. */
|
|
|
bca718 |
+ vl %v16,16(%r5,%r2)
|
|
|
bca718 |
+ vfenezbs %v16,%v16,%v16
|
|
|
bca718 |
+ je .Llen_found16
|
|
|
bca718 |
+ vl %v16,32(%r5,%r2)
|
|
|
bca718 |
+ vfenezbs %v16,%v16,%v16
|
|
|
bca718 |
+ je .Llen_found32
|
|
|
bca718 |
+ vl %v16,48(%r5,%r2)
|
|
|
bca718 |
+ vfenezbs %v16,%v16,%v16
|
|
|
bca718 |
+ je .Llen_found48
|
|
|
bca718 |
+
|
|
|
bca718 |
+ aghi %r5,64
|
|
|
bca718 |
+ j .Llen_loop /* No zero -> loop. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+.Llen_found48:
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+.Llen_found32:
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+.Llen_found16:
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+.Llen_found:
|
|
|
bca718 |
+ vlgvb %r1,%v16,7 /* Load byte index of zero. */
|
|
|
bca718 |
+ algr %r5,%r1
|
|
|
bca718 |
+
|
|
|
bca718 |
+.Llen_end:
|
|
|
bca718 |
+ /* STRCPY
|
|
|
bca718 |
+ %r1 = zero byte index (tmp)
|
|
|
bca718 |
+ %r6 = loaded bytes (tmp)
|
|
|
bca718 |
+ %r3 = curr src pointer
|
|
|
bca718 |
+ %r2 = curr dst pointer
|
|
|
bca718 |
+ %r7 = border, tmp
|
|
|
bca718 |
+ */
|
|
|
bca718 |
+ la %r2,0(%r5,%r2) /* strcpy at end of dst-string. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ vlbb %v16,0(%r3),6 /* Load s until next 4k-byte boundary. */
|
|
|
bca718 |
+ lcbb %r6,0(%r3),6 /* Get bytes to 4k-byte boundary or 16. */
|
|
|
bca718 |
+ llgfr %r6,%r6 /* Convert 32bit to 64bit. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ lghi %r5,0 /* current_len = 0. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ clgrjle %r4,%r6,.Lcpy_remaining_v16 /* If n <= loaded-bytes
|
|
|
bca718 |
+ -> process remaining. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* n > loaded-byte-count. */
|
|
|
bca718 |
+ vfenezb %v17,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ vlgvb %r1,%v17,7 /* Load zero index or 16 if not found. */
|
|
|
bca718 |
+ clrjl %r1,%r6,.Lcpy_found_v16_store /* Found zero within loaded
|
|
|
bca718 |
+ bytes, copy and return. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* Align s to 16 byte. */
|
|
|
bca718 |
+ risbgn %r7,%r3,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
|
|
|
bca718 |
+ lghi %r5,15 /* current_len = 15. */
|
|
|
bca718 |
+ slr %r5,%r7 /* Compute highest index to 16byte boundary. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* Zero not found and n > loaded-byte-count. */
|
|
|
bca718 |
+ vstl %v16,%r5,0(%r2) /* Copy loaded characters - no zero. */
|
|
|
bca718 |
+ ahi %r5,1 /* Start loop at next character. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /*
|
|
|
bca718 |
+ Now we are 16byte aligned, so we can load a full vreg
|
|
|
bca718 |
+ without page fault.
|
|
|
bca718 |
+ */
|
|
|
bca718 |
+ lgr %r1,%r5 /* If %r5 + 64 < maxlen? -> loop64. */
|
|
|
bca718 |
+ aghi %r1,64
|
|
|
bca718 |
+ clgrjl %r1,%r4,.Lcpy_loop64
|
|
|
bca718 |
+
|
|
|
bca718 |
+ vl %v16,0(%r5,%r3) /* Load s. */
|
|
|
bca718 |
+ clgijl %r4,17,.Lcpy_remaining_v16 /* If n <=16,
|
|
|
bca718 |
+ process remaining bytes. */
|
|
|
bca718 |
+.Lcpy_lt64:
|
|
|
bca718 |
+ lgr %r7,%r4
|
|
|
bca718 |
+ slgfi %r7,16 /* border_len = n - 16. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* If current_len >= border then process remaining bytes. */
|
|
|
bca718 |
+ clgrjhe %r5,%r7,.Lcpy_remaining_v16
|
|
|
bca718 |
+ vfenezbs %v17,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ je .Lcpy_found_v16 /* Jump away if zero was found. */
|
|
|
bca718 |
+ vl %v18,16(%r5,%r3) /* Load next part of s. */
|
|
|
bca718 |
+ vst %v16,0(%r5,%r2) /* Store previous part without zero to dst. */
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+
|
|
|
bca718 |
+ clgrjhe %r5,%r7,.Lcpy_remaining_v18
|
|
|
bca718 |
+ vfenezbs %v17,%v18,%v18
|
|
|
bca718 |
+ je .Lcpy_found_v18
|
|
|
bca718 |
+ vl %v16,16(%r5,%r3)
|
|
|
bca718 |
+ vst %v18,0(%r5,%r2)
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+
|
|
|
bca718 |
+ clgrjhe %r5,%r7,.Lcpy_remaining_v16
|
|
|
bca718 |
+ vfenezbs %v17,%v16,%v16
|
|
|
bca718 |
+ je .Lcpy_found_v16
|
|
|
bca718 |
+ vl %v18,16(%r5,%r3)
|
|
|
bca718 |
+ vst %v16,0(%r5,%r2)
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+
|
|
|
bca718 |
+.Lcpy_remaining_v18:
|
|
|
bca718 |
+ vlr %v16,%v18
|
|
|
bca718 |
+.Lcpy_remaining_v16:
|
|
|
bca718 |
+ /* v16 contains the remaining bytes [1...16].
|
|
|
bca718 |
+ Store remaining bytes and append string-termination. */
|
|
|
bca718 |
+ vfenezb %v17,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ slgrk %r7,%r4,%r5 /* Remaining bytes = maxlen - current_len. */
|
|
|
bca718 |
+ aghi %r7,-1 /* vstl needs highest index. */
|
|
|
bca718 |
+ vlgvb %r1,%v17,7 /* Load zero index or 16 if not found. */
|
|
|
bca718 |
+ la %r2,0(%r5,%r2) /* vstl has no index register. */
|
|
|
bca718 |
+ /* Zero-index within remaining-bytes, store up to zero and end. */
|
|
|
bca718 |
+ clgrjle %r1,%r7,.Lcpy_found_v16_store
|
|
|
bca718 |
+ vstl %v16,%r7,0(%r2) /* Store remaining bytes. */
|
|
|
bca718 |
+ lghi %r1,0
|
|
|
bca718 |
+ stc %r1,1(%r7,%r2) /* Store string-null-termination beyond n. */
|
|
|
bca718 |
+.Lcpy_end:
|
|
|
bca718 |
+ /* Restore saved registers. */
|
|
|
bca718 |
+ vlgvg %r6,%v31,0
|
|
|
bca718 |
+ vlgvg %r7,%v31,1
|
|
|
bca718 |
+ lgr %r2,%r0 /* Load saved dest-ptr. */
|
|
|
bca718 |
+ br %r14
|
|
|
bca718 |
+
|
|
|
bca718 |
+.Lcpy_found_v16_32:
|
|
|
bca718 |
+ aghi %r5,32
|
|
|
bca718 |
+ j .Lcpy_found_v16
|
|
|
bca718 |
+.Lcpy_found_v18_48:
|
|
|
bca718 |
+ aghi %r5,32
|
|
|
bca718 |
+.Lcpy_found_v18_16:
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+.Lcpy_found_v18:
|
|
|
bca718 |
+ vlr %v16,%v18
|
|
|
bca718 |
+.Lcpy_found_v16:
|
|
|
bca718 |
+ /* v16 contains a zero. Store remaining bytes to zero. current_len
|
|
|
bca718 |
+ has not reached border, thus checking for n is not needed! */
|
|
|
bca718 |
+ vlgvb %r1,%v17,7 /* Load byte index of zero. */
|
|
|
bca718 |
+ la %r2,0(%r5,%r2)
|
|
|
bca718 |
+.Lcpy_found_v16_store:
|
|
|
bca718 |
+ vstl %v16,%r1,0(%r2) /* Copy characters including zero. */
|
|
|
bca718 |
+ j .Lcpy_end
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* Find zero in 16byte aligned loop. */
|
|
|
bca718 |
+.Lcpy_loop64:
|
|
|
bca718 |
+ vl %v16,0(%r5,%r3) /* Load s. */
|
|
|
bca718 |
+ vfenezbs %v17,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ je .Lcpy_found_v16 /* Jump away if zero was found. */
|
|
|
bca718 |
+ vl %v18,16(%r5,%r3) /* Load next part of s. */
|
|
|
bca718 |
+ vst %v16,0(%r5,%r2) /* Store previous part without zero to dst. */
|
|
|
bca718 |
+ vfenezbs %v17,%v18,%v18
|
|
|
bca718 |
+ je .Lcpy_found_v18_16
|
|
|
bca718 |
+ vl %v16,32(%r5,%r3)
|
|
|
bca718 |
+ vst %v18,16(%r5,%r2)
|
|
|
bca718 |
+ vfenezbs %v17,%v16,%v16
|
|
|
bca718 |
+ je .Lcpy_found_v16_32
|
|
|
bca718 |
+ vl %v18,48(%r5,%r3)
|
|
|
bca718 |
+ vst %v16,32(%r5,%r2)
|
|
|
bca718 |
+ vfenezbs %v17,%v18,%v18
|
|
|
bca718 |
+ je .Lcpy_found_v18_48
|
|
|
bca718 |
+ vst %v18,48(%r5,%r2)
|
|
|
bca718 |
+
|
|
|
bca718 |
+ aghi %r5,64
|
|
|
bca718 |
+ lgr %r1,%r5 /* If %r5 + 64 < maxlen? -> loop64. */
|
|
|
bca718 |
+ aghi %r1,64
|
|
|
bca718 |
+ clgrjl %r1,%r4,.Lcpy_loop64
|
|
|
bca718 |
+
|
|
|
bca718 |
+ vl %v16,0(%r5,%r3) /* Load s. */
|
|
|
bca718 |
+ j .Lcpy_lt64
|
|
|
bca718 |
+END(__strncat_vx)
|
|
|
bca718 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/strncat.c b/sysdeps/s390/multiarch/strncat.c
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..82e87ad
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/strncat.c
|
|
|
bca718 |
@@ -0,0 +1,27 @@
|
|
|
bca718 |
+/* Multiple versions of strncat.
|
|
|
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 (__strncat, strncat)
|
|
|
bca718 |
+
|
|
|
bca718 |
+#else
|
|
|
bca718 |
+# include <string/strncat.c>
|
|
|
bca718 |
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/wcsncat-c.c b/sysdeps/s390/multiarch/wcsncat-c.c
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..4938ef2
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/wcsncat-c.c
|
|
|
bca718 |
@@ -0,0 +1,25 @@
|
|
|
bca718 |
+/* Default wcsncat 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 WCSNCAT __wcsncat_c
|
|
|
bca718 |
+
|
|
|
bca718 |
+# include <wchar.h>
|
|
|
bca718 |
+extern __typeof (wcsncat) __wcsncat_c;
|
|
|
bca718 |
+# include <wcsmbs/wcsncat.c>
|
|
|
bca718 |
+#endif
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/wcsncat-vx.S b/sysdeps/s390/multiarch/wcsncat-vx.S
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..7e0653e
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/wcsncat-vx.S
|
|
|
bca718 |
@@ -0,0 +1,265 @@
|
|
|
bca718 |
+/* Vector optimized 32/64 bit S/390 version of wcsncat.
|
|
|
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 * wcsncat (wchar_t *dest, const wchar_t *src, size_t n)
|
|
|
bca718 |
+ Concatenate two strings - at most n characters of src.
|
|
|
bca718 |
+
|
|
|
bca718 |
+ Register usage:
|
|
|
bca718 |
+ -r0=saved dest pointer for return
|
|
|
bca718 |
+ -r1=tmp
|
|
|
bca718 |
+ -r2=dest
|
|
|
bca718 |
+ -r3=src
|
|
|
bca718 |
+ -r4=n
|
|
|
bca718 |
+ -r5=current_len
|
|
|
bca718 |
+ -r6=tmp
|
|
|
bca718 |
+ -r7=tmp
|
|
|
bca718 |
+ -v16=part of src
|
|
|
bca718 |
+ -v17=index of zero
|
|
|
bca718 |
+ -v18=part of src
|
|
|
bca718 |
+ -v31=register save area for r6, r7
|
|
|
bca718 |
+*/
|
|
|
bca718 |
+ENTRY(__wcsncat_vx)
|
|
|
bca718 |
+ .machine "z13"
|
|
|
bca718 |
+ .machinemode "zarch_nohighgprs"
|
|
|
bca718 |
+
|
|
|
bca718 |
+# if !defined __s390x__
|
|
|
bca718 |
+ llgfr %r4,%r4
|
|
|
bca718 |
+# endif /* !defined __s390x__ */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ clgfi %r4,0
|
|
|
bca718 |
+ ber %r14 /* Nothing to do, if n == 0. */
|
|
|
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 |
+ /* If either src or dest is not 4byte aligned, use __wcsncat_c. */
|
|
|
bca718 |
+ tmll %r2,3 /* Test if s is 4-byte aligned? */
|
|
|
bca718 |
+ jne .Lfallback /* And use common-code variant if not. */
|
|
|
bca718 |
+ tmll %r3,3 /* Test if src is 4-byte aligned? */
|
|
|
bca718 |
+ jne .Lfallback /* And use common-code variant if not. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ lgr %r0,%r2 /* Save destination pointer for return. */
|
|
|
bca718 |
+ vlvgp %v31,%r6,%r7 /* Save registers. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* WCSLEN
|
|
|
bca718 |
+ %r1 = loaded bytes (tmp)
|
|
|
bca718 |
+ %r6 = zero byte index (tmp)
|
|
|
bca718 |
+ %r2 = dst
|
|
|
bca718 |
+ */
|
|
|
bca718 |
+ vfenezf %v16,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ vlgvb %r5,%v16,7 /* Load zero index or 16 if not found. */
|
|
|
bca718 |
+ clrjl %r5,%r1,.Llen_end /* Found zero within 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 /* current_len = 16. */
|
|
|
bca718 |
+ slr %r5,%r1 /* Compute bytes to 16bytes boundary. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* Find zero in 16byte aligned loop. */
|
|
|
bca718 |
+.Llen_loop:
|
|
|
bca718 |
+ vl %v16,0(%r5,%r2) /* Load s. */
|
|
|
bca718 |
+ vfenezfs %v16,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ je .Llen_found /* Jump away if zero was found. */
|
|
|
bca718 |
+ vl %v16,16(%r5,%r2)
|
|
|
bca718 |
+ vfenezfs %v16,%v16,%v16
|
|
|
bca718 |
+ je .Llen_found16
|
|
|
bca718 |
+ vl %v16,32(%r5,%r2)
|
|
|
bca718 |
+ vfenezfs %v16,%v16,%v16
|
|
|
bca718 |
+ je .Llen_found32
|
|
|
bca718 |
+ vl %v16,48(%r5,%r2)
|
|
|
bca718 |
+ vfenezfs %v16,%v16,%v16
|
|
|
bca718 |
+ je .Llen_found48
|
|
|
bca718 |
+
|
|
|
bca718 |
+ aghi %r5,64
|
|
|
bca718 |
+ j .Llen_loop /* No zero -> loop. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+.Llen_found48:
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+.Llen_found32:
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+.Llen_found16:
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+.Llen_found:
|
|
|
bca718 |
+ vlgvb %r1,%v16,7 /* Load byte index of zero. */
|
|
|
bca718 |
+ algr %r5,%r1
|
|
|
bca718 |
+
|
|
|
bca718 |
+.Llen_end:
|
|
|
bca718 |
+ /* WCSNCPY
|
|
|
bca718 |
+ %r1 = zero byte index (tmp)
|
|
|
bca718 |
+ %r6 = loaded bytes (tmp)
|
|
|
bca718 |
+ %r3 = curr src pointer
|
|
|
bca718 |
+ %r2 = curr dst pointer
|
|
|
bca718 |
+ %r7 = border, tmp
|
|
|
bca718 |
+ */
|
|
|
bca718 |
+ la %r2,0(%r5,%r2) /* strcpy at end of dst-string. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ vlbb %v16,0(%r3),6 /* Load s until next 4k-byte boundary. */
|
|
|
bca718 |
+ lcbb %r6,0(%r3),6 /* Get bytes to 4k-byte boundary or 16. */
|
|
|
bca718 |
+ llgfr %r6,%r6 /* Convert 32bit to 64bit. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ lghi %r5,0 /* current_len = 0. */
|
|
|
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 |
+ clgrjle %r4,%r6,.Lcpy_remaining_v16 /* If n <= loaded-bytes
|
|
|
bca718 |
+ -> process remaining. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* n > loaded-byte-count. */
|
|
|
bca718 |
+ vfenezf %v17,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ vlgvb %r1,%v17,7 /* Load zero index or 16 if not found. */
|
|
|
bca718 |
+ clrjl %r1,%r6,.Lcpy_found_v16_store /* Found zero within loaded bytes,
|
|
|
bca718 |
+ copy and return. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* Align s to 16 byte. */
|
|
|
bca718 |
+ risbgn %r1,%r3,60,128+63,0 /* %r3 = bits 60-63 of %r2 'and' 15. */
|
|
|
bca718 |
+ lghi %r5,15 /* current_len = 15. */
|
|
|
bca718 |
+ slr %r5,%r1 /* Compute highest index to 16byte boundary. *
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* Zero not found and maxlen > loaded-byte-count. */
|
|
|
bca718 |
+ vstl %v16,%r5,0(%r2) /* Copy loaded characters - no zero. */
|
|
|
bca718 |
+ ahi %r5,1 /* Start loop at next character. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /*
|
|
|
bca718 |
+ Now we are 16byte aligned, so we can load a full vreg
|
|
|
bca718 |
+ without page fault.
|
|
|
bca718 |
+ */
|
|
|
bca718 |
+ lgr %r1,%r5 /* If %r5 + 64 < maxlen? -> loop64. */
|
|
|
bca718 |
+ aghi %r1,64
|
|
|
bca718 |
+ clgrjl %r1,%r4,.Lcpy_loop64
|
|
|
bca718 |
+
|
|
|
bca718 |
+ vl %v16,0(%r5,%r3) /* Load s. */
|
|
|
bca718 |
+ clgijl %r4,17,.Lcpy_remaining_v16 /* If n <=16,
|
|
|
bca718 |
+ process remaining bytes. */
|
|
|
bca718 |
+.Lcpy_lt64:
|
|
|
bca718 |
+ lgr %r7,%r4
|
|
|
bca718 |
+ slgfi %r7,16 /* border_len = n - 16. */
|
|
|
bca718 |
+
|
|
|
bca718 |
+ clgrjhe %r5,%r7,.Lcpy_remaining_v16
|
|
|
bca718 |
+ vfenezfs %v17,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ je .Lcpy_found_v16 /* Jump away if zero was found. */
|
|
|
bca718 |
+ vl %v18,16(%r5,%r3) /* Load next part of s. */
|
|
|
bca718 |
+ vst %v16,0(%r5,%r2) /* Save previous part without zero to dst. */
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+
|
|
|
bca718 |
+ clgrjhe %r5,%r7,.Lcpy_remaining_v18
|
|
|
bca718 |
+ vfenezfs %v17,%v18,%v18
|
|
|
bca718 |
+ je .Lcpy_found_v18
|
|
|
bca718 |
+ vl %v16,16(%r5,%r3)
|
|
|
bca718 |
+ vst %v18,0(%r5,%r2)
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+
|
|
|
bca718 |
+ clgrjhe %r5,%r7,.Lcpy_remaining_v16
|
|
|
bca718 |
+ vfenezfs %v17,%v16,%v16
|
|
|
bca718 |
+ je .Lcpy_found_v16
|
|
|
bca718 |
+ vl %v18,16(%r5,%r3)
|
|
|
bca718 |
+ vst %v16,0(%r5,%r2)
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+
|
|
|
bca718 |
+.Lcpy_remaining_v18:
|
|
|
bca718 |
+ vlr %v16,%v18
|
|
|
bca718 |
+.Lcpy_remaining_v16:
|
|
|
bca718 |
+ /* v16 contains the remaining bytes [1...16].
|
|
|
bca718 |
+ Store remaining bytes and append string-termination. */
|
|
|
bca718 |
+ vfenezf %v17,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ slgrk %r7,%r4,%r5 /* Remaining bytes = maxlen - current_len. */
|
|
|
bca718 |
+ aghi %r7,-1 /* vstl needs highest index. */
|
|
|
bca718 |
+ vlgvb %r1,%v17,7 /* Load zero index or 16 if not found. */
|
|
|
bca718 |
+ la %r2,0(%r5,%r2) /* vstl has no index register. */
|
|
|
bca718 |
+ /* Zero-index within remaining-bytes, store up to zero and end. */
|
|
|
bca718 |
+ clgrjle %r1,%r7,.Lcpy_found_v16_store
|
|
|
bca718 |
+ vstl %v16,%r7,0(%r2) /* Store remaining bytes. */
|
|
|
bca718 |
+ lghi %r1,0
|
|
|
bca718 |
+ st %r1,1(%r7,%r2) /* Store string-null-termination beyond n. */
|
|
|
bca718 |
+.Lcpy_end:
|
|
|
bca718 |
+ /* Restore saved registers. */
|
|
|
bca718 |
+ vlgvg %r6,%v31,0
|
|
|
bca718 |
+ vlgvg %r7,%v31,1
|
|
|
bca718 |
+ lgr %r2,%r0 /* Load saved dest-ptr. */
|
|
|
bca718 |
+ br %r14
|
|
|
bca718 |
+
|
|
|
bca718 |
+.Lcpy_found_v16_32:
|
|
|
bca718 |
+ aghi %r5,32
|
|
|
bca718 |
+ j .Lcpy_found_v16
|
|
|
bca718 |
+.Lcpy_found_v18_48:
|
|
|
bca718 |
+ aghi %r5,32
|
|
|
bca718 |
+.Lcpy_found_v18_16:
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+.Lcpy_found_v18:
|
|
|
bca718 |
+ vlr %v16,%v18
|
|
|
bca718 |
+.Lcpy_found_v16:
|
|
|
bca718 |
+ /* v16 contains a zero. Store remaining bytes to zero. current_len
|
|
|
bca718 |
+ has not reached border, thus checking for n is not needed! */
|
|
|
bca718 |
+ vlgvb %r1,%v17,7 /* Load byte index of zero. */
|
|
|
bca718 |
+ la %r2,0(%r5,%r2)
|
|
|
bca718 |
+.Lcpy_found_v16_store:
|
|
|
bca718 |
+ aghi %r1,3 /* Also copy remaining bytes of zero. */
|
|
|
bca718 |
+ vstl %v16,%r1,0(%r2) /* Copy characters including zero. */
|
|
|
bca718 |
+ j .Lcpy_end
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* Find zero in 16byte aligned loop. */
|
|
|
bca718 |
+.Lcpy_loop2:
|
|
|
bca718 |
+ vl %v16,16(%r5,%r3)
|
|
|
bca718 |
+ vst %v18,0(%r5,%r2)
|
|
|
bca718 |
+ aghi %r5,16
|
|
|
bca718 |
+
|
|
|
bca718 |
+.Lcpy_loop64:
|
|
|
bca718 |
+ vl %v16,0(%r5,%r3)
|
|
|
bca718 |
+ vfenezfs %v17,%v16,%v16 /* Find element not equal with zero search. */
|
|
|
bca718 |
+ je .Lcpy_found_v16 /* Jump away if zero was found. */
|
|
|
bca718 |
+ vl %v18,16(%r5,%r3) /* Load next part of s. */
|
|
|
bca718 |
+ vst %v16,0(%r5,%r2) /* Save previous part without zero to dst. */
|
|
|
bca718 |
+ vfenezfs %v17,%v18,%v18
|
|
|
bca718 |
+ je .Lcpy_found_v18_16
|
|
|
bca718 |
+ vl %v16,32(%r5,%r3)
|
|
|
bca718 |
+ vst %v18,16(%r5,%r2)
|
|
|
bca718 |
+ vfenezfs %v17,%v16,%v16
|
|
|
bca718 |
+ je .Lcpy_found_v16_32
|
|
|
bca718 |
+ vl %v18,48(%r5,%r3)
|
|
|
bca718 |
+ vst %v16,32(%r5,%r2)
|
|
|
bca718 |
+ vfenezfs %v17,%v18,%v18
|
|
|
bca718 |
+ je .Lcpy_found_v18_48
|
|
|
bca718 |
+ vst %v18,48(%r5,%r2)
|
|
|
bca718 |
+
|
|
|
bca718 |
+ aghi %r5,64
|
|
|
bca718 |
+ lgr %r1,%r5 /* If %r5 + 64 < maxlen? -> loop64. */
|
|
|
bca718 |
+ aghi %r1,64
|
|
|
bca718 |
+ clgrjl %r1,%r4,.Lcpy_loop64
|
|
|
bca718 |
+
|
|
|
bca718 |
+ vl %v16,0(%r5,%r3) /* Load s. */
|
|
|
bca718 |
+ j .Lcpy_lt64
|
|
|
bca718 |
+
|
|
|
bca718 |
+.Lfallback:
|
|
|
bca718 |
+ jg __wcsncat_c
|
|
|
bca718 |
+END(__wcsncat_vx)
|
|
|
bca718 |
+#endif /* HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc */
|
|
|
bca718 |
diff --git a/sysdeps/s390/multiarch/wcsncat.c b/sysdeps/s390/multiarch/wcsncat.c
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..621444d
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/sysdeps/s390/multiarch/wcsncat.c
|
|
|
bca718 |
@@ -0,0 +1,27 @@
|
|
|
bca718 |
+/* Multiple versions of wcsncat.
|
|
|
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 (__wcsncat, wcsncat)
|
|
|
bca718 |
+
|
|
|
bca718 |
+#else
|
|
|
bca718 |
+# include <wcsmbs/wcsncat.c>
|
|
|
bca718 |
+#endif /* !(defined HAVE_S390_VX_ASM_SUPPORT && !defined NOT_IN_libc) */
|
|
|
bca718 |
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
|
|
|
bca718 |
index 9bfc78c..44b1502 100644
|
|
|
bca718 |
--- a/wcsmbs/Makefile
|
|
|
bca718 |
+++ b/wcsmbs/Makefile
|
|
|
bca718 |
@@ -42,7 +42,7 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
|
|
|
bca718 |
mbrtoc16 c16rtomb
|
|
|
bca718 |
|
|
|
bca718 |
strop-tests := wcscmp wmemcmp wcslen wcschr wcsrchr wcscpy wcsnlen \
|
|
|
bca718 |
- wcpcpy wcsncpy wcpncpy wcscat
|
|
|
bca718 |
+ wcpcpy wcsncpy wcpncpy wcscat wcsncat
|
|
|
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-wcsncat-ifunc.c b/wcsmbs/test-wcsncat-ifunc.c
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..5497f7d
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/wcsmbs/test-wcsncat-ifunc.c
|
|
|
bca718 |
@@ -0,0 +1,20 @@
|
|
|
bca718 |
+/* Test and measure IFUNC implementations of wcsncat 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-wcsncat.c"
|
|
|
bca718 |
diff --git a/wcsmbs/test-wcsncat.c b/wcsmbs/test-wcsncat.c
|
|
|
bca718 |
new file mode 100644
|
|
|
bca718 |
index 0000000..8b91a18
|
|
|
bca718 |
--- /dev/null
|
|
|
bca718 |
+++ b/wcsmbs/test-wcsncat.c
|
|
|
bca718 |
@@ -0,0 +1,20 @@
|
|
|
bca718 |
+/* Test wcsncat 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-strncat.c"
|
|
|
bca718 |
diff --git a/wcsmbs/wcsncat.c b/wcsmbs/wcsncat.c
|
|
|
bca718 |
index 2131466..21a3a1e 100644
|
|
|
bca718 |
--- a/wcsmbs/wcsncat.c
|
|
|
bca718 |
+++ b/wcsmbs/wcsncat.c
|
|
|
bca718 |
@@ -18,10 +18,13 @@
|
|
|
bca718 |
|
|
|
bca718 |
#include <wchar.h>
|
|
|
bca718 |
|
|
|
bca718 |
+#ifndef WCSNCAT
|
|
|
bca718 |
+# define WCSNCAT wcsncat
|
|
|
bca718 |
+#endif
|
|
|
bca718 |
|
|
|
bca718 |
/* Append no more than N wide-character of SRC onto DEST. */
|
|
|
bca718 |
wchar_t *
|
|
|
bca718 |
-wcsncat (dest, src, n)
|
|
|
bca718 |
+WCSNCAT (dest, src, n)
|
|
|
bca718 |
wchar_t *dest;
|
|
|
bca718 |
const wchar_t *src;
|
|
|
bca718 |
size_t n;
|
|
|
bca718 |
--
|
|
|
bca718 |
2.3.0
|
|
|
bca718 |
|