Add versions of wcscpy, wcschr, wcsrchr for power6/power7.
[glibc.git] / sysdeps / powerpc / powerpc32 / power6 / wcscpy.c
blob9bd907788e6f2337a0bcd1e033c081757a13b63e
1 /* wcscpy.c - Wide Character Copy for powerpc32/power6.
2 Copyright (C) 2012 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>
23 /* Copy SRC to DEST. */
24 wchar_t *
25 wcscpy (dest, src)
26 wchar_t *dest;
27 const wchar_t *src;
29 wint_t c,d;
30 wchar_t *wcp, *wcp2;
32 if (__alignof__ (wchar_t) >= sizeof (wchar_t))
34 const ptrdiff_t off = dest - src;
36 wcp = (wchar_t *) src;
37 wcp2 = wcp + 1 ;
41 d = *wcp;
42 wcp[off] = d;
43 if (d == L'\0')
44 return dest;
45 wcp += 2;
47 c = *wcp2;
48 wcp2[off] = c;
49 if (c == L'\0')
50 return dest;
51 wcp2 += 2;
53 d = *wcp;
54 wcp[off] = d;
55 if (d == L'\0')
56 return dest;
57 wcp += 2;
59 c = *wcp2;
60 wcp2[off] = c;
61 if (c == L'\0')
62 return dest;
63 wcp2 += 2;
65 d = *wcp;
66 wcp[off] = d;
67 if (d == L'\0')
68 return dest;
69 wcp += 2;
71 c = *wcp2;
72 wcp2[off] = c;
73 if (c == L'\0')
74 return dest;
75 wcp2 += 2;
77 d = *wcp;
78 wcp[off] = d;
79 if (d == L'\0')
80 return dest;
81 wcp += 2;
83 c = *wcp2;
84 wcp2[off] = c;
85 if (c == L'\0')
86 return dest;
87 wcp2 += 2;
89 while (c != L'\0');
92 else
94 wcp = dest;
98 c = *src++;
99 *wcp++ = c;
101 while (c != L'\0');
103 return dest;