From 0189cc9d771e5911b07fbf91ca18da3a338f8d30 Mon Sep 17 00:00:00 2001 From: Nathan Lee Date: Sat, 3 Oct 2026 21:37:57 -0500 Subject: add first userspace invocation --- website-kernel/arch/mem.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'website-kernel/arch/mem.c') diff --git a/website-kernel/arch/mem.c b/website-kernel/arch/mem.c index 301eb74..4b9a0b0 100644 --- a/website-kernel/arch/mem.c +++ b/website-kernel/arch/mem.c @@ -1,5 +1,6 @@ #include #include +#include static struct mempage_t *root; @@ -24,7 +25,6 @@ void set_root(struct mempage_t *incoming_root) { } void *kmalloc(size_t size) { - size = sizeof(size_t) + round_size(size, sizeof(struct mempage_t)); struct mempage_t *parent = NULL; struct mempage_t *node = root; @@ -92,3 +92,16 @@ void memzero(void *ptr, size_t size) { ((uint8_t *)ptr)[i] = 0; } } + +int memcmp(const void *s1, const void *s2, size_t n) { + const unsigned char *p1 = (const unsigned char *)s1; + const unsigned char *p2 = (const unsigned char *)s2; + + for (size_t i = 0; i < n; i++) { + if (p1[i] != p2[i]) { + return p1[i] - p2[i]; + } + } + + return 0; +} -- cgit v1.2.3