aboutsummaryrefslogtreecommitdiff
path: root/signal
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2016-12-01 19:24:13 -0500
committerZack Weinberg <zackw@panix.com>2017-05-20 19:04:43 -0400
commita992f506ff7162da2afa5a6151cc6f15949ceef4 (patch)
tree93ed5242c166dde96fd0ec244801d9f5fdaca86a /signal
parent500b3a499fff61157db464a99f459c772d7eb6c0 (diff)
downloadglibc-a992f506ff7162da2afa5a6151cc6f15949ceef4.tar
glibc-a992f506ff7162da2afa5a6151cc6f15949ceef4.tar.gz
glibc-a992f506ff7162da2afa5a6151cc6f15949ceef4.tar.bz2
glibc-a992f506ff7162da2afa5a6151cc6f15949ceef4.zip
Remove __need macros from signal.h.
The types affected are __sig_atomic_t, sig_atomic_t, __sigset_t, sigset_t, sigval_t, sigevent_t, and siginfo_t. __sig_atomic_t is a scalar, so it's now directly available from bits/types.h. The others get bits/types/ headers. Side effects include: There have been small changes to which non-signal headers expose which subset of the signal-related types. A couple of architectures' nested siginfo_t fields had to be renamed to prevent undesired macro expansion. Internal code that wants to manipulate signal masks must now include <sigsetops.h> (which is not installed) and should be aware that __sigaddset, __sigandset, __sigdelset, __sigemptyset, and __sigorset no longer return a value (unlike the public API). Relatedly, the public signal.h no longer declares any of those functions. The obsolete sigmask() macro no longer has a system-specific definition -- in the cases where it matters, it didn't work anyway. New Linux architectures should create bits/siginfo-arch.h and/or bits/siginfo-consts-arch.h to customize their siginfo_t, rather than duplicating everything in bits/siginfo.h (which no longer exists). Add new __SI_* macros if necessary. Ports to other operating systems are strongly encouraged to generalize this scheme further. * bits/sigevent-consts.h * bits/siginfo-consts.h * bits/types/__sigset_t.h * bits/types/sigevent_t.h * bits/types/siginfo_t.h * sysdeps/unix/sysv/linux/bits/sigevent-consts.h * sysdeps/unix/sysv/linux/bits/siginfo-consts.h * sysdeps/unix/sysv/linux/bits/types/__sigset_t.h * sysdeps/unix/sysv/linux/bits/types/sigevent_t.h * sysdeps/unix/sysv/linux/bits/types/siginfo_t.h: New system-dependent bits headers. * sysdeps/unix/sysv/linux/bits/siginfo-arch.h * sysdeps/unix/sysv/linux/bits/siginfo-consts-arch.h * sysdeps/unix/sysv/linux/ia64/bits/siginfo-arch.h * sysdeps/unix/sysv/linux/ia64/bits/siginfo-consts-arch.h * sysdeps/unix/sysv/linux/mips/bits/siginfo-arch.h * sysdeps/unix/sysv/linux/sparc/bits/siginfo-arch.h * sysdeps/unix/sysv/linux/tile/bits/siginfo-arch.h * sysdeps/unix/sysv/linux/tile/bits/siginfo-consts-arch.h * sysdeps/unix/sysv/linux/x86/bits/siginfo-arch.h: New Linux-only system-dependent bits headers. * signal/bits/types/sig_atomic_t.h * signal/bits/types/sigset_t.h * signal/bits/types/sigval_t.h: New non-system-dependent bits headers. * sysdeps/generic/sigsetops.h * sysdeps/unix/sysv/linux/sigsetops.h: New internal headers. * include/bits/types/sig_atomic_t.h * include/bits/types/sigset_t.h * include/bits/types/sigval_t.h: New wrappers. * signal/sigsetops.h * bits/siginfo.h * bits/sigset.h * sysdeps/unix/sysv/linux/bits/siginfo.h * sysdeps/unix/sysv/linux/bits/sigset.h * sysdeps/unix/sysv/linux/ia64/bits/siginfo.h * sysdeps/unix/sysv/linux/mips/bits/siginfo.h * sysdeps/unix/sysv/linux/s390/bits/siginfo.h * sysdeps/unix/sysv/linux/sparc/bits/siginfo.h * sysdeps/unix/sysv/linux/tile/bits/siginfo.h * sysdeps/unix/sysv/linux/x86/bits/siginfo.h: Deleted. * signal/Makefile, sysdeps/unix/sysv/linux/Makefile: Update lists of installed headers. * posix/bits/types.h: Define __sig_atomic_t here. * signal/signal.h: Use the new bits headers; no need to handle __need_sig_atomic_t nor __need_sigset_t. Don't use __sigmask to define sigmask. * include/signal.h: No need to handle __need_sig_atomic_t nor __need_sigset_t. Don't define __sigemptyset. * io/sys/poll.h, setjmp/setjmp.h * sysdeps/arm/sys/ucontext.h, sysdeps/generic/sys/ucontext.h * sysdeps/i386/sys/ucontext.h, sysdeps/m68k/sys/ucontext.h * sysdeps/mach/hurd/i386/bits/sigcontext.h * sysdeps/mips/sys/ucontext.h, sysdeps/powerpc/novmxsetjmp.h * sysdeps/pthread/bits/sigthread.h * sysdeps/unix/sysv/linux/hppa/sys/ucontext.h * sysdeps/unix/sysv/linux/m68k/sys/ucontext.h * sysdeps/unix/sysv/linux/mips/sys/ucontext.h * sysdeps/unix/sysv/linux/nios2/sys/ucontext.h * sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h * sysdeps/unix/sysv/linux/s390/sys/ucontext.h * sysdeps/unix/sysv/linux/sh/sys/ucontext.h * sysdeps/unix/sysv/linux/sparc/sys/ucontext.h * sysdeps/unix/sysv/linux/tile/sys/ucontext.h * sysdeps/unix/sysv/linux/x86/sys/ucontext.h: Use bits/types/__sigset_t.h. * misc/sys/select.h, posix/spawn.h * sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h * sysdeps/unix/sysv/linux/sys/epoll.h * sysdeps/unix/sysv/linux/sys/signalfd.h: Use bits/types/sigset_t.h. * resolv/netdb.h, rt/mqueue.h: Use bits/types/sigevent_t.h. * rt/aio.h: Use bits/types/sigevent_t.h and bits/sigevent-consts.h. * socket/sys/socket.h: Don't include bits/sigset.h. * login/utmp_file.c, shadow/lckpwdf.c, signal/sigandset.c * signal/sigisempty.c, stdlib/abort.c, sysdeps/posix/profil.c * sysdeps/posix/sigignore.c, sysdeps/posix/sigintr.c * sysdeps/posix/signal.c, sysdeps/posix/sigset.c * sysdeps/posix/sprofil.c, sysdeps/posix/sysv_signal.c * sysdeps/unix/sysv/linux/nptl-signals.h: Include sigsetops.h. * signal/sigaddset.c, signal/sigandset.c, signal/sigdelset.c * signal/sigorset.c, stdlib/abort.c, sysdeps/posix/sigignore.c * sysdeps/posix/signal.c, sysdeps/posix/sigset.c: __sigaddset, __sigandset, __sigdelset, __sigemptyset, __sigorset now return no value. * signal/sigaddset.c, signal/sigdelset.c, signal/sigismem.c Include <errno.h>, <signal.h>, and <sigsetops.h> instead of "sigsetops.h". * signal/sigsetops.c: Explicitly define __sigismember, __sigaddset, and __sigdelset as compatibility symbols. * signal/Versions: Correct commentary on __sigpause, __sigaddset, __sigdelset, __sigismember. * inet/rcmd.c: Include sigsetops.h. Convert old code using __sigblock/__sigsetmask to use __sigprocmask and friends.
Diffstat (limited to 'signal')
-rw-r--r--signal/Makefile12
-rw-r--r--signal/Versions8
-rw-r--r--signal/bits/types/sig_atomic_t.h10
-rw-r--r--signal/bits/types/sigset_t.h9
-rw-r--r--signal/bits/types/sigval_t.h13
-rw-r--r--signal/sigaddset.c7
-rw-r--r--signal/sigandset.c8
-rw-r--r--signal/sigdelset.c7
-rw-r--r--signal/sigisempty.c7
-rw-r--r--signal/sigismem.c4
-rw-r--r--signal/signal.h41
-rw-r--r--signal/sigorset.c8
-rw-r--r--signal/sigsetops.c58
-rw-r--r--signal/sigsetops.h32
14 files changed, 129 insertions, 95 deletions
diff --git a/signal/Makefile b/signal/Makefile
index 077aaea6ad..de92558f2c 100644
--- a/signal/Makefile
+++ b/signal/Makefile
@@ -22,10 +22,14 @@ subdir := signal
include ../Makeconfig
-headers := signal.h sys/signal.h bits/signum.h bits/sigcontext.h \
- bits/sigaction.h bits/sigset.h bits/siginfo.h bits/sigstack.h \
- bits/sigthread.h bits/types/struct_sigstack.h bits/types/stack_t.h \
- bits/ss_flags.h
+headers := signal.h sys/signal.h \
+ bits/signum.h bits/sigcontext.h bits/sigaction.h \
+ bits/sigevent-consts.h bits/siginfo-consts.h \
+ bits/sigstack.h bits/sigthread.h bits/ss_flags.h \
+ bits/types/__sigset_t.h bits/types/sig_atomic_t.h \
+ bits/types/sigevent_t.h bits/types/siginfo_t.h \
+ bits/types/sigset_t.h bits/types/stack_t.h \
+ bits/types/struct_sigstack.h
routines := signal raise killpg \
sigaction sigprocmask kill \
diff --git a/signal/Versions b/signal/Versions
index 4d86930ec6..a915ef400f 100644
--- a/signal/Versions
+++ b/signal/Versions
@@ -1,13 +1,13 @@
libc {
GLIBC_2.0 {
# functions with special/multiple interfaces
- __sigaddset; __sigdelset; __sigismember; __sysv_signal;
+ __sigpause; __sysv_signal;
- # functions used in inline functions or macros
- __sigpause;
+ # functions formerly used in inline functions or macros
+ __sigaddset; __sigdelset; __sigismember;
# functions used in other libraries
- __sigaction;
+ __sigaction;
# b*
bsd_signal;
diff --git a/signal/bits/types/sig_atomic_t.h b/signal/bits/types/sig_atomic_t.h
new file mode 100644
index 0000000000..47eaa28311
--- /dev/null
+++ b/signal/bits/types/sig_atomic_t.h
@@ -0,0 +1,10 @@
+#ifndef __sig_atomic_t_defined
+#define __sig_atomic_t_defined 1
+
+#include <bits/types.h>
+
+/* An integral type that can be modified atomically, without the
+ possibility of a signal arriving in the middle of the operation. */
+typedef __sig_atomic_t sig_atomic_t;
+
+#endif
diff --git a/signal/bits/types/sigset_t.h b/signal/bits/types/sigset_t.h
new file mode 100644
index 0000000000..8b27e9112d
--- /dev/null
+++ b/signal/bits/types/sigset_t.h
@@ -0,0 +1,9 @@
+#ifndef __sigset_t_defined
+#define __sigset_t_defined 1
+
+#include <bits/types/__sigset_t.h>
+
+/* A set of signals to be blocked, unblocked, or waited for. */
+typedef __sigset_t sigset_t;
+
+#endif
diff --git a/signal/bits/types/sigval_t.h b/signal/bits/types/sigval_t.h
new file mode 100644
index 0000000000..666598f0ca
--- /dev/null
+++ b/signal/bits/types/sigval_t.h
@@ -0,0 +1,13 @@
+#ifndef __sigval_t_defined
+#define __sigval_t_defined
+
+/* Type for data associated with a signal. */
+union sigval
+{
+ int sival_int;
+ void *sival_ptr;
+};
+
+typedef union sigval sigval_t;
+
+#endif
diff --git a/signal/sigaddset.c b/signal/sigaddset.c
index ca280d8e76..161be7b352 100644
--- a/signal/sigaddset.c
+++ b/signal/sigaddset.c
@@ -15,7 +15,9 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include "sigsetops.h"
+#include <errno.h>
+#include <signal.h>
+#include <sigsetops.h>
/* Add SIGNO to SET. */
int
@@ -27,6 +29,7 @@ sigaddset (sigset_t *set, int signo)
return -1;
}
- return __sigaddset (set, signo);
+ __sigaddset (set, signo);
+ return 0;
}
libc_hidden_def (sigaddset)
diff --git a/signal/sigandset.c b/signal/sigandset.c
index f81a5939ee..ffea141c63 100644
--- a/signal/sigandset.c
+++ b/signal/sigandset.c
@@ -17,18 +17,18 @@
#include <errno.h>
#include <signal.h>
-#define __need_NULL
-#include <stddef.h>
+#include <sigsetops.h>
/* Combine sets LEFT and RIGHT by logical AND and place result in DEST. */
int
sigandset (sigset_t *dest, const sigset_t *left, const sigset_t *right)
{
- if (dest == NULL || left == NULL || right == NULL)
+ if (!dest || !left || !right)
{
__set_errno (EINVAL);
return -1;
}
- return __sigandset (dest, left, right);
+ __sigandset (dest, left, right);
+ return 0;
}
diff --git a/signal/sigdelset.c b/signal/sigdelset.c
index 4632103b22..2aaa536937 100644
--- a/signal/sigdelset.c
+++ b/signal/sigdelset.c
@@ -15,7 +15,9 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include "sigsetops.h"
+#include <errno.h>
+#include <signal.h>
+#include <sigsetops.h>
/* Add SIGNO to SET. */
int
@@ -27,6 +29,7 @@ sigdelset (sigset_t *set, int signo)
return -1;
}
- return __sigdelset (set, signo);
+ __sigdelset (set, signo);
+ return 0;
}
libc_hidden_def (sigdelset)
diff --git a/signal/sigisempty.c b/signal/sigisempty.c
index eabe71ce6b..bea03f1216 100644
--- a/signal/sigisempty.c
+++ b/signal/sigisempty.c
@@ -17,18 +17,17 @@
#include <errno.h>
#include <signal.h>
-#define __need_NULL
-#include <stddef.h>
+#include <sigsetops.h>
/* Test whether SET is empty. */
int
sigisemptyset (const sigset_t *set)
{
- if (set == NULL)
+ if (!set)
{
__set_errno (EINVAL);
return -1;
}
- return __sigisemptyset (set);
+ return __sigisemptyset (set);
}
diff --git a/signal/sigismem.c b/signal/sigismem.c
index 8da14ac26d..6ef4a4d19d 100644
--- a/signal/sigismem.c
+++ b/signal/sigismem.c
@@ -15,7 +15,9 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include "sigsetops.h"
+#include <errno.h>
+#include <signal.h>
+#include <sigsetops.h>
/* Return 1 if SIGNO is in SET, 0 if not. */
int
diff --git a/signal/signal.h b/signal/signal.h
index d01df3290a..a51e912d08 100644
--- a/signal/signal.h
+++ b/signal/signal.h
@@ -20,40 +20,21 @@
*/
#ifndef _SIGNAL_H
-
-#if !defined __need_sig_atomic_t && !defined __need_sigset_t
-# define _SIGNAL_H
-#endif
+#define _SIGNAL_H
#include <features.h>
__BEGIN_DECLS
-#include <bits/sigset.h> /* __sigset_t, __sig_atomic_t. */
+#include <bits/types.h>
+#include <bits/signum.h>
-/* An integral type that can be modified atomically, without the
- possibility of a signal arriving in the middle of the operation. */
-#if defined __need_sig_atomic_t || defined _SIGNAL_H
-# ifndef __sig_atomic_t_defined
-# define __sig_atomic_t_defined
-typedef __sig_atomic_t sig_atomic_t;
-# endif
-# undef __need_sig_atomic_t
-#endif
+#include <bits/types/sig_atomic_t.h>
-#if defined __need_sigset_t || (defined _SIGNAL_H && defined __USE_POSIX)
-# ifndef __sigset_t_defined
-# define __sigset_t_defined
-typedef __sigset_t sigset_t;
-# endif
-# undef __need_sigset_t
+#if defined __USE_POSIX
+#include <bits/types/sigset_t.h>
#endif
-#ifdef _SIGNAL_H
-
-#include <bits/types.h>
-#include <bits/signum.h>
-
#if defined __USE_XOPEN || defined __USE_XOPEN2K
# ifndef __pid_t_defined
typedef __pid_t pid_t;
@@ -73,8 +54,10 @@ typedef __uid_t uid_t;
#endif
#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
-/* Get the `siginfo_t' type plus the needed symbols. */
-# include <bits/siginfo.h>
+# include <bits/types/siginfo_t.h>
+# include <bits/types/sigevent_t.h>
+# include <bits/siginfo-consts.h>
+# include <bits/sigevent-consts.h>
#endif
@@ -174,7 +157,7 @@ extern int __sigpause (int __sig_or_mask, int __is_sig);
simply do not work in many situations. Use `sigprocmask' instead. */
/* Compute mask for signal SIG. */
-# define sigmask(sig) __sigmask(sig)
+# define sigmask(sig) ((int)(1u << ((sig) - 1)))
/* Block signals in MASK, returning the old mask. */
extern int sigblock (int __mask) __THROW __attribute_deprecated__;
@@ -366,8 +349,6 @@ extern int __libc_current_sigrtmin (void) __THROW;
/* Return number of available real-time signal with lowest priority. */
extern int __libc_current_sigrtmax (void) __THROW;
-#endif /* signal.h */
-
__END_DECLS
#endif /* not signal.h */
diff --git a/signal/sigorset.c b/signal/sigorset.c
index 9ea867d79d..8a586db6b5 100644
--- a/signal/sigorset.c
+++ b/signal/sigorset.c
@@ -17,18 +17,18 @@
#include <errno.h>
#include <signal.h>
-#define __need_NULL
-#include <stddef.h>
+#include <sigsetops.h>
/* Combine sets LEFT and RIGHT by logical OR and place result in DEST. */
int
sigorset (sigset_t *dest, const sigset_t *left, const sigset_t *right)
{
- if (dest == NULL || left == NULL || right == NULL)
+ if (!dest || !left || !right)
{
__set_errno (EINVAL);
return -1;
}
- return __sigorset (dest, left, right);
+ __sigorset (dest, left, right);
+ return 0;
}
diff --git a/signal/sigsetops.c b/signal/sigsetops.c
index 0317662a14..d56412f94b 100644
--- a/signal/sigsetops.c
+++ b/signal/sigsetops.c
@@ -1,11 +1,53 @@
-/* Define the real-function versions of all inline functions
- defined in signal.h (or bits/sigset.h). */
+/* Compatibility symbols for old versions of signal.h.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
-#include <features.h>
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#define _EXTERN_INLINE
-#ifndef __USE_EXTERN_INLINES
-# define __USE_EXTERN_INLINES 1
-#endif
+ 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <signal.h>
+#include <sigsetops.h>
+#include <shlib-compat.h>
+
+/* These were formerly defined by <signal.h> as inline functions,
+ so they require out-of-line compatibility definitions. */
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_26)
-#include "signal.h"
+int
+attribute_compat_text_section
+(__sigismember) (const __sigset_t *set, int sig)
+{
+ return __sigismember (set, sig);
+}
+compat_symbol (libc, __sigismember, __sigismember, GLIBC_2_0);
+
+int
+attribute_compat_text_section
+(__sigaddset) (__sigset_t *set, int sig)
+{
+ __sigaddset (set, sig);
+ return 0;
+}
+compat_symbol (libc, __sigaddset, __sigaddset, GLIBC_2_0);
+
+int
+attribute_compat_text_section
+(__sigdelset) (__sigset_t *set, int sig)
+{
+ __sigdelset (set, sig);
+ return 0;
+}
+compat_symbol (libc, __sigdelset, __sigdelset, GLIBC_2_0);
+
+#endif
diff --git a/signal/sigsetops.h b/signal/sigsetops.h
deleted file mode 100644
index cd1282000e..0000000000
--- a/signal/sigsetops.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1991-2017 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 Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-/* Definitions relevant to functions that operate on `sigset_t's. */
-
-#include <errno.h>
-#include <signal.h>
-#include <string.h>
-
-#define BITS (_NSIG - 1)
-#define ELT(signo) (((signo) - 1) / BITS)
-#define MASK(signo) (1 << (((signo) - 1) % BITS))
-
-#undef sigemptyset
-#undef sigfillset
-#undef sigaddset
-#undef sigdelset
-#undef sigismember