[uClibc-cvs] svn commit: trunk/uClibc/libc/string/powerpc

jocke at uclibc.org jocke at uclibc.org
Tue Jun 21 14:03:16 UTC 2005


Author: jocke
Date: 2005-06-21 08:03:15 -0600 (Tue, 21 Jun 2005)
New Revision: 10560

Log:
Fic gcc 4.0 compilation. Still no confimation that this works on
gcc 4.0 but I don't want to wait anymore.


Modified:
   trunk/uClibc/libc/string/powerpc/string.c


Changeset:
Modified: trunk/uClibc/libc/string/powerpc/string.c
===================================================================
--- trunk/uClibc/libc/string/powerpc/string.c	2005-06-21 11:09:32 UTC (rev 10559)
+++ trunk/uClibc/libc/string/powerpc/string.c	2005-06-21 14:03:15 UTC (rev 10560)
@@ -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 @@
  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 @@
  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 @@
 		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 @@
  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 @@
  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 @@
 	    : "=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 @@
 		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 @@
 	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 @@
 		goto copy_chunks;
 	goto lessthan8;
 }
+strong_alias(__memset, memset);
 #endif
 
 #ifdef L_bzero




More information about the uClibc-cvs mailing list