--- Coro/Coro/CoroAPI.h 2001/08/25 15:14:03 1.1 +++ Coro/Coro/CoroAPI.h 2006/12/01 19:41:06 1.10 @@ -5,48 +5,54 @@ #include "perl.h" #include "XSUB.h" -/* perl-related */ -#define TRANSFER_SAVE_DEFAV 0x00000001 -#define TRANSFER_SAVE_DEFSV 0x00000002 -#define TRANSFER_SAVE_ERRSV 0x00000004 -/* c-related */ -#define TRANSFER_SAVE_CCTXT 0x00000008 -#ifdef CORO_LAZY_STACK -# define TRANSFER_LAZY_STACK 0x00000010 -#else -# define TRANSFER_LAZY_STACK 0x00000000 +#ifndef pTHX_ +# define pTHX_ +# define aTHX_ +# define pTHX +# define aTHX #endif -#define TRANSFER_SAVE_ALL (TRANSFER_SAVE_DEFAV|TRANSFER_SAVE_DEFSV \ - |TRANSFER_SAVE_ERRSV|TRANSFER_SAVE_CCTXT) +/* perl-related */ +#define TRANSFER_SAVE_DEFAV 0x00000001 /* @_ */ +#define TRANSFER_SAVE_DEFSV 0x00000002 /* $_ */ +#define TRANSFER_SAVE_ERRSV 0x00000004 /* $@ */ + +#define TRANSFER_SAVE_ALL ( TRANSFER_SAVE_DEFAV \ + | TRANSFER_SAVE_DEFSV \ + | TRANSFER_SAVE_ERRSV ) -struct coro; /* opaque */ +/*struct coro;*/ /* opaque */ +/* private structure, always use the provided macros below */ struct CoroAPI { I32 ver; -#define CORO_API_VERSION 1 +#define CORO_API_VERSION 2 +#define CORO_API_REVISION 0 /* internal */ /*struct coro *(*sv_to_coro)(SV *arg, const char *funcname, const char *varname);*/ - /* public, state */ - void (*transfer)(pTHX_ SV *prev, SV *next, int flags); + /* public API, Coro::State */ + void (*transfer) (SV *prev, SV *next, int flags); - /* public, coro */ - void (*schedule)(int cede); - void (*ready)(SV *sv); + /* public API, Coro */ + void (*schedule) (void); + void (*cede) (void); + int (*ready) (SV *coro_sv); + int (*is_ready) (SV *coro_sv); int *nready; - GV *current; + SV *current; }; static struct CoroAPI *GCoroAPI; -#define CORO_TRANSFER(prev,next) GCoroAPI->transfer(aTHX_ (prev),(next)) -#define CORO_SCHEDULE GCoroAPI->schedule(0) -#define CORO_CEDE GCoroAPI->schedule(1) -#define CORO_READY(coro) GCoroAPI->ready(coro) -#define CORO_NREADY (*GCoroAPI->nready) -#define CORO_CURRENT GvSV(GCoroAPI->current) +#define CORO_TRANSFER(prev,next,flags) GCoroAPI->transfer (aTHX_ (prev), (next), (flags)) +#define CORO_SCHEDULE GCoroAPI->schedule () +#define CORO_CEDE GCoroAPI->cede () +#define CORO_READY(coro) GCoroAPI->ready (coro) +#define CORO_IS_READY(coro) GCoroAPI->is_ready (coro) +#define CORO_NREADY (*GCoroAPI->nready) +#define CORO_CURRENT SvRV (GCoroAPI->current) #define I_CORO_API(YourName) \ STMT_START { \