Skip to contentSkip to conversation

parisc: Add assembly implementations for strlen, strcpy, strncpy and strcat

PATCH In review Helge Deller 3 participants 5 messages Feb 6, 2019 – Feb 7, 2019 PA-RISC architecture

lore
Share & tools
lore

Helge Deller

author maintainer
#0 lore raw

PATCH 1/1 parisc: Add assembly implementations for strlen, strcpy, strncpy and strcat

Add performance-optimized versions of the strlen, strcpy, strncpy and strcat string functions.

arch/parisc/include/asm/string.h +12 -0
index f6e1132f4e35..62a9be5e55b2 100644
@@ -8,4 +8,16 @@ extern void * memset(void *, int, size_t);
 #define __HAVE_ARCH_MEMCPY
 void * memcpy(void * dest,const void *src,size_t count);
 
+#define __HAVE_ARCH_STRLEN
+extern size_t strlen(const char *s);
+
+#define __HAVE_ARCH_STRCPY
+extern char *strcpy(char *dest, const char *src);
+
+#define __HAVE_ARCH_STRNCPY
+extern char *strncpy(char *dest, const char *src, size_t count);
+
+#define __HAVE_ARCH_STRCAT
+extern char *strcat(char *dest, const char *src);
+
 #endif
arch/parisc/kernel/parisc_ksyms.c +4 -0
index 7baa2265d439..9a72823e939c 100644
@@ -30,6 +30,10 @@
 
 #include <linux/string.h>
 EXPORT_SYMBOL(memset);
+EXPORT_SYMBOL(strlen);
+EXPORT_SYMBOL(strcpy);
+EXPORT_SYMBOL(strncpy);
+EXPORT_SYMBOL(strcat);
 
 #include <linux/atomic.h>
 EXPORT_SYMBOL(__xchg8);
arch/parisc/lib/Makefile +1 -1
index f2dac4d73b1b..c2d266358358 100644
@@ -3,6 +3,6 @@
 #
 
 lib-y	:= lusercopy.o bitops.o checksum.o io.o memset.o memcpy.o \
-	   ucmpdi2.o delay.o
+	   ucmpdi2.o delay.o string.o
 
 obj-y	:= iomap.o
arch/parisc/lib/string.S new file +107 -0

107 lines not on this page · raw message

#2 lore raw
In reply to Helge Deller
Quoted 3 lines · Helge Deller

Add performance-optimized versions of the strlen, strcpy, strncpy and strcat string functions.

Can you say anything else about them? E.g., are you using some feature that the compiler isn't able to generate? Do you have performance data?

Except for strlen, they look like straightforward translations of the simple C implementations.

author maintainer
#3 lore raw
Quoted 6 lines · Matt Turner
Quoted 3 lines · Helge Deller

Add performance-optimized versions of the strlen, strcpy, strncpy and strcat string functions.

Can you say anything else about them?

No.

Quoted 2 lines

E.g., are you using some feature that the compiler isn't able to generate?

Some assembler instructions are used which the compiler doesn't use by default for such use cases.

Quoted 1 line

Do you have performance data?

Not yet.
Maybe someone wants to do that?

Quoted 2 lines

Except for strlen, they look like straightforward translations of the simple C implementations.

The code is much smaller than what the compiler generates and the layout of the bytes-stores are targetted the behaviour of the parisc 64bit CPUs.

Helge

#4 lore raw
Quoted 23 lines · Helge Deller
Quoted 6 lines · Matt Turner
Quoted 3 lines · Helge Deller

Add performance-optimized versions of the strlen, strcpy, strncpy and strcat string functions.

Can you say anything else about them?

No.

Quoted 2 lines

E.g., are you using some feature that the compiler isn't able to generate?

Some assembler instructions are used which the compiler doesn't use by default for such use cases.

Quoted 1 line

Do you have performance data?

Not yet.
Maybe someone wants to do that?

Quoted 6 lines
Quoted 2 lines

Except for strlen, they look like straightforward translations of the simple C implementations.

The code is much smaller than what the compiler generates and the layout of the bytes-stores are targetted the behaviour of the parisc 64bit CPUs.

So is that the rationale? I'm not sure how anyone can offer review if they don't know what you're trying to accomplish.