From b190dc3e9ff85453235a638931a9314352d72fe2 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 26 Sep 2016 03:05:25 +0800 Subject: [PATCH] components/lwip,esp32: fixes for C++ - put contents of a few headers into c++ guard blocks - fix off-by-one error in do_global_ctors - remove system_init from startup code (should be called from main) --- components/esp32/cpu_start.c | 5 +---- components/lwip/include/lwip/port/arch/sys_arch.h | 12 +++++++++++- components/lwip/include/lwip/port/netif/wlanif.h | 8 ++++++++ components/tcpip_adapter/include/tcpip_adapter.h | 10 ++++++++-- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/components/esp32/cpu_start.c b/components/esp32/cpu_start.c index f2cec8426..5566d978a 100644 --- a/components/esp32/cpu_start.c +++ b/components/esp32/cpu_start.c @@ -134,7 +134,7 @@ void IRAM_ATTR user_start_cpu1(void) static void do_global_ctors(void) { void (**p)(void); - for (p = &__init_array_end; p >= &__init_array_start; --p) { + for (p = &__init_array_end - 1; p >= &__init_array_start; --p) { (*p)(); } } @@ -153,9 +153,6 @@ void user_start_cpu0(void) do_global_ctors(); esp_ipc_init(); spi_flash_init(); -#ifdef CONFIG_WIFI_ENABLED - system_init(); -#endif xTaskCreatePinnedToCore(&mainTask, "mainTask", ESP_TASK_MAIN_STACK, NULL, ESP_TASK_MAIN_PRIO, NULL, 0); diff --git a/components/lwip/include/lwip/port/arch/sys_arch.h b/components/lwip/include/lwip/port/arch/sys_arch.h index be8ff7226..a86334825 100644 --- a/components/lwip/include/lwip/port/arch/sys_arch.h +++ b/components/lwip/include/lwip/port/arch/sys_arch.h @@ -38,6 +38,11 @@ #include "freertos/queue.h" #include "freertos/semphr.h" +#ifdef __cplusplus +extern "C" { +#endif + + typedef xSemaphoreHandle sys_sem_t; typedef xSemaphoreHandle sys_mutex_t; typedef xTaskHandle sys_thread_t; @@ -67,6 +72,11 @@ uint32_t system_get_time(void); void sys_delay_ms(uint32_t ms); sys_sem_t* sys_thread_sem_init(void); void sys_thread_sem_deinit(void); -sys_sem_t* sys_thread_sem_get(void); +sys_sem_t* sys_thread_sem_get(void); + +#ifdef __cplusplus +} +#endif + #endif /* __SYS_ARCH_H__ */ diff --git a/components/lwip/include/lwip/port/netif/wlanif.h b/components/lwip/include/lwip/port/netif/wlanif.h index f9e322ebd..7eb303eab 100755 --- a/components/lwip/include/lwip/port/netif/wlanif.h +++ b/components/lwip/include/lwip/port/netif/wlanif.h @@ -10,6 +10,10 @@ #include "lwip/err.h" +#ifdef __cplusplus +extern "C" { +#endif + err_t wlanif_init(struct netif *netif); void wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb); @@ -20,4 +24,8 @@ wifi_interface_t wifi_get_interface(void *dev); void netif_reg_addr_change_cb(void* cb); +#ifdef __cplusplus +} +#endif + #endif /* _WLAN_LWIP_IF_H_ */ diff --git a/components/tcpip_adapter/include/tcpip_adapter.h b/components/tcpip_adapter/include/tcpip_adapter.h index 9cae530ef..51fb233d8 100644 --- a/components/tcpip_adapter/include/tcpip_adapter.h +++ b/components/tcpip_adapter/include/tcpip_adapter.h @@ -16,9 +16,7 @@ #define _TCPIP_ADAPTER_H_ #include - #include "rom/queue.h" - #include "esp_wifi.h" #define CONFIG_TCPIP_LWIP 1 @@ -28,6 +26,10 @@ #include "lwip/ip_addr.h" #include "apps/dhcpserver.h" +#ifdef __cplusplus +extern "C" { +#endif + #define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \ ip4_addr2_16(ipaddr), \ ip4_addr3_16(ipaddr), \ @@ -129,5 +131,9 @@ wifi_interface_t tcpip_adapter_get_wifi_if(void *dev); esp_err_t tcpip_adapter_get_sta_list(struct station_info *sta_info, struct station_list **sta_list); esp_err_t tcpip_adapter_free_sta_list(struct station_list *sta_list); +#ifdef __cplusplus +} +#endif + #endif /* _TCPIP_ADAPTER_H_ */