diff options
author | Joakim Tjernlund <joakim.tjernlund@transmode.se> | 2005-06-21 14:03:15 +0000 |
---|---|---|
committer | Joakim Tjernlund <joakim.tjernlund@transmode.se> | 2005-06-21 14:03:15 +0000 |
commit | 3579c6cf0e9e3786d9d208ca9c2f16bb7f6a79ff (patch) | |
tree | 52e646376a8eb18cedf4f83cb5b85833ec3c0155 /libc/string | |
parent | 1f29aa48288c3e8ac9601fbe21b043772ca3eae1 (diff) |
Fic gcc 4.0 compilation. Still no confimation that this works on
gcc 4.0 but I don't want to wait anymore.
Diffstat (limited to 'libc/string')
-rw-r--r-- | libc/string/powerpc/string.c | 72 |
1 files changed, 42 insertions, 30 deletions
diff --git a/libc/string/powerpc/string.c b/libc/string/powerpc/string.c index 1835e6aa7..acd5d0144 100644 --- a/libc/string/powerpc/string.c +++ b/libc/string/powerpc/string.c @@ -32,15 +32,16 @@ #include <locale.h> /* for __LOCALE_C_ONLY */ #ifdef L_memcpy -void *memcpy(void *to, const void *from, size_t n) +void attribute_hidden *__memcpy(void *to, const void *from, size_t n) /* PPC can do pre increment and load/store, but not post increment and load/store. Therefore use *++ptr instead of *ptr++. */ { unsigned long rem, chunks, tmp1, tmp2; - void *tmp_to; + unsigned char *tmp_to; + unsigned char *tmp_from = (unsigned char *)from; chunks = n / 8; - from -= 4; + tmp_from -= 4; tmp_to = to - 4; if (!chunks) goto lessthan8; @@ -50,9 +51,9 @@ void *memcpy(void *to, const void *from, size_t n) copy_chunks: do { /* make gcc to load all data, then store it */ - tmp1 = *(unsigned long *)(from+4); - from += 8; - tmp2 = *(unsigned long *)from; + tmp1 = *(unsigned long *)(tmp_from+4); + tmp_from += 8; + tmp2 = *(unsigned long *)tmp_from; *(unsigned long *)(tmp_to+4) = tmp1; tmp_to += 8; *(unsigned long *)tmp_to = tmp2; @@ -60,23 +61,25 @@ void *memcpy(void *to, const void *from, size_t n) lessthan8: n = n % 8; if (n >= 4) { - *++(unsigned long *)tmp_to = *++(unsigned long *)from; + *(unsigned long *)(tmp_to+4) = *(unsigned long *)(tmp_from+4); + tmp_from += 4; + tmp_to += 4; n = n-4; } if (!n ) return to; - from += 3; + tmp_from += 3; tmp_to += 3; do { - *++(unsigned char *)tmp_to = *++(unsigned char *)from; + *++tmp_to = *++tmp_from; } while (--n); return to; align: rem = 4 - rem; - n = n-rem; + n = n - rem; do { - *(unsigned char *)(tmp_to+4) = *(unsigned char *)(from+4); - ++from; + *(tmp_to+4) = *(tmp_from+4); + ++tmp_from; ++tmp_to; } while (--rem); chunks = n / 8; @@ -84,18 +87,20 @@ void *memcpy(void *to, const void *from, size_t n) goto copy_chunks; goto lessthan8; } +strong_alias(__memcpy, memcpy); #endif #ifdef L_memmove -void *memmove(void *to, const void *from, size_t n) +void attribute_hidden *__memmove(void *to, const void *from, size_t n) { unsigned long rem, chunks, tmp1, tmp2; - void *tmp_to; + unsigned char *tmp_to; + unsigned char *tmp_from = (unsigned char *)from; - if (from >= to) + if (tmp_from >= (unsigned char *)to) return memcpy(to, from, n); chunks = n / 8; - from += n; + tmp_from += n; tmp_to = to + n; if (!chunks) goto lessthan8; @@ -105,9 +110,9 @@ void *memmove(void *to, const void *from, size_t n) copy_chunks: do { /* make gcc to load all data, then store it */ - tmp1 = *(unsigned long *)(from-4); - from -= 8; - tmp2 = *(unsigned long *)from; + tmp1 = *(unsigned long *)(tmp_from-4); + tmp_from -= 8; + tmp2 = *(unsigned long *)tmp_from; *(unsigned long *)(tmp_to-4) = tmp1; tmp_to -= 8; *(unsigned long *)tmp_to = tmp2; @@ -115,26 +120,29 @@ void *memmove(void *to, const void *from, size_t n) lessthan8: n = n % 8; if (n >= 4) { - *--(unsigned long *)tmp_to = *--(unsigned long *)from; + *(unsigned long *)(tmp_to-4) = *(unsigned long *)(tmp_from-4); + tmp_from -= 4; + tmp_to -= 4; n = n-4; } if (!n ) return to; do { - *--(unsigned char *)tmp_to = *--(unsigned char *)from; + *--tmp_to = *--tmp_from; } while (--n); return to; align: rem = 4 - rem; - n = n-rem; + n = n - rem; do { - *--(unsigned char *)tmp_to = *--(unsigned char *)from; + *--tmp_to = *--tmp_from; } while (--rem); chunks = n / 8; if (chunks) goto copy_chunks; goto lessthan8; } +strong_alias(__memmove, memmove); #endif #ifdef L_memset @@ -148,10 +156,10 @@ static inline int expand_byte_word(int c){ : "=r" (c) : "0" (c)); return c; } -void *memset(void *to, int c, size_t n) +void attribute_hidden *__memset(void *to, int c, size_t n) { unsigned long rem, chunks; - void *tmp_to; + unsigned char *tmp_to; chunks = n / 8; tmp_to = to - 4; @@ -163,19 +171,22 @@ void *memset(void *to, int c, size_t n) goto align; copy_chunks: do { - *++(unsigned long *)tmp_to = c; - *++(unsigned long *)tmp_to = c; + *(unsigned long *)(tmp_to+4) = c; + tmp_to += 4; + *(unsigned long *)(tmp_to+4) = c; + tmp_to += 4; } while (--chunks); lessthan8: n = n % 8; if (n >= 4) { - *++(unsigned long *)tmp_to = c; + *(unsigned long *)(tmp_to+4) = c; + tmp_to += 4; n = n-4; } if (!n ) return to; tmp_to += 3; do { - *++(unsigned char *)tmp_to = c; + *++tmp_to = c; } while (--n); return to; @@ -183,7 +194,7 @@ void *memset(void *to, int c, size_t n) rem = 4 - rem; n = n-rem; do { - *(unsigned char *)(tmp_to+4) = c; + *(tmp_to+4) = c; ++tmp_to; } while (--rem); chunks = n / 8; @@ -191,6 +202,7 @@ void *memset(void *to, int c, size_t n) goto copy_chunks; goto lessthan8; } +strong_alias(__memset, memset); #endif #ifdef L_bzero |