ASIO: fixed undefined ref to atomic functions and enabled examples for CI (esp32s2beta)

Implemented the atomic functions needed to compile and link the asio examples on esp32s2beta.
This commit is contained in:
Marius Vikhammer 2019-11-01 09:54:34 +08:00
parent bf1977e48e
commit 845003a1c3
5 changed files with 29 additions and 4 deletions

View File

@ -34,6 +34,25 @@
return ret; \
}
#define FETCH_ADD(n, type) type __atomic_fetch_add_ ## n (type* ptr, type value, int memorder) \
{ \
unsigned state = portENTER_CRITICAL_NESTED(); \
type ret = *ptr; \
*ptr = *ptr + value; \
portEXIT_CRITICAL_NESTED(state); \
return ret; \
}
#define FETCH_SUB(n, type) type __atomic_fetch_sub_ ## n (type* ptr, type value, int memorder) \
{ \
unsigned state = portENTER_CRITICAL_NESTED(); \
type ret = *ptr; \
*ptr = *ptr - value; \
portEXIT_CRITICAL_NESTED(state); \
return ret; \
}
//this piece of code should only be compiled if the cpu doesn't support atomic compare and swap (s32c1i)
#if XCHAL_HAVE_S32C1I == 0
@ -44,4 +63,14 @@ CMP_EXCHANGE(2, uint16_t)
CMP_EXCHANGE(4, uint32_t)
CMP_EXCHANGE(8, uint64_t)
FETCH_ADD(1, uint8_t)
FETCH_ADD(2, uint16_t)
FETCH_ADD(4, uint32_t)
FETCH_ADD(8, uint64_t)
FETCH_SUB(1, uint8_t)
FETCH_SUB(2, uint16_t)
FETCH_SUB(4, uint32_t)
FETCH_SUB(8, uint64_t)
#endif

View File

@ -6,6 +6,5 @@ cmake_minimum_required(VERSION 3.5)
# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
set(SUPPORTED_TARGETS esp32)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(asio_chat_client)

View File

@ -6,6 +6,5 @@ cmake_minimum_required(VERSION 3.5)
# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
set(SUPPORTED_TARGETS esp32)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(asio_chat_server)

View File

@ -6,6 +6,5 @@ cmake_minimum_required(VERSION 3.5)
# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
set(SUPPORTED_TARGETS esp32)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(asio_tcp_echo_server)

View File

@ -6,6 +6,5 @@ cmake_minimum_required(VERSION 3.5)
# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
set(SUPPORTED_TARGETS esp32)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(asio_udp_echo_server)