From owner-svn-src-head@FreeBSD.ORG Tue Aug 24 09:57:07 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 170AD10656AB; Tue, 24 Aug 2010 09:57:07 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 05EFA8FC27; Tue, 24 Aug 2010 09:57:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7O9v6GU070050; Tue, 24 Aug 2010 09:57:06 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7O9v6BE070046; Tue, 24 Aug 2010 09:57:06 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201008240957.o7O9v6BE070046@svn.freebsd.org> From: David Xu Date: Tue, 24 Aug 2010 09:57:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211737 - in head/lib/libthr: . thread X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2010 09:57:07 -0000 Author: davidxu Date: Tue Aug 24 09:57:06 2010 New Revision: 211737 URL: http://svn.freebsd.org/changeset/base/211737 Log: Add wrapper for setcontext() and swapcontext(), the wrappers unblock SIGCANCEL which is needed by thread cancellation. Modified: head/lib/libthr/pthread.map head/lib/libthr/thread/thr_private.h head/lib/libthr/thread/thr_sig.c Modified: head/lib/libthr/pthread.map ============================================================================== --- head/lib/libthr/pthread.map Tue Aug 24 08:11:11 2010 (r211736) +++ head/lib/libthr/pthread.map Tue Aug 24 09:57:06 2010 (r211737) @@ -342,6 +342,7 @@ FBSDprivate_1.0 { _pthread_timedjoin_np; _pthread_yield; _raise; + _setcontext; _sigaction; _sigprocmask; _sigsuspend; @@ -351,6 +352,7 @@ FBSDprivate_1.0 { _spinlock; _spinlock_debug; _spinunlock; + _swapcontext; /* Debugger needs these. */ _libthr_debug; @@ -397,4 +399,6 @@ FBSD_1.1 { FBSD_1.2 { openat; + setcontext; + swapcontext; }; Modified: head/lib/libthr/thread/thr_private.h ============================================================================== --- head/lib/libthr/thread/thr_private.h Tue Aug 24 08:11:11 2010 (r211736) +++ head/lib/libthr/thread/thr_private.h Tue Aug 24 09:57:06 2010 (r211737) @@ -709,6 +709,12 @@ int __sys_sigwaitinfo(const sigset_t *se int __sys_nanosleep(const struct timespec *, struct timespec *); #endif +/* #include */ +#ifdef _SYS_UCONTEXT_H_ +int __sys_setcontext(const ucontext_t *ucp); +int __sys_swapcontext(ucontext_t *oucp, const ucontext_t *ucp); +#endif + /* #include */ #ifdef _UNISTD_H_ int __sys_close(int); Modified: head/lib/libthr/thread/thr_sig.c ============================================================================== --- head/lib/libthr/thread/thr_sig.c Tue Aug 24 08:11:11 2010 (r211736) +++ head/lib/libthr/thread/thr_sig.c Tue Aug 24 09:57:06 2010 (r211737) @@ -59,7 +59,29 @@ int _sigwaitinfo(const sigset_t *set, si int __sigwait(const sigset_t *set, int *sig); int _sigwait(const sigset_t *set, int *sig); int __sigsuspend(const sigset_t *sigmask); +int _setcontext(const ucontext_t *); +int _swapcontext(ucontext_t *, const ucontext_t *); +static void +remove_thr_signals(sigset_t *set) +{ + if (SIGISMEMBER(*set, SIGCANCEL)) + SIGDELSET(*set, SIGCANCEL); +} + +static const sigset_t * +thr_remove_thr_signals(const sigset_t *set, sigset_t *newset) +{ + const sigset_t *pset; + + if (SIGISMEMBER(*set, SIGCANCEL)) { + *newset = *set; + SIGDELSET(*newset, SIGCANCEL); + pset = newset; + } else + pset = set; + return (pset); +} static void sigcancel_handler(int sig __unused, @@ -268,20 +290,6 @@ _pthread_sigmask(int how, const sigset_t __weak_reference(__sigsuspend, sigsuspend); -static const sigset_t * -thr_remove_thr_signals(const sigset_t *set, sigset_t *newset) -{ - const sigset_t *pset; - - if (SIGISMEMBER(*set, SIGCANCEL)) { - *newset = *set; - SIGDELSET(*newset, SIGCANCEL); - pset = newset; - } else - pset = set; - return (pset); -} - int _sigsuspend(const sigset_t * set) { @@ -389,3 +397,26 @@ __sigwait(const sigset_t *set, int *sig) _thr_cancel_leave_defer(curthread, (ret != 0)); return (ret); } + +__weak_reference(_setcontext, setcontext); +int +_setcontext(const ucontext_t *ucp) +{ + ucontext_t uc; + + (void) memcpy(&uc, ucp, sizeof (uc)); + remove_thr_signals(&uc.uc_sigmask); + + return __sys_setcontext(&uc); +} + +__weak_reference(_swapcontext, swapcontext); +int +_swapcontext(ucontext_t *oucp, const ucontext_t *ucp) +{ + ucontext_t uc; + + (void) memcpy(&uc, ucp, sizeof (uc)); + remove_thr_signals(&uc.uc_sigmask); + return __sys_swapcontext(oucp, &uc); +}