mirror of
https://github.com/eclipse-threadx/threadx.git
synced 2026-09-21 12:44:01 +08:00
Removed clz.c workaround; use riscv32-unknown-elf toolchain (#538)
bsp/clz.c provided a weak __clzsi2 fallback to work around the missing rv32 multilib in the riscv-collab riscv64-unknown-elf toolchain. Since cmake/riscv32-unknown-elf-rv32imc.cmake now uses the dedicated riscv32- unknown-elf-gcc toolchain (riscv-collab riscv32-elf release), which ships a native rv32/ilp32 libgcc with all required helpers, the workaround is no longer needed. Remove bsp/clz.c and its entry in CMakeLists.txt. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot
parent
4a7343159b
commit
6061c43f96
@@ -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
|
||||
|
||||
@@ -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 <stdint.h>
|
||||
|
||||
__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;
|
||||
}
|
||||
Reference in New Issue
Block a user