summaryrefslogtreecommitdiff
path: root/arch/i386/boot/string.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-07-11 19:18:41 (GMT)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-12 17:55:55 (GMT)
commit5be865661516263d90317a6b35b588a2d7c3cb55 (patch)
treed8eb903bc210256b3d4b667506279c0c8c21cab5 /arch/i386/boot/string.c
parentad7e906d5687bb076fe6c3c980d6e013a3a42bde (diff)
downloadlinux-fsl-qoriq-5be865661516263d90317a6b35b588a2d7c3cb55.tar.xz
String-handling functions for the new x86 setup code.
strcmp(), memcpy(), memset(), as well as routines to copy to and from other segments (as pointed to by fs and gs). Signed-off-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/i386/boot/string.c')
-rw-r--r--arch/i386/boot/string.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/arch/i386/boot/string.c b/arch/i386/boot/string.c
new file mode 100644
index 0000000..481a220
--- /dev/null
+++ b/arch/i386/boot/string.c
@@ -0,0 +1,52 @@
+/* -*- linux-c -*- ------------------------------------------------------- *
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ * Copyright 2007 rPath, Inc. - All Rights Reserved
+ *
+ * This file is part of the Linux kernel, and is made available under
+ * the terms of the GNU General Public License version 2.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * arch/i386/boot/string.c
+ *
+ * Very basic string functions
+ */
+
+#include "boot.h"
+
+int strcmp(const char *str1, const char *str2)
+{
+ const unsigned char *s1 = (const unsigned char *)str1;
+ const unsigned char *s2 = (const unsigned char *)str2;
+ int delta = 0;
+
+ while (*s1 || *s2) {
+ delta = *s2 - *s1;
+ if (delta)
+ return delta;
+ s1++;
+ s2++;
+ }
+ return 0;
+}
+
+size_t strnlen(const char *s, size_t maxlen)
+{
+ const char *es = s;
+ while (*es && maxlen) {
+ es++;
+ maxlen--;
+ }
+
+ return (es - s);
+}
+
+unsigned int atou(const char *s)
+{
+ unsigned int i = 0;
+ while (isdigit(*s))
+ i = i * 10 + (*s++ - '0');
+ return i;
+}