17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7be238fcSRoger A. Faulkner * Common Development and Distribution License (the "License"). 6*7be238fcSRoger A. Faulkner * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate 227c478bd9Sstevel@tonic-gate /* 23*7be238fcSRoger A. Faulkner * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 27*7be238fcSRoger A. Faulkner /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <sys/param.h> 307c478bd9Sstevel@tonic-gate #include <sys/types.h> 317c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 327c478bd9Sstevel@tonic-gate #include <sys/systm.h> 337c478bd9Sstevel@tonic-gate #include <sys/errno.h> 347c478bd9Sstevel@tonic-gate #include <sys/proc.h> 357c478bd9Sstevel@tonic-gate #include <sys/fault.h> 367c478bd9Sstevel@tonic-gate #include <sys/signal.h> 377c478bd9Sstevel@tonic-gate #include <sys/schedctl.h> 387c478bd9Sstevel@tonic-gate #include <sys/debug.h> 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate int64_t 417c478bd9Sstevel@tonic-gate lwp_sigmask(int how, uint_t bits0, uint_t bits1) 427c478bd9Sstevel@tonic-gate { 437c478bd9Sstevel@tonic-gate kthread_t *t = curthread; 447c478bd9Sstevel@tonic-gate proc_t *p = ttoproc(t); 457c478bd9Sstevel@tonic-gate rval_t rv; 467c478bd9Sstevel@tonic-gate 47*7be238fcSRoger A. Faulkner /* 48*7be238fcSRoger A. Faulkner * We don't need to acquire p->p_lock here; 49*7be238fcSRoger A. Faulkner * we are manipulating thread-private data. 50*7be238fcSRoger A. Faulkner */ 51*7be238fcSRoger A. Faulkner 527c478bd9Sstevel@tonic-gate schedctl_finish_sigblock(t); 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate bits0 &= (FILLSET0 & ~CANTMASK0); 557c478bd9Sstevel@tonic-gate bits1 &= (FILLSET1 & ~CANTMASK1); 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate rv.r_val1 = t->t_hold.__sigbits[0]; 587c478bd9Sstevel@tonic-gate rv.r_val2 = t->t_hold.__sigbits[1]; 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate switch (how) { 617c478bd9Sstevel@tonic-gate case SIG_BLOCK: 627c478bd9Sstevel@tonic-gate t->t_hold.__sigbits[0] |= bits0; 637c478bd9Sstevel@tonic-gate t->t_hold.__sigbits[1] |= bits1; 647c478bd9Sstevel@tonic-gate break; 657c478bd9Sstevel@tonic-gate case SIG_UNBLOCK: 667c478bd9Sstevel@tonic-gate t->t_hold.__sigbits[0] &= ~bits0; 677c478bd9Sstevel@tonic-gate t->t_hold.__sigbits[1] &= ~bits1; 687c478bd9Sstevel@tonic-gate if (sigcheck(p, t)) 697c478bd9Sstevel@tonic-gate t->t_sig_check = 1; 707c478bd9Sstevel@tonic-gate break; 717c478bd9Sstevel@tonic-gate case SIG_SETMASK: 727c478bd9Sstevel@tonic-gate t->t_hold.__sigbits[0] = bits0; 737c478bd9Sstevel@tonic-gate t->t_hold.__sigbits[1] = bits1; 747c478bd9Sstevel@tonic-gate if (sigcheck(p, t)) 757c478bd9Sstevel@tonic-gate t->t_sig_check = 1; 767c478bd9Sstevel@tonic-gate break; 777c478bd9Sstevel@tonic-gate } 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate return (rv.r_vals); 807c478bd9Sstevel@tonic-gate } 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* 837c478bd9Sstevel@tonic-gate * This system call is no longer called from libc. 847c478bd9Sstevel@tonic-gate * It exists solely for the benefit of statically-linked 857c478bd9Sstevel@tonic-gate * binaries from the past. It should be eliminated. 867c478bd9Sstevel@tonic-gate */ 877c478bd9Sstevel@tonic-gate int 887c478bd9Sstevel@tonic-gate sigprocmask(int how, sigset_t *setp, sigset_t *osetp) 897c478bd9Sstevel@tonic-gate { 907c478bd9Sstevel@tonic-gate sigset_t set; 917c478bd9Sstevel@tonic-gate k_sigset_t kset; 927c478bd9Sstevel@tonic-gate rval_t rv; 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate /* 957c478bd9Sstevel@tonic-gate * User's oset and set might be the same address, so copyin first and 967c478bd9Sstevel@tonic-gate * save before copying out. 977c478bd9Sstevel@tonic-gate */ 987c478bd9Sstevel@tonic-gate if (setp) { 997c478bd9Sstevel@tonic-gate switch (how) { 1007c478bd9Sstevel@tonic-gate case SIG_BLOCK: 1017c478bd9Sstevel@tonic-gate case SIG_UNBLOCK: 1027c478bd9Sstevel@tonic-gate case SIG_SETMASK: 1037c478bd9Sstevel@tonic-gate break; 1047c478bd9Sstevel@tonic-gate default: 1057c478bd9Sstevel@tonic-gate return (set_errno(EINVAL)); 1067c478bd9Sstevel@tonic-gate } 1077c478bd9Sstevel@tonic-gate if (copyin((caddr_t)setp, (caddr_t)&set, sizeof (sigset_t))) 1087c478bd9Sstevel@tonic-gate return (set_errno(EFAULT)); 1097c478bd9Sstevel@tonic-gate sigutok(&set, &kset); 1107c478bd9Sstevel@tonic-gate } else { 1117c478bd9Sstevel@tonic-gate /* none of SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK equals 0 */ 1127c478bd9Sstevel@tonic-gate how = 0; 1137c478bd9Sstevel@tonic-gate sigemptyset(&kset); 1147c478bd9Sstevel@tonic-gate } 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate rv.r_vals = lwp_sigmask(how, kset.__sigbits[0], kset.__sigbits[1]); 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate if (osetp) { 1197c478bd9Sstevel@tonic-gate kset.__sigbits[0] = rv.r_val1; 1207c478bd9Sstevel@tonic-gate kset.__sigbits[1] = rv.r_val2; 1217c478bd9Sstevel@tonic-gate sigktou(&kset, &set); 1227c478bd9Sstevel@tonic-gate if (copyout((caddr_t)&set, (caddr_t)osetp, sizeof (sigset_t))) 1237c478bd9Sstevel@tonic-gate return (set_errno(EFAULT)); 1247c478bd9Sstevel@tonic-gate } 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate return (0); 1277c478bd9Sstevel@tonic-gate } 128