diff -Nauwr lwip_orig/lwip/src/api/sockets.c final_lwip/lwip/src/api/sockets.c
--- lwip_orig/lwip/src/api/sockets.c	2008-03-23 09:10:18.000000000 -0400
+++ final_lwip/lwip/src/api/sockets.c	2008-05-21 07:26:14.000000000 -0400
@@ -188,7 +188,7 @@
   struct lwip_socket *sock;
 
   if ((s < 0) || (s >= NUM_SOCKETS)) {
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): invalid\n", s));
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%"S32_F"): invalid\n", s));
     set_errno(EBADF);
     return NULL;
   }
@@ -196,7 +196,7 @@
   sock = &sockets[s];
 
   if (!sock->conn) {
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): not active\n", s));
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%"S32_F"): not active\n", s));
     set_errno(EBADF);
     return NULL;
   }
@@ -253,14 +253,14 @@
   struct sockaddr_in sin;
   err_t err;
 
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d)...\n", s));
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%"S32_F")...\n", s));
   sock = get_socket(s);
   if (!sock)
     return -1;
 
   newconn = netconn_accept(sock->conn);
   if (!newconn) {
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) failed, err=%d\n", s, sock->conn->err));
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%"S32_F") failed, err=%"S32_F"\n", s, sock->conn->err));
     sock_set_errno(sock, err_to_errno(sock->conn->err));
     return -1;
   }
@@ -305,9 +305,9 @@
   newconn->socket = newsock;
   sys_sem_signal(socksem);
 
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) returning new sock=%d addr=", s, newsock));
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%"S32_F") returning new sock=%"S32_F" addr=", s, newsock));
   ip_addr_debug_print(SOCKETS_DEBUG, &naddr);
-  LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u\n", port));
+  LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U32_F"\n", port));
 
   sock_set_errno(sock, 0);
   return newsock;
@@ -332,19 +332,19 @@
   local_addr.addr = ((struct sockaddr_in *)name)->sin_addr.s_addr;
   local_port = ((struct sockaddr_in *)name)->sin_port;
 
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d, addr=", s));
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%"S32_F", addr=", s));
   ip_addr_debug_print(SOCKETS_DEBUG, &local_addr);
-  LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(local_port)));
+  LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U32_F")\n", ntohs(local_port)));
 
   err = netconn_bind(sock->conn, &local_addr, ntohs(local_port));
 
   if (err != ERR_OK) {
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) failed, err=%d\n", s, err));
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%"S32_F") failed, err=%"S32_F"\n", s, err));
     sock_set_errno(sock, err_to_errno(err));
     return -1;
   }
 
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) succeeded\n", s));
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%"S32_F") succeeded\n", s));
   sock_set_errno(sock, 0);
   return 0;
 }
@@ -354,7 +354,7 @@
 {
   struct lwip_socket *sock;
 
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s));
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%"S32_F")\n", s));
 
   sock = get_socket(s);
   if (!sock) {
@@ -390,7 +390,7 @@
              sock_set_errno(sock, err_to_errno(ERR_ARG)); return -1;);
 
   if (((struct sockaddr_in *)name)->sin_family == AF_UNSPEC) {
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, AF_UNSPEC)\n", s));
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%"S32_F", AF_UNSPEC)\n", s));
     err = netconn_disconnect(sock->conn);
   } else {
     struct ip_addr remote_addr;
@@ -399,20 +399,20 @@
     remote_addr.addr = ((struct sockaddr_in *)name)->sin_addr.s_addr;
     remote_port = ((struct sockaddr_in *)name)->sin_port;
 
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, addr=", s));
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%"S32_F", addr=", s));
     ip_addr_debug_print(SOCKETS_DEBUG, &remote_addr);
-    LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(remote_port)));
+    LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U32_F")\n", ntohs(remote_port)));
 
     err = netconn_connect(sock->conn, &remote_addr, ntohs(remote_port));
   }
 
   if (err != ERR_OK) {
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) failed, err=%d\n", s, err));
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%"S32_F") failed, err=%"S32_F"\n", s, err));
     sock_set_errno(sock, err_to_errno(err));
     return -1;
   }
 
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) succeeded\n", s));
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%"S32_F") succeeded\n", s));
   sock_set_errno(sock, 0);
   return 0;
 }
@@ -431,7 +431,7 @@
   struct lwip_socket *sock;
   err_t err;
 
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d, backlog=%d)\n", s, backlog));
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%"S32_F", backlog=%"S32_F")\n", s, backlog));
 
   sock = get_socket(s);
   if (!sock)
@@ -448,7 +448,7 @@
   err = netconn_listen_with_backlog(sock->conn, backlog);
 
   if (err != ERR_OK) {
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d) failed, err=%d\n", s, err));
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%"S32_F") failed, err=%"S32_F"\n", s, err));
     sock_set_errno(sock, err_to_errno(err));
     return -1;
   }
@@ -468,7 +468,7 @@
   u16_t               port;
   u8_t                done = 0;
 
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d, %p, %d, 0x%x, ..)\n", s, mem, len, flags));
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%"S32_F", %p, %"S32_F", 0x%"X32_F", ..)\n", s, mem, len, flags));
   sock = get_socket(s);
   if (!sock)
     return -1;
@@ -481,7 +481,7 @@
     } else {
       /* If this is non-blocking call, then check first */
       if (((flags & MSG_DONTWAIT) || (sock->flags & O_NONBLOCK)) && !sock->rcvevent) {
-        LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning EWOULDBLOCK\n", s));
+        LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%"S32_F"): returning EWOULDBLOCK\n", s));
         sock_set_errno(sock, EWOULDBLOCK);
         return -1;
       }
@@ -493,14 +493,14 @@
 
       if (!buf) {
         /* We should really do some error checking here. */
-        LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): buf == NULL!\n", s));
+        LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%"S32_F"): buf == NULL!\n", s));
         sock_set_errno(sock, (((sock->conn->pcb.ip!=NULL) && (sock->conn->err==ERR_OK))?ETIMEDOUT:err_to_errno(sock->conn->err)));
         return 0;
       }
     }
 
     buflen = netbuf_len(buf);
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom: buflen=%d len=%d off=%d sock->lastoffset=%d\n", buflen, len, off, sock->lastoffset));
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom: buflen=%"S32_F" len=%"S32_F" off=%"S32_F" sock->lastoffset=%"S32_F"\n", buflen, len, off, sock->lastoffset));
 
     buflen -= sock->lastoffset;
 
@@ -568,9 +568,9 @@
 
     SMEMCPY(from, &sin, *fromlen);
 
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s));
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%"S32_F"): addr=", s));
     ip_addr_debug_print(SOCKETS_DEBUG, addr);
-    LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, off));
+    LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U32_F" len=%"U32_F"\n", port, off));
   } else {
 #if SOCKETS_DEBUG
     struct sockaddr_in sin;
@@ -583,9 +583,9 @@
       port = netbuf_fromport(buf);
     }
 
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s));
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%"S32_F"): addr=", s));
     ip_addr_debug_print(SOCKETS_DEBUG, addr);
-    LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, off));
+    LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U32_F" len=%"U32_F"\n", port, off));
 #endif /*  SOCKETS_DEBUG */
   }
 
@@ -611,7 +611,7 @@
   struct lwip_socket *sock;
   err_t err;
 
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d, data=%p, size=%d, flags=0x%x)\n",
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%"S32_F", data=%p, size=%"S32_F", flags=0x%x)\n",
                               s, data, size, flags));
 
   sock = get_socket(s);
@@ -629,7 +629,7 @@
 
   err = netconn_write(sock->conn, data, size, NETCONN_COPY | ((flags & MSG_MORE)?NETCONN_MORE:0));
 
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) err=%d size=%d\n", s, err, size));
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%"S32_F") err=%"S32_F" size=%"S32_F"\n", s, err, size));
   sock_set_errno(sock, err_to_errno(err));
   return (err==ERR_OK?size:-1);
 }
@@ -705,10 +705,10 @@
     buf.port         = 0;
   }
 
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_sendto(%d, data=%p, size=%d, flags=0x%x to=",
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_sendto(%"S32_F", data=%p, size=%"S32_F", flags=0x%x to=",
               s, data, size, flags));
   ip_addr_debug_print(SOCKETS_DEBUG, &remote_addr);
-  LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u\n", remote_port));
+  LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U32_F"\n", remote_port));
     
   /* make the buffer point to the data that should be sent */
   if ((err = netbuf_ref(&buf, data, size)) == ERR_OK) {
@@ -737,22 +737,22 @@
   switch (type) {
   case SOCK_RAW:
     conn = netconn_new_with_proto_and_callback(NETCONN_RAW, (u8_t)protocol, event_callback);
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_RAW, %d) = ",
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_RAW, %"S32_F") = ",
                                  domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol));
     break;
   case SOCK_DGRAM:
     conn = netconn_new_with_callback( (protocol == IPPROTO_UDPLITE) ?
                  NETCONN_UDPLITE : NETCONN_UDP, event_callback);
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_DGRAM, %d) = ",
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_DGRAM, %"S32_F") = ",
                                  domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol));
     break;
   case SOCK_STREAM:
     conn = netconn_new_with_callback(NETCONN_TCP, event_callback);
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_STREAM, %d) = ",
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_STREAM, %"S32_F") = ",
                                  domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol));
     break;
   default:
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%d, %d/UNKNOWN, %d) = -1\n",
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%"S32_F", %"S32_F"/UNKNOWN, %"S32_F") = -1\n",
                                  domain, type, protocol));
     set_errno(EINVAL);
     return -1;
@@ -772,7 +772,7 @@
     return -1;
   }
   conn->socket = i;
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("%d\n", i));
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("%"S32_F"\n", i));
   set_errno(0);
   return i;
 }
@@ -817,7 +817,7 @@
       p_sock = get_socket(i);
       if (p_sock && (p_sock->lastdata || p_sock->rcvevent)) {
         FD_SET(i, &lreadset);
-        LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for reading\n", i));
+        LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%"S32_F" ready for reading\n", i));
         nready++;
       }
     }
@@ -826,7 +826,7 @@
       p_sock = get_socket(i);
       if (p_sock && p_sock->sendevent) {
         FD_SET(i, &lwriteset);
-        LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for writing\n", i));
+        LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%"S32_F" ready for writing\n", i));
         nready++;
       }
     }
@@ -853,9 +853,9 @@
   struct lwip_select_cb select_cb;
   struct lwip_select_cb *p_selcb;
 
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select(%d, %p, %p, %p, tvsec=%ld tvusec=%ld)\n",
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select(%"S32_F", %p, %p, %p, tvsec=%lu tvusec=%lu)\n",
                   maxfdp1, (void *)readset, (void *) writeset, (void *) exceptset,
-                  timeout ? timeout->tv_sec : -1L, timeout ? timeout->tv_usec : -1L));
+                  timeout ? timeout->tv_sec : -1, timeout ? timeout->tv_usec : -1));
 
   select_cb.next = 0;
   select_cb.readset = readset;
@@ -981,7 +981,7 @@
   if (exceptset)
     *exceptset = lexceptset;
   
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: nready=%d\n", nready));
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: nready=%"S32_F"\n", nready));
   set_errno(0);
   
   return nready;
@@ -1088,7 +1088,7 @@
 lwip_shutdown(int s, int how)
 {
   LWIP_UNUSED_ARG(how);
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_shutdown(%d, how=%d)\n", s, how));
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_shutdown(%"S32_F", how=%"S32_F")\n", s, how));
   return lwip_close(s); /* XXX temporary hack until proper implementation */
 }
 
@@ -1110,9 +1110,9 @@
   /* get the IP address and port */
   netconn_getaddr(sock->conn, &naddr, &sin.sin_port, local);
 
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getaddrname(%d, addr=", s));
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getaddrname(%"S32_F", addr=", s));
   ip_addr_debug_print(SOCKETS_DEBUG, &naddr);
-  LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%d)\n", sin.sin_port));
+  LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"S32_F")\n", sin.sin_port));
 
   sin.sin_port = htons(sin.sin_port);
   sin.sin_addr.s_addr = naddr.addr;
@@ -1202,7 +1202,7 @@
       break;
 
     default:
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n",
                                   s, optname));
       err = ENOPROTOOPT;
     }  /* switch (optname) */
@@ -1234,7 +1234,7 @@
 #endif /* LWIP_IGMP */
 
     default:
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, UNIMPL: optname=0x%x, ..)\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", IPPROTO_IP, UNIMPL: optname=0x%x, ..)\n",
                                   s, optname));
       err = ENOPROTOOPT;
     }  /* switch (optname) */
@@ -1263,7 +1263,7 @@
       break;
        
     default:
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n",
                                   s, optname));
       err = ENOPROTOOPT;
     }  /* switch (optname) */
@@ -1287,7 +1287,7 @@
       break;
        
     default:
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_UDPLITE, UNIMPL: optname=0x%x, ..)\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", IPPROTO_UDPLITE, UNIMPL: optname=0x%x, ..)\n",
                                   s, optname));
       err = ENOPROTOOPT;
     }  /* switch (optname) */
@@ -1295,7 +1295,7 @@
 #endif /* LWIP_UDP && LWIP_UDPLITE*/
 /* UNDEFINED LEVEL */
   default:
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", level=0x%x, UNIMPL: optname=0x%x, ..)\n",
                                   s, level, optname));
       err = ENOPROTOOPT;
   }  /* switch */
@@ -1363,7 +1363,7 @@
 #endif /* SO_REUSE */
     /*case SO_USELOOPBACK: UNIMPL */
       *(int*)optval = sock->conn->pcb.ip->so_options & optname;
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, optname=0x%x, ..) = %s\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", SOL_SOCKET, optname=0x%x, ..) = %s\n",
                                   s, optname, (*(int*)optval?"on":"off")));
       break;
 
@@ -1381,10 +1381,10 @@
       default: /* unrecognized socket type */
         *(int*)optval = sock->conn->type;
         LWIP_DEBUGF(SOCKETS_DEBUG,
-                    ("lwip_getsockopt(%d, SOL_SOCKET, SO_TYPE): unrecognized socket type %d\n",
+                    ("lwip_getsockopt(%"S32_F", SOL_SOCKET, SO_TYPE): unrecognized socket type %"S32_F"\n",
                     s, *(int *)optval));
       }  /* switch (sock->conn->type) */
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_TYPE) = %d\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", SOL_SOCKET, SO_TYPE) = %"S32_F"\n",
                   s, *(int *)optval));
       break;
 
@@ -1394,7 +1394,7 @@
       } 
       *(int *)optval = sock->err;
       sock->err = 0;
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_ERROR) = %d\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", SOL_SOCKET, SO_ERROR) = %"S32_F"\n",
                   s, *(int *)optval));
       break;
 
@@ -1421,23 +1421,23 @@
     switch (optname) {
     case IP_TTL:
       *(int*)optval = sock->conn->pcb.ip->ttl;
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_TTL) = %d\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", IPPROTO_IP, IP_TTL) = %"S32_F"\n",
                   s, *(int *)optval));
       break;
     case IP_TOS:
       *(int*)optval = sock->conn->pcb.ip->tos;
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_TOS) = %d\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", IPPROTO_IP, IP_TOS) = %"S32_F"\n",
                   s, *(int *)optval));
       break;
 #if LWIP_IGMP
     case IP_MULTICAST_TTL:
       *(u8_t*)optval = sock->conn->pcb.ip->ttl;
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_MULTICAST_TTL) = %d\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", IPPROTO_IP, IP_MULTICAST_TTL) = %"S32_F"\n",
                   s, *(int *)optval));
       break;
     case IP_MULTICAST_IF:
       ((struct in_addr*) optval)->s_addr = sock->conn->pcb.udp->multicast_ip.addr;
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_MULTICAST_IF) = 0x%x\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", IPPROTO_IP, IP_MULTICAST_IF) = 0x%x\n",
                   s, *(u32_t *)optval));
       break;
 #endif /* LWIP_IGMP */
@@ -1450,29 +1450,29 @@
     switch (optname) {
     case TCP_NODELAY:
       *(int*)optval = (sock->conn->pcb.tcp->flags & TF_NODELAY);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_TCP, TCP_NODELAY) = %s\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", IPPROTO_TCP, TCP_NODELAY) = %s\n",
                   s, (*(int*)optval)?"on":"off") );
       break;
     case TCP_KEEPALIVE:
       *(int*)optval = (int)sock->conn->pcb.tcp->keep_idle;
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, TCP_KEEPALIVE) = %d\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", IPPROTO_IP, TCP_KEEPALIVE) = %"S32_F"\n",
                   s, *(int *)optval));
       break;
 
 #if LWIP_TCP_KEEPALIVE
     case TCP_KEEPIDLE:
       *(int*)optval = (int)(sock->conn->pcb.tcp->keep_idle/1000);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, TCP_KEEPIDLE) = %d\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", IPPROTO_IP, TCP_KEEPIDLE) = %"S32_F"\n",
                   s, *(int *)optval));
       break;
     case TCP_KEEPINTVL:
       *(int*)optval = (int)(sock->conn->pcb.tcp->keep_intvl/1000);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, TCP_KEEPINTVL) = %d\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", IPPROTO_IP, TCP_KEEPINTVL) = %"S32_F"\n",
                   s, *(int *)optval));
       break;
     case TCP_KEEPCNT:
       *(int*)optval = (int)sock->conn->pcb.tcp->keep_cnt;
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, TCP_KEEPCNT) = %d\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", IPPROTO_IP, TCP_KEEPCNT) = %"S32_F"\n",
                   s, *(int *)optval));
       break;
 #endif /* LWIP_TCP_KEEPALIVE */
@@ -1486,12 +1486,12 @@
     switch (optname) {
     case UDPLITE_SEND_CSCOV:
       *(int*)optval = sock->conn->pcb.udp->chksum_len_tx;
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV) = %d\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV) = %"S32_F"\n",
                   s, (*(int*)optval)) );
       break;
     case UDPLITE_RECV_CSCOV:
       *(int*)optval = sock->conn->pcb.udp->chksum_len_rx;
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) = %d\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%"S32_F", IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) = %"S32_F"\n",
                   s, (*(int*)optval)) );
       break;
     }  /* switch (optname) */
@@ -1561,7 +1561,7 @@
 #endif /* LWIP_UDP */
       break;
     default:
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n",
                   s, optname));
       err = ENOPROTOOPT;
     }  /* switch (optname) */
@@ -1607,7 +1607,7 @@
       break;
 #endif /* LWIP_IGMP */
       default:
-        LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, UNIMPL: optname=0x%x, ..)\n",
+        LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", IPPROTO_IP, UNIMPL: optname=0x%x, ..)\n",
                     s, optname));
         err = ENOPROTOOPT;
     }  /* switch (optname) */
@@ -1636,7 +1636,7 @@
       break;
 
     default:
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n",
                   s, optname));
       err = ENOPROTOOPT;
     }  /* switch (optname) */
@@ -1660,7 +1660,7 @@
       break;
 
     default:
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UNIMPL: optname=0x%x, ..)\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", IPPROTO_UDPLITE, UNIMPL: optname=0x%x, ..)\n",
                   s, optname));
       err = ENOPROTOOPT;
     }  /* switch (optname) */
@@ -1668,7 +1668,7 @@
 #endif /* LWIP_UDP && LWIP_UDPLITE */
 /* UNDEFINED LEVEL */
   default:
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n",
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", level=0x%x, UNIMPL: optname=0x%x, ..)\n",
                 s, level, optname));
     err = ENOPROTOOPT;
   }  /* switch (level) */
@@ -1740,7 +1740,7 @@
       } else {
         sock->conn->pcb.ip->so_options &= ~optname;
       }
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, optname=0x%x, ..) -> %s\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", SOL_SOCKET, optname=0x%x, ..) -> %s\n",
                   s, optname, (*(int*)optval?"on":"off")));
       break;
 #if LWIP_SO_RCVTIMEO
@@ -1770,12 +1770,12 @@
     switch (optname) {
     case IP_TTL:
       sock->conn->pcb.ip->ttl = (u8_t)(*(int*)optval);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TTL, ..) -> %u\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", IPPROTO_IP, IP_TTL, ..) -> %"U32_F"\n",
                   s, sock->conn->pcb.ip->ttl));
       break;
     case IP_TOS:
       sock->conn->pcb.ip->tos = (u8_t)(*(int*)optval);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TOS, ..)-> %u\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", IPPROTO_IP, IP_TOS, ..)-> %"U32_F"\n",
                   s, sock->conn->pcb.ip->tos));
       break;
 #if LWIP_IGMP
@@ -1814,29 +1814,29 @@
       } else {
         sock->conn->pcb.tcp->flags &= ~TF_NODELAY;
       }
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_NODELAY) -> %s\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", IPPROTO_TCP, TCP_NODELAY) -> %s\n",
                   s, (*(int *)optval)?"on":"off") );
       break;
     case TCP_KEEPALIVE:
       sock->conn->pcb.tcp->keep_idle = (u32_t)(*(int*)optval);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPALIVE) -> %lu\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", IPPROTO_TCP, TCP_KEEPALIVE) -> %"U32_F"\n",
                   s, sock->conn->pcb.tcp->keep_idle));
       break;
 
 #if LWIP_TCP_KEEPALIVE
     case TCP_KEEPIDLE:
       sock->conn->pcb.tcp->keep_idle = 1000*(u32_t)(*(int*)optval);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPIDLE) -> %lu\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", IPPROTO_TCP, TCP_KEEPIDLE) -> %"U32_F"\n",
                   s, sock->conn->pcb.tcp->keep_idle));
       break;
     case TCP_KEEPINTVL:
       sock->conn->pcb.tcp->keep_intvl = 1000*(u32_t)(*(int*)optval);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPINTVL) -> %lu\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", IPPROTO_TCP, TCP_KEEPINTVL) -> %"U32_F"\n",
                   s, sock->conn->pcb.tcp->keep_intvl));
       break;
     case TCP_KEEPCNT:
       sock->conn->pcb.tcp->keep_cnt = (u32_t)(*(int*)optval);
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPCNT) -> %lu\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", IPPROTO_TCP, TCP_KEEPCNT) -> %"U32_F"\n",
                   s, sock->conn->pcb.tcp->keep_cnt));
       break;
 #endif /* LWIP_TCP_KEEPALIVE */
@@ -1855,7 +1855,7 @@
       } else {
         sock->conn->pcb.udp->chksum_len_tx = *(int*)optval;
       }
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV) -> %d\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV) -> %"S32_F"\n",
                   s, (*(int*)optval)) );
       break;
     case UDPLITE_RECV_CSCOV:
@@ -1865,7 +1865,7 @@
       } else {
         sock->conn->pcb.udp->chksum_len_rx = *(int*)optval;
       }
-      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) -> %d\n",
+      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%"S32_F", IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) -> %"S32_F"\n",
                   s, (*(int*)optval)) );
       break;
     }  /* switch (optname) */
@@ -1876,7 +1876,7 @@
 }
 
 int
-lwip_ioctl(int s, long cmd, void *argp)
+lwip_ioctl(int s, int cmd, void *argp)
 {
   struct lwip_socket *sock = get_socket(s);
   u16_t buflen = 0;
@@ -1901,7 +1901,7 @@
       *((u16_t*)argp) += buflen;
     }
 
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONREAD, %p) = %u\n", s, argp, *((u16_t*)argp)));
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%"S32_F", FIONREAD, %p) = %"U32_F"\n", s, argp, *((u16_t*)argp)));
     sock_set_errno(sock, 0);
     return 0;
 
@@ -1910,12 +1910,12 @@
       sock->flags |= O_NONBLOCK;
     else
       sock->flags &= ~O_NONBLOCK;
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONBIO, %d)\n", s, !!(sock->flags & O_NONBLOCK)));
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%"S32_F", FIONBIO, %"S32_F")\n", s, !!(sock->flags & O_NONBLOCK)));
     sock_set_errno(sock, 0);
     return 0;
 
   default:
-    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, UNIMPL: 0x%lx, %p)\n", s, cmd, argp));
+    LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%"S32_F", UNIMPL: 0x%x, %p)\n", s, cmd, argp));
     sock_set_errno(sock, ENOSYS); /* not yet implemented */
     return -1;
   } /* switch (cmd) */
diff -Nauwr lwip_orig/lwip/src/include/lwip/sockets.h final_lwip/lwip/src/include/lwip/sockets.h
--- lwip_orig/lwip/src/include/lwip/sockets.h	2007-12-17 11:15:32.000000000 -0500
+++ final_lwip/lwip/src/include/lwip/sockets.h	2008-05-20 00:48:31.000000000 -0400
@@ -221,25 +221,25 @@
                                            old ioctl's */
 #define _IO(x,y)        (IOC_VOID|((x)<<8)|(y))
 
-#define _IOR(x,y,t)     (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
+#define _IOR(x,y,t)     (IOC_OUT|(((int)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
 
-#define _IOW(x,y,t)     (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
+#define _IOW(x,y,t)     (IOC_IN|(((int)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
 #endif /* !defined(FIONREAD) || !defined(FIONBIO) */
 
 #ifndef FIONREAD
-#define FIONREAD    _IOR('f', 127, unsigned long) /* get # bytes to read */
+#define FIONREAD    _IOR('f', 127, unsigned int) /* get # bytes to read */
 #endif
 #ifndef FIONBIO
-#define FIONBIO     _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */
+#define FIONBIO     _IOW('f', 126, unsigned int) /* set/clear non-blocking i/o */
 #endif
 
 /* Socket I/O Controls: unimplemented */
 #ifndef SIOCSHIWAT
-#define SIOCSHIWAT  _IOW('s',  0, unsigned long)  /* set high watermark */
-#define SIOCGHIWAT  _IOR('s',  1, unsigned long)  /* get high watermark */
-#define SIOCSLOWAT  _IOW('s',  2, unsigned long)  /* set low watermark */
-#define SIOCGLOWAT  _IOR('s',  3, unsigned long)  /* get low watermark */
-#define SIOCATMARK  _IOR('s',  7, unsigned long)  /* at oob mark? */
+#define SIOCSHIWAT  _IOW('s',  0, unsigned int)  /* set high watermark */
+#define SIOCGHIWAT  _IOR('s',  1, unsigned int)  /* get high watermark */
+#define SIOCSLOWAT  _IOW('s',  2, unsigned int)  /* set low watermark */
+#define SIOCGLOWAT  _IOR('s',  3, unsigned int)  /* get low watermark */
+#define SIOCATMARK  _IOR('s',  7, unsigned int)  /* at oob mark? */
 #endif
 
 /* Socket flags: */
@@ -271,8 +271,8 @@
 
 #if LWIP_TIMEVAL_PRIVATE
 struct timeval {
-  long    tv_sec;         /* seconds */
-  long    tv_usec;        /* and microseconds */
+  u32_t    tv_sec;         /* seconds */
+  u32_t    tv_usec;        /* and microseconds */
 };
 #endif /* LWIP_TIMEVAL_PRIVATE */
 
@@ -299,7 +299,7 @@
 int lwip_write(int s, const void *dataptr, int size);
 int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
                 struct timeval *timeout);
-int lwip_ioctl(int s, long cmd, void *argp);
+int lwip_ioctl(int s, int cmd, void *argp);
 
 #if LWIP_COMPAT_SOCKETS
 #define accept(a,b,c)         lwip_accept(a,b,c)
diff -Nauwr lwip_orig/lwip/src/include/lwip/sys.h final_lwip/lwip/src/include/lwip/sys.h
--- lwip_orig/lwip/src/include/lwip/sys.h	2008-01-15 07:44:37.000000000 -0500
+++ final_lwip/lwip/src/include/lwip/sys.h	2008-05-20 00:48:31.000000000 -0400
@@ -142,7 +142,7 @@
 /* The following functions are used only in Unix code, and
    can be omitted when porting the stack. */
 /* Returns the current time in microseconds. */
-unsigned long sys_now(void);
+u32_t sys_now(void);
 
 #endif /* NO_SYS */
--- lwip_orig/contrib/ports/unix/sys_arch.c	2008-01-17 06:46:25.000000000 -0500
+++ final_lwip/contrib/ports/unix/sys_arch.c	2008-05-20 00:48:50.000000000 -0400
@@ -168,10 +168,11 @@
   }
   
   if (NULL == st) {
-    LWIP_DEBUGF(SYS_DEBUG, ("sys_thread_new: pthread_create %d, st = 0x%x",
-                       code, (int)st));
+    LWIP_DEBUGF(SYS_DEBUG, ("sys_thread_new: pthread_create %d, st = 0x%lx",
+                       code, (long)st));
     abort();
   }
+  printf("THREAD CREATED: %s!\n",name);
   return st;
 }
 /*-----------------------------------------------------------------------------------*/
@@ -574,14 +575,14 @@
 /*-----------------------------------------------------------------------------------*/
 
 #ifndef MAX_JIFFY_OFFSET
-#define MAX_JIFFY_OFFSET ((~0UL >> 1)-1)
+#define MAX_JIFFY_OFFSET ((~0U >> 1)-1)
 #endif
 
 #ifndef HZ
 #define HZ 100
 #endif
 
-unsigned long
+u32_t
 sys_jiffies(void)
 {
     struct timeval tv;
--- lwip_orig/contrib/ports/unix/include/arch/cc.h	2007-12-19 15:26:53.000000000 -0500
+++ final_lwip/contrib/ports/unix/include/arch/cc.h	2008-05-20 00:48:50.000000000 -0400
@@ -46,8 +46,8 @@
 typedef signed     char    s8_t;
 typedef unsigned   short   u16_t;
 typedef signed     short   s16_t;
-typedef unsigned   long    u32_t;
-typedef signed     long    s32_t;
+typedef unsigned   int     u32_t;
+typedef signed     int     s32_t;
 
 typedef u32_t mem_ptr_t;
 
@@ -55,9 +55,9 @@
 #define U16_F "hu"
 #define S16_F "hd"
 #define X16_F "hx"
-#define U32_F "lu"
-#define S32_F "ld"
-#define X32_F "lx"
+#define U32_F "u"
+#define S32_F "d"
+#define X32_F "x"
 
 /* Compiler hints for packing structures */
 #define PACK_STRUCT_FIELD(x) x __attribute__((packed))
