[coreboot] New patch to review for coreboot: 618c314 Add an implementation for the memchr library function

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Mon Mar 5 22:03:34 CET 2012


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/708

-gerrit

commit 618c314d845a4fc23f8fc8902bcff334c1d8fd12
Author: Gabe Black <gabeblack at google.com>
Date:   Fri Sep 16 02:18:56 2011 -0700

    Add an implementation for the memchr library function
    
    This function is declared in string.h, but no implementation was compiled in
    this change adds a very simple, naive implementation.
    
    Change-Id: Icded479d246f7cce8a3d2154c69f75178fa513e1
    Signed-off-by: Gabe Black <gabeblack at google.com>
---
 src/lib/Makefile.inc |    2 ++
 src/lib/memchr.c     |   11 +++++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 906dfae..e0e5e75 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -1,6 +1,7 @@
 
 
 romstage-y += memset.c
+romstage-y += memchr.c
 romstage-y += memcpy.c
 romstage-y += memcmp.c
 romstage-y += cbfs.c
@@ -15,6 +16,7 @@ romstage-$(CONFIG_CONSOLE_NE2K) += compute_ip_checksum.c
 romstage-$(CONFIG_USBDEBUG) += usbdebug.c
 
 ramstage-y += memset.c
+ramstage-y += memchr.c
 ramstage-y += memcpy.c
 ramstage-y += memcmp.c
 ramstage-y += memmove.c
diff --git a/src/lib/memchr.c b/src/lib/memchr.c
new file mode 100644
index 0000000..a890dce
--- /dev/null
+++ b/src/lib/memchr.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;
+}




More information about the coreboot mailing list