summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86/core/x86_string.c18
-rw-r--r--src/arch/x86/include/bits/string.h14
2 files changed, 20 insertions, 12 deletions
diff --git a/src/arch/x86/core/x86_string.c b/src/arch/x86/core/x86_string.c
index 962a7d84d..69c73f704 100644
--- a/src/arch/x86/core/x86_string.c
+++ b/src/arch/x86/core/x86_string.c
@@ -106,6 +106,24 @@ void * __memmove ( void *dest, const void *src, size_t len ) {
}
/**
+ * Calculate length of string
+ *
+ * @v string String
+ * @ret len Length (excluding NUL)
+ */
+size_t strlen ( const char *string ) {
+ const char *discard_D;
+ size_t len_plus_one;
+
+ __asm__ __volatile__ ( "repne scasb\n\t"
+ "not %1\n\t"
+ : "=&D" ( discard_D ), "=&c" ( len_plus_one )
+ : "0" ( string ), "1" ( -1UL ), "a" ( 0 ) );
+
+ return ( len_plus_one - 1 );
+}
+
+/**
* Compare strings (up to a specified length)
*
* @v str1 First string
diff --git a/src/arch/x86/include/bits/string.h b/src/arch/x86/include/bits/string.h
index 75a1f01a8..249dd5438 100644
--- a/src/arch/x86/include/bits/string.h
+++ b/src/arch/x86/include/bits/string.h
@@ -234,17 +234,7 @@ return dest;
extern int strncmp ( const char *str1, const char *str2, size_t len );
#define __HAVE_ARCH_STRLEN
-static inline size_t strlen(const char * s)
-{
-int d0;
-register int __res;
-__asm__ __volatile__(
- "repne\n\t"
- "scasb\n\t"
- "notl %0\n\t"
- "decl %0"
- :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffff));
-return __res;
-}
+
+extern size_t strlen ( const char *string );
#endif /* ETHERBOOT_BITS_STRING_H */