[RFC PATCH 08/13] ARC: string: use generic C code if no ZOL support

Sergey Matyukevich geomatsi at gmail.com
Tue Feb 22 06:15:01 PST 2022


From: Vineet Gupta <vgupta at kernel.org>

Switch to generic C code when ZOL is not supported.
Generic code lacks memzero, so define it.

Signed-off-by: Vineet Gupta <vgupta at kernel.org>
---
 arch/arc/include/asm/string.h | 15 ++++++++++++++-
 arch/arc/kernel/arcksyms.c    |  2 ++
 arch/arc/lib/Makefile         |  4 ++++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/arch/arc/include/asm/string.h b/arch/arc/include/asm/string.h
index 3182ea9dcdde..5cde5226fada 100644
--- a/arch/arc/include/asm/string.h
+++ b/arch/arc/include/asm/string.h
@@ -14,6 +14,8 @@
 
 #include <linux/types.h>
 
+#ifndef CONFIG_ARC_LACKS_ZOL
+
 #define __HAVE_ARCH_MEMSET
 #define __HAVE_ARCH_MEMCPY
 #define __HAVE_ARCH_MEMCMP
@@ -22,7 +24,7 @@
 #define __HAVE_ARCH_STRCMP
 #define __HAVE_ARCH_STRLEN
 
-extern void *memset(void *ptr, int, __kernel_size_t);
+extern void *memset(void *, int, __kernel_size_t);
 extern void *memcpy(void *, const void *, __kernel_size_t);
 extern void memzero(void *ptr, __kernel_size_t n);
 extern int memcmp(const void *, const void *, __kernel_size_t);
@@ -31,4 +33,15 @@ extern char *strcpy(char *dest, const char *src);
 extern int strcmp(const char *cs, const char *ct);
 extern __kernel_size_t strlen(const char *);
 
+#else
+
+extern void *memset(void *, int, __kernel_size_t);
+
+static inline void memzero(void *s, size_t count)
+{
+	memset(s, 0, count);
+}
+
+#endif
+
 #endif /* _ASM_ARC_STRING_H */
diff --git a/arch/arc/kernel/arcksyms.c b/arch/arc/kernel/arcksyms.c
index 8851c0a19e09..d682cea639a4 100644
--- a/arch/arc/kernel/arcksyms.c
+++ b/arch/arc/kernel/arcksyms.c
@@ -45,6 +45,7 @@ EXPORT_SYMBOL(__floatunsisf);
 EXPORT_SYMBOL(__udivdi3);
 
 /* ARC optimised assembler routines */
+#ifndef CONFIG_ARC_LACKS_ZOL
 EXPORT_SYMBOL(memset);
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memcmp);
@@ -52,3 +53,4 @@ EXPORT_SYMBOL(strchr);
 EXPORT_SYMBOL(strcpy);
 EXPORT_SYMBOL(strcmp);
 EXPORT_SYMBOL(strlen);
+#endif
diff --git a/arch/arc/lib/Makefile b/arch/arc/lib/Makefile
index 87d18f5013dc..28793e1ad1be 100644
--- a/arch/arc/lib/Makefile
+++ b/arch/arc/lib/Makefile
@@ -3,6 +3,8 @@
 # Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
 #
 
+ifndef CONFIG_ARC_LACKS_ZOL
+
 lib-y	:= strchr-700.o strcpy-700.o strlen.o memcmp.o
 
 lib-$(CONFIG_ISA_ARCOMPACT)	+= memcpy-700.o memset.o strcmp.o
@@ -14,4 +16,6 @@ else
 lib-$(CONFIG_ISA_ARCV2)		+=memcpy-archs.o
 endif
 
+endif
+
 lib-$(CONFIG_ARC_LACKS_ZOL)	+= uaccess.o
-- 
2.25.1




More information about the linux-snps-arc mailing list