summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2024-05-27 13:53:52 -0500
committerDanny Holman <dholman@gymli.org>2024-05-27 13:53:52 -0500
commitaaf7355c5ededfcdc877c7f2989fb1ba02dfb848 (patch)
tree0c4588650fe1fc1fa1af2972353a2bc920cf1e68 /include
parent41cff28f5447b5f669db62ce2a73be98bc5bce37 (diff)
libk: create a subset libc for kernel use
Create a subset of the C library for use inside the kernel. Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'include')
-rw-r--r--include/libk/container_of.h (renamed from include/kernel/container_of.h)4
-rw-r--r--include/libk/data/list.h (renamed from include/kernel/data/list.h)4
-rw-r--r--include/libk/data/ringbuf.h (renamed from include/kernel/data/ringbuf.h)4
-rw-r--r--include/libk/io.h (renamed from include/kernel/io.h)5
-rw-r--r--include/libk/kmalloc.h (renamed from include/kernel/kmalloc.h)7
-rw-r--r--include/libk/string.h (renamed from include/kernel/string.h)5
6 files changed, 16 insertions, 13 deletions
diff --git a/include/kernel/container_of.h b/include/libk/container_of.h
index 1b5b444..fdc400c 100644
--- a/include/kernel/container_of.h
+++ b/include/libk/container_of.h
@@ -1,5 +1,5 @@
-#ifndef KERNEL_CONTAINER_OF_H
-#define KERNEL_CONTAINER_OF_H
+#ifndef LIBK_CONTAINER_OF_H
+#define LIBK_CONTAINER_OF_H
#ifndef container_of
#define container_of(ptr, type, member) ({ \
diff --git a/include/kernel/data/list.h b/include/libk/data/list.h
index b61cfaa..69eee3a 100644
--- a/include/kernel/data/list.h
+++ b/include/libk/data/list.h
@@ -1,5 +1,5 @@
-#ifndef KERNEL_LIST_H
-#define KERNEL_LIST_H
+#ifndef LIBK_LIST_H
+#define LIBK_LIST_H
#include <stddef.h>
diff --git a/include/kernel/data/ringbuf.h b/include/libk/data/ringbuf.h
index 25a7125..cc6d77b 100644
--- a/include/kernel/data/ringbuf.h
+++ b/include/libk/data/ringbuf.h
@@ -1,5 +1,5 @@
-#ifndef KERNEL_RINGBUF_H
-#define KERNEL_RINGBUF_H
+#ifndef LIBK_RINGBUF_H
+#define LIBK_RINGBUF_H
#include <kernel/kmalloc.h>
#include <kernel/string.h>
diff --git a/include/kernel/io.h b/include/libk/io.h
index cf8404a..72dc5d7 100644
--- a/include/kernel/io.h
+++ b/include/libk/io.h
@@ -1,8 +1,9 @@
-#ifndef KERNEL_IO_H
-#define KERNEL_IO_H
+#ifndef LIBK_IO_H
+#define LIBK_IO_H
#include <stdarg.h>
+char* convert(unsigned int num, int base);
int vkprintf(const char *fmt, va_list args);
int kprintf(const char *fmt, ...);
diff --git a/include/kernel/kmalloc.h b/include/libk/kmalloc.h
index d8debd1..6573d28 100644
--- a/include/kernel/kmalloc.h
+++ b/include/libk/kmalloc.h
@@ -1,14 +1,15 @@
-#ifndef KERNEL_KMALLOC_H
-#define KERNEL_KMALLOC_H
+#ifndef LIBK_KMALLOC_H
+#define LIBK_KMALLOC_H
#include <stdint.h>
#include <stddef.h>
struct mem_block {
- uintptr_t start;
+ void *start;
size_t size;
int alloc;
struct mem_block *next;
+ struct mem_block *prev;
};
void kmalloc_init(void);
diff --git a/include/kernel/string.h b/include/libk/string.h
index 76bf610..1fb4af1 100644
--- a/include/kernel/string.h
+++ b/include/libk/string.h
@@ -1,5 +1,5 @@
-#ifndef STRING_H
-#define STRING_H
+#ifndef LIBK_STRING_H
+#define LIBK_STRING_H
#include <stddef.h>
@@ -12,6 +12,7 @@ int strcmp(const char *str1, const char *str2);
size_t strlen(const char *str);
char* strncpy(char* __restrict dest, const char* __restrict src, size_t n);
char* strcpy(char* __restrict dest, const char* __restrict src);
+char* strncat(char* __restrict dest, const char* __restrict src, size_t n);
char* strcat(char* __restrict dest, const char* __restrict src);
char* strtok(char* __restrict str, const char* __restrict delim);