diff options
author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2007-11-21 12:34:41 +0000 |
---|---|---|
committer | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2007-11-21 12:34:41 +0000 |
commit | 90f1927f14e9cdbae37981af728af8e727838069 (patch) | |
tree | a501f0526428f3c1e3f1150496b5e87fbb2c88c0 /libc/string/cris/strcpy.c | |
parent | b0f709e6c8c87833dda6701adfd4857bcba7e7fb (diff) |
Added optimized versions of strcpy() and strncpy() for CRIS/CRISv32.
Diffstat (limited to 'libc/string/cris/strcpy.c')
-rw-r--r-- | libc/string/cris/strcpy.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/libc/string/cris/strcpy.c b/libc/string/cris/strcpy.c new file mode 100644 index 000000000..0af25253e --- /dev/null +++ b/libc/string/cris/strcpy.c @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2006-2007 Axis Communications AB + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <string.h> + +libc_hidden_proto(strcpy) +char *strcpy(char *dest, const char *src) +{ + char *ret = dest; + unsigned long himagic = 0x80808080L; + unsigned long lomagic = 0x01010101L; + + while ((unsigned long)src & (sizeof src - 1)) + { + if (!(*dest++ = *src++)) + { + return ret; + } + } + + while (1) + { + unsigned long value = *(unsigned long*)src; + unsigned long magic; + + src += sizeof (unsigned long); + + if ((magic = (value - lomagic) & himagic)) + { + if (magic & ~value) + { + break; + } + } + + *(unsigned long*)dest = value; + dest += sizeof (unsigned long); + } + + src -= sizeof (unsigned long); + + while ((*dest++ = *src++)) + { + } + + return ret; +} +libc_hidden_def(strcpy) |