libpayload: add memchr to libc

libfdt requires memchr. Add missing function to libc.

Change-Id: I872026559d16a352f350147c9d7c4be97456a99f
Signed-off-by: Philipp Hug <philipp@hug.cx>
Reviewed-on: https://review.coreboot.org/c/31354
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Philipp Hug 2019-02-11 20:50:31 +01:00 committed by ron minnich
parent 2d8aff3d93
commit b2566f207e
2 changed files with 13 additions and 0 deletions

View File

@ -39,6 +39,7 @@
void *memset(void *s, int c, size_t n); void *memset(void *s, int c, size_t n);
void *memcpy(void *dst, const void *src, size_t n); void *memcpy(void *dst, const void *src, size_t n);
void *memmove(void *dst, const void *src, size_t n); void *memmove(void *dst, const void *src, size_t n);
void *memchr(const void *s, int c, size_t n);
int memcmp(const void *s1, const void *s2, size_t len); int memcmp(const void *s1, const void *s2, size_t len);
/** @} */ /** @} */

View File

@ -145,3 +145,15 @@ static int default_memcmp(const void *s1, const void *s2, size_t n)
int memcmp(const void *s1, const void *s2, size_t n) int memcmp(const void *s1, const void *s2, size_t n)
__attribute__((weak, alias("default_memcmp"))); __attribute__((weak, alias("default_memcmp")));
void *memchr(const void *s, int c, size_t n)
{
unsigned char *p = (unsigned char *)s;
while (n--)
if (*p != (unsigned char)c)
p++;
else
return p;
return 0;
}