BarryServer : Git

All the code for all my projects
// BarryServer : Git / OrionLibC / commit / fd1ac463b480044ea9b8ae4fa3f56a73b00e2ed3 / signal / sigsetops.c

// Related

OrionLibC

Barry Adding more signal functions fd1ac46 (2 years, 2 months ago)
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)));
+}