t16-byte align - plan9port - [fork] Plan 9 from user space | |
git clone git://src.adamsgaard.dk/plan9port | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit fa07e3d777fc52a7c564f71c9b7f2bba1d0e7716 | |
parent d9ed72433f25ec45908dede1022425a3f3ed1c67 | |
Author: rsc | |
Date: Sat, 22 Apr 2006 00:50:08 +0000 16-byte align Diffstat: M src/libthread/Darwin-386.c | 9 +++++++++ 1 file changed, 9 insertions(+), 0 deletions(-) --- | |
diff --git a/src/libthread/Darwin-386.c b/src/libthread/Darwin-386.c | |
t@@ -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; |