From a992f506ff7162da2afa5a6151cc6f15949ceef4 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Thu, 1 Dec 2016 19:24:13 -0500 Subject: 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 (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 , , and 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. --- bits/types/siginfo_t.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 bits/types/siginfo_t.h (limited to 'bits/types/siginfo_t.h') diff --git a/bits/types/siginfo_t.h b/bits/types/siginfo_t.h new file mode 100644 index 0000000000..ab6bf18bec --- /dev/null +++ b/bits/types/siginfo_t.h @@ -0,0 +1,21 @@ +#ifndef __siginfo_t_defined +#define __siginfo_t_defined 1 + +#include +#include + +typedef struct siginfo + { + int si_signo; /* Signal number. */ + int si_errno; /* If non-zero, an errno value associated with + this signal, as defined in . */ + int si_code; /* Signal code. */ + __pid_t si_pid; /* Sending process ID. */ + __uid_t si_uid; /* Real user ID of sending process. */ + void *si_addr; /* Address of faulting instruction. */ + int si_status; /* Exit value or signal. */ + long int si_band; /* Band event for SIGPOLL. */ + sigval_t si_value; /* Signal value. */ + } siginfo_t; + +#endif -- cgit v1.2.3 From 67f0aff0c63e5deaade7f6cc7758f5cb63344fb8 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 16 Aug 2017 20:33:59 +0000 Subject: Fix sigval namespace (bug 21944). XPG4.2 defines the siginfo_t type, but not union sigval or its contents (which were added in the 1993 edition of POSIX.1), resulting in namespace violations for sigval, sival_int and sival_ptr for signal.h and sys/wait.h for that standard because those headers incorrectly expose those names in that case. This patch fixes this problem. The public type in this case is union sigval, but various places in the headers use the sigval_t name for it; direct uses of union sigval are already properly guarded or in headers not in XPG4.2. Now, sigval_t, although not a standard name, does seem to be widely used outside glibc. The approach taken by this patch is to make installed headers use the name __sigval_t instead. __sigval_t is then defined to either union sigval or union __sigval (where union __sigval has __-prefixed member names as well), depending on whether there are any namespace issues with the union sigval name and its members. In the case where union __sigval is used, sigval_t is not defined at all, to avoid the problem of sigval_t having a C++ mangled name that depends on feature test macros. sigval_t is still defined by signal.h if __USE_MISC (reflecting the nonstandard nature of that name). Tested for x86_64. [BZ #21944] * signal/bits/types/__sigval_t.h: New file. * signal/Makefile (headers): Add bits/types/__sigval_t.h. * signal/bits/types/sigval_t.h: Include and define sigval_t using __sigval_t. * include/bits/types/__sigval_t.h: New file. * bits/types/sigevent_t.h: Include instead of . (struct sigevent): Use __sigval_t instead of sigval_t. * bits/types/siginfo_t.h: Include instead of . (siginfo_t): Use __sigval_t instead of sigval_t. * sysdeps/unix/sysv/linux/bits/types/sigevent_t.h: Include instead of . (struct sigevent): Use __sigval_t instead of sigval_t. * sysdeps/unix/sysv/linux/bits/types/siginfo_t.h: Include instead of . (siginfo_t): Use __sigval_t instead of sigval_t. * signal/signal.h [__USE_MISC]: Include . --- ChangeLog | 22 +++++++++++++ bits/types/sigevent_t.h | 6 ++-- bits/types/siginfo_t.h | 4 +-- include/bits/types/__sigval_t.h | 1 + signal/Makefile | 3 +- signal/bits/types/__sigval_t.h | 41 +++++++++++++++++++++++++ signal/bits/types/sigval_t.h | 21 ++++++++----- signal/signal.h | 4 +++ sysdeps/unix/sysv/linux/bits/types/sigevent_t.h | 6 ++-- sysdeps/unix/sysv/linux/bits/types/siginfo_t.h | 6 ++-- 10 files changed, 94 insertions(+), 20 deletions(-) create mode 100644 include/bits/types/__sigval_t.h create mode 100644 signal/bits/types/__sigval_t.h (limited to 'bits/types/siginfo_t.h') diff --git a/ChangeLog b/ChangeLog index 5f69f5d176..e6babbbbee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2017-08-16 Joseph Myers + + [BZ #21944] + * signal/bits/types/__sigval_t.h: New file. + * signal/Makefile (headers): Add bits/types/__sigval_t.h. + * signal/bits/types/sigval_t.h: Include + and define sigval_t using __sigval_t. + * include/bits/types/__sigval_t.h: New file. + * bits/types/sigevent_t.h: Include + instead of . + (struct sigevent): Use __sigval_t instead of sigval_t. + * bits/types/siginfo_t.h: Include + instead of . + (siginfo_t): Use __sigval_t instead of sigval_t. + * sysdeps/unix/sysv/linux/bits/types/sigevent_t.h: Include + instead of . + (struct sigevent): Use __sigval_t instead of sigval_t. + * sysdeps/unix/sysv/linux/bits/types/siginfo_t.h: Include + instead of . + (siginfo_t): Use __sigval_t instead of sigval_t. + * signal/signal.h [__USE_MISC]: Include . + 2017-08-16 H.J. Lu * NEWS: Remove "[Add new features here]" for 2.27. diff --git a/bits/types/sigevent_t.h b/bits/types/sigevent_t.h index 7b8cb054d7..5611268610 100644 --- a/bits/types/sigevent_t.h +++ b/bits/types/sigevent_t.h @@ -2,15 +2,15 @@ #define __sigevent_t_defined 1 #include -#include +#include /* Structure to transport application-defined values with signals. */ typedef struct sigevent { - sigval_t sigev_value; + __sigval_t sigev_value; int sigev_signo; int sigev_notify; - void (*sigev_notify_function) (sigval_t); /* Function to start. */ + void (*sigev_notify_function) (__sigval_t); /* Function to start. */ void *sigev_notify_attributes; /* Really pthread_attr_t.*/ } sigevent_t; diff --git a/bits/types/siginfo_t.h b/bits/types/siginfo_t.h index ab6bf18bec..1ac2a98fbd 100644 --- a/bits/types/siginfo_t.h +++ b/bits/types/siginfo_t.h @@ -2,7 +2,7 @@ #define __siginfo_t_defined 1 #include -#include +#include typedef struct siginfo { @@ -15,7 +15,7 @@ typedef struct siginfo void *si_addr; /* Address of faulting instruction. */ int si_status; /* Exit value or signal. */ long int si_band; /* Band event for SIGPOLL. */ - sigval_t si_value; /* Signal value. */ + __sigval_t si_value; /* Signal value. */ } siginfo_t; #endif diff --git a/include/bits/types/__sigval_t.h b/include/bits/types/__sigval_t.h new file mode 100644 index 0000000000..62f8e48ed8 --- /dev/null +++ b/include/bits/types/__sigval_t.h @@ -0,0 +1 @@ +#include diff --git a/signal/Makefile b/signal/Makefile index 8c9a7d1844..a6a1289437 100644 --- a/signal/Makefile +++ b/signal/Makefile @@ -30,7 +30,8 @@ headers := signal.h sys/signal.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/sigval_t.h \ - bits/types/stack_t.h bits/types/struct_sigstack.h + bits/types/stack_t.h bits/types/struct_sigstack.h \ + bits/types/__sigval_t.h routines := signal raise killpg \ sigaction sigprocmask kill \ diff --git a/signal/bits/types/__sigval_t.h b/signal/bits/types/__sigval_t.h new file mode 100644 index 0000000000..79b4ffe401 --- /dev/null +++ b/signal/bits/types/__sigval_t.h @@ -0,0 +1,41 @@ +/* Define __sigval_t. + Copyright (C) 1997-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 + . */ + +#ifndef ____sigval_t_defined +#define ____sigval_t_defined + +/* Type for data associated with a signal. */ +#ifdef __USE_POSIX199309 +union sigval +{ + int sival_int; + void *sival_ptr; +}; + +typedef union sigval __sigval_t; +#else +union __sigval +{ + int __sival_int; + void *__sival_ptr; +}; + +typedef union __sigval __sigval_t; +#endif + +#endif diff --git a/signal/bits/types/sigval_t.h b/signal/bits/types/sigval_t.h index 666598f0ca..a05d7f469f 100644 --- a/signal/bits/types/sigval_t.h +++ b/signal/bits/types/sigval_t.h @@ -1,13 +1,18 @@ #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; +#include + +/* To avoid sigval_t (not a standard type name) having C++ name + mangling depending on whether the selected standard includes union + sigval, it should not be defined at all when using a standard for + which the sigval name is not reserved; in that case, headers should + not include and should use only the + internal __sigval_t name. */ +#ifndef __USE_POSIX199309 +# error "sigval_t defined for standard not including union sigval" +#endif + +typedef __sigval_t sigval_t; #endif diff --git a/signal/signal.h b/signal/signal.h index c8f6100ac4..416c5a252a 100644 --- a/signal/signal.h +++ b/signal/signal.h @@ -58,6 +58,10 @@ typedef __uid_t uid_t; # include #endif +#ifdef __USE_MISC +# include +#endif + #ifdef __USE_POSIX199309 # include # include diff --git a/sysdeps/unix/sysv/linux/bits/types/sigevent_t.h b/sysdeps/unix/sysv/linux/bits/types/sigevent_t.h index 0d4857b16e..e8b28de7e3 100644 --- a/sysdeps/unix/sysv/linux/bits/types/sigevent_t.h +++ b/sysdeps/unix/sysv/linux/bits/types/sigevent_t.h @@ -3,7 +3,7 @@ #include #include -#include +#include #define __SIGEV_MAX_SIZE 64 #if __WORDSIZE == 64 @@ -21,7 +21,7 @@ typedef union pthread_attr_t pthread_attr_t; /* Structure to transport application-defined values with signals. */ typedef struct sigevent { - sigval_t sigev_value; + __sigval_t sigev_value; int sigev_signo; int sigev_notify; @@ -35,7 +35,7 @@ typedef struct sigevent struct { - void (*_function) (sigval_t); /* Function to start. */ + void (*_function) (__sigval_t); /* Function to start. */ pthread_attr_t *_attribute; /* Thread attributes. */ } _sigev_thread; } _sigev_un; diff --git a/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h b/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h index bed69148f9..33766d1813 100644 --- a/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h +++ b/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h @@ -3,7 +3,7 @@ #include #include -#include +#include #define __SI_MAX_SIZE 128 #if __WORDSIZE == 64 @@ -64,7 +64,7 @@ typedef struct { int si_tid; /* Timer ID. */ int si_overrun; /* Overrun count. */ - sigval_t si_sigval; /* Signal value. */ + __sigval_t si_sigval; /* Signal value. */ } _timer; /* POSIX.1b signals. */ @@ -72,7 +72,7 @@ typedef struct { __pid_t si_pid; /* Sending process ID. */ __uid_t si_uid; /* Real user ID of sending process. */ - sigval_t si_sigval; /* Signal value. */ + __sigval_t si_sigval; /* Signal value. */ } _rt; /* SIGCHLD. */ -- cgit v1.2.3 From ed37092475495aee5651057ad6e6dd8e2af7006f Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 19 Apr 2018 21:34:07 +0200 Subject: hurd: remove non-standard siginfo symbol * bits/types/siginfo_t.h: Remove siginfo struct name, unused and non-compliant. --- ChangeLog | 2 ++ bits/types/siginfo_t.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'bits/types/siginfo_t.h') diff --git a/ChangeLog b/ChangeLog index c43812e433..337eb6b35e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -77,6 +77,8 @@ * sysdeps/pthread/bits/types/sigevent_t.h: New file, based on the generic version but include to make struct sigevent's sigev_notify_attributes field a pthread_attr_t*. + * bits/types/siginfo_t.h: Remove siginfo struct name, unused and + non-compliant. 2018-04-18 Joseph Myers diff --git a/bits/types/siginfo_t.h b/bits/types/siginfo_t.h index 1ac2a98fbd..450cb9431f 100644 --- a/bits/types/siginfo_t.h +++ b/bits/types/siginfo_t.h @@ -4,7 +4,7 @@ #include #include -typedef struct siginfo +typedef struct { int si_signo; /* Signal number. */ int si_errno; /* If non-zero, an errno value associated with -- cgit v1.2.3