Subject: SA_SIGINFO for mips
To: None <port-mips@netbsd.org>
From: Christopher SEKIYA <wileyc@rezrov.net>
List: port-mips
Date: 10/12/2003 13:03:13
All,

Attached is a diff that implements the SA_SIGINFO bits for mips.  It's
a direct copy of the i386 implementation.  This addresses a failure during
the regression tests and permits a make build to complete.

-- Chris
	GPG key FEB9DE7F (91AF 4534 4529 4BCC 31A5  938E 023E EEFB FEB9 DE7F)


Index: lib/libc/arch/mips/sys/__sigaction14_sigtramp.c
===================================================================
RCS file: /cvsroot/src/lib/libc/arch/mips/sys/__sigaction14_sigtramp.c,v
retrieving revision 1.2
diff -u -r1.2 __sigaction14_sigtramp.c
--- lib/libc/arch/mips/sys/__sigaction14_sigtramp.c	2003/01/18 11:10:45	1.2
+++ lib/libc/arch/mips/sys/__sigaction14_sigtramp.c	2003/10/12 03:20:46
@@ -36,25 +36,51 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#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);
+
+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)
 {
-	extern int __sigtramp_sigcontext_1[];
+	if (have_sigreturn == -1)
+		get_have_sigreturn();
 
-	/*
-	 * Right here we should select the SA_SIGINFO trampoline
-	 * if SA_SIGINFO is set in the sigaction.
-	 */
+	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_sigcontext_1, 1));
+	return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2);
 }
Index: sys/arch/mips/include/signal.h
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/include/signal.h,v
retrieving revision 1.20
diff -u -r1.20 signal.h
--- sys/arch/mips/include/signal.h	2003/08/07 16:28:29	1.20
+++ sys/arch/mips/include/signal.h	2003/10/12 03:21:03
@@ -41,6 +41,13 @@
 
 #include <machine/cdefs.h>	/* for API selection */
 
+#define __HAVE_SIGINFO
+#ifdef COMPAT_16
+#define SIGTRAMP_VALID(vers)	((unsigned)(vers) <= 2)
+#else
+#define SIGTRAMP_VALID(vers)	((vers) == 2)
+#endif
+
 #if !defined(__ASSEMBLER__)
 
 /*