From f16647740eff2741bdd0336c54928c766596d03a Mon Sep 17 00:00:00 2001 From: Andrew Gallatin Date: Fri, 10 Nov 2000 23:00:54 +0000 Subject: [PATCH] Simplify and correct OSF/1 signal handling. - No signal translation is needed. Our signals match the OSF/1 signals - an OSF/1 sigset_t is 64 bits. Make certain to use all 64-bits of it. We'd previously only used the lower 32 bits. This was mostly harmless as I don't know of an OSF/1 apps which use any signals > 31. However, the alpha Linux ABI uses the osf/1 signal routines and threaded linux apps tyically use signals 32 and 33 to comminicate with the manager thread, so it is important we preserve the upper 32-bits. Reviewed by: marcel (at least in principal) --- sys/alpha/osf1/osf1_signal.c | 105 +++++------------------------------ sys/alpha/osf1/osf1_signal.h | 40 +------------ sys/alpha/osf1/osf1_sysvec.c | 4 +- 3 files changed, 16 insertions(+), 133 deletions(-) diff --git a/sys/alpha/osf1/osf1_signal.c b/sys/alpha/osf1/osf1_signal.c index 5dd585ff9b7f..738b0a45d055 100644 --- a/sys/alpha/osf1/osf1_signal.c +++ b/sys/alpha/osf1/osf1_signal.c @@ -101,92 +101,18 @@ static void osf1_to_bsd_sigaction __P((const struct osf1_sigaction *osa, #define osf1_sigismember(s, n) (*(s) & sigmask(n)) #define osf1_sigaddset(s, n) (*(s) |= sigmask(n)) -int bsd_to_osf1_sig[OSF1_SIGTBLSZ] = { - OSF1_SIGHUP, /* 1 */ - OSF1_SIGINT, /* 2 */ - OSF1_SIGQUIT, /* 3 */ - OSF1_SIGILL, /* 4 */ - OSF1_SIGTRAP, /* 5 */ - OSF1_SIGABRT, /* 6 */ - OSF1_SIGEMT, /* 7 */ - OSF1_SIGFPE, /* 8 */ - OSF1_SIGKILL, /* 9 */ - OSF1_SIGBUS, /* 10 */ - OSF1_SIGSEGV, /* 11 */ - OSF1_SIGSYS, /* 12 */ - OSF1_SIGPIPE, /* 13 */ - OSF1_SIGALRM, /* 14 */ - OSF1_SIGTERM, /* 15 */ - OSF1_SIGURG, /* 16 */ - OSF1_SIGSTOP, /* 17 */ - OSF1_SIGTSTP, /* 18 */ - OSF1_SIGCONT, /* 19 */ - OSF1_SIGCHLD, /* 20 */ - OSF1_SIGTTIN, /* 21 */ - OSF1_SIGTTOU, /* 22 */ - OSF1_SIGIO, /* 23 */ - OSF1_SIGXCPU, /* 24 */ - OSF1_SIGXFSZ, /* 25 */ - OSF1_SIGVTALRM, /* 26 */ - OSF1_SIGPROF, /* 27 */ - OSF1_SIGWINCH, /* 28 */ - OSF1_SIGINFO, /* 29 */ - OSF1_SIGUSR1, /* 30 */ - OSF1_SIGUSR2, /* 31 */ - 0 /* 32 */ -}; - -int osf1_to_bsd_sig[OSF1_SIGTBLSZ] = { - SIGHUP, /* 1 */ - SIGINT, /* 2 */ - SIGQUIT, /* 3 */ - SIGILL, /* 4 */ - SIGTRAP, /* 5 */ - SIGABRT, /* 6 */ - SIGEMT, /* 7 */ - SIGFPE, /* 8 */ - SIGKILL, /* 9 */ - SIGBUS, /* 10 */ - SIGSEGV, /* 11 */ - SIGSYS, /* 12 */ - SIGPIPE, /* 13 */ - SIGALRM, /* 14 */ - SIGTERM, /* 15 */ - SIGURG, /* 16 */ - SIGSTOP, /* 17 */ - SIGTSTP, /* 18 */ - SIGCONT, /* 19 */ - SIGCHLD, /* 20 */ - SIGTTIN, /* 21 */ - SIGTTOU, /* 22 */ - SIGIO, /* 23 */ - SIGXCPU, /* 24 */ - SIGXFSZ, /* 25 */ - SIGVTALRM, /* 26 */ - SIGPROF, /* 27 */ - SIGWINCH, /* 28 */ - SIGINFO, /* 29 */ - SIGUSR1, /* 30 */ - SIGUSR2, /* 31 */ - 0 /* 32 */ -}; - void osf1_to_bsd_sigset(oss, bss) const osf1_sigset_t *oss; sigset_t *bss; { - int i, newsig; + const u_int32_t *obits; SIGEMPTYSET(*bss); - for (i = 1; i <= OSF1_SIGTBLSZ; i++) { - if (osf1_sigismember(oss, i)) { - newsig = osf1_to_bsd_sig[_SIG_IDX(i)]; - if (newsig) - SIGADDSET(*bss, newsig); - } - } + obits = (const u_int32_t *)oss; + bss->__bits[0] = obits[0]; + bss->__bits[1] = obits[1]; } void @@ -194,17 +120,12 @@ bsd_to_osf1_sigset(bss, oss) const sigset_t *bss; osf1_sigset_t *oss; { - int i, newsig; + u_int32_t *obits; osf1_sigemptyset(oss); - for (i = 1; i <= OSF1_SIGTBLSZ; i++) { - if (SIGISMEMBER(*bss, i)) { - newsig = bsd_to_osf1_sig[_SIG_IDX(i)]; - if (newsig) - osf1_sigaddset(oss, newsig); - } - } - + obits = (u_int32_t *)oss; + obits[0] = bss->__bits[0]; + obits[1] = bss->__bits[1]; } /* @@ -319,7 +240,7 @@ osf1_sigaction(p, uap) } else nbsa = NULL; - SCARG(&sa, sig) = OSF1_OSF12BSD_SIG(SCARG(uap, signum)); + SCARG(&sa, sig) = SCARG(uap, signum); SCARG(&sa, act) = nbsa; SCARG(&sa, oact) = obsa; @@ -394,7 +315,7 @@ osf1_signal(p, uap) sg = stackgap_init(); - signum = OSF1_OSF12BSD_SIG(OSF1_SIGNO(SCARG(uap, signum))); + signum = OSF1_SIGNO(SCARG(uap, signum)); if (signum <= 0 || signum > OSF1_NSIG) { if (OSF1_SIGCALL(SCARG(uap, signum)) == OSF1_SIGNAL_MASK || OSF1_SIGCALL(SCARG(uap, signum)) == OSF1_SIGDEFER_MASK) @@ -635,7 +556,7 @@ osf1_kill(p, uap) struct kill_args ka; SCARG(&ka, pid) = SCARG(uap, pid); - SCARG(&ka, signum) = OSF1_OSF12BSD_SIG(SCARG(uap, signum)); + SCARG(&ka, signum) = SCARG(uap, signum); return kill(p, &ka); } @@ -698,7 +619,7 @@ osf1_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) * Build the signal context to be used by sigreturn. */ ksi.si_sc.sc_onstack = oonstack; - SIG2OSIG(*mask, ksi.si_sc.sc_mask); + bsd_to_osf1_sigset(mask, &ksi.si_sc.sc_mask); ksi.si_sc.sc_pc = frame->tf_regs[FRAME_PC]; ksi.si_sc.sc_ps = frame->tf_regs[FRAME_PS]; @@ -787,7 +708,7 @@ osf1_sigreturn(struct proc *p, * sigmask is stored in sc_reserved, sc_mask is only used for * backward compatibility. */ - SIGSETOLD(p->p_sigmask, ksc.sc_mask); + osf1_to_bsd_sigset(&ksc.sc_mask, &p->p_sigmask); SIG_CANTMASK(p->p_sigmask); set_regs(p, (struct reg *)ksc.sc_regs); diff --git a/sys/alpha/osf1/osf1_signal.h b/sys/alpha/osf1/osf1_signal.h index 7983242f38ad..2559f67d1b4e 100644 --- a/sys/alpha/osf1/osf1_signal.h +++ b/sys/alpha/osf1/osf1_signal.h @@ -3,39 +3,7 @@ #ifndef _OSF1_SIGNAL_H #define _OSF1_SIGNAL_H -#define OSF1_SIGHUP 1 -#define OSF1_SIGINT 2 -#define OSF1_SIGQUIT 3 -#define OSF1_SIGILL 4 -#define OSF1_SIGTRAP 5 -#define OSF1_SIGABRT 6 -#define OSF1_SIGEMT 7 -#define OSF1_SIGFPE 8 -#define OSF1_SIGKILL 9 -#define OSF1_SIGBUS 10 -#define OSF1_SIGSEGV 11 -#define OSF1_SIGSYS 12 -#define OSF1_SIGPIPE 13 -#define OSF1_SIGALRM 14 -#define OSF1_SIGTERM 15 -#define OSF1_SIGURG 16 -#define OSF1_SIGSTOP 17 -#define OSF1_SIGTSTP 18 -#define OSF1_SIGCONT 19 -#define OSF1_SIGCHLD 20 -#define OSF1_SIGTTIN 21 -#define OSF1_SIGTTOU 22 -#define OSF1_SIGIO 23 -#define OSF1_SIGXCPU 24 -#define OSF1_SIGXFSZ 25 -#define OSF1_SIGVTALRM 26 -#define OSF1_SIGPROF 27 -#define OSF1_SIGWINCH 28 -#define OSF1_SIGINFO 29 -#define OSF1_SIGUSR1 30 -#define OSF1_SIGUSR2 31 -#define OSF1_NSIG 32 -#define OSF1_SIGTBLSZ 32 +#define OSF1_NSIG 64 #define OSF1_SIG_DFL 0 #define OSF1_SIG_ERR -1 @@ -50,12 +18,6 @@ #define OSF1_SIG_SETMASK 3 -#define OSF1_BSD2OSF1_SIG(sig) \ - (((sig) <= OSF1_SIGTBLSZ) ? bsd_to_osf1_sig[_SIG_IDX(sig)] : sig) -#define OSF1_OSF12BSD_SIG(sig) \ - (((sig) <= OSF1_SIGTBLSZ) ? osf1_to_bsd_sig[_SIG_IDX(sig)] : sig) - - typedef u_long osf1_sigset_t; typedef void (*osf1_handler_t) __P((int)); diff --git a/sys/alpha/osf1/osf1_sysvec.c b/sys/alpha/osf1/osf1_sysvec.c index b89375a133d3..540ab7bd27e9 100644 --- a/sys/alpha/osf1/osf1_sysvec.c +++ b/sys/alpha/osf1/osf1_sysvec.c @@ -63,8 +63,8 @@ struct sysentvec osf1_sysvec = { OSF1_SYS_MAXSYSCALL, osf1_sysent, 0x0, - NSIG, - bsd_to_osf1_sig, + 0, + 0, 0, 0, 0, /* trap-to-signal translation function */