syscalls: sigpending

This commit is contained in:
Matheus
2024-09-08 23:14:18 -03:00
parent 61e3866ffd
commit ca04805517
4 changed files with 32 additions and 8 deletions
+3 -1
View File
@@ -89,6 +89,7 @@ extern syscall_setgid
extern syscall_setegid
extern syscall_sigsuspend
extern syscall_sigtimedwait
extern syscall_sigpending
syscalltab:
dq syscall_print
dq syscall_mmap
@@ -180,7 +181,8 @@ dq syscall_setgid
dq syscall_setegid
dq syscall_sigsuspend
dq syscall_sigtimedwait
syscallcount equ 90
dq syscall_sigpending
syscallcount equ 91
section .text
global arch_syscall_entry
; on entry:
+5 -3
View File
@@ -5,7 +5,7 @@
#ifdef SYSCALL_LOGGING
#define SYSCALL_COUNT 90
#define SYSCALL_COUNT 91
#define LOGSTR(x) arch_e9_puts(x)
static char *name[] = {
@@ -98,7 +98,8 @@ static char *name[] = {
"setgid",
"setegid",
"sigsuspend",
"sigtimedwait"
"sigtimedwait",
"sigpending"
};
static char *args[] = {
@@ -191,7 +192,8 @@ static char *args[] = {
"gid %d", // setgid
"egid %d", // setegid
"sigset %p", // sigsuspend
"set %p info %p, timespec %p" // sigtimedwait
"sigset %p info %p, timespec %p", // sigtimedwait
"sigset %p\n" // sigpending
};
#endif
+14
View File
@@ -0,0 +1,14 @@
#include <kernel/syscalls.h>
#include <kernel/signal.h>
#include <logging.h>
syscallret_t syscall_sigpending(context_t *, sigset_t *uset) {
syscallret_t ret;
sigset_t set;
signal_pending(_cpu()->thread, &set);
ret.errno = usercopy_touser(uset, &set, sizeof(sigset_t));
ret.ret = ret.errno ? -1 : 0;
return ret;
}
+10 -4
View File
@@ -221,10 +221,10 @@ index 0000000..e5b087a
+
diff --git mlibc-workdir/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
new file mode 100644
index 0000000..f8c16e7
index 0000000..1ce2424
--- /dev/null
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
@@ -0,0 +1,997 @@
@@ -0,0 +1,1002 @@
+#include <bits/ensure.h>
+#include <mlibc/debug.hpp>
+#include <mlibc/all-sysdeps.hpp>
@@ -299,6 +299,11 @@ index 0000000..f8c16e7
+ return 0;
+ }
+
+ int sys_sigpending(sigset_t *set) {
+ long ret;
+ return syscall(SYSCALL_SIGPENDING, &ret, (uint64_t)set);
+ }
+
+ int sys_sigtimedwait(const sigset_t *__restrict set, siginfo_t *__restrict info, const struct timespec *__restrict timeout, int *out_signal) {
+ long ret;
+ long err = syscall(SYSCALL_SIGTIMEDWAIT, &ret, (uint64_t)set, (uint64_t)info, (uint64_t)timeout);
@@ -1241,10 +1246,10 @@ index 0000000..990eca0
+#endif
diff --git mlibc-workdir/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
new file mode 100644
index 0000000..11376a2
index 0000000..058d486
--- /dev/null
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
@@ -0,0 +1,113 @@
@@ -0,0 +1,114 @@
+#ifndef _SYSCALL_H_INCLUDE
+#define _SYSCALL_H_INCLUDE
+
@@ -1338,6 +1343,7 @@ index 0000000..11376a2
+#define SYSCALL_SETEGID 87
+#define SYSCALL_SIGSUSPEND 88
+#define SYSCALL_SIGTIMEDWAIT 89
+#define SYSCALL_SIGPENDING 90
+
+#include <stddef.h>
+#include <stdint.h>