4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
36 * pid = vforkx(flags);
37 * syscall trap: forksys(2, flags)
40 * syscall trap: forksys(2, 0)
43 * %o1 == 0 in parent process, %o1 == 1 in child process.
44 * %o0 == pid of child in parent, %o0 == pid of parent in child.
46 * The child gets a zero return value.
47 * The parent gets the pid of the child.
51 * Note that since the SPARC architecture maintains stack maintence
52 * information (return pc, sp, fp) in the register windows, both parent
53 * and child can execute in a common address space without conflict.
55 * We block all blockable signals while performing the vfork() system call
56 * trap. This enables us to set curthread->ul_vfork safely, so that we
57 * don't end up in a signal handler with curthread->ul_vfork set wrong.
62 mov
%o0
, %o5
/* flags */
64 clr
%o5
/* flags = 0 */
66 mov SIG_SETMASK
, %o0
/* block all signals */
71 SYSTRAP_RVAL1
(lwp_sigmask
)
73 mov
%o5
, %o1
/* flags */
75 SYSTRAP_2RVALS
(forksys
) /* vforkx(flags) */
79 mov
%o0
, %o5
/* save the vfork() error number */
81 mov SIG_SETMASK
, %o0
/* reinstate signals */
82 ld [%g7
+ UL_SIGMASK
], %o1
83 ld [%g7
+ UL_SIGMASK
+ 4], %o2
84 ld [%g7
+ UL_SIGMASK
+ 8], %o3
85 ld [%g7
+ UL_SIGMASK
+ 12], %o4
86 SYSTRAP_RVAL1
(lwp_sigmask
)
89 mov
%o5
, %o0
/* restore the vfork() error number */
93 * To determine if we are (still) a child of vfork(), the child
94 * increments curthread->ul_vfork by one and the parent decrements
95 * it by one. If the result is zero, then we are not a child of
96 * vfork(), else we are. We do this to deal with the case of
97 * a vfork() child calling vfork().
100 ld [%g7
+ UL_VFORK
], %g1
101 brnz
,a,pt
%g1
, 3f
/* don't let it go negative */
102 sub %g1
, 1, %g1
/* curthread->ul_vfork--; */
105 clr
%o0
/* zero the return value in the child */
106 add %g1
, 1, %g1
/* curthread->ul_vfork++; */
108 st %g1
, [%g7
+ UL_VFORK
]
110 * Clear the schedctl interface in both parent and child.
111 * (The child might have modified the parent.)
113 stn
%g0
, [%g7
+ UL_SCHEDCTL
]
114 stn
%g0
, [%g7
+ UL_SCHEDCTL_CALLED
]
115 mov
%o0
, %o5
/* save the vfork() return value */
117 mov SIG_SETMASK
, %o0
/* reinstate signals */
118 ld [%g7
+ UL_SIGMASK
], %o1
119 ld [%g7
+ UL_SIGMASK
+ 4], %o2
120 ld [%g7
+ UL_SIGMASK
+ 8], %o3
121 ld [%g7
+ UL_SIGMASK
+ 12], %o4
122 SYSTRAP_RVAL1
(lwp_sigmask
)
125 mov
%o5
, %o0
/* restore the vfork() return value */