aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/std/memcmp.c
diff options
context:
space:
mode:
authorEmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com>2023-06-15 22:36:39 -0400
committerEmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com>2023-06-15 22:36:39 -0400
commita78033acc941fc4bcf6188f1d48fd8e012673fff (patch)
treeac92adae5e40274fd9e0b78352a24840cc88eab4 /kernel/std/memcmp.c
initial commit
Diffstat (limited to 'kernel/std/memcmp.c')
-rw-r--r--kernel/std/memcmp.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/kernel/std/memcmp.c b/kernel/std/memcmp.c
new file mode 100644
index 0000000..93141e1
--- /dev/null
+++ b/kernel/std/memcmp.c
@@ -0,0 +1,13 @@
+#include <string.h>
+
+int memcmp(const void* aptr, const void* bptr, size_t size) {
+ const unsigned char* a = (const unsigned char*) aptr;
+ const unsigned char* b = (const unsigned char*) bptr;
+ for (size_t i = 0; i < size; i++) {
+ if (a[i] < b[i])
+ return -1;
+ else if (b[i] < a[i])
+ return 1;
+ }
+ return 0;
+} \ No newline at end of file