From d785561eaee30916891690067a59f40acfeec3eb Mon Sep 17 00:00:00 2001 From: Joel Cunningham Date: Mon, 5 Feb 2018 17:30:00 -0600 Subject: [PATCH] tcpip: guard tcpip_msg enum/struct member with !CORE_LOCKING enum tcpip_msg_type and struct tcpip_msg have members which are only used when core locking and/or core locking input are disabled. Remove these from the union to reduce the size. Remove from enum to prevent usage when these are options are disabled A quick sizeof test with MSVC 2013 showed a 4 byte size reduction for struct tcpip_msg (16 bytes -> 12bytes) for the following configuration: LWIP_TCPIP_CORE_LOCKING 1 LWIP_TCPIP_CORE_LOCKING_INPUT 1 LWIP_TCPIP_TIMEOUT 0 --- src/include/lwip/priv/tcpip_priv.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/include/lwip/priv/tcpip_priv.h b/src/include/lwip/priv/tcpip_priv.h index 21643687..74be634b 100644 --- a/src/include/lwip/priv/tcpip_priv.h +++ b/src/include/lwip/priv/tcpip_priv.h @@ -111,9 +111,13 @@ typedef err_t (*tcpip_api_call_fn)(struct tcpip_api_call_data* call); err_t tcpip_api_call(tcpip_api_call_fn fn, struct tcpip_api_call_data *call); enum tcpip_msg_type { +#if !LWIP_TCPIP_CORE_LOCKING TCPIP_MSG_API, TCPIP_MSG_API_CALL, +#endif /* !LWIP_TCPIP_CORE_LOCKING */ +#if !LWIP_TCPIP_CORE_LOCKING_INPUT TCPIP_MSG_INPKT, +#endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */ #if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS TCPIP_MSG_TIMEOUT, TCPIP_MSG_UNTIMEOUT, @@ -125,6 +129,7 @@ enum tcpip_msg_type { struct tcpip_msg { enum tcpip_msg_type type; union { +#if !LWIP_TCPIP_CORE_LOCKING struct { tcpip_callback_fn function; void* msg; @@ -134,11 +139,14 @@ struct tcpip_msg { struct tcpip_api_call_data *arg; sys_sem_t *sem; } api_call; +#endif /* LWIP_TCPIP_CORE_LOCKING */ +#if !LWIP_TCPIP_CORE_LOCKING_INPUT struct { struct pbuf *p; struct netif *netif; netif_input_fn input_fn; } inp; +#endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */ struct { tcpip_callback_fn function; void *ctx;