lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Re: Your patch (socket changes and lightweight protection)


From: Marc Boucher
Subject: [lwip-users] Re: Your patch (socket changes and lightweight protection)
Date: Fri, 7 Feb 2003 12:07:24 +0100
User-agent: Mutt/1.5.1i

On Thu, Feb 06, 2003 at 05:35:47PM -0500, David Haas wrote:
> Hi Marc,
> 
> I spent several days integrating your patch with changes I had made and 
> checking it all in. A couple of things fell out, which you might want to 
> resubmit. I think they are relatively minor:

Thanks David. Please find new patch below (against current CVS).

When merging with the latest code I also had to change the way the
recently added lightweight protection works, because it falsely assumed
that state (level) info was 32 bits and implemented everything as functions,
whereas on some platforms it is most easily/efficiently done with macros.
The macro approach also avoids polluting the code with too many
#ifdef SYS_LIGHTWEIGHT_PROT checks, since the macros can be defined to
nothing to leave out this functionality. Otherwise the macros
are defined to the functions to preserve compatibility with current
code in contrib.

> 
> 1) - removed early "struct tcp_pcb;" definition in event.h which tasking
> compiler dislikes and doesn't seem required anyways.
> 
> This seemed to be required when building the unixsim port with gcc. 
> Since this is essentially the "standard" port which anyone should be 
> able to compile and build, I left your change out.

I've dealt with this by integrating event.h into tcp.h.

> 
> 2) - extended sys_thread_new() to return pid of created thread as 
> sys_thread_t.
> 
> This was not reflected in the unix version of sys_thread_new(). It was 
> only in the ".h" file. So I removed it for now.

The patch below attempts to update all sys_thread_new() implementations
in contrib. People involved in the various ports should verify correctness.

> 
> I also had already written a sys_timeout_remove() function. When I 
> compared yours with mine, they were similar, but you were not adjusting 
> the next time in the list. This is necessary. So I put in my function 
> instead of yours.

No, actually it isn't necessary nor in fact desirable to change the
times or remove the timeout from the list. My implementation 
just neutralizes the timeout by setting its handler to NULL, without
touching the list, which avoids a lot of complexity dealing with
race conditions and the need to recalculate relative time values.
I would strongly recommend using this more simple approach.
The sys_untimeout() name is also in my opinion preferable for consistency
with BSD tradition.

> 
> I had fixed a couple of other select() bugs, so you will notice some 
> slight differences in the code. Let me know if I did anything wrong. It 
> was a big patch and I while I looked at each difference carefully, I 
> certainly might have screwed something up. I did test tcp connections 
> with my code before I submitted. I use select() in that code.

ok

Cheers
Marc

diff -r -u contrib/ports/6502/sys_c64.c contrib-mb/ports/6502/sys_c64.c
--- contrib/ports/6502/sys_c64.c        2003-01-18 19:33:29.000000000 +0100
+++ contrib-mb/ports/6502/sys_c64.c     2003-02-07 10:46:48.000000000 +0100
@@ -113,7 +113,7 @@
   return &timeouts;
 }
 
/*-----------------------------------------------------------------------------------*/
-void
+sys_thread_t
 sys_thread_new(void (* function)(void *arg), void *arg)
 {
 }
diff -r -u contrib/ports/coldfire/sys_arch.c 
contrib-mb/ports/coldfire/sys_arch.c
--- contrib/ports/coldfire/sys_arch.c   2003-02-07 10:16:13.000000000 +0100
+++ contrib-mb/ports/coldfire/sys_arch.c        2003-02-07 10:47:35.000000000 
+0100
@@ -126,7 +126,7 @@
 
/*---------------------------------------------------------------------------------*/
 /* We use Nucleus task as thread. Create one with a standard size stack at a 
standard
  * priority. */
-void
+sys_thread_t
 sys_thread_new(void (*function)(void *arg), void *arg)
 {
     NU_TASK *p_thread;
@@ -161,7 +161,7 @@
                                         NU_PREEMPT,
                                         NU_START);
                 if (status == NU_SUCCESS)
-                    return;
+                    return num_thread;
             }
             
         }
diff -r -u contrib/ports/rtxc/sys_arch.c contrib-mb/ports/rtxc/sys_arch.c
--- contrib/ports/rtxc/sys_arch.c       2003-01-18 19:33:29.000000000 +0100
+++ contrib-mb/ports/rtxc/sys_arch.c    2003-02-07 11:52:13.000000000 +0100
@@ -241,7 +241,7 @@
   KS_terminate(0);
 }
 
/*-----------------------------------------------------------------------------------*/
-void
+sys_thread_t
 sys_thread_new(void (* function)(void *arg), void *arg) 
 {
   TASK newtask;
@@ -262,6 +262,8 @@
   KS_deftask_arg(newtask, &threadarg);    
   KS_execute(newtask);
   KS_wait(THRDSYNC);
+
+  return newtask;
 }
 
 
diff -r -u contrib/ports/unix/sys_arch.c contrib-mb/ports/unix/sys_arch.c
--- contrib/ports/unix/sys_arch.c       2003-02-07 10:16:14.000000000 +0100
+++ contrib-mb/ports/unix/sys_arch.c    2003-02-07 10:49:17.000000000 +0100
@@ -150,7 +150,7 @@
   return st;
 }
 
/*-----------------------------------------------------------------------------------*/
-void
+sys_thread_t
 sys_thread_new(void (*function)(void *arg), void *arg)
 {
   int code;
@@ -172,6 +172,8 @@
                       code, (int)st));
     abort();
   }
+
+  return tmp;
 }
 
/*-----------------------------------------------------------------------------------*/
 struct sys_mbox *


diff -urN lwip-cvs-03020700/doc/sys_arch.txt 
lwip-cvs-03020700-mb/doc/sys_arch.txt
--- lwip-cvs-03020700/doc/sys_arch.txt  2002-10-19 21:48:06.000000000 +0200
+++ lwip-cvs-03020700-mb/doc/sys_arch.txt       2003-02-07 10:38:58.000000000 
+0100
@@ -115,9 +115,9 @@
 such functionality is needed in lwIP, the following function will have
 to be implemented as well:
 
-- void sys_thread_new(void (* thread)(void *arg), void *arg)
+- sys_thread_t sys_thread_new(void (* thread)(void *arg), void *arg)
 
   Starts a new thread that will begin its execution in the function
   "thread()". The "arg" argument will be passed as an argument to the
-  thread() function.
+  thread() function. The id of the new thread is returned.
 
diff -urN lwip-cvs-03020700/src/api/tcpip.c lwip-cvs-03020700-mb/src/api/tcpip.c
--- lwip-cvs-03020700/src/api/tcpip.c   2003-02-07 10:15:59.000000000 +0100
+++ lwip-cvs-03020700-mb/src/api/tcpip.c        2003-02-07 10:51:01.000000000 
+0100
@@ -60,7 +60,7 @@
 
   tcp_tmr();
   if(tcp_active_pcbs || tcp_tw_pcbs) {
-       sys_timeout(TCP_TMR_INTERVAL, (sys_timeout_handler)tcpip_tcp_timer, 
NULL);
+       sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
   } else {
        tcpip_tcp_timer_active = 0;
   }
@@ -71,7 +71,7 @@
 {
   if(!tcpip_tcp_timer_active && (tcp_active_pcbs || tcp_tw_pcbs)) {
        tcpip_tcp_timer_active = 1;
-       sys_timeout(TCP_TMR_INTERVAL, (sys_timeout_handler)tcpip_tcp_timer, 
NULL);
+       sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
   }
 }
 
/*-----------------------------------------------------------------------------------*/
diff -urN lwip-cvs-03020700/src/core/ipv4/ip.c 
lwip-cvs-03020700-mb/src/core/ipv4/ip.c
--- lwip-cvs-03020700/src/core/ipv4/ip.c        2003-02-07 10:16:02.000000000 
+0100
+++ lwip-cvs-03020700-mb/src/core/ipv4/ip.c     2003-02-07 11:49:12.000000000 
+0100
@@ -110,7 +110,6 @@
 #if LWIP_UDP > 0
   case IP_PROTO_UDP:
     return udp_lookup(iphdr, inp);
-    break;
 #endif /* LWIP_UDP */
 #if LWIP_TCP > 0    
   case IP_PROTO_TCP:
@@ -118,7 +117,6 @@
 #endif /* LWIP_TCP */
   case IP_PROTO_ICMP:
     return 1;
-    break;
   default:
     return 0;
   }
diff -urN lwip-cvs-03020700/src/core/ipv4/ip_frag.c 
lwip-cvs-03020700-mb/src/core/ipv4/ip_frag.c
--- lwip-cvs-03020700/src/core/ipv4/ip_frag.c   2003-02-07 10:16:02.000000000 
+0100
+++ lwip-cvs-03020700-mb/src/core/ipv4/ip_frag.c        2003-02-07 
10:51:10.000000000 +0100
@@ -95,7 +95,7 @@
 {
   if(ip_reasstmr > 1) {
     ip_reasstmr--;
-    sys_timeout(IP_REASS_TMO, (sys_timeout_handler) ip_reass_timer, NULL);
+    sys_timeout(IP_REASS_TMO, ip_reass_timer, NULL);
   } else if(ip_reasstmr == 1)
        ip_reasstmr = 0;
 }
@@ -121,7 +121,7 @@
     DEBUGF(IP_REASS_DEBUG, ("ip_reass: new packet\n"));
     memcpy(iphdr, fraghdr, IP_HLEN);
     ip_reasstmr = IP_REASS_MAXAGE;
-    sys_timeout(IP_REASS_TMO, (sys_timeout_handler) ip_reass_timer, NULL);
+    sys_timeout(IP_REASS_TMO, ip_reass_timer, NULL);
     ip_reassflags = 0;
     /* Clear the bitmap. */
     memset(ip_reassbitmap, 0, sizeof(ip_reassbitmap));
@@ -148,7 +148,7 @@
       DEBUGF(IP_REASS_DEBUG,
             ("ip_reass: fragment outside of buffer (%d:%d/%d).\n", offset,
              offset + len, IP_REASS_BUFSIZE));
-      sys_timeout_remove((sys_timeout_handler) ip_reass_timer, NULL);
+      sys_untimeout(ip_reass_timer, NULL);
       ip_reasstmr = 0;
       goto nullreturn;
     }
@@ -236,7 +236,7 @@
       /* If we have come this far, we have a full packet in the
          buffer, so we allocate a pbuf and copy the packet into it. We
          also reset the timer. */
-      sys_timeout_remove((sys_timeout_handler) ip_reass_timer, NULL);
+      sys_untimeout(ip_reass_timer, NULL);
       ip_reasstmr = 0;
       pbuf_free(p);
       p = pbuf_alloc(PBUF_LINK, ip_reasslen, PBUF_POOL);
diff -urN lwip-cvs-03020700/src/core/memp.c lwip-cvs-03020700-mb/src/core/memp.c
--- lwip-cvs-03020700/src/core/memp.c   2003-02-07 10:16:02.000000000 +0100
+++ lwip-cvs-03020700-mb/src/core/memp.c        2003-02-07 11:43:31.000000000 
+0100
@@ -110,7 +110,9 @@
                                        sizeof(struct memp)))];
 
 
/*-----------------------------------------------------------------------------------*/
+#ifndef SYS_LIGHTWEIGHT_PROT
 static sys_sem_t mutex;
+#endif
 
/*-----------------------------------------------------------------------------------*/
 #ifdef LWIP_DEBUG
 static int
@@ -168,7 +170,9 @@
     }
   }
 
+#ifndef SYS_LIGHTWEIGHT_PROT
   mutex = sys_sem_new(1);
+#endif
 
   
 }
@@ -213,18 +217,20 @@
 {
   void *mem;
 #ifdef SYS_LIGHTWEIGHT_PROT
-  u32_t old_level = sys_arch_protect();
-#else /* SYS_LIGHTWEIGHT_PROT */  
+  SYS_ARCH_DECL_PROTECT(prot_state);
+
+  SYS_ARCH_PROTECT(prot_state);
+#else
   sys_sem_wait(mutex);
-#endif /* SYS_LIGHTWEIGHT_PROT */  
+#endif
 
   mem = memp_malloc(type);
 
 #ifdef SYS_LIGHTWEIGHT_PROT
-  sys_arch_unprotect(old_level);
-#else /* SYS_LIGHTWEIGHT_PROT */
+  SYS_ARCH_UNPROTECT(prot_state);
+#else
   sys_sem_signal(mutex);
-#endif /* SYS_LIGHTWEIGHT_PROT */  
+#endif
   return mem;
 }
 
/*-----------------------------------------------------------------------------------*/
@@ -254,18 +260,20 @@
 memp_freep(memp_t type, void *mem)
 {
 #ifdef SYS_LIGHTWEIGHT_PROT
-  u32_t old_level = sys_arch_protect();
-#else /* SYS_LIGHTWEIGHT_PROT */  
+  SYS_ARCH_DECL_PROTECT(prot_state);
+
+  SYS_ARCH_PROTECT(prot_state);
+#else
   sys_sem_wait(mutex);
-#endif /* SYS_LIGHTWEIGHT_PROT */  
+#endif
 
   memp_free(type, mem);
 
 #ifdef SYS_LIGHTWEIGHT_PROT
-  sys_arch_unprotect(old_level);
-#else /* SYS_LIGHTWEIGHT_PROT */
+  SYS_ARCH_UNPROTECT(prot_state);
+#else
   sys_sem_signal(mutex);
-#endif /* SYS_LIGHTWEIGHT_PROT */  
+#endif
 
 }
 
/*-----------------------------------------------------------------------------------*/
diff -urN lwip-cvs-03020700/src/core/pbuf.c lwip-cvs-03020700-mb/src/core/pbuf.c
--- lwip-cvs-03020700/src/core/pbuf.c   2003-02-07 10:16:02.000000000 +0100
+++ lwip-cvs-03020700-mb/src/core/pbuf.c        2003-02-07 11:43:34.000000000 
+0100
@@ -116,12 +116,9 @@
 pbuf_pool_alloc(void)
 {
   struct pbuf *p = NULL;
+  SYS_ARCH_DECL_PROTECT(prot_state);
 
-#ifdef SYS_LIGHTWEIGHT_PROT
-  u32_t old_level;
-
-  old_level = sys_arch_protect();
-#endif /* SYS_LIGHTWEIGHT_PROT */
+  SYS_ARCH_PROTECT(prot_state);
   
   /* First, see if there are pbufs in the cache. */
   if(pbuf_pool_alloc_cache) {
@@ -165,9 +162,7 @@
   }
 #endif /* PBUF_STATS */
 
-#ifdef SYS_LIGHTWEIGHT_PROT
-  sys_arch_unprotect(old_level);
-#endif /* SYS_LIGHTWEIGHT_PROT */  
+  SYS_ARCH_UNPROTECT(prot_state);
 
   return p;   
 }
@@ -176,14 +171,9 @@
 pbuf_pool_free(struct pbuf *p)
 {
   struct pbuf *q;
-#ifdef SYS_LIGHTWEIGHT_PROT
-  u32_t old_level;
-#endif /* SYS_LIGHTWEIGHT_PROT */
-  
+  SYS_ARCH_DECL_PROTECT(prot_state);
 
-#ifdef SYS_LIGHTWEIGHT_PROT
-    old_level = sys_arch_protect();
-#endif /* SYS_LIGHTWEIGHT_PROT */
+  SYS_ARCH_PROTECT(prot_state);
 
 #ifdef PBUF_STATS
     for(q = p; q != NULL; q = q->next) {
@@ -197,9 +187,8 @@
     for(q = pbuf_pool_alloc_cache; q->next != NULL; q = q->next);
     q->next = p;    
   }
-#ifdef SYS_LIGHTWEIGHT_PROT
-  sys_arch_unprotect(old_level);
-#endif /* SYS_LIGHTWEIGHT_PROT */  
+
+  SYS_ARCH_UNPROTECT(prot_state);
 }
 
/*-----------------------------------------------------------------------------------*/
 /* pbuf_alloc():
@@ -343,13 +332,13 @@
 pbuf_refresh(void)
 {
   struct pbuf *p;
-#ifdef SYS_LIGHTWEIGHT_PROT
-  u32_t old_level;
+  SYS_ARCH_DECL_PROTECT(prot_state);
 
-  old_level = sys_arch_protect();
-#else /* SYS_LIGHTWEIGHT_PROT */  
+  SYS_ARCH_PROTECT(prot_state);
+
+#ifndef SYS_LIGHTWEIGHT_PROT
   sys_sem_wait(pbuf_pool_free_sem);
-#endif /* else SYS_LIGHTWEIGHT_PROT */
+#endif
   
   if(pbuf_pool_free_cache != NULL) {
 #ifndef SYS_LIGHTWEIGHT_PROT      
@@ -373,11 +362,12 @@
     pbuf_pool_free_lock = 0;
 #endif /* SYS_LIGHTWEIGHT_PROT */    
   }
-#ifdef SYS_LIGHTWEIGHT_PROT
-  sys_arch_unprotect(old_level);
-#else  /* SYS_LIGHTWEIGHT_PROT */
+
+#ifndef SYS_LIGHTWEIGHT_PROT
   sys_sem_signal(pbuf_pool_free_sem);
 #endif /* SYS_LIGHTWEIGHT_PROT */  
+
+  SYS_ARCH_UNPROTECT(prot_state);
 }
 
 #ifdef PBUF_STATS
@@ -394,9 +384,10 @@
 
 #ifdef SYS_LIGHTWEIGHT_PROT
 #define PBUF_POOL_FREE(p)  do {                                                
 \
-                             u32_t old_level = sys_arch_protect();        \
+                             SYS_ARCH_DECL_PROTECT(ppfp_state);         \
+                             SYS_ARCH_PROTECT(ppfp_state);              \
                              PBUF_POOL_FAST_FREE(p);                           
 \
-                             sys_arch_unprotect(old_level);                 \
+                             SYS_ARCH_UNPROTECT(ppfp_state);            \
                            } while(0)
 #else /* SYS_LIGHTWEIGHT_PROT */
 #define PBUF_POOL_FREE(p)  do {                                         \
@@ -536,10 +527,8 @@
 {
   struct pbuf *q;
   u8_t count = 0;
-#ifdef SYS_LIGHTWEIGHT_PROT
-  u32_t old_level;
-#endif /* SYS_LIGHTWEIGHT_PROT */
-  
+  SYS_ARCH_DECL_PROTECT(prot_state);
+
   if(p == NULL) {
     return 0;
   }
@@ -552,21 +541,18 @@
   
   LWIP_ASSERT("pbuf_free: p->ref > 0", p->ref > 0);
 
-#ifdef SYS_LIGHTWEIGHT_PROT
   /* Since decrementing ref cannot be guarranteed to be a single machine 
operation
      we must protect it. Also, the later test of ref must be protected.
   */
-  old_level = sys_arch_protect();
-#endif /* SYS_LIGHTWEIGHT_PROT */  
+  SYS_ARCH_PROTECT(prot_state);
+  
   /* Decrement reference count. */  
   p->ref--;
 
   /*q = NULL;           DJH: Unnecessary statement*/
   /* If reference count == 0, actually deallocate pbuf. */
   if(p->ref == 0) {
-#ifdef SYS_LIGHTWEIGHT_PROT
-      sys_arch_unprotect(old_level);
-#endif     
+    SYS_ARCH_UNPROTECT(prot_state);
       
     while(p != NULL) {
       /* Check if this is a pbuf from the pool. */
@@ -590,10 +576,9 @@
     }
     pbuf_refresh();
   }
-#ifdef SYS_LIGHTWEIGHT_PROT
-  else
-      sys_arch_unprotect(old_level);
-#endif /* SYS_LIGHTWEIGHT_PROT */  
+  else {
+    SYS_ARCH_UNPROTECT(prot_state);
+  }
 
   PERF_STOP("pbuf_free");
   
@@ -628,21 +613,15 @@
 void
 pbuf_ref(struct pbuf *p)
 {
-#ifdef SYS_LIGHTWEIGHT_PROT
-    u32_t old_level;
-#endif /* SYS_LIGHTWEIGHT_PROT */
+  SYS_ARCH_DECL_PROTECT(prot_state);
     
   if(p == NULL) {
     return;
   }
 
-#ifdef SYS_LIGHTWEIGHT_PROT
-  old_level = sys_arch_protect();
-#endif /* SYS_LIGHTWEIGHT_PROT */  
+  SYS_ARCH_PROTECT(prot_state);
   ++(p->ref);
-#ifdef SYS_LIGHTWEIGHT_PROT
-  sys_arch_unprotect(old_level);
-#endif /* SYS_LIGHTWEIGHT_PROT */  
+  SYS_ARCH_UNPROTECT(prot_state);
 }
 
 
/*------------------------------------------------------------------------------*/
@@ -653,18 +632,14 @@
 void
 pbuf_ref_chain(struct pbuf *p)
 {
-#ifdef SYS_LIGHTWEIGHT_PROT
-    u32_t old_level = sys_arch_protect();
-#endif /* SYS_LIGHTWEIGHT_PROT */
-    
+  SYS_ARCH_DECL_PROTECT(prot_state);
+
+  SYS_ARCH_PROTECT(prot_state);
   while (p != NULL) {
     p->ref++;
     p=p->next;
   }
-
-#ifdef SYS_LIGHTWEIGHT_PROT
-  sys_arch_unprotect(old_level);
-#endif /* SYS_LIGHTWEIGHT_PROT */  
+  SYS_ARCH_UNPROTECT(prot_state);
 }
 
/*-----------------------------------------------------------------------------------*/
 /* pbuf_chain():
diff -urN lwip-cvs-03020700/src/core/sys.c lwip-cvs-03020700-mb/src/core/sys.c
--- lwip-cvs-03020700/src/core/sys.c    2003-02-07 10:16:02.000000000 +0100
+++ lwip-cvs-03020700-mb/src/core/sys.c 2003-02-07 11:36:54.000000000 +0100
@@ -200,52 +200,30 @@
   }
   
 }
-
-/* Go through timeout list (for this task only) and remove the first matching 
entry,
-   even though the timeout has not triggered yet.
-*/
 
/*-----------------------------------------------------------------------------------*/
 void
-sys_timeout_remove(sys_timeout_handler h, void *arg)
+sys_untimeout(sys_timeout_handler h, void *arg)
 {
-    struct sys_timeouts *timeouts;
-    struct sys_timeout *prev_t, *t;
+  struct sys_timeouts *timeouts = sys_arch_timeouts();
+  struct sys_timeout *t;
 
-    timeouts = sys_arch_timeouts();
-    
-    if (timeouts->next == NULL)
-        return;
+  DEBUGF(SYS_DEBUG, ("sys_untimeout: pid=%d h=%p arg=%p\n", 
(int)os_current_process(), h, arg));
 
-    for (t = timeouts->next, prev_t = NULL; t != NULL; prev_t = t, t = t->next)
-    {
-        if ((t->h == h) && (t->arg == arg))
-        {
-            /* We have a match */
-            /* Unlink from previous in list */
-            if (prev_t == NULL)
-                timeouts->next = t->next;
-            else
-                prev_t->next = t->next;
-            /* If not the last one, add time of this one back to next */
-            if (t->next != NULL)
-                t->next->time += t->time;
-            memp_free(MEMP_SYS_TIMEOUT, t);
-            return;
-        }
-    }
-    return;
+  LWIP_ASSERT("sys_timeout: timeouts != NULL", timeouts != NULL);
+  for(t = timeouts->next; t; t = t->next) {
+      if(t->h == h && t->arg == arg) {
+             DEBUGF(SYS_DEBUG, ("sys_untimeout: zapping %p\n", t));
+             t->h = NULL;
+         }
+  }
 }
-
-            
-                
-    
 
/*-----------------------------------------------------------------------------------*/
 static void
 sswt_handler(void *arg)
 {
     struct sswt_cb *sswt_cb = (struct sswt_cb *) arg;
     
-    /* Timeout. Set flag to TRUE and signal semephore */
+    /* Timeout. Set flag to TRUE and signal semaphore */
     sswt_cb->timeflag = 1;
     sys_sem_signal(*(sswt_cb->psem));
 }
@@ -274,7 +252,7 @@
         return 0;
     } else {
         /* Not a timeout. Remove timeout entry */
-        sys_timeout_remove(sswt_handler, &sswt_cb);
+        sys_untimeout(sswt_handler, &sswt_cb);
         return 1;
     }
     
diff -urN lwip-cvs-03020700/src/include/lwip/debug.h 
lwip-cvs-03020700-mb/src/include/lwip/debug.h
--- lwip-cvs-03020700/src/include/lwip/debug.h  2003-02-07 10:16:02.000000000 
+0100
+++ lwip-cvs-03020700-mb/src/include/lwip/debug.h       2003-02-07 
10:35:47.000000000 +0100
@@ -188,7 +188,6 @@
 #define DHCP_DEBUG       0
 #endif
 
-#include <stdio.h>
 #define DEBUGF(debug, x) do { if(debug){ printf x; } } while(0)
 
 
diff -urN lwip-cvs-03020700/src/include/lwip/event.h 
lwip-cvs-03020700-mb/src/include/lwip/event.h
--- lwip-cvs-03020700/src/include/lwip/event.h  2002-10-19 15:00:10.000000000 
+0200
+++ lwip-cvs-03020700-mb/src/include/lwip/event.h       1970-01-01 
01:00:00.000000000 +0100
@@ -1,29 +0,0 @@
-#ifndef __LWIP_EVENT_H__
-#define __LWIP_EVENT_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_EVENT_API
-
-#include "lwip/pbuf.h"
-
-enum lwip_event {
-  LWIP_EVENT_ACCEPT,
-  LWIP_EVENT_SENT,
-  LWIP_EVENT_RECV,
-  LWIP_EVENT_CONNECTED,
-  LWIP_EVENT_POLL,
-  LWIP_EVENT_ERR
-};
-
-struct tcp_pcb;
-
-err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb,
-                    enum lwip_event,
-                    struct pbuf *p,
-                    u16_t size,
-                    err_t err);
-
-#endif /* LWIP_EVENT_API */
-
-#endif /* __LWIP_EVENT_H__ */
diff -urN lwip-cvs-03020700/src/include/lwip/sys.h 
lwip-cvs-03020700-mb/src/include/lwip/sys.h
--- lwip-cvs-03020700/src/include/lwip/sys.h    2003-02-07 10:16:02.000000000 
+0100
+++ lwip-cvs-03020700-mb/src/include/lwip/sys.h 2003-02-07 11:26:12.000000000 
+0100
@@ -87,7 +87,7 @@
  *
  */
 void sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
-void sys_timeout_remove(sys_timeout_handler h, void *arg);
+void sys_untimeout(sys_timeout_handler h, void *arg);
 struct sys_timeouts *sys_arch_timeouts(void);
 
 /* Semaphore functions. */
@@ -105,16 +105,37 @@
 void sys_mbox_free(sys_mbox_t mbox);
 void sys_mbox_fetch(sys_mbox_t mbox, void **msg);
 
+#ifdef SYS_LIGHTWEIGHT_PROT
 /* Critical Region Protection */
-/* These functions must be implemented in the sys_arch.c file.
+
+#ifndef SYS_ARCH_DECL_PROTECT
+/* These functions should be implemented either as macros in
+   sys_arch.h or in the sys_arch.c file.
    In some implementations they can provide a more light-weight protection
    mechanism than using semaphores. Otherwise semaphores can be used for
    implementation */
-u32_t sys_arch_protect(void);
-void sys_arch_unprotect(u32_t pval);
+
+typedef u32_t sys_arch_protect_state_t;
+
+sys_arch_protect_state_t sys_arch_protect(void);
+void sys_arch_unprotect(sys_arch_protect_state_t pval);
+
+#define SYS_ARCH_DECL_PROTECT(var) sys_arch_protect_state_t var
+#define SYS_ARCH_PROTECT(var) var = sys_arch_protect()
+#define SYS_ARCH_UNPROTECT(var) sys_arch_unprotect(var)
+
+#endif /* SYS_ARCH_DECL_PROTECT */
+
+#else
+
+#define SYS_ARCH_DECL_PROTECT(var) 
+#define SYS_ARCH_PROTECT(var) do {} while(0)
+#define SYS_ARCH_UNPROTECT(var) do {} while (0)
+
+#endif /* SYS_LIGHTWEIGHT_PROT */
 
 /* Thread functions. */
-void sys_thread_new(void (* thread)(void *arg), void *arg);
+sys_thread_t sys_thread_new(void (* thread)(void *arg), void *arg);
 
 /* The following functions are used only in Unix code, and
    can be omitted when porting the stack. */
diff -urN lwip-cvs-03020700/src/include/lwip/tcp.h 
lwip-cvs-03020700-mb/src/include/lwip/tcp.h
--- lwip-cvs-03020700/src/include/lwip/tcp.h    2003-02-07 10:16:02.000000000 
+0100
+++ lwip-cvs-03020700-mb/src/include/lwip/tcp.h 2003-02-07 10:45:07.000000000 
+0100
@@ -44,8 +44,6 @@
 
 #include "lwip/err.h"
 
-#include "lwip/event.h"
-
 struct tcp_pcb;
 
 /* Functions for interfacing with TCP: */
@@ -307,6 +305,22 @@
 };
 
 #if LWIP_EVENT_API
+
+enum lwip_event {
+  LWIP_EVENT_ACCEPT,
+  LWIP_EVENT_SENT,
+  LWIP_EVENT_RECV,
+  LWIP_EVENT_CONNECTED,
+  LWIP_EVENT_POLL,
+  LWIP_EVENT_ERR
+};
+
+err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb,
+                    enum lwip_event,
+                    struct pbuf *p,
+                    u16_t size,
+                    err_t err);
+
 #define TCP_EVENT_ACCEPT(pcb,err,ret)    ret = 
lwip_tcp_event((pcb)->callback_arg, (pcb),\
                                                    LWIP_EVENT_ACCEPT, NULL, 0, 
err)
 #define TCP_EVENT_SENT(pcb,space,ret) ret = 
lwip_tcp_event((pcb)->callback_arg, (pcb),\
diff -urN lwip-cvs-03020700/src/netif/ethernetif.c 
lwip-cvs-03020700-mb/src/netif/ethernetif.c
--- lwip-cvs-03020700/src/netif/ethernetif.c    2003-01-13 14:26:39.000000000 
+0100
+++ lwip-cvs-03020700-mb/src/netif/ethernetif.c 2003-02-07 10:51:19.000000000 
+0100
@@ -312,7 +312,7 @@
 arp_timer(void *arg)
 {
   arp_tmr();
-  sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, NULL);
+  sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
 }
 
/*-----------------------------------------------------------------------------------*/
 /*
@@ -341,6 +341,6 @@
   low_level_init(netif);
   arp_init();
 
-  sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, NULL);
+  sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
 }
 
/*-----------------------------------------------------------------------------------*/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]