ref: aa0b415d7be2602637696ad6235fb6b569c98199
parent: c3502416b37b482d5d80a79e56ce09d714a9270d
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Feb 17 03:40:40 EST 2017
[libc] Add memcmp()
--- a/libc/src/Makefile
+++ b/libc/src/Makefile
@@ -3,7 +3,7 @@
LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \
strrchr.o strcat.o strncpy.o strncat.o \
- memset.o memcpy.o memmove.o
+ memset.o memcpy.o memmove.o memcmp.o
all: libc.a
--- /dev/null
+++ b/libc/src/memcmp.c
@@ -1,0 +1,13 @@
+/* See LICENSE file for copyright and license details. */
+
+#include <string.h>
+
+int
+memcmp(const void *s1, const void *s2, size_t n)
+{
+ char *s = (char *) s1, *t = (char *) s2;
+
+ while (n > 0 && *s++ != *t++)
+ --n;
+ return n != 0;
+}