diff options
author | root <root> | 2008-11-08 04:52:01 +0000 |
---|---|---|
committer | root <root> | 2008-11-08 04:52:01 +0000 |
commit | ce5dfff9ddefbf677d0362d47865c271548e69b3 (patch) | |
tree | 50bce1ded4bb461d78029141d45a159f24345b53 | |
parent | 930f681be412f20ef67d9aa0d40ae44cbf682814 (diff) |
*** empty log message ***
-rw-r--r-- | coro.c | 19 | ||||
-rw-r--r-- | coro.h | 8 |
2 files changed, 14 insertions, 13 deletions
@@ -76,9 +76,9 @@ # include <unistd.h> # endif -static volatile coro_func coro_init_func; -static volatile void *coro_init_arg; -static volatile coro_context *new_coro, *create_coro; +static coro_func coro_init_func; +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 */ @@ -92,7 +92,7 @@ coro_init (void) volatile coro_func func = coro_init_func; volatile void *arg = coro_init_arg; - coro_transfer ((coro_context *)new_coro, (coro_context *)create_coro); + coro_transfer (new_coro, create_coro); func ((void *)arg); @@ -112,7 +112,7 @@ trampoline (int sig) #if _XOPEN_UNIX > 0 _setjmp (new_coro->env) #else - setjmp (new_coro->env) + sigsetjmp (new_coro->env, 0) #endif ) { #if HAVE_CFI @@ -281,7 +281,7 @@ coro_create (coro_context *ctx, coro_func coro, void *arg, void *sptr, long ssiz # elif CORO_IRIX - setjmp (ctx->env); + sigsetjmp (ctx->env, 0); ctx->env[JB_PC] = (__uint64_t)coro_init; ctx->env[JB_SP] = (__uint64_t)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); @@ -308,13 +308,10 @@ coro_create (coro_context *ctx, coro_func coro, void *arg, void *sptr, long ssiz coro_transfer (create_coro, new_coro); } -#endif - /*****************************************************************************/ /* pthread backend */ /*****************************************************************************/ - -#if CORO_PTHREAD +#elif CORO_PTHREAD /* this mutex will be locked by the running coroutine */ pthread_mutex_t coro_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -412,5 +409,7 @@ coro_destroy (coro_context *ctx) pthread_cond_destroy (&ctx->cv); } +#else +# error unsupported backend #endif @@ -234,9 +234,11 @@ struct coro_context { }; # if _XOPEN_UNIX > 0 -# define coro_transfer(p,n) do { if (!_setjmp ((p)->env)) _longjmp ((n)->env, 1); } while (0) +# define coro_transfer(p,n) do { if (! _setjmp ((p)->env )) _longjmp ((n)->env, 1); } while (0) +# elif CORO_LOSER +# define coro_transfer(p,n) do { if (! setjmp ((p)->env )) longjmp ((n)->env, 1); } while (0) # else -# define coro_transfer(p,n) do { if (! setjmp ((p)->env)) longjmp ((n)->env, 1); } while (0) +# define coro_transfer(p,n) do { if (!sigsetjmp ((p)->env, 0)) siglongjmp ((n)->env, 1); } while (0) # endif # define coro_destroy(ctx) (void *)(ctx) @@ -244,7 +246,7 @@ struct coro_context { #elif CORO_ASM struct coro_context { - volatile void **sp; /* must be at offset 0 */ + void **sp; /* must be at offset 0 */ }; void __attribute__ ((__noinline__, __regparm__(2))) |