mirror of
https://github.com/apache/nuttx.git
synced 2026-10-19 12:48:48 +00:00
Add assembly-optimized implementations for 14 string/memory functions using word-at-a-time techniques (DETECTNULL, broadcast+XOR) and XLEN-adaptive macros for both RV32 and RV64: - memmove: direction check + forward tail to memcpy, reverse path with 16xSZREG unroll and shift-merge for misaligned src. - memcmp: word-granularity compare when both pointers share alignment, bytewise fallback for mismatched pointers. - memchr: broadcast target byte, XOR with each word, DETECTNULL to find matches. Counter-based bounds (no pointer overflow). - strlen: DETECTNULL word loop, constants loaded from .srodata. - strnlen: strlen with counter-based length limit. - strcpy/strncpy: word loop with DETECTNULL, zero-fill remainder for strncpy. strncpy reuses strcpy via #define USE_AS_STRNCPY. - stpcpy/stpncpy: reuse strcpy/strncpy via #define USE_AS_STPCPY. - strchr/strchrnul: broadcast+XOR detecting both target char and null simultaneously. strchrnul reuses strchr via #define. - strrchr: forward scan recording last match position. - strncmp: word-at-a-time compare with null detection and counter. - strcat: strlen(dst) then strcpy(dst_end, src) word-at-a-time. Each function is independently selectable via CONFIG_RISCV_<FUNC>, or all enabled together with CONFIG_RISCV_STRING_FUNCTION=y. Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: ganjing <ganjing@xiaomi.com> |
||
|---|---|---|
| .. | ||
| libbuiltin | ||
| libc | ||
| libdsp | ||
| libm | ||
| libnx | ||
| libxx | ||
| CMakeLists.txt | ||