Skip to content

Commit

Permalink
powerpc: boot: add strrchr function
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Paul Mackerras <[email protected]>
Acked-by: Michael Ellerman <[email protected]>
Signed-off-by: Rob Herring <[email protected]>
  • Loading branch information
robherring committed Mar 6, 2018
1 parent fdfb69a commit a54b81e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions arch/powerpc/boot/stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ size_t strnlen(const char * s, size_t count)
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__

# define do_div(n, base) ({ \
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/boot/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *strcat(char *dest, const char *src);
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 strncmp(const char *s1, const char *s2, size_t n);
extern size_t strlen(const char *s);
Expand Down

0 comments on commit a54b81e

Please sign in to comment.