[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [PATCH] Fix 64-bit issues in unix port
From: |
David Woodhouse |
Subject: |
[lwip-devel] [PATCH] Fix 64-bit issues in unix port |
Date: |
Mon, 22 Sep 2008 11:08:31 -0700 |
Firstly, IP addresses are not 'unsigned long'.
Secondly, pointers _are_.
Using uint32_t would be preferable, but not necessarily portable to
ancient broken systems which don't yet support a C standard which was
released in the previous millennium. So I used 'unsigned int' instead.
Fix a bunch of printf format warnings too, and make the Unix
implementation of sys_jiffies() match the prototype in the core code.
Index: ports/unix/sys_arch.c
===================================================================
RCS file: /sources/lwip/contrib/ports/unix/sys_arch.c,v
retrieving revision 1.23
diff -u -p -r1.23 sys_arch.c
--- ports/unix/sys_arch.c 16 Jul 2008 20:37:57 -0000 1.23
+++ ports/unix/sys_arch.c 22 Sep 2008 17:41:49 -0000
@@ -172,8 +172,8 @@ sys_thread_new(char *name, void (* funct
}
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, (unsigned long)st));
abort();
}
return st;
@@ -588,7 +588,7 @@ sys_arch_unprotect(sys_prot_t pval)
#define HZ 100
#endif
-unsigned long
+u32_t
sys_jiffies(void)
{
struct timeval tv;
Index: ports/unix/include/arch/cc.h
===================================================================
RCS file: /sources/lwip/contrib/ports/unix/include/arch/cc.h,v
retrieving revision 1.10
diff -u -p -r1.10 cc.h
--- ports/unix/include/arch/cc.h 25 Nov 2007 14:09:16 -0000 1.10
+++ ports/unix/include/arch/cc.h 22 Sep 2008 17:41:50 -0000
@@ -46,18 +46,18 @@ typedef unsigned char u8_t;
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;
+typedef unsigned long mem_ptr_t;
/* Define (sn)printf formatters for these lwIP types */
#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))
Index: ports/unix/netif/tcpdump.c
===================================================================
RCS file: /sources/lwip/contrib/ports/unix/netif/tcpdump.c,v
retrieving revision 1.6
diff -u -p -r1.6 tcpdump.c
--- ports/unix/netif/tcpdump.c 30 May 2008 11:58:40 -0000 1.6
+++ ports/unix/netif/tcpdump.c 22 Sep 2008 17:41:51 -0000
@@ -123,14 +123,14 @@ tcpdump(struct pbuf *p)
len = ntohs(IPH_LEN(iphdr)) - offset * 4 - IP_HLEN;
if (len != 0 || flags[0] != '.') {
- fprintf(file, "%s %lu:%lu(%u) ",
+ fprintf(file, "%s %u:%u(%u) ",
flags,
ntohl(tcphdr->seqno),
ntohl(tcphdr->seqno) + len,
len);
}
if (TCPH_FLAGS(tcphdr) & TCP_ACK) {
- fprintf(file, "ack %lu ",
+ fprintf(file, "ack %u ",
ntohl(tcphdr->ackno));
}
fprintf(file, "wnd %u\n",
Index: ports/unix/proj/unixsim/simhost.c
===================================================================
RCS file: /sources/lwip/contrib/ports/unix/proj/unixsim/simhost.c,v
retrieving revision 1.23
diff -u -p -r1.23 simhost.c
--- ports/unix/proj/unixsim/simhost.c 15 Jan 2008 13:10:52 -0000 1.23
+++ ports/unix/proj/unixsim/simhost.c 22 Sep 2008 17:41:52 -0000
@@ -284,7 +284,7 @@ ping_recv(int s, struct ip_addr *addr)
len = lwip_recvfrom(s, buf,sizeof(buf),0,(struct sockaddr*)&from,&fromlen);
- printf("Received %d bytes from %lx\n",len,ntohl(from.sin_addr.s_addr));
+ printf("Received %d bytes from %x\n",len,ntohl(from.sin_addr.s_addr));
}
static void
--
dwmw2
- [lwip-devel] [PATCH] Fix 64-bit issues in unix port,
David Woodhouse <=