Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / powerpc / power6 / wcscpy.c
blob417ec72ac9e3752a3eca107ce4d30bbc3cc29233
1 /* wcscpy.c - Wide Character Copy for POWER6+.
2 Copyright (C) 2012-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, see <http://www.gnu.org/licenses/>. */
19 #include <stddef.h>
20 #include <wchar.h>
22 #ifndef WCSCPY
23 # define WCSCPY wcscpy
24 #endif
26 /* Copy SRC to DEST. */
27 wchar_t *
28 WCSCPY (wchar_t *dest, const wchar_t *src)
30 wint_t c,d;
31 wchar_t *wcp, *wcp2;
33 if (__alignof__ (wchar_t) >= sizeof (wchar_t))
35 const ptrdiff_t off = dest - src;
37 wcp = (wchar_t *) src;
38 wcp2 = wcp + 1 ;
42 d = *wcp;
43 wcp[off] = d;
44 if (d == L'\0')
45 return dest;
46 wcp += 2;
48 c = *wcp2;
49 wcp2[off] = c;
50 if (c == L'\0')
51 return dest;
52 wcp2 += 2;
54 d = *wcp;
55 wcp[off] = d;
56 if (d == L'\0')
57 return dest;
58 wcp += 2;
60 c = *wcp2;
61 wcp2[off] = c;
62 if (c == L'\0')
63 return dest;
64 wcp2 += 2;
66 d = *wcp;
67 wcp[off] = d;
68 if (d == L'\0')
69 return dest;
70 wcp += 2;
72 c = *wcp2;
73 wcp2[off] = c;
74 if (c == L'\0')
75 return dest;
76 wcp2 += 2;
78 d = *wcp;
79 wcp[off] = d;
80 if (d == L'\0')
81 return dest;
82 wcp += 2;
84 c = *wcp2;
85 wcp2[off] = c;
86 if (c == L'\0')
87 return dest;
88 wcp2 += 2;
90 while (c != L'\0');
93 else
95 wcp = dest;
99 c = *src++;
100 *wcp++ = c;
102 while (c != L'\0');
104 return dest;