--- libcoro/coro.h 2006/10/26 07:27:50 1.15 +++ libcoro/coro.h 2007/04/27 19:26:18 1.20 @@ -38,6 +38,8 @@ /* * 2006-10-26 Include stddef.h on OS X to work around one of its bugs. * Reported by Michael_G_Schwern. + * 2006-11-26 Use _setjmp instead of setjmp on GNU/Linux. + * 2007-04-27 Set unwind frame info if gcc 3+ and ELF is detected. */ #ifndef CORO_H @@ -100,9 +102,9 @@ typedef void (*coro_func)(void *); /* - * A coroutine state is saved in the following structure. Treat it as a + * A coroutine state is saved in the following structure. Treat it as an * opaque type. errno and sigmask might be saved, but don't rely on it, - * implement your own switching primitive if you need it. + * implement your own switching primitive if you need that. */ typedef struct coro_context coro_context; @@ -114,9 +116,11 @@ * Allocating/deallocating the stack is your own responsibility, so there is * no coro_destroy function. */ -void coro_create (coro_context *ctx, - coro_func coro, void *arg, - void *sptr, long ssize); +void coro_create (coro_context *ctx, /* an uninitialised coro_context */ + coro_func coro, /* the coroutine code to be executed */ + void *arg, /* a single pointer passed to the coro */ + void *sptr, /* start of stack area */ + long ssize); /* size of stack area */ /* * The following prototype defines the coroutine switching function. It is @@ -161,7 +165,7 @@ #elif CORO_SJLJ || CORO_LOSER || CORO_LINUX || CORO_IRIX #if defined(CORO_LINUX) && !defined(_GNU_SOURCE) -# define _GNU_SOURCE // for linux libc +# define _GNU_SOURCE /* for linux libc */ #endif #include @@ -170,7 +174,11 @@ jmp_buf env; }; -#define coro_transfer(p,n) do { if (!setjmp ((p)->env)) longjmp ((n)->env, 1); } while(0) +#if CORO_LINUX +# 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) +#endif #endif