syscalls: getcpu

This commit is contained in:
Matheus
2025-09-12 23:03:30 -03:00
parent ad4f5ff8cf
commit a599c7f95e
4 changed files with 34 additions and 20 deletions
+12 -16
View File
@@ -84,26 +84,21 @@ index d5ba7b2..a86353f 100644
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 bb85dba..5e9e21a 100644
index bb85dba..5f12e17 100644
--- mlibc-clean/sysdeps/astral/generic/generic.cpp
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
@@ -31,6 +31,12 @@ namespace mlibc {
@@ -40,6 +40,31 @@ namespace mlibc {
return 0;
}
+ int sys_getcpu(int *cpu) {
+ *cpu = 0;
+ // TODO unstub
+ long ret;
+ // can never fail
+ syscall(SYSCALL_GETCPU, &ret);
+ *cpu = ret;
+ return 0;
+ }
+
int sys_getsockopt(int fd, int layer, int number,
void *__restrict buffer, socklen_t *__restrict size) {
(void)size;
@@ -40,6 +46,23 @@ namespace mlibc {
return 0;
}
+ int sys_flock(int fd, int options) {
+ long r;
+ return syscall(SYSCALL_FLOCK, &r, fd, options);
@@ -124,7 +119,7 @@ index bb85dba..5e9e21a 100644
int sys_tgkill(int pid, int tid, int sig) {
long ret;
return syscall(SYSCALL_KILLTHREAD, &ret, pid, tid, sig);
@@ -161,7 +184,18 @@ namespace mlibc {
@@ -161,7 +186,18 @@ namespace mlibc {
*bytes_written = writec;
return error;
}
@@ -144,7 +139,7 @@ index bb85dba..5e9e21a 100644
#ifndef MLIBC_BUILDING_RTLD
typedef struct {
@@ -376,6 +410,12 @@ namespace mlibc {
@@ -376,6 +412,12 @@ namespace mlibc {
return ret;
}
@@ -157,7 +152,7 @@ index bb85dba..5e9e21a 100644
#ifndef MLIBC_BUILDING_RTLD
[[noreturn]] void sys_thread_exit() {
@@ -771,7 +811,7 @@ namespace mlibc {
@@ -771,7 +813,7 @@ namespace mlibc {
int sys_tcb_set(void *pointer) {
long r;
@@ -184,16 +179,17 @@ index d738e02..7e4f2a1 100644
#ifdef __cplusplus
extern "C" {
diff --git mlibc-clean/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
index 5f42d62..6fbb253 100644
index 5f42d62..8414286 100644
--- mlibc-clean/sysdeps/astral/include/astral/syscall.h
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
@@ -96,6 +96,9 @@
@@ -96,6 +96,10 @@
#define SYSCALL_SIGTIMEDWAIT 89
#define SYSCALL_SIGPENDING 90
#define SYSCALL_KILLTHREAD 91
+#define SYSCALL_SHUTDOWN 92
+#define SYSCALL_NICE 93
+#define SYSCALL_FLOCK 94
+#define SYSCALL_GETCPU 95
#ifndef __MLIBC_ABI_ONLY