Add an implementation for the memchr library function
Change-Id: Icded479d246f7cce8a3d2154c69f75178fa513e1 Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-on: http://review.coreboot.org/708 Reviewed-by: Ronald G. Minnich <rminnich@gmail.com> Tested-by: build bot (Jenkins) Reviewed-by: Mathias Krause <minipli@googlemail.com>
This commit is contained in:
parent
8ebd11eab9
commit
1025f3afc8
|
@ -8,6 +8,7 @@ void *memcpy(void *dest, const void *src, size_t n);
|
||||||
void *memmove(void *dest, const void *src, size_t n);
|
void *memmove(void *dest, const void *src, size_t n);
|
||||||
void *memset(void *s, int c, size_t n);
|
void *memset(void *s, int c, 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);
|
||||||
|
void *memchr(const void *s, int c, size_t n);
|
||||||
#if !defined(__PRE_RAM__)
|
#if !defined(__PRE_RAM__)
|
||||||
int sprintf(char * buf, const char *fmt, ...);
|
int sprintf(char * buf, const char *fmt, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
romstage-y += memset.c
|
romstage-y += memset.c
|
||||||
|
romstage-y += memchr.c
|
||||||
romstage-y += memcpy.c
|
romstage-y += memcpy.c
|
||||||
romstage-y += memcmp.c
|
romstage-y += memcmp.c
|
||||||
romstage-y += cbfs.c
|
romstage-y += cbfs.c
|
||||||
|
@ -15,6 +16,7 @@ romstage-$(CONFIG_CONSOLE_NE2K) += compute_ip_checksum.c
|
||||||
romstage-$(CONFIG_USBDEBUG) += usbdebug.c
|
romstage-$(CONFIG_USBDEBUG) += usbdebug.c
|
||||||
|
|
||||||
ramstage-y += memset.c
|
ramstage-y += memset.c
|
||||||
|
ramstage-y += memchr.c
|
||||||
ramstage-y += memcpy.c
|
ramstage-y += memcpy.c
|
||||||
ramstage-y += memcmp.c
|
ramstage-y += memcmp.c
|
||||||
ramstage-y += memmove.c
|
ramstage-y += memmove.c
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include <string.h>
|
||||||
|
void *memchr(const void *s, int c, size_t n)
|
||||||
|
{
|
||||||
|
const unsigned char *sc = s;
|
||||||
|
while (n--) {
|
||||||
|
if (*sc == (unsigned char)c)
|
||||||
|
return (void *)sc;
|
||||||
|
sc++;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
Loading…
Reference in New Issue