1 /* $NetBSD: svr4_lwp.c,v 1.13 2006/11/16 01:32:44 christos Exp $ */
2
3 /*-
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: svr4_lwp.c,v 1.13 2006/11/16 01:32:44 christos Exp $");
41
42 #include <sys/param.h>
43 #include <sys/kernel.h>
44 #include <sys/systm.h>
45 #include <sys/queue.h>
46 #include <sys/mbuf.h>
47 #include <sys/file.h>
48 #include <sys/mount.h>
49 #include <sys/time.h>
50 #include <sys/resourcevar.h>
51 #include <sys/proc.h>
52 #include <sys/user.h>
53 #include <sys/socket.h>
54 #include <sys/socketvar.h>
55 #include <sys/sa.h>
56 #include <sys/syscallargs.h>
57 #include <sys/un.h>
58 #include <sys/stat.h>
59
60 #include <compat/svr4/svr4_types.h>
61 #include <compat/svr4/svr4_util.h>
62 #include <compat/svr4/svr4_socket.h>
63 #include <compat/svr4/svr4_signal.h>
64 #include <compat/svr4/svr4_sockmod.h>
65 #include <compat/svr4/svr4_lwp.h>
66 #include <compat/svr4/svr4_ucontext.h>
67 #include <compat/svr4/svr4_syscallargs.h>
68
69
70 int
71 svr4_sys__lwp_self(l, v, retval)
72 struct lwp *l;
73 void *v;
74 register_t *retval;
75 {
76 return sys__lwp_self(l, v, retval);
77 }
78
79 int
80 svr4_sys__lwp_create(l, v, retval)
81 struct lwp *l;
82 void *v;
83 register_t *retval;
84 {
85 struct svr4_sys__lwp_create_args *uap = v;
86 struct sys__lwp_create_args lc;
87 int flags;
88
89 flags = 0;
90
91 if (SCARG(uap, flags) & SVR4_LWP_DETACHED)
92 flags &= LWP_DETACHED;
93
94 if (SCARG(uap, flags) & SVR4_LWP_SUSPENDED)
95 flags &= LWP_SUSPENDED;
96
97 if (SCARG(uap, flags) & SVR4___LWP_ASLWP) {
98 /* XXX Punt! */
99 }
100
101
102 /* XXX At the moment, svr4_ucontext_t and ucontext_t are the same */
103 SCARG(&lc, ucp) = (ucontext_t *)SCARG(uap, uc);
104 SCARG(&lc, flags) = flags;
105 SCARG(&lc, new_lwp) = (lwpid_t *)SCARG(uap, lwpid);
106
107
108 return sys__lwp_create(l, &lc, retval);
109 }
110
111 int
112 svr4_sys__lwp_kill(l, v, retval)
113 struct lwp *l;
114 void *v;
115 register_t *retval;
116 {
117 struct svr4_sys__lwp_kill_args *uap = v;
118 struct sys_kill_args ap;
119 SCARG(&ap, pid) = SCARG(uap, lwpid);
120 SCARG(&ap, signum) = SCARG(uap, signum);
121
122 /* XXX NJWLWP */
123 return sys_kill(l, &ap, retval);
124 }
125
126 int
127 svr4_sys__lwp_info(struct lwp *l, void *v, register_t *retval)
128 {
129 struct svr4_sys__lwp_info_args *uap = v;
130 struct svr4_lwpinfo lwpinfo;
131 int error;
132
133 /* XXX NJWLWP */
134 TIMEVAL_TO_TIMESPEC(&l->l_proc->p_stats->p_ru.ru_stime, &lwpinfo.lwp_stime);
135 TIMEVAL_TO_TIMESPEC(&l->l_proc->p_stats->p_ru.ru_utime, &lwpinfo.lwp_utime);
136
137 if ((error = copyout(&lwpinfo, SCARG(uap, lwpinfo), sizeof(lwpinfo))) ==
138 -1)
139 return error;
140 return 0;
141 }
142
143 int
144 svr4_sys__lwp_exit(struct lwp *l, void *v, register_t *retval)
145 {
146
147 return sys__lwp_exit(l, NULL, retval);
148 }
149
150 int
151 svr4_sys__lwp_wait(l, v, retval)
152 struct lwp *l;
153 void *v;
154 register_t *retval;
155 {
156 struct svr4_sys__lwp_wait_args *uap = v;
157 struct sys__lwp_wait_args ap;
158
159 SCARG(&ap, wait_for) = SCARG(uap, wait_for);
160 SCARG(&ap, departed) = (lwpid_t *)SCARG(uap, departed_lwp);
161
162 return sys__lwp_wait(l, &ap, retval);
163 }
164
165 int
166 svr4_sys__lwp_suspend(l, v, retval)
167 struct lwp *l;
168 void *v;
169 register_t *retval;
170 {
171 struct svr4_sys__lwp_suspend_args *uap = v;
172 struct sys__lwp_suspend_args ap;
173
174 SCARG(&ap, target) = SCARG(uap, lwpid);
175
176 return sys__lwp_suspend(l, &ap, retval);
177 }
178
179
180 int
181 svr4_sys__lwp_continue(l, v, retval)
182 struct lwp *l;
183 void *v;
184 register_t *retval;
185 {
186 struct svr4_sys__lwp_continue_args *uap = v;
187 struct sys__lwp_continue_args ap;
188
189 SCARG(&ap, target) = SCARG(uap, lwpid);
190
191 return sys__lwp_continue(l, &ap, retval);
192 }
193
194 int
195 svr4_sys__lwp_getprivate(struct lwp *l, void *v, register_t *retval)
196 {
197 /* XXX NJWLWP: Replace with call to native version if we ever
198 * implement that. */
199
200 *retval = (register_t)l->l_private;
201 return 0;
202 }
203
204 int
205 svr4_sys__lwp_setprivate(struct lwp *l, void *v, register_t *retval)
206 {
207 struct svr4_sys__lwp_setprivate_args *uap = v;
208
209 /* XXX NJWLWP: Replace with call to native version if we ever
210 * implement that. */
211
212 return copyin(SCARG(uap, buffer), &l->l_private, sizeof(void *));
213 }
Cache object: b83e99800a7d8451ee93d7249f81109b
|