1 /* 2 * Copyright (C) 2006-2007 Axis Communications AB 3 * 4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. 5 */ 6 7 #include <string.h> 8 strcpy(char * dest,const char * src)9char *strcpy(char *dest, const char *src) 10 { 11 char *ret = dest; 12 unsigned long himagic = 0x80808080L; 13 unsigned long lomagic = 0x01010101L; 14 15 while ((unsigned long)src & (sizeof src - 1)) 16 { 17 if (!(*dest++ = *src++)) 18 { 19 return ret; 20 } 21 } 22 23 while (1) 24 { 25 unsigned long value = *(unsigned long*)src; 26 unsigned long magic; 27 28 src += sizeof (unsigned long); 29 30 if ((magic = (value - lomagic) & himagic)) 31 { 32 if (magic & ~value) 33 { 34 break; 35 } 36 } 37 38 *(unsigned long*)dest = value; 39 dest += sizeof (unsigned long); 40 } 41 42 src -= sizeof (unsigned long); 43 44 while ((*dest++ = *src++)) 45 { 46 } 47 48 return ret; 49 } 50 libc_hidden_def(strcpy) 51