For kernels that have COMPAT_16 enabled, detect that and use the old

sigcontext trampoline code when SA_SIGINFO is not set.
This commit is contained in:
christos 2003-09-11 20:23:46 +00:00
parent 7340db7385
commit c18cae3e90

View File

@ -1,4 +1,4 @@
/* $NetBSD: __sigaction14_sigtramp.c,v 1.3 2003/09/06 22:10:40 christos Exp $ */
/* $NetBSD: __sigaction14_sigtramp.c,v 1.4 2003/09/11 20:23:46 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -39,17 +39,45 @@
#define __LIBC12_SOURCE__
#include <sys/types.h>
#include <sys/param.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);
static void
get_have_sigreturn(void)
{
#if defined(SYS___sigreturn14)
__have_sigreturn = syscall(SYS___sigreturn14, NULL) == EFAULT;
#elif defined(SYS_compat_16___sigreturn14)
__have_sigreturn = syscall(SYS_compat_16___sigreturn14, NULL) == EFAULT;
#else
__have_sigreturn = 0;
#endif
}
int
__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
{
extern int __sigtramp_siginfo_2[];
extern int __sigtramp_sigcontext_1[];
return (__sigaction_sigtramp(sig, act, oact,
__sigtramp_siginfo_2, 2));
if (__have_sigreturn == -1)
get_have_sigreturn();
if (__have_sigreturn && act && (act->sa_flags & SA_SIGINFO) == 0)
return (__sigaction_sigtramp(sig, act, oact,
__sigtramp_sigcontext_1, 1));
return (__sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2));
}