Skip to content

Commit

Permalink
wcsmbs: Use loop_unroll on wcschr
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zatrazz committed Apr 4, 2019
1 parent 447a130 commit 7ba0100
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2019-04-04 Adhemerval Zanella <[email protected]>

* 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.
Expand Down
22 changes: 17 additions & 5 deletions wcsmbs/wcschr.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<http://www.gnu.org/licenses/>. */

#include <wchar.h>
#include <loop_unroll.h>

#ifndef WCSCHR
# define WCSCHR __wcschr
Expand All @@ -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)
Expand Down

0 comments on commit 7ba0100

Please sign in to comment.