mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 17:52:26 -05:00
3a0a8848fb
Old: Syscall::invoke(Syscall::SC_foo, (dword)arg1, (dword)arg2) New: syscall(SC_foo, arg1, arg2)
103 lines
1.9 KiB
C++
103 lines
1.9 KiB
C++
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include <signal.h>
|
|
#include <stdio.h>
|
|
#include <Kernel/Syscall.h>
|
|
|
|
extern "C" {
|
|
|
|
int kill(pid_t pid, int sig)
|
|
{
|
|
int rc = syscall(SC_kill, pid, sig);
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
}
|
|
|
|
int killpg(int pgrp, int sig)
|
|
{
|
|
int rc = syscall(SC_killpg, pgrp, sig);
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
}
|
|
|
|
sighandler_t signal(int signum, sighandler_t handler)
|
|
{
|
|
struct sigaction new_act;
|
|
struct sigaction old_act;
|
|
new_act.sa_handler = handler;
|
|
new_act.sa_flags = 0;
|
|
new_act.sa_mask = 0;
|
|
new_act.sa_restorer = nullptr;
|
|
int rc = sigaction(signum, &new_act, &old_act);
|
|
if (rc < 0)
|
|
return SIG_ERR;
|
|
return old_act.sa_handler;
|
|
}
|
|
|
|
int sigaction(int signum, const struct sigaction* act, struct sigaction* old_act)
|
|
{
|
|
int rc = syscall(SC_sigaction, signum, act, old_act);
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
}
|
|
|
|
int sigemptyset(sigset_t* set)
|
|
{
|
|
*set = 0;
|
|
return 0;
|
|
}
|
|
|
|
int sigfillset(sigset_t* set)
|
|
{
|
|
*set = 0xffffffff;
|
|
return 0;
|
|
}
|
|
|
|
int sigaddset(sigset_t* set, int sig)
|
|
{
|
|
if (sig < 1 || sig > 32) {
|
|
errno = EINVAL;
|
|
return -1;
|
|
}
|
|
*set |= 1 << (sig);
|
|
return 0;
|
|
}
|
|
|
|
int sigdelset(sigset_t* set, int sig)
|
|
{
|
|
if (sig < 1 || sig > 32) {
|
|
errno = EINVAL;
|
|
return -1;
|
|
}
|
|
*set &= ~(1 << (sig));
|
|
return 0;
|
|
}
|
|
|
|
int sigismember(const sigset_t* set, int sig)
|
|
{
|
|
if (sig < 1 || sig > 32) {
|
|
errno = EINVAL;
|
|
return -1;
|
|
}
|
|
if (*set & (1 << (sig)))
|
|
return 1;
|
|
return 0;
|
|
}
|
|
|
|
int sigprocmask(int how, const sigset_t* set, sigset_t* old_set)
|
|
{
|
|
int rc = syscall(SC_sigprocmask, how, set, old_set);
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
}
|
|
|
|
int sigpending(sigset_t* set)
|
|
{
|
|
int rc = syscall(SC_sigpending, set);
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
}
|
|
|
|
const char* sys_siglist[NSIG] = {
|
|
#undef __SIGNAL
|
|
#define __SIGNAL(a, b) b,
|
|
__ENUMERATE_ALL_SIGNALS
|
|
#undef __SIGNAL
|
|
};
|
|
|
|
}
|