Fix signalcontext and makecontext.

This commit is contained in:
Olivier Houchard 2004-11-05 23:53:02 +00:00
parent 7a06812fe5
commit 60497154c8
3 changed files with 17 additions and 14 deletions

View File

@ -2,7 +2,8 @@
.ident "$FreeBSD$"
ENTRY(_ctx_start)
mov pc, r0
mov r0, r1
mov lr, pc
mov pc, r4
mov r0, r5
bl _C_LABEL(ctx_done)
bl _C_LABEL(abort)

View File

@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
#include <stdarg.h>
extern void _ctx_start(ucontext_t *, int argc, ...);
extern void _ctx_start(void);
void
ctx_done(ucontext_t *ucp)
@ -72,7 +72,8 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
/* Compute and align stack pointer. */
sp = (unsigned int *)
(((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size) & ~7);
(((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size -
sizeof(double)) & ~7);
/* Allocate necessary stack space for arguments exceeding r0-3. */
if (argc > 4)
sp -= argc - 4;
@ -80,8 +81,9 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
/* Wipe out frame pointer. */
gr[_REG_FP] = 0;
/* Arrange for return via the trampoline code. */
gr[_REG_LR] = (__greg_t)_ctx_start;
gr[_REG_PC] = (__greg_t)func;
gr[_REG_PC] = (__greg_t)_ctx_start;
gr[_REG_R4] = (__greg_t)func;
gr[_REG_R5] = (__greg_t)ucp;
va_start(ap, argc);
/* Pass up to four arguments in r0-3. */

View File

@ -51,11 +51,8 @@ __signalcontext(ucontext_t *ucp, int sig, __sighandler_t *func)
struct sigframe *sfp;
__greg_t *gr = ucp->uc_mcontext.__gregs;
unsigned int *sp;
mcontext_t *mc;
mc = &ucp->uc_mcontext;
sp = (unsigned int *)
(((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size) & ~7);
sp = (unsigned int *)gr[_REG_SP];
sfp = (struct sigframe *)sp - 1;
@ -63,13 +60,16 @@ __signalcontext(ucontext_t *ucp, int sig, __sighandler_t *func)
bcopy(ucp, &sfp->sf_uc, sizeof(*ucp));
sfp->sf_si.si_signo = sig;
gr[_REG_SP] = (__greg_t)sp;
gr[_REG_SP] = (__greg_t)sfp;
/* Wipe out frame pointer. */
gr[_REG_FP] = 0;
/* Arrange for return via the trampoline code. */
gr[_REG_LR] = (__greg_t)_ctx_start;
gr[_REG_PC] = (__greg_t)func;
gr[_REG_R0] = (__greg_t)ucp;
gr[_REG_PC] = (__greg_t)_ctx_start;
gr[_REG_R4] = (__greg_t)func;
gr[_REG_R5] = (__greg_t)ucp;
gr[_REG_R0] = (__greg_t)sig;
gr[_REG_R1] = (__greg_t)&sfp->sf_si;
gr[_REG_R2] = (__greg_t)&sfp->sf_uc;
ucp->uc_link = &sfp->sf_uc;
sigdelset(&ucp->uc_sigmask, sig);