From bd9c1b715f2e2ab580e291143d767a389e775ac1 Mon Sep 17 00:00:00 2001 From: negativekelvin Date: Sat, 16 Jun 2018 08:53:48 -0700 Subject: [PATCH] Fixes to track updates in esp-idf --- component.mk | 2 +- contrib/cross-esp32.cmake | 1 + lib/core/private.h | 14 +++++++------- lib/plat/esp32/esp32-service.c | 12 ++++++------ lib/plat/esp32/esp32-sockets.c | 4 ++-- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/component.mk b/component.mk index 9afdeb6f7..67b8abb7e 100644 --- a/component.mk +++ b/component.mk @@ -25,7 +25,7 @@ build: -DBUILD_DIR_BASE=$(BUILD_DIR_BASE) \ -DCMAKE_TOOLCHAIN_FILE=$(COMPONENT_PATH)/contrib/cross-esp32.cmake \ -DCMAKE_BUILD_TYPE=RELEASE \ - -DLWS_MBEDTLS_INCLUDE_DIRS="${IDF_PATH}/components/openssl/include;${IDF_PATH}/components/mbedtls/include;${IDF_PATH}/components/mbedtls/port/include" \ + -DLWS_MBEDTLS_INCLUDE_DIRS="${IDF_PATH}/components/openssl/include;${IDF_PATH}/components/mbedtls/mbedtls/include;${IDF_PATH}/components/mbedtls/port/include" \ -DLWS_WITH_STATS=0 \ -DLWS_WITH_HTTP2=1 \ -DLWS_WITH_RANGES=1 \ diff --git a/contrib/cross-esp32.cmake b/contrib/cross-esp32.cmake index 6487f7648..406763c61 100644 --- a/contrib/cross-esp32.cmake +++ b/contrib/cross-esp32.cmake @@ -17,6 +17,7 @@ set(CMAKE_LINKER "${CROSS_PATH}/bin/xtensa-esp32-elf-ld${EXECUTABLE_EXT}") SET(CMAKE_C_FLAGS "-nostdlib -Wall -Werror \ -I${BUILD_DIR_BASE}/include \ + -I${IDF_PATH}/components/newlib/platform_include \ -I${IDF_PATH}/components/mdns/include \ -I${IDF_PATH}/components/heap/include \ -I${IDF_PATH}/components/driver/include \ diff --git a/lib/core/private.h b/lib/core/private.h index 6766e47d6..7b94782a0 100644 --- a/lib/core/private.h +++ b/lib/core/private.h @@ -93,18 +93,12 @@ #define LWS_H2_RX_SCRATCH_SIZE 512 -#ifndef LWS_HAVE_BZERO - #ifndef bzero - #define bzero(b, len) (memset((b), '\0', (len)), (void) 0) - #endif -#endif +#define lws_socket_is_valid(x) (x != LWS_SOCK_INVALID) #ifndef LWS_HAVE_STRERROR #define strerror(x) "" #endif -#define lws_socket_is_valid(x) (x != LWS_SOCK_INVALID) - /* * * ------ private platform defines ------ @@ -125,6 +119,12 @@ #endif #endif +#ifndef LWS_HAVE_BZERO + #ifndef bzero + #define bzero(b, len) (memset((b), '\0', (len)), (void) 0) + #endif +#endif + /* * * ------ public api ------ diff --git a/lib/plat/esp32/esp32-service.c b/lib/plat/esp32/esp32-service.c index 0d1d84d63..3549d9d49 100644 --- a/lib/plat/esp32/esp32-service.c +++ b/lib/plat/esp32/esp32-service.c @@ -126,25 +126,25 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) if (pt->fds[n].fd >= max_fd) max_fd = pt->fds[n].fd; if (pt->fds[n].events & LWS_POLLIN) - FD_SET(pt->fds[n].fd - LWIP_SOCKET_OFFSET, &readfds); + FD_SET(pt->fds[n].fd, &readfds); if (pt->fds[n].events & LWS_POLLOUT) - FD_SET(pt->fds[n].fd - LWIP_SOCKET_OFFSET, &writefds); - FD_SET(pt->fds[n].fd - LWIP_SOCKET_OFFSET, &errfds); + FD_SET(pt->fds[n].fd, &writefds); + FD_SET(pt->fds[n].fd, &errfds); } n = select(max_fd + 1, &readfds, &writefds, &errfds, ptv); n = 0; for (m = 0; m < pt->fds_count; m++) { c = 0; - if (FD_ISSET(pt->fds[m].fd - LWIP_SOCKET_OFFSET, &readfds)) { + if (FD_ISSET(pt->fds[m].fd, &readfds)) { pt->fds[m].revents |= LWS_POLLIN; c = 1; } - if (FD_ISSET(pt->fds[m].fd - LWIP_SOCKET_OFFSET, &writefds)) { + if (FD_ISSET(pt->fds[m].fd, &writefds)) { pt->fds[m].revents |= LWS_POLLOUT; c = 1; } - if (FD_ISSET(pt->fds[m].fd - LWIP_SOCKET_OFFSET, &errfds)) { + if (FD_ISSET(pt->fds[m].fd, &errfds)) { // lwsl_notice("errfds %d\n", pt->fds[m].fd); pt->fds[m].revents |= LWS_POLLHUP; c = 1; diff --git a/lib/plat/esp32/esp32-sockets.c b/lib/plat/esp32/esp32-sockets.c index 8f3b658a2..dac37584d 100644 --- a/lib/plat/esp32/esp32-sockets.c +++ b/lib/plat/esp32/esp32-sockets.c @@ -48,7 +48,7 @@ lws_send_pipe_choked(struct lws *wsi) return 1; FD_ZERO(&writefds); - FD_SET(wsi_eff->desc.sockfd - LWIP_SOCKET_OFFSET, &writefds); + FD_SET(wsi_eff->desc.sockfd, &writefds); n = select(wsi_eff->desc.sockfd + 1, NULL, &writefds, NULL, &tv); if (n < 0) @@ -64,7 +64,7 @@ lws_poll_listen_fd(struct lws_pollfd *fd) struct timeval tv = { 0, 0 }; FD_ZERO(&readfds); - FD_SET(fd->fd - LWIP_SOCKET_OFFSET, &readfds); + FD_SET(fd->fd, &readfds); return select(fd->fd + 1, &readfds, NULL, NULL, &tv); }