From e3fd0b0e93a7b49a2f26640633fb2643c460ff4a Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Mon, 11 Mar 2019 23:39:15 -0300 Subject: wcsmbs: Add wcscpy loop unroll option This allows an architecture to use the old generic implementation and also set explicit loop unrolling. Checked on aarch64-linux-gnu. * include/loop_unroll.h: New file. * wcsmbs/wcscpy (__wcscpy): Add option to use loop unrolling besides generic implementation. --- wcsmbs/wcscpy.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'wcsmbs/wcscpy.c') diff --git a/wcsmbs/wcscpy.c b/wcsmbs/wcscpy.c index 6fb2969513..36c001f69a 100644 --- a/wcsmbs/wcscpy.c +++ b/wcsmbs/wcscpy.c @@ -17,6 +17,7 @@ . */ #include +#include #ifdef WCSCPY @@ -27,7 +28,25 @@ wchar_t * __wcscpy (wchar_t *dest, const wchar_t *src) { +#ifndef UNROLL_NTIMES return __wmemcpy (dest, src, __wcslen (src) + 1); +#else + /* Some architectures might have costly tail function call (powerpc + for instance) where wmemcpy call overhead for smalls sizes might + be more costly than just unrolling the main loop. */ + wchar_t *wcp = dest; + +#define ITERATION(index) \ + ({ \ + wchar_t c = *src++; \ + *wcp++ = c; \ + c != L'\0'; \ + }) + + while (1) + UNROLL_REPEAT(UNROLL_NTIMES, ITERATION); + return dest; +#endif } #ifndef WCSCPY weak_alias (__wcscpy, wcscpy) -- cgit 1.4.1