aboutsummaryrefslogtreecommitdiff
path: root/libc/inc/mem.h
diff options
context:
space:
mode:
authorMarvin Borner2020-08-15 17:42:36 +0200
committerMarvin Borner2020-08-15 17:42:36 +0200
commit9f16b032d38613ca95e321e1d1e652c43129c68b (patch)
tree33f71a84f60b496ed31a128ec542c5341c754b0d /libc/inc/mem.h
parent32b8722128dfb4ca9e814940a23c2b22a283bb12 (diff)
Added libgui
Diffstat (limited to 'libc/inc/mem.h')
-rw-r--r--libc/inc/mem.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/libc/inc/mem.h b/libc/inc/mem.h
new file mode 100644
index 0000000..0030b3d
--- /dev/null
+++ b/libc/inc/mem.h
@@ -0,0 +1,27 @@
+// MIT License, Copyright (c) 2020 Marvin Borner
+
+#ifndef MEM_H
+#define MEM_H
+
+#include <def.h>
+
+// Huh
+#ifdef kernel
+#define malloc(n) (void *)((HEAP += n) - n) // TODO: Implement real/better malloc/free
+#define free(ptr)
+#elif defined(userspace)
+#include <sys.h>
+#define malloc(n) (void *)sys1(SYS_MALLOC, n)
+#define free(ptr) (void)(sys1(SYS_FREE, (int)ptr))
+#else
+#error "No lib target specified. Please use -Dkernel or -Duserspace"
+#endif
+
+u32 HEAP;
+u32 HEAP_START;
+
+void *memcpy(void *dst, const void *src, u32 n);
+void *memset(void *dst, int c, u32 n);
+int memcmp(const void *s1, const void *s2, u32 n);
+
+#endif