diff options
Diffstat (limited to 'arch/x86/boot/string.c')
| -rw-r--r-- | arch/x86/boot/string.c | 46 | 
1 files changed, 45 insertions, 1 deletions
diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c index 3cbc4058dd2..493f3fd9f13 100644 --- a/arch/x86/boot/string.c +++ b/arch/x86/boot/string.c @@ -12,7 +12,16 @@   * Very basic string functions   */ -#include "boot.h" +#include <linux/types.h> +#include "ctype.h" + +int memcmp(const void *s1, const void *s2, size_t len) +{ +	u8 diff; +	asm("repe; cmpsb; setnz %0" +	    : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len)); +	return diff; +}  int strcmp(const char *str1, const char *str2)  { @@ -111,3 +120,38 @@ unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int bas  	return result;  } + +/** + * strlen - Find the length of a string + * @s: The string to be sized + */ +size_t strlen(const char *s) +{ +	const char *sc; + +	for (sc = s; *sc != '\0'; ++sc) +		/* nothing */; +	return sc - s; +} + +/** + * strstr - Find the first substring in a %NUL terminated string + * @s1: The string to be searched + * @s2: The string to search for + */ +char *strstr(const char *s1, const char *s2) +{ +	size_t l1, l2; + +	l2 = strlen(s2); +	if (!l2) +		return (char *)s1; +	l1 = strlen(s1); +	while (l1 >= l2) { +		l1--; +		if (!memcmp(s1, s2, l2)) +			return (char *)s1; +		s1++; +	} +	return NULL; +}  | 
