1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28 29 #include <sys/param.h> 30 #include <sys/types.h> 31 #include <sys/sysmacros.h> 32 #include <sys/systm.h> 33 #include <sys/errno.h> 34 #include <sys/proc.h> 35 #include <sys/fault.h> 36 #include <sys/signal.h> 37 #include <sys/schedctl.h> 38 #include <sys/debug.h> 39 40 /* ARGSUSED4 */ 41 int64_t 42 lwp_sigmask(int how, uint_t bits0, uint_t bits1, uint_t bits2, uint_t bits3) 43 { 44 kthread_t *t = curthread; 45 proc_t *p = ttoproc(t); 46 rval_t rv; 47 48 /* 49 * We don't need to acquire p->p_lock here; 50 * we are manipulating thread-private data. 51 */ 52 53 schedctl_finish_sigblock(t); 54 55 bits0 &= (FILLSET0 & ~CANTMASK0); 56 bits1 &= (FILLSET1 & ~CANTMASK1); 57 bits2 &= (FILLSET2 & ~CANTMASK2); 58 59 /* 60 * As a sop to the s10 brand, we continue to return 61 * the first two words of the signal mask, regardless 62 * of the value of 'how', even though libc doesn't use them. 63 */ 64 rv.r_val1 = t->t_hold.__sigbits[0]; 65 rv.r_val2 = t->t_hold.__sigbits[1]; 66 67 switch (how) { 68 case SIG_BLOCK: 69 t->t_hold.__sigbits[0] |= bits0; 70 t->t_hold.__sigbits[1] |= bits1; 71 t->t_hold.__sigbits[2] |= bits2; 72 break; 73 case SIG_UNBLOCK: 74 t->t_hold.__sigbits[0] &= ~bits0; 75 t->t_hold.__sigbits[1] &= ~bits1; 76 t->t_hold.__sigbits[2] &= ~bits2; 77 if (sigcheck(p, t)) 78 t->t_sig_check = 1; 79 break; 80 case SIG_SETMASK: 81 t->t_hold.__sigbits[0] = bits0; 82 t->t_hold.__sigbits[1] = bits1; 83 t->t_hold.__sigbits[2] = bits2; 84 if (sigcheck(p, t)) 85 t->t_sig_check = 1; 86 break; 87 } 88 89 return (rv.r_vals); 90 } 91 92 int 93 sigprocmask(int how, sigset_t *setp, sigset_t *osetp) 94 { 95 sigset_t set; 96 sigset_t oset; 97 k_sigset_t kset; 98 99 /* 100 * User's osetp and setp might be the same address, 101 * so copyin first and save before copying out. 102 */ 103 if (setp) { 104 switch (how) { 105 case SIG_BLOCK: 106 case SIG_UNBLOCK: 107 case SIG_SETMASK: 108 break; 109 default: 110 return (set_errno(EINVAL)); 111 } 112 if (copyin((caddr_t)setp, (caddr_t)&set, sizeof (sigset_t))) 113 return (set_errno(EFAULT)); 114 sigutok(&set, &kset); 115 } 116 117 if (osetp) { 118 sigktou(&curthread->t_hold, &oset); 119 if (copyout((caddr_t)&oset, (caddr_t)osetp, sizeof (sigset_t))) 120 return (set_errno(EFAULT)); 121 } 122 123 if (setp) { 124 (void) lwp_sigmask(how, 125 kset.__sigbits[0], 126 kset.__sigbits[1], 127 kset.__sigbits[2], 128 0); 129 } 130 131 return (0); 132 } 133