[uClibc-cvs] CVS update of uClibc/ldso/include (dl-string.h)

Joakim Tjernlund jocke at codepoet.org
Tue Aug 10 15:25:37 UTC 2004


    Date: Tuesday, August 10, 2004 @ 09:25:37
  Author: jocke
    Path: /var/cvs/uClibc/ldso/include

Modified: dl-string.h (1.9 -> 1.10)

Optimze _dl_memset() for PowerPC.
Other arches may also benefit from this iff it can do
unaligned stores.


Index: uClibc/ldso/include/dl-string.h
diff -u uClibc/ldso/include/dl-string.h:1.9 uClibc/ldso/include/dl-string.h:1.10
--- uClibc/ldso/include/dl-string.h:1.9	Tue Aug 10 09:18:18 2004
+++ uClibc/ldso/include/dl-string.h	Tue Aug 10 09:25:35 2004
@@ -158,6 +158,33 @@
 	return 0;
 }
 
+#if defined(powerpc)
+/* Will generate smaller and faster code due to loop unrolling.*/
+static inline void *_dl_memset(void *to, int c, size_t n)
+{
+        unsigned long chunks;
+        unsigned long *tmp_to;
+	unsigned char *tmp_char;
+
+        chunks = n / 4;
+        tmp_to = to + n;
+        c = c << 8 | c;
+        c = c << 16 | c;
+        if (!chunks)
+                goto lessthan4;
+        do {
+                *--tmp_to = c;
+        } while (--chunks);
+ lessthan4:
+        n = n % 4;
+        if (!n ) return to;
+        tmp_char = (unsigned char *)tmp_to;
+        do {
+                *--tmp_char = c;
+        } while (--n);
+        return to;
+}
+#else
 static inline void * _dl_memset(void * str,int c,size_t len)
 {
 	register char *a = str;
@@ -167,6 +194,7 @@
 
 	return str;
 }
+#endif
 
 static inline char *_dl_get_last_path_component(char *path)
 {



More information about the uClibc-cvs mailing list