diff --git a/ports/risc-v32/gnu/example_build/core_v_mcu/CMakeLists.txt b/ports/risc-v32/gnu/example_build/core_v_mcu/CMakeLists.txt index 6946b347..662914d1 100644 --- a/ports/risc-v32/gnu/example_build/core_v_mcu/CMakeLists.txt +++ b/ports/risc-v32/gnu/example_build/core_v_mcu/CMakeLists.txt @@ -21,7 +21,6 @@ set(SRCS ${CORE_V_MCU_DIR}/crt0.S ${CORE_V_MCU_DIR}/vectors.S ${CORE_V_MCU_DIR}/tx_initialize_low_level.S - ${CORE_V_MCU_DIR}/bsp/clz.c ${CORE_V_MCU_DIR}/bsp/irq.c ${CORE_V_MCU_DIR}/bsp/timer_irq.c ${CORE_V_MCU_DIR}/bsp/fll.c diff --git a/ports/risc-v32/gnu/example_build/core_v_mcu/bsp/clz.c b/ports/risc-v32/gnu/example_build/core_v_mcu/bsp/clz.c deleted file mode 100644 index ef3cb23b..00000000 --- a/ports/risc-v32/gnu/example_build/core_v_mcu/bsp/clz.c +++ /dev/null @@ -1,29 +0,0 @@ -/* clz.c — portable fallback for __clzsi2 (count leading zeros, 32-bit) - * - * The riscv-collab bare-metal toolchain (riscv64-unknown-elf from /opt/riscv) - * is built without multilib and does not ship an rv32/ilp32 libgcc. As a - * result __clzsi2, which GCC emits for __builtin_clz() on targets without a - * hardware CLZ instruction, is missing at link time. - * - * This file provides a weak definition so that the build is self-contained - * with any RISC-V bare-metal toolchain. When a toolchain does ship the symbol - * in libgcc (e.g. the Ubuntu gcc-riscv64-unknown-elf package), the libgcc copy - * will take precedence over this weak one. - */ - -#include - -__attribute__((weak)) -int __clzsi2(uint32_t x) -{ - if (x == 0U) - return 32; - - int n = 0; - if ((x & 0xFFFF0000U) == 0U) { n += 16; x <<= 16; } - if ((x & 0xFF000000U) == 0U) { n += 8; x <<= 8; } - if ((x & 0xF0000000U) == 0U) { n += 4; x <<= 4; } - if ((x & 0xC0000000U) == 0U) { n += 2; x <<= 2; } - if ((x & 0x80000000U) == 0U) { n += 1; } - return n; -}