… | |
… | |
10 | # define aTHX_ |
10 | # define aTHX_ |
11 | # define pTHX |
11 | # define pTHX |
12 | # define aTHX |
12 | # define aTHX |
13 | #endif |
13 | #endif |
14 | |
14 | |
15 | /* perl-related */ |
|
|
16 | #define CORO_SAVE_DEFAV 0x00000001 /* @_ */ |
|
|
17 | #define CORO_SAVE_DEFSV 0x00000002 /* $_ */ |
|
|
18 | #define CORO_SAVE_ERRSV 0x00000004 /* $@ */ |
|
|
19 | #define CORO_SAVE_IRSSV 0x00000008 /* $/ */ |
|
|
20 | #define CORO_SAVE_DEFFH 0x00000010 /* default filehandle */ |
|
|
21 | |
|
|
22 | #define CORO_SAVE_ALL ( CORO_SAVE_DEFAV \ |
|
|
23 | | CORO_SAVE_DEFSV \ |
|
|
24 | | CORO_SAVE_ERRSV \ |
|
|
25 | | CORO_SAVE_IRSSV \ |
|
|
26 | | CORO_SAVE_DEFFH) |
|
|
27 | |
|
|
28 | #define CORO_SAVE_DEF CORO_SAVE_ALL |
|
|
29 | |
|
|
30 | /*struct coro;*/ /* opaque */ |
15 | /*struct coro;*/ /* opaque */ |
31 | |
16 | |
32 | /* private structure, always use the provided macros below */ |
17 | /* private structure, always use the provided macros below */ |
33 | struct CoroAPI { |
18 | struct CoroAPI { |
34 | I32 ver; |
19 | I32 ver; |
35 | #define CORO_API_VERSION 4 |
20 | #define CORO_API_VERSION 5 |
36 | #define CORO_API_REVISION 0 |
21 | #define CORO_API_REVISION 0 |
37 | |
22 | |
38 | /* internal */ |
23 | /* internal */ |
39 | /*struct coro *(*sv_to_coro)(SV *arg, const char *funcname, const char *varname);*/ |
24 | /*struct coro *(*sv_to_coro)(SV *arg, const char *funcname, const char *varname);*/ |
40 | |
25 | |
41 | /* private API, Coro::State */ |
26 | /* private API, Coro::State */ |
42 | void (*transfer) (SV *prev_sv, SV *next_sv); |
27 | void (*transfer) (SV *prev_sv, SV *next_sv); |
43 | int (*save) (SV *coro_sv, int new_save); |
|
|
44 | |
28 | |
45 | /* private API, Coro */ |
29 | /* private API, Coro */ |
46 | void (*schedule) (void); |
30 | void (*schedule) (void); |
47 | int (*cede) (void); |
31 | int (*cede) (void); |
48 | int (*cede_notself) (void); |
32 | int (*cede_notself) (void); |
… | |
… | |
61 | #define CORO_CEDE_NOTSELF GCoroAPI->cede_notself () |
45 | #define CORO_CEDE_NOTSELF GCoroAPI->cede_notself () |
62 | #define CORO_READY(coro) GCoroAPI->ready (coro) |
46 | #define CORO_READY(coro) GCoroAPI->ready (coro) |
63 | #define CORO_IS_READY(coro) GCoroAPI->is_ready (coro) |
47 | #define CORO_IS_READY(coro) GCoroAPI->is_ready (coro) |
64 | #define CORO_NREADY (*GCoroAPI->nready) |
48 | #define CORO_NREADY (*GCoroAPI->nready) |
65 | #define CORO_CURRENT SvRV (GCoroAPI->current) |
49 | #define CORO_CURRENT SvRV (GCoroAPI->current) |
66 | #define CORO_GET_SAVE(coro) GCoroAPI->save ((coro), -1) |
|
|
67 | #define CORO_SET_SAVE(coro,save) GCoroAPI->save ((coro), (save)) |
|
|
68 | |
50 | |
69 | #define I_CORO_API(YourName) \ |
51 | #define I_CORO_API(YourName) \ |
70 | STMT_START { \ |
52 | STMT_START { \ |
71 | SV *sv = perl_get_sv("Coro::API",0); \ |
53 | SV *sv = perl_get_sv("Coro::API",0); \ |
72 | if (!sv) croak("Coro::API not found"); \ |
54 | if (!sv) croak("Coro::API not found"); \ |