Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <michal.simek@xilinx.com>
Link: https://lore.kernel.org/r/1f5cfc026a8a458f3e3134ab80f65bd4ac7e3e8e.1645797329.git.michal.simek@xilinx.com

+5 -44
+1 -1
arch/microblaze/include/asm/string.h
··· 10 10 11 11 #ifdef CONFIG_OPT_LIB_FUNCTION 12 12 #define __HAVE_ARCH_MEMSET 13 - #endif 14 13 #define __HAVE_ARCH_MEMCPY 15 14 #define __HAVE_ARCH_MEMMOVE 16 15 17 16 extern void *memset(void *, int, __kernel_size_t); 18 17 extern void *memcpy(void *, const void *, __kernel_size_t); 19 18 extern void *memmove(void *, const void *, __kernel_size_t); 19 + #endif 20 20 21 21 #endif /* __KERNEL__ */ 22 22
+2 -16
arch/microblaze/lib/memcpy.c
··· 31 31 32 32 #include <linux/string.h> 33 33 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 48 35 void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c) 49 36 { 50 37 const char *src = v_src; ··· 175 188 176 189 return v_dst; 177 190 } 178 - #endif /* CONFIG_OPT_LIB_FUNCTION */ 179 191 EXPORT_SYMBOL(memcpy); 180 - #endif /* __HAVE_ARCH_MEMCPY */ 192 + #endif /* CONFIG_OPT_LIB_FUNCTION */
+2 -27
arch/microblaze/lib/memmove.c
··· 30 30 #include <linux/compiler.h> 31 31 #include <linux/string.h> 32 32 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 58 34 void *memmove(void *v_dst, const void *v_src, __kernel_size_t c) 59 35 { 60 36 const char *src = v_src; ··· 191 215 } 192 216 return v_dst; 193 217 } 194 - #endif /* CONFIG_OPT_LIB_FUNCTION */ 195 218 EXPORT_SYMBOL(memmove); 196 - #endif /* __HAVE_ARCH_MEMMOVE */ 219 + #endif /* CONFIG_OPT_LIB_FUNCTION */