diff options
author | marcel <marcel@FreeBSD.org> | 1999-10-04 19:33:58 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 1999-10-04 19:33:58 +0000 |
commit | 05e89da65f3f17ac5d45847a1070dff333d05e7a (patch) | |
tree | 5374ca102220e75048c919ed852c428f9646cddf /sys/sys/_sigset.h | |
parent | 77802960193ff746b91be4aae32ed2a9ed8b5090 (diff) | |
download | FreeBSD-src-05e89da65f3f17ac5d45847a1070dff333d05e7a.zip FreeBSD-src-05e89da65f3f17ac5d45847a1070dff333d05e7a.tar.gz |
Re-introduction of sigcontext.
struct sigcontext and ucontext_t/mcontext_t are defined in such
a way that both (ie struct sigcontext and ucontext_t) can be
passed on to sigreturn. The signal handler is still given a
ucontext_t for maximum flexibility.
For backward compatibility sigreturn restores the state for the
alternate signal stack from sigcontext.sc_onstack and not from
ucontext_t.uc_stack. A good way to determine which value the
application has set and thus which value to use, is still open
for discussion.
NOTE: This change should only affect those binaries that use
sigcontext and/or ucontext_t. In the source tree itself
this is only doscmd. Recompilation is required for those
applications.
This commit also fixes a lot of style bugs without hopefully
adding new ones.
NOTE: struct sigaltstack.ss_size now has type size_t again. For
some reason I changed that into unsigned int.
Parts submitted by: bde
sigaltstack bug found by: bde
Diffstat (limited to 'sys/sys/_sigset.h')
-rw-r--r-- | sys/sys/_sigset.h | 106 |
1 files changed, 58 insertions, 48 deletions
diff --git a/sys/sys/_sigset.h b/sys/sys/_sigset.h index 8d1e773..edddbbe 100644 --- a/sys/sys/_sigset.h +++ b/sys/sys/_sigset.h @@ -44,22 +44,20 @@ #include <sys/cdefs.h> #include <sys/_posix.h> -#include <sys/types.h> -#include <machine/signal.h> /* sig_atomic_t; trap codes; sigcontext */ /* - * sigset_t macros + * sigset_t macros. */ -#define _SIG_WORDS 4 -#define _SIG_MAXSIG 128 -#define _SIG_IDX(sig) ((sig) - 1) -#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5) -#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31)) +#define _SIG_WORDS 4 +#define _SIG_MAXSIG 128 +#define _SIG_IDX(sig) ((sig) - 1) +#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5) +#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31)) /* - * system defined signals + * System defined signals. */ -#define SIGHUP 1 /* hangup */ +#define SIGHUP 1 /* hangup */ #define SIGINT 2 /* interrupt */ #define SIGQUIT 3 /* quit */ #define SIGILL 4 /* illegal instr. (not reset when caught) */ @@ -98,11 +96,11 @@ #define SIGXFSZ 25 /* exceeded file size limit */ #define SIGVTALRM 26 /* virtual time alarm */ #define SIGPROF 27 /* profiling time alarm */ -#define SIGWINCH 28 /* window size changes */ -#define SIGINFO 29 /* information request */ +#define SIGWINCH 28 /* window size changes */ +#define SIGINFO 29 /* information request */ #endif -#define SIGUSR1 30 /* user defined signal 1 */ -#define SIGUSR2 31 /* user defined signal 2 */ +#define SIGUSR1 30 /* user defined signal 1 */ +#define SIGUSR2 31 /* user defined signal 2 */ /*- * Type of a signal handling function. @@ -124,50 +122,62 @@ typedef void __sighandler_t __P((int)); #define SIG_DFL ((__sighandler_t *)0) #define SIG_IGN ((__sighandler_t *)1) -#define SIG_HOLD ((__sighandler_t *)2) +#define SIG_HOLD ((__sighandler_t *)2) #define SIG_ERR ((__sighandler_t *)-1) +#ifndef _POSIX_SOURCE union sigval { /* Members as suggested by Annex C of POSIX 1003.1b. */ - int sigval_int; - void *sigval_ptr; + int sigval_int; + void *sigval_ptr; }; -typedef struct { - int si_signo; /* signal number */ - int si_errno; /* errno association */ +typedef struct __siginfo { + int si_signo; /* signal number */ + int si_errno; /* errno association */ /* * Cause of signal, one of the SI_ macros or signal-specific * values, i.e. one of the FPE_... values for SIGFPE. This * value is equivalent to the second argument to an old-style * FreeBSD signal handler. */ - int si_code; /* signal code */ - pid_t si_pid; /* sending process */ - uid_t si_uid; /* sender's ruid */ - int si_status; /* exit value */ - void *si_addr; /* faulting instruction */ - union sigval si_value; /* signal value */ - long si_band; /* band event for SIGPOLL */ - int __spare__[7]; /* gimme some slack */ + int si_code; /* signal code */ + int si_pid; /* sending process */ + unsigned int si_uid; /* sender's ruid */ + int si_status; /* exit value */ + void *si_addr; /* faulting instruction */ + union sigval si_value; /* signal value */ + long si_band; /* band event for SIGPOLL */ + int __spare__[7]; /* gimme some slack */ } siginfo_t; +#endif -typedef struct { +typedef struct __sigset { unsigned int __bits[_SIG_WORDS]; } sigset_t; +/* + * XXX - there are some nasty dependencies. + * Now that sigset_t has been defined we can + * include the MD structures. + */ +#include <machine/signal.h> /* sig_atomic_t; trap codes; sigcontext */ + #if !defined(_ANSI_SOURCE) +struct __siginfo; + /* * Signal vector "template" used in sigaction call. */ struct sigaction { union { void (*__sa_handler) __P((int)); - void (*__sa_sigaction) __P((int, siginfo_t *, void *)); + void (*__sa_sigaction) __P((int, struct __siginfo *, + void *)); } __sigaction_u; /* signal handler */ - int sa_flags; /* see signal options below */ - sigset_t sa_mask; /* signal mask to apply */ + int sa_flags; /* see signal options below */ + sigset_t sa_mask; /* signal mask to apply */ }; /* if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. */ @@ -189,7 +199,7 @@ struct sigaction { #define SA_USERTRAMP 0x0100 /* do not bounce off kernel's sigtramp */ #endif -#define NSIG 32 +#define NSIG 32 /* number of old signals (counting 0) */ /* POSIX 1003.1b required values. */ #define SI_USER 0x10001 @@ -211,12 +221,12 @@ typedef _BSD_SIZE_T_ size_t; #endif /* - * sigaltstack + * Structure used in sigaltstack call. */ typedef struct sigaltstack { - char *ss_sp; /* signal stack base */ - unsigned int ss_size; /* signal stack length */ - int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ + char *ss_sp; /* signal stack base */ + size_t ss_size; /* signal stack length */ + int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ } stack_t; #define SS_ONSTACK 0x0001 /* take signal on alternate stack */ @@ -224,9 +234,7 @@ typedef struct sigaltstack { #define MINSIGSTKSZ 8192 /* minimum allowable stack */ #define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */ -/* - * Suck in definition of ucontext_t - */ +/* Have enough typedefs for this now. XXX */ #include <sys/ucontext.h> /* @@ -234,9 +242,9 @@ typedef struct sigaltstack { * Signal vector "template" used in sigvec call. */ struct sigvec { - __sighandler_t *sv_handler; /* signal handler */ - int sv_mask; /* signal mask to apply */ - int sv_flags; /* see signal options below */ + __sighandler_t *sv_handler; /* signal handler */ + int sv_mask; /* signal mask to apply */ + int sv_flags; /* see signal options below */ }; #define SV_ONSTACK SA_ONSTACK @@ -251,8 +259,8 @@ struct sigvec { * Structure used in sigstack call. */ struct sigstack { - char *ss_sp; /* signal stack pointer */ - int ss_onstack; /* current status */ + char *ss_sp; /* signal stack pointer */ + int ss_onstack; /* current status */ }; /* @@ -272,14 +280,16 @@ struct sigstack { #define SIG_UNBLOCK 2 /* unblock specified signal set */ #define SIG_SETMASK 3 /* set specified signal set */ +#ifndef _POSIX_SOURCE struct sigevent { - int sigev_notify; /* Notification type */ - int sigev_signo; /* Signal number */ - union sigval sigev_value; /* Signal value */ + int sigev_notify; /* Notification type */ + int sigev_signo; /* Signal number */ + union sigval sigev_value; /* Signal value */ }; #define SIGEV_NONE 0 /* No async notification */ #define SIGEV_SIGNAL 1 /* Generate a queued signal */ +#endif #endif /* !_ANSI_SOURCE */ |