Commit 93e2e851 authored by Michal Simek's avatar Michal Simek

microblaze: Separate library optimized functions

memcpy/memmove/memset
Signed-off-by: default avatarMichal Simek <monstr@monstr.eu>
parent ccea0e6e
...@@ -33,17 +33,24 @@ ...@@ -33,17 +33,24 @@
#include <asm/system.h> #include <asm/system.h>
#ifdef __HAVE_ARCH_MEMCPY #ifdef __HAVE_ARCH_MEMCPY
#ifndef CONFIG_OPT_LIB_FUNCTION
void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c) void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
{ {
const char *src = v_src; const char *src = v_src;
char *dst = v_dst; char *dst = v_dst;
#ifndef CONFIG_OPT_LIB_FUNCTION
/* Simple, byte oriented memcpy. */ /* Simple, byte oriented memcpy. */
while (c--) while (c--)
*dst++ = *src++; *dst++ = *src++;
return v_dst; return v_dst;
#else }
#else /* CONFIG_OPT_LIB_FUNCTION */
void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
{
const char *src = v_src;
char *dst = v_dst;
/* The following code tries to optimize the copy by using unsigned /* The following code tries to optimize the copy by using unsigned
* alignment. This will work fine if both source and destination are * alignment. This will work fine if both source and destination are
* aligned on the same boundary. However, if they are aligned on * aligned on the same boundary. However, if they are aligned on
...@@ -150,7 +157,7 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c) ...@@ -150,7 +157,7 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
} }
return v_dst; return v_dst;
#endif
} }
#endif /* CONFIG_OPT_LIB_FUNCTION */
EXPORT_SYMBOL(memcpy); EXPORT_SYMBOL(memcpy);
#endif /* __HAVE_ARCH_MEMCPY */ #endif /* __HAVE_ARCH_MEMCPY */
...@@ -31,16 +31,12 @@ ...@@ -31,16 +31,12 @@
#include <linux/string.h> #include <linux/string.h>
#ifdef __HAVE_ARCH_MEMMOVE #ifdef __HAVE_ARCH_MEMMOVE
#ifndef CONFIG_OPT_LIB_FUNCTION
void *memmove(void *v_dst, const void *v_src, __kernel_size_t c) void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
{ {
const char *src = v_src; const char *src = v_src;
char *dst = v_dst; char *dst = v_dst;
#ifdef CONFIG_OPT_LIB_FUNCTION
const uint32_t *i_src;
uint32_t *i_dst;
#endif
if (!c) if (!c)
return v_dst; return v_dst;
...@@ -48,7 +44,6 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c) ...@@ -48,7 +44,6 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
if (v_dst <= v_src) if (v_dst <= v_src)
return memcpy(v_dst, v_src, c); return memcpy(v_dst, v_src, c);
#ifndef CONFIG_OPT_LIB_FUNCTION
/* copy backwards, from end to beginning */ /* copy backwards, from end to beginning */
src += c; src += c;
dst += c; dst += c;
...@@ -58,7 +53,22 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c) ...@@ -58,7 +53,22 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
*--dst = *--src; *--dst = *--src;
return v_dst; return v_dst;
#else }
#else /* CONFIG_OPT_LIB_FUNCTION */
void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
{
const char *src = v_src;
char *dst = v_dst;
const uint32_t *i_src;
uint32_t *i_dst;
if (!c)
return v_dst;
/* Use memcpy when source is higher than dest */
if (v_dst <= v_src)
return memcpy(v_dst, v_src, c);
/* The following code tries to optimize the copy by using unsigned /* The following code tries to optimize the copy by using unsigned
* alignment. This will work fine if both source and destination are * alignment. This will work fine if both source and destination are
* aligned on the same boundary. However, if they are aligned on * aligned on the same boundary. However, if they are aligned on
...@@ -169,7 +179,7 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c) ...@@ -169,7 +179,7 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
*--dst = *--src; *--dst = *--src;
} }
return v_dst; return v_dst;
#endif
} }
#endif /* CONFIG_OPT_LIB_FUNCTION */
EXPORT_SYMBOL(memmove); EXPORT_SYMBOL(memmove);
#endif /* __HAVE_ARCH_MEMMOVE */ #endif /* __HAVE_ARCH_MEMMOVE */
...@@ -31,17 +31,30 @@ ...@@ -31,17 +31,30 @@
#include <linux/string.h> #include <linux/string.h>
#ifdef __HAVE_ARCH_MEMSET #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) void *memset(void *v_src, int c, __kernel_size_t n)
{ {
char *src = v_src; char *src = v_src;
#ifdef CONFIG_OPT_LIB_FUNCTION
uint32_t *i_src; uint32_t *i_src;
uint32_t w32 = 0; uint32_t w32 = 0;
#endif
/* Truncate c to 8 bits */ /* Truncate c to 8 bits */
c = (c & 0xFF); c = (c & 0xFF);
#ifdef CONFIG_OPT_LIB_FUNCTION
if (unlikely(c)) { if (unlikely(c)) {
/* Make a repeating word out of it */ /* Make a repeating word out of it */
w32 = c; w32 = c;
...@@ -72,12 +85,13 @@ void *memset(void *v_src, int c, __kernel_size_t n) ...@@ -72,12 +85,13 @@ void *memset(void *v_src, int c, __kernel_size_t n)
src = (void *)i_src; src = (void *)i_src;
} }
#endif
/* Simple, byte oriented memset or the rest of count. */ /* Simple, byte oriented memset or the rest of count. */
while (n--) while (n--)
*src++ = c; *src++ = c;
return v_src; return v_src;
} }
#endif /* CONFIG_OPT_LIB_FUNCTION */
EXPORT_SYMBOL(memset); EXPORT_SYMBOL(memset);
#endif /* __HAVE_ARCH_MEMSET */ #endif /* __HAVE_ARCH_MEMSET */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment