Commit 1edad85b authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky

[S390] use compiler builtin versions of strlen/strcpy/strcat

Use builtin variants if gcc 4 or newer is used to compile the kernel.
Generates better code than the asm variants.
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 504665a9
...@@ -100,6 +100,7 @@ static inline char *strcat(char *dst, const char *src) ...@@ -100,6 +100,7 @@ static inline char *strcat(char *dst, const char *src)
static inline char *strcpy(char *dst, const char *src) static inline char *strcpy(char *dst, const char *src)
{ {
#if __GNUC__ < 4
register int r0 asm("0") = 0; register int r0 asm("0") = 0;
char *ret = dst; char *ret = dst;
...@@ -109,10 +110,14 @@ static inline char *strcpy(char *dst, const char *src) ...@@ -109,10 +110,14 @@ static inline char *strcpy(char *dst, const char *src)
: "+&a" (dst), "+&a" (src) : "d" (r0) : "+&a" (dst), "+&a" (src) : "d" (r0)
: "cc", "memory"); : "cc", "memory");
return ret; return ret;
#else
return __builtin_strcpy(dst, src);
#endif
} }
static inline size_t strlen(const char *s) static inline size_t strlen(const char *s)
{ {
#if __GNUC__ < 4
register unsigned long r0 asm("0") = 0; register unsigned long r0 asm("0") = 0;
const char *tmp = s; const char *tmp = s;
...@@ -121,6 +126,9 @@ static inline size_t strlen(const char *s) ...@@ -121,6 +126,9 @@ static inline size_t strlen(const char *s)
" jo 0b" " jo 0b"
: "+d" (r0), "+a" (tmp) : : "cc"); : "+d" (r0), "+a" (tmp) : : "cc");
return r0 - (unsigned long) s; return r0 - (unsigned long) s;
#else
return __builtin_strlen(s);
#endif
} }
static inline size_t strnlen(const char * s, size_t n) static inline size_t strnlen(const char * s, size_t n)
......
...@@ -44,7 +44,11 @@ static inline char *__strnend(const char *s, size_t n) ...@@ -44,7 +44,11 @@ static inline char *__strnend(const char *s, size_t n)
*/ */
size_t strlen(const char *s) size_t strlen(const char *s)
{ {
#if __GNUC__ < 4
return __strend(s) - s; return __strend(s) - s;
#else
return __builtin_strlen(s);
#endif
} }
EXPORT_SYMBOL(strlen); EXPORT_SYMBOL(strlen);
...@@ -70,6 +74,7 @@ EXPORT_SYMBOL(strnlen); ...@@ -70,6 +74,7 @@ EXPORT_SYMBOL(strnlen);
*/ */
char *strcpy(char *dest, const char *src) char *strcpy(char *dest, const char *src)
{ {
#if __GNUC__ < 4
register int r0 asm("0") = 0; register int r0 asm("0") = 0;
char *ret = dest; char *ret = dest;
...@@ -78,6 +83,9 @@ char *strcpy(char *dest, const char *src) ...@@ -78,6 +83,9 @@ char *strcpy(char *dest, const char *src)
: "+&a" (dest), "+&a" (src) : "d" (r0) : "+&a" (dest), "+&a" (src) : "d" (r0)
: "cc", "memory" ); : "cc", "memory" );
return ret; return ret;
#else
return __builtin_strcpy(dest, src);
#endif
} }
EXPORT_SYMBOL(strcpy); EXPORT_SYMBOL(strcpy);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment