diff options
Diffstat (limited to 'arch/microblaze/lib/memset.c')
| -rw-r--r-- | arch/microblaze/lib/memset.c | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/arch/microblaze/lib/memset.c b/arch/microblaze/lib/memset.c index 4df851d41a2..04ea72c8a81 100644 --- a/arch/microblaze/lib/memset.c +++ b/arch/microblaze/lib/memset.c @@ -24,33 +24,47 @@ * not any responsibility to update it. */ +#include <linux/export.h> #include <linux/types.h> #include <linux/stddef.h> #include <linux/compiler.h> -#include <linux/module.h> #include <linux/string.h> #ifdef __HAVE_ARCH_MEMSET +#ifndef CONFIG_OPT_LIB_FUNCTION void *memset(void *v_src, int c, __kernel_size_t n) { + char *src = v_src; + + /* Truncate c to 8 bits */ + c = (c & 0xFF); + + /* Simple, byte oriented memset or the rest of count. */ + while (n--) + *src++ = c; + return v_src; +} +#else /* CONFIG_OPT_LIB_FUNCTION */ +void *memset(void *v_src, int c, __kernel_size_t n) +{ char *src = v_src; -#ifdef CONFIG_OPT_LIB_FUNCTION uint32_t *i_src; - uint32_t w32; -#endif + uint32_t w32 = 0; + /* Truncate c to 8 bits */ c = (c & 0xFF); -#ifdef CONFIG_OPT_LIB_FUNCTION - /* Make a repeating word out of it */ - w32 = c; - w32 |= w32 << 8; - w32 |= w32 << 16; + if (unlikely(c)) { + /* Make a repeating word out of it */ + w32 = c; + w32 |= w32 << 8; + w32 |= w32 << 16; + } - if (n >= 4) { + if (likely(n >= 4)) { /* Align the destination to a word boundary */ - /* This is done in an endian independant manner */ + /* This is done in an endian independent manner */ switch ((unsigned) src & 3) { case 1: *src++ = c; @@ -71,12 +85,13 @@ void *memset(void *v_src, int c, __kernel_size_t n) src = (void *)i_src; } -#endif + /* Simple, byte oriented memset or the rest of count. */ while (n--) *src++ = c; return v_src; } +#endif /* CONFIG_OPT_LIB_FUNCTION */ EXPORT_SYMBOL(memset); #endif /* __HAVE_ARCH_MEMSET */ |
