--- libcoro/coro.c 2008/11/08 04:52:01 1.40 +++ libcoro/coro.c 2008/11/19 02:56:16 1.44 @@ -80,12 +80,6 @@ static void *coro_init_arg; static coro_context *new_coro, *create_coro; -/* what we really want to detect here is wether we use a new-enough version of GAS */ -/* with dwarf debug info. instead, check for gcc 3, ELF and GNU/Linux and hope for the best */ -# if __GNUC__ >= 3 && __ELF__ && __linux__ -# define HAVE_CFI 1 -# endif - static void coro_init (void) { @@ -108,21 +102,8 @@ static void trampoline (int sig) { - if ( - #if _XOPEN_UNIX > 0 - _setjmp (new_coro->env) - #else - sigsetjmp (new_coro->env, 0) - #endif - ) { - #if HAVE_CFI - asm (".cfi_startproc"); - #endif - coro_init (); /* start it */ - #if HAVE_CFI - asm (".cfi_endproc"); - #endif - } + if (coro_setjmp (new_coro->env)) + coro_init (); /* start it */ else trampoline_done = 1; } @@ -243,7 +224,7 @@ # elif CORO_LOSER - setjmp (ctx->env); + coro_setjmp (ctx->env); #if __CYGWIN__ ctx->env[7] = (long)((char *)sptr + ssize) - sizeof (long); ctx->env[8] = (long)coro_init; @@ -262,7 +243,7 @@ # elif CORO_LINUX - _setjmp (ctx->env); + coro_setjmp (ctx->env); #if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (JB_PC) && defined (JB_SP) ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init; ctx->env[0].__jmpbuf[JB_SP] = (long)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); @@ -281,13 +262,13 @@ # elif CORO_IRIX - sigsetjmp (ctx->env, 0); + coro_setjmp (ctx->env, 0); ctx->env[JB_PC] = (__uint64_t)coro_init; ctx->env[JB_SP] = (__uint64_t)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); # elif CORO_ASM - ctx->sp = (volatile void **)(ssize + (char *)sptr); + ctx->sp = (void **)(ssize + (char *)sptr); *--ctx->sp = (void *)abort; /* needed for alignment only */ *--ctx->sp = (void *)coro_init; ctx->sp -= NUM_SAVED; @@ -355,6 +336,9 @@ { pthread_cond_signal (&next->cv); pthread_cond_wait (&prev->cv, &coro_mutex); +#if __FreeBSD__ /* freebsd is of course broken and needs manual testcancel calls... yay... */ + pthread_testcancel (); +#endif } void