add SCC optimized memset function

This commit is contained in:
Stefan Lankes 2011-08-27 05:24:28 -07:00
parent 7b9f890c66
commit 2acd2a2f57

View file

@ -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