Sync usage with man page.
[netbsd-mini2440.git] / sys / compat / netbsd32 / netbsd32_sem.c
blob3885969e1a2875dd85a8efba4422eac513d20acc
1 /* $NetBSD: netbsd32_sem.c,v 1.7 2008/04/29 06:53:02 martin Exp $ */
3 /*
4 * Copyright (c) 2006 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_sem.c,v 1.7 2008/04/29 06:53:02 martin Exp $");
32 #ifdef _KERNEL_OPT
33 #include "opt_posix.h"
34 #endif
36 #include <sys/types.h>
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/kernel.h>
40 #include <sys/dirent.h>
41 #include <sys/ksem.h>
42 #include <sys/mount.h>
43 #include <sys/proc.h>
44 #include <sys/syscallargs.h>
46 #include <compat/netbsd32/netbsd32.h>
47 #include <compat/netbsd32/netbsd32_syscallargs.h>
48 #include <compat/netbsd32/netbsd32_conv.h>
50 static int
51 netbsd32_ksem_copyout(const void *src, void *dst, size_t size)
53 const intptr_t *idp = src;
54 netbsd32_intptr_t id32, *outidp = dst;
56 KASSERT(size == sizeof(intptr_t));
58 /* Returning a kernel pointer to userspace sucks badly :-( */
59 id32 = (netbsd32_intptr_t)*idp;
60 return copyout(&id32, outidp, sizeof(id32));
63 int
64 netbsd32__ksem_init(struct lwp *l, const struct netbsd32__ksem_init_args *uap, register_t *retval)
66 /* {
67 syscallarg(unsigned int) value;
68 syscallarg(netbsd32_semidp_t) idp;
69 } */
71 return do_ksem_init(l, SCARG(uap, value),
72 SCARG_P32(uap, idp), netbsd32_ksem_copyout);
75 int
76 netbsd32__ksem_open(struct lwp *l, const struct netbsd32__ksem_open_args *uap, register_t *retval)
78 /* {
79 syscallarg(const netbsd32_charp) name;
80 syscallarg(int) oflag;
81 syscallarg(mode_t) mode;
82 syscallarg(unsigned int) value;
83 syscallarg(netbsd32_semidp_t) idp;
84 } */
86 return do_ksem_open(l, SCARG_P32(uap, name),
87 SCARG(uap, oflag), SCARG(uap, mode), SCARG(uap, value),
88 SCARG_P32(uap, idp), netbsd32_ksem_copyout);
91 int
92 netbsd32__ksem_unlink(struct lwp *l, const struct netbsd32__ksem_unlink_args *uap, register_t *retval)
94 /* {
95 syscallarg(const netbsd32_charp) name;
96 } */
97 struct sys__ksem_unlink_args ua;
99 NETBSD32TOP_UAP(name, const char);
100 return sys__ksem_unlink(l, &ua, retval);
104 netbsd32__ksem_close(struct lwp *l, const struct netbsd32__ksem_close_args *uap, register_t *retval)
106 /* {
107 syscallarg(netbsd32_intptr_t) id;
108 } */
109 struct sys__ksem_close_args ua;
111 NETBSD32TOX_UAP(id, intptr_t);
112 return sys__ksem_close(l, &ua, retval);
116 netbsd32__ksem_post(struct lwp *l, const struct netbsd32__ksem_post_args *uap, register_t *retval)
118 /* {
119 syscallarg(netbsd32_intptr_t) id;
120 } */
121 struct sys__ksem_post_args ua;
123 NETBSD32TOX_UAP(id, intptr_t);
124 return sys__ksem_post(l, &ua, retval);
128 netbsd32__ksem_wait(struct lwp *l, const struct netbsd32__ksem_wait_args *uap, register_t *retval)
130 /* {
131 syscallarg(netbsd32_intptr_t) id;
132 } */
133 struct sys__ksem_wait_args ua;
135 NETBSD32TOX_UAP(id, intptr_t);
136 return sys__ksem_wait(l, &ua, retval);
140 netbsd32__ksem_trywait(struct lwp *l, const struct netbsd32__ksem_trywait_args *uap, register_t *retval)
142 /* {
143 syscallarg(netbsd32_intptr_t) id;
144 } */
145 struct sys__ksem_trywait_args ua;
147 NETBSD32TOX_UAP(id, intptr_t);
148 return sys__ksem_trywait(l, &ua, retval);
152 netbsd32__ksem_destroy(struct lwp *l, const struct netbsd32__ksem_destroy_args *uap, register_t *retval)
154 /* {
155 syscallarg(netbsd32_intptr_t) id;
156 } */
157 struct sys__ksem_destroy_args ua;
159 NETBSD32TOX_UAP(id, intptr_t);
160 return sys__ksem_destroy(l, &ua, retval);
164 netbsd32__ksem_getvalue(struct lwp *l, const struct netbsd32__ksem_getvalue_args *uap, register_t *retval)
166 /* {
167 syscallarg(netbsd32_intptr_t) id;
168 syscallarg(netbsd32_intp) value;
169 } */
170 struct sys__ksem_getvalue_args ua;
172 NETBSD32TOX_UAP(id, intptr_t);
173 NETBSD32TOP_UAP(value, unsigned int);
174 return sys__ksem_getvalue(l, &ua, retval);