From e670b60126b0e09d24b3ac5cfd68f5e174d1c5ea Mon Sep 17 00:00:00 2001 From: term_est <62337595+term-est@users.noreply.github.com> Date: Fri, 3 Mar 2023 11:21:07 +0300 Subject: [PATCH 1/2] Fix possible conversion errors by using __builtin_ffsll instead of __builtin_ffs Signed-off-by: term_est <62337595+term-est@users.noreply.github.com> --- components/xtensa/include/xt_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/xtensa/include/xt_utils.h b/components/xtensa/include/xt_utils.h index 80374fb08a..4cb32a29a3 100644 --- a/components/xtensa/include/xt_utils.h +++ b/components/xtensa/include/xt_utils.h @@ -152,7 +152,7 @@ FORCE_INLINE_ATTR void xt_utils_set_watchpoint(int wp_num, { // Initialize DBREAKC bits (see Table 4–143 or isa_rm.pdf) uint32_t dbreakc_reg = 0x3F; - dbreakc_reg = dbreakc_reg << (__builtin_ffs(size) - 1); + dbreakc_reg = dbreakc_reg << (__builtin_ffsll(size) - 1); dbreakc_reg = dbreakc_reg & 0x3F; if (on_read) { dbreakc_reg |= BIT(30); From 5946c6ad167b631c152d17770ed35ab40b219cad Mon Sep 17 00:00:00 2001 From: Jakob Hasse Date: Tue, 25 Apr 2023 14:32:36 +0800 Subject: [PATCH 2/2] cxx/esp_hw_support: added build test, changed parameter types Changed rv_utils_intr_edge_ack and esp_cpu_intr_edge_ack to take uint32_t instead of int to avoid build errors. The test is to test in particular that __builtin_ffsll, used in xt_utils.h, which is included via esp_cpu.h, compiles fine in C++20 with -Wsign-conversion enabled. Closes https://github.com/espressif/esp-idf/pull/10895 --- components/esp_hw_support/include/esp_cpu.h | 4 +- components/riscv/include/riscv/rv_utils.h | 2 +- .../system/cxx_build_test/main/CMakeLists.txt | 3 ++ .../main/test_esp_hw_support.cpp | 37 +++++++++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 tools/test_apps/system/cxx_build_test/main/test_esp_hw_support.cpp diff --git a/components/esp_hw_support/include/esp_cpu.h b/components/esp_hw_support/include/esp_cpu.h index 7199cf0103..b30eb3f17f 100644 --- a/components/esp_hw_support/include/esp_cpu.h +++ b/components/esp_hw_support/include/esp_cpu.h @@ -413,9 +413,9 @@ FORCE_INLINE_ATTR void esp_cpu_intr_edge_ack(int intr_num) { assert(intr_num >= 0 && intr_num < SOC_CPU_INTR_NUM); #ifdef __XTENSA__ - xthal_set_intclear(1 << intr_num); + xthal_set_intclear((unsigned) (1 << intr_num)); #else - rv_utils_intr_edge_ack(intr_num); + rv_utils_intr_edge_ack((unsigned) intr_num); #endif } diff --git a/components/riscv/include/riscv/rv_utils.h b/components/riscv/include/riscv/rv_utils.h index 5fc0b2e426..e7349ef082 100644 --- a/components/riscv/include/riscv/rv_utils.h +++ b/components/riscv/include/riscv/rv_utils.h @@ -102,7 +102,7 @@ FORCE_INLINE_ATTR uint32_t rv_utils_intr_get_enabled_mask(void) return REG_READ(INTERRUPT_CORE0_CPU_INT_ENABLE_REG); } -FORCE_INLINE_ATTR void rv_utils_intr_edge_ack(int intr_num) +FORCE_INLINE_ATTR void rv_utils_intr_edge_ack(unsigned int intr_num) { REG_SET_BIT(INTERRUPT_CORE0_CPU_INT_CLEAR_REG, intr_num); } diff --git a/tools/test_apps/system/cxx_build_test/main/CMakeLists.txt b/tools/test_apps/system/cxx_build_test/main/CMakeLists.txt index df82785cfb..44110851e6 100644 --- a/tools/test_apps/system/cxx_build_test/main/CMakeLists.txt +++ b/tools/test_apps/system/cxx_build_test/main/CMakeLists.txt @@ -1,5 +1,8 @@ idf_component_register(SRCS cxx_build_test_main.cpp test_soc_reg_macros.cpp + test_esp_hw_support.cpp INCLUDE_DIRS "." PRIV_REQUIRES driver REQUIRES soc) + +set_source_files_properties(test_esp_hw_support.cpp PROPERTIES COMPILE_FLAGS -Wsign-conversion) diff --git a/tools/test_apps/system/cxx_build_test/main/test_esp_hw_support.cpp b/tools/test_apps/system/cxx_build_test/main/test_esp_hw_support.cpp new file mode 100644 index 0000000000..17056e13c2 --- /dev/null +++ b/tools/test_apps/system/cxx_build_test/main/test_esp_hw_support.cpp @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ + +#include "esp_cpu.h" +#include "clk_ctrl_os.h" +//#include "clk_tree.h" TODO: outdated header name (IDF-7286) +#include "dport_access.h" +#include "esp_async_memcpy.h" +#include "esp_chip_info.h" +#include "esp_crc.h" +#include "esp_fault.h" +#include "esp_interface.h" +#include "esp_intr_alloc.h" +#include "esp_mac.h" +#include "esp_memory_utils.h" +#include "esp_memprot_err.h" +#include "esp_memprot.h" +#include "esp_memprot_types.h" +#include "esp_random.h" +#include "esp_sleep.h" +#include "rtc_wdt.h" +#include "spinlock.h" + +#include "soc/soc_caps.h" + +#if SOC_HMAC_SUPPORTED +#include "esp_hmac.h" +#endif + +#if SOC_DIG_SIGN_SUPPORTED +#include "esp_ds.h" +#endif + +extern "C" void app_main() { }