diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2016-07-24 09:27:05 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2016-08-18 16:04:26 +1000 |
commit | ad1b72c40762bc9c50f46d9fc2620faaa25e10bd (patch) | |
tree | dc45467e3129ec1e308b8e07ca38db1083042605 /libc | |
parent | ac3e90e1ef0aeab3faf2359ea77d130fade86548 (diff) | |
download | skiboot-ad1b72c40762bc9c50f46d9fc2620faaa25e10bd.zip skiboot-ad1b72c40762bc9c50f46d9fc2620faaa25e10bd.tar.gz skiboot-ad1b72c40762bc9c50f46d9fc2620faaa25e10bd.tar.bz2 |
libc: Use 8-bytes stores for non-0 memset too
Memory poisoning hammers this, so let's be a bit smart about it and
avoid falling back to byte stores when the data is not 0
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
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; } |