From 259fd0364d0ee131e1df6c46a0ed7a032c5e73a7 Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Tue, 10 Aug 2004 15:25:35 +0000 Subject: Optimze _dl_memset() for PowerPC. Other arches may also benefit from this iff it can do unaligned stores. --- ldso/include/dl-string.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'ldso/include') diff --git a/ldso/include/dl-string.h b/ldso/include/dl-string.h index 3e14971e6..c428634d2 100644 --- a/ldso/include/dl-string.h +++ b/ldso/include/dl-string.h @@ -158,6 +158,33 @@ static inline int _dl_memcmp(const void * s1,const void * s2,size_t len) 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 @@ static inline void * _dl_memset(void * str,int c,size_t len) return str; } +#endif static inline char *_dl_get_last_path_component(char *path) { -- cgit v1.2.3