3 <<strcpy>>---copy string
10 char *strcpy(char *<[dst]>, const char *<[src]>);
14 char *strcpy(<[dst]>, <[src]>)
19 <<strcpy>> copies the string pointed to by <[src]>
20 (including the terminating null character) to the array
21 pointed to by <[dst]>.
24 This function returns the initial value of <[dst]>.
29 <<strcpy>> requires no supporting OS subroutines.
41 /* Nonzero if either X or Y is not aligned on a "long" boundary. */
42 #define UNALIGNED(X, Y) \
43 (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
45 #if LONG_MAX == 2147483647L
46 #define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080)
48 #if LONG_MAX == 9223372036854775807L
49 /* Nonzero if X (a long int) contains a NULL byte. */
50 #define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080)
52 #error long int is not a 32bit or 64bit type.
57 #error long int is not a 32bit or 64bit byte
61 _DEFUN (strcpy
, (dst0
, src0
),
65 #if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
68 while (*dst0
++ = *src0
++)
74 _CONST
char *src
= src0
;
76 _CONST
long *aligned_src
;
78 /* If SRC or DEST is unaligned, then copy bytes. */
79 if (!UNALIGNED (src
, dst
))
81 aligned_dst
= (long*)dst
;
82 aligned_src
= (long*)src
;
84 /* SRC and DEST are both "long int" aligned, try to do "long int"
86 while (!DETECTNULL(*aligned_src
))
88 *aligned_dst
++ = *aligned_src
++;
91 dst
= (char*)aligned_dst
;
92 src
= (char*)aligned_src
;
95 while (*dst
++ = *src
++)
98 #endif /* not PREFER_SIZE_OVER_SPEED */