Commit a54b81ea authored by Rob Herring's avatar Rob Herring

powerpc: boot: add strrchr function

libfdt gained a new dependency on strrchr, so copy the implementation
from lib/string.c. Most of the string functions are in assembly, but
stdio.c already has strnlen, so add strrchr there.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Acked-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
parent fdfb69a7
...@@ -21,6 +21,16 @@ size_t strnlen(const char * s, size_t count) ...@@ -21,6 +21,16 @@ size_t strnlen(const char * s, size_t count)
return sc - s; return sc - s;
} }
char *strrchr(const char *s, int c)
{
const char *last = NULL;
do {
if (*s == (char)c)
last = s;
} while (*s++);
return (char *)last;
}
#ifdef __powerpc64__ #ifdef __powerpc64__
# define do_div(n, base) ({ \ # define do_div(n, base) ({ \
......
...@@ -7,6 +7,7 @@ extern char *strcpy(char *dest, const char *src); ...@@ -7,6 +7,7 @@ extern char *strcpy(char *dest, const char *src);
extern char *strncpy(char *dest, const char *src, size_t n); extern char *strncpy(char *dest, const char *src, size_t n);
extern char *strcat(char *dest, const char *src); extern char *strcat(char *dest, const char *src);
extern char *strchr(const char *s, int c); extern char *strchr(const char *s, int c);
extern char *strrchr(const char *s, int c);
extern int strcmp(const char *s1, const char *s2); extern int strcmp(const char *s1, const char *s2);
extern int strncmp(const char *s1, const char *s2, size_t n); extern int strncmp(const char *s1, const char *s2, size_t n);
extern size_t strlen(const char *s); extern size_t strlen(const char *s);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment