Date: Fri, 20 Aug 2010 13:42:48 +0000 (UTC) From: David Xu <davidxu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r211526 - head/lib/libthr/thread Message-ID: <201008201342.o7KDgmUE038862@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: davidxu Date: Fri Aug 20 13:42:48 2010 New Revision: 211526 URL: http://svn.freebsd.org/changeset/base/211526 Log: Reduce redundant code. Submitted by: kib Modified: head/lib/libthr/thread/thr_sig.c Modified: head/lib/libthr/thread/thr_sig.c ============================================================================== --- head/lib/libthr/thread/thr_sig.c Fri Aug 20 12:26:02 2010 (r211525) +++ head/lib/libthr/thread/thr_sig.c Fri Aug 20 13:42:48 2010 (r211526) @@ -268,23 +268,26 @@ _pthread_sigmask(int how, const sigset_t __weak_reference(__sigsuspend, sigsuspend); -int -_sigsuspend(const sigset_t * set) +static const sigset_t * +thr_remove_thr_signals(const sigset_t *set, sigset_t *newset) { - sigset_t newset; const sigset_t *pset; - int ret; if (SIGISMEMBER(*set, SIGCANCEL)) { - newset = *set; - SIGDELSET(newset, SIGCANCEL); - pset = &newset; + *newset = *set; + SIGDELSET(*newset, SIGCANCEL); + pset = newset; } else pset = set; + return (pset); +} - ret = __sys_sigsuspend(pset); +int +_sigsuspend(const sigset_t * set) +{ + sigset_t newset; - return (ret); + return (__sys_sigsuspend(thr_remove_thr_signals(set, &newset))); } int @@ -292,18 +295,10 @@ __sigsuspend(const sigset_t * set) { struct pthread *curthread = _get_curthread(); sigset_t newset; - const sigset_t *pset; int ret; - if (SIGISMEMBER(*set, SIGCANCEL)) { - newset = *set; - SIGDELSET(newset, SIGCANCEL); - pset = &newset; - } else - pset = set; - _thr_cancel_enter(curthread); - ret = __sys_sigsuspend(pset); + ret = __sys_sigsuspend(thr_remove_thr_signals(set, &newset)); _thr_cancel_leave(curthread); return (ret); @@ -318,17 +313,9 @@ _sigtimedwait(const sigset_t *set, sigin const struct timespec * timeout) { sigset_t newset; - const sigset_t *pset; - int ret; - if (SIGISMEMBER(*set, SIGCANCEL)) { - newset = *set; - SIGDELSET(newset, SIGCANCEL); - pset = &newset; - } else - pset = set; - ret = __sys_sigtimedwait(pset, info, timeout); - return (ret); + return (__sys_sigtimedwait(thr_remove_thr_signals(set, &newset), info, + timeout)); } /* @@ -342,17 +329,11 @@ __sigtimedwait(const sigset_t *set, sigi { struct pthread *curthread = _get_curthread(); sigset_t newset; - const sigset_t *pset; int ret; - if (SIGISMEMBER(*set, SIGCANCEL)) { - newset = *set; - SIGDELSET(newset, SIGCANCEL); - pset = &newset; - } else - pset = set; _thr_cancel_enter_defer(curthread, 1); - ret = __sys_sigtimedwait(pset, info, timeout); + ret = __sys_sigtimedwait(thr_remove_thr_signals(set, &newset), info, + timeout); _thr_cancel_leave_defer(curthread, (ret == -1)); return (ret); } @@ -361,18 +342,8 @@ int _sigwaitinfo(const sigset_t *set, siginfo_t *info) { sigset_t newset; - const sigset_t *pset; - int ret; - - if (SIGISMEMBER(*set, SIGCANCEL)) { - newset = *set; - SIGDELSET(newset, SIGCANCEL); - pset = &newset; - } else - pset = set; - ret = __sys_sigwaitinfo(pset, info); - return (ret); + return (__sys_sigwaitinfo(thr_remove_thr_signals(set, &newset), info)); } /* @@ -385,18 +356,10 @@ __sigwaitinfo(const sigset_t *set, sigin { struct pthread *curthread = _get_curthread(); sigset_t newset; - const sigset_t *pset; int ret; - if (SIGISMEMBER(*set, SIGCANCEL)) { - newset = *set; - SIGDELSET(newset, SIGCANCEL); - pset = &newset; - } else - pset = set; - _thr_cancel_enter_defer(curthread, 1); - ret = __sys_sigwaitinfo(pset, info); + ret = __sys_sigwaitinfo(thr_remove_thr_signals(set, &newset), info); _thr_cancel_leave_defer(curthread, ret == -1); return (ret); } @@ -405,18 +368,8 @@ int _sigwait(const sigset_t *set, int *sig) { sigset_t newset; - const sigset_t *pset; - int ret; - - if (SIGISMEMBER(*set, SIGCANCEL)) { - newset = *set; - SIGDELSET(newset, SIGCANCEL); - pset = &newset; - } else - pset = set; - ret = __sys_sigwait(pset, sig); - return (ret); + return (__sys_sigwait(thr_remove_thr_signals(set, &newset), sig)); } /* @@ -429,18 +382,10 @@ __sigwait(const sigset_t *set, int *sig) { struct pthread *curthread = _get_curthread(); sigset_t newset; - const sigset_t *pset; int ret; - if (SIGISMEMBER(*set, SIGCANCEL)) { - newset = *set; - SIGDELSET(newset, SIGCANCEL); - pset = &newset; - } else - pset = set; - _thr_cancel_enter_defer(curthread, 1); - ret = __sys_sigwait(pset, sig); + ret = __sys_sigwait(thr_remove_thr_signals(set, &newset), sig); _thr_cancel_leave_defer(curthread, (ret != 0)); return (ret); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008201342.o7KDgmUE038862>