mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
syscalls: sigtimedwait
This commit is contained in:
@@ -88,6 +88,7 @@ extern syscall_seteuid
|
|||||||
extern syscall_setgid
|
extern syscall_setgid
|
||||||
extern syscall_setegid
|
extern syscall_setegid
|
||||||
extern syscall_sigsuspend
|
extern syscall_sigsuspend
|
||||||
|
extern syscall_sigtimedwait
|
||||||
syscalltab:
|
syscalltab:
|
||||||
dq syscall_print
|
dq syscall_print
|
||||||
dq syscall_mmap
|
dq syscall_mmap
|
||||||
@@ -178,7 +179,8 @@ dq syscall_seteuid
|
|||||||
dq syscall_setgid
|
dq syscall_setgid
|
||||||
dq syscall_setegid
|
dq syscall_setegid
|
||||||
dq syscall_sigsuspend
|
dq syscall_sigsuspend
|
||||||
syscallcount equ 89
|
dq syscall_sigtimedwait
|
||||||
|
syscallcount equ 90
|
||||||
section .text
|
section .text
|
||||||
global arch_syscall_entry
|
global arch_syscall_entry
|
||||||
; on entry:
|
; on entry:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#ifdef SYSCALL_LOGGING
|
#ifdef SYSCALL_LOGGING
|
||||||
|
|
||||||
#define SYSCALL_COUNT 89
|
#define SYSCALL_COUNT 90
|
||||||
#define LOGSTR(x) arch_e9_puts(x)
|
#define LOGSTR(x) arch_e9_puts(x)
|
||||||
|
|
||||||
static char *name[] = {
|
static char *name[] = {
|
||||||
@@ -97,7 +97,8 @@ static char *name[] = {
|
|||||||
"seteuid",
|
"seteuid",
|
||||||
"setgid",
|
"setgid",
|
||||||
"setegid",
|
"setegid",
|
||||||
"sigsuspend"
|
"sigsuspend",
|
||||||
|
"sigtimedwait"
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *args[] = {
|
static char *args[] = {
|
||||||
@@ -189,7 +190,8 @@ static char *args[] = {
|
|||||||
"euid %d", // seteuid
|
"euid %d", // seteuid
|
||||||
"gid %d", // setgid
|
"gid %d", // setgid
|
||||||
"egid %d", // setegid
|
"egid %d", // setegid
|
||||||
"sigset %p" // sigsuspend
|
"sigset %p", // sigsuspend
|
||||||
|
"set %p info %p, timespec %p" // sigtimedwait
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#include <kernel/syscalls.h>
|
||||||
|
#include <kernel/signal.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <logging.h>
|
||||||
|
|
||||||
|
syscallret_t syscall_sigtimedwait(context_t *, sigset_t *uset, siginfo_t *uinfo, timespec_t *utimeout) {
|
||||||
|
syscallret_t ret = {
|
||||||
|
.ret = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
sigset_t set;
|
||||||
|
timespec_t timeout;
|
||||||
|
siginfo_t info;
|
||||||
|
int signum;
|
||||||
|
|
||||||
|
ret.errno = usercopy_fromuser(&set, uset, sizeof(sigset_t));
|
||||||
|
if (ret.errno)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret.errno = usercopy_fromuser(&timeout, utimeout, sizeof(timespec_t));
|
||||||
|
if (ret.errno)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret.errno = signal_wait(&set, &timeout, &info, &signum);
|
||||||
|
if (ret.errno)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
if (uinfo)
|
||||||
|
ret.errno = usercopy_touser(uinfo, &info, sizeof(siginfo_t));
|
||||||
|
|
||||||
|
ret.ret = ret.errno ? -1 : 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
@@ -219,10 +219,10 @@ index 0000000..e5b087a
|
|||||||
+
|
+
|
||||||
diff --git mlibc-workdir/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
diff --git mlibc-workdir/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..32711c2
|
index 0000000..f8c16e7
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||||
@@ -0,0 +1,990 @@
|
@@ -0,0 +1,997 @@
|
||||||
+#include <bits/ensure.h>
|
+#include <bits/ensure.h>
|
||||||
+#include <mlibc/debug.hpp>
|
+#include <mlibc/debug.hpp>
|
||||||
+#include <mlibc/all-sysdeps.hpp>
|
+#include <mlibc/all-sysdeps.hpp>
|
||||||
@@ -297,6 +297,13 @@ index 0000000..32711c2
|
|||||||
+ return 0;
|
+ return 0;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ 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);
|
||||||
|
+ *out_signal = ret;
|
||||||
|
+ return err;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ int sys_sigsuspend(const sigset_t *set) {
|
+ int sys_sigsuspend(const sigset_t *set) {
|
||||||
+ long ret;
|
+ long ret;
|
||||||
+ return syscall(SYSCALL_SIGSUSPEND, &ret, (uint64_t)set);
|
+ return syscall(SYSCALL_SIGSUSPEND, &ret, (uint64_t)set);
|
||||||
@@ -1232,10 +1239,10 @@ index 0000000..990eca0
|
|||||||
+#endif
|
+#endif
|
||||||
diff --git mlibc-workdir/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
diff --git mlibc-workdir/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..7772e74
|
index 0000000..11376a2
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||||
@@ -0,0 +1,112 @@
|
@@ -0,0 +1,113 @@
|
||||||
+#ifndef _SYSCALL_H_INCLUDE
|
+#ifndef _SYSCALL_H_INCLUDE
|
||||||
+#define _SYSCALL_H_INCLUDE
|
+#define _SYSCALL_H_INCLUDE
|
||||||
+
|
+
|
||||||
@@ -1328,6 +1335,7 @@ index 0000000..7772e74
|
|||||||
+#define SYSCALL_SETGID 86
|
+#define SYSCALL_SETGID 86
|
||||||
+#define SYSCALL_SETEGID 87
|
+#define SYSCALL_SETEGID 87
|
||||||
+#define SYSCALL_SIGSUSPEND 88
|
+#define SYSCALL_SIGSUSPEND 88
|
||||||
|
+#define SYSCALL_SIGTIMEDWAIT 89
|
||||||
+
|
+
|
||||||
+#include <stddef.h>
|
+#include <stddef.h>
|
||||||
+#include <stdint.h>
|
+#include <stdint.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user