commit fa07e3d777fc52a7c564f71c9b7f2bba1d0e7716 from: rsc date: Sat Apr 22 00:50:08 2006 UTC 16-byte align commit - d9ed72433f25ec45908dede1022425a3f3ed1c67 commit + fa07e3d777fc52a7c564f71c9b7f2bba1d0e7716 blob - 3725f264a4ef4f7b132095d58194cc55820437c3 blob + 0bd3c0fd6409fb4c31f0f8cfc40fe0164a90b05f --- src/libthread/Darwin-386.c +++ 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;