summaryrefslogtreecommitdiff
path: root/kernel/memcmp.c
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2021-03-24 12:04:46 +0000
committerAda Christine <adachristine18@gmail.com>2021-03-24 12:04:46 +0000
commitac843b4be02de473a3697bc64c25c6c3793c9e8f (patch)
tree91b40ca05cf25f6ba3050a496e239858ce7bf8ee /kernel/memcmp.c
parent90820d94b942cc3ecf62818e401e271217255b03 (diff)
forgot gcc wants these functions
Diffstat (limited to 'kernel/memcmp.c')
-rw-r--r--kernel/memcmp.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/kernel/memcmp.c b/kernel/memcmp.c
new file mode 100644
index 0000000..2348afe
--- /dev/null
+++ b/kernel/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;
+}