aboutsummaryrefslogtreecommitdiffstats
path: root/libc/memcmp.c
diff options
context:
space:
mode:
authorEmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com>2024-05-05 01:08:00 -0400
committerEmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com>2024-05-05 01:08:00 -0400
commit4aa74dbe2a35a45668b33d688f17b680c2232572 (patch)
tree42794e2fe2ba653ccbf772bb02dbfda07f75943e /libc/memcmp.c
parent2d59766eb330b9d15a9bcbcd7e1695809fc099c5 (diff)
improved makefile somewhat
Diffstat (limited to 'libc/memcmp.c')
-rw-r--r--libc/memcmp.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libc/memcmp.c b/libc/memcmp.c
new file mode 100644
index 0000000..93141e1
--- /dev/null
+++ b/libc/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