From fc1db87318dc31960159ada426572a322b8aa623 Mon Sep 17 00:00:00 2001 From: sg Date: Fri, 9 Oct 2015 21:00:21 +0200 Subject: [PATCH] Fixed compiling api with LWIP_NETCONN_SEM_PER_THREAD==1 && LWIP_MPU_COMPATIBLE==1 --- src/api/api_lib.c | 2 +- src/api/api_msg.c | 4 ++-- src/api/sockets.c | 14 ++++++++++++-- src/include/lwip/api_msg.h | 8 +++++++- src/include/lwip/tcpip.h | 6 ++++++ 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/api/api_lib.c b/src/api/api_lib.c index 625e0702..3ad26f8e 100644 --- a/src/api/api_lib.c +++ b/src/api/api_lib.c @@ -867,7 +867,7 @@ netconn_gethostbyname(const char *name, ip_addr_t *addr) #endif /* LWIP_NETCONN_SEM_PER_THREAD */ tcpip_callback(lwip_netconn_do_gethostbyname, &API_VAR_REF(msg)); - sys_sem_wait(API_EXPR_REF(API_VAR_REF(msg).sem)); + sys_sem_wait(API_EXPR_REF_SEM(API_VAR_REF(msg).sem)); #if !LWIP_NETCONN_SEM_PER_THREAD sys_sem_free(API_EXPR_REF(API_VAR_REF(msg).sem)); #endif /* !LWIP_NETCONN_SEM_PER_THREAD */ diff --git a/src/api/api_msg.c b/src/api/api_msg.c index 012f1c69..466e4888 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -1827,7 +1827,7 @@ lwip_netconn_do_dns_found(const char *name, const ip_addr_t *ipaddr, void *arg) API_EXPR_DEREF(msg->addr) = *ipaddr; } /* wake up the application task waiting in netconn_gethostbyname */ - sys_sem_signal(API_EXPR_REF(msg->sem)); + sys_sem_signal(API_EXPR_REF_SEM(msg->sem)); } /** @@ -1852,7 +1852,7 @@ lwip_netconn_do_gethostbyname(void *arg) if (API_EXPR_DEREF(msg->err) != ERR_INPROGRESS) { /* on error or immediate success, wake up the application * task waiting in netconn_gethostbyname */ - sys_sem_signal(API_EXPR_REF(msg->sem)); + sys_sem_signal(API_EXPR_REF_SEM(msg->sem)); } } #endif /* LWIP_DNS */ diff --git a/src/api/sockets.c b/src/api/sockets.c index 50cb75f0..6dab6e05 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -1841,7 +1841,12 @@ lwip_getsockopt_callback(void *arg) LWIP_ASSERT("arg != NULL", arg != NULL); data = (struct lwip_setgetsockopt_data*)arg; - data->err = lwip_getsockopt_impl(data->s, data->level, data->optname, data->optval.p, + data->err = lwip_getsockopt_impl(data->s, data->level, data->optname, +#if LWIP_MPU_COMPATIBLE + data->optval, +#else /* LWIP_MPU_COMPATIBLE */ + data->optval.p, +#endif /* LWIP_MPU_COMPATIBLE */ &data->optlen); sys_sem_signal((sys_sem_t*)(data->completed_sem)); @@ -2233,7 +2238,12 @@ lwip_setsockopt_callback(void *arg) LWIP_ASSERT("arg != NULL", arg != NULL); data = (struct lwip_setgetsockopt_data*)arg; - data->err = lwip_setsockopt_impl(data->s, data->level, data->optname, data->optval.pc, + data->err = lwip_setsockopt_impl(data->s, data->level, data->optname, +#if LWIP_MPU_COMPATIBLE + data->optval, +#else /* LWIP_MPU_COMPATIBLE */ + data->optval.pc, +#endif /* LWIP_MPU_COMPATIBLE */ data->optlen); sys_sem_signal((sys_sem_t*)(data->completed_sem)); diff --git a/src/include/lwip/api_msg.h b/src/include/lwip/api_msg.h index 86784435..ac0e5064 100644 --- a/src/include/lwip/api_msg.h +++ b/src/include/lwip/api_msg.h @@ -58,9 +58,15 @@ extern "C" { #if LWIP_MPU_COMPATIBLE #define API_MSG_M_DEF(m) m #define API_MSG_M_DEF_C(t, m) t m +#ifdef LWIP_NETCONN_SEM_PER_THREAD +#define API_MSG_M_DEF_SEM(m) *m +#else +#define API_MSG_M_DEF_SEM(m) API_MSG_M_DEF(m) +#endif #else /* LWIP_MPU_COMPATIBLE */ #define API_MSG_M_DEF(m) *m #define API_MSG_M_DEF_C(t, m) const t * m +#define API_MSG_M_DEF_SEM(m) API_MSG_M_DEF(m) #endif /* LWIP_MPU_COMPATIBLE */ /* For the netconn API, these values are use as a bitmask! */ @@ -177,7 +183,7 @@ struct dns_api_msg { #endif /* LWIP_IPV4 && LWIP_IPV6 */ /** This semaphore is posted when the name is resolved, the application thread should wait on it. */ - sys_sem_t API_MSG_M_DEF(sem); + sys_sem_t API_MSG_M_DEF_SEM(sem); /** Errors are given back here */ err_t API_MSG_M_DEF(err); }; diff --git a/src/include/lwip/tcpip.h b/src/include/lwip/tcpip.h index afad0ec7..ec5480c6 100644 --- a/src/include/lwip/tcpip.h +++ b/src/include/lwip/tcpip.h @@ -114,6 +114,11 @@ extern sys_mutex_t lock_tcpip_core; } while(0) #define API_VAR_FREE(pool, name) memp_free(pool, name) #define API_EXPR_REF(expr) &(expr) +#if LWIP_NETCONN_SEM_PER_THREAD +#define API_EXPR_REF_SEM(expr) (expr) +#else +#define API_EXPR_REF_SEM(expr) API_EXPR_REF(expr) +#endif #define API_EXPR_DEREF(expr) expr #else /* LWIP_MPU_COMPATIBLE */ #define API_VAR_REF(name) name @@ -122,6 +127,7 @@ extern sys_mutex_t lock_tcpip_core; #define API_VAR_ALLOC_DONTFAIL(type, pool, name) #define API_VAR_FREE(pool, name) #define API_EXPR_REF(expr) expr +#define API_EXPR_REF_SEM(expr) API_EXPR_REF(expr) #define API_EXPR_DEREF(expr) *(expr) #endif /* LWIP_MPU_COMPATIBLE */