mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
256 lines
7.9 KiB
Diff
256 lines
7.9 KiB
Diff
diff --git mlibc-clean/abis/linux/in.h mlibc-workdir/abis/linux/in.h
|
|
index 87bc25f..d7370d0 100644
|
|
--- mlibc-clean/abis/linux/in.h
|
|
+++ mlibc-workdir/abis/linux/in.h
|
|
@@ -109,6 +109,9 @@ struct group_source_req {
|
|
|
|
#define IPPORT_RESERVED 1024
|
|
|
|
+#define IP_MULTICAST_TTL 33
|
|
+#define IPV6_MULTICAST_HOPS 18
|
|
+
|
|
#define IPPROTO_IP 0
|
|
#define IPPROTO_HOPOPTS 0
|
|
#define IPPROTO_ICMP 1
|
|
diff --git mlibc-clean/meson.build mlibc-workdir/meson.build
|
|
index 39796b5..7d671fc 100644
|
|
--- mlibc-clean/meson.build
|
|
+++ mlibc-workdir/meson.build
|
|
@@ -268,6 +268,7 @@ elif host_machine.system() == 'astral'
|
|
libc_include_dirs += include_directories('sysdeps/astral/include')
|
|
internal_conf.set10('MLIBC_MAP_DSO_SEGMENTS', true)
|
|
internal_conf.set10('MLIBC_MAP_FILE_WINDOWS', true)
|
|
+ internal_conf.set10('MLIBC_MMAP_ALLOCATE_DSO', true)
|
|
subdir('sysdeps/astral')
|
|
else
|
|
error('No sysdeps defined for OS: ' + host_machine.system())
|
|
diff --git mlibc-clean/options/ansi/generic/environment.cpp mlibc-workdir/options/ansi/generic/environment.cpp
|
|
index 5625592..36b42ee 100644
|
|
--- mlibc-clean/options/ansi/generic/environment.cpp
|
|
+++ mlibc-workdir/options/ansi/generic/environment.cpp
|
|
@@ -111,8 +111,10 @@ namespace mlibc {
|
|
int putenv(char *string) {
|
|
frg::string_view view{string};
|
|
size_t s = view.find_first('=');
|
|
- if(s == size_t(-1))
|
|
- __ensure(!"Environment strings need to contain an equals sign");
|
|
+ if(s == size_t(-1)) {
|
|
+ unsetenv(string);
|
|
+ return 0;
|
|
+ }
|
|
|
|
update_vector();
|
|
assign_variable(view.sub_string(0, s), string, true);
|
|
diff --git mlibc-clean/options/ansi/generic/string.cpp mlibc-workdir/options/ansi/generic/string.cpp
|
|
index 8defd0e..d6cb65b 100644
|
|
--- mlibc-clean/options/ansi/generic/string.cpp
|
|
+++ mlibc-workdir/options/ansi/generic/string.cpp
|
|
@@ -406,7 +406,6 @@ char *strerror(int e) {
|
|
case ENOPROTOOPT: s = "Protocol not available (ENOPROTOOPT)"; break;
|
|
case ENOTEMPTY: s = "Directory not empty (ENOTEMPTY)"; break;
|
|
case ENOTRECOVERABLE: s = "Sate not recoverable (ENOTRECOVERABLE)"; break;
|
|
- case ENOTSUP: s = "Operation not supported (ENOTSUP)"; break;
|
|
case ENOTTY: s = "Inappropriate ioctl for device (ENOTTY)"; break;
|
|
case EOVERFLOW: s = "Value too large for defined datatype (EOVERFLOW)"; break;
|
|
#if EOPNOTSUPP != ENOTSUP
|
|
diff --git mlibc-clean/options/crypt/generic/crypt.cpp mlibc-workdir/options/crypt/generic/crypt.cpp
|
|
index 65e0d23..95b060c 100644
|
|
--- mlibc-clean/options/crypt/generic/crypt.cpp
|
|
+++ mlibc-workdir/options/crypt/generic/crypt.cpp
|
|
@@ -1,7 +1,8 @@
|
|
#include <crypt.h>
|
|
#include <bits/ensure.h>
|
|
+#include <string.h>
|
|
|
|
-char *crypt(const char *, const char *) {
|
|
+char *crypt(const char *passwd, const char *) {
|
|
__ensure(!"Not implemented");
|
|
__builtin_unreachable();
|
|
}
|
|
diff --git mlibc-clean/options/glibc/generic/execinfo.cpp mlibc-workdir/options/glibc/generic/execinfo.cpp
|
|
index 3474615..e034881 100644
|
|
--- mlibc-clean/options/glibc/generic/execinfo.cpp
|
|
+++ mlibc-workdir/options/glibc/generic/execinfo.cpp
|
|
@@ -1,9 +1,10 @@
|
|
#include <execinfo.h>
|
|
#include <bits/ensure.h>
|
|
+#include <mlibc/debug.hpp>
|
|
|
|
int backtrace(void **, int) {
|
|
- __ensure(!"Not implemented");
|
|
- __builtin_unreachable();
|
|
+ mlibc::infoLogger() << "libc: backtrace() is not implemented!\n" << frg::endlog;
|
|
+ return 0;
|
|
}
|
|
|
|
char **backtrace_symbols(void *const *, int) {
|
|
diff --git mlibc-clean/options/posix/generic/dlfcn.cpp mlibc-workdir/options/posix/generic/dlfcn.cpp
|
|
index fc34a3b..b1a95a9 100644
|
|
--- mlibc-clean/options/posix/generic/dlfcn.cpp
|
|
+++ mlibc-workdir/options/posix/generic/dlfcn.cpp
|
|
@@ -1,4 +1,4 @@
|
|
-
|
|
+#define _GNU_SOURCE
|
|
#include <bits/ensure.h>
|
|
#include <dlfcn.h>
|
|
|
|
diff --git mlibc-clean/options/posix/generic/unistd.cpp mlibc-workdir/options/posix/generic/unistd.cpp
|
|
index 444ad22..d1ca86e 100644
|
|
--- mlibc-clean/options/posix/generic/unistd.cpp
|
|
+++ mlibc-workdir/options/posix/generic/unistd.cpp
|
|
@@ -484,8 +484,9 @@ int lockf(int fd, int op, off_t size) {
|
|
}
|
|
|
|
int nice(int) {
|
|
- __ensure(!"Not implemented");
|
|
- __builtin_unreachable();
|
|
+ return EPERM;
|
|
+ //__ensure(!"Not implemented");
|
|
+ //__builtin_unreachable();
|
|
}
|
|
|
|
long pathconf(const char *, int name) {
|
|
diff --git mlibc-clean/options/rtld/generic/main.cpp mlibc-workdir/options/rtld/generic/main.cpp
|
|
index 9219ef0..1ff679c 100644
|
|
--- mlibc-clean/options/rtld/generic/main.cpp
|
|
+++ mlibc-workdir/options/rtld/generic/main.cpp
|
|
@@ -17,6 +17,8 @@
|
|
#include "elf.hpp"
|
|
#include "linker.hpp"
|
|
|
|
+#define _GNU_SOURCE
|
|
+
|
|
#if __MLIBC_POSIX_OPTION
|
|
#include <dlfcn.h>
|
|
#endif
|
|
diff --git mlibc-clean/sysdeps/astral/generic/astral.cpp mlibc-workdir/sysdeps/astral/generic/astral.cpp
|
|
index d5ba7b2..a86353f 100644
|
|
--- mlibc-clean/sysdeps/astral/generic/astral.cpp
|
|
+++ mlibc-workdir/sysdeps/astral/generic/astral.cpp
|
|
@@ -4,7 +4,7 @@
|
|
|
|
#ifndef MLIBC_BUILDING_RTLD
|
|
|
|
-int syscall_archctl(int func, void *arg) {
|
|
+int arch_ctl(int func, void *arg) {
|
|
long ret;
|
|
long error = syscall(SYSCALL_ARCHCTL, &ret, func, (uint64_t)arg);
|
|
if(error)
|
|
diff --git mlibc-clean/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
|
index 2a504ab..3c46318 100644
|
|
--- mlibc-clean/sysdeps/astral/generic/generic.cpp
|
|
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
|
@@ -31,6 +31,12 @@ namespace mlibc {
|
|
return 0;
|
|
}
|
|
|
|
+ int sys_getcpu(int *cpu) {
|
|
+ *cpu = 0;
|
|
+ // TODO unstub
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
int sys_getsockopt(int fd, int layer, int number,
|
|
void *__restrict buffer, socklen_t *__restrict size) {
|
|
(void)size;
|
|
@@ -40,6 +46,11 @@ namespace mlibc {
|
|
return 0;
|
|
}
|
|
|
|
+ int sys_shutdown(int sockfd, int how) {
|
|
+ long ret;
|
|
+ return syscall(SYSCALL_SHUTDOWN, &ret, sockfd, how);
|
|
+ }
|
|
+
|
|
int sys_tgkill(int pid, int tid, int sig) {
|
|
long ret;
|
|
return syscall(SYSCALL_KILLTHREAD, &ret, pid, tid, sig);
|
|
@@ -161,7 +172,18 @@ namespace mlibc {
|
|
*bytes_written = writec;
|
|
return error;
|
|
}
|
|
-
|
|
+
|
|
+ int sys_getrlimit(int resource, struct rlimit *limit) {
|
|
+ switch(resource) {
|
|
+ case RLIMIT_NOFILE:
|
|
+ limit->rlim_cur = RLIM_INFINITY;
|
|
+ limit->rlim_max = RLIM_INFINITY;
|
|
+ return 0;
|
|
+ default:
|
|
+ return EINVAL;
|
|
+ }
|
|
+ }
|
|
+
|
|
#ifndef MLIBC_BUILDING_RTLD
|
|
|
|
typedef struct {
|
|
@@ -487,6 +509,12 @@ namespace mlibc {
|
|
return ret;
|
|
}
|
|
|
|
+ pid_t sys_gettid() {
|
|
+ long ret;
|
|
+ syscall(SYSCALL_GETTID, &ret);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
#ifndef MLIBC_BUILDING_RTLD
|
|
|
|
[[noreturn]] void sys_thread_exit() {
|
|
@@ -882,7 +910,7 @@ namespace mlibc {
|
|
|
|
int sys_tcb_set(void *pointer) {
|
|
long r;
|
|
- return syscall(SYSCALL_ARCHCTL, &r, ARCH_CTL_FSBASE, (uint64_t)pointer);
|
|
+ return syscall(SYSCALL_ARCHCTL, &r, ARCH_CTL_SET_FSBASE, (uint64_t)pointer);
|
|
}
|
|
|
|
#define FUTEX_WAIT 0
|
|
diff --git mlibc-clean/sysdeps/astral/include/astral/archctl.h mlibc-workdir/sysdeps/astral/include/astral/archctl.h
|
|
index d738e02..7e4f2a1 100644
|
|
--- mlibc-clean/sysdeps/astral/include/astral/archctl.h
|
|
+++ mlibc-workdir/sysdeps/astral/include/astral/archctl.h
|
|
@@ -1,8 +1,10 @@
|
|
#ifndef _ASTRAL_ARCHCTL_H
|
|
#define _ASTRAL_ARCHCTL_H
|
|
|
|
-#define ARCH_CTL_GSBASE 0
|
|
-#define ARCH_CTL_FSBASE 1
|
|
+#define ARCH_CTL_SET_GSBASE 0
|
|
+#define ARCH_CTL_SET_FSBASE 1
|
|
+#define ARCH_CTL_GET_GSBASE 2
|
|
+#define ARCH_CTL_GET_FSBASE 3
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
diff --git mlibc-clean/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
|
index 5f42d62..852f9ff 100644
|
|
--- mlibc-clean/sysdeps/astral/include/astral/syscall.h
|
|
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
|
@@ -96,6 +96,7 @@
|
|
#define SYSCALL_SIGTIMEDWAIT 89
|
|
#define SYSCALL_SIGPENDING 90
|
|
#define SYSCALL_KILLTHREAD 91
|
|
+#define SYSCALL_SHUTDOWN 92
|
|
|
|
#ifndef __MLIBC_ABI_ONLY
|
|
|
|
diff --git mlibc-clean/sysdeps/astral/meson.build mlibc-workdir/sysdeps/astral/meson.build
|
|
index a5ede46..e198d2e 100644
|
|
--- mlibc-clean/sysdeps/astral/meson.build
|
|
+++ mlibc-workdir/sysdeps/astral/meson.build
|
|
@@ -63,6 +63,12 @@ if not no_headers
|
|
subdir: 'abi-bits',
|
|
follow_symlinks: true,
|
|
)
|
|
+ install_headers(
|
|
+ 'include/astral/syscall.h',
|
|
+ 'include/astral/archctl.h',
|
|
+ subdir: 'astral',
|
|
+ follow_symlinks: true,
|
|
+ )
|
|
endif
|
|
|
|
if not headers_only
|