… | |
… | |
14 | |
14 | |
15 | /* perl-related */ |
15 | /* perl-related */ |
16 | #define TRANSFER_SAVE_DEFAV 0x00000001 /* @_ */ |
16 | #define TRANSFER_SAVE_DEFAV 0x00000001 /* @_ */ |
17 | #define TRANSFER_SAVE_DEFSV 0x00000002 /* $_ */ |
17 | #define TRANSFER_SAVE_DEFSV 0x00000002 /* $_ */ |
18 | #define TRANSFER_SAVE_ERRSV 0x00000004 /* $@ */ |
18 | #define TRANSFER_SAVE_ERRSV 0x00000004 /* $@ */ |
19 | /* c-related */ |
|
|
20 | #define TRANSFER_SAVE_CCTXT 0x00000100 |
|
|
21 | #ifdef CORO_LAZY_STACK |
|
|
22 | # define TRANSFER_LAZY_STACK 0x00000200 |
|
|
23 | #else |
|
|
24 | # define TRANSFER_LAZY_STACK 0x00000000 |
|
|
25 | #endif |
|
|
26 | |
19 | |
27 | #define TRANSFER_SAVE_ALL (TRANSFER_SAVE_DEFAV|TRANSFER_SAVE_DEFSV \ |
20 | #define TRANSFER_SAVE_ALL ( TRANSFER_SAVE_DEFAV \ |
|
|
21 | | TRANSFER_SAVE_DEFSV \ |
28 | |TRANSFER_SAVE_ERRSV|TRANSFER_SAVE_CCTXT) |
22 | | TRANSFER_SAVE_ERRSV ) |
29 | |
23 | |
30 | struct coro; /* opaque */ |
24 | struct coro; /* opaque */ |
31 | |
25 | |
32 | struct CoroAPI { |
26 | struct CoroAPI { |
33 | I32 ver; |
27 | I32 ver; |
… | |
… | |
35 | |
29 | |
36 | /* internal */ |
30 | /* internal */ |
37 | /*struct coro *(*sv_to_coro)(SV *arg, const char *funcname, const char *varname);*/ |
31 | /*struct coro *(*sv_to_coro)(SV *arg, const char *funcname, const char *varname);*/ |
38 | |
32 | |
39 | /* public, state */ |
33 | /* public, state */ |
40 | void (*transfer)(pTHX_ SV *prev, SV *next, int flags); |
34 | void (*transfer)(SV *prev, SV *next, int flags); |
41 | |
35 | |
42 | /* public, coro */ |
36 | /* public, coro */ |
43 | void (*schedule)(void); |
37 | void (*schedule)(void); |
44 | void (*cede)(void); |
38 | void (*cede)(void); |
45 | void (*ready)(SV *sv); |
39 | void (*ready)(SV *sv); |
… | |
… | |
47 | GV *current; |
41 | GV *current; |
48 | }; |
42 | }; |
49 | |
43 | |
50 | static struct CoroAPI *GCoroAPI; |
44 | static struct CoroAPI *GCoroAPI; |
51 | |
45 | |
52 | #define CORO_TRANSFER(prev,next) GCoroAPI->transfer(aTHX_ (prev),(next)) |
46 | #define CORO_TRANSFER(prev,next,flags) GCoroAPI->transfer(aTHX_ (prev), (next), (flags)) |
53 | #define CORO_SCHEDULE GCoroAPI->schedule() |
47 | #define CORO_SCHEDULE GCoroAPI->schedule () |
54 | #define CORO_CEDE GCoroAPI->cede() |
48 | #define CORO_CEDE GCoroAPI->cede () |
55 | #define CORO_READY(coro) GCoroAPI->ready(coro) |
49 | #define CORO_READY(coro) GCoroAPI->ready (coro) |
56 | #define CORO_NREADY (*GCoroAPI->nready) |
50 | #define CORO_NREADY (*GCoroAPI->nready) |
57 | #define CORO_CURRENT SvRV(GvSV(GCoroAPI->current)) |
51 | #define CORO_CURRENT SvRV(GvSV(GCoroAPI->current)) |
58 | |
52 | |
59 | #define I_CORO_API(YourName) \ |
53 | #define I_CORO_API(YourName) \ |
60 | STMT_START { \ |
54 | STMT_START { \ |