BarryServer : Git

All the code for all my projects
// BarryServer : Git / OrionLibC / commit / fd1ac463b480044ea9b8ae4fa3f56a73b00e2ed3

// Related

OrionLibC

Barry Adding more signal functions fd1ac46 (2 years, 2 months ago)
diff --git a/include/signal.h b/include/signal.h
index 84535e8..b355567 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -40,6 +40,11 @@ int tgkill(pid_t tgid, pid_t tid, int sig);
 int kill(pid_t pid, int sig);
 sighandler_t signal(int signum, sighandler_t handler);
 int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
+int sigemptyset(sigset_t *set);
+int sigfillset(sigset_t *set);
+int sigaddset(sigset_t *set, int signum);
+int sigdelset(sigset_t *set, int signum);
+int sigismember(const sigset_t *set, int signum);
 
 #ifdef __cplusplus
 }
diff --git a/signal/sigsetops.c b/signal/sigsetops.c
new file mode 100644
index 0000000..08cf870
--- /dev/null
+++ b/signal/sigsetops.c
@@ -0,0 +1,53 @@
+#include <signal.h>
+#include <errno.h>
+
+/* Empty a signal set */
+int
+sigemptyset(sigset_t *set)
+{
+	*set = 0;
+	return 0;
+}
+
+/* Fill a signal set */
+int
+sigfillset(sigset_t *set)
+{
+	*set = 0xFFFFFFFF;
+	return 0;
+}
+
+/* Add a signal to a signal set */
+int
+sigaddset(sigset_t *set, int signum)
+{
+	if (signum < 0 || signum >= 32) {
+		errno = EINVAL;
+		return -1;
+	}
+	*set |= (1 << (signum - 1));
+	return 0;
+}
+
+/* Remove a signal from a signal set */
+int
+sigdelset(sigset_t *set, int signum)
+{
+	if (signum < 0 || signum >= 32) {
+		errno = EINVAL;
+		return -1;
+	}
+	*set &= ~(1 << (signum - 1));
+	return 0;
+}
+
+/* Check if a signal is in a signal set */
+int
+sigismember(const sigset_t *set, int signum)
+{
+	if (signum < 0 || signum >= 32) {
+		errno = EINVAL;
+		return -1;
+	}
+	return (*set & (1 << (signum - 1)));
+}