Skip to content

Commit

Permalink
new helper: sigmask_to_save()
Browse files Browse the repository at this point in the history
replace boilerplate "should we use ->saved_sigmask or ->blocked?"
with calls of obvious inlined helper...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Jun 1, 2012
1 parent 51a7b44 commit b7f9a11
Show file tree
Hide file tree
Showing 31 changed files with 92 additions and 250 deletions.
5 changes: 1 addition & 4 deletions arch/alpha/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,9 @@ static inline void
handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
struct pt_regs * regs, struct switch_stack *sw)
{
sigset_t *oldset = &current->blocked;
sigset_t *oldset = sigmask_to_save();
int ret;

if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;

if (ka->sa.sa_flags & SA_SIGINFO)
ret = setup_rt_frame(sig, ka, info, oldset, regs, sw);
else
Expand Down
12 changes: 3 additions & 9 deletions arch/arm/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,11 @@ setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
*/
static int
handle_signal(unsigned long sig, struct k_sigaction *ka,
siginfo_t *info, sigset_t *oldset,
struct pt_regs * regs)
siginfo_t *info, struct pt_regs *regs)
{
struct thread_info *thread = current_thread_info();
struct task_struct *tsk = current;
sigset_t *oldset = sigmask_to_save();
int usig = sig;
int ret;

Expand Down Expand Up @@ -617,8 +617,6 @@ static void do_signal(struct pt_regs *regs, int syscall)
*/
signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) {
sigset_t *oldset;

/*
* Depending on the signal settings we may need to revert the
* decision to restart the system call. But skip this if a
Expand All @@ -635,11 +633,7 @@ static void do_signal(struct pt_regs *regs, int syscall)
clear_thread_flag(TIF_SYSCALL_RESTARTSYS);
}

if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
if (handle_signal(signr, &ka, &info, oldset, regs) == 0) {
if (handle_signal(signr, &ka, &info, regs) == 0) {
/*
* A signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame,
Expand Down
20 changes: 7 additions & 13 deletions arch/avr32/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ static inline void setup_syscall_restart(struct pt_regs *regs)

static inline void
handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
sigset_t *oldset, struct pt_regs *regs, int syscall)
struct pt_regs *regs, int syscall)
{
int ret;

/*
* Set up the stack frame
*/
ret = setup_rt_frame(sig, ka, info, oldset, regs);
ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);

/*
* Check that the resulting registers are sane
Expand All @@ -255,7 +255,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
* doesn't want to handle. Thus you cannot kill init even with a
* SIGKILL even by mistake.
*/
int do_signal(struct pt_regs *regs, sigset_t *oldset, int syscall)
static void do_signal(struct pt_regs *regs, int syscall)
{
siginfo_t info;
int signr;
Expand All @@ -267,12 +267,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset, int syscall)
* without doing anything if so.
*/
if (!user_mode(regs))
return 0;

if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else if (!oldset)
oldset = &current->blocked;
return;

signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (syscall) {
Expand All @@ -298,11 +293,10 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset, int syscall)
if (signr == 0) {
/* No signal to deliver -- put the saved sigmask back */
restore_saved_sigmask();
return 0;
return;
}

handle_signal(signr, &ka, &info, oldset, regs, syscall);
return 1;
handle_signal(signr, &ka, &info, regs, syscall);
}

asmlinkage void do_notify_resume(struct pt_regs *regs, struct thread_info *ti)
Expand All @@ -313,7 +307,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, struct thread_info *ti)
syscall = 1;

if (ti->flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
do_signal(regs, &current->blocked, syscall);
do_signal(regs, syscall);

if (ti->flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
Expand Down
12 changes: 3 additions & 9 deletions arch/blackfin/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
*/
static int
handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs *regs)
struct pt_regs *regs)
{
int ret;

Expand All @@ -259,7 +259,7 @@ handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
handle_restart(regs, ka, 1);

/* set up the stack frame */
ret = setup_rt_frame(sig, ka, info, oldset, regs);
ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);

if (ret == 0)
block_sigmask(ka, sig);
Expand All @@ -281,22 +281,16 @@ asmlinkage void do_signal(struct pt_regs *regs)
siginfo_t info;
int signr;
struct k_sigaction ka;
sigset_t *oldset;

current->thread.esp0 = (unsigned long)regs;

if (try_to_freeze())
goto no_signal;

if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;

signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) {
/* Whee! Actually deliver the signal. */
if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
if (handle_signal(signr, &info, &ka, regs) == 0) {
/* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply
Expand Down
14 changes: 3 additions & 11 deletions arch/c6x/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
*/
static int handle_signal(int sig,
siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs *regs,
int syscall)
struct pt_regs *regs, int syscall)
{
int ret;

Expand All @@ -278,7 +277,7 @@ static int handle_signal(int sig,
}

/* Set up the stack frame */
ret = setup_rt_frame(sig, ka, info, oldset, regs);
ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
if (ret == 0)
block_sigmask(ka, sig);

Expand All @@ -292,23 +291,16 @@ static void do_signal(struct pt_regs *regs, int syscall)
{
struct k_sigaction ka;
siginfo_t info;
sigset_t *oldset;
int signr;

/* we want the common case to go fast, which is why we may in certain
* cases get here from kernel mode */
if (!user_mode(regs))
return;

if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;

signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) {
if (handle_signal(signr, &info, &ka, oldset,
regs, syscall) == 0) {
if (handle_signal(signr, &info, &ka, regs, syscall) == 0) {
/* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply
Expand Down
11 changes: 3 additions & 8 deletions arch/cris/arch-v10/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,9 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,

static inline int handle_signal(int canrestart, unsigned long sig,
siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs *regs)
struct pt_regs *regs)
{
sigset_t *oldset = sigmask_to_save();
int ret;

/* Are we from a system call? */
Expand Down Expand Up @@ -478,7 +479,6 @@ void do_signal(int canrestart, struct pt_regs *regs)
siginfo_t info;
int signr;
struct k_sigaction ka;
sigset_t *oldset;

/*
* We want the common case to go fast, which
Expand All @@ -489,16 +489,11 @@ void do_signal(int canrestart, struct pt_regs *regs)
if (!user_mode(regs))
return;

if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;

signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) {
/* Whee! Actually deliver the signal. */
if (handle_signal(canrestart, signr, &info, &ka,
oldset, regs)) {
regs)) {
/* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply
Expand Down
11 changes: 3 additions & 8 deletions arch/cris/arch-v32/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,9 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
static inline int
handle_signal(int canrestart, unsigned long sig,
siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs * regs)
struct pt_regs * regs)
{
sigset_t *oldset = sigmask_to_save();
int ret;

/* Check if this got called from a system call. */
Expand Down Expand Up @@ -511,7 +512,6 @@ do_signal(int canrestart, struct pt_regs *regs)
int signr;
siginfo_t info;
struct k_sigaction ka;
sigset_t *oldset;

/*
* The common case should go fast, which is why this point is
Expand All @@ -521,17 +521,12 @@ do_signal(int canrestart, struct pt_regs *regs)
if (!user_mode(regs))
return;

if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;

signr = get_signal_to_deliver(&info, &ka, regs, NULL);

if (signr > 0) {
/* Whee! Actually deliver the signal. */
if (handle_signal(canrestart, signr, &info, &ka,
oldset, regs)) {
regs)) {
/* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply
Expand Down
10 changes: 3 additions & 7 deletions arch/frv/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,9 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
* OK, we're invoking a handler
*/
static int handle_signal(unsigned long sig, siginfo_t *info,
struct k_sigaction *ka, sigset_t *oldset)
struct k_sigaction *ka)
{
sigset_t *oldset = sigmask_to_save();
int ret;

/* Are we from a system call? */
Expand Down Expand Up @@ -492,14 +493,9 @@ static void do_signal(void)
if (try_to_freeze())
goto no_signal;

if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;

signr = get_signal_to_deliver(&info, &ka, __frame, NULL);
if (signr > 0) {
if (handle_signal(signr, &info, &ka, oldset) == 0) {
if (handle_signal(signr, &info, &ka) == 0) {
/* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply
Expand Down
11 changes: 3 additions & 8 deletions arch/h8300/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,9 @@ static int setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
*/
static void
handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs * regs)
struct pt_regs * regs)
{
sigset_t *oldset = sigmask_to_save();
int ret;
/* are we from a system call? */
if (regs->orig_er0 >= 0) {
Expand Down Expand Up @@ -457,7 +458,6 @@ statis void do_signal(struct pt_regs *regs)
siginfo_t info;
int signr;
struct k_sigaction ka;
sigset_t *oldset;

/*
* We want the common case to go fast, which
Expand All @@ -473,15 +473,10 @@ statis void do_signal(struct pt_regs *regs)

current->thread.esp0 = (unsigned long) regs;

if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;

signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) {
/* Whee! Actually deliver the signal. */
handle_signal(signr, &info, &ka, oldset, regs);
handle_signal(signr, &info, &ka, regs);
return;
}
no_signal:
Expand Down
13 changes: 3 additions & 10 deletions arch/hexagon/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info,
* Setup invocation of signal handler
*/
static int handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
sigset_t *oldset, struct pt_regs *regs)
struct pt_regs *regs)
{
int rc;

Expand Down Expand Up @@ -186,7 +186,7 @@ static int handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
* Set up the stack frame; not doing the SA_SIGINFO thing. We
* only set up the rt_frame flavor.
*/
rc = setup_rt_frame(sig, ka, info, oldset, regs);
rc = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);

/* If there was an error on setup, no signal was delivered. */
if (rc)
Expand Down Expand Up @@ -215,14 +215,7 @@ static void do_signal(struct pt_regs *regs)
signo = get_signal_to_deliver(&info, &sigact, regs, NULL);

if (signo > 0) {
sigset_t *oldset;

if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;

if (handle_signal(signo, &info, &sigact, oldset, regs) == 0) {
if (handle_signal(signo, &info, &sigact, regs) == 0) {
/*
* Successful delivery case. The saved sigmask is
* stored in the signal frame, and will be restored
Expand Down
Loading

0 comments on commit b7f9a11

Please sign in to comment.