int error;
sys_sigreturn(p, v, retval)struct proc *p;void *v;register_t *retval;{	struct sys_sigreturn_args /* {	   syscallarg(struct sigcontext *) sigcntxp;	} */ *uap = v;	register struct sigcontext *scp;	register struct trapframe *tf;	struct sigcontext ksc;	int error;	scp = (struct sigcontext *)SCARG(uap, sigcntxp);#ifdef DEBUG	if (sigdebug & SDB_FOLLOW)		printf("sigreturn: pid %d, scp %x\n", p->p_pid, scp);#endif#if defined(UVM)	if ((int)scp & 3 || uvm_useracc((caddr_t)scp, sizeof *scp, B_WRITE) == 0 ||	    copyin((caddr_t)scp, (caddr_t)&ksc, sizeof(struct sigcontext)))		return (EINVAL);#else	if ((int)scp & 3 || useracc((caddr_t)scp, sizeof *scp, B_WRITE) == 0 ||	    copyin((caddr_t)scp, (caddr_t)&ksc, sizeof(struct sigcontext)))		return (EINVAL);#endif	tf = p->p_md.md_tf;	scp = &ksc;	/*	 * xip, nip and fip must be multiples of 4.  This is all	 * that is required; if it holds, just do it.	 */#if 0	if (((scp->sc_xip | scp->sc_nip | scp->sc_fip) & 3) != 0)		return (EINVAL);#endif /* 0 */#if DIAGNOSTIC	if (((scp->sc_xip | scp->sc_nip | scp->sc_fip) & 3) != 0){		printf("xip %x nip %x fip %x\n",		       scp->sc_xip, scp->sc_nip, scp->sc_fip);		return (EINVAL);	}#endif 	/*	 * this can be improved by doing	 *	 bcopy(sc_reg to tf, sizeof sigcontext - 2 words)	 * XXX nivas	 */	bcopy((caddr_t)scp->sc_regs, (caddr_t)tf->r, sizeof(scp->sc_regs));	tf->sxip = (scp->sc_xip) | XIP_V;	tf->snip = (scp->sc_nip) | NIP_V;	tf->sfip = (scp->sc_fip) | FIP_V;	tf->epsr = scp->sc_ps;	tf->r[31] = scp->sc_sp;	tf->fpsr = scp->sc_fpsr;	tf->fpcr = scp->sc_fpcr;	tf->ssbr = scp->sc_ssbr;	tf->dmt0 = scp->sc_dmt0;	tf->dmd0 = scp->sc_dmd0;	tf->dma0 = scp->sc_dma0;	tf->dmt1 = scp->sc_dmt1;	tf->dmd1 = scp->sc_dmd1;	tf->dma1 = scp->sc_dma1;	tf->dmt2 = scp->sc_dmt2;	tf->dmd2 = scp->sc_dmd2;	tf->dma2 = scp->sc_dma2;	tf->fpecr = scp->sc_fpecr;	tf->fphs1 = scp->sc_fphs1;	tf->fpls1 = scp->sc_fpls1;	tf->fphs2 = scp->sc_fphs2;	tf->fpls2 = scp->sc_fpls2;	tf->fppt = scp->sc_fppt;	tf->fprh = scp->sc_fprh;	tf->fprl = scp->sc_fprl;	tf->fpit = scp->sc_fpit;	tf->epsr = scp->sc_ps;	/*	 * Restore the user supplied information	 */	if (scp->sc_onstack & 01)		p->p_sigacts->ps_sigstk.ss_flags |= SA_ONSTACK;	else		p->p_sigacts->ps_sigstk.ss_flags &= ~SA_ONSTACK;	p->p_sigmask = scp->sc_mask & ~sigcantmask;	return (EJUSTRETURN);}