Home | History | Annotate | Line # | Download | only in netbsd32
netbsd32_compat_13.c revision 1.4.2.2
      1  1.4.2.2  bouyer /*	$NetBSD: netbsd32_compat_13.c,v 1.4.2.2 2001/02/11 19:14:10 bouyer Exp $	*/
      2      1.1     mrg 
      3      1.1     mrg /*
      4      1.1     mrg  * Copyright (c) 1998 Matthew R. Green
      5      1.1     mrg  * All rights reserved.
      6      1.1     mrg  *
      7      1.1     mrg  * Redistribution and use in source and binary forms, with or without
      8      1.1     mrg  * modification, are permitted provided that the following conditions
      9      1.1     mrg  * are met:
     10      1.1     mrg  * 1. Redistributions of source code must retain the above copyright
     11      1.1     mrg  *    notice, this list of conditions and the following disclaimer.
     12      1.1     mrg  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.1     mrg  *    notice, this list of conditions and the following disclaimer in the
     14      1.1     mrg  *    documentation and/or other materials provided with the distribution.
     15      1.1     mrg  * 3. The name of the author may not be used to endorse or promote products
     16      1.1     mrg  *    derived from this software without specific prior written permission.
     17      1.1     mrg  *
     18      1.1     mrg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19      1.1     mrg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20      1.1     mrg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21      1.1     mrg  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22      1.1     mrg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     23      1.1     mrg  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     24      1.1     mrg  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     25      1.1     mrg  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     26      1.1     mrg  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27      1.1     mrg  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28      1.1     mrg  * SUCH DAMAGE.
     29      1.1     mrg  */
     30      1.1     mrg 
     31      1.1     mrg #include <sys/param.h>
     32      1.1     mrg #include <sys/systm.h>
     33      1.1     mrg #include <sys/mount.h>
     34      1.1     mrg #include <sys/proc.h>
     35      1.1     mrg #include <sys/signal.h>
     36  1.4.2.1  bouyer #include <sys/signalvar.h>
     37      1.1     mrg #include <sys/syscallargs.h>
     38      1.1     mrg 
     39      1.3     mrg #include <compat/netbsd32/netbsd32.h>
     40      1.3     mrg #include <compat/netbsd32/netbsd32_syscallargs.h>
     41      1.1     mrg 
     42      1.1     mrg int
     43      1.4     eeh compat_13_netbsd32_sigaltstack13(p, v, retval)
     44      1.1     mrg 	struct proc *p;
     45      1.1     mrg 	void *v;
     46      1.1     mrg 	register_t *retval;
     47      1.1     mrg {
     48      1.4     eeh 	struct compat_13_netbsd32_sigaltstack13_args /* {
     49      1.3     mrg 		syscallarg(const netbsd32_sigaltstack13p_t) nss;
     50      1.3     mrg 		syscallarg(netbsd32_sigaltstack13p_t) oss;
     51      1.1     mrg 	} */ *uap = v;
     52      1.1     mrg 	struct compat_13_sys_sigaltstack_args ua;
     53  1.4.2.2  bouyer 	struct sigaltstack13 ss13, *nss13up, *oss13up;
     54  1.4.2.2  bouyer 	struct netbsd32_sigaltstack13 s32ss;
     55  1.4.2.2  bouyer 	caddr_t sg;
     56  1.4.2.2  bouyer 	int error;
     57  1.4.2.2  bouyer 
     58  1.4.2.2  bouyer 	if (!SCARG(uap, nss))
     59  1.4.2.2  bouyer 		return (EINVAL);
     60  1.4.2.2  bouyer 
     61  1.4.2.2  bouyer 	sg = stackgap_init(p->p_emul);
     62  1.4.2.2  bouyer 
     63  1.4.2.2  bouyer 	SCARG(&ua, nss) = nss13up = stackgap_alloc(&sg, sizeof(*nss13up));
     64  1.4.2.2  bouyer 	if (SCARG(uap, oss))
     65  1.4.2.2  bouyer 		SCARG(&ua, oss) = oss13up = stackgap_alloc(&sg, sizeof(*oss13up));
     66  1.4.2.2  bouyer 	else
     67  1.4.2.2  bouyer 		SCARG(&ua, oss) = NULL;
     68  1.4.2.2  bouyer 
     69  1.4.2.2  bouyer 	error = copyin((caddr_t)(u_long)SCARG(uap, nss), &s32ss, sizeof s32ss);
     70  1.4.2.2  bouyer 	if (error)
     71  1.4.2.2  bouyer 		return (error);
     72  1.4.2.2  bouyer 	ss13.ss_sp = (char *)(u_long)s32ss.ss_sp;
     73  1.4.2.2  bouyer 	ss13.ss_size = s32ss.ss_size;
     74  1.4.2.2  bouyer 	ss13.ss_flags = s32ss.ss_flags;
     75  1.4.2.2  bouyer 	error = copyout(&ss13, nss13up, sizeof *nss13up);
     76  1.4.2.2  bouyer 	if (error)
     77  1.4.2.2  bouyer 		return (error);
     78  1.4.2.2  bouyer 
     79  1.4.2.2  bouyer 	error = compat_13_sys_sigaltstack(p, &ua, retval);
     80  1.4.2.2  bouyer 	if (error)
     81  1.4.2.2  bouyer 		return (error);
     82  1.4.2.2  bouyer 
     83  1.4.2.2  bouyer 	if (SCARG(uap, oss)) {
     84  1.4.2.2  bouyer 		error = copyin(nss13up, &ss13, sizeof *nss13up);
     85  1.4.2.2  bouyer 		if (error)
     86  1.4.2.2  bouyer 			return (error);
     87  1.4.2.2  bouyer 		s32ss.ss_sp = (netbsd32_charp)(u_long)ss13.ss_sp;
     88  1.4.2.2  bouyer 		s32ss.ss_size = ss13.ss_size;
     89  1.4.2.2  bouyer 		s32ss.ss_flags = ss13.ss_flags;
     90  1.4.2.2  bouyer 		error = copyout(&s32ss, (caddr_t)(u_long)SCARG(uap, nss), sizeof s32ss);
     91  1.4.2.2  bouyer 		if (error)
     92  1.4.2.2  bouyer 			return (error);
     93  1.4.2.2  bouyer 	}
     94      1.1     mrg 
     95  1.4.2.2  bouyer 	return (0);
     96  1.4.2.1  bouyer }
     97  1.4.2.1  bouyer 
     98  1.4.2.1  bouyer 
     99  1.4.2.1  bouyer int
    100  1.4.2.1  bouyer compat_13_netbsd32_sigprocmask(p, v, retval)
    101  1.4.2.1  bouyer 	struct proc *p;
    102  1.4.2.1  bouyer 	void *v;
    103  1.4.2.1  bouyer 	register_t *retval;
    104  1.4.2.1  bouyer {
    105  1.4.2.1  bouyer 	struct compat_13_netbsd32_sigprocmask_args /* {
    106  1.4.2.1  bouyer 		syscallarg(int) how;
    107  1.4.2.1  bouyer 		syscallarg(int) mask;
    108  1.4.2.1  bouyer 	} */ *uap = v;
    109  1.4.2.1  bouyer 	sigset13_t ness, oess;
    110  1.4.2.1  bouyer 	sigset_t nbss, obss;
    111  1.4.2.1  bouyer 	int error;
    112  1.4.2.1  bouyer 
    113  1.4.2.1  bouyer 	ness = SCARG(uap, mask);
    114  1.4.2.1  bouyer 	native_sigset13_to_sigset(&ness, &nbss);
    115  1.4.2.1  bouyer 	error = sigprocmask1(p, SCARG(uap, how), &nbss, &obss);
    116  1.4.2.1  bouyer 	if (error)
    117  1.4.2.1  bouyer 		return (error);
    118  1.4.2.1  bouyer 	native_sigset_to_sigset13(&obss, &oess);
    119  1.4.2.1  bouyer 	*retval = oess;
    120  1.4.2.1  bouyer 	return (0);
    121  1.4.2.1  bouyer }
    122  1.4.2.1  bouyer 
    123  1.4.2.1  bouyer int
    124  1.4.2.1  bouyer compat_13_netbsd32_sigsuspend(p, v, retval)
    125  1.4.2.1  bouyer 	struct proc *p;
    126  1.4.2.1  bouyer 	void *v;
    127  1.4.2.1  bouyer 	register_t *retval;
    128  1.4.2.1  bouyer {
    129  1.4.2.1  bouyer 	struct compat_13_netbsd32_sigsuspend_args /* {
    130  1.4.2.1  bouyer 		syscallarg(sigset13_t) mask;
    131  1.4.2.1  bouyer 	} */ *uap = v;
    132  1.4.2.1  bouyer 	sigset13_t ess;
    133  1.4.2.1  bouyer 	sigset_t bss;
    134  1.4.2.1  bouyer 
    135  1.4.2.1  bouyer 	ess = SCARG(uap, mask);
    136  1.4.2.1  bouyer 	native_sigset13_to_sigset(&ess, &bss);
    137  1.4.2.1  bouyer 	return (sigsuspend1(p, &bss));
    138      1.1     mrg }
    139