Skip to content

Commit

Permalink
microblaze: Use simple memmove/memcpy implementation from lib/string.c
Browse files Browse the repository at this point in the history
This is based on previous commit ("microblaze: Use simple memset
implementation from lib/string.c") where generic memset implementation is
used when OPT_LIB_FUNCTION is not defined. The same change can be done for
memset/memcpy implementation where doesn't make sense to have generic
implementation in architecture code.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Link: https://lore.kernel.org/r/1f5cfc026a8a458f3e3134ab80f65bd4ac7e3e8e.1645797329.git.michal.simek@xilinx.com
  • Loading branch information
Michal Simek committed Apr 21, 2022
1 parent 95fee37 commit 61a4e65
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 44 deletions.
2 changes: 1 addition & 1 deletion arch/microblaze/include/asm/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

#ifdef CONFIG_OPT_LIB_FUNCTION
#define __HAVE_ARCH_MEMSET
#endif
#define __HAVE_ARCH_MEMCPY
#define __HAVE_ARCH_MEMMOVE

extern void *memset(void *, int, __kernel_size_t);
extern void *memcpy(void *, const void *, __kernel_size_t);
extern void *memmove(void *, const void *, __kernel_size_t);
#endif

#endif /* __KERNEL__ */

Expand Down
18 changes: 2 additions & 16 deletions arch/microblaze/lib/memcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,7 @@

#include <linux/string.h>

#ifdef __HAVE_ARCH_MEMCPY
#ifndef 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;

/* Simple, byte oriented memcpy. */
while (c--)
*dst++ = *src++;

return v_dst;
}
#else /* CONFIG_OPT_LIB_FUNCTION */
#ifdef CONFIG_OPT_LIB_FUNCTION
void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
{
const char *src = v_src;
Expand Down Expand Up @@ -188,6 +175,5 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)

return v_dst;
}
#endif /* CONFIG_OPT_LIB_FUNCTION */
EXPORT_SYMBOL(memcpy);
#endif /* __HAVE_ARCH_MEMCPY */
#endif /* CONFIG_OPT_LIB_FUNCTION */
29 changes: 2 additions & 27 deletions arch/microblaze/lib/memmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,7 @@
#include <linux/compiler.h>
#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;

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);

/* copy backwards, from end to beginning */
src += c;
dst += c;

/* Simple, byte oriented memmove. */
while (c--)
*--dst = *--src;

return v_dst;
}
#else /* CONFIG_OPT_LIB_FUNCTION */
#ifdef CONFIG_OPT_LIB_FUNCTION
void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
{
const char *src = v_src;
Expand Down Expand Up @@ -215,6 +191,5 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
}
return v_dst;
}
#endif /* CONFIG_OPT_LIB_FUNCTION */
EXPORT_SYMBOL(memmove);
#endif /* __HAVE_ARCH_MEMMOVE */
#endif /* CONFIG_OPT_LIB_FUNCTION */

0 comments on commit 61a4e65

Please sign in to comment.