1 /* Copyright (c) 2017 SiFive Inc. All rights reserved.
3 This copyrighted material is made available to anyone wishing to use,
4 modify, copy, or redistribute it subject to the terms and conditions
5 of the FreeBSD License. This program is distributed in the hope that
6 it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
7 including the implied warranties of MERCHANTABILITY or FITNESS FOR
8 A PARTICULAR PURPOSE. A copy of this license is available at
9 http://www.opensource.org/licenses.
15 char *strcpy(char *dst
, const char *src
)
19 #if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
20 int misaligned
= ((uintptr_t)dst
| (uintptr_t)src
) & (sizeof (long) - 1);
21 if (__builtin_expect(!misaligned
, 1))
23 long *ldst
= (long *)dst
;
24 const long *lsrc
= (const long *)src
;
26 while (!__libc_detect_null(*lsrc
))
30 src
= (const char *)lsrc
;
35 if (!(*dst
++ = c0
)) return dst0
;
36 if (!(*dst
++ = c1
)) return dst0
;
38 if (!(*dst
++ = c2
)) return dst0
;
39 if (sizeof (long) == 4) goto out
;
41 if (!(*dst
++ = c3
)) return dst0
;
43 if (!(*dst
++ = c4
)) return dst0
;
45 if (!(*dst
++ = c5
)) return dst0
;
46 if (!(*dst
++ = c6
)) return dst0
;
52 #endif /* not PREFER_SIZE_OVER_SPEED */