userret.h revision 1.2
11.2Sagc/*	$NetBSD: userret.h,v 1.2 2003/08/07 16:26:36 agc Exp $	*/
21.1Sfvdl
31.1Sfvdl/*
41.1Sfvdl * XXXfvdl same as i386 counterpart, but should probably be independent.
51.1Sfvdl */
61.1Sfvdl
71.1Sfvdl/*-
81.1Sfvdl * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
91.1Sfvdl * All rights reserved.
101.1Sfvdl *
111.1Sfvdl * This code is derived from software contributed to The NetBSD Foundation
121.1Sfvdl * by Charles M. Hannum.
131.1Sfvdl *
141.1Sfvdl * Redistribution and use in source and binary forms, with or without
151.1Sfvdl * modification, are permitted provided that the following conditions
161.1Sfvdl * are met:
171.1Sfvdl * 1. Redistributions of source code must retain the above copyright
181.1Sfvdl *    notice, this list of conditions and the following disclaimer.
191.1Sfvdl * 2. Redistributions in binary form must reproduce the above copyright
201.1Sfvdl *    notice, this list of conditions and the following disclaimer in the
211.1Sfvdl *    documentation and/or other materials provided with the distribution.
221.1Sfvdl * 3. All advertising materials mentioning features or use of this software
231.1Sfvdl *    must display the following acknowledgement:
241.1Sfvdl *        This product includes software developed by the NetBSD
251.1Sfvdl *        Foundation, Inc. and its contributors.
261.1Sfvdl * 4. Neither the name of The NetBSD Foundation nor the names of its
271.1Sfvdl *    contributors may be used to endorse or promote products derived
281.1Sfvdl *    from this software without specific prior written permission.
291.1Sfvdl *
301.1Sfvdl * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
311.1Sfvdl * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
321.1Sfvdl * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
331.1Sfvdl * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
341.1Sfvdl * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
351.1Sfvdl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
361.1Sfvdl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
371.1Sfvdl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
381.1Sfvdl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
391.1Sfvdl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
401.1Sfvdl * POSSIBILITY OF SUCH DAMAGE.
411.1Sfvdl */
421.1Sfvdl
431.1Sfvdl/*-
441.1Sfvdl * Copyright (c) 1990 The Regents of the University of California.
451.1Sfvdl * All rights reserved.
461.1Sfvdl *
471.1Sfvdl * This code is derived from software contributed to Berkeley by
481.1Sfvdl * William Jolitz.
491.1Sfvdl *
501.1Sfvdl * Redistribution and use in source and binary forms, with or without
511.1Sfvdl * modification, are permitted provided that the following conditions
521.1Sfvdl * are met:
531.1Sfvdl * 1. Redistributions of source code must retain the above copyright
541.1Sfvdl *    notice, this list of conditions and the following disclaimer.
551.1Sfvdl * 2. Redistributions in binary form must reproduce the above copyright
561.1Sfvdl *    notice, this list of conditions and the following disclaimer in the
571.1Sfvdl *    documentation and/or other materials provided with the distribution.
581.2Sagc * 3. Neither the name of the University nor the names of its contributors
591.1Sfvdl *    may be used to endorse or promote products derived from this software
601.1Sfvdl *    without specific prior written permission.
611.1Sfvdl *
621.1Sfvdl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
631.1Sfvdl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
641.1Sfvdl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
651.1Sfvdl * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
661.1Sfvdl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
671.1Sfvdl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
681.1Sfvdl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
691.1Sfvdl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
701.1Sfvdl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
711.1Sfvdl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
721.1Sfvdl * SUCH DAMAGE.
731.1Sfvdl *
741.1Sfvdl */
751.1Sfvdl
761.1Sfvdlstatic __inline void userret __P((register struct lwp *));
771.1Sfvdl
781.1Sfvdl/*
791.1Sfvdl * Define the code needed before returning to user mode, for
801.1Sfvdl * trap and syscall.
811.1Sfvdl */
821.1Sfvdlstatic __inline void
831.1Sfvdluserret(l)
841.1Sfvdl	register struct lwp *l;
851.1Sfvdl{
861.1Sfvdl	int sig;
871.1Sfvdl	struct proc *p = l->l_proc;
881.1Sfvdl
891.1Sfvdl	while ((sig = CURSIG(l)) != 0)
901.1Sfvdl		postsig(sig);
911.1Sfvdl
921.1Sfvdl	if (p->p_userret)
931.1Sfvdl		(p->p_userret)(l, p->p_userret_arg);
941.1Sfvdl
951.1Sfvdl	while (l->l_flag & L_SA_UPCALL)
961.1Sfvdl		sa_upcall_userret(l);
971.1Sfvdl
981.1Sfvdl	curcpu()->ci_schedstate.spc_curpriority = l->l_priority = l->l_usrpri;
991.1Sfvdl}
100