aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-03-12 10:05:49 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-04-04 16:01:14 +0700
commit662c2cc4e9f00ffc789b636db18617538b4d9051 (patch)
tree5874484f3480801c376bfdc2c1a1bf8e13cfe77e
parent421e3005ca16627f4fefc51956811c1ca74377f6 (diff)
downloadglibc-662c2cc4e9f00ffc789b636db18617538b4d9051.tar
glibc-662c2cc4e9f00ffc789b636db18617538b4d9051.tar.gz
glibc-662c2cc4e9f00ffc789b636db18617538b4d9051.tar.bz2
glibc-662c2cc4e9f00ffc789b636db18617538b4d9051.zip
wcsmbs: Use loop_unroll on wcsrchr
This allows an architecture to set explicit loop unrolling. Checked on aarch64-linux-gnu. * wcsmbs/wcsrchr.c (WCSRCHR): Use loop_unroll.h to parametrize the loop unroll.
-rw-r--r--ChangeLog3
-rw-r--r--wcsmbs/wcsrchr.c22
2 files changed, 19 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 33ea5d5304..c633bc581f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2019-04-04 Adhemerval Zanella <adhemerval.zanella@linaro.org>
+ * wcsmbs/wcsrchr.c (WCSRCHR): Use loop_unroll.h to parametrize
+ the loop unroll.
+
* sysdeps/powerpc/Makefile [$(subdir) == wcsmbs] (CFLAGS-wcschr.c):
New rule.
* sysdeps/powerpc/power6/wcschr.c: Remove file.
diff --git a/wcsmbs/wcsrchr.c b/wcsmbs/wcsrchr.c
index 0d4bad0704..7679534180 100644
--- a/wcsmbs/wcsrchr.c
+++ b/wcsmbs/wcsrchr.c
@@ -17,6 +17,7 @@
<http://www.gnu.org/licenses/>. */
#include <wchar.h>
+#include <loop_unroll.h>
#ifndef WCSRCHR
# define WCSRCHR wcsrchr
@@ -26,12 +27,21 @@
wchar_t *
WCSRCHR (const wchar_t *wcs, const wchar_t wc)
{
- const wchar_t *retval = NULL;
+ wchar_t *retval = NULL;
- do
- if (*wcs == wc)
- retval = wcs;
- while (*wcs++ != L'\0');
+#define ITERATION(index) \
+ ({ \
+ if (*wcs == wc) \
+ retval = (wchar_t*) wcs; \
+ *wcs++ != L'\0'; \
+ })
- return (wchar_t *) retval;
+#ifndef UNROLL_NTIMES
+# define UNROLL_NTIMES 1
+#endif
+
+ while (1)
+ UNROLL_REPEAT (UNROLL_NTIMES, ITERATION);
+
+ return retval;
}