diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2019-03-11 23:39:15 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2019-04-04 16:01:10 +0700 |
commit | e3fd0b0e93a7b49a2f26640633fb2643c460ff4a (patch) | |
tree | 56a9c07a5330c18e39e9b53b39a7c5acbd91713c /wcsmbs | |
parent | 8260f23616c1a2a4e609f989a195fba7690a42ca (diff) | |
download | glibc-e3fd0b0e93a7b49a2f26640633fb2643c460ff4a.tar.gz glibc-e3fd0b0e93a7b49a2f26640633fb2643c460ff4a.tar.xz glibc-e3fd0b0e93a7b49a2f26640633fb2643c460ff4a.zip |
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.
Diffstat (limited to 'wcsmbs')
-rw-r--r-- | wcsmbs/wcscpy.c | 19 |
1 files changed, 19 insertions, 0 deletions
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 @@ <http://www.gnu.org/licenses/>. */ #include <wchar.h> +#include <loop_unroll.h> #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) |