| Rev | Line | |
|---|
| [1] | 1 | /* fast strcpy -- Copyright (C) 2003 Thomas M. Ogrisegg <tom@hi-tek.fnord.at> */ |
|---|
| 2 | #include <string.h> |
|---|
| 3 | #include "dietfeatures.h" |
|---|
| 4 | #include "dietstring.h" |
|---|
| 5 | |
|---|
| 6 | char * |
|---|
| 7 | strcpy (char *s1, const char *s2) |
|---|
| 8 | { |
|---|
| 9 | char *res = s1; |
|---|
| 10 | #ifdef WANT_SMALL_STRING_ROUTINES |
|---|
| 11 | while ((*s1++ = *s2++)); |
|---|
| 12 | return (res); |
|---|
| 13 | #else |
|---|
| 14 | int tmp; |
|---|
| 15 | unsigned long l; |
|---|
| 16 | |
|---|
| 17 | if (UNALIGNED(s1, s2)) { |
|---|
| 18 | while ((*s1++ = *s2++)); |
|---|
| 19 | return (res); |
|---|
| 20 | } |
|---|
| 21 | if ((tmp = STRALIGN(s1))) { |
|---|
| 22 | while (tmp-- && (*s1++ = *s2++)); |
|---|
| 23 | if (tmp != -1) return (res); |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | while (1) { |
|---|
| 27 | l = *(const unsigned long *) s2; |
|---|
| 28 | if (((l - MKW(0x1ul)) & ~l) & MKW(0x80ul)) { |
|---|
| 29 | while ((*s1++ = GFC(l))) INCSTR(l); |
|---|
| 30 | return (res); |
|---|
| 31 | } |
|---|
| 32 | *(unsigned long *) s1 = l; |
|---|
| 33 | s2 += sizeof(unsigned long); |
|---|
| 34 | s1 += sizeof(unsigned long); |
|---|
| 35 | } |
|---|
| 36 | #endif |
|---|
| 37 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.