When delivering a signal, arrange to have the handler invoked directly,

using the trampoline only for the return.  This saves two instructions
in the trampoline, one of them being a branch.
This commit is contained in:
thorpej 2002-06-23 19:16:43 +00:00
parent 7f7f0f86bd
commit 9cb2f482f0
2 changed files with 10 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sig_machdep.c,v 1.12 2002/06/23 00:16:20 thorpej Exp $ */
/* $NetBSD: sig_machdep.c,v 1.13 2002/06/23 19:16:43 thorpej Exp $ */
/*
* Copyright (c) 1994-1998 Mark Brinicombe.
@ -44,7 +44,7 @@
#include <sys/param.h>
__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.12 2002/06/23 00:16:20 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.13 2002/06/23 19:16:43 thorpej Exp $");
#include <sys/mount.h> /* XXX only needed by syscallargs.h */
#include <sys/proc.h>
@ -148,14 +148,15 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
}
/*
* Build context to run handler in.
* Build context to run handler in. We invoke the handler
* directly, only returning via the trampoline.
*/
tf->tf_r0 = sig;
tf->tf_r1 = code;
tf->tf_r2 = (int)&fp->sf_sc;
tf->tf_r3 = (int)catcher;
tf->tf_pc = (int)catcher;
tf->tf_usr_sp = (int)fp;
tf->tf_pc = (int)p->p_sigctx.ps_sigcode;
tf->tf_usr_lr = (int)p->p_sigctx.ps_sigcode;
#ifndef acorn26
/* XXX This should not be needed. */
cpu_icache_sync_all();

View File

@ -1,4 +1,4 @@
/* $NetBSD: sigcode.S,v 1.2 2002/06/23 00:16:20 thorpej Exp $ */
/* $NetBSD: sigcode.S,v 1.3 2002/06/23 19:16:43 thorpej Exp $ */
/*
* Copyright (C) 1994-1997 Mark Brinicombe
@ -33,7 +33,7 @@
#include <machine/asm.h>
RCSID("$NetBSD: sigcode.S,v 1.2 2002/06/23 00:16:20 thorpej Exp $")
RCSID("$NetBSD: sigcode.S,v 1.3 2002/06/23 19:16:43 thorpej Exp $")
#include "assym.h"
#include <sys/syscall.h>
@ -44,20 +44,10 @@ RCSID("$NetBSD: sigcode.S,v 1.2 2002/06/23 00:16:20 thorpej Exp $")
ENTRY_NP(sigcode)
/*
* r0-r2 are our signal handler parameters
* r3 is the handler address
* The kernel arranges for the handler to be invoked directly. This
* trampoline is used only to return from the signal.
*
* The stack pointer points to the saved sigcontext.
*/
add lr, pc, #0 /* Set return address */
mov pc, r3 /* Call the handler */
/*
* Call sig_return with address of the signal context. Note the
* pointer to this may have been clobbered by the handler, so
* we need to recompute from the stack pointer (which, thankfully,
* is quite easy).
*/
mov r0, sp
swi SYS___sigreturn14