Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/arch/m68k/sys Userland portion of SIGTRAMP_VALID() ...



details:   https://anonhg.NetBSD.org/src/rev/9d1ee7969de8
branches:  trunk
changeset: 553558:9d1ee7969de8
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Oct 18 18:16:23 2003 +0000

description:
Userland portion of SIGTRAMP_VALID() commit.

diffstat:

 lib/libc/arch/m68k/sys/__sigaction14_sigtramp.c |  59 ++++++++++--------------
 1 files changed, 25 insertions(+), 34 deletions(-)

diffs (85 lines):

diff -r d1fa6ecbcd26 -r 9d1ee7969de8 lib/libc/arch/m68k/sys/__sigaction14_sigtramp.c
--- a/lib/libc/arch/m68k/sys/__sigaction14_sigtramp.c   Sat Oct 18 18:08:07 2003 +0000
+++ b/lib/libc/arch/m68k/sys/__sigaction14_sigtramp.c   Sat Oct 18 18:16:23 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: __sigaction14_sigtramp.c,v 1.3 2003/09/22 14:42:03 cl Exp $    */
+/*     $NetBSD: __sigaction14_sigtramp.c,v 1.4 2003/10/18 18:16:23 christos Exp $      */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,51 +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[];
-extern int __sigreturn14(struct sigcontext *);
-
-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(SIGILL, &nsa, &osa, __sigtramp_siginfo_2, 2);
-
-       /* (void)syscall(SYS_compat_16___sigreturn14, NULL); */
-       (void)__sigreturn14(NULL);
-       have_sigreturn = errno == EFAULT;
-
-       __sigaction_sigtramp(SIGILL, &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 no sigaction, use the "default" trampoline since it won't
+        * be used.
+        */
+       if (act == NULL)
+               return  __sigaction_sigtramp(sig, act, oact, NULL, 0);
 
-       if (have_sigreturn && act && (act->sa_flags & SA_SIGINFO) == 0)
-               return __sigaction_sigtramp(sig, act, oact,
+       /*
+        * 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);
 }



Home | Main Index | Thread Index | Old Index