From 68e65dd6025fadb612d807b919326ce1756d63a1 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 7 Nov 2022 08:34:02 +0200 Subject: [PATCH] Update libc --- .vscode/c_boilerplates.code-snippets | 28 ++++++++++++++++++++++++++++ .vscode/c_cpp_properties.json | 26 ++++++++++++++++++++++++++ Fennix Userspace.code-workspace | 3 ++- Makefile | 1 + libc/Makefile | 1 + libc/include/dlfcn.h | 11 +++++++++++ libc/include/types.h | 6 ++++++ libc/runtime/crti.c | 0 libc/runtime/crtn.c | 0 libc/src/dlfcn.c | 23 +++++++++++++++++++++++ 10 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 .vscode/c_boilerplates.code-snippets create mode 100644 .vscode/c_cpp_properties.json create mode 100644 libc/include/dlfcn.h create mode 100644 libc/runtime/crti.c create mode 100644 libc/runtime/crtn.c create mode 100644 libc/src/dlfcn.c diff --git a/.vscode/c_boilerplates.code-snippets b/.vscode/c_boilerplates.code-snippets new file mode 100644 index 00000000..ef558a13 --- /dev/null +++ b/.vscode/c_boilerplates.code-snippets @@ -0,0 +1,28 @@ +{ + "Fennix Kernel Header": { + "prefix": [ + "head", + ], + "body": [ + "#ifndef __FENNIX_LIBC_${2:header}_H__", + "#define __FENNIX_LIBC_${2:header}_H__", + "", + "#include ", + "", + "$0", + "", + "#endif // !__FENNIX_LIBC_${2:header}_H__", + "" + ], + "description": "Create kernel header." + }, + "Fennix Kernel brief": { + "prefix": [ + "brief", + ], + "body": [ + "/** @brief $0 */" + ], + "description": "Create kernel documentation brief." + } +} \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..ef225a0d --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,26 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/libc/include/**", + "${workspaceFolder}/out/system/include**" + ], + "defines": [ + "__debug_vscode__", + "GIT_COMMIT=\"0000000000000000000000000000000000000000\"", + "GIT_COMMIT_SHORT=\"0000000\"", + "DEBUG=\"1\"" + ], + "compilerPath": "/usr/bin/gcc", + "cStandard": "c17", + "cppStandard": "c++20", + "intelliSenseMode": "gcc-x64", + "configurationProvider": "ms-vscode.makefile-tools", + "compilerArgs": [ + "-pipe", + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/Fennix Userspace.code-workspace b/Fennix Userspace.code-workspace index 22148c5d..8508b496 100644 --- a/Fennix Userspace.code-workspace +++ b/Fennix Userspace.code-workspace @@ -7,7 +7,8 @@ "settings": { "debug.allowBreakpointsEverywhere": true, "files.associations": { - "fex.hpp": "c" + "fex.hpp": "c", + "types.h": "c" } } } \ No newline at end of file diff --git a/Makefile b/Makefile index 5fb33edd..e12a3e3c 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ build: mkdir -p out mkdir -p out/system mkdir -p out/system/lib + mkdir -p out/system/include make --quiet -C libc build make --quiet -C apps build diff --git a/libc/Makefile b/libc/Makefile index a595fa35..0906be25 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -1,4 +1,5 @@ build: + cp include/* ../out/system/include make --quiet -C runtime build make --quiet -C libgcc build make --quiet -C src build diff --git a/libc/include/dlfcn.h b/libc/include/dlfcn.h new file mode 100644 index 00000000..49752100 --- /dev/null +++ b/libc/include/dlfcn.h @@ -0,0 +1,11 @@ +#ifndef __FENNIX_LIBC_DLFCN_H__ +#define __FENNIX_LIBC_DLFCN_H__ + +#include + +void *dlopen(const char *filename, int flags); +void *dlsym(void *handle, const char *symbol); +int dlclose(void *handle); +char *dlerror(void); + +#endif // !__FENNIX_LIBC_DLFCN_H__ diff --git a/libc/include/types.h b/libc/include/types.h index e69de29b..5ec3064f 100644 --- a/libc/include/types.h +++ b/libc/include/types.h @@ -0,0 +1,6 @@ +#ifndef __FENNIX_LIBC_TYPES_H__ +#define __FENNIX_LIBC_TYPES_H__ + +#define NULL ((void *)0) + +#endif // !__FENNIX_LIBC_TYPES_H__ diff --git a/libc/runtime/crti.c b/libc/runtime/crti.c new file mode 100644 index 00000000..e69de29b diff --git a/libc/runtime/crtn.c b/libc/runtime/crtn.c new file mode 100644 index 00000000..e69de29b diff --git a/libc/src/dlfcn.c b/libc/src/dlfcn.c new file mode 100644 index 00000000..5866c5f3 --- /dev/null +++ b/libc/src/dlfcn.c @@ -0,0 +1,23 @@ +#include + +static char *error = "Not implemented"; + +__attribute__((weak)) void *dlopen(const char *filename, int flags) +{ + return NULL; +} + +__attribute__((weak)) void *dlsym(void *handle, const char *symbol) +{ + return NULL; +} + +__attribute__((weak)) int dlclose(void *handle) +{ + return -1; +} + +__attribute__((weak)) char *dlerror(void) +{ + return error; +}