From 500f774b7fa6297cf6ceecacae3f52c26071ca26 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 22 Aug 2024 14:28:39 +0300 Subject: [PATCH] LibC: Add a lot of stub implementations for different libc functions some ports want to link against these, but they are not ever called based on simple testing This patch adds stubs for - openlog - syslog - getrusage - mlock - mprotect - getpeername - shutdown - tzset - mktime --- userspace/libraries/LibC/CMakeLists.txt | 2 ++ userspace/libraries/LibC/sys/mman.cpp | 13 +++++++++++++ userspace/libraries/LibC/sys/resource.cpp | 7 +++++++ userspace/libraries/LibC/sys/socket.cpp | 14 ++++++++++++++ userspace/libraries/LibC/syslog.cpp | 12 ++++++++++++ userspace/libraries/LibC/time.cpp | 15 +++++++++++++++ 6 files changed, 63 insertions(+) create mode 100644 userspace/libraries/LibC/sys/resource.cpp create mode 100644 userspace/libraries/LibC/syslog.cpp diff --git a/userspace/libraries/LibC/CMakeLists.txt b/userspace/libraries/LibC/CMakeLists.txt index 271f0629..07f6840c 100644 --- a/userspace/libraries/LibC/CMakeLists.txt +++ b/userspace/libraries/LibC/CMakeLists.txt @@ -25,12 +25,14 @@ set(LIBC_SOURCES sys/banan-os.cpp sys/ioctl.cpp sys/mman.cpp + sys/resource.cpp sys/select.cpp sys/socket.cpp sys/stat.cpp sys/time.cpp sys/utsname.cpp sys/wait.cpp + syslog.cpp termios.cpp time.cpp unistd.cpp diff --git a/userspace/libraries/LibC/sys/mman.cpp b/userspace/libraries/LibC/sys/mman.cpp index f08a0022..b53c8252 100644 --- a/userspace/libraries/LibC/sys/mman.cpp +++ b/userspace/libraries/LibC/sys/mman.cpp @@ -27,3 +27,16 @@ int msync(void* addr, size_t len, int flags) { return syscall(SYS_MSYNC, addr, len, flags); } + + +#include + +int mlock(const void*, size_t) +{ + ASSERT_NOT_REACHED(); +} + +int mprotect(void*, size_t, int) +{ + ASSERT_NOT_REACHED(); +} diff --git a/userspace/libraries/LibC/sys/resource.cpp b/userspace/libraries/LibC/sys/resource.cpp new file mode 100644 index 00000000..e21c99a1 --- /dev/null +++ b/userspace/libraries/LibC/sys/resource.cpp @@ -0,0 +1,7 @@ +#include +#include + +int getrusage(int, struct rusage*) +{ + ASSERT_NOT_REACHED(); +} diff --git a/userspace/libraries/LibC/sys/socket.cpp b/userspace/libraries/LibC/sys/socket.cpp index 2cc5abd4..d97747c8 100644 --- a/userspace/libraries/LibC/sys/socket.cpp +++ b/userspace/libraries/LibC/sys/socket.cpp @@ -77,3 +77,17 @@ int setsockopt(int socket, int level, int option_name, const void* option_value, { return syscall(SYS_SETSOCKOPT, socket, level, option_name, option_value, option_len); } + + + +#include + +int getpeername(int, struct sockaddr* __restrict, socklen_t* __restrict) +{ + ASSERT_NOT_REACHED(); +} + +int shutdown(int, int) +{ + ASSERT_NOT_REACHED(); +} diff --git a/userspace/libraries/LibC/syslog.cpp b/userspace/libraries/LibC/syslog.cpp new file mode 100644 index 00000000..696867ed --- /dev/null +++ b/userspace/libraries/LibC/syslog.cpp @@ -0,0 +1,12 @@ +#include +#include + +void openlog(const char*, int, int) +{ + ASSERT_NOT_REACHED(); +} + +void syslog(int, const char*, ...) +{ + ASSERT_NOT_REACHED(); +} diff --git a/userspace/libraries/LibC/time.cpp b/userspace/libraries/LibC/time.cpp index a1ae89a9..658ef1c5 100644 --- a/userspace/libraries/LibC/time.cpp +++ b/userspace/libraries/LibC/time.cpp @@ -452,3 +452,18 @@ size_t strftime(char* __restrict s, size_t maxsize, const char* __restrict forma s[len++] = '\0'; return len; } + + + +#include + +long timezone; +void tzset() +{ + ASSERT_NOT_REACHED(); +} + +time_t mktime(struct tm*) +{ + ASSERT_NOT_REACHED(); +}