Call sigaltstack1() directly instead of using the stackgap to call

sys___sigaltstack14().
Prototype up some code under #if 0 to use sigaction1().
This commit is contained in:
dsl 2007-05-13 09:07:25 +00:00
parent 0a4e8a3014
commit d4540f5b2a
1 changed files with 27 additions and 66 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_signal.c,v 1.30 2007/03/04 06:01:28 christos Exp $ */
/* $NetBSD: osf1_signal.c,v 1.31 2007/05/13 09:07:25 dsl Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: osf1_signal.c,v 1.30 2007/03/04 06:01:28 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: osf1_signal.c,v 1.31 2007/05/13 09:07:25 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -116,48 +116,26 @@ osf1_sys_sigaltstack(l, v, retval)
register_t *retval;
{
struct osf1_sys_sigaltstack_args *uap = v;
struct proc *p = l->l_proc;
struct osf1_sigaltstack *noss, *ooss, tmposs;
struct sigaltstack *nbss, *obss, tmpbss;
struct sys___sigaltstack14_args sa;
void *sg;
struct osf1_sigaltstack osf1_ss;
struct sigaltstack nbss, obss;
int error;
sg = stackgap_init(p, 0);
noss = SCARG(uap, nss);
ooss = SCARG(uap, oss);
if (ooss != NULL)
obss = stackgap_alloc(p, &sg, sizeof(struct sigaltstack));
else
obss = NULL;
if (noss != NULL) {
nbss = stackgap_alloc(p, &sg, sizeof(struct sigaltstack));
if ((error = copyin(noss, &tmposs, sizeof(tmposs))) != 0)
if (SCARG(uap, nss) != NULL) {
error = copyin(SCARG(uap, nss), &osf1_ss, sizeof(osf1_ss));
if (error != 0)
return error;
if ((error = osf1_cvt_sigaltstack_to_native(&tmposs, &tmpbss)) != 0)
return error;
if ((error = copyout(&tmpbss, nbss, sizeof(tmpbss))) != 0)
error = osf1_cvt_sigaltstack_to_native(&osf1_ss, &nbss);
if (error != 0)
return error;
error = sigaltstack1(l, &nbss, &obss);
} else
nbss = NULL;
error = sigaltstack1(l, NULL, &obss);
SCARG(&sa, nss) = nbss;
SCARG(&sa, oss) = obss;
if ((error = sys___sigaltstack14(l, &sa, retval)) != 0)
if (error != 0 || SCARG(uap, oss) == NULL)
return error;
if (obss != NULL) {
if ((error = copyin(obss, &tmpbss, sizeof(tmpbss))) != 0)
return error;
osf1_cvt_sigaltstack_from_native(&tmpbss, &tmposs);
if ((error = copyout(&tmposs, ooss, sizeof(tmposs))) != 0)
return error;
}
return 0;
osf1_cvt_sigaltstack_from_native(&obss, &osf1_ss);
return copyout(&osf1_ss, SCARG(uap, oss), sizeof(osf1_ss));
}
#if 0
@ -171,7 +149,6 @@ osf1_sys_signal(l, v, retval)
struct proc *p = l->l_proc;
int signum;
int error;
void *sg = stackgap_init(p, 0);
if (SCARG(uap, signum) < 0 || SCARG(uap, signum) > OSF1_NSIG)
return EINVAL;
@ -202,32 +179,23 @@ osf1_sys_signal(l, v, retval)
case OSF1_SIGNAL_MASK:
{
struct sys_sigaction_args sa_args;
struct sigaction *nbsa, *obsa, sa;
struct sigaction nbsa, obsa;
nbsa = stackgap_alloc(p, &sg, sizeof(struct sigaction));
obsa = stackgap_alloc(p, &sg, sizeof(struct sigaction));
SCARG(&sa_args, signum) = signum;
SCARG(&sa_args, nsa) = nbsa;
SCARG(&sa_args, osa) = obsa;
sa.sa_handler = SCARG(uap, handler);
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
nbsa.sa_handler = SCARG(uap, handler);
sigemptyset(&nbsa.sa_mask);
nbsa.sa_flags = 0;
#if 0
if (signum != SIGALRM)
sa.sa_flags = SA_RESTART;
nbsa.sa_flags = SA_RESTART;
#endif
if ((error = copyout(&sa, nbsa, sizeof(sa))) != 0)
return error;
if ((error = sys_sigaction(l, &sa_args, retval)) != 0) {
error = sigaction1(l, signum, &nbsa, &obsa, ?, ?);
if (error != 0) {
DPRINTF(("signal: sigaction failed: %d\n",
error));
*retval = (int)OSF1_SIG_ERR;
return error;
}
if ((error = copyin(obsa, &sa, sizeof(sa))) != 0)
return error;
*retval = (int)sa.sa_handler;
*retval = (int)obsa.sa_handler;
return 0;
}
@ -252,19 +220,12 @@ osf1_sys_signal(l, v, retval)
case OSF1_SIGIGNORE_MASK:
{
struct sys_sigaction_args sa_args;
struct sigaction *bsa, sa;
struct sigaction bsa;
bsa = stackgap_alloc(p, &sg, sizeof(struct sigaction));
SCARG(&sa_args, signum) = signum;
SCARG(&sa_args, nsa) = bsa;
SCARG(&sa_args, osa) = NULL;
sa.sa_handler = SIG_IGN;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
if ((error = copyout(&sa, bsa, sizeof(sa))) != 0)
return error;
if ((error = sys_sigaction(l, &sa_args, retval)) != 0) {
bsa.sa_handler = SIG_IGN;
sigemptyset(&bsa.sa_mask);
bsa.sa_flags = 0;
if ((error = sigaction1(l, &bsa, NULL, ?, ?)) != 0) {
DPRINTF(("sigignore: sigaction failed\n"));
return error;
}