From 2acd2a2f57f27d6e9ded396f0e8cf720f7ac19b6 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sat, 27 Aug 2011 05:24:28 -0700 Subject: [PATCH] add SCC optimized memset function --- arch/x86/include/asm/string.h | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/string.h b/arch/x86/include/asm/string.h index e1c092b7..66f5e617 100644 --- a/arch/x86/include/asm/string.h +++ b/arch/x86/include/asm/string.h @@ -117,9 +117,37 @@ inline static void *memcpy(void* dest, const void *src, size_t count) #ifdef HAVE_ARCH_MEMSET +#ifdef CONFIG_ROCKCREEK /** @brief Repeated write of a value to a whole range of bytes * - * Writes a value repeatedly double word wise (4 byte) to a range of bytes + * SCC optimized version of memset (see memcpy) + * + * @param dest Destination address + * @param val Value to flood the range with + * @param count Size of target range in bytes + */ +inline static void *memset(void* dest, int val, size_t count) +{ + int32_t i, j; + + if (BUILTIN_EXPECT(!dest, 0)) + return dest; + + asm volatile ("cld\n\t" + "1: cmpl $32, %%ebx ; jb 2f\n\t" + "movl (%%edi), %%edx\n\t" + "movl $32, %%ecx\n\t" + "rep stosb\n\t" + "subl $32, %%ebx\n\t" + "jmp 1b\n\t" + "2: movl %%ebx, %%ecx ; rep stosb" + : "=&b"(i), "=&D"(j) + : "a"(val), "1"(dest), "0"(count) : "%edx", "%ecx", "memory","cc"); + + return dest; +} +#else +/** @brief Repeated write of a value to a whole range of bytes * * @param dest Destination address * @param val Value to flood the range with @@ -140,6 +168,8 @@ inline static void *memset(void* dest, int val, size_t count) } #endif +#endif + #ifdef HAVE_ARCH_STRLEN /** @brief Standard string length