mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-30 15:38:06 +01:00
Fix standards conformance bugs in <signal.h>:
include/signal.h: There was massive namespace pollution from including <sys/types.h>. POSIX functions were declared even when _ANSI_SOURCE is defined. sys.sys/signal.h: NSIG was declared even if _ANSI_SOURCE or _POSIX_SOURCE is defined. sig_atomic_t wasn't declared if _POSIX_SOURCE is defined. Declare a typedef for signal handling functions and use it to unobfuscate declarations and to avoid half-baked function types that cause unwanted compiler warnings at certain warning levels. Fix confusing comment about SA_RESTART. sys/i386/include/signal.h: This has to be included to get the declaration of sig_atomic_t even when _ANSI_SOURCE is defined, so be more careful about polluting the ANSI namespace. Uniformize idempotency ifdefs.
This commit is contained in:
parent
200db83402
commit
943c18018b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=9343
@ -33,12 +33,12 @@
|
||||
* @(#)signal.h 8.3 (Berkeley) 3/30/94
|
||||
*/
|
||||
|
||||
#ifndef _USER_SIGNAL_H
|
||||
#define _USER_SIGNAL_H
|
||||
#ifndef _SIGNAL_H_
|
||||
#define _SIGNAL_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/signal.h>
|
||||
#include <machine/ansi.h>
|
||||
|
||||
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
|
||||
extern __const char *__const sys_signame[NSIG];
|
||||
@ -48,7 +48,7 @@ extern __const char *__const sys_siglist[NSIG];
|
||||
__BEGIN_DECLS
|
||||
int raise __P((int));
|
||||
#ifndef _ANSI_SOURCE
|
||||
int kill __P((pid_t, int));
|
||||
int kill __P((_BSD_PID_T_, int));
|
||||
int sigaction __P((int, const struct sigaction *, struct sigaction *));
|
||||
int sigaddset __P((sigset_t *, int));
|
||||
int sigdelset __P((sigset_t *, int));
|
||||
@ -59,7 +59,7 @@ int sigpending __P((sigset_t *));
|
||||
int sigprocmask __P((int, const sigset_t *, sigset_t *));
|
||||
int sigsuspend __P((const sigset_t *));
|
||||
#ifndef _POSIX_SOURCE
|
||||
int killpg __P((pid_t, int));
|
||||
int killpg __P((_BSD_PID_T_, int));
|
||||
int sigblock __P((int));
|
||||
int siginterrupt __P((int, int));
|
||||
int sigpause __P((int));
|
||||
@ -68,15 +68,17 @@ int sigsetmask __P((int));
|
||||
int sigstack __P((const struct sigstack *, struct sigstack *));
|
||||
int sigvec __P((int, struct sigvec *, struct sigvec *));
|
||||
void psignal __P((unsigned int, const char *));
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
#endif /* !_ANSI_SOURCE */
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
#endif /* !_ANSI_SOURCE */
|
||||
__END_DECLS
|
||||
|
||||
#ifndef _ANSI_SOURCE
|
||||
/* List definitions after function declarations, or Reiser cpp gets upset. */
|
||||
#define sigaddset(set, signo) (*(set) |= 1 << ((signo) - 1), 0)
|
||||
#define sigdelset(set, signo) (*(set) &= ~(1 << ((signo) - 1)), 0)
|
||||
#define sigemptyset(set) (*(set) = 0, 0)
|
||||
#define sigfillset(set) (*(set) = ~(sigset_t)0, 0)
|
||||
#define sigismember(set, signo) ((*(set) & (1 << ((signo) - 1))) != 0)
|
||||
#endif /* !_ANSI_SOURCE */
|
||||
|
||||
#endif /* !_USER_SIGNAL_H */
|
||||
#endif /* !_SIGNAL_H_ */
|
||||
|
@ -31,11 +31,11 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)signal.h 8.1 (Berkeley) 6/11/93
|
||||
* $Id: signal.h,v 1.3 1994/08/02 07:39:01 davidg Exp $
|
||||
* $Id: signal.h,v 1.4 1994/08/21 04:55:30 paul Exp $
|
||||
*/
|
||||
|
||||
#ifndef _I386_MACHINE_SIGNAL_H_
|
||||
#define _I386_MACHINE_SIGNAL_H_
|
||||
#ifndef _MACHINE_SIGNAL_H_
|
||||
#define _MACHINE_SIGNAL_H_
|
||||
|
||||
/*
|
||||
* Machine-dependent signal definitions
|
||||
@ -43,9 +43,9 @@
|
||||
|
||||
typedef int sig_atomic_t;
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
|
||||
|
||||
#include <machine/trap.h> /* codes for SIGILL, SIGFPE */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Information pushed on stack when a signal is delivered.
|
||||
@ -78,4 +78,6 @@ struct sigcontext {
|
||||
# define sc_ps sc_efl
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
|
||||
|
||||
#endif /* !_MACHINE_SIGNAL_H_ */
|
||||
|
@ -31,11 +31,11 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)signal.h 8.1 (Berkeley) 6/11/93
|
||||
* $Id: signal.h,v 1.3 1994/08/02 07:39:01 davidg Exp $
|
||||
* $Id: signal.h,v 1.4 1994/08/21 04:55:30 paul Exp $
|
||||
*/
|
||||
|
||||
#ifndef _I386_MACHINE_SIGNAL_H_
|
||||
#define _I386_MACHINE_SIGNAL_H_
|
||||
#ifndef _MACHINE_SIGNAL_H_
|
||||
#define _MACHINE_SIGNAL_H_
|
||||
|
||||
/*
|
||||
* Machine-dependent signal definitions
|
||||
@ -43,9 +43,9 @@
|
||||
|
||||
typedef int sig_atomic_t;
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
|
||||
|
||||
#include <machine/trap.h> /* codes for SIGILL, SIGFPE */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Information pushed on stack when a signal is delivered.
|
||||
@ -78,4 +78,6 @@ struct sigcontext {
|
||||
# define sc_ps sc_efl
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
|
||||
|
||||
#endif /* !_MACHINE_SIGNAL_H_ */
|
||||
|
@ -36,16 +36,17 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)signal.h 8.2 (Berkeley) 1/21/94
|
||||
* $Id: signal.h,v 1.2 1994/08/02 07:53:32 davidg Exp $
|
||||
* $Id: signal.h,v 1.3 1995/01/29 01:19:25 ats Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SIGNAL_H_
|
||||
#define _SYS_SIGNAL_H_
|
||||
|
||||
#define NSIG 32 /* counting 0; could be 33 (mask is 1-32) */
|
||||
#include <sys/cdefs.h>
|
||||
#include <machine/signal.h> /* sig_atomic_t; trap codes; sigcontext */
|
||||
|
||||
#ifndef _ANSI_SOURCE
|
||||
#include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */
|
||||
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
|
||||
#define NSIG 32 /* counting 0; could be 33 (mask is 1-32) */
|
||||
#endif
|
||||
|
||||
#define SIGHUP 1 /* hangup */
|
||||
@ -93,19 +94,27 @@
|
||||
#define SIGUSR1 30 /* user defined signal 1 */
|
||||
#define SIGUSR2 31 /* user defined signal 2 */
|
||||
|
||||
#if defined(_ANSI_SOURCE) || defined(__cplusplus)
|
||||
/*
|
||||
* Language spec sez we must list exactly one parameter, even though we
|
||||
/*-
|
||||
* Type of a signal handling function.
|
||||
*
|
||||
* Language spec sez signal handlers take exactly one arg, even though we
|
||||
* actually supply three. Ugh!
|
||||
*
|
||||
* We don't try to hide the difference by leaving out the args because
|
||||
* that would cause warnings about conformant programs. Nonconformant
|
||||
* programs can avoid the warnings by casting to (__sighandler_t *) or
|
||||
* sig_t before calling signal() or assigning to sa_handler or sv_handler.
|
||||
*
|
||||
* The kernel should reverse the cast before calling the function. It
|
||||
* has no way to do this, but on most machines 1-arg and 3-arg functions
|
||||
* have the same calling protocol so there is no problem in practice.
|
||||
* A bit in sa_flags could be used to specify the number of args.
|
||||
*/
|
||||
#define SIG_DFL (void (*)(int))0
|
||||
#define SIG_IGN (void (*)(int))1
|
||||
#define SIG_ERR (void (*)(int))-1
|
||||
#else
|
||||
#define SIG_DFL (void (*)())0
|
||||
#define SIG_IGN (void (*)())1
|
||||
#define SIG_ERR (void (*)())-1
|
||||
#endif
|
||||
typedef void __sighandler_t __P((int));
|
||||
|
||||
#define SIG_DFL ((__sighandler_t *)0)
|
||||
#define SIG_IGN ((__sighandler_t *)1)
|
||||
#define SIG_ERR ((__sighandler_t *)-1)
|
||||
|
||||
#ifndef _ANSI_SOURCE
|
||||
typedef unsigned int sigset_t;
|
||||
@ -114,13 +123,13 @@ typedef unsigned int sigset_t;
|
||||
* Signal vector "template" used in sigaction call.
|
||||
*/
|
||||
struct sigaction {
|
||||
void (*sa_handler)(); /* signal handler */
|
||||
__sighandler_t *sa_handler; /* signal handler */
|
||||
sigset_t sa_mask; /* signal mask to apply */
|
||||
int sa_flags; /* see signal options below */
|
||||
};
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define SA_ONSTACK 0x0001 /* take signal on signal stack */
|
||||
#define SA_RESTART 0x0002 /* restart system on signal return */
|
||||
#define SA_RESTART 0x0002 /* restart system call on signal return */
|
||||
#define SA_DISABLE 0x0004 /* disable taking signals on alternate stack */
|
||||
#ifdef COMPAT_SUNOS
|
||||
#define SA_USERTRAMP 0x0100 /* do not bounce off kernel's sigtramp */
|
||||
@ -136,10 +145,7 @@ struct sigaction {
|
||||
#define SIG_SETMASK 3 /* set specified signal set */
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#ifndef KERNEL
|
||||
#include <sys/cdefs.h>
|
||||
#endif
|
||||
typedef void (*sig_t) __P((int)); /* type of signal function */
|
||||
typedef __sighandler_t *sig_t; /* type of pointer to a signal function */
|
||||
|
||||
/*
|
||||
* Structure used in sigaltstack call.
|
||||
@ -157,7 +163,7 @@ struct sigaltstack {
|
||||
* Signal vector "template" used in sigvec call.
|
||||
*/
|
||||
struct sigvec {
|
||||
void (*sv_handler)(); /* signal handler */
|
||||
__sighandler_t *sv_handler; /* signal handler */
|
||||
int sv_mask; /* signal mask to apply */
|
||||
int sv_flags; /* see signal options below */
|
||||
};
|
||||
@ -190,6 +196,7 @@ struct sigstack {
|
||||
* defined by <sys/signal.h>.
|
||||
*/
|
||||
__BEGIN_DECLS
|
||||
void (*signal __P((int, void (*) __P((int))))) __P((int));
|
||||
__sighandler_t *signal __P((int, __sighandler_t *));
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_SYS_SIGNAL_H_ */
|
||||
|
@ -36,16 +36,17 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)signal.h 8.2 (Berkeley) 1/21/94
|
||||
* $Id: signal.h,v 1.2 1994/08/02 07:53:32 davidg Exp $
|
||||
* $Id: signal.h,v 1.3 1995/01/29 01:19:25 ats Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SIGNAL_H_
|
||||
#define _SYS_SIGNAL_H_
|
||||
|
||||
#define NSIG 32 /* counting 0; could be 33 (mask is 1-32) */
|
||||
#include <sys/cdefs.h>
|
||||
#include <machine/signal.h> /* sig_atomic_t; trap codes; sigcontext */
|
||||
|
||||
#ifndef _ANSI_SOURCE
|
||||
#include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */
|
||||
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
|
||||
#define NSIG 32 /* counting 0; could be 33 (mask is 1-32) */
|
||||
#endif
|
||||
|
||||
#define SIGHUP 1 /* hangup */
|
||||
@ -93,19 +94,27 @@
|
||||
#define SIGUSR1 30 /* user defined signal 1 */
|
||||
#define SIGUSR2 31 /* user defined signal 2 */
|
||||
|
||||
#if defined(_ANSI_SOURCE) || defined(__cplusplus)
|
||||
/*
|
||||
* Language spec sez we must list exactly one parameter, even though we
|
||||
/*-
|
||||
* Type of a signal handling function.
|
||||
*
|
||||
* Language spec sez signal handlers take exactly one arg, even though we
|
||||
* actually supply three. Ugh!
|
||||
*
|
||||
* We don't try to hide the difference by leaving out the args because
|
||||
* that would cause warnings about conformant programs. Nonconformant
|
||||
* programs can avoid the warnings by casting to (__sighandler_t *) or
|
||||
* sig_t before calling signal() or assigning to sa_handler or sv_handler.
|
||||
*
|
||||
* The kernel should reverse the cast before calling the function. It
|
||||
* has no way to do this, but on most machines 1-arg and 3-arg functions
|
||||
* have the same calling protocol so there is no problem in practice.
|
||||
* A bit in sa_flags could be used to specify the number of args.
|
||||
*/
|
||||
#define SIG_DFL (void (*)(int))0
|
||||
#define SIG_IGN (void (*)(int))1
|
||||
#define SIG_ERR (void (*)(int))-1
|
||||
#else
|
||||
#define SIG_DFL (void (*)())0
|
||||
#define SIG_IGN (void (*)())1
|
||||
#define SIG_ERR (void (*)())-1
|
||||
#endif
|
||||
typedef void __sighandler_t __P((int));
|
||||
|
||||
#define SIG_DFL ((__sighandler_t *)0)
|
||||
#define SIG_IGN ((__sighandler_t *)1)
|
||||
#define SIG_ERR ((__sighandler_t *)-1)
|
||||
|
||||
#ifndef _ANSI_SOURCE
|
||||
typedef unsigned int sigset_t;
|
||||
@ -114,13 +123,13 @@ typedef unsigned int sigset_t;
|
||||
* Signal vector "template" used in sigaction call.
|
||||
*/
|
||||
struct sigaction {
|
||||
void (*sa_handler)(); /* signal handler */
|
||||
__sighandler_t *sa_handler; /* signal handler */
|
||||
sigset_t sa_mask; /* signal mask to apply */
|
||||
int sa_flags; /* see signal options below */
|
||||
};
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define SA_ONSTACK 0x0001 /* take signal on signal stack */
|
||||
#define SA_RESTART 0x0002 /* restart system on signal return */
|
||||
#define SA_RESTART 0x0002 /* restart system call on signal return */
|
||||
#define SA_DISABLE 0x0004 /* disable taking signals on alternate stack */
|
||||
#ifdef COMPAT_SUNOS
|
||||
#define SA_USERTRAMP 0x0100 /* do not bounce off kernel's sigtramp */
|
||||
@ -136,10 +145,7 @@ struct sigaction {
|
||||
#define SIG_SETMASK 3 /* set specified signal set */
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#ifndef KERNEL
|
||||
#include <sys/cdefs.h>
|
||||
#endif
|
||||
typedef void (*sig_t) __P((int)); /* type of signal function */
|
||||
typedef __sighandler_t *sig_t; /* type of pointer to a signal function */
|
||||
|
||||
/*
|
||||
* Structure used in sigaltstack call.
|
||||
@ -157,7 +163,7 @@ struct sigaltstack {
|
||||
* Signal vector "template" used in sigvec call.
|
||||
*/
|
||||
struct sigvec {
|
||||
void (*sv_handler)(); /* signal handler */
|
||||
__sighandler_t *sv_handler; /* signal handler */
|
||||
int sv_mask; /* signal mask to apply */
|
||||
int sv_flags; /* see signal options below */
|
||||
};
|
||||
@ -190,6 +196,7 @@ struct sigstack {
|
||||
* defined by <sys/signal.h>.
|
||||
*/
|
||||
__BEGIN_DECLS
|
||||
void (*signal __P((int, void (*) __P((int))))) __P((int));
|
||||
__sighandler_t *signal __P((int, __sighandler_t *));
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_SYS_SIGNAL_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user