1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:17:35 +00:00

Add sigset_t helper functions to LibC.

This commit is contained in:
Andreas Kling 2018-11-06 12:02:58 +01:00
parent 153ea704af
commit 46f0c28a4a
2 changed files with 48 additions and 1 deletions

View file

@ -28,5 +28,47 @@ int sigaction(int signum, const struct sigaction* act, struct sigaction* 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 - 1);
return 0;
}
int sigdelset(sigset_t* set, int sig)
{
if (sig < 1 || sig > 32) {
errno = EINVAL;
return -1;
}
*set &= ~(1 << (sig - 1));
return 0;
}
int sigismember(const sigset_t* set, int sig)
{
if (sig < 1 || sig > 32) {
errno = EINVAL;
return -1;
}
if (*set & (1 << (sig - 1)))
return 1;
return 0;
}
}

View file

@ -22,7 +22,12 @@ struct sigaction {
int kill(pid_t, int sig);
sighandler_t signal(int sig, sighandler_t);
int sigaction(int signum, const struct sigaction* act, struct sigaction* old_act);
int sigaction(int sig, const struct sigaction* act, struct sigaction* old_act);
int sigemptyset(sigset_t*);
int sigfillset(sigset_t*);
int sigaddset(sigset_t*, int sig);
int sigdelset(sigset_t*, int sig);
int sigismember(const sigset_t*, int sig);
#define SIG_DFL ((__sighandler_t)0)
#define SIG_ERR ((__sighandler_t)-1)