diff options
author | Ulrich Drepper <drepper@redhat.com> | 1997-04-04 15:34:33 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1997-04-04 15:34:33 +0000 |
commit | b0b60fc2f1e1c9a778ce9142771945a9d9f0c705 (patch) | |
tree | 6883765c03e049ff4c708515b26bdf01b167f78a | |
parent | 6a11e51e2c560d592d60298b24c48e82f8cb9653 (diff) |
Add sigisempty, sigorset, and sigandset
-rw-r--r-- | signal/Makefile | 3 | ||||
-rw-r--r-- | signal/sigandset.c | 36 | ||||
-rw-r--r-- | signal/sigisempty.c | 34 | ||||
-rw-r--r-- | signal/signal.h | 13 | ||||
-rw-r--r-- | signal/sigorset.c | 36 | ||||
-rw-r--r-- | sysdeps/generic/sigset.h | 10 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sigset.h | 35 |
7 files changed, 163 insertions, 4 deletions
diff --git a/signal/Makefile b/signal/Makefile index 2d99437208..a8e26ed239 100644 --- a/signal/Makefile +++ b/signal/Makefile @@ -30,7 +30,8 @@ routines := signal raise killpg \ sigstack sigaltstack sigintr \ sigsetops sigempty sigfillset sigaddset sigdelset sigismem \ sigreturn \ - siggetmask sysv_signal + siggetmask sysv_signal \ + sigisempty sigandset sigorset tests := tst-signal diff --git a/signal/sigandset.c b/signal/sigandset.c new file mode 100644 index 0000000000..bb3747c19d --- /dev/null +++ b/signal/sigandset.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1991, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <signal.h> + +/* Combine sets LEFT and RIGHT by logical AND and place result in DEST. */ +int +sigandset (dest, left, right) + sigset_t *dest; + const sigset_t *left; + const sigset_t *right; +{ + if (dest == NULL || left == NULL || right == NULL) + { + __set_errno (EINVAL); + return -1; + } + + return __sigandset (dest, left, right); +} diff --git a/signal/sigisempty.c b/signal/sigisempty.c new file mode 100644 index 0000000000..50dc343491 --- /dev/null +++ b/signal/sigisempty.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <signal.h> + +/* Test whether SET is empty. */ +int +sigisemptyset (set) + const sigset_t *set; +{ + if (set == NULL) + { + __set_errno (EINVAL); + return -1; + } + + return __sigisemptyset (set); +} diff --git a/signal/signal.h b/signal/signal.h index b1953e5133..df54e7940d 100644 --- a/signal/signal.h +++ b/signal/signal.h @@ -183,6 +183,19 @@ extern int sigdelset __P ((sigset_t *__set, int __signo)); /* Return 1 if SIGNO is in SET, 0 if not. */ extern int sigismember __P ((__const sigset_t *__set, int __signo)); +#ifdef __USE_GNU +/* Return non-empty value is SET is not empty. */ +extern int sigisemptyset __P ((__const sigset_t *__set)); + +/* Build new signal set by combining the two inputs set using logical AND. */ +extern int sigandset __P ((sigset_t *__set, __const sigset_t *__left, + __const sigset_t *__right)); + +/* Build new signal set by combining the two inputs set using logical OR. */ +extern int sigorset __P ((sigset_t *__set, __const sigset_t *__left, + __const sigset_t *__right)); +#endif /* GNU */ + /* Get the system-specific definitions of `struct sigaction' and the `SA_*' and `SIG_*'. constants. */ #include <sigaction.h> diff --git a/signal/sigorset.c b/signal/sigorset.c new file mode 100644 index 0000000000..e8ae22fd5a --- /dev/null +++ b/signal/sigorset.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1991, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <signal.h> + +/* Combine sets LEFT and RIGHT by logical OR and place result in DEST. */ +int +sigorset (dest, left, right) + sigset_t *dest; + const sigset_t *left; + const sigset_t *right; +{ + if (dest == NULL || left == NULL || right == NULL) + { + __set_errno (EINVAL); + return -1; + } + + return __sigorset (dest, left, right); +} diff --git a/sysdeps/generic/sigset.h b/sysdeps/generic/sigset.h index a137d428c3..6f4ea0e5a8 100644 --- a/sysdeps/generic/sigset.h +++ b/sysdeps/generic/sigset.h @@ -1,5 +1,5 @@ /* __sig_atomic_t, __sigset_t, and related definitions. Generic/BSD version. - Copyright (C) 1991, 1992, 1994, 1996 Free Software Foundation, Inc. + Copyright (C) 1991, 1992, 1994, 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -48,6 +48,14 @@ typedef unsigned long int __sigset_t; #define __sigemptyset(set) ((*(set) = (__sigset_t) 0), 0) #define __sigfillset(set) ((*(set) = ~(__sigset_t) 0), 0) +#ifdef _GNU_SOURCE +# define __sigisemptyset(set) (*(set) == (__sigset_t) 0) +# define __sigandset(dest, left, right) \ + ((*(set) = (*(left) & *(right))), 0) +# define __sigorset(dest, left, right) \ + ((*(set) = (*(left) | *(right))), 0) +#endif + /* These functions needn't check for a bogus signal number -- error checking is done in the non __ versions. */ diff --git a/sysdeps/unix/sysv/linux/sigset.h b/sysdeps/unix/sysv/linux/sigset.h index 752d13adff..741ff9ac9d 100644 --- a/sysdeps/unix/sysv/linux/sigset.h +++ b/sysdeps/unix/sysv/linux/sigset.h @@ -54,16 +54,47 @@ typedef struct #define __sigword(sig) (((sig) - 1) / (8 * sizeof (unsigned long int))) #if defined __GNUC__ && __GNUC__ >= 2 -#define __sigemptyset(set) \ +# define __sigemptyset(set) \ (__extension__ ({ int __cnt = _SIGSET_NWORDS; \ sigset_t *__set = (set); \ while (--__cnt >= 0) __set->__val[__cnt] = 0; \ 0; })) -#define __sigfillset(set) \ +# define __sigfillset(set) \ (__extension__ ({ int __cnt = _SIGSET_NWORDS; \ sigset_t *__set = (set); \ while (--__cnt >= 0) __set->__val[__cnt] = ~0UL; \ 0; })) + +# ifdef _GNU_SOURCE +/* The POSIX does not specify for handling the whole signal set in one + command. This is often wanted and so we define three more functions + here. */ +# define __sigisemptyset(set) \ + (__extension__ ({ int __cnt = _SIGSET_NWORDS; \ + const sigset_t *__set = (set); \ + int __ret = __set->__val[--__cnt]; \ + while (!__ret && --__cnt >= 0) \ + __ret = __set->__val[__cnt]; \ + __ret == 0; })) +# define __sigandset(dest, left, right) \ + (__extension__ ({ int __cnt = _SIGSET_NWORDS; \ + sigset_t *__dest = (dest); \ + const sigset_t *__left = (left); \ + const sigset_t *__right = (right); \ + while (--__cnt >= 0) \ + __dest->__val[__cnt] = (__left->__val[__cnt] \ + & __right->__val[__cnt]); \ + 0; })) +# define __sigorset(dest, left, right) \ + (__extension__ ({ int __cnt = _SIGSET_NWORDS; \ + sigset_t *__dest = (dest); \ + const sigset_t *__left = (left); \ + const sigset_t *__right = (right); \ + while (--__cnt >= 0) \ + __dest->__val[__cnt] = (__left->__val[__cnt] \ + | __right->__val[__cnt]); \ + 0; })) +# endif #endif /* These functions needn't check for a bogus signal number -- error |