]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
wcsmbs: Use loop_unroll on wcschr
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 12 Mar 2019 12:33:03 +0000 (09:33 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 4 Apr 2019 09:01:14 +0000 (16:01 +0700)
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.

ChangeLog
wcsmbs/wcschr.c

index db83b9e7b6e13411c5b8c51735ae8facfb0d263c..3671de05f5fdeb7214ea54063f4a5f0a10baf76d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2019-04-04  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
+       * wcsmbs/wcschr.c (WCSCHR): Use loop_unroll.h to parametrize
+       the loop unroll.
+
        * sysdeps/powerpc/Makefile [$(subdir) == wcsmbs] (CFLAGS-wcscpy.c):
        New rule.
        * sysdeps/powerpc/power6/wcscpy.c: Remove file.
index cd66b2a58c9729adc502917e1a431889c7a6a1d6..6ed7916022ef2bc43385955e6f845848f8c420e3 100644 (file)
@@ -16,6 +16,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <wchar.h>
+#include <loop_unroll.h>
 
 #ifndef WCSCHR
 # define WCSCHR __wcschr
 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)