sync with the x86 one.

This commit is contained in:
christos 2003-10-18 18:33:51 +00:00
parent 11088af0ac
commit f57e3e8f0a
1 changed files with 25 additions and 33 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: __sigaction14_sigtramp.c,v 1.3 2003/10/07 17:08:07 skd Exp $ */
/* $NetBSD: __sigaction14_sigtramp.c,v 1.4 2003/10/18 18:33:51 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -37,50 +37,42 @@
*/
#include <sys/types.h>
#include <sys/param.h>
#include <stddef.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include <sys/syscall.h>
#include "extern.h"
__weak_alias(__sigaction14, __libc_sigaction14)
static int have_sigreturn = -1;
static void get_have_sigreturn(void);
extern int __sigtramp_siginfo_2[];
extern int __sigtramp_sigcontext_1[];
static void
get_have_sigreturn(void)
{
struct sigaction nsa, osa;
sigemptyset(&nsa.sa_mask);
nsa.sa_flags = 0;
nsa.sa_handler = SIG_IGN;
__sigaction_sigtramp(SIGSYS, &nsa, &osa, __sigtramp_siginfo_2, 2);
(void)syscall(SYS_compat_16___sigreturn14, NULL);
have_sigreturn = errno == EFAULT;
__sigaction_sigtramp(SIGSYS, &osa, NULL, __sigtramp_siginfo_2, 2);
}
int
__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
{
if (have_sigreturn == -1)
get_have_sigreturn();
extern const int __sigtramp_sigcontext_1[];
extern const int __sigtramp_siginfo_2[];
int rv;
if (have_sigreturn && act && (act->sa_flags & SA_SIGINFO) == 0)
return __sigaction_sigtramp(sig, act, oact,
/*
* If no sigaction, use the "default" trampoline since it won't
* be used.
*/
if (act == NULL)
return __sigaction_sigtramp(sig, act, oact, NULL, 0);
/*
* We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not
* set in the sigaction.
*/
if ((act->sa_flags & SA_SIGINFO) == 0) {
rv = __sigaction_sigtramp(sig, act, oact,
__sigtramp_sigcontext_1, 1);
if (rv >= 0 || errno != EINVAL)
return rv;
}
/*
* If SA_SIGINFO was specified or the compatibility trampolines
* can't be used, use the siginfo trampoline.
*/
return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2);
}