summaryrefslogtreecommitdiff
path: root/lib/libc/string/memcmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/string/memcmp.c')
-rw-r--r--lib/libc/string/memcmp.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/libc/string/memcmp.c b/lib/libc/string/memcmp.c
new file mode 100644
index 0000000..a3d47fb
--- /dev/null
+++ b/lib/libc/string/memcmp.c
@@ -0,0 +1,15 @@
+#include <string.h>
+
+int
+memcmp(const void *s1, const void *s2, size_t n)
+{
+ const char *str1 = (const char *)s1;
+ const char *str2 = (const char *)s2;
+ while (n--) {
+ if (*str1 != *str2)
+ return *str1 - *str2;
+ str1++; str2++;
+ }
+ return 0;
+}
+