netbsd32_signal.c revision 1.1.4.3 1 /* $NetBSD: netbsd32_signal.c,v 1.1.4.3 2002/08/23 02:37:11 petrov Exp $ */
2
3 /*
4 * Copyright (c) 1998, 2001 Matthew R. Green
5 * All rights reserved.
6 *
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.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: netbsd32_signal.c,v 1.1.4.3 2002/08/23 02:37:11 petrov Exp $");
33
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/malloc.h>
37 #include <sys/mount.h>
38 #include <sys/stat.h>
39 #include <sys/time.h>
40 #include <sys/signalvar.h>
41 #include <sys/proc.h>
42
43 #include <compat/netbsd32/netbsd32.h>
44 #include <compat/netbsd32/netbsd32_syscallargs.h>
45
46 int
47 netbsd32_sigaction(l, v, retval)
48 struct lwp *l;
49 void *v;
50 register_t *retval;
51 {
52 struct netbsd32_sigaction_args /* {
53 syscallarg(int) signum;
54 syscallarg(const netbsd32_sigactionp_t) nsa;
55 syscallarg(netbsd32_sigactionp_t) osa;
56 } */ *uap = v;
57 struct sigaction nsa, osa;
58 struct netbsd32_sigaction *sa32p, sa32;
59 int error;
60
61 if (SCARG(uap, nsa)) {
62 sa32p = (struct netbsd32_sigaction *)(u_long)SCARG(uap, nsa);
63 if (copyin(sa32p, &sa32, sizeof(sa32)))
64 return EFAULT;
65 nsa.sa_handler = (void *)(u_long)sa32.sa_handler;
66 nsa.sa_mask = sa32.sa_mask;
67 nsa.sa_flags = sa32.sa_flags;
68 }
69 error = sigaction1(l->l_proc, SCARG(uap, signum),
70 SCARG(uap, nsa) ? &nsa : 0,
71 SCARG(uap, osa) ? &osa : 0,
72 NULL, 0);
73
74 if (error)
75 return (error);
76
77 if (SCARG(uap, osa)) {
78 sa32.sa_handler = (netbsd32_sigactionp_t)(u_long)osa.sa_handler;
79 sa32.sa_mask = osa.sa_mask;
80 sa32.sa_flags = osa.sa_flags;
81 sa32p = (struct netbsd32_sigaction *)(u_long)SCARG(uap, osa);
82 if (copyout(&sa32, sa32p, sizeof(sa32)))
83 return EFAULT;
84 }
85
86 return (0);
87 }
88
89 int
90 netbsd32___sigaltstack14(l, v, retval)
91 struct lwp *l;
92 void *v;
93 register_t *retval;
94 {
95 struct netbsd32___sigaltstack14_args /* {
96 syscallarg(const netbsd32_sigaltstackp_t) nss;
97 syscallarg(netbsd32_sigaltstackp_t) oss;
98 } */ *uap = v;
99 struct netbsd32_sigaltstack s32;
100 struct sigaltstack nss, oss;
101 int error;
102
103 if (SCARG(uap, nss)) {
104 error = copyin((caddr_t)(u_long)SCARG(uap, nss), &s32, sizeof(s32));
105 if (error)
106 return (error);
107 nss.ss_sp = (void *)(u_long)s32.ss_sp;
108 nss.ss_size = (size_t)s32.ss_size;
109 nss.ss_flags = s32.ss_flags;
110 }
111 error = sigaltstack1(l->l_proc,
112 SCARG(uap, nss) ? &nss : 0, SCARG(uap, oss) ? &oss : 0);
113 if (error)
114 return (error);
115 if (SCARG(uap, oss)) {
116 s32.ss_sp = (netbsd32_voidp)(u_long)oss.ss_sp;
117 s32.ss_size = (netbsd32_size_t)oss.ss_size;
118 s32.ss_flags = oss.ss_flags;
119 error = copyout(&s32, (caddr_t)(u_long)SCARG(uap, oss), sizeof(s32));
120 if (error)
121 return (error);
122 }
123 return (0);
124 }
125
126 /* ARGSUSED */
127 int
128 netbsd32___sigaction14(l, v, retval)
129 struct lwp *l;
130 void *v;
131 register_t *retval;
132 {
133 struct netbsd32___sigaction14_args /* {
134 syscallarg(int) signum;
135 syscallarg(const struct sigaction *) nsa;
136 syscallarg(struct sigaction *) osa;
137 } */ *uap = v;
138 struct netbsd32_sigaction sa32;
139 struct sigaction nsa, osa;
140 int error;
141
142 if (SCARG(uap, nsa)) {
143 error = copyin((caddr_t)(u_long)SCARG(uap, nsa),
144 &sa32, sizeof(sa32));
145 if (error)
146 return (error);
147 nsa.sa_handler = (void *)(u_long)sa32.sa_handler;
148 nsa.sa_mask = sa32.sa_mask;
149 nsa.sa_flags = sa32.sa_flags;
150 }
151 error = sigaction1(l->l_proc, SCARG(uap, signum),
152 SCARG(uap, nsa) ? &nsa : 0, SCARG(uap, osa) ? &osa : 0,
153 NULL, 0);
154 if (error)
155 return (error);
156 if (SCARG(uap, osa)) {
157 sa32.sa_handler = (netbsd32_voidp)(u_long)osa.sa_handler;
158 sa32.sa_mask = osa.sa_mask;
159 sa32.sa_flags = osa.sa_flags;
160 error = copyout(&sa32, (caddr_t)(u_long)SCARG(uap, osa), sizeof(sa32));
161 if (error)
162 return (error);
163 }
164 return (0);
165 }
166