diff --git a/components/xtensa/stdatomic.c b/components/xtensa/stdatomic.c index a4a9c383bf..2846ced402 100644 --- a/components/xtensa/stdatomic.c +++ b/components/xtensa/stdatomic.c @@ -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 \ No newline at end of file diff --git a/examples/protocols/asio/chat_client/CMakeLists.txt b/examples/protocols/asio/chat_client/CMakeLists.txt index 38033d9431..ddcc068ba8 100644 --- a/examples/protocols/asio/chat_client/CMakeLists.txt +++ b/examples/protocols/asio/chat_client/CMakeLists.txt @@ -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) diff --git a/examples/protocols/asio/chat_server/CMakeLists.txt b/examples/protocols/asio/chat_server/CMakeLists.txt index cd6a925f33..182f8d4024 100644 --- a/examples/protocols/asio/chat_server/CMakeLists.txt +++ b/examples/protocols/asio/chat_server/CMakeLists.txt @@ -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) diff --git a/examples/protocols/asio/tcp_echo_server/CMakeLists.txt b/examples/protocols/asio/tcp_echo_server/CMakeLists.txt index cc906e36c7..6bf8f46825 100644 --- a/examples/protocols/asio/tcp_echo_server/CMakeLists.txt +++ b/examples/protocols/asio/tcp_echo_server/CMakeLists.txt @@ -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) diff --git a/examples/protocols/asio/udp_echo_server/CMakeLists.txt b/examples/protocols/asio/udp_echo_server/CMakeLists.txt index 0ebe12f2ba..59493277c4 100644 --- a/examples/protocols/asio/udp_echo_server/CMakeLists.txt +++ b/examples/protocols/asio/udp_echo_server/CMakeLists.txt @@ -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)