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 SA_SIGINFO support for m68k (libc)



details:   https://anonhg.NetBSD.org/src/rev/af20d82e4ba6
branches:  trunk
changeset: 552261:af20d82e4ba6
user:      cl <cl%NetBSD.org@localhost>
date:      Mon Sep 22 14:42:02 2003 +0000

description:
SA_SIGINFO support for m68k (libc)

diffstat:

 lib/libc/arch/m68k/Makefile.inc                 |   4 +-
 lib/libc/arch/m68k/sys/__sigaction14_sigtramp.c |  47 ++++++++++++++++----
 lib/libc/arch/m68k/sys/__sigreturn14.S          |   5 +-
 lib/libc/arch/m68k/sys/__sigtramp1.S            |   3 +-
 lib/libc/arch/m68k/sys/__sigtramp2.S            |  57 +++++++++++++++++++++++++
 5 files changed, 101 insertions(+), 15 deletions(-)

diffs (189 lines):

diff -r a2b64d33a7db -r af20d82e4ba6 lib/libc/arch/m68k/Makefile.inc
--- a/lib/libc/arch/m68k/Makefile.inc   Mon Sep 22 14:37:57 2003 +0000
+++ b/lib/libc/arch/m68k/Makefile.inc   Mon Sep 22 14:42:02 2003 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.8 2002/07/10 04:29:07 thorpej Exp $
+#      $NetBSD: Makefile.inc,v 1.9 2003/09/22 14:42:02 cl Exp $
 
 KMINCLUDES=    arch/m68k/DEFS.h arch/m68k/SYS.h
 KMSRCS=        bcmp.S bcopy.S bzero.S ffs.S index.S rindex.S \
@@ -8,4 +8,4 @@
        ashldi3.S ashrdi3.S lshrdi3.S \
        bswap16.S bswap32.S bswap64.S
 
-SRCS+= __sigaction14_sigtramp.c __sigtramp1.S
+SRCS+= __sigaction14_sigtramp.c __sigtramp1.S __sigtramp2.S
diff -r a2b64d33a7db -r af20d82e4ba6 lib/libc/arch/m68k/sys/__sigaction14_sigtramp.c
--- a/lib/libc/arch/m68k/sys/__sigaction14_sigtramp.c   Mon Sep 22 14:37:57 2003 +0000
+++ b/lib/libc/arch/m68k/sys/__sigaction14_sigtramp.c   Mon Sep 22 14:42:02 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: __sigaction14_sigtramp.c,v 1.2 2003/01/18 11:09:37 thorpej Exp $       */
+/*     $NetBSD: __sigaction14_sigtramp.c,v 1.3 2003/09/22 14:42:03 cl Exp $    */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -36,25 +36,52 @@
  * 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[];
+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)
 {
-       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);
 }
diff -r a2b64d33a7db -r af20d82e4ba6 lib/libc/arch/m68k/sys/__sigreturn14.S
--- a/lib/libc/arch/m68k/sys/__sigreturn14.S    Mon Sep 22 14:37:57 2003 +0000
+++ b/lib/libc/arch/m68k/sys/__sigreturn14.S    Mon Sep 22 14:42:02 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: __sigreturn14.S,v 1.7 2003/08/07 16:42:14 agc Exp $    */
+/*     $NetBSD: __sigreturn14.S,v 1.8 2003/09/22 14:42:03 cl Exp $     */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -33,13 +33,14 @@
  * SUCH DAMAGE.
  */
 
+#define __HAVE_SIGINFO
 #include "SYS.h"
 
 #if defined(LIBC_SCCS) && !defined(lint)
 #if 0
        RCSID("from: @(#)sigreturn.s    5.1 (Berkeley) 5/12/90")
 #else
-       RCSID("$NetBSD: __sigreturn14.S,v 1.7 2003/08/07 16:42:14 agc Exp $")
+       RCSID("$NetBSD: __sigreturn14.S,v 1.8 2003/09/22 14:42:03 cl Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
diff -r a2b64d33a7db -r af20d82e4ba6 lib/libc/arch/m68k/sys/__sigtramp1.S
--- a/lib/libc/arch/m68k/sys/__sigtramp1.S      Mon Sep 22 14:37:57 2003 +0000
+++ b/lib/libc/arch/m68k/sys/__sigtramp1.S      Mon Sep 22 14:42:02 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: __sigtramp1.S,v 1.1 2002/07/09 23:32:37 thorpej Exp $  */
+/*     $NetBSD: __sigtramp1.S,v 1.2 2003/09/22 14:42:04 cl Exp $       */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -36,6 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define __HAVE_SIGINFO
 #include "SYS.h"
 
 /*
diff -r a2b64d33a7db -r af20d82e4ba6 lib/libc/arch/m68k/sys/__sigtramp2.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/m68k/sys/__sigtramp2.S      Mon Sep 22 14:42:02 2003 +0000
@@ -0,0 +1,57 @@
+/*     $NetBSD: __sigtramp2.S,v 1.1 2003/09/22 14:42:04 cl Exp $
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the NetBSD
+ *     Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "SYS.h"
+
+/*
+ * The m68k signal trampoline is invoked only to return from
+ * the signal; the kernel calls the signal handler directly.
+ *
+ * On entry, stack looks like:
+ *
+ *             ucontext structure                      [12+sizeof(siginfo_t)]
+ *             siginfo structure                       [12]
+ *             pointer to ucontext structure           [8]
+ *             pointer to siginfo structure            [4]
+ *     sp->    signal number                           [0]
+ */
+ENTRY_NOPROFILE(__sigtramp_siginfo_2)
+       movl    %sp@(8),%a0     /* get pointer to ucontext */
+       movl    %a0,%sp@(4)     /* put it in the argument slot */
+                               /* fake return address already there */
+        movl    #SYS_setcontext,%d0
+        trap    #0
+       movl    %d0,%sp@(4)     /* error code */
+       SYSTRAP(exit)           /* exit */



Home | Main Index | Thread Index | Old Index