summaryrefslogtreecommitdiff
path: root/src/signal
diff options
context:
space:
mode:
Diffstat (limited to 'src/signal')
-rw-r--r--src/signal/sigaddset.c7
-rw-r--r--src/signal/sigdelset.c7
-rw-r--r--src/signal/sigemptyset.c3
-rw-r--r--src/signal/sigfillset.c4
-rw-r--r--src/signal/sigismember.c9
5 files changed, 25 insertions, 5 deletions
diff --git a/src/signal/sigaddset.c b/src/signal/sigaddset.c
index 81b408f3..fae413e1 100644
--- a/src/signal/sigaddset.c
+++ b/src/signal/sigaddset.c
@@ -1,9 +1,14 @@
#include "sys/types.h"
#include <signal.h>
+#include "limits.h"
int sigaddset(sigset_t * set, int signo)
{
- (void)set; (void)signo;
+ /* TODO: fail with EINVAL if signo is not a valid signal number */
+ size_t byte = signo % CHAR_BIT;
+ int bit = signo / CHAR_BIT;
+
+ set->__bits[byte] |= (1 << bit);
return 0;
}
/*
diff --git a/src/signal/sigdelset.c b/src/signal/sigdelset.c
index ca20cc43..bcd0d716 100644
--- a/src/signal/sigdelset.c
+++ b/src/signal/sigdelset.c
@@ -1,9 +1,14 @@
#include "sys/types.h"
#include <signal.h>
+#include "limits.h"
int sigdelset(sigset_t * set, int signo)
{
- (void)set; (void)signo;
+ /* TODO: fail with EINVAL if signo is not a valid signal number */
+ size_t byte = signo % CHAR_BIT;
+ int bit = signo / CHAR_BIT;
+
+ set->__bits[byte] ^= (1 << bit);
return 0;
}
/*
diff --git a/src/signal/sigemptyset.c b/src/signal/sigemptyset.c
index 2f579579..d09ff500 100644
--- a/src/signal/sigemptyset.c
+++ b/src/signal/sigemptyset.c
@@ -1,9 +1,10 @@
#include "sys/types.h"
#include <signal.h>
+#include "string.h"
int sigemptyset(sigset_t * set)
{
- (void)set;
+ memset(set, 0, sizeof(*set));
return 0;
}
/*
diff --git a/src/signal/sigfillset.c b/src/signal/sigfillset.c
index 4530e42a..493912b3 100644
--- a/src/signal/sigfillset.c
+++ b/src/signal/sigfillset.c
@@ -1,9 +1,11 @@
#include "sys/types.h"
#include <signal.h>
+#include "string.h"
+#include "limits.h"
int sigfillset(sigset_t * set)
{
- (void)set;
+ memset(set, UCHAR_MAX, sizeof(*set));
return 0;
}
/*
diff --git a/src/signal/sigismember.c b/src/signal/sigismember.c
index 5e21cb5c..6d3c1512 100644
--- a/src/signal/sigismember.c
+++ b/src/signal/sigismember.c
@@ -1,9 +1,16 @@
#include "sys/types.h"
#include <signal.h>
+#include "limits.h"
int sigismember(const sigset_t * set, int signo)
{
- (void)set; (void)signo;
+ /* TODO: fail with EINVAL if signo is not a valid signal number */
+
+ size_t byte = signo % CHAR_BIT;
+ int bit = signo / CHAR_BIT;
+ if (set->__bits[byte] & (1 << bit)) {
+ return 1;
+ }
return 0;
}
/*