diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2009-03-26 10:24:37 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2009-03-26 10:24:24 -0400 |
commit | 1edad85b16fdda43c8ab809e2779e8bf64ab8bb2 (patch) | |
tree | 45e777718c8fda461c2232f2b74b8dc0a04e4ea6 /arch/s390/include/asm | |
parent | 504665a91498f43d220b7d0942281067283a35f7 (diff) |
[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>
Diffstat (limited to 'arch/s390/include/asm')
-rw-r--r-- | arch/s390/include/asm/string.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/s390/include/asm/string.h b/arch/s390/include/asm/string.h index adf079170aa6..cd0241db5a46 100644 --- a/arch/s390/include/asm/string.h +++ b/arch/s390/include/asm/string.h | |||
@@ -100,6 +100,7 @@ static inline char *strcat(char *dst, const char *src) | |||
100 | 100 | ||
101 | static inline char *strcpy(char *dst, const char *src) | 101 | static inline char *strcpy(char *dst, const char *src) |
102 | { | 102 | { |
103 | #if __GNUC__ < 4 | ||
103 | register int r0 asm("0") = 0; | 104 | register int r0 asm("0") = 0; |
104 | char *ret = dst; | 105 | char *ret = dst; |
105 | 106 | ||
@@ -109,10 +110,14 @@ static inline char *strcpy(char *dst, const char *src) | |||
109 | : "+&a" (dst), "+&a" (src) : "d" (r0) | 110 | : "+&a" (dst), "+&a" (src) : "d" (r0) |
110 | : "cc", "memory"); | 111 | : "cc", "memory"); |
111 | return ret; | 112 | return ret; |
113 | #else | ||
114 | return __builtin_strcpy(dst, src); | ||
115 | #endif | ||
112 | } | 116 | } |
113 | 117 | ||
114 | static inline size_t strlen(const char *s) | 118 | static inline size_t strlen(const char *s) |
115 | { | 119 | { |
120 | #if __GNUC__ < 4 | ||
116 | register unsigned long r0 asm("0") = 0; | 121 | register unsigned long r0 asm("0") = 0; |
117 | const char *tmp = s; | 122 | const char *tmp = s; |
118 | 123 | ||
@@ -121,6 +126,9 @@ static inline size_t strlen(const char *s) | |||
121 | " jo 0b" | 126 | " jo 0b" |
122 | : "+d" (r0), "+a" (tmp) : : "cc"); | 127 | : "+d" (r0), "+a" (tmp) : : "cc"); |
123 | return r0 - (unsigned long) s; | 128 | return r0 - (unsigned long) s; |
129 | #else | ||
130 | return __builtin_strlen(s); | ||
131 | #endif | ||
124 | } | 132 | } |
125 | 133 | ||
126 | static inline size_t strnlen(const char * s, size_t n) | 134 | static inline size_t strnlen(const char * s, size_t n) |