From c18cae3e9016a7c8e0a21e0266638a97b2c98797 Mon Sep 17 00:00:00 2001 From: christos Date: Thu, 11 Sep 2003 20:23:46 +0000 Subject: [PATCH] For kernels that have COMPAT_16 enabled, detect that and use the old sigcontext trampoline code when SA_SIGINFO is not set. --- .../arch/i386/sys/__sigaction14_sigtramp.c | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/lib/libc/arch/i386/sys/__sigaction14_sigtramp.c b/lib/libc/arch/i386/sys/__sigaction14_sigtramp.c index 089ab4b9c91f..5b66d9137dc7 100644 --- a/lib/libc/arch/i386/sys/__sigaction14_sigtramp.c +++ b/lib/libc/arch/i386/sys/__sigaction14_sigtramp.c @@ -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 +#include #include +#include +#include +#include #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)); }