commit fa07e3d777fc52a7c564f71c9b7f2bba1d0e7716
parent d9ed72433f25ec45908dede1022425a3f3ed1c67
Author: rsc <devnull@localhost>
Date: Sat, 22 Apr 2006 00:50:08 +0000
16-byte align
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/libthread/Darwin-386.c b/src/libthread/Darwin-386.c
@@ -3,10 +3,19 @@
void
makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
{
+ int n;
int *sp;
sp = (int*)ucp->uc_stack.ss_sp+ucp->uc_stack.ss_size/4;
sp -= argc;
+ /*
+ * Stack pointer at call instruction (before return address
+ * gets pushed) must be 16-byte aligned.
+ */
+ if((uintptr)sp%4)
+ abort();
+ while((uintptr)sp%16)
+ sp--;
memmove(sp, &argc+1, argc*sizeof(int));
*--sp = 0; /* return address */
ucp->uc_mcontext.mc_eip = (long)func;