riscv: Move strlen to util
This commit is contained in:
parent
84481138ef
commit
c083919796
3 changed files with 11 additions and 9 deletions
|
|
@ -89,6 +89,7 @@ void memzero(void *s, unsigned long n);
|
|||
void *memset(void *s, unsigned long c, unsigned long n) VISIBLE;
|
||||
void *memcpy(void* ptr_dst, const void* ptr_src, unsigned long n) VISIBLE;
|
||||
int PURE strncmp(const char *s1, const char *s2, int n);
|
||||
unsigned long strlen(const char *s);
|
||||
long CONST char_to_long(char c);
|
||||
long PURE str_to_long(const char* str);
|
||||
|
||||
|
|
|
|||
|
|
@ -78,15 +78,6 @@ const char fdt_memory[] = {'m', 'e', 'm', 'o', 'r', 'y', 0};
|
|||
|
||||
// RVTODO: this code needs to updated to not have function pointers or string literals "like this"
|
||||
// and any of these appropriate string functions should be moved to common utils
|
||||
static word_t strlen(const char *s)
|
||||
{
|
||||
const char *p = s;
|
||||
while (*p) {
|
||||
p++;
|
||||
}
|
||||
return p - s;
|
||||
}
|
||||
|
||||
static int strcmp(const char* s1, const char* s2)
|
||||
{
|
||||
unsigned char c1, c2;
|
||||
|
|
|
|||
10
src/util.c
10
src/util.c
|
|
@ -95,6 +95,16 @@ strncmp(const char* s1, const char* s2, int n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
unsigned long
|
||||
strlen(const char *s)
|
||||
{
|
||||
const char *p = s;
|
||||
while (*p) {
|
||||
p++;
|
||||
}
|
||||
return p - s;
|
||||
}
|
||||
|
||||
long CONST
|
||||
char_to_long(char c)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue