m68k: Switch to saner sigsuspend()

and saner do_signal() arguments, while we are at it

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
This commit is contained in:
Al Viro 2010-09-29 23:28:59 -04:00 коммит произвёл Geert Uytterhoeven
Родитель 35fc157baf
Коммит e68847fee7
4 изменённых файлов: 26 добавлений и 61 удалений

Просмотреть файл

@ -104,5 +104,6 @@ static inline struct thread_info *current_thread_info(void)
#define TIF_SYSCALL_TRACE 15 /* syscall trace active */ #define TIF_SYSCALL_TRACE 15 /* syscall trace active */
#define TIF_MEMDIE 16 /* is terminating due to OOM killer */ #define TIF_MEMDIE 16 /* is terminating due to OOM killer */
#define TIF_FREEZE 17 /* thread is freezing for suspend */ #define TIF_FREEZE 17 /* thread is freezing for suspend */
#define TIF_RESTORE_SIGMASK 18 /* restore signal mask in do_signal */
#endif /* _ASM_M68K_THREAD_INFO_H */ #endif /* _ASM_M68K_THREAD_INFO_H */

Просмотреть файл

@ -373,6 +373,9 @@
#define __ARCH_WANT_SYS_SIGPENDING #define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK #define __ARCH_WANT_SYS_SIGPROCMASK
#define __ARCH_WANT_SYS_RT_SIGACTION #define __ARCH_WANT_SYS_RT_SIGACTION
#ifndef __uClinux__
#define __ARCH_WANT_SYS_RT_SIGSUSPEND
#endif
/* /*
* "Conditional" syscalls * "Conditional" syscalls

Просмотреть файл

@ -174,9 +174,8 @@ do_signal_return:
subql #4,%sp | dummy return address subql #4,%sp | dummy return address
SAVE_SWITCH_STACK SAVE_SWITCH_STACK
pea %sp@(SWITCH_STACK_SIZE) pea %sp@(SWITCH_STACK_SIZE)
clrl %sp@-
bsrl do_signal bsrl do_signal
addql #8,%sp addql #4,%sp
RESTORE_SWITCH_STACK RESTORE_SWITCH_STACK
addql #4,%sp addql #4,%sp
tstl %d0 tstl %d0
@ -290,22 +289,6 @@ ENTRY(sys_vfork)
RESTORE_SWITCH_STACK RESTORE_SWITCH_STACK
rts rts
ENTRY(sys_sigsuspend)
SAVE_SWITCH_STACK
pea %sp@(SWITCH_STACK_SIZE)
jbsr do_sigsuspend
addql #4,%sp
RESTORE_SWITCH_STACK
rts
ENTRY(sys_rt_sigsuspend)
SAVE_SWITCH_STACK
pea %sp@(SWITCH_STACK_SIZE)
jbsr do_rt_sigsuspend
addql #4,%sp
RESTORE_SWITCH_STACK
rts
ENTRY(sys_sigreturn) ENTRY(sys_sigreturn)
SAVE_SWITCH_STACK SAVE_SWITCH_STACK
jbsr do_sigreturn jbsr do_sigreturn

Просмотреть файл

@ -51,8 +51,6 @@
#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs);
const int frame_extra_sizes[16] = { const int frame_extra_sizes[16] = {
[1] = -1, /* sizeof(((struct frame *)0)->un.fmt1), */ [1] = -1, /* sizeof(((struct frame *)0)->un.fmt1), */
[2] = sizeof(((struct frame *)0)->un.fmt2), [2] = sizeof(((struct frame *)0)->un.fmt2),
@ -74,51 +72,21 @@ const int frame_extra_sizes[16] = {
/* /*
* Atomically swap in the new signal mask, and wait for a signal. * Atomically swap in the new signal mask, and wait for a signal.
*/ */
asmlinkage int do_sigsuspend(struct pt_regs *regs) asmlinkage int
sys_sigsuspend(int unused0, int unused1, old_sigset_t mask)
{ {
old_sigset_t mask = regs->d3;
sigset_t saveset;
mask &= _BLOCKABLE; mask &= _BLOCKABLE;
saveset = current->blocked; spin_lock_irq(&current->sighand->siglock);
current->saved_sigmask = current->blocked;
siginitset(&current->blocked, mask); siginitset(&current->blocked, mask);
recalc_sigpending(); recalc_sigpending();
spin_unlock_irq(&current->sighand->siglock);
regs->d0 = -EINTR;
while (1) {
current->state = TASK_INTERRUPTIBLE; current->state = TASK_INTERRUPTIBLE;
schedule(); schedule();
if (do_signal(&saveset, regs)) set_restore_sigmask();
return -EINTR;
}
}
asmlinkage int return -ERESTARTNOHAND;
do_rt_sigsuspend(struct pt_regs *regs)
{
sigset_t __user *unewset = (sigset_t __user *)regs->d1;
size_t sigsetsize = (size_t)regs->d2;
sigset_t saveset, newset;
/* XXX: Don't preclude handling different sized sigset_t's. */
if (sigsetsize != sizeof(sigset_t))
return -EINVAL;
if (copy_from_user(&newset, unewset, sizeof(newset)))
return -EFAULT;
sigdelsetmask(&newset, ~_BLOCKABLE);
saveset = current->blocked;
current->blocked = newset;
recalc_sigpending();
regs->d0 = -EINTR;
while (1) {
current->state = TASK_INTERRUPTIBLE;
schedule();
if (do_signal(&saveset, regs))
return -EINTR;
}
} }
asmlinkage int asmlinkage int
@ -1017,21 +985,25 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
* want to handle. Thus you cannot kill init even with a SIGKILL even by * want to handle. Thus you cannot kill init even with a SIGKILL even by
* mistake. * mistake.
*/ */
asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs) asmlinkage int do_signal(struct pt_regs *regs)
{ {
siginfo_t info; siginfo_t info;
struct k_sigaction ka; struct k_sigaction ka;
int signr; int signr;
sigset_t *oldset;
current->thread.esp0 = (unsigned long) regs; current->thread.esp0 = (unsigned long) regs;
if (!oldset) if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked; oldset = &current->blocked;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) { if (signr > 0) {
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
handle_signal(signr, &ka, &info, oldset, regs); handle_signal(signr, &ka, &info, oldset, regs);
clear_thread_flag(TIF_RESTORE_SIGMASK);
return 1; return 1;
} }
@ -1040,5 +1012,11 @@ asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs)
/* Restart the system call - no handlers present */ /* Restart the system call - no handlers present */
handle_restart(regs, NULL, 0); handle_restart(regs, NULL, 0);
/* If there's no signal to deliver, we just restore the saved mask. */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}
return 0; return 0;
} }