diff options
| author | Nathan Lee <me@nwlee.tech> | 2026-10-03 21:37:57 -0500 |
|---|---|---|
| committer | Nathan Lee <me@nwlee.tech> | 2026-10-03 21:37:57 -0500 |
| commit | 0189cc9d771e5911b07fbf91ca18da3a338f8d30 (patch) | |
| tree | dbf2c8a366547dda3ec99f752417a4085a5a5599 /website-kernel/arch/mem.c | |
| parent | 182ad75161c77b4a75d48275979ce44cde213e3f (diff) | |
add first userspace invocation
Diffstat (limited to 'website-kernel/arch/mem.c')
| -rw-r--r-- | website-kernel/arch/mem.c | 15 |
1 files changed, 14 insertions, 1 deletions
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 <int.h> #include <sys.h> +#include <log.h> 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; +} |
