Skip to content

Commit 61a4e65

Browse files
author
Michal Simek
committed
microblaze: Use simple memmove/memcpy implementation from lib/string.c
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 <[email protected]> Link: https://lore.kernel.org/r/1f5cfc026a8a458f3e3134ab80f65bd4ac7e3e8e.1645797329.git.michal.simek@xilinx.com
1 parent 95fee37 commit 61a4e65

File tree

3 files changed

+5
-44
lines changed

3 files changed

+5
-44
lines changed

arch/microblaze/include/asm/string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
#ifdef CONFIG_OPT_LIB_FUNCTION
1212
#define __HAVE_ARCH_MEMSET
13-
#endif
1413
#define __HAVE_ARCH_MEMCPY
1514
#define __HAVE_ARCH_MEMMOVE
1615

1716
extern void *memset(void *, int, __kernel_size_t);
1817
extern void *memcpy(void *, const void *, __kernel_size_t);
1918
extern void *memmove(void *, const void *, __kernel_size_t);
19+
#endif
2020

2121
#endif /* __KERNEL__ */
2222

arch/microblaze/lib/memcpy.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,7 @@
3131

3232
#include <linux/string.h>
3333

34-
#ifdef __HAVE_ARCH_MEMCPY
35-
#ifndef CONFIG_OPT_LIB_FUNCTION
36-
void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
37-
{
38-
const char *src = v_src;
39-
char *dst = v_dst;
40-
41-
/* Simple, byte oriented memcpy. */
42-
while (c--)
43-
*dst++ = *src++;
44-
45-
return v_dst;
46-
}
47-
#else /* CONFIG_OPT_LIB_FUNCTION */
34+
#ifdef CONFIG_OPT_LIB_FUNCTION
4835
void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
4936
{
5037
const char *src = v_src;
@@ -188,6 +175,5 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
188175

189176
return v_dst;
190177
}
191-
#endif /* CONFIG_OPT_LIB_FUNCTION */
192178
EXPORT_SYMBOL(memcpy);
193-
#endif /* __HAVE_ARCH_MEMCPY */
179+
#endif /* CONFIG_OPT_LIB_FUNCTION */

arch/microblaze/lib/memmove.c

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,7 @@
3030
#include <linux/compiler.h>
3131
#include <linux/string.h>
3232

33-
#ifdef __HAVE_ARCH_MEMMOVE
34-
#ifndef CONFIG_OPT_LIB_FUNCTION
35-
void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
36-
{
37-
const char *src = v_src;
38-
char *dst = v_dst;
39-
40-
if (!c)
41-
return v_dst;
42-
43-
/* Use memcpy when source is higher than dest */
44-
if (v_dst <= v_src)
45-
return memcpy(v_dst, v_src, c);
46-
47-
/* copy backwards, from end to beginning */
48-
src += c;
49-
dst += c;
50-
51-
/* Simple, byte oriented memmove. */
52-
while (c--)
53-
*--dst = *--src;
54-
55-
return v_dst;
56-
}
57-
#else /* CONFIG_OPT_LIB_FUNCTION */
33+
#ifdef CONFIG_OPT_LIB_FUNCTION
5834
void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
5935
{
6036
const char *src = v_src;
@@ -215,6 +191,5 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
215191
}
216192
return v_dst;
217193
}
218-
#endif /* CONFIG_OPT_LIB_FUNCTION */
219194
EXPORT_SYMBOL(memmove);
220-
#endif /* __HAVE_ARCH_MEMMOVE */
195+
#endif /* CONFIG_OPT_LIB_FUNCTION */

0 commit comments

Comments
 (0)