From f6e7386001beb648ba68734df1fbb72c2c1d2375 Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Sat, 7 Mar 2009 19:35:10 +0100 Subject: [PATCH] signals: rename CURSIGNB to CURSIG_NOBLOCK and unify implementation CURSIG() is defined as __cursig() and CURSIGNB() as __cursignb(). However both __cursig() and __cursignb() do almost the same thing, so consolidate the code into one function. --- sys/kern/kern_fork.c | 2 +- sys/sys/signal2.h | 42 +++++++++++++++++++++--------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index ed602999b9..bd7fb5c734 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -285,7 +285,7 @@ fork1(struct lwp *lp1, int flags, struct proc **procp) pgrp = NULL; if ((flags & RFPGLOCK) && (pgrp = p1->p_pgrp) != NULL) { lockmgr(&pgrp->pg_lock, LK_SHARED); - if (CURSIGNB(lp1)) { + if (CURSIG_NOBLOCK(lp1)) { error = ERESTART; goto done; } diff --git a/sys/sys/signal2.h b/sys/sys/signal2.h index 3414eda8ca..0266979f37 100644 --- a/sys/sys/signal2.h +++ b/sys/sys/signal2.h @@ -66,9 +66,9 @@ lwp_delsig(struct lwp *lp, int sig) SIGDELSET(lp->lwp_proc->p_siglist, sig); } -#define CURSIG(lp) __cursig(lp, 0) -#define CURSIG_TRACE(lp) __cursig(lp, 1) -#define CURSIGNB(lp) __cursignb(lp) +#define CURSIG(lp) __cursig(lp, 1, 0) +#define CURSIG_TRACE(lp) __cursig(lp, 1, 1) +#define CURSIG_NOBLOCK(lp) __cursig(lp, 0, 0) /* * Determine signal that should be delivered to process p, the current @@ -79,32 +79,32 @@ lwp_delsig(struct lwp *lp, int sig) */ static __inline int -__cursig(struct lwp *lp, int maytrace) +__cursig(struct lwp *lp, int mayblock, int maytrace) { - struct proc *p; + struct proc *p = lp->lwp_proc; sigset_t tmpset; int r; - p = lp->lwp_proc; tmpset = lwp_sigpend(lp); SIGSETNAND(tmpset, lp->lwp_sigmask); - if (!(p->p_flag & P_TRACED) && SIGISEMPTY(tmpset)) - return(0); - r = issignal(lp, maytrace); - return(r); -} -static __inline -int -__cursignb(struct lwp *lp) -{ - sigset_t tmpset; + /* Nothing interesting happening? */ + if (SIGISEMPTY(tmpset)) { + /* + * Quit here, unless + * a) we may block and + * b) somebody is tracing us. + */ + if (!(mayblock && (p->p_flag & P_TRACED))) + return (0); + } - tmpset = lwp_sigpend(lp); - SIGSETNAND(tmpset, lp->lwp_sigmask); - if (SIGISEMPTY(tmpset)) - return(FALSE); - return (TRUE); + if (mayblock) + r = issignal(lp, maytrace); + else + r = TRUE; /* simply state the fact */ + + return(r); } #endif -- 2.11.4.GIT