]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Add sigisempty, sigorset, and sigandset
authorUlrich Drepper <drepper@redhat.com>
Fri, 4 Apr 1997 15:34:33 +0000 (15:34 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 4 Apr 1997 15:34:33 +0000 (15:34 +0000)
signal/Makefile
signal/sigandset.c [new file with mode: 0644]
signal/sigisempty.c [new file with mode: 0644]
signal/signal.h
signal/sigorset.c [new file with mode: 0644]
sysdeps/generic/sigset.h
sysdeps/unix/sysv/linux/sigset.h

index 2d99437208055b177bb0e1e771bb60e8bb599ab8..a8e26ed2397fc81e8592876a7bec91d8cea95f6f 100644 (file)
@@ -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 (file)
index 0000000..bb3747c
--- /dev/null
@@ -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 (file)
index 0000000..50dc343
--- /dev/null
@@ -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);
+}
index b1953e51332d1a88db1ea8f2eea1621e70822d1e..df54e7940d4ce054861b167f94701319dd29d016 100644 (file)
@@ -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 (file)
index 0000000..e8ae22f
--- /dev/null
@@ -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);
+}
index a137d428c3198868ba1c2566c89dd542694d4880..6f4ea0e5a82d2101660389db3ccfb7eb63a870b9 100644 (file)
@@ -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.  */
 
index 752d13adffdeb903a81d03ed5a0f67683ac70ade..741ff9ac9d9e847be3a06fd34d963d2abea85cfa 100644 (file)
@@ -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