summaryrefslogtreecommitdiff
path: root/lib/memcmp.c
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2021-03-29 01:41:50 +0000
committerAda Christine <adachristine18@gmail.com>2021-03-29 01:41:50 +0000
commit42c6af83ec7e26983f1ecdefc81ea481a2354cb4 (patch)
treea096824a181eff4874e7840d148f3e5a06e3a5df /lib/memcmp.c
parent56ec6c782455f7d8e4560d30ad6d2c3e1cd2738f (diff)
don't echo command spam
move common files to new source add VPATH to loader and kernel makefiles for common source
Diffstat (limited to 'lib/memcmp.c')
-rw-r--r--lib/memcmp.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/memcmp.c b/lib/memcmp.c
new file mode 100644
index 0000000..2348afe
--- /dev/null
+++ b/lib/memcmp.c
@@ -0,0 +1,16 @@
+/* Public domain. */
+#include <stddef.h>
+
+int
+memcmp (const void *str1, const void *str2, size_t count)
+{
+ const unsigned char *s1 = str1;
+ const unsigned char *s2 = str2;
+
+ while (count-- > 0)
+ {
+ if (*s1++ != *s2++)
+ return s1[-1] < s2[-1] ? -1 : 1;
+ }
+ return 0;
+}