String-handling functions for the new x86 setup code.
[linux-2.6/kvm.git] / arch / i386 / boot / string.c
blob481a22097781953c088931b52021d9a5365b80b2
1 /* -*- linux-c -*- ------------------------------------------------------- *
3 * Copyright (C) 1991, 1992 Linus Torvalds
4 * Copyright 2007 rPath, Inc. - All Rights Reserved
6 * This file is part of the Linux kernel, and is made available under
7 * the terms of the GNU General Public License version 2.
9 * ----------------------------------------------------------------------- */
12 * arch/i386/boot/string.c
14 * Very basic string functions
17 #include "boot.h"
19 int strcmp(const char *str1, const char *str2)
21 const unsigned char *s1 = (const unsigned char *)str1;
22 const unsigned char *s2 = (const unsigned char *)str2;
23 int delta = 0;
25 while (*s1 || *s2) {
26 delta = *s2 - *s1;
27 if (delta)
28 return delta;
29 s1++;
30 s2++;
32 return 0;
35 size_t strnlen(const char *s, size_t maxlen)
37 const char *es = s;
38 while (*es && maxlen) {
39 es++;
40 maxlen--;
43 return (es - s);
46 unsigned int atou(const char *s)
48 unsigned int i = 0;
49 while (isdigit(*s))
50 i = i * 10 + (*s++ - '0');
51 return i;