diff options
author | marcel <marcel@FreeBSD.org> | 1999-09-29 15:12:18 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 1999-09-29 15:12:18 +0000 |
commit | bd000d73ad75473ad7201663ffb27c36ab130f0e (patch) | |
tree | bc01945dc4b7113b39c954abf475834f0e086487 /sys/i386/ibcs2 | |
parent | a16d76cb5680cf0afd1a3be9be9d1f7ea686a96c (diff) | |
download | FreeBSD-src-bd000d73ad75473ad7201663ffb27c36ab130f0e.zip FreeBSD-src-bd000d73ad75473ad7201663ffb27c36ab130f0e.tar.gz |
sigset_t change (part 4 of 5)
-----------------------------
The compatibility code and/or emulators have been updated:
iBCS2 now mostly uses the older syscalls. SVR4 now properly
handles all signals. This has been achieved by using the
new sigset_t throughout the emulator. The Linuxulator has
been severely updated. Internally the new Linux sigset_t is
made the default. These are then mapped to and from the
new FreeBSD sigset_t.
Also, rt_sigsuspend has been implemented in the Linuxulator.
Implementing this syscall basicly caused all this sigset_t
changing in the first place and the syscall has been used
throughout the change as a means for testing. It basicly is
too much work to undo the implementation so that it can
later be added again.
A special note on the use of sv_sigtbl and sv_sigsize in
struct sysentvec:
Every signal larger than sv_sigsize is not translated and is
passed on to the signal handler unmodified. Signals in the
range 1 upto and including sv_sigsize are translated.
The rationale is that only the system defined signals need to
be translated.
The emulators also have been updated so that the translation
tables are only indexed for valid (system defined) signals.
This change also fixes the translation bug already in the
SVR4 emulator.
Diffstat (limited to 'sys/i386/ibcs2')
-rw-r--r-- | sys/i386/ibcs2/ibcs2_misc.c | 4 | ||||
-rw-r--r-- | sys/i386/ibcs2/ibcs2_signal.c | 90 | ||||
-rw-r--r-- | sys/i386/ibcs2/ibcs2_signal.h | 3 | ||||
-rw-r--r-- | sys/i386/ibcs2/ibcs2_sysvec.c | 5 |
4 files changed, 57 insertions, 45 deletions
diff --git a/sys/i386/ibcs2/ibcs2_misc.c b/sys/i386/ibcs2/ibcs2_misc.c index cea6b15..de67da4 100644 --- a/sys/i386/ibcs2/ibcs2_misc.c +++ b/sys/i386/ibcs2/ibcs2_misc.c @@ -167,9 +167,9 @@ ibcs2_wait(p, uap) /* convert status/signal result */ if(WIFSTOPPED(status)) status = - IBCS2_STOPCODE(bsd_to_ibcs2_sig[WSTOPSIG(status)]); + IBCS2_STOPCODE(bsd_to_ibcs2_sig[_SIG_IDX(WSTOPSIG(status))]); else if(WIFSIGNALED(status)) - status = bsd_to_ibcs2_sig[WTERMSIG(status)]; + status = bsd_to_ibcs2_sig[_SIG_IDX(WTERMSIG(status))]; /* else exit status -- identical */ /* record result/status */ diff --git a/sys/i386/ibcs2/ibcs2_signal.c b/sys/i386/ibcs2/ibcs2_signal.c index fa111fa..8aacade 100644 --- a/sys/i386/ibcs2/ibcs2_signal.c +++ b/sys/i386/ibcs2/ibcs2_signal.c @@ -39,9 +39,9 @@ #include <i386/ibcs2/ibcs2_xenix.h> #include <i386/ibcs2/ibcs2_util.h> -#define sigemptyset(s) bzero((s), sizeof(*(s))) -#define sigismember(s, n) (*(s) & sigmask(n)) -#define sigaddset(s, n) (*(s) |= sigmask(n)) +#define sigemptyset(s) SIGEMPTYSET(*(s)) +#define sigismember(s, n) SIGISMEMBER(*(s), n) +#define sigaddset(s, n) SIGADDSET(*(s), n) #define ibcs2_sigmask(n) (1 << ((n) - 1)) #define ibcs2_sigemptyset(s) bzero((s), sizeof(*(s))) @@ -55,8 +55,7 @@ static void ibcs2_to_bsd_sigaction __P((struct ibcs2_sigaction *, static void bsd_to_ibcs2_sigaction __P((struct sigaction *, struct ibcs2_sigaction *)); -int bsd_to_ibcs2_sig[] = { - 0, /* 0 */ +int bsd_to_ibcs2_sig[IBCS2_SIGTBLSZ] = { IBCS2_SIGHUP, /* 1 */ IBCS2_SIGINT, /* 2 */ IBCS2_SIGQUIT, /* 3 */ @@ -88,10 +87,10 @@ int bsd_to_ibcs2_sig[] = { 0, /* 29 */ IBCS2_SIGUSR1, /* 30 */ IBCS2_SIGUSR2, /* 31 */ + 0 /* 32 */ }; -static int ibcs2_to_bsd_sig[] = { - 0, /* 0 */ +static int ibcs2_to_bsd_sig[IBCS2_SIGTBLSZ] = { SIGHUP, /* 1 */ SIGINT, /* 2 */ SIGQUIT, /* 3 */ @@ -123,6 +122,7 @@ static int ibcs2_to_bsd_sig[] = { SIGPROF, /* 29 */ 0, /* 30 */ 0, /* 31 */ + 0 /* 32 */ }; void @@ -133,9 +133,9 @@ ibcs2_to_bsd_sigset(iss, bss) int i, newsig; sigemptyset(bss); - for (i = 1; i < IBCS2_NSIG; i++) { + for (i = 1; i <= IBCS2_SIGTBLSZ; i++) { if (ibcs2_sigismember(iss, i)) { - newsig = ibcs2_to_bsd_sig[i]; + newsig = ibcs2_to_bsd_sig[_SIG_IDX(i)]; if (newsig) sigaddset(bss, newsig); } @@ -150,9 +150,9 @@ bsd_to_ibcs2_sigset(bss, iss) int i, newsig; ibcs2_sigemptyset(iss); - for (i = 1; i < NSIG; i++) { + for (i = 1; i <= IBCS2_SIGTBLSZ; i++) { if (sigismember(bss, i)) { - newsig = bsd_to_ibcs2_sig[i]; + newsig = bsd_to_ibcs2_sig[_SIG_IDX(i)]; if (newsig) ibcs2_sigaddset(iss, newsig); } @@ -215,9 +215,9 @@ ibcs2_sigaction(p, uap) } else nbsa = NULL; - SCARG(&sa, signum) = ibcs2_to_bsd_sig[SCARG(uap, sig)]; - SCARG(&sa, nsa) = nbsa; - SCARG(&sa, osa) = obsa; + SCARG(&sa, sig) = ibcs2_to_bsd_sig[_SIG_IDX(SCARG(uap, sig))]; + SCARG(&sa, act) = nbsa; + SCARG(&sa, oact) = obsa; if ((error = sigaction(p, &sa)) != 0) return error; @@ -239,7 +239,7 @@ ibcs2_sigsys(p, uap) struct ibcs2_sigsys_args *uap; { struct sigaction sa; - int signum = ibcs2_to_bsd_sig[IBCS2_SIGNO(SCARG(uap, sig))]; + int signum = ibcs2_to_bsd_sig[_SIG_IDX(IBCS2_SIGNO(SCARG(uap, sig)))]; int error; caddr_t sg = stackgap_init(); @@ -265,11 +265,11 @@ ibcs2_sigsys(p, uap) case IBCS2_SIGHOLD_MASK: { - struct sigprocmask_args sa; + struct osigprocmask_args sa; SCARG(&sa, how) = SIG_BLOCK; SCARG(&sa, mask) = sigmask(signum); - return sigprocmask(p, &sa); + return osigprocmask(p, &sa); } case IBCS2_SIGNAL_MASK: @@ -289,9 +289,9 @@ ibcs2_sigsys(p, uap) ibcs2_sigset: nbsa = stackgap_alloc(&sg, sizeof(struct sigaction)); obsa = stackgap_alloc(&sg, sizeof(struct sigaction)); - SCARG(&sa_args, signum) = signum; - SCARG(&sa_args, nsa) = nbsa; - SCARG(&sa_args, osa) = obsa; + SCARG(&sa_args, sig) = signum; + SCARG(&sa_args, act) = nbsa; + SCARG(&sa_args, oact) = obsa; sa.sa_handler = SCARG(uap, fp); sigemptyset(&sa.sa_mask); @@ -319,7 +319,7 @@ ibcs2_sigsys(p, uap) if(sigismember(&p->p_sigmask, signum)) { /* return SIG_HOLD and unblock signal*/ p->p_retval[0] = (int)IBCS2_SIG_HOLD; - p->p_sigmask &= ~sigmask(signum); + SIGDELSET(p->p_sigmask, signum); } return 0; @@ -327,11 +327,11 @@ ibcs2_sigsys(p, uap) case IBCS2_SIGRELSE_MASK: { - struct sigprocmask_args sa; + struct osigprocmask_args sa; SCARG(&sa, how) = SIG_UNBLOCK; SCARG(&sa, mask) = sigmask(signum); - return sigprocmask(p, &sa); + return osigprocmask(p, &sa); } case IBCS2_SIGIGNORE_MASK: @@ -340,9 +340,9 @@ ibcs2_sigsys(p, uap) struct sigaction *bsa; bsa = stackgap_alloc(&sg, sizeof(struct sigaction)); - SCARG(&sa_args, signum) = signum; - SCARG(&sa_args, nsa) = bsa; - SCARG(&sa_args, osa) = NULL; + SCARG(&sa_args, sig) = signum; + SCARG(&sa_args, act) = bsa; + SCARG(&sa_args, oact) = NULL; sa.sa_handler = SIG_IGN; sigemptyset(&sa.sa_mask); @@ -358,10 +358,12 @@ ibcs2_sigsys(p, uap) case IBCS2_SIGPAUSE_MASK: { - struct sigsuspend_args sa; + osigset_t mask; + struct osigsuspend_args sa; - SCARG(&sa, mask) = p->p_sigmask &~ sigmask(signum); - return sigsuspend(p, &sa); + SIG2OSIG(p->p_sigmask, mask); + SCARG(&sa, mask) = mask &~ sigmask(signum); + return osigsuspend(p, &sa); } default: @@ -398,15 +400,17 @@ ibcs2_sigprocmask(p, uap) switch (SCARG(uap, how)) { case IBCS2_SIG_BLOCK: - p->p_sigmask |= bss & ~sigcantmask; + SIGSETOR(p->p_sigmask, bss); + SIG_CANTMASK(p->p_sigmask); break; case IBCS2_SIG_UNBLOCK: - p->p_sigmask &= ~bss; + SIGSETNAND(p->p_sigmask, bss); break; case IBCS2_SIG_SETMASK: - p->p_sigmask = bss & ~sigcantmask; + p->p_sigmask = bss; + SIG_CANTMASK(p->p_sigmask); break; default: @@ -427,7 +431,8 @@ ibcs2_sigpending(p, uap) sigset_t bss; ibcs2_sigset_t iss; - bss = p->p_siglist & p->p_sigmask; + bss = p->p_siglist; + SIGSETAND(bss, p->p_sigmask); bsd_to_ibcs2_sigset(&bss, &iss); return copyout(&iss, SCARG(uap, mask), sizeof(iss)); @@ -440,16 +445,17 @@ ibcs2_sigsuspend(p, uap) { ibcs2_sigset_t sss; sigset_t bss; - struct sigsuspend_args sa; + osigset_t mask; + struct osigsuspend_args sa; int error; if ((error = copyin(SCARG(uap, mask), &sss, sizeof(sss))) != 0) return error; ibcs2_to_bsd_sigset(&sss, &bss); - - SCARG(&sa, mask) = bss; - return sigsuspend(p, &sa); + SIG2OSIG(bss, mask); + SCARG(&sa, mask) = mask; + return osigsuspend(p, &sa); } int @@ -457,10 +463,12 @@ ibcs2_pause(p, uap) register struct proc *p; struct ibcs2_pause_args *uap; { - struct sigsuspend_args bsa; + struct osigsuspend_args bsa; + osigset_t mask; - SCARG(&bsa, mask) = p->p_sigmask; - return sigsuspend(p, &bsa); + SIG2OSIG(p->p_sigmask, mask); + SCARG(&bsa, mask) = mask; + return osigsuspend(p, &bsa); } int @@ -471,6 +479,6 @@ ibcs2_kill(p, uap) struct kill_args ka; SCARG(&ka, pid) = SCARG(uap, pid); - SCARG(&ka, signum) = ibcs2_to_bsd_sig[SCARG(uap, signo)]; + SCARG(&ka, signum) = ibcs2_to_bsd_sig[_SIG_IDX(SCARG(uap, signo))]; return kill(p, &ka); } diff --git a/sys/i386/ibcs2/ibcs2_signal.h b/sys/i386/ibcs2/ibcs2_signal.h index a81fc7b..2eadf6c 100644 --- a/sys/i386/ibcs2/ibcs2_signal.h +++ b/sys/i386/ibcs2/ibcs2_signal.h @@ -28,6 +28,8 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ */ #ifndef _IBCS2_SIGNAL_H @@ -56,6 +58,7 @@ #define IBCS2_SIGWINCH 20 #define IBCS2_SIGPOLL 22 #define IBCS2_NSIG 32 +#define IBCS2_SIGTBLSZ 32 /* * SCO-specific diff --git a/sys/i386/ibcs2/ibcs2_sysvec.c b/sys/i386/ibcs2/ibcs2_sysvec.c index bed71d6..b1717f4 100644 --- a/sys/i386/ibcs2/ibcs2_sysvec.c +++ b/sys/i386/ibcs2/ibcs2_sysvec.c @@ -36,9 +36,10 @@ #include <sys/sysent.h> #include <sys/signalvar.h> #include <sys/proc.h> + #include <i386/ibcs2/ibcs2_syscall.h> +#include <i386/ibcs2/ibcs2_signal.h> -extern int bsd_to_ibcs2_sig[]; extern int bsd_to_ibcs2_errno[]; extern struct sysent ibcs2_sysent[IBCS2_SYS_MAXSYSCALL]; extern int szsigcode; @@ -48,7 +49,7 @@ struct sysentvec ibcs2_svr3_sysvec = { sizeof (ibcs2_sysent) / sizeof (ibcs2_sysent[0]), ibcs2_sysent, 0xFF, - NSIG, + IBCS2_SIGTBLSZ, bsd_to_ibcs2_sig, ELAST + 1, bsd_to_ibcs2_errno, |