*
  */
 
-
-
-
-/* These cannot be inlined because they are referenced as fn ptrs */
-ulong_t v3_hash_long(ulong_t val, uint_t bits);
-ulong_t v3_hash_buffer(uchar_t * msg, uint_t length);
-
-
-
-
 #define DEFINE_HASHTABLE_INSERT(fnname, keytype, valuetype)            \
     static int fnname (struct hashtable * htable, keytype key, valuetype value) { \
        return v3_htable_insert(htable, (addr_t)key, (addr_t)value);    \
 
 
 
+/* These cannot be inlined because they are referenced as fn ptrs */
+ulong_t v3_hash_long(ulong_t val, uint_t bits);
+ulong_t v3_hash_buffer(uchar_t * msg, uint_t length);
+
+
 
 struct hashtable * v3_create_htable(uint_t min_size,
                                    uint_t (*hashfunction) (addr_t key),
 
 int vsnprintf(char *str, size_t size, const char * fmt, va_list ap);
 int vsnrprintf(char *str, size_t size, int radix, const char * fmt, va_list ap);
 
+#define HD_COLUMN_MASK  0xff
+#define HD_DELIM_MASK   0xff00
+#define HD_OMIT_COUNT   (1 << 16)
+#define HD_OMIT_HEX     (1 << 17)
+#define HD_OMIT_CHARS   (1 << 18)
+
+
+void v3_hexdump(const void * ptr, int length, const char * hdr, int flags);
+
 #endif
 
 
 
 #include <palacios/vmm_sprintf.h>
 
 
-#define NEED_SPRINTF 1
-#define NEED_SNPRINTF 1
-#define NEED_VSPRINTF 1
-#define NEED_VSNPRINTF 1
+#define NEED_SPRINTF 0
+#define NEED_SNPRINTF 0
+#define NEED_VSPRINTF 0
+#define NEED_VSNPRINTF 0
 #define NEED_VSNRPRINTF 1
 
 
 
 
 struct snprintf_arg {
-       char    *str;
-       size_t  remain;
+    char       *str;
+    size_t     remain;
 };
 
 
 #endif
 
 
-static void
-snprintf_func(int ch, void *arg)
-{
+static void snprintf_func(int ch, void *arg) {
        struct snprintf_arg *const info = arg;
 
        if (info->remain >= 2) {
  * written in the buffer (i.e., the first character of the string).
  * The buffer pointed to by `nbuf' must have length >= MAXNBUF.
  */
-static char *
-ksprintn(char *nbuf, uint64_t num, int base, int *lenp, int upper)
-{
+static char * ksprintn(char *nbuf, uint64_t num, int base, int *lenp, int upper) {
        char *p, c;
 
        p = nbuf;
 }
 
 
-#define HD_COLUMN_MASK  0xff
-#define HD_DELIM_MASK   0xff00
-#define HD_OMIT_COUNT   (1 << 16)
-#define HD_OMIT_HEX     (1 << 17)
-#define HD_OMIT_CHARS   (1 << 18)
 
 
-void
-v3_hexdump(const void *ptr, int length, const char *hdr, int flags)
-{
-       int i, j, k;
-       int cols;
-       const unsigned char *cp;
-       char delim;
-
-       if ((flags & HD_DELIM_MASK) != 0)
-               delim = (flags & HD_DELIM_MASK) >> 8;
-       else
-               delim = ' ';
-
-       if ((flags & HD_COLUMN_MASK) != 0)
-               cols = flags & HD_COLUMN_MASK;
-       else
-               cols = 16;
-
-       cp = ptr;
-       for (i = 0; i < length; i+= cols) {
-               if (hdr != NULL)
-                       PrintDebug("%s", hdr);
-
-               if ((flags & HD_OMIT_COUNT) == 0)
-                       PrintDebug("%04x  ", i);
-
-               if ((flags & HD_OMIT_HEX) == 0) {
-                       for (j = 0; j < cols; j++) {
-                               k = i + j;
-                               if (k < length)
-                                       PrintDebug("%c%02x", delim, cp[k]);
-                               else
-                                       PrintDebug("   ");
-                       }
-               }
+void v3_hexdump(const void * ptr, int length, const char * hdr, int flags) {
+    int i, j, k;
+    int cols;
+    const unsigned char *cp;
+    char delim;
+    
+    if ((flags & HD_DELIM_MASK) != 0)
+       delim = (flags & HD_DELIM_MASK) >> 8;
+    else
+       delim = ' ';
+
+    if ((flags & HD_COLUMN_MASK) != 0)
+       cols = flags & HD_COLUMN_MASK;
+    else
+       cols = 16;
+
+    cp = ptr;
+    for (i = 0; i < length; i+= cols) {
+       if (hdr != NULL)
+           PrintDebug("%s", hdr);
+
+       if ((flags & HD_OMIT_COUNT) == 0)
+           PrintDebug("%04x  ", i);
+
+       if ((flags & HD_OMIT_HEX) == 0) {
+           for (j = 0; j < cols; j++) {
+               k = i + j;
+               if (k < length)
+                   PrintDebug("%c%02x", delim, cp[k]);
+               else
+                   PrintDebug("   ");
+           }
+       }
 
-               if ((flags & HD_OMIT_CHARS) == 0) {
-                       PrintDebug("  |");
-                       for (j = 0; j < cols; j++) {
-                               k = i + j;
-                               if (k >= length)
-                                       PrintDebug(" ");
-                               else if (cp[k] >= ' ' && cp[k] <= '~')
-                                       PrintDebug("%c", cp[k]);
-                               else
-                                       PrintDebug(".");
-                       }
-                       PrintDebug("|");
-               }
-               PrintDebug("\n");
+       if ((flags & HD_OMIT_CHARS) == 0) {
+           PrintDebug("  |");
+           for (j = 0; j < cols; j++) {
+               k = i + j;
+               if (k >= length)
+                   PrintDebug(" ");
+               else if (cp[k] >= ' ' && cp[k] <= '~')
+                   PrintDebug("%c", cp[k]);
+               else
+                   PrintDebug(".");
+           }
+           PrintDebug("|");
        }
+       PrintDebug("\n");
+    }
 }
 
 
  */
 
 
-
 #define NEED_MEMSET 0
 #define NEED_MEMCPY 0
 #define NEED_MEMCMP 0
 
 
 
+#include <palacios/vmm_types.h>
 #include <palacios/vmm_string.h>
 #include <palacios/vmm.h>
 
 
 #if NEED_MEMSET
-void* memset(void* s, int c, size_t n)
-{
-    unsigned char* p = (unsigned char*) s;
+void * memset(void * s, int c, size_t n) {
+    uchar_t * p = (uchar_t *) s;
 
     while (n > 0) {
-       *p++ = (unsigned char) c;
+       *p++ = (uchar_t) c;
        --n;
     }
 
 #endif
 
 #if NEED_MEMCPY
-void* memcpy(void *dst, const void* src, size_t n)
-{
-    unsigned char* d = (unsigned char*) dst;
-    const unsigned char* s = (const unsigned char*) src;
+void * memcpy(void * dst, const void * src, size_t n) {
+    uchar_t * d = (uchar_t *) dst;
+    const uchar_t * s = (const uchar_t *)src;
 
     while (n > 0) {
        *d++ = *s++;
 
 
 #if NEED_CMP
-int memcmp(const void *s1_, const void *s2_, size_t n)
-{
-    const signed char *s1 = s1_, *s2 = s2_;
+int memcmp(const void * s1_, const void * s2_, size_t n) {
+    const char * s1 = s1_;
+    const char * s2 = s2_;
 
     while (n > 0) {
-       int cmp = *s1 - *s2;
-       if (cmp != 0)
+       int cmp = (*s1 - *s2);
+       
+       if (cmp != 0) {
            return cmp;
+       }
+
        ++s1;
        ++s2;
     }
 
 
 #if NEED_STRLEN
-size_t strlen(const char* s)
-{
+size_t strlen(const char * s) {
     size_t len = 0;
-    while (*s++ != '\0')
+
+    while (*s++ != '\0') {
        ++len;
+    }
+
     return len;
 }
 #endif
  * This is very useful for checking the length of untrusted
  * strings (e.g., from user space).
  */
-size_t strnlen(const char *s, size_t maxlen)
-{
+size_t strnlen(const char * s, size_t maxlen) {
     size_t len = 0;
-    while (len < maxlen && *s++ != '\0')
+
+    while ((len < maxlen) && (*s++ != '\0')) {
        ++len;
+    }
+
     return len;
 }
 #endif
 
 
 #if NEED_STRCMP
-int strcmp(const char* s1, const char* s2)
-{
+int strcmp(const char * s1, const char * s2) {
     while (1) {
-       int cmp = *s1 - *s2;
-       if (cmp != 0 || *s1 == '\0' || *s2 == '\0')
+       int cmp = (*s1 - *s2);
+       
+       if ((cmp != 0) || (*s1 == '\0') || (*s2 == '\0')) {
            return cmp;
+       }
+       
        ++s1;
        ++s2;
     }
 
 
 #if NEED_STRNCMP
-int strncmp(const char* s1, const char* s2, size_t limit)
-{
+int strncmp(const char * s1, const char * s2, size_t limit) {
     size_t i = 0;
+
     while (i < limit) {
-       int cmp = *s1 - *s2;
-       if (cmp != 0 || *s1 == '\0' || *s2 == '\0')
+       int cmp = (*s1 - *s2);
+
+       if ((cmp != 0) || (*s1 == '\0') || (*s2 == '\0')) {
            return cmp;
+       }
+
        ++s1;
        ++s2;
        ++i;
 
 
 #if NEED_STRCAT
-char *strcat(char *s1, const char *s2)
-{
-    char *t1;
+char * strcat(char * s1, const char * s2) {
+    char * t1 = s1;
+
+    while (*s1) { s1++; }
+    while (*s2) { *s1++ = *s2++; }
 
-    t1 = s1;
-    while (*s1) s1++;
-    while(*s2) *s1++ = *s2++;
     *s1 = '\0';
 
     return t1;
 
 
 #if NEED_STRNCAT
-char *strncat(char *s1, const char *s2, size_t limit)
-{
+char * strncat(char * s1, const char * s2, size_t limit) {
     size_t i = 0;
-    char *t1;
+    char * t1;
+
     t1 = s1;
-    while (*s1) s1++;
+
+    while (*s1) { s1++; }
+
     while (i < limit) {
-       if(*s2 == '\0') break;
+       if (*s2 == '\0') {
+           break;
+       }
        *s1++ = *s2++;          
     }
     *s1 = '\0';
 
 
 #if NEED_STRCPY
-char *strcpy(char *dest, const char *src)
+char * strcpy(char * dest, const char * src)
 {
     char *ret = dest;
 
 
 
 #if NEED_STRNCPY
-char *strncpy(char *dest, const char *src, size_t limit)
-{
-    char *ret = dest;
+char * strncpy(char * dest, const char * src, size_t limit) {
+    char * ret = dest;
 
-    while (*src != '\0' && limit > 0) {
+    while ((*src != '\0') && (limit > 0)) {
        *dest++ = *src++;
        --limit;
     }
+
     if (limit > 0)
        *dest = '\0';
 
 
 
 #if NEED_STRDUP
-char *strdup(const char *s1)
-{
+char * strdup(const char * s1) {
     char *ret;
 
     ret = V3_Malloc(strlen(s1) + 1);
 
 
 #if NEED_ATOI
-int atoi(const char *buf) 
-{
+int atoi(const char * buf) {
     int ret = 0;
 
-    while (*buf >= '0' && *buf <= '9') {
+    while ((*buf >= '0') && (*buf <= '9')) {
        ret *= 10;
-       ret += *buf - '0';
+       ret += (*buf - '0');
        buf++;
     }
 
 
 
 #if NEED_STRCHR
-char *strchr(const char *s, int c)
-{
+char * strchr(const char * s, int c) {
     while (*s != '\0') {
        if (*s == c)
-           return (char *) s;
+           return (char *)s;
        ++s;
     }
     return 0;
 
 
 #if NEED_STRRCHR
-char *strrchr(const char *s, int c)
-{
+char * strrchr(const char * s, int c) {
     size_t len = strlen(s);
-    const char *p = s + len;
+    const char * p = s + len;
 
     while (p > s) {
        --p;
-       if (*p == c)
-           return (char*) p;
+
+       if (*p == c) {
+           return (char *)p;
+       }
     }
     return 0;
 }
 #endif
 
 #if NEED_STRPBRK
-char *strpbrk(const char *s, const char *accept)
-{
+char * strpbrk(const char * s, const char * accept) {
     size_t setLen = strlen(accept);
 
     while (*s != '\0') {
        size_t i;
        for (i = 0; i < setLen; ++i) {
-           if (*s == accept[i])
-               return (char *) s;
+           if (*s == accept[i]) {
+               return (char *)s;
+           }
        }
        ++s;
     }