Source-Changes-HG archive

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

[src/trunk]: src/lib/libpthread GC sigcontext<->mcontext code and __HAVE_SIGI...



details:   https://anonhg.NetBSD.org/src/rev/41b04b81db8c
branches:  trunk
changeset: 555710:41b04b81db8c
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Nov 25 22:36:32 2003 +0000

description:
GC sigcontext<->mcontext code and __HAVE_SIGINFO. All supported archs have
siginfo implemented.

diffstat:

 lib/libpthread/pthread_int.h |  53 +-------------------------------------------
 lib/libpthread/pthread_sig.c |  31 +++----------------------
 2 files changed, 5 insertions(+), 79 deletions(-)

diffs (134 lines):

diff -r 7e4486bedfce -r 41b04b81db8c lib/libpthread/pthread_int.h
--- a/lib/libpthread/pthread_int.h      Tue Nov 25 22:29:34 2003 +0000
+++ b/lib/libpthread/pthread_int.h      Tue Nov 25 22:36:32 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_int.h,v 1.20 2003/11/09 18:56:48 christos Exp $        */
+/*     $NetBSD: pthread_int.h,v 1.21 2003/11/25 22:36:32 christos Exp $        */
 
 /*-
  * Copyright (c) 2001,2002,2003 The NetBSD Foundation, Inc.
@@ -298,57 +298,6 @@
        _INITCONTEXT_U_MD(ucp)                                          \
        } while (/*CONSTCOND*/0)
 
-#ifdef __PTHREAD_SIGNAL_PRIVATE
-#ifndef __HAVE_SIGINFO
-
-/*
- * Macros for converting from ucontext to sigcontext and vice-versa.
- * Note that going from sigcontext->ucontext is only safe for a
- * sigcontext that was first created from a ucontext.
- *
- * Arch-specific code can override this, if necessary.  It may also
- * be necessary for arch-specific code to include extra info along with
- * the sigcontext.
- */
-#ifndef PTHREAD_SIGCONTEXT_EXTRA
-#define        PTHREAD_SIGCONTEXT_EXTRA
-#endif
-
-struct pthread__sigcontext {
-       struct sigcontext       psc_context;
-       PTHREAD_SIGCONTEXT_EXTRA
-};
-
-#ifndef PTHREAD_UCONTEXT_TO_SIGCONTEXT
-#define        PTHREAD_UCONTEXT_TO_SIGCONTEXT(mask, uc, psc)                   \
-do {                                                                   \
-       (uc)->uc_sigmask = *(mask);                                     \
-       /*                                                              \
-        * XXX We may want to check for _UC_USER here and do a          \
-        * XXX _INITCONTEXT_U_MD() and clearing _UC_USER on such        \
-        * XXX contexts before converting to a signcontext, thus        \
-        * XXX allowing signal handlers to modify the non-_UC_USER      \
-        * XXX registers.  Hazy territory; ignore it for now.           \
-        */                                                             \
-       _UCONTEXT_TO_SIGCONTEXT((uc), &(psc)->psc_context);             \
-} while (/*CONSTCOND*/0)
-
-#define        PTHREAD_SIGCONTEXT_TO_UCONTEXT(psc, uc)                         \
-do {                                                                   \
-       _SIGCONTEXT_TO_UCONTEXT(&(psc)->psc_context, (uc));             \
-       (uc)->uc_flags &= ~_UC_SIGMASK;                                 \
-} while (/*CONSTCOND*/0)
-#else
-void   pthread__ucontext_to_sigcontext(const sigset_t *, ucontext_t *,
-           struct pthread__sigcontext *);
-void   pthread__sigcontext_to_ucontext(const struct pthread__sigcontext *,
-           ucontext_t *);
-#endif /* PTHREAD_UCONTEXT_TO_SIGCONTEXT */
-
-#endif /* __HAVE_SIGINFO */
-
-#endif /* __PTHREAD_SIGNAL_PRIVATE */
-
 #ifdef PTHREAD_MACHINE_HAS_ID_REGISTER
 #define pthread__id(reg) (reg)
 #else
diff -r 7e4486bedfce -r 41b04b81db8c lib/libpthread/pthread_sig.c
--- a/lib/libpthread/pthread_sig.c      Tue Nov 25 22:29:34 2003 +0000
+++ b/lib/libpthread/pthread_sig.c      Tue Nov 25 22:36:32 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_sig.c,v 1.28 2003/11/25 22:26:44 christos Exp $        */
+/*     $NetBSD: pthread_sig.c,v 1.29 2003/11/25 22:36:32 christos Exp $        */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_sig.c,v 1.28 2003/11/25 22:26:44 christos Exp $");
+__RCSID("$NetBSD: pthread_sig.c,v 1.29 2003/11/25 22:36:32 christos Exp $");
 
 /* We're interposing a specific version of the signal interface. */
 #define        __LIBC12_SOURCE__
@@ -728,6 +728,7 @@
 {
        sigset_t oldmask;
        struct sigaction act;
+       ucontext_t uc;  /* XXX: we don't pass the right context here */
 
        pthread_spinlock(self, &pt_sigacts_lock);
        act = pt_sigacts[si->si_signo];
@@ -742,20 +743,7 @@
 
 
        pthread_spinunlock(self, &self->pt_siglock);
-#ifdef __HAVE_SIGINFO
-       {
-               ucontext_t uc;
-               (*act.sa_sigaction)(si->si_signo, si, &uc);
-       }
-#else
-       {
-               struct sigcontext xxxsc;
-               void (*handler)(int, int, struct sigcontext *);
-               handler = (void (*)(int, int, struct sigcontext *))
-                   act.sa_handler;
-               (*handler)(si->si_signo, si->si_trap, &xxxsc);
-       }
-#endif
+       (*act.sa_sigaction)(si->si_signo, si, &uc);
        pthread_spinlock(self, &self->pt_siglock);
 
        self->pt_sigmask = oldmask;
@@ -921,18 +909,7 @@
            pthread__self(), info->si_signo, info->si_code, uc,
            uc->uc_sigmask.__bits[0]));
 
-#ifdef __HAVE_SIGINFO
        (*handler)(info->si_signo, info, uc);
-#else
-       {
-               struct pthread__sigcontext psc;
-
-               PTHREAD_UCONTEXT_TO_SIGCONTEXT(&uc->uc_sigmask, uc, &psc);
-               ((void *(*)(int, int, struct sigcontext *))handler)
-                   (info->si_signo, info->si_trap, &psc.psc_context);
-               PTHREAD_SIGCONTEXT_TO_UCONTEXT(&psc, uc);
-       }
-#endif
 
        /*
         * We've finished the handler, so this thread can restore the



Home | Main Index | Thread Index | Old Index