initial commit of lk (little kernel) project
diff --git a/lib/libc/atexit.c b/lib/libc/atexit.c
new file mode 100644
index 0000000..85d7bdf
--- /dev/null
+++ b/lib/libc/atexit.c
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/* nulled out atexit. static object constructors call this */
+int atexit(void (*func)(void))
+{
+	return 0;
+}
+
diff --git a/lib/libc/atoi.c b/lib/libc/atoi.c
new file mode 100644
index 0000000..e3dd320
--- /dev/null
+++ b/lib/libc/atoi.c
@@ -0,0 +1,105 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <ctype.h>
+
+#define LONG_IS_INT 1
+
+static int hexval(char c)
+{
+	if (c >= '0' && c <= '9')
+		return c - '0';
+	else if (c >= 'a' && c <= 'f')
+		return c - 'a' + 10;
+	else if (c >= 'A' && c <= 'F')
+		return c - 'A' + 10;
+		
+	return 0;
+}
+
+int atoi(const char *num)
+{
+#if !LONG_IS_INT
+	// XXX fail
+#else
+	return atol(num);
+#endif
+}
+
+unsigned int atoui(const char *num)
+{
+#if !LONG_IS_INT
+	// XXX fail
+#else
+	return atoul(num);
+#endif
+}
+
+long atol(const char *num)
+{
+	long value = 0;
+	int neg = 0;
+
+	if (num[0] == '0' && num[1] == 'x') {
+		// hex
+		num += 2;
+		while (*num && isxdigit(*num))
+			value = value * 16 + hexval(*num++);
+	} else {
+		// decimal
+		if (num[0] == '-') {
+			neg = 1;
+			num++;
+		}
+		while (*num && isdigit(*num))
+			value = value * 10 + *num++  - '0';
+	}
+
+	if (neg)
+		value = -value;
+
+	return value;
+}
+
+unsigned long atoul(const char *num)
+{
+	unsigned long value = 0;
+	if (num[0] == '0' && num[1] == 'x') {
+		// hex
+		num += 2;
+		while (*num && isxdigit(*num))
+			value = value * 16 + hexval(*num++);
+	} else {
+		// decimal
+		while (*num && isdigit(*num))
+			value = value * 10 + *num++  - '0';
+	}
+
+	return value;
+}
+
diff --git a/lib/libc/ctype.c b/lib/libc/ctype.c
new file mode 100644
index 0000000..1509822
--- /dev/null
+++ b/lib/libc/ctype.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <ctype.h>
+
+#if 0
+/* XXX unimplemented for now */
+int iscntrl(int c);
+int isgraph(int c);
+int isprint(int c);
+int ispunct(int c);
+#endif
+
+int isblank(int c)
+{
+	return (c == ' ' || c == '\t');
+}
+
+int isspace(int c)
+{
+	return (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v');
+}
+
+int islower(int c)
+{
+	return ((c >= 'a') && (c <= 'z'));
+}
+
+int isupper(int c)
+{
+	return ((c >= 'A') && (c <= 'Z'));
+}
+
+int isdigit(int c)
+{
+	return ((c >= '0') && (c <= '9'));
+}
+
+int isalpha(int c)
+{
+	return isupper(c) || islower(c);
+}
+
+int isalnum(int c)
+{
+	return isalpha(c) || isdigit(c);
+}
+
+int isxdigit(int c)
+{
+	return isdigit(c) || ((c >= 'a') && (c <= 'f')) || ((c >= 'A') && (c <= 'F'));
+}
+
+int tolower(int c)
+{
+	if ((c >= 'A') && (c <= 'Z'))
+		return c + ('a' - 'A');
+	return c;
+}
+
+int toupper(int c)
+{
+	if ((c >= 'a') && (c <= 'z'))
+		return c + ('A' - 'a');
+	return c;
+}
+
diff --git a/lib/libc/malloc.c b/lib/libc/malloc.c
new file mode 100644
index 0000000..fd5fe8a
--- /dev/null
+++ b/lib/libc/malloc.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <debug.h>
+#include <malloc.h>
+#include <string.h>
+#include <lib/heap.h>
+
+void *malloc(size_t size)
+{
+	return heap_alloc(size, 0);
+}
+
+void *memalign(size_t boundary, size_t size)
+{
+	return heap_alloc(size, boundary);
+}
+
+void *calloc(size_t count, size_t size)
+{
+	void *ptr;
+	size_t realsize = count * size;
+
+	ptr = heap_alloc(realsize, 0);
+	if (!ptr)
+		return NULL;
+
+	memset(ptr, 0, realsize);
+	return ptr;
+}
+
+void free(void *ptr)
+{
+	return heap_free(ptr);
+}
+
diff --git a/lib/libc/new.cpp b/lib/libc/new.cpp
new file mode 100644
index 0000000..3a5f431
--- /dev/null
+++ b/lib/libc/new.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2006 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <new.h>
+#include <debug.h>
+#include <kernel/heap.h>
+
+void *operator new(size_t s)
+{
+	return heap_alloc(s, 0);
+}
+
+void *operator new[](size_t s)
+{
+	return heap_alloc(s, 0);
+}
+
+void *operator new(size_t , void *p)
+{
+	return p;
+}
+
+void operator delete(void *p)
+{
+	return heap_free(p);
+}
+
+void operator delete[](void *p)
+{
+	return heap_free(p);
+}
+
diff --git a/lib/libc/printf.c b/lib/libc/printf.c
new file mode 100644
index 0000000..806d5a9
--- /dev/null
+++ b/lib/libc/printf.c
@@ -0,0 +1,305 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <limits.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <printf.h>
+#include <string.h>
+
+int printf(const char *fmt, ...)
+{
+	int err;
+
+	va_list ap;
+	va_start(ap, fmt);
+	err = dvprintf(fmt, ap);
+	va_end(ap);
+
+	return err;
+}
+
+int sprintf(char *str, const char *fmt, ...)
+{
+	int err;
+
+	va_list ap;
+	va_start(ap, fmt);
+	err = vsprintf(str, fmt, ap);
+	va_end(ap);
+
+	return err;
+}
+
+
+#define LONGFLAG     0x00000001
+#define LONGLONGFLAG 0x00000002
+#define HALFFLAG     0x00000004
+#define HALFHALFFLAG 0x00000008
+#define SIZETFLAG    0x00000010
+#define ALTFLAG      0x00000020
+#define CAPSFLAG     0x00000040
+#define SHOWSIGNFLAG 0x00000080
+#define SIGNEDFLAG   0x00000100
+#define LEFTFORMATFLAG 0x00000200
+#define LEADZEROFLAG 0x00000400
+
+static char *longlong_to_string(char *buf, unsigned long long n, int len, uint flag)
+{
+	int pos = len;
+	int negative = 0;
+
+	if((flag & SIGNEDFLAG) && (long long)n < 0) {
+		negative = 1;
+		n = -n;
+	}
+
+	buf[--pos] = 0;
+	
+	/* only do the math if the number is >= 10 */
+	while(n >= 10) {
+		int digit = n % 10;
+
+		n /= 10;
+
+		buf[--pos] = digit + '0';
+	}
+	buf[--pos] = n + '0';
+	
+	if(negative)
+		buf[--pos] = '-';
+	else if((flag & SHOWSIGNFLAG))
+		buf[--pos] = '+';
+
+	return &buf[pos];
+}
+
+static char *longlong_to_hexstring(char *buf, unsigned long long u, int len, uint flag)
+{
+	int pos = len;
+	static const char hextable[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+	static const char hextable_caps[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+	const char *table;
+
+	if((flag & CAPSFLAG))
+		table = hextable_caps;
+	else
+		table = hextable;
+
+	buf[--pos] = 0;
+	do {
+		unsigned int digit = u % 16;
+		u /= 16;
+	
+		buf[--pos] = table[digit];
+	} while(u != 0);
+
+	return &buf[pos];
+}
+
+int vsprintf(char *str, const char *fmt, va_list ap)
+{
+	char c;
+	unsigned char uc;
+	const char *s;
+	unsigned long long n;
+	void *ptr;
+	int flags;
+	unsigned int format_num;
+	int chars_written = 0;
+	char num_buffer[32];
+
+#define OUTPUT_CHAR(c) do { (*str++ = c); chars_written++; } while(0)
+
+	for(;;) {	
+		/* handle regular chars that aren't format related */
+		while((c = *fmt++) != 0) {
+			if(c == '%')
+				break; /* we saw a '%', break and start parsing format */
+			OUTPUT_CHAR(c);
+		}
+
+		/* make sure we haven't just hit the end of the string */
+		if(c == 0)
+			break;
+
+		/* reset the format state */
+		flags = 0;
+		format_num = 0;
+
+next_format:
+		/* grab the next format character */
+		c = *fmt++;
+		if(c == 0)
+			break;
+					
+		switch(c) {
+			case '0'...'9':
+				if (c == '0' && format_num == 0)
+					flags |= LEADZEROFLAG;
+				format_num *= 10;
+				format_num += c - '0';
+				goto next_format;
+			case '.':
+				/* XXX for now eat numeric formatting */
+				goto next_format;
+			case '%':
+				OUTPUT_CHAR('%');
+				break;
+			case 'c':
+				uc = va_arg(ap, unsigned int);
+				OUTPUT_CHAR(uc);
+				break;
+			case 's':
+				s = va_arg(ap, const char *);
+				if(s == 0)
+					s = "<null>";
+				goto _output_string;
+			case '-':
+				flags |= LEFTFORMATFLAG;
+				goto next_format;
+			case '+':
+				flags |= SHOWSIGNFLAG;
+				goto next_format;
+			case '#':
+				flags |= ALTFLAG;
+				goto next_format;
+			case 'l':
+				if(flags & LONGFLAG)
+					flags |= LONGLONGFLAG;
+				flags |= LONGFLAG;
+				goto next_format;
+			case 'h':
+				if(flags & HALFFLAG)
+					flags |= HALFHALFFLAG;
+				flags |= HALFFLAG;
+				goto next_format;
+		    case 'z':
+				flags |= SIZETFLAG;
+				goto next_format;
+			case 'D':
+				flags |= LONGFLAG;
+				/* fallthrough */
+			case 'i':
+			case 'd':
+				n = (flags & LONGLONGFLAG) ? va_arg(ap, long long) :
+					(flags & LONGFLAG) ? va_arg(ap, long) : 
+					(flags & HALFHALFFLAG) ? (signed char)va_arg(ap, int) :
+					(flags & HALFFLAG) ? (short)va_arg(ap, int) :
+					(flags & SIZETFLAG) ? va_arg(ap, ssize_t) :
+					va_arg(ap, int);
+				flags |= SIGNEDFLAG;
+				s = longlong_to_string(num_buffer, n, sizeof(num_buffer), flags);
+				goto _output_string;
+			case 'U':
+				flags |= LONGFLAG;
+				/* fallthrough */
+			case 'u':
+				n = (flags & LONGLONGFLAG) ? va_arg(ap, unsigned long long) :
+					(flags & LONGFLAG) ? va_arg(ap, unsigned long) : 
+					(flags & HALFHALFFLAG) ? (unsigned char)va_arg(ap, unsigned int) :
+					(flags & HALFFLAG) ? (unsigned short)va_arg(ap, unsigned int) :
+					(flags & SIZETFLAG) ? va_arg(ap, size_t) :
+					va_arg(ap, unsigned int);
+				s = longlong_to_string(num_buffer, n, sizeof(num_buffer), flags);
+				goto _output_string;
+			case 'p':
+				flags |= LONGFLAG | ALTFLAG;
+				goto hex;
+			case 'X':
+				flags |= CAPSFLAG;
+				/* fallthrough */
+hex:
+			case 'x':
+				n = (flags & LONGLONGFLAG) ? va_arg(ap, unsigned long long) :
+				    (flags & LONGFLAG) ? va_arg(ap, unsigned long) : 
+					(flags & HALFHALFFLAG) ? (unsigned char)va_arg(ap, unsigned int) :
+					(flags & HALFFLAG) ? (unsigned short)va_arg(ap, unsigned int) :
+					(flags & SIZETFLAG) ? va_arg(ap, size_t) :
+					va_arg(ap, unsigned int);
+				s = longlong_to_hexstring(num_buffer, n, sizeof(num_buffer), flags);
+				if(flags & ALTFLAG) {
+					OUTPUT_CHAR('0');
+					OUTPUT_CHAR((flags & CAPSFLAG) ? 'X': 'x');
+				}
+				goto _output_string;
+			case 'n':
+				ptr = va_arg(ap, void *);
+				if(flags & LONGLONGFLAG)
+					*(long long *)ptr = chars_written;
+				else if(flags & LONGFLAG)
+					*(long *)ptr = chars_written;
+				else if(flags & HALFHALFFLAG)
+					*(signed char *)ptr = chars_written;
+				else if(flags & HALFFLAG)
+					*(short *)ptr = chars_written;
+				else if(flags & SIZETFLAG)
+					*(size_t *)ptr = chars_written;
+				else 
+					*(int *)ptr = chars_written;
+				break;
+			default:
+				OUTPUT_CHAR('%');
+				OUTPUT_CHAR(c);
+				break;
+		}
+
+		/* move on to the next field */
+		continue;
+
+		/* shared output code */
+_output_string:
+		if (flags & LEFTFORMATFLAG) {
+			/* left justify the text */
+			uint count = 0;
+			while(*s != 0) {
+				OUTPUT_CHAR(*s++);
+				count++;
+			}
+
+			/* pad to the right (if necessary) */
+			for (; format_num > count; format_num--)
+				OUTPUT_CHAR(' ');
+		} else {
+			/* right justify the text (digits) */
+			size_t string_len = strlen(s);
+			char outchar = (flags & LEADZEROFLAG) ? '0' : ' ';
+			for (; format_num > string_len; format_num--)
+				OUTPUT_CHAR(outchar);
+
+			/* output the string */
+			while(*s != 0)
+				OUTPUT_CHAR(*s++);
+		}
+		continue;
+	}
+
+	/* null terminate */
+	OUTPUT_CHAR('\0');
+	chars_written--; /* don't count the null */
+
+#undef OUTPUT_CHAR
+
+	return chars_written;
+}
+
+
diff --git a/lib/libc/pure_virtual.cpp b/lib/libc/pure_virtual.cpp
new file mode 100644
index 0000000..68cfe3b
--- /dev/null
+++ b/lib/libc/pure_virtual.cpp
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2006 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <debug.h>
+
+extern "C" void __cxa_pure_virtual(void)
+{
+	panic("pure virtual called\n");	
+}
+
diff --git a/lib/libc/rand.c b/lib/libc/rand.c
new file mode 100644
index 0000000..fe4f392
--- /dev/null
+++ b/lib/libc/rand.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <rand.h>
+
+static int randseed = 12345;
+
+int rand(void)
+{
+	return (randseed = randseed * 12345 + 17);
+}
diff --git a/lib/libc/rules.mk b/lib/libc/rules.mk
new file mode 100644
index 0000000..1d43092
--- /dev/null
+++ b/lib/libc/rules.mk
@@ -0,0 +1,19 @@
+LOCAL_DIR := $(GET_LOCAL_DIR)
+
+OBJS += \
+	$(LOCAL_DIR)/atoi.o \
+	$(LOCAL_DIR)/ctype.o \
+	$(LOCAL_DIR)/printf.o \
+	$(LOCAL_DIR)/malloc.o \
+	$(LOCAL_DIR)/rand.o \
+
+
+include $(LOCAL_DIR)/string/rules.mk
+
+ifeq ($(WITH_CPP_SUPPORT),true)
+OBJS += \
+	$(LOCAL_DIR)/new.o \
+	$(LOCAL_DIR)/atexit.o \
+	$(LOCAL_DIR)/pure_virtual.o
+endif
+
diff --git a/lib/libc/string/arch/arm/memcpy.S b/lib/libc/string/arch/arm/memcpy.S
new file mode 100644
index 0000000..3b7816d
--- /dev/null
+++ b/lib/libc/string/arch/arm/memcpy.S
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <asm.h>
+#include <arch/arm/cores.h>
+
+.text
+.align 2
+
+/* void bcopy(const void *src, void *dest, size_t n); */
+FUNCTION(bcopy)
+	// swap args for bcopy
+	mov	r12, r0
+	mov	r0, r1
+	mov r1, r12
+
+/* void *memcpy(void *dest, const void *src, size_t n); */
+FUNCTION(memmove)
+FUNCTION(memcpy)
+	// check for zero length copy or the same pointer
+	cmp		r2, #0
+	cmpne	r1, r0
+	bxeq	lr
+
+	// save a few registers for use and the return code (input dst)
+	stmfd	sp!, {r0, r4, r5, lr}
+
+	// check for forwards overlap (src > dst, distance < len)
+	subs	r3, r0, r1
+	cmpgt	r2, r3
+	bgt		.L_forwardoverlap
+
+	// check for a short copy len.
+	// 20 bytes is enough so that if a 16 byte alignment needs to happen there is at least a 
+	//   wordwise copy worth of work to be done.
+	cmp		r2, #(16+4)
+	blt		.L_bytewise
+
+	// see if they are similarly aligned on 4 byte boundaries
+	eor		r3, r0, r1
+	tst		r3, #3
+	bne		.L_bytewise		// dissimilarly aligned, nothing we can do (for now)
+
+	// check for 16 byte alignment on dst.
+	// this will also catch src being not 4 byte aligned, since it is similarly 4 byte 
+	//   aligned with dst at this point.
+	tst		r0, #15
+	bne		.L_not16bytealigned
+
+	// check to see if we have at least 32 bytes of data to copy.
+	// if not, just revert to wordwise copy
+	cmp		r2, #32
+	blt		.L_wordwise
+
+.L_bigcopy:
+	// copy 32 bytes at a time. src & dst need to be at least 4 byte aligned, 
+	// and we need at least 32 bytes remaining to copy
+
+	// save r6-r7 for use in the big copy
+	stmfd	sp!, {r6-r7}
+
+	sub		r2, r2, #32		// subtract an extra 32 to the len so we can avoid an extra compare
+
+.L_bigcopy_loop:
+	ldmia	r1!, {r4, r5, r6, r7}
+	stmia	r0!, {r4, r5, r6, r7}
+	ldmia	r1!, {r4, r5, r6, r7}
+	subs	r2, r2, #32
+	stmia	r0!, {r4, r5, r6, r7}
+	bge		.L_bigcopy_loop
+
+	// restore r6-r7
+	ldmfd	sp!, {r6-r7}
+
+	// see if we are done
+	adds	r2, r2, #32
+	beq		.L_done
+
+	// less then 4 bytes left?
+	cmp		r2, #4
+	blt		.L_bytewise
+
+.L_wordwise:
+	// copy 4 bytes at a time.
+	// src & dst are guaranteed to be word aligned, and at least 4 bytes are left to copy.
+	subs	r2, r2, #4
+
+.L_wordwise_loop:
+	ldr		r3, [r1], #4
+	subs	r2, r2, #4
+	str		r3, [r0], #4
+	bge		.L_wordwise_loop
+
+	// correct the remaining len and test for completion
+	adds	r2, r2, #4	
+	beq		.L_done
+
+.L_bytewise:
+	// simple bytewise copy
+	ldrb	r3, [r1], #1
+	subs	r2, r2, #1
+	strb	r3, [r0], #1
+	bgt		.L_bytewise
+
+.L_done:
+	// load dst for return and restore r4,r5
+#if ARM_ARCH_LEVEL >= 5
+	ldmfd	sp!, {r0, r4, r5, pc}
+#else
+	ldmfd	sp!, {r0, r4, r5, lr}
+	bx		lr
+#endif
+
+.L_not16bytealigned:
+	// dst is not 16 byte aligned, so we will copy up to 15 bytes to get it aligned.
+	// src is guaranteed to be similarly word aligned with dst.
+
+	// set the condition flags based on the alignment.
+	lsl		r12, r0, #28
+	rsb		r12, r12, #0
+	msr		CPSR_f, r12				// move into NZCV fields in CPSR
+
+	// move as many bytes as necessary to get the dst aligned
+	ldrvsb	r3, [r1], #1			// V set
+	ldrcsh	r4, [r1], #2			// C set
+	ldreq	r5, [r1], #4			// Z set
+
+	strvsb	r3, [r0], #1
+	strcsh	r4, [r0], #2
+	streq	r5, [r0], #4
+
+	ldmmiia	r1!, {r3-r4}			// N set
+	stmmiia	r0!, {r3-r4}
+
+	// fix the remaining len
+	sub		r2, r2, r12, lsr #28
+
+	// test to see what we should do now
+	cmp		r2, #32
+	bge		.L_bigcopy
+	b		.L_wordwise
+	
+	// src and dest overlap 'forwards' or dst > src
+.L_forwardoverlap:
+
+	// do a bytewise reverse copy for now
+	add		r1, r1, r2
+	add		r0, r0, r2
+
+.L_bytewisereverse:
+	// simple bytewise reverse copy
+	ldrb	r3, [r1], #-1
+	subs	r2, r2, #1
+	strb	r3, [r0], #-1
+	bgt		.L_bytewisereverse
+
+	b		.L_done
+
diff --git a/lib/libc/string/arch/arm/memset.S b/lib/libc/string/arch/arm/memset.S
new file mode 100644
index 0000000..b31d053
--- /dev/null
+++ b/lib/libc/string/arch/arm/memset.S
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <asm.h>
+#include <arch/arm/cores.h>
+
+.text
+.align 2
+
+/* void bzero(void *s, size_t n); */
+FUNCTION(bzero)
+	mov		r2, r1
+	mov		r1, #0
+
+/* void *memset(void *s, int c, size_t n); */
+FUNCTION(memset)
+	// check for zero length
+	cmp		r2, #0
+	bxeq	lr
+
+	// save the original pointer
+	mov		r12, r0
+
+	// short memsets aren't worth optimizing
+	cmp		r2, #(32 + 16)
+	blt		.L_bytewise
+
+	// fill a 32 bit register with the 8 bit value
+	and		r1, r1, #0xff
+	orr		r1, r1, r1, lsl #8
+	orr		r1, r1, r1, lsl #16
+
+	// check for 16 byte alignment
+	tst		r0, #15
+	bne		.L_not16bytealigned
+
+.L_bigset:
+	// dump some registers to make space for our values
+	stmfd	sp!, { r4-r5 }
+	
+	// fill a bunch of registers with the set value
+	mov		r3, r1
+	mov		r4, r1
+	mov		r5, r1
+
+	// prepare the count register so we can avoid an extra compare
+	sub 	r2, r2, #32
+
+	// 32 bytes at a time
+.L_bigset_loop:
+	stmia	r0!, { r1, r3, r4, r5 }
+	subs	r2, r2, #32
+	stmia	r0!, { r1, r3, r4, r5 }
+	bge		.L_bigset_loop
+
+	// restore our dumped registers
+	ldmfd	sp!, { r4-r5 }
+
+	// see if we're done
+	adds	r2, r2, #32
+	beq		.L_done
+
+.L_bytewise:
+	// bytewise memset
+	subs	r2, r2, #1
+	strb	r1, [r0], #1
+	bgt		.L_bytewise
+
+.L_done:
+	// restore the base pointer as return value
+	mov		r0, r12
+	bx		lr
+
+.L_not16bytealigned:
+	// dst is not 16 byte aligned, so we will set up to 15 bytes to get it aligned.
+
+	// set the condition flags based on the alignment.
+	lsl     r3, r0, #28
+	rsb     r3, r3, #0
+	msr     CPSR_f, r3             // move into NZCV fields in CPSR
+
+	// move as many bytes as necessary to get the dst aligned
+	strvsb  r1, [r0], #1			// V set
+	strcsh  r1, [r0], #2			// C set
+	streq   r1, [r0], #4			// Z set
+	strmi   r1, [r0], #4			// N set
+	strmi   r1, [r0], #4			// N set
+
+	// fix the remaining len
+	sub     r2, r2, r3, lsr #28
+
+	// do the large memset
+	b       .L_bigset
+
diff --git a/lib/libc/string/arch/arm/rules.mk b/lib/libc/string/arch/arm/rules.mk
new file mode 100644
index 0000000..89a68f4
--- /dev/null
+++ b/lib/libc/string/arch/arm/rules.mk
@@ -0,0 +1,11 @@
+LOCAL_DIR := $(GET_LOCAL_DIR)
+
+ASM_STRING_OPS := bcopy bzero memcpy memmove memset
+
+OBJS += \
+	$(LOCAL_DIR)/memcpy.o \
+	$(LOCAL_DIR)/memset.o
+
+# filter out the C implementation
+C_STRING_OPS := $(filter-out $(ASM_STRING_OPS),$(C_STRING_OPS))
+
diff --git a/lib/libc/string/bcopy.c b/lib/libc/string/bcopy.c
new file mode 100644
index 0000000..873e6f6
--- /dev/null
+++ b/lib/libc/string/bcopy.c
@@ -0,0 +1,35 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+void *
+bcopy(void const *src, void *dest, size_t count)
+{
+	return memcpy(dest, src, count);
+}
+
diff --git a/lib/libc/string/bzero.c b/lib/libc/string/bzero.c
new file mode 100644
index 0000000..32b43bb
--- /dev/null
+++ b/lib/libc/string/bzero.c
@@ -0,0 +1,35 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+void
+bzero(void *dst, size_t count)
+{
+	memset(dst, 0, count);
+}
+
diff --git a/lib/libc/string/memchr.c b/lib/libc/string/memchr.c
new file mode 100644
index 0000000..094c2a1
--- /dev/null
+++ b/lib/libc/string/memchr.c
@@ -0,0 +1,45 @@
+/*
+** Copyright 2001, Manuel J. Petit. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+void *
+memchr(void const *buf, int c, size_t len)
+{
+	size_t i;
+	unsigned char const *b= buf;
+	unsigned char        x= (c&0xff);
+
+	for(i= 0; i< len; i++) {
+		if(b[i]== x) {
+			return (void*)(b+i);
+		}
+	}
+
+	return NULL;
+}
+
diff --git a/lib/libc/string/memcmp.c b/lib/libc/string/memcmp.c
new file mode 100644
index 0000000..a050bc7
--- /dev/null
+++ b/lib/libc/string/memcmp.c
@@ -0,0 +1,40 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+int
+memcmp(const void *cs, const void *ct, size_t count)
+{
+	const unsigned char *su1, *su2;
+	signed char res = 0;
+
+	for(su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
+		if((res = *su1 - *su2) != 0)
+			break;
+	return res;
+}
diff --git a/lib/libc/string/memcpy.c b/lib/libc/string/memcpy.c
new file mode 100644
index 0000000..00e547e
--- /dev/null
+++ b/lib/libc/string/memcpy.c
@@ -0,0 +1,69 @@
+/*
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+
+#if !_ASM_MEMCPY
+
+typedef long word;
+
+#define lsize sizeof(word)
+#define lmask (lsize - 1)
+
+void *memcpy(void *dest, const void *src, size_t count)
+{
+	char *d = (char *)dest;
+	const char *s = (const char *)src;
+	int len;
+
+	if(count == 0 || dest == src)
+		return dest;
+
+	if(((long)d | (long)s) & lmask) {
+		// src and/or dest do not align on word boundary
+		if((((long)d ^ (long)s) & lmask) || (count < lsize))
+			len = count; // copy the rest of the buffer with the byte mover
+		else
+			len = lsize - ((long)d & lmask); // move the ptrs up to a word boundary
+
+		count -= len;
+		for(; len > 0; len--)
+			*d++ = *s++;
+	}
+	for(len = count / lsize; len > 0; len--) {
+		*(word *)d = *(word *)s;
+		d += lsize;
+		s += lsize;
+	}
+	for(len = count & lmask; len > 0; len--)
+		*d++ = *s++;
+
+	return dest;
+}
+
+#endif
diff --git a/lib/libc/string/memmove.c b/lib/libc/string/memmove.c
new file mode 100644
index 0000000..cb08a6c
--- /dev/null
+++ b/lib/libc/string/memmove.c
@@ -0,0 +1,93 @@
+/*
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+#if !_ASM_MEMMOVE
+
+typedef long word;
+
+#define lsize sizeof(word)
+#define lmask (lsize - 1)
+
+void *
+memmove(void *dest, void const *src, size_t count)
+{
+	char *d = (char *)dest;
+	const char *s = (const char *)src;
+	int len;
+
+	if(count == 0 || dest == src)
+		return dest;
+
+	if((long)d < (long)s) {
+		if(((long)d | (long)s) & lmask) {
+			// src and/or dest do not align on word boundary
+			if((((long)d ^ (long)s) & lmask) || (count < lsize))
+				len = count; // copy the rest of the buffer with the byte mover
+			else
+				len = lsize - ((long)d & lmask); // move the ptrs up to a word boundary
+
+			count -= len;
+			for(; len > 0; len--)
+				*d++ = *s++;
+		}
+		for(len = count / lsize; len > 0; len--) {
+			*(word *)d = *(word *)s;
+			d += lsize;
+			s += lsize;
+		}
+		for(len = count & lmask; len > 0; len--)
+			*d++ = *s++;
+	} else {
+		d += count;
+		s += count;
+		if(((long)d | (long)s) & lmask) {
+			// src and/or dest do not align on word boundary
+			if((((long)d ^ (long)s) & lmask) || (count <= lsize))
+				len = count;
+			else
+				len = ((long)d & lmask);
+
+			count -= len;
+			for(; len > 0; len--)
+				*--d = *--s;
+		}
+		for(len = count / lsize; len > 0; len--) {
+			d -= lsize;
+			s -= lsize;
+			*(word *)d = *(word *)s;
+		}
+		for(len = count & lmask; len > 0; len--)
+			*--d = *--s;
+	}
+
+	return dest;
+}
+
+#endif
+
diff --git a/lib/libc/string/memscan.c b/lib/libc/string/memscan.c
new file mode 100644
index 0000000..7d58cf2
--- /dev/null
+++ b/lib/libc/string/memscan.c
@@ -0,0 +1,41 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <libc/string.h>
+#include <libc/ctype.h>
+
+void *memscan(void *addr, int c, size_t size)
+{
+	unsigned char *p = (unsigned char *)addr;
+
+	while(size) {
+		if(*p == c)
+			return (void *)p;
+		p++;
+		size--;
+	}
+  	return (void *)p;
+}
diff --git a/lib/libc/string/memset.c b/lib/libc/string/memset.c
new file mode 100644
index 0000000..1abee39
--- /dev/null
+++ b/lib/libc/string/memset.c
@@ -0,0 +1,61 @@
+/*
+** Copyright 2005, Michael Noisternig. All rights reserved.
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+void *
+memset(void *s, int c, size_t count)
+{
+	char *xs = (char *) s;
+	size_t len = (-(size_t)s) & (sizeof(size_t)-1);
+	int cc = c & 0xff;
+
+	if ( count > len ) {
+		count -= len;
+		cc |= cc << 8;
+		cc |= cc << 16;
+
+		// write to non-aligned memory byte-wise
+		for ( ; len > 0; len-- )
+			*xs++ = c;
+
+		// write to aligned memory dword-wise
+		for ( len = count/sizeof(size_t); len > 0; len-- ) {
+			*((size_t *)xs) = cc;
+			xs += sizeof(size_t);
+		}
+
+		count &= sizeof(size_t)-1;
+	}
+
+	// write remaining bytes
+	for ( ; count > 0; count-- )
+		*xs++ = c;
+
+	return s;
+}
diff --git a/lib/libc/string/rules.mk b/lib/libc/string/rules.mk
new file mode 100644
index 0000000..1d038e6
--- /dev/null
+++ b/lib/libc/string/rules.mk
@@ -0,0 +1,42 @@
+LOCAL_DIR := $(GET_LOCAL_DIR)
+
+C_STRING_OPS := \
+	bcopy \
+	bzero \
+	memchr \
+	memcmp \
+	memcpy \
+	memmove \
+	memset \
+	strcat \
+	strchr \
+	strcmp \
+	strcoll \
+	strcpy \
+	strdup \
+	strerror \
+	strlcat \
+	strlcpy \
+	strlen \
+	strncat \
+	strncpy \
+	strncmp \
+	strnicmp \
+	strnlen \
+	strpbrk \
+	strrchr \
+	strspn \
+	strstr \
+	strtok \
+	strxfrm
+
+LIBC_STRING_C_DIR := $(LOCAL_DIR)
+
+# include the arch specific string routines
+#
+# the makefile may filter out implemented versions from the C_STRING_OPS variable
+include $(LOCAL_DIR)/arch/$(ARCH)/rules.mk
+
+OBJS += \
+	$(addprefix $(LIBC_STRING_C_DIR)/,$(addsuffix .o,$(C_STRING_OPS)))
+
diff --git a/lib/libc/string/strcat.c b/lib/libc/string/strcat.c
new file mode 100644
index 0000000..445b95a
--- /dev/null
+++ b/lib/libc/string/strcat.c
@@ -0,0 +1,42 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+char *
+strcat(char *dest,  char const*src)
+{
+	char *tmp = dest;
+
+	while(*dest)
+		dest++;
+	while((*dest++ = *src++) != '\0')
+		;
+
+	return tmp;
+}
+
diff --git a/lib/libc/string/strchr.c b/lib/libc/string/strchr.c
new file mode 100644
index 0000000..4c6bb16
--- /dev/null
+++ b/lib/libc/string/strchr.c
@@ -0,0 +1,37 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+char *
+strchr(const char *s, int c)
+{
+	for(; *s != (char) c; ++s)
+		if (*s == '\0')
+			return NULL;
+	return (char *) s;
+}
diff --git a/lib/libc/string/strcmp.c b/lib/libc/string/strcmp.c
new file mode 100644
index 0000000..5402718
--- /dev/null
+++ b/lib/libc/string/strcmp.c
@@ -0,0 +1,41 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+int
+strcmp(char const *cs, char const *ct)
+{
+	signed char __res;
+
+	while(1) {
+		if((__res = *cs - *ct++) != 0 || !*cs++)
+			break;
+	}
+
+	return __res;
+}
diff --git a/lib/libc/string/strcoll.c b/lib/libc/string/strcoll.c
new file mode 100644
index 0000000..021946a
--- /dev/null
+++ b/lib/libc/string/strcoll.c
@@ -0,0 +1,34 @@
+/* 
+** Copyright 2004, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+
+int
+strcoll(const char *s1, const char *s2)
+{
+	return strcmp(s1, s2);
+}
+
diff --git a/lib/libc/string/strcpy.c b/lib/libc/string/strcpy.c
new file mode 100644
index 0000000..e6cc78e
--- /dev/null
+++ b/lib/libc/string/strcpy.c
@@ -0,0 +1,39 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+char *
+strcpy(char *dest, char const *src)
+{
+	char *tmp = dest;
+
+	while((*dest++ = *src++) != '\0')
+		;
+	return tmp;
+}
+
diff --git a/lib/libc/string/strdup.c b/lib/libc/string/strdup.c
new file mode 100644
index 0000000..bbfc6a3
--- /dev/null
+++ b/lib/libc/string/strdup.c
@@ -0,0 +1,43 @@
+/* 
+** Copyright 2004, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <stdlib.h>
+#include <string.h>
+
+char *
+strdup(const char *str)
+{
+	size_t len;
+	char *copy;
+	
+	len = strlen(str) + 1;
+	copy = malloc(len);
+	if (copy == NULL)
+		return NULL;
+	memcpy(copy, str, len);
+	return copy;
+}
+
diff --git a/lib/libc/string/strerror.c b/lib/libc/string/strerror.c
new file mode 100644
index 0000000..7319659
--- /dev/null
+++ b/lib/libc/string/strerror.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <string.h>
+#include <sys/types.h>
+
+char const *
+strerror(int errnum)
+{
+	if (errnum < 0) {
+		return "General Error";
+	} else {
+		return "No Error";
+	}
+}
+
diff --git a/lib/libc/string/strlcat.c b/lib/libc/string/strlcat.c
new file mode 100644
index 0000000..5e3488d
--- /dev/null
+++ b/lib/libc/string/strlcat.c
@@ -0,0 +1,50 @@
+/*
+** Copyright 2002, Manuel J. Petit. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <string.h>
+#include <sys/types.h>
+
+size_t
+strlcat(char *dst, char const *src, size_t s)
+{
+	size_t i;
+	size_t j= strnlen(dst, s);
+
+	if(!s) {
+		return j+strlen(src);
+	}
+
+	dst+= j;
+
+	for(i= 0; ((i< s-1) && src[i]); i++) {
+		dst[i]= src[i];
+	}
+
+	dst[i]= 0;
+
+	return j + i + strlen(src+i);
+}
diff --git a/lib/libc/string/strlcpy.c b/lib/libc/string/strlcpy.c
new file mode 100644
index 0000000..a0995a0
--- /dev/null
+++ b/lib/libc/string/strlcpy.c
@@ -0,0 +1,47 @@
+/*
+** Copyright 2002, Manuel J. Petit. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <string.h>
+#include <sys/types.h>
+
+size_t
+strlcpy(char *dst, char const *src, size_t s)
+{
+	size_t i= 0;
+
+	if(!s) {
+		return strlen(src);
+	}
+
+	for(i= 0; ((i< s-1) && src[i]); i++) {
+		dst[i]= src[i];
+	}
+
+	dst[i]= 0;
+
+	return i + strlen(src+i);
+}
diff --git a/lib/libc/string/strlen.c b/lib/libc/string/strlen.c
new file mode 100644
index 0000000..9f87fc0
--- /dev/null
+++ b/lib/libc/string/strlen.c
@@ -0,0 +1,41 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+size_t
+strlen(char const *s)
+{
+	size_t i;
+
+	i= 0;
+	while(s[i]) {
+		i+= 1;
+	}
+
+	return i;
+}
diff --git a/lib/libc/string/strncat.c b/lib/libc/string/strncat.c
new file mode 100644
index 0000000..fe0393d
--- /dev/null
+++ b/lib/libc/string/strncat.c
@@ -0,0 +1,48 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+char *
+strncat(char *dest, char const *src, size_t count)
+{
+	char *tmp = dest;
+
+	if(count > 0) {
+		while(*dest)
+			dest++;
+		while((*dest++ = *src++)) {
+			if (--count == 0) {
+				*dest = '\0';
+				break;
+			}
+		}
+	}
+
+	return tmp;
+}
+
diff --git a/lib/libc/string/strncmp.c b/lib/libc/string/strncmp.c
new file mode 100644
index 0000000..2f4d877
--- /dev/null
+++ b/lib/libc/string/strncmp.c
@@ -0,0 +1,42 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+int
+strncmp(char const *cs, char const *ct, size_t count)
+{
+	signed char __res = 0;
+
+	while(count > 0) {
+		if ((__res = *cs - *ct++) != 0 || !*cs++)
+			break;
+		count--;
+	}
+
+	return __res;
+}
diff --git a/lib/libc/string/strncpy.c b/lib/libc/string/strncpy.c
new file mode 100644
index 0000000..b0bf174
--- /dev/null
+++ b/lib/libc/string/strncpy.c
@@ -0,0 +1,40 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+char *
+strncpy(char *dest, char const *src, size_t count)
+{
+	char *tmp = dest;
+
+	while(count-- && (*dest++ = *src++) != '\0')
+		;
+
+	return tmp;
+}
+
diff --git a/lib/libc/string/strnicmp.c b/lib/libc/string/strnicmp.c
new file mode 100644
index 0000000..0ca82b3
--- /dev/null
+++ b/lib/libc/string/strnicmp.c
@@ -0,0 +1,55 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <ctype.h>
+#include <sys/types.h>
+
+int
+strnicmp(char const *s1, char const *s2, size_t len)
+{
+	unsigned char c1 = '\0';
+	unsigned char c2 = '\0';
+
+	if(len > 0) {
+		do {
+			c1 = *s1; c2 = *s2;
+			s1++; s2++;
+			if(!c1)
+				break;
+			if(!c2)
+				break;
+			if(c1 == c2)
+				continue;
+			c1 = tolower(c1);
+			c2 = tolower(c2);
+			if (c1 != c2)
+				break;
+		} while(--len);
+	}
+	return (int)c1 - (int)c2;
+}
+#pragma weak strncasecmp=strnicmp
diff --git a/lib/libc/string/strnlen.c b/lib/libc/string/strnlen.c
new file mode 100644
index 0000000..afd19a7
--- /dev/null
+++ b/lib/libc/string/strnlen.c
@@ -0,0 +1,38 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+size_t
+strnlen(char const *s, size_t count)
+{
+	const char *sc;
+
+	for(sc = s; count-- && *sc != '\0'; ++sc)
+		;
+	return sc - s;
+}
diff --git a/lib/libc/string/strpbrk.c b/lib/libc/string/strpbrk.c
new file mode 100644
index 0000000..a97bcb6
--- /dev/null
+++ b/lib/libc/string/strpbrk.c
@@ -0,0 +1,44 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+char *
+strpbrk(char const *cs, char const *ct)
+{
+	const char *sc1;
+	const char *sc2;
+
+	for(sc1 = cs; *sc1 != '\0'; ++sc1) {
+		for(sc2 = ct; *sc2 != '\0'; ++sc2) {
+			if(*sc1 == *sc2)
+				return (char *)sc1;
+		}
+	}
+
+	return NULL;
+}
diff --git a/lib/libc/string/strrchr.c b/lib/libc/string/strrchr.c
new file mode 100644
index 0000000..5327659
--- /dev/null
+++ b/lib/libc/string/strrchr.c
@@ -0,0 +1,45 @@
+/* 
+** Copyright 2001, Manuel J. Petit. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+char *
+strrchr(char const *s, int c)
+{
+	char const *last= c?0:s;
+
+
+	while(*s) {
+		if(*s== c) {
+			last= s;
+		}
+
+		s+= 1;
+	}
+
+	return (char *)last;
+}
diff --git a/lib/libc/string/strspn.c b/lib/libc/string/strspn.c
new file mode 100644
index 0000000..354c1d6
--- /dev/null
+++ b/lib/libc/string/strspn.c
@@ -0,0 +1,48 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+size_t
+strspn(char const *s, char const *accept)
+{
+	const char *p;
+	const char *a;
+	size_t count = 0;
+
+	for(p = s; *p != '\0'; ++p) {
+		for(a = accept; *a != '\0'; ++a) {
+			if(*p == *a)
+				break;
+		}
+		if(*a == '\0')
+			return count;
+		++count;
+	}
+
+	return count;
+}
diff --git a/lib/libc/string/strstr.c b/lib/libc/string/strstr.c
new file mode 100644
index 0000000..a36b3f9
--- /dev/null
+++ b/lib/libc/string/strstr.c
@@ -0,0 +1,46 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+char *
+strstr(char const *s1, char const *s2)
+{
+	int 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;
+}
diff --git a/lib/libc/string/strtok.c b/lib/libc/string/strtok.c
new file mode 100644
index 0000000..b7c4585
--- /dev/null
+++ b/lib/libc/string/strtok.c
@@ -0,0 +1,51 @@
+/* 
+** Copyright 2001, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+static char *___strtok = NULL;
+
+char *
+strtok(char *s, char const *ct)
+{
+	char *sbegin, *send;
+
+	sbegin  = s ? s : ___strtok;
+	if (!sbegin) {
+		return NULL;
+	}
+	sbegin += strspn(sbegin,ct);
+	if (*sbegin == '\0') {
+		___strtok = NULL;
+		return( NULL );
+	}
+	send = strpbrk( sbegin, ct);
+	if (send && *send != '\0')
+		*send++ = '\0';
+	___strtok = send;
+	return (sbegin);
+}
diff --git a/lib/libc/string/strxfrm.c b/lib/libc/string/strxfrm.c
new file mode 100644
index 0000000..df005ec
--- /dev/null
+++ b/lib/libc/string/strxfrm.c
@@ -0,0 +1,42 @@
+/* 
+** Copyright 2004, Travis Geiselbrecht. All rights reserved.
+** Distributed under the terms of the NewOS License.
+*/
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <string.h>
+#include <sys/types.h>
+
+size_t
+strxfrm(char *dest, const char *src, size_t n)
+{
+	size_t len = strlen(src);
+
+	if(n) {
+		size_t copy_len = len < n ? len : n - 1;
+		memcpy(dest, src, copy_len);
+		dest[copy_len] = 0;
+	}
+	return len;
+}
+