]> git.corax.cc Git - corax/commitdiff
Use standard C functions from klibc within the kernel
authorMatthias Kruk <m@m10k.eu>
Tue, 19 Nov 2019 06:55:01 +0000 (15:55 +0900)
committerMatthias Kruk <m@m10k.eu>
Tue, 19 Nov 2019 06:55:01 +0000 (15:55 +0900)
include/string.h [new file with mode: 0644]
kernel/Makefile
kernel/arch/debug.c
kernel/arch/heap.c
kernel/arch/paging.c
kernel/core/process.c
kernel/include/debug.h

diff --git a/include/string.h b/include/string.h
new file mode 100644 (file)
index 0000000..9697603
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef _STRING_H
+#define _STRING_H
+
+#include <sys/types.h>
+
+void* memset(void *dst, int val, u32_t n);
+void* memcpy(void *dst, const void *src, u32_t n);
+size_t strlen(const char*);
+
+#endif /* _STRING_H */
index a5c754877e05a86f0ac674d833c87cae876ea2c5..2d37c049f2ce74705164aa66b462e4bccf7c0392 100644 (file)
@@ -1,5 +1,5 @@
-OBJECTS = arch/arch.o core/core.o
-DEPS = arch core
+OBJECTS = arch/arch.o core/core.o klibc/klibc.a
+DEPS = arch core klibc
 LDFLAGS = --oformat=elf32-i386 -b elf32-i386 -m elf_i386
 CFLAGS = -m32 -Wall -nostdlib -nodefaultlibs -nostartfiles -ffreestanding
 PHONY = $(DEPS) clean
index 3793a3c2984bfd4466ed8bd157dd0a2946b5218d..57750068d055973522e265e88c935fb8c7a6ebf3 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <corax/types.h>
 #include <debug.h>
+#include <string.h>
 
 #define ABS(x)  (((x) < 0) ? (-(x)) : (x))
 
@@ -140,30 +141,6 @@ u64_t _u64mod(u64_t dividend, u64_t divisor)
     return(dividend);
 }
 
-void* memset(void *dst, int val, u32_t n)
-{
-    char *ptr;
-
-    ptr = dst;
-    while(n--) {
-        *ptr++ = val;
-    }
-    return(dst);
-}
-
-void* memcpy(void *dst, const void *src, u32_t n)
-{
-    char *d;
-    const char *s;
-
-    d = dst;
-    s = src;
-    while(n--) {
-        *d++ = *s++;
-    }
-    return(dst);
-}
-
 static void _putchar(int c)
 {
     if(c == '\n') {
index bc73405645cbddda9ef66122a936e7b702ed14a2..0a855349f739e2b80ed7bb29e8404216bf5824ad 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <corax/errno.h>
 #include <debug.h>
+#include <string.h>
 #include "paging.h"
 #include "heap.h"
 
index 038eb19c052b8e8f8e84af236ea29cd34bcf797a..645ea68a4c1cf27f5304eeea6352b564dbc1dc28 100644 (file)
@@ -22,6 +22,7 @@
 #include <multiboot.h>
 #include <debug.h>
 #include <arch.h>
+#include <string.h>
 #include "cpu.h"
 #include "paging.h"
 #include "heap.h"
index 0d960a677fdc0960bb256e0316b5740f177fa493..09b40d9d479fd68caebbdc5d368bcda2a8492fa4 100644 (file)
@@ -7,6 +7,7 @@
 #include <debug.h>
 #include <process.h>
 #include <signal.h>
+#include <string.h>
 #include "fd.h"
 #include "sched.h"
 
index af816c15b02168423e3935f4e4753dfd3d8943fb..d642963c288eb87a2f134a994ec76480b4cff6d9 100644 (file)
@@ -28,9 +28,6 @@ i64_t _i64mod(i64_t, i64_t);
 
 #define PANIC(msg)  dbg_panic(__func__, __FILE__, __LINE__, msg)
 
-void* memset(void *dst, int val, u32_t n);
-void* memcpy(void *dst, const void *src, u32_t n);
-
 int dbg_printf(const char*, ...);
 void dbg_panic(const char*, const char*, i32_t, const char*);