forked from Vhex-Kernel-Core/fxlibc
Lephenixnoir
6021c536f7
This change provides an optimized hand-written strlen function for SuperH targets. The original plan was to declare the C-based naive version weak and just let the linker figure out the proper one to use, but unfortunately static libraries don't work like that; ld intentionally stops at the first version even if it's weak. Instead, some #ifdef's are used in the C-based strlen to not compile it when unneeded. The optimized strlen uses 4-byte accesses and cmp/str.
13 lines
155 B
C
13 lines
155 B
C
#include <string.h>
|
|
|
|
#ifndef __SUPPORT_ARCH_SH
|
|
|
|
size_t strlen(char const *s)
|
|
{
|
|
size_t i = 0;
|
|
while(s[i]) i++;
|
|
return i;
|
|
}
|
|
|
|
#endif /*__SUPPORT_ARCH_SH*/
|