Home | History | Annotate | Line # | Download | only in common
linux32_signal.c revision 1.8.2.2
      1  1.8.2.2   yamt /*	$NetBSD: linux32_signal.c,v 1.8.2.2 2009/06/20 07:20:17 yamt Exp $ */
      2      1.1   manu 
      3      1.1   manu /*-
      4      1.1   manu  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
      5      1.1   manu  *
      6      1.1   manu  * Redistribution and use in source and binary forms, with or without
      7      1.1   manu  * modification, are permitted provided that the following conditions
      8      1.1   manu  * are met:
      9      1.1   manu  * 1. Redistributions of source code must retain the above copyright
     10      1.1   manu  *    notice, this list of conditions and the following disclaimer.
     11      1.1   manu  * 2. Redistributions in binary form must reproduce the above copyright
     12      1.1   manu  *    notice, this list of conditions and the following disclaimer in the
     13      1.1   manu  *    documentation and/or other materials provided with the distribution.
     14      1.1   manu  * 3. All advertising materials mentioning features or use of this software
     15      1.1   manu  *    must display the following acknowledgement:
     16      1.1   manu  *	This product includes software developed by Emmanuel Dreyfus
     17      1.1   manu  * 4. The name of the author may not be used to endorse or promote
     18      1.1   manu  *    products derived from this software without specific prior written
     19      1.1   manu  *    permission.
     20      1.1   manu  *
     21      1.1   manu  * THIS SOFTWARE IS PROVIDED BY THE THE AUTHOR AND CONTRIBUTORS ``AS IS''
     22      1.1   manu  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     23      1.1   manu  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     24      1.1   manu  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
     25      1.1   manu  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26      1.1   manu  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27      1.1   manu  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28      1.1   manu  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29      1.1   manu  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30      1.1   manu  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     31      1.1   manu  * POSSIBILITY OF SUCH DAMAGE.
     32      1.1   manu  */
     33      1.6  lukem 
     34      1.6  lukem #include <sys/cdefs.h>
     35  1.8.2.2   yamt __KERNEL_RCSID(0, "$NetBSD: linux32_signal.c,v 1.8.2.2 2009/06/20 07:20:17 yamt Exp $");
     36      1.6  lukem 
     37      1.1   manu #include <sys/param.h>
     38      1.1   manu #include <sys/ucred.h>
     39      1.1   manu #include <sys/signalvar.h>
     40      1.1   manu #include <sys/lwp.h>
     41      1.1   manu #include <sys/time.h>
     42      1.2     ad #include <sys/proc.h>
     43      1.1   manu 
     44      1.1   manu #include <compat/netbsd32/netbsd32.h>
     45      1.1   manu 
     46      1.1   manu #include <compat/linux32/common/linux32_types.h>
     47      1.1   manu #include <compat/linux32/common/linux32_signal.h>
     48      1.1   manu #include <compat/linux32/linux32_syscallargs.h>
     49      1.1   manu 
     50      1.1   manu #define linux32_sigemptyset(s)    memset((s), 0, sizeof(*(s)))
     51      1.1   manu #define linux32_sigismember(s, n) ((s)->sig[((n) - 1) / LINUX32__NSIG_BPW]  \
     52      1.1   manu 				    & (1 << ((n) - 1) % LINUX32__NSIG_BPW))
     53      1.1   manu #define linux32_sigaddset(s, n)   ((s)->sig[((n) - 1) / LINUX32__NSIG_BPW]  \
     54      1.1   manu 				    |= (1 << ((n) - 1) % LINUX32__NSIG_BPW))
     55      1.1   manu 
     56      1.1   manu extern const int native_to_linux32_signo[];
     57      1.1   manu extern const int linux32_to_native_signo[];
     58      1.1   manu 
     59  1.8.2.1   yamt #ifdef DEBUG_LINUX
     60  1.8.2.1   yamt #define DPRINTF(a)      uprintf a
     61  1.8.2.1   yamt #else
     62  1.8.2.1   yamt #define DPRINTF(a)
     63  1.8.2.1   yamt #endif
     64  1.8.2.1   yamt 
     65      1.1   manu void
     66      1.5    dsl linux32_to_native_sigset(sigset_t *bss, const linux32_sigset_t *lss)
     67      1.1   manu {
     68      1.1   manu 	int i, newsig;
     69      1.1   manu 
     70      1.1   manu 	sigemptyset(bss);
     71      1.1   manu 	for (i = 1; i < LINUX32__NSIG; i++) {
     72      1.1   manu 		if (linux32_sigismember(lss, i)) {
     73      1.1   manu 			newsig = linux32_to_native_signo[i];
     74      1.1   manu 			if (newsig)
     75      1.1   manu 				sigaddset(bss, newsig);
     76      1.1   manu 		}
     77      1.1   manu 	}
     78      1.1   manu }
     79      1.1   manu 
     80      1.1   manu void
     81      1.5    dsl native_to_linux32_sigset(linux32_sigset_t *lss, const sigset_t *bss)
     82      1.1   manu {
     83      1.1   manu 	int i, newsig;
     84      1.1   manu 
     85      1.1   manu 	linux32_sigemptyset(lss);
     86      1.1   manu 	for (i = 1; i < NSIG; i++) {
     87      1.1   manu 		if (sigismember(bss, i)) {
     88      1.1   manu 			newsig = native_to_linux32_signo[i];
     89      1.1   manu 			if (newsig)
     90      1.1   manu 				linux32_sigaddset(lss, newsig);
     91      1.1   manu 		}
     92      1.1   manu 	}
     93      1.1   manu }
     94      1.1   manu 
     95      1.1   manu unsigned int
     96      1.5    dsl native_to_linux32_sigflags(const int bsf)
     97      1.1   manu {
     98      1.1   manu 	unsigned int lsf = 0;
     99      1.1   manu 	if ((bsf & SA_NOCLDSTOP) != 0)
    100      1.1   manu 		lsf |= LINUX32_SA_NOCLDSTOP;
    101      1.1   manu 	if ((bsf & SA_NOCLDWAIT) != 0)
    102      1.1   manu 		lsf |= LINUX32_SA_NOCLDWAIT;
    103      1.1   manu 	if ((bsf & SA_ONSTACK) != 0)
    104      1.1   manu 		lsf |= LINUX32_SA_ONSTACK;
    105      1.1   manu 	if ((bsf & SA_RESTART) != 0)
    106      1.1   manu 		lsf |= LINUX32_SA_RESTART;
    107      1.1   manu 	if ((bsf & SA_NODEFER) != 0)
    108      1.1   manu 		lsf |= LINUX32_SA_NOMASK;
    109      1.1   manu 	if ((bsf & SA_RESETHAND) != 0)
    110      1.1   manu 		lsf |= LINUX32_SA_ONESHOT;
    111      1.1   manu 	if ((bsf & SA_SIGINFO) != 0)
    112      1.1   manu 		lsf |= LINUX32_SA_SIGINFO;
    113      1.1   manu 	return lsf;
    114      1.1   manu }
    115      1.1   manu 
    116      1.1   manu int
    117      1.5    dsl linux32_to_native_sigflags(const unsigned long lsf)
    118      1.1   manu {
    119      1.1   manu 	int bsf = 0;
    120      1.1   manu 	if ((lsf & LINUX32_SA_NOCLDSTOP) != 0)
    121      1.1   manu 		bsf |= SA_NOCLDSTOP;
    122      1.1   manu 	if ((lsf & LINUX32_SA_NOCLDWAIT) != 0)
    123      1.1   manu 		bsf |= SA_NOCLDWAIT;
    124      1.1   manu 	if ((lsf & LINUX32_SA_ONSTACK) != 0)
    125      1.1   manu 		bsf |= SA_ONSTACK;
    126      1.1   manu 	if ((lsf & LINUX32_SA_RESTART) != 0)
    127      1.1   manu 		bsf |= SA_RESTART;
    128      1.1   manu 	if ((lsf & LINUX32_SA_ONESHOT) != 0)
    129      1.1   manu 		bsf |= SA_RESETHAND;
    130      1.1   manu 	if ((lsf & LINUX32_SA_NOMASK) != 0)
    131      1.1   manu 		bsf |= SA_NODEFER;
    132      1.1   manu 	if ((lsf & LINUX32_SA_SIGINFO) != 0)
    133      1.1   manu 		bsf |= SA_SIGINFO;
    134      1.1   manu 	if ((lsf & ~LINUX32_SA_ALLBITS) != 0) {
    135      1.1   manu #ifdef DEBUG_LINUX
    136      1.1   manu 		printf("linux32_old_to_native_sigflags: "
    137      1.1   manu 		    "%lx extra bits ignored\n", lsf);
    138      1.1   manu #endif
    139      1.1   manu 	}
    140      1.1   manu 	return bsf;
    141      1.1   manu }
    142      1.1   manu 
    143      1.1   manu void
    144      1.5    dsl linux32_to_native_sigaction(struct sigaction *bsa, const struct linux32_sigaction *lsa)
    145      1.1   manu {
    146      1.1   manu 	bsa->sa_handler = NETBSD32PTR64(lsa->linux_sa_handler);
    147      1.1   manu 	linux32_to_native_sigset(&bsa->sa_mask, &lsa->linux_sa_mask);
    148      1.1   manu 	bsa->sa_flags = linux32_to_native_sigflags(lsa->linux_sa_flags);
    149      1.1   manu }
    150      1.1   manu 
    151      1.1   manu void
    152      1.5    dsl native_to_linux32_sigaction(struct linux32_sigaction *lsa, const struct sigaction *bsa)
    153      1.1   manu {
    154      1.3    dsl 	NETBSD32PTR32(lsa->linux_sa_handler, bsa->sa_handler);
    155      1.1   manu 	native_to_linux32_sigset(&lsa->linux_sa_mask, &bsa->sa_mask);
    156      1.1   manu 	lsa->linux_sa_flags = native_to_linux32_sigflags(bsa->sa_flags);
    157      1.3    dsl 	NETBSD32PTR32(lsa->linux_sa_restorer, NULL);
    158      1.1   manu }
    159      1.1   manu 
    160      1.1   manu void
    161      1.5    dsl native_to_linux32_sigaltstack(struct linux32_sigaltstack *lss, const struct sigaltstack *bss)
    162      1.1   manu {
    163      1.3    dsl 	NETBSD32PTR32(lss->ss_sp, bss->ss_sp);
    164      1.1   manu 	lss->ss_size = bss->ss_size;
    165      1.1   manu 	if (bss->ss_flags & SS_ONSTACK)
    166      1.1   manu 	    lss->ss_flags = LINUX32_SS_ONSTACK;
    167      1.1   manu 	else if (bss->ss_flags & SS_DISABLE)
    168      1.1   manu 	    lss->ss_flags = LINUX32_SS_DISABLE;
    169      1.1   manu 	else
    170      1.1   manu 	    lss->ss_flags = 0;
    171      1.1   manu }
    172      1.1   manu 
    173      1.1   manu 
    174      1.1   manu void
    175      1.5    dsl native_to_linux32_old_sigset(linux32_old_sigset_t *lss, const sigset_t *bss)
    176      1.1   manu {
    177      1.1   manu 	linux32_sigset_t lsnew;
    178      1.1   manu 
    179      1.1   manu 	native_to_linux32_sigset(&lsnew, bss);
    180      1.1   manu 
    181      1.1   manu 	/* convert new sigset to old sigset */
    182      1.1   manu 	*lss = lsnew.sig[0];
    183      1.1   manu }
    184      1.1   manu 
    185      1.1   manu void
    186      1.5    dsl linux32_old_to_native_sigset(sigset_t *bss, const linux32_old_sigset_t *lss)
    187      1.1   manu {
    188      1.1   manu 	linux32_sigset_t ls;
    189      1.1   manu 
    190  1.8.2.1   yamt 	memset(&ls, 0, sizeof(ls));
    191      1.1   manu 	ls.sig[0] = *lss;
    192      1.1   manu 
    193      1.1   manu 	linux32_to_native_sigset(bss, &ls);
    194      1.1   manu }
    195      1.1   manu 
    196      1.1   manu int
    197      1.7    dsl linux32_sys_rt_sigaction(struct lwp *l, const struct linux32_sys_rt_sigaction_args *uap, register_t *retval)
    198      1.1   manu {
    199      1.7    dsl 	/* {
    200      1.1   manu 		syscallarg(int) signum;
    201      1.1   manu 		syscallarg(const linux32_sigactionp_t) nsa;
    202      1.1   manu 		syscallarg(linux32_sigactionp_t) osa;
    203      1.1   manu 		syscallarg(netbsd32_size_t) sigsetsize;
    204      1.7    dsl 	} */
    205      1.1   manu 	struct linux32_sigaction nls32;
    206      1.1   manu 	struct linux32_sigaction ols32;
    207      1.1   manu 	struct sigaction ns;
    208      1.1   manu 	struct sigaction os;
    209      1.1   manu 	int error;
    210      1.1   manu 	int sig;
    211      1.1   manu 	int vers = 0;
    212      1.1   manu 	void *tramp = NULL;
    213      1.1   manu 
    214  1.8.2.1   yamt 	if (SCARG(uap, sigsetsize) != sizeof(linux32_sigset_t)) {
    215  1.8.2.1   yamt 		DPRINTF(("rt_sigaction: Inconsistent sigsetsize %u %zu\n",
    216  1.8.2.1   yamt 		    SCARG(uap, sigsetsize), sizeof(linux32_sigset_t)));
    217      1.1   manu 		return EINVAL;
    218  1.8.2.1   yamt 	}
    219      1.1   manu 
    220      1.4    dsl 	if (SCARG_P32(uap, nsa) != NULL) {
    221      1.4    dsl 		if ((error = copyin(SCARG_P32(uap, nsa),
    222  1.8.2.1   yamt 		    &nls32, sizeof(nls32))) != 0) {
    223  1.8.2.1   yamt 			DPRINTF(("rt_sigaction: Copyin %d\n", error));
    224      1.1   manu 			return error;
    225  1.8.2.1   yamt 		}
    226      1.1   manu 		linux32_to_native_sigaction(&ns, &nls32);
    227      1.1   manu 	}
    228      1.1   manu 
    229      1.1   manu 	sig = SCARG(uap, signum);
    230  1.8.2.1   yamt 	if (sig < 0 || sig >= LINUX32__NSIG) {
    231  1.8.2.1   yamt 		DPRINTF(("rt_sigaction: Bad signal number %d %d\n",
    232  1.8.2.1   yamt 		    sig, LINUX32__NSIG));
    233      1.1   manu 		return EINVAL;
    234  1.8.2.1   yamt 	}
    235      1.1   manu 	if (sig > 0 && !linux32_to_native_signo[sig]) {
    236      1.1   manu 		/* unknown signal... */
    237      1.1   manu 		os.sa_handler = SIG_IGN;
    238      1.1   manu 		sigemptyset(&os.sa_mask);
    239      1.1   manu 		os.sa_flags = 0;
    240      1.1   manu 	} else {
    241      1.2     ad 		if ((error = sigaction1(l,
    242      1.1   manu 		    linux32_to_native_signo[sig],
    243      1.4    dsl 		    SCARG_P32(uap, nsa) ? &ns : NULL,
    244      1.4    dsl 		    SCARG_P32(uap, osa) ? &os : NULL,
    245  1.8.2.1   yamt 		    tramp, vers)) != 0) {
    246  1.8.2.1   yamt 			DPRINTF(("rt_sigaction: sigaction %d\n", error));
    247      1.1   manu 			return error;
    248  1.8.2.1   yamt 		}
    249      1.1   manu 	}
    250      1.1   manu 
    251      1.4    dsl 	if (SCARG_P32(uap, osa) != NULL) {
    252      1.1   manu 		native_to_linux32_sigaction(&ols32, &os);
    253      1.1   manu 
    254      1.4    dsl 		if ((error = copyout(&ols32, SCARG_P32(uap, osa),
    255  1.8.2.1   yamt 		    sizeof(ols32))) != 0) {
    256  1.8.2.1   yamt 			DPRINTF(("rt_sigaction: Copyout %d\n", error));
    257      1.1   manu 			return error;
    258  1.8.2.1   yamt 		}
    259      1.1   manu 	}
    260      1.1   manu 
    261      1.1   manu 	return 0;
    262      1.1   manu }
    263      1.1   manu 
    264      1.1   manu int
    265      1.7    dsl linux32_sys_rt_sigprocmask(struct lwp *l, const struct linux32_sys_rt_sigprocmask_args *uap, register_t *retval)
    266      1.1   manu {
    267      1.7    dsl 	/* {
    268      1.1   manu 		syscallarg(int) how;
    269      1.1   manu 		syscallarg(const linux32_sigsetp_t) set;
    270      1.1   manu 		syscallarg(linux32_sigsetp_t) oset;
    271      1.1   manu 		syscallarg(netbsd32_size_t) sigsetsize;
    272      1.7    dsl 	} */
    273      1.1   manu 	struct proc *p = l->l_proc;
    274      1.1   manu 	linux32_sigset_t nls32, ols32;
    275      1.1   manu 	sigset_t ns, os;
    276      1.1   manu 	int error;
    277      1.1   manu 	int how;
    278      1.1   manu 
    279      1.1   manu 	if (SCARG(uap, sigsetsize) != sizeof(linux32_sigset_t))
    280      1.1   manu 		return EINVAL;
    281      1.1   manu 
    282      1.1   manu 	switch (SCARG(uap, how)) {
    283      1.1   manu 	case LINUX32_SIG_BLOCK:
    284      1.1   manu 		how = SIG_BLOCK;
    285      1.1   manu 		break;
    286      1.1   manu 	case LINUX32_SIG_UNBLOCK:
    287      1.1   manu 		how = SIG_UNBLOCK;
    288      1.1   manu 		break;
    289      1.1   manu 	case LINUX32_SIG_SETMASK:
    290      1.1   manu 		how = SIG_SETMASK;
    291      1.1   manu 		break;
    292      1.1   manu 	default:
    293      1.1   manu 		return EINVAL;
    294      1.1   manu 		break;
    295      1.1   manu 	}
    296      1.1   manu 
    297      1.4    dsl 	if (SCARG_P32(uap, set) != NULL) {
    298      1.4    dsl 		if ((error = copyin(SCARG_P32(uap, set),
    299      1.1   manu 		    &nls32, sizeof(nls32))) != 0)
    300      1.1   manu 			return error;
    301      1.1   manu 		linux32_to_native_sigset(&ns, &nls32);
    302      1.1   manu 	}
    303      1.1   manu 
    304      1.8     ad 	mutex_enter(p->p_lock);
    305      1.2     ad 	error = sigprocmask1(l, how,
    306      1.4    dsl 	    SCARG_P32(uap, set) ? &ns : NULL,
    307      1.4    dsl 	    SCARG_P32(uap, oset) ? &os : NULL);
    308      1.8     ad 	mutex_exit(p->p_lock);
    309      1.2     ad 
    310      1.2     ad         if (error != 0)
    311      1.1   manu 		return error;
    312      1.1   manu 
    313      1.4    dsl 	if (SCARG_P32(uap, oset) != NULL) {
    314      1.1   manu 		native_to_linux32_sigset(&ols32, &os);
    315      1.1   manu 		if ((error = copyout(&ols32,
    316      1.4    dsl 		    SCARG_P32(uap, oset), sizeof(ols32))) != 0)
    317      1.1   manu 			return error;
    318      1.1   manu 	}
    319      1.1   manu 
    320      1.1   manu 	return 0;
    321      1.1   manu }
    322      1.1   manu 
    323      1.1   manu int
    324      1.7    dsl linux32_sys_kill(struct lwp *l, const struct linux32_sys_kill_args *uap, register_t *retval)
    325      1.7    dsl {
    326      1.7    dsl 	/* {
    327      1.1   manu 		syscallarg(int) pid;
    328      1.1   manu 		syscallarg(int) signum;
    329      1.7    dsl 	} */
    330      1.1   manu 
    331      1.1   manu 	struct sys_kill_args ka;
    332      1.1   manu 	int sig;
    333      1.1   manu 
    334      1.1   manu 	SCARG(&ka, pid) = SCARG(uap, pid);
    335      1.1   manu 	sig = SCARG(uap, signum);
    336      1.1   manu 	if (sig < 0 || sig >= LINUX32__NSIG)
    337      1.1   manu 		return (EINVAL);
    338      1.1   manu 	SCARG(&ka, signum) = linux32_to_native_signo[sig];
    339      1.1   manu 	return sys_kill(l, &ka, retval);
    340      1.1   manu }
    341      1.1   manu 
    342      1.1   manu int
    343      1.7    dsl linux32_sys_rt_sigsuspend(struct lwp *l, const struct linux32_sys_rt_sigsuspend_args *uap, register_t *retval)
    344      1.7    dsl {
    345      1.7    dsl 	/* {
    346      1.1   manu 		syscallarg(linux32_sigsetp_t) unewset;
    347      1.1   manu                 syscallarg(netbsd32_size_t) sigsetsize;
    348      1.7    dsl 	} */
    349      1.1   manu 	linux32_sigset_t lss;
    350      1.1   manu 	sigset_t bss;
    351      1.1   manu 	int error;
    352      1.1   manu 
    353      1.1   manu 	if (SCARG(uap, sigsetsize) != sizeof(linux32_sigset_t))
    354      1.1   manu 		return EINVAL;
    355      1.1   manu 
    356      1.4    dsl 	if ((error = copyin(SCARG_P32(uap, unewset),
    357      1.1   manu 	    &lss, sizeof(linux32_sigset_t))) != 0)
    358      1.1   manu 		return error;
    359      1.1   manu 
    360      1.1   manu 	linux32_to_native_sigset(&bss, &lss);
    361      1.1   manu 
    362      1.2     ad 	return sigsuspend1(l, &bss);
    363      1.1   manu }
    364      1.1   manu 
    365      1.1   manu int
    366      1.7    dsl linux32_sys_signal(struct lwp *l, const struct linux32_sys_signal_args *uap, register_t *retval)
    367      1.1   manu {
    368      1.7    dsl 	/* {
    369      1.1   manu 		syscallarg(int) signum;
    370      1.1   manu 		syscallarg(linux32_handler_t) handler;
    371      1.7    dsl 	} */
    372      1.1   manu         struct sigaction nbsa, obsa;
    373      1.1   manu         int error, sig;
    374      1.1   manu 
    375      1.1   manu         *retval = -1;
    376      1.1   manu 
    377      1.1   manu         sig = SCARG(uap, signum);
    378      1.1   manu         if (sig < 0 || sig >= LINUX32__NSIG)
    379      1.1   manu                 return EINVAL;
    380      1.1   manu 
    381      1.4    dsl         nbsa.sa_handler = SCARG_P32(uap, handler);
    382      1.1   manu         sigemptyset(&nbsa.sa_mask);
    383      1.1   manu         nbsa.sa_flags = SA_RESETHAND | SA_NODEFER;
    384      1.1   manu 
    385      1.2     ad         if ((error = sigaction1(l, linux32_to_native_signo[sig],
    386      1.1   manu             &nbsa, &obsa, NULL, 0)) != 0)
    387      1.1   manu 		return error;
    388      1.1   manu 
    389      1.1   manu         *retval = (int)(long)obsa.sa_handler;
    390      1.1   manu         return 0;
    391      1.1   manu }
    392  1.8.2.1   yamt 
    393  1.8.2.1   yamt int
    394  1.8.2.1   yamt linux32_sys_rt_sigpending(struct lwp *l, const struct linux32_sys_rt_sigpending_args *uap, register_t *retval)
    395  1.8.2.1   yamt {
    396  1.8.2.1   yamt 	/* {
    397  1.8.2.1   yamt 		syscallarg(linux32_sigsetp_t) set;
    398  1.8.2.1   yamt 		syscallarg(netbsd32_size_t) sigsetsize;
    399  1.8.2.1   yamt 	} */
    400  1.8.2.1   yamt 	sigset_t bss;
    401  1.8.2.1   yamt 	linux32_sigset_t lss;
    402  1.8.2.1   yamt 
    403  1.8.2.1   yamt 	if (SCARG(uap, sigsetsize) != sizeof(linux32_sigset_t))
    404  1.8.2.1   yamt 		return EINVAL;
    405  1.8.2.1   yamt 
    406  1.8.2.1   yamt 	sigpending1(l, &bss);
    407  1.8.2.1   yamt 	native_to_linux32_sigset(&lss, &bss);
    408  1.8.2.1   yamt 	return copyout(&lss, SCARG_P32(uap, set), sizeof(lss));
    409  1.8.2.1   yamt }
    410  1.8.2.2   yamt 
    411  1.8.2.2   yamt int
    412  1.8.2.2   yamt linux32_sys_siggetmask(struct lwp *l, const void *v, register_t *retval)
    413  1.8.2.2   yamt {
    414  1.8.2.2   yamt 	struct proc *p = l->l_proc;
    415  1.8.2.2   yamt 	sigset_t bss;
    416  1.8.2.2   yamt 	linux32_old_sigset_t lss;
    417  1.8.2.2   yamt 	int error;
    418  1.8.2.2   yamt 
    419  1.8.2.2   yamt 	mutex_enter(p->p_lock);
    420  1.8.2.2   yamt 	error = sigprocmask1(l, SIG_SETMASK, 0, &bss);
    421  1.8.2.2   yamt 	mutex_exit(p->p_lock);
    422  1.8.2.2   yamt 	if (error)
    423  1.8.2.2   yamt 		return error;
    424  1.8.2.2   yamt 	native_to_linux32_old_sigset(&lss, &bss);
    425  1.8.2.2   yamt 	*retval = lss;
    426  1.8.2.2   yamt 	return 0;
    427  1.8.2.2   yamt }
    428  1.8.2.2   yamt 
    429  1.8.2.2   yamt int
    430  1.8.2.2   yamt linux32_sys_sigsetmask(struct lwp *l, const struct linux32_sys_sigsetmask_args *uap, register_t *retval)
    431  1.8.2.2   yamt {
    432  1.8.2.2   yamt 	/* {
    433  1.8.2.2   yamt 		syscallarg(linux32_old_sigset_t) mask;
    434  1.8.2.2   yamt 	} */
    435  1.8.2.2   yamt 	sigset_t nbss, obss;
    436  1.8.2.2   yamt 	linux32_old_sigset_t nlss, olss;
    437  1.8.2.2   yamt 	struct proc *p = l->l_proc;
    438  1.8.2.2   yamt 	int error;
    439  1.8.2.2   yamt 
    440  1.8.2.2   yamt 	nlss = SCARG(uap, mask);
    441  1.8.2.2   yamt 	linux32_old_to_native_sigset(&nbss, &nlss);
    442  1.8.2.2   yamt 	mutex_enter(p->p_lock);
    443  1.8.2.2   yamt 	error = sigprocmask1(l, SIG_SETMASK, &nbss, &obss);
    444  1.8.2.2   yamt 	mutex_exit(p->p_lock);
    445  1.8.2.2   yamt 	if (error)
    446  1.8.2.2   yamt 		return error;
    447  1.8.2.2   yamt 	native_to_linux32_old_sigset(&olss, &obss);
    448  1.8.2.2   yamt 	*retval = olss;
    449  1.8.2.2   yamt 	return 0;
    450  1.8.2.2   yamt }
    451  1.8.2.2   yamt 
    452  1.8.2.2   yamt int
    453  1.8.2.2   yamt linux32_sys_rt_queueinfo(struct lwp *l, const struct linux32_sys_rt_queueinfo_args *uap, register_t *retval)
    454  1.8.2.2   yamt {
    455  1.8.2.2   yamt 	/*
    456  1.8.2.2   yamt 		syscallarg(int) pid;
    457  1.8.2.2   yamt 		syscallarg(int) sig;
    458  1.8.2.2   yamt 		syscallarg(linux32_siginfop_t) uinfo;
    459  1.8.2.2   yamt 	*/
    460  1.8.2.2   yamt 	int error;
    461  1.8.2.2   yamt 	linux32_siginfo_t info;
    462  1.8.2.2   yamt 
    463  1.8.2.2   yamt 	error = copyin(SCARG_P32(uap, uinfo), &info, sizeof(info));
    464  1.8.2.2   yamt 	if (error)
    465  1.8.2.2   yamt 		return error;
    466  1.8.2.2   yamt 	if (info.lsi_code >= 0)
    467  1.8.2.2   yamt 		return EPERM;
    468  1.8.2.2   yamt 
    469  1.8.2.2   yamt 	/* XXX To really implement this we need to      */
    470  1.8.2.2   yamt 	/* XXX keep a list of queued signals somewhere. */
    471  1.8.2.2   yamt 	return linux32_sys_kill(l, (const void *)uap, retval);
    472  1.8.2.2   yamt }
    473