--- libcoro/coro.c 2008/04/24 12:40:38 1.31 +++ libcoro/coro.c 2008/10/30 09:44:31 1.33 @@ -122,12 +122,12 @@ #endif #if CORO_ASM -void __attribute__((__noinline__, __fastcall__)) +void __attribute__((__noinline__, __regparm__(2))) coro_transfer (struct coro_context *prev, struct coro_context *next) { asm volatile ( #if __amd64 -# define NUM_CLOBBERED 5 +# define NUM_SAVED 5 "push %%rbx\n\t" "push %%r12\n\t" "push %%r13\n\t" @@ -141,7 +141,7 @@ "pop %%r12\n\t" "pop %%rbx\n\t" #elif __i386 -# define NUM_CLOBBERED 4 +# define NUM_SAVED 4 "push %%ebx\n\t" "push %%esi\n\t" "push %%edi\n\t" @@ -326,9 +326,14 @@ # elif CORO_ASM ctx->sp = (volatile void **)(ssize + (char *)sptr); + /* we try to allow for both functions with and without frame pointers */ *--ctx->sp = (void *)coro_init; - *--ctx->sp = (void *)coro_init; // this is needed when the prologue saves ebp - ctx->sp -= NUM_CLOBBERED; + { + void **frame = ctx->sp - 1; + int i; + for (i = NUM_SAVED; i--; ) + *--ctx->sp = frame; + } # endif