diff options
Diffstat (limited to 'libc')
-rw-r--r-- | libc/string/memset.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libc/string/memset.c b/libc/string/memset.c index 18b7619..dae4366 100644 --- a/libc/string/memset.c +++ b/libc/string/memset.c @@ -18,6 +18,7 @@ void * memset(void *dest, int c, size_t size) { unsigned char *d = (unsigned char *)dest; + unsigned long big_c = 0; #if defined(__powerpc__) || defined(__powerpc64__) if (size > CACHE_LINE_SIZE && c==0) { @@ -33,8 +34,14 @@ memset(void *dest, int c, size_t size) } #endif + if (c) { + big_c = c; + big_c |= (big_c << 8) | big_c; + big_c |= (big_c << 16) | big_c; + big_c |= (big_c << 32) | big_c; + } while (size >= 8 && c == 0) { - *((unsigned long long*)d) = 0ULL; + *((unsigned long *)d) = big_c; d+=8; size-=8; } |