From 19c8476344d30daaf81dac90420731cae53f317f Mon Sep 17 00:00:00 2001 From: liuzhifu Date: Fri, 9 Sep 2016 10:20:14 +0800 Subject: [PATCH] modify macro ESP32_TX_FLOW_CTRL to inline function --- components/lwip/api/sockets.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/components/lwip/api/sockets.c b/components/lwip/api/sockets.c index 3616ce2940..4123712c15 100755 --- a/components/lwip/api/sockets.c +++ b/components/lwip/api/sockets.c @@ -390,17 +390,18 @@ static void lwip_socket_drop_registered_memberships(int s); #ifdef LWIP_ESP8266 extern size_t system_get_free_heap_size(void); extern bool esp_wifi_tx_is_stop(void); -#define ESP32_TX_FLOW_CTRL() \ -do{\ - uint8_t _wait_delay = 0;\ - while ((system_get_free_heap_size() < HEAP_HIGHWAT) || esp_wifi_tx_is_stop()){\ - vTaskDelay(_wait_delay/portTICK_RATE_MS);\ - if (_wait_delay < 64) _wait_delay *= 2;\ - }\ -}while(0) +inline void esp32_tx_flow_ctrl(void) +{ + uint8_t _wait_delay = 0; + + while ((system_get_free_heap_size() < HEAP_HIGHWAT) || esp_wifi_tx_is_stop()){ + vTaskDelay(_wait_delay/portTICK_RATE_MS); + if (_wait_delay < 64) _wait_delay *= 2; + } +} #else -#define ESP32_TX_FLOW_CTRL() +#define esp32_tx_flow_ctrl() #endif /** The global array of available sockets */ @@ -1219,7 +1220,7 @@ lwip_send(int s, const void *data, size_t size, int flags) #endif /* (LWIP_UDP || LWIP_RAW) */ } - ESP32_TX_FLOW_CTRL(); + esp32_tx_flow_ctrl(); write_flags = NETCONN_COPY | ((flags & MSG_MORE) ? NETCONN_MORE : 0) | @@ -1402,7 +1403,7 @@ lwip_sendto(int s, const void *data, size_t size, int flags, #endif /* LWIP_TCP */ } - ESP32_TX_FLOW_CTRL(); + esp32_tx_flow_ctrl(); if ((to != NULL) && !SOCK_ADDR_TYPE_MATCH(to, sock)) { /* sockaddr does not match socket type (IPv4/IPv6) */ -- 2.40.0