Reduce redundant code.
Submitted by: kib
This commit is contained in:
parent
635f917a9d
commit
82746ea546
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=211526
@ -268,23 +268,26 @@ _pthread_sigmask(int how, const sigset_t *set, sigset_t *oset)
|
||||
|
||||
__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)
|
||||
{
|
||||
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_sigsuspend(pset);
|
||||
|
||||
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, siginfo_t *info,
|
||||
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, siginfo_t *info,
|
||||
{
|
||||
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, siginfo_t *info)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user