aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/arch/microblaze/lib/memmove.c
diff options
context:
space:
mode:
authorMichal Simek <monstr@monstr.eu>2010-10-09 13:58:24 +1000
committerMichal Simek <monstr@monstr.eu>2010-10-21 15:52:01 +1000
commit93e2e85139509338c68279c7260ebb68177b23a9 (patch)
tree64171deb6d2f046da3cf7c5111f73e419be1d460 /arch/microblaze/lib/memmove.c
parentmicroblaze: Support timer on AXI lite (diff)
downloadwireguard-linux-93e2e85139509338c68279c7260ebb68177b23a9.tar.xz
wireguard-linux-93e2e85139509338c68279c7260ebb68177b23a9.zip
microblaze: Separate library optimized functions
memcpy/memmove/memset Signed-off-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch/microblaze/lib/memmove.c')
-rw-r--r--arch/microblaze/lib/memmove.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/arch/microblaze/lib/memmove.c b/arch/microblaze/lib/memmove.c
index 0929198c5e68..1d3c0e7990e5 100644
--- a/arch/microblaze/lib/memmove.c
+++ b/arch/microblaze/lib/memmove.c
@@ -31,16 +31,12 @@
#include <linux/string.h>
#ifdef __HAVE_ARCH_MEMMOVE
+#ifndef 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;
-#ifdef CONFIG_OPT_LIB_FUNCTION
- const uint32_t *i_src;
- uint32_t *i_dst;
-#endif
-
if (!c)
return v_dst;
@@ -48,7 +44,6 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
if (v_dst <= v_src)
return memcpy(v_dst, v_src, c);
-#ifndef CONFIG_OPT_LIB_FUNCTION
/* copy backwards, from end to beginning */
src += c;
dst += c;
@@ -58,7 +53,22 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
*--dst = *--src;
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
* alignment. This will work fine if both source and destination are
* 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)
*--dst = *--src;
}
return v_dst;
-#endif
}
+#endif /* CONFIG_OPT_LIB_FUNCTION */
EXPORT_SYMBOL(memmove);
#endif /* __HAVE_ARCH_MEMMOVE */