Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / compat / netbsd32 / netbsd32_lwp.c
blobd839f68bb390ae7385f09d8344aeb8c6e830ddc7
1 /* $NetBSD: netbsd32_lwp.c,v 1.10.14.1 2009/01/04 01:56:02 christos Exp $ */
3 /*
4 * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __KERNEL_RCSID(0, "$NetBSD: netbsd32_lwp.c,v 1.10.14.1 2009/01/04 01:56:02 christos Exp $");
32 #include <sys/types.h>
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/dirent.h>
37 #include <sys/mount.h>
38 #include <sys/proc.h>
39 #include <sys/syscallargs.h>
40 #include <sys/lwpctl.h>
42 #include <compat/netbsd32/netbsd32.h>
43 #include <compat/netbsd32/netbsd32_syscallargs.h>
44 #include <compat/netbsd32/netbsd32_conv.h>
46 /* Sycalls conversion */
48 int
49 netbsd32__lwp_create(struct lwp *l, const struct netbsd32__lwp_create_args *uap, register_t *retval)
51 /* {
52 syscallarg(const netbsd32_ucontextp) ucp;
53 syscallarg(netbsd32_u_long) flags;
54 syscallarg(netbsd32_lwpidp) new_lwp;
55 } */
56 struct sys__lwp_create_args ua;
58 NETBSD32TOP_UAP(ucp, const ucontext_t);
59 NETBSD32TO64_UAP(flags);
60 NETBSD32TOP_UAP(new_lwp, lwpid_t);
62 return sys__lwp_create(l, &ua, retval);
65 int
66 netbsd32__lwp_wait(struct lwp *l, const struct netbsd32__lwp_wait_args *uap, register_t *retval)
68 /* {
69 syscallarg(lwpid_t) wait_for;
70 syscallarg(netbsd32_lwpidp) departed;
71 } */
72 struct sys__lwp_wait_args ua;
74 NETBSD32TO64_UAP(wait_for);
75 NETBSD32TOP_UAP(departed, lwpid_t);
76 return sys__lwp_wait(l, &ua, retval);
79 int
80 netbsd32__lwp_suspend(struct lwp *l, const struct netbsd32__lwp_suspend_args *uap, register_t *retval)
82 /* {
83 syscallarg(lwpid_t) target;
84 } */
85 struct sys__lwp_suspend_args ua;
87 NETBSD32TO64_UAP(target);
88 return sys__lwp_suspend(l, &ua, retval);
91 int
92 netbsd32__lwp_continue(struct lwp *l, const struct netbsd32__lwp_continue_args *uap, register_t *retval)
94 /* {
95 syscallarg(lwpid_t) target;
96 } */
97 struct sys__lwp_continue_args ua;
99 NETBSD32TO64_UAP(target);
100 return sys__lwp_continue(l, &ua, retval);
104 netbsd32__lwp_wakeup(struct lwp *l, const struct netbsd32__lwp_wakeup_args *uap, register_t *retval)
106 /* {
107 syscallarg(lwpid_t) target;
108 } */
109 struct sys__lwp_wakeup_args ua;
111 NETBSD32TO64_UAP(target);
112 return sys__lwp_wakeup(l, &ua, retval);
116 netbsd32__lwp_setprivate(struct lwp *l, const struct netbsd32__lwp_setprivate_args *uap, register_t *retval)
118 /* {
119 syscallarg(netbsd32_voidp) ptr;
120 } */
121 struct sys__lwp_setprivate_args ua;
123 NETBSD32TOP_UAP(ptr, void);
124 return sys__lwp_setprivate(l, &ua, retval);
128 netbsd32____lwp_park50(struct lwp *l,
129 const struct netbsd32____lwp_park50_args *uap, register_t *retval)
131 /* {
132 syscallarg(const netbsd32_timespec50p) ts;
133 syscallarg(lwpid_t) unpark;
134 syscallarg(netbsd32_voidp) hint;
135 syscallarg(netbsd32_voidp) unparkhint;
136 } */
137 struct timespec ts, *tsp;
138 struct netbsd32_timespec ts32;
139 int error;
141 if (SCARG_P32(uap, ts) == NULL)
142 tsp = NULL;
143 else {
144 error = copyin(SCARG_P32(uap, ts), &ts32, sizeof ts32);
145 if (error != 0)
146 return error;
147 netbsd32_to_timespec(&ts32, &ts);
148 tsp = &ts;
151 if (SCARG(uap, unpark) != 0) {
152 error = lwp_unpark(SCARG(uap, unpark),
153 SCARG_P32(uap, unparkhint));
154 if (error != 0)
155 return error;
158 return lwp_park(tsp, SCARG_P32(uap, hint));
162 netbsd32__lwp_kill(struct lwp *l, const struct netbsd32__lwp_kill_args *uap, register_t *retval)
164 /* {
165 syscallarg(lwpid_t) target;
166 syscallarg(int) signo;
167 } */
168 struct sys__lwp_kill_args ua;
170 NETBSD32TO64_UAP(target);
171 NETBSD32TO64_UAP(signo);
172 return sys__lwp_kill(l, &ua, retval);
175 netbsd32__lwp_detach(struct lwp *l, const struct netbsd32__lwp_detach_args *uap, register_t *retval)
177 /* {
178 syscallarg(lwpid_t) target;
179 } */
180 struct sys__lwp_detach_args ua;
182 NETBSD32TO64_UAP(target);
183 return sys__lwp_detach(l, &ua, retval);
187 netbsd32__lwp_unpark(struct lwp *l, const struct netbsd32__lwp_unpark_args *uap, register_t *retval)
189 /* {
190 syscallarg(lwpid_t) target;
191 syscallarg(netbsd32_voidp) hint;
192 } */
193 struct sys__lwp_unpark_args ua;
195 NETBSD32TO64_UAP(target);
196 NETBSD32TOP_UAP(hint, void);
197 return sys__lwp_unpark(l, &ua, retval);
201 netbsd32__lwp_unpark_all(struct lwp *l, const struct netbsd32__lwp_unpark_all_args *uap, register_t *retval)
203 /* {
204 syscallarg(const netbsd32_lwpidp) targets;
205 syscallarg(netbsd32_size_t) ntargets;
206 syscallarg(netbsd32_voidp) hint;
207 } */
208 struct sys__lwp_unpark_all_args ua;
210 NETBSD32TOP_UAP(targets, const lwpid_t);
211 NETBSD32TOX_UAP(ntargets, size_t);
212 NETBSD32TOP_UAP(hint, void);
213 return sys__lwp_unpark_all(l, &ua, retval);
217 netbsd32__lwp_setname(struct lwp *l, const struct netbsd32__lwp_setname_args *uap, register_t *retval)
219 /* {
220 syscallarg(lwpid_t) target;
221 syscallarg(const netbsd32_charp) name;
222 } */
223 struct sys__lwp_setname_args ua;
225 NETBSD32TO64_UAP(target);
226 NETBSD32TOP_UAP(name, char *);
227 return sys__lwp_setname(l, &ua, retval);
231 netbsd32__lwp_getname(struct lwp *l, const struct netbsd32__lwp_getname_args *uap, register_t *retval)
233 /* {
234 syscallarg(lwpid_t) target;
235 syscallarg(netbsd32_charp) name;
236 syscallarg(netbsd32_size_t) len;
237 } */
238 struct sys__lwp_getname_args ua;
240 NETBSD32TO64_UAP(target);
241 NETBSD32TOP_UAP(name, char *);
242 NETBSD32TOX_UAP(len, size_t);
243 return sys__lwp_getname(l, &ua, retval);
247 netbsd32__lwp_ctl(struct lwp *l, const struct netbsd32__lwp_ctl_args *uap, register_t *retval)
249 /* {
250 syscallarg(int) features;
251 syscallarg(netbsd32_pointer_t) address;
252 } */
253 struct sys__lwp_ctl_args ua;
255 NETBSD32TO64_UAP(features);
256 NETBSD32TOP_UAP(address, struct lwpctl *);
257 return sys__lwp_ctl(l, &ua, retval);