From a1990e1e833624b26b0ca55aa7fce56bb594f814 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Thu, 6 Dec 2012 20:51:32 +0100 Subject: [PATCH] add sigandset and sigorset (needed for qemu) --- include/signal.h | 3 +++ src/signal/sigandset.c | 17 +++++++++++++++++ src/signal/sigorset.c | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 src/signal/sigandset.c create mode 100644 src/signal/sigorset.c diff --git a/include/signal.h b/include/signal.h index b24f43a5..b8ba1b5a 100644 --- a/include/signal.h +++ b/include/signal.h @@ -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 index 00000000..f62c7fec --- /dev/null +++ b/src/signal/sigandset.c @@ -0,0 +1,17 @@ +#define _GNU_SOURCE +#include +#include + +#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 index 00000000..232075b1 --- /dev/null +++ b/src/signal/sigorset.c @@ -0,0 +1,17 @@ +#define _GNU_SOURCE +#include +#include + +#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; +} + -- 2.25.1