From 7ba0100c6a7f933d32648b7df5d03cb4d75fe301 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Tue, 12 Mar 2019 09:33:03 -0300 Subject: [PATCH] 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. --- ChangeLog | 3 +++ wcsmbs/wcschr.c | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index db83b9e..3671de0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2019-04-04 Adhemerval Zanella + * 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. diff --git a/wcsmbs/wcschr.c b/wcsmbs/wcschr.c index cd66b2a..6ed7916 100644 --- a/wcsmbs/wcschr.c +++ b/wcsmbs/wcschr.c @@ -16,6 +16,7 @@ . */ #include +#include #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) -- 2.7.4