2019-01-01 08:11:28 +08:00
|
|
|
/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
|
1997-01-26 13:33:35 +08:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 12:58:11 +08:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1997-01-26 13:33:35 +08:00
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 12:58:11 +08:00
|
|
|
Lesser General Public License for more details.
|
1997-01-26 13:33:35 +08:00
|
|
|
|
2001-07-06 12:58:11 +08:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-10 07:18:22 +08:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1996-02-08 18:00:34 +08:00
|
|
|
|
2003-02-02 04:53:16 +08:00
|
|
|
#include <wchar.h>
|
2019-03-12 10:39:15 +08:00
|
|
|
#include <loop_unroll.h>
|
1996-02-08 18:00:34 +08:00
|
|
|
|
|
|
|
|
2019-02-06 03:35:12 +08:00
|
|
|
#ifdef WCSCPY
|
|
|
|
# define __wcscpy WCSCPY
|
2013-10-14 22:43:31 +08:00
|
|
|
#endif
|
|
|
|
|
1996-02-08 18:00:34 +08:00
|
|
|
/* Copy SRC to DEST. */
|
|
|
|
wchar_t *
|
2019-02-06 03:35:12 +08:00
|
|
|
__wcscpy (wchar_t *dest, const wchar_t *src)
|
1996-02-08 18:00:34 +08:00
|
|
|
{
|
2019-03-12 10:39:15 +08:00
|
|
|
#ifndef UNROLL_NTIMES
|
2019-02-06 04:32:03 +08:00
|
|
|
return __wmemcpy (dest, src, __wcslen (src) + 1);
|
2019-03-12 10:39:15 +08:00
|
|
|
#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
|
1996-02-08 18:00:34 +08:00
|
|
|
}
|
2019-02-06 03:35:12 +08:00
|
|
|
#ifndef WCSCPY
|
|
|
|
weak_alias (__wcscpy, wcscpy)
|
|
|
|
libc_hidden_def (__wcscpy)
|
|
|
|
#endif
|