[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: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
504665a914
commit
1edad85b16
|
@ -100,6 +100,7 @@ static inline char *strcat(char *dst, const char *src)
|
|||
|
||||
static inline char *strcpy(char *dst, const char *src)
|
||||
{
|
||||
#if __GNUC__ < 4
|
||||
register int r0 asm("0") = 0;
|
||||
char *ret = dst;
|
||||
|
||||
|
@ -109,10 +110,14 @@ static inline char *strcpy(char *dst, const char *src)
|
|||
: "+&a" (dst), "+&a" (src) : "d" (r0)
|
||||
: "cc", "memory");
|
||||
return ret;
|
||||
#else
|
||||
return __builtin_strcpy(dst, src);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline size_t strlen(const char *s)
|
||||
{
|
||||
#if __GNUC__ < 4
|
||||
register unsigned long r0 asm("0") = 0;
|
||||
const char *tmp = s;
|
||||
|
||||
|
@ -121,6 +126,9 @@ static inline size_t strlen(const char *s)
|
|||
" jo 0b"
|
||||
: "+d" (r0), "+a" (tmp) : : "cc");
|
||||
return r0 - (unsigned long) s;
|
||||
#else
|
||||
return __builtin_strlen(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
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)
|
|||
*/
|
||||
size_t strlen(const char *s)
|
||||
{
|
||||
#if __GNUC__ < 4
|
||||
return __strend(s) - s;
|
||||
#else
|
||||
return __builtin_strlen(s);
|
||||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL(strlen);
|
||||
|
||||
|
@ -70,6 +74,7 @@ EXPORT_SYMBOL(strnlen);
|
|||
*/
|
||||
char *strcpy(char *dest, const char *src)
|
||||
{
|
||||
#if __GNUC__ < 4
|
||||
register int r0 asm("0") = 0;
|
||||
char *ret = dest;
|
||||
|
||||
|
@ -78,6 +83,9 @@ char *strcpy(char *dest, const char *src)
|
|||
: "+&a" (dest), "+&a" (src) : "d" (r0)
|
||||
: "cc", "memory" );
|
||||
return ret;
|
||||
#else
|
||||
return __builtin_strcpy(dest, src);
|
||||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL(strcpy);
|
||||
|
||||
|
|
Loading…
Reference in New Issue