]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
microblaze: Use simple memmove/memcpy implementation from lib/string.c
authorMichal Simek <michal.simek@xilinx.com>
Fri, 25 Feb 2022 13:55:36 +0000 (14:55 +0100)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 21 Apr 2022 08:54:21 +0000 (10:54 +0200)
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
arch/microblaze/include/asm/string.h
arch/microblaze/lib/memcpy.c
arch/microblaze/lib/memmove.c

index dbdb9eb4a733c5f5100311af6c5d4db905a3b622..8798ad2c132af54ad27b7c0f18e20653169f1b2d 100644 (file)
 
 #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__ */
 
index 63041fdf916d7cc02579cab81df8c8d7e8493d28..9966dce55619d56c989cce8dec415705a702c947 100644 (file)
 
 #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;
@@ -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 */
index 9862f6b1e59d232824454a9a6a8c2749b6c72cde..2e49d0ef1e07cd5a86935ccc036b19379c2df177 100644 (file)
 #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;
@@ -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 */