add sigandset and sigorset (needed for qemu)
authorrofl0r <retnyg@gmx.net>
Thu, 6 Dec 2012 19:51:32 +0000 (20:51 +0100)
committerrofl0r <retnyg@gmx.net>
Thu, 6 Dec 2012 19:51:32 +0000 (20:51 +0100)
include/signal.h
src/signal/sigandset.c [new file with mode: 0644]
src/signal/sigorset.c [new file with mode: 0644]

index b24f43a5c57c721f40631192872a7f4b2d445ac9..b8ba1b5a536a30a3dc6726b3d48aa58c8ffbcdb5 100644 (file)
@@ -220,6 +220,9 @@ typedef void (*sig_t)(int);
 typedef void (*sighandler_t)(int);
 void (*bsd_signal(int, void (*)(int)))(int);
 int sigisemptyset(const sigset_t *);
+int sigorset (sigset_t *, sigset_t *, sigset_t *);
+int sigandset(sigset_t *, sigset_t *, sigset_t *);
+
 #define SA_NOMASK SA_NODEFER
 #define SA_ONESHOT SA_RESETHAND
 #endif
diff --git a/src/signal/sigandset.c b/src/signal/sigandset.c
new file mode 100644 (file)
index 0000000..f62c7fe
--- /dev/null
@@ -0,0 +1,17 @@
+#define _GNU_SOURCE
+#include <signal.h>
+#include <errno.h>
+
+#define SST_SIZE (sizeof(sigset_t) / sizeof(long))
+
+int sigandset(sigset_t *dest, sigset_t *left, sigset_t *right)
+{
+       if(!dest || !left || !right) {
+               errno = EINVAL;
+               return -1;
+       }
+       unsigned long i = 0, *d = (void*) dest, *l = (void*) left, *r = (void*) right;
+       for(; i < SST_SIZE; i++) d[i] = l[i] & r[i];
+       return 0;
+}
+
diff --git a/src/signal/sigorset.c b/src/signal/sigorset.c
new file mode 100644 (file)
index 0000000..232075b
--- /dev/null
@@ -0,0 +1,17 @@
+#define _GNU_SOURCE
+#include <signal.h>
+#include <errno.h>
+
+#define SST_SIZE (sizeof(sigset_t) / sizeof(long))
+
+int sigorset(sigset_t *dest, sigset_t *left, sigset_t *right)
+{
+       if(!dest || !left || !right) {
+               errno = EINVAL;
+               return -1;
+       }
+       unsigned long i = 0, *d = (void*) dest, *l = (void*) left, *r = (void*) right;
+       for(; i < SST_SIZE; i++) d[i] = l[i] | r[i];
+       return 0;
+}
+