diff --git a/doc/sys_arch.txt b/doc/sys_arch.txt index 752d18d4..6568a775 100644 --- a/doc/sys_arch.txt +++ b/doc/sys_arch.txt @@ -115,9 +115,9 @@ If threads are supported by the underlying operating system and if 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 --git a/src/api/tcpip.c b/src/api/tcpip.c index 37fb99dd..7666fd03 100644 --- a/src/api/tcpip.c +++ b/src/api/tcpip.c @@ -60,7 +60,7 @@ tcpip_tcp_timer(void *arg) 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 @@ tcp_timer_needed(void) { 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 --git a/src/core/ipv4/ip.c b/src/core/ipv4/ip.c index 9d985a61..e7a324ef 100644 --- a/src/core/ipv4/ip.c +++ b/src/core/ipv4/ip.c @@ -108,7 +108,6 @@ ip_lookup(void *header, struct netif *inp) #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: @@ -116,7 +115,6 @@ ip_lookup(void *header, struct netif *inp) #endif /* LWIP_TCP */ case IP_PROTO_ICMP: return 1; - break; default: return 0; } diff --git a/src/core/ipv4/ip_frag.c b/src/core/ipv4/ip_frag.c index 4632a051..dcf21e7d 100644 --- a/src/core/ipv4/ip_frag.c +++ b/src/core/ipv4/ip_frag.c @@ -95,7 +95,7 @@ ip_reass_timer(void *arg) { 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 @@ ip_reass(struct pbuf *p) 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 @@ ip_reass(struct pbuf *p) 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 @@ ip_reass(struct pbuf *p) /* 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 --git a/src/core/memp.c b/src/core/memp.c index 2df9b140..a2948b00 100644 --- a/src/core/memp.c +++ b/src/core/memp.c @@ -110,7 +110,9 @@ static u8_t memp_memory[(MEMP_NUM_PBUF * sizeof(struct memp)))]; /*-----------------------------------------------------------------------------------*/ +#ifndef SYS_LIGHTWEIGHT_PROT static sys_sem_t mutex; +#endif /*-----------------------------------------------------------------------------------*/ #ifdef LWIP_DEBUG static int @@ -168,7 +170,9 @@ memp_init(void) } } +#ifndef SYS_LIGHTWEIGHT_PROT mutex = sys_sem_new(1); +#endif } diff --git a/src/core/sys.c b/src/core/sys.c index aa788e13..79b866c5 100644 --- a/src/core/sys.c +++ b/src/core/sys.c @@ -206,7 +206,7 @@ sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg) */ /*-----------------------------------------------------------------------------------*/ 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; @@ -245,7 +245,7 @@ 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 +274,7 @@ sys_sem_wait_timeout(sys_sem_t sem, u32_t timeout) 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 --git a/src/include/lwip/debug.h b/src/include/lwip/debug.h index aadefc43..98567c03 100644 --- a/src/include/lwip/debug.h +++ b/src/include/lwip/debug.h @@ -36,9 +36,9 @@ #ifdef LWIP_DEBUG -#define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x) } while(0) -#define DEBUGF(debug, x) do { if(debug) LWIP_PLATFORM_DIAG(x) } while(0) -#define LWIP_ERROR(x) do { LWIP_PLATFORM_DIAG(x) } while(0) +#define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x); } while(0) +#define DEBUGF(debug, x) do { if(debug) LWIP_PLATFORM_DIAG(x); } while(0) +#define LWIP_ERROR(x) do { LWIP_PLATFORM_DIAG(x); } while(0) /* These defines control the amount of debugging output: */ #define MEM_TRACKING diff --git a/src/include/lwip/event.h b/src/include/lwip/event.h deleted file mode 100644 index 677cafc5..00000000 --- a/src/include/lwip/event.h +++ /dev/null @@ -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 --git a/src/include/lwip/sys.h b/src/include/lwip/sys.h index 47fa573d..0caceea9 100644 --- a/src/include/lwip/sys.h +++ b/src/include/lwip/sys.h @@ -91,7 +91,7 @@ void sys_init(void); * */ 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. */ diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h index 26503731..e76729e9 100644 --- a/src/include/lwip/tcp.h +++ b/src/include/lwip/tcp.h @@ -44,8 +44,6 @@ #include "lwip/err.h" -#include "lwip/event.h" - struct tcp_pcb; /* Functions for interfacing with TCP: */ @@ -307,6 +305,22 @@ struct tcp_pcb_listen { }; #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 --git a/src/netif/ethernetif.c b/src/netif/ethernetif.c index c10ae3b0..8d9eb668 100644 --- a/src/netif/ethernetif.c +++ b/src/netif/ethernetif.c @@ -312,7 +312,7 @@ static void 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 @@ ethernetif_init(struct netif *netif) 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); } /*-----------------------------------------------------------------------------------*/