Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/linux/arch/i386 Now that we have siginfo, use it, ...



details:   https://anonhg.NetBSD.org/src/rev/6b5ff92b5da2
branches:  trunk
changeset: 552208:6b5ff92b5da2
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Sep 21 17:42:23 2003 +0000

description:
Now that we have siginfo, use it, instead of pretending to have one.

diffstat:

 sys/compat/linux/arch/i386/linux_machdep.c |  58 +++++++++++++++++------------
 1 files changed, 33 insertions(+), 25 deletions(-)

diffs (129 lines):

diff -r 09d5779d01d7 -r 6b5ff92b5da2 sys/compat/linux/arch/i386/linux_machdep.c
--- a/sys/compat/linux/arch/i386/linux_machdep.c        Sun Sep 21 17:15:36 2003 +0000
+++ b/sys/compat/linux/arch/i386/linux_machdep.c        Sun Sep 21 17:42:23 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_machdep.c,v 1.96 2003/09/06 22:09:21 christos Exp $      */
+/*     $NetBSD: linux_machdep.c,v 1.97 2003/09/21 17:42:23 christos Exp $      */
 
 /*-
  * Copyright (c) 1995, 2000 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.96 2003/09/06 22:09:21 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.97 2003/09/21 17:42:23 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vm86.h"
@@ -126,8 +126,8 @@
     sigset_t *, struct linux_sigcontext *));
 static int linux_restore_sigcontext __P((struct lwp *,
     struct linux_sigcontext *, register_t *));
-static void linux_rt_sendsig __P((int, sigset_t *, u_long));
-static void linux_old_sendsig __P((int, sigset_t *, u_long));
+static void linux_rt_sendsig __P((ksiginfo_t *, sigset_t *));
+static void linux_old_sendsig __P((ksiginfo_t *, sigset_t *));
 
 extern char linux_sigcode[], linux_rt_sigcode[];
 /*
@@ -195,9 +195,9 @@
 linux_sendsig(ksiginfo_t *ksi, sigset_t *mask)
 {
        if (SIGACTION(curproc, ksi->ksi_signo).sa_flags & SA_SIGINFO)
-               linux_rt_sendsig(ksi->ksi_signo, mask, ksi->ksi_trap);
+               linux_rt_sendsig(ksi, mask);
        else
-               linux_old_sendsig(ksi->ksi_signo, mask, ksi->ksi_trap);
+               linux_old_sendsig(ksi, mask);
 }
 
 
@@ -266,16 +266,14 @@
 }
 
 static void
-linux_rt_sendsig(sig, mask, code)
-       int sig;
-       sigset_t *mask;
-       u_long code;
+linux_rt_sendsig(ksiginfo_t *ksi, sigset_t *mask)
 {
        struct lwp *l = curlwp;
        struct proc *p = l->l_proc;
        struct trapframe *tf;
        struct linux_rt_sigframe *fp, frame;
        int onstack;
+       linux_siginfo_t *lsi;
        sig_t catcher = SIGACTION(p, sig).sa_handler;
        struct sigaltstack *sas = &p->p_sigctx.ps_sigstk;
 
@@ -302,26 +300,38 @@
        frame.sf_sip = &fp->sf_si;
        frame.sf_ucp = &fp->sf_uc;
 
-       (void)memset(&frame.sf_si, 0, sizeof(frame.sf_si));
        /*
-        * XXX: We'll fake bit of it here, all of the following
-        * info is a bit bogus, because we don't have the
-        * right info passed to us from the trap.
+        * XXX: the following code assumes that the constants for
+        * siginfo are the same between linux and NetBSD.
         */
-       switch (frame.sf_si.lsi_signo = frame.sf_sig) {
+       (void)memset(lsi = &frame.sf_si, 0, sizeof(frame.sf_si));
+       lsi->lsi_errno = native_to_linux_errno[ksi->ksi_errno];
+       lsi->lsi_code = ksi->ksi_code;
+       switch (lsi->lsi_signo = frame.sf_sig) {
+       case LINUX_SIGILL:
+       case LINUX_SIGFPE:
        case LINUX_SIGSEGV:
-               frame.sf_si.lsi_code = LINUX_SEGV_MAPERR;
-               break;
        case LINUX_SIGBUS:
-               frame.sf_si.lsi_code = LINUX_BUS_ADRERR;
-               break;
        case LINUX_SIGTRAP:
-               frame.sf_si.lsi_code = LINUX_TRAP_BRKPT;
+               lsi->lsi_addr = ksi->ksi_addr;
                break;
        case LINUX_SIGCHLD:
+               lsi->lsi_uid = ksi->ksi_uid;
+               lsi->lsi_pid = ksi->ksi_pid;
+               lsi->lsi_status = ksi->ksi_status;
+               lsi->lsi_utime = ksi->ksi_utime;
+               lsi->lsi_stime = ksi->ksi_stime;
+               break;
        case LINUX_SIGIO:
+               lsi->lsi_band = ksi->ksi_band;
+               lsi->lsi_fd = ksi->ksi_fd;
+               break;
        default:
-               frame.sf_si.lsi_signo = 0;
+               lsi->lsi_uid = ksi->ksi_uid;
+               lsi->lsi_pid = ksi->ksi_pid;
+               if (lsi->lsi_signo == LINUX_SIGALRM ||
+                   lsi->lsi_signo >= LINUX_SIGRTMIN)
+                       lsi->lsi_sigval.sival_ptr = ksi->ksi_sigval.sival_ptr;
                break;
        }
 
@@ -357,16 +367,14 @@
 }
 
 static void
-linux_old_sendsig(sig, mask, code)
-       int sig;
-       sigset_t *mask;
-       u_long code;
+linux_old_sendsig(ksiginfo_t *ksi, sigset_t *mask)
 {
        struct lwp *l = curlwp;
        struct proc *p = l->l_proc;
        struct trapframe *tf;
        struct linux_sigframe *fp, frame;
        int onstack;
+       int sig = ksi->ksi_signo;
        sig_t catcher = SIGACTION(p, sig).sa_handler;
        struct sigaltstack *sas = &p->p_sigctx.ps_sigstk;
 



Home | Main Index | Thread Index | Old Index