svr4_signal.c (54305) | svr4_signal.c (56046) |
---|---|
1/* 2 * Copyright (c) 1998 Mark Newton 3 * Copyright (c) 1994 Christos Zoulas 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * | 1/* 2 * Copyright (c) 1998 Mark Newton 3 * Copyright (c) 1994 Christos Zoulas 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/sys/compat/svr4/svr4_signal.c 54305 1999-12-08 12:01:59Z newton $ | 28 * $FreeBSD: head/sys/compat/svr4/svr4_signal.c 56046 2000-01-15 15:38:17Z newton $ |
29 */ 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/proc.h> 34#include <sys/filedesc.h> 35#include <sys/signal.h> 36#include <sys/signalvar.h> --- 4 unchanged lines hidden (view full) --- 41#include <svr4/svr4_signal.h> 42#include <svr4/svr4_proto.h> 43#include <svr4/svr4_util.h> 44#include <svr4/svr4_ucontext.h> 45 46#define svr4_sigmask(n) (1 << (((n) - 1) & 31)) 47#define svr4_sigword(n) (((n) - 1) >> 5) 48#define svr4_sigemptyset(s) memset((s), 0, sizeof(*(s))) | 29 */ 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/proc.h> 34#include <sys/filedesc.h> 35#include <sys/signal.h> 36#include <sys/signalvar.h> --- 4 unchanged lines hidden (view full) --- 41#include <svr4/svr4_signal.h> 42#include <svr4/svr4_proto.h> 43#include <svr4/svr4_util.h> 44#include <svr4/svr4_ucontext.h> 45 46#define svr4_sigmask(n) (1 << (((n) - 1) & 31)) 47#define svr4_sigword(n) (((n) - 1) >> 5) 48#define svr4_sigemptyset(s) memset((s), 0, sizeof(*(s))) |
49#define svr4_sigfillset(s) memset((s), 0xffffffff, sizeof(*(s))) | |
50#define svr4_sigismember(s, n) ((s)->bits[svr4_sigword(n)] & svr4_sigmask(n)) 51#define svr4_sigaddset(s, n) ((s)->bits[svr4_sigword(n)] |= svr4_sigmask(n)) 52 53void svr4_to_bsd_sigaction __P((const struct svr4_sigaction *, 54 struct sigaction *)); 55void bsd_to_svr4_sigaction __P((const struct sigaction *, 56 struct svr4_sigaction *)); | 49#define svr4_sigismember(s, n) ((s)->bits[svr4_sigword(n)] & svr4_sigmask(n)) 50#define svr4_sigaddset(s, n) ((s)->bits[svr4_sigword(n)] |= svr4_sigmask(n)) 51 52void svr4_to_bsd_sigaction __P((const struct svr4_sigaction *, 53 struct sigaction *)); 54void bsd_to_svr4_sigaction __P((const struct sigaction *, 55 struct svr4_sigaction *)); |
56void svr4_sigfillset __P((svr4_sigset_t *)); |
|
57 58int bsd_to_svr4_sig[SVR4_SIGTBLSZ] = { 59 SVR4_SIGHUP, 60 SVR4_SIGINT, 61 SVR4_SIGQUIT, 62 SVR4_SIGILL, 63 SVR4_SIGTRAP, 64 SVR4_SIGABRT, --- 54 unchanged lines hidden (view full) --- 119 SIGTTOU, 120 SIGVTALRM, 121 SIGPROF, 122 SIGXCPU, 123 SIGXFSZ, 124}; 125 126void | 57 58int bsd_to_svr4_sig[SVR4_SIGTBLSZ] = { 59 SVR4_SIGHUP, 60 SVR4_SIGINT, 61 SVR4_SIGQUIT, 62 SVR4_SIGILL, 63 SVR4_SIGTRAP, 64 SVR4_SIGABRT, --- 54 unchanged lines hidden (view full) --- 119 SIGTTOU, 120 SIGVTALRM, 121 SIGPROF, 122 SIGXCPU, 123 SIGXFSZ, 124}; 125 126void |
127svr4_sigfillset(s) 128 svr4_sigset_t *s; 129{ 130 int i; 131 132 svr4_sigemptyset(s); 133 for (i = 0; i < SVR4_NSIG; i++) 134 if (svr4_to_bsd_sig[i] != 0) 135 svr4_sigaddset(s, i); 136} 137 138void |
|
127svr4_to_bsd_sigset(sss, bss) 128 const svr4_sigset_t *sss; 129 sigset_t *bss; 130{ 131 int i, newsig; 132 133 SIGEMPTYSET(*bss); | 139svr4_to_bsd_sigset(sss, bss) 140 const svr4_sigset_t *sss; 141 sigset_t *bss; 142{ 143 int i, newsig; 144 145 SIGEMPTYSET(*bss); |
134 bss->__bits[0] = sss->bits[0] & ~((1U << SVR4_SIGTBLSZ) - 1); 135 bss->__bits[1] = sss->bits[1]; 136 bss->__bits[2] = sss->bits[2]; 137 bss->__bits[3] = sss->bits[3]; 138 for (i = 1; i <= SVR4_SIGTBLSZ; i++) { 139 if (svr4_sigismember(sss, i)) { 140 newsig = svr4_to_bsd_sig[_SIG_IDX(i)]; | 146 for (i = 0; i < SVR4_NSIG; i++) 147 if (svr4_sigismember(sss, i + 1)) { 148 newsig = svr4_to_bsd_sig[i]; |
141 if (newsig) 142 SIGADDSET(*bss, newsig); 143 } | 149 if (newsig) 150 SIGADDSET(*bss, newsig); 151 } |
144 } | |
145} 146 147void 148bsd_to_svr4_sigset(bss, sss) 149 const sigset_t *bss; 150 svr4_sigset_t *sss; 151{ 152 int i, newsig; --- 101 unchanged lines hidden (view full) --- 254 struct svr4_sys_sigaction_args *uap; 255{ 256 struct svr4_sigaction *nisa, *oisa, tmpisa; 257 struct sigaction *nbsa, *obsa, tmpbsa; 258 struct sigaction_args sa; 259 caddr_t sg; 260 int error; 261 | 152} 153 154void 155bsd_to_svr4_sigset(bss, sss) 156 const sigset_t *bss; 157 svr4_sigset_t *sss; 158{ 159 int i, newsig; --- 101 unchanged lines hidden (view full) --- 261 struct svr4_sys_sigaction_args *uap; 262{ 263 struct svr4_sigaction *nisa, *oisa, tmpisa; 264 struct sigaction *nbsa, *obsa, tmpbsa; 265 struct sigaction_args sa; 266 caddr_t sg; 267 int error; 268 |
269 DPRINTF(("@@@ svr4_sys_sigaction(%d, %d, %d)\n", p->p_pid, 270 SCARG(uap, signum), 271 SVR4_SVR42BSD_SIG(SCARG(uap, signum)))); 272 |
|
262 sg = stackgap_init(); 263 nisa = SCARG(uap, nsa); 264 oisa = SCARG(uap, osa); 265 266 if (oisa != NULL) 267 obsa = stackgap_alloc(&sg, sizeof(struct sigaction)); 268 else 269 obsa = NULL; 270 271 if (nisa != NULL) { 272 nbsa = stackgap_alloc(&sg, sizeof(struct sigaction)); 273 if ((error = copyin(nisa, &tmpisa, sizeof(tmpisa))) != 0) 274 return error; 275 svr4_to_bsd_sigaction(&tmpisa, &tmpbsa); 276 if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0) 277 return error; 278 } else 279 nbsa = NULL; 280 | 273 sg = stackgap_init(); 274 nisa = SCARG(uap, nsa); 275 oisa = SCARG(uap, osa); 276 277 if (oisa != NULL) 278 obsa = stackgap_alloc(&sg, sizeof(struct sigaction)); 279 else 280 obsa = NULL; 281 282 if (nisa != NULL) { 283 nbsa = stackgap_alloc(&sg, sizeof(struct sigaction)); 284 if ((error = copyin(nisa, &tmpisa, sizeof(tmpisa))) != 0) 285 return error; 286 svr4_to_bsd_sigaction(&tmpisa, &tmpbsa); 287 if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0) 288 return error; 289 } else 290 nbsa = NULL; 291 |
292#if defined(DEBUG_SVR4) 293 { 294 int i; 295 for (i = 0; i < 4; i++) 296 DPRINTF(("\tssa_mask[%d] = %lx\n", i, 297 nisa->ssa_mask.bits[i])); 298 DPRINTF(("\tssa_handler = %lx\n", nisa->ssa_handler)); 299 } 300#endif 301 |
|
281 SCARG(&sa, sig) = SVR4_SVR42BSD_SIG(SCARG(uap, signum)); 282 SCARG(&sa, act) = nbsa; 283 SCARG(&sa, oact) = obsa; 284 285 if ((error = sigaction(p, &sa)) != 0) 286 return error; 287 288 if (oisa != NULL) { --- 59 unchanged lines hidden (view full) --- 348 * Stolen from the ibcs2 one 349 */ 350int 351svr4_sys_signal(p, uap) 352 register struct proc *p; 353 struct svr4_sys_signal_args *uap; 354{ 355 int signum; | 302 SCARG(&sa, sig) = SVR4_SVR42BSD_SIG(SCARG(uap, signum)); 303 SCARG(&sa, act) = nbsa; 304 SCARG(&sa, oact) = obsa; 305 306 if ((error = sigaction(p, &sa)) != 0) 307 return error; 308 309 if (oisa != NULL) { --- 59 unchanged lines hidden (view full) --- 369 * Stolen from the ibcs2 one 370 */ 371int 372svr4_sys_signal(p, uap) 373 register struct proc *p; 374 struct svr4_sys_signal_args *uap; 375{ 376 int signum; |
356 int error, *retval; | 377 int error, *retval = p->p_retval; |
357 caddr_t sg = stackgap_init(); 358 | 378 caddr_t sg = stackgap_init(); 379 |
380 DPRINTF(("@@@ svr4_sys_signal(%d)\n", p->p_pid)); 381 |
|
359 signum = SVR4_SVR42BSD_SIG(SVR4_SIGNO(SCARG(uap, signum))); | 382 signum = SVR4_SVR42BSD_SIG(SVR4_SIGNO(SCARG(uap, signum))); |
360 retval = p->p_retval; | |
361 if (signum <= 0 || signum > SVR4_NSIG) 362 return (EINVAL); 363 364 switch (SVR4_SIGCALL(SCARG(uap, signum))) { 365 case SVR4_SIGDEFER_MASK: 366 if (SCARG(uap, handler) == SVR4_SIG_HOLD) 367 goto sighold; 368 /* FALLTHROUGH */ --- 156 unchanged lines hidden (view full) --- 525svr4_sys_sigpending(p, uap) 526 struct proc *p; 527 struct svr4_sys_sigpending_args *uap; 528{ 529 sigset_t bss; 530 int *retval; 531 svr4_sigset_t sss; 532 | 383 if (signum <= 0 || signum > SVR4_NSIG) 384 return (EINVAL); 385 386 switch (SVR4_SIGCALL(SCARG(uap, signum))) { 387 case SVR4_SIGDEFER_MASK: 388 if (SCARG(uap, handler) == SVR4_SIG_HOLD) 389 goto sighold; 390 /* FALLTHROUGH */ --- 156 unchanged lines hidden (view full) --- 547svr4_sys_sigpending(p, uap) 548 struct proc *p; 549 struct svr4_sys_sigpending_args *uap; 550{ 551 sigset_t bss; 552 int *retval; 553 svr4_sigset_t sss; 554 |
555 DPRINTF(("@@@ svr4_sys_sigpending(%d)\n", p->p_pid)); |
|
533 retval = p->p_retval; 534 switch (SCARG(uap, what)) { 535 case 1: /* sigpending */ 536 if (SCARG(uap, mask) == NULL) 537 return 0; 538 bss = p->p_siglist; 539 SIGSETAND(bss, p->p_sigmask); 540 bsd_to_svr4_sigset(&bss, &sss); 541 break; 542 543 case 2: /* sigfillset */ 544 svr4_sigfillset(&sss); | 556 retval = p->p_retval; 557 switch (SCARG(uap, what)) { 558 case 1: /* sigpending */ 559 if (SCARG(uap, mask) == NULL) 560 return 0; 561 bss = p->p_siglist; 562 SIGSETAND(bss, p->p_sigmask); 563 bsd_to_svr4_sigset(&bss, &sss); 564 break; 565 566 case 2: /* sigfillset */ 567 svr4_sigfillset(&sss); |
568#if defined(DEBUG_SVR4) 569 { 570 int i; 571 for (i = 0; i < 4; i++) 572 DPRINTF(("new sigset[%d] = %lx\n", i, (long)sss.bits[i])); 573 } 574#endif |
|
545 break; 546 547 default: 548 return EINVAL; 549 } 550 551 return copyout(&sss, SCARG(uap, mask), sizeof(sss)); 552} --- 47 unchanged lines hidden (view full) --- 600 svr4_getcontext(p, &uc, &p->p_sigmask, 601 p->p_sigstk.ss_flags & SS_ONSTACK); 602 return copyout(&uc, uap->uc, sizeof(uc)); 603 604 case 1: 605 DPRINTF(("setcontext(%p)\n", uap->uc)); 606 if ((error = copyin(uap->uc, &uc, sizeof(uc))) != 0) 607 return error; | 575 break; 576 577 default: 578 return EINVAL; 579 } 580 581 return copyout(&sss, SCARG(uap, mask), sizeof(sss)); 582} --- 47 unchanged lines hidden (view full) --- 630 svr4_getcontext(p, &uc, &p->p_sigmask, 631 p->p_sigstk.ss_flags & SS_ONSTACK); 632 return copyout(&uc, uap->uc, sizeof(uc)); 633 634 case 1: 635 DPRINTF(("setcontext(%p)\n", uap->uc)); 636 if ((error = copyin(uap->uc, &uc, sizeof(uc))) != 0) 637 return error; |
608 DPRINTF(("uc_flags = %x\n", uc.uc_flags)); 609 DPRINTF(("uc_sigmask = %x\n", uc.uc_sigmask)); 610 | 638 DPRINTF(("uc_flags = %lx\n", uc.uc_flags)); 639#if defined(DEBUG_SVR4) 640 { 641 int i; 642 for (i = 0; i < 4; i++) 643 DPRINTF(("uc_sigmask[%d] = %lx\n", i, 644 uc.uc_sigmask.bits[i])); 645 } 646#endif |
611 return svr4_setcontext(p, &uc); 612 613 default: 614 DPRINTF(("context(%d, %p)\n", uap->func, 615 uap->uc)); 616 return ENOSYS; 617 } 618 return 0; --- 12 unchanged lines hidden --- | 647 return svr4_setcontext(p, &uc); 648 649 default: 650 DPRINTF(("context(%d, %p)\n", uap->func, 651 uap->uc)); 652 return ENOSYS; 653 } 654 return 0; --- 12 unchanged lines hidden --- |