about summary refs log tree commit diff
path: root/wcsmbs
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-03-12 09:33:03 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-04-04 16:01:14 +0700
commit7ba0100c6a7f933d32648b7df5d03cb4d75fe301 (patch)
tree24d3da022d621eb1cbd09bb6774b7d612cf64fe3 /wcsmbs
parent447a1306c3db3fd27be751928cea6892a5867af8 (diff)
downloadglibc-7ba0100c6a7f933d32648b7df5d03cb4d75fe301.tar.gz
glibc-7ba0100c6a7f933d32648b7df5d03cb4d75fe301.tar.xz
glibc-7ba0100c6a7f933d32648b7df5d03cb4d75fe301.zip
wcsmbs: Use loop_unroll on wcschr
This allows an architecture to set explicit loop unrolling.

Checked on aarch64-linux-gnu.

	* wcsmbs/wcschr.c (WCSCHR): Use loop_unroll.h to parametrize
	the loop unroll.
Diffstat (limited to 'wcsmbs')
-rw-r--r--wcsmbs/wcschr.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/wcsmbs/wcschr.c b/wcsmbs/wcschr.c
index cd66b2a58c..6ed7916022 100644
--- a/wcsmbs/wcschr.c
+++ b/wcsmbs/wcschr.c
@@ -16,6 +16,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <wchar.h>
+#include <loop_unroll.h>
 
 #ifndef WCSCHR
 # define WCSCHR __wcschr
@@ -25,12 +26,23 @@
 wchar_t *
 WCSCHR (const wchar_t *wcs, const wchar_t wc)
 {
-  do
-    if (*wcs == wc)
-      return (wchar_t *) wcs;
-  while (*wcs++ != L'\0');
+  wchar_t *dest = NULL;
 
-  return NULL;
+#define ITERATION(index)		\
+  ({					\
+    if (*wcs == wc)			\
+      dest = (wchar_t*) wcs;		\
+    dest == NULL && *wcs++ != L'\0';	\
+  })
+
+#ifndef UNROLL_NTIMES
+# define UNROLL_NTIMES 1
+#endif
+
+  while (1)
+    UNROLL_REPEAT (UNROLL_NTIMES, ITERATION);
+
+  return dest;
 }
 libc_hidden_def (__wcschr)
 weak_alias (__wcschr, wcschr)