1 /* $NetBSD: kern_sig_13.c,v 1.18 2008/04/24 18:39:22 ad Exp $ */
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: kern_sig_13.c,v 1.18 2008/04/24 18:39:22 ad Exp $");
35 #include <sys/param.h>
37 #include <sys/signal.h>
38 #include <sys/signalvar.h>
39 #include <sys/systm.h>
41 #include <sys/mount.h>
42 #include <sys/syscallargs.h>
44 #include <machine/limits.h>
46 #include <compat/sys/signal.h>
47 #include <compat/sys/signalvar.h>
48 #include <compat/common/compat_util.h>
49 #include <compat/common/compat_sigaltstack.h>
52 native_sigset13_to_sigset(const sigset13_t
*oss
, sigset_t
*ss
)
62 native_sigset_to_sigset13(const sigset_t
*ss
, sigset13_t
*oss
)
69 native_sigaction13_to_sigaction(const struct sigaction13
*osa
, struct sigaction
*sa
)
72 sa
->sa_handler
= osa
->osa_handler
;
73 native_sigset13_to_sigset(&osa
->osa_mask
, &sa
->sa_mask
);
74 sa
->sa_flags
= osa
->osa_flags
;
78 native_sigaction_to_sigaction13(const struct sigaction
*sa
, struct sigaction13
*osa
)
81 osa
->osa_handler
= sa
->sa_handler
;
82 native_sigset_to_sigset13(&sa
->sa_mask
, &osa
->osa_mask
);
83 osa
->osa_flags
= sa
->sa_flags
;
87 compat_13_sys_sigaltstack(struct lwp
*l
, const struct compat_13_sys_sigaltstack_args
*uap
, register_t
*retval
)
90 syscallarg(const struct sigaltstack13 *) nss;
91 syscallarg(struct sigaltstack13 *) oss;
93 compat_sigaltstack(uap
, sigaltstack13
, SS_ONSTACK
, SS_DISABLE
);
97 compat_13_sys_sigaction(struct lwp
*l
, const struct compat_13_sys_sigaction_args
*uap
, register_t
*retval
)
100 syscallarg(int) signum;
101 syscallarg(const struct sigaction13 *) nsa;
102 syscallarg(struct sigaction13 *) osa;
104 struct sigaction13 nesa
, oesa
;
105 struct sigaction nbsa
, obsa
;
108 if (SCARG(uap
, nsa
)) {
109 error
= copyin(SCARG(uap
, nsa
), &nesa
, sizeof(nesa
));
112 native_sigaction13_to_sigaction(&nesa
, &nbsa
);
114 error
= sigaction1(l
, SCARG(uap
, signum
),
115 SCARG(uap
, nsa
) ? &nbsa
: 0, SCARG(uap
, osa
) ? &obsa
: 0,
119 if (SCARG(uap
, osa
)) {
120 native_sigaction_to_sigaction13(&obsa
, &oesa
);
121 error
= copyout(&oesa
, SCARG(uap
, osa
), sizeof(oesa
));
129 compat_13_sys_sigprocmask(struct lwp
*l
, const struct compat_13_sys_sigprocmask_args
*uap
, register_t
*retval
)
133 syscallarg(int) mask;
135 struct proc
*p
= l
->l_proc
;
136 sigset13_t ness
, oess
;
140 ness
= SCARG(uap
, mask
);
141 native_sigset13_to_sigset(&ness
, &nbss
);
142 mutex_enter(p
->p_lock
);
143 error
= sigprocmask1(l
, SCARG(uap
, how
), &nbss
, &obss
);
144 mutex_exit(p
->p_lock
);
147 native_sigset_to_sigset13(&obss
, &oess
);
153 compat_13_sys_sigpending(struct lwp
*l
, const void *v
, register_t
*retval
)
158 sigpending1(l
, &bss
);
159 native_sigset_to_sigset13(&bss
, &ess
);
165 compat_13_sys_sigsuspend(struct lwp
*l
, const struct compat_13_sys_sigsuspend_args
*uap
, register_t
*retval
)
168 syscallarg(sigset13_t) mask;
173 ess
= SCARG(uap
, mask
);
174 native_sigset13_to_sigset(&ess
, &bss
);
175 return (sigsuspend1(l
, &bss
));