… | |
… | |
13 | |
13 | |
14 | /* |
14 | /* |
15 | |
15 | |
16 | =head1 NAME |
16 | =head1 NAME |
17 | |
17 | |
18 | perlmulticore.h - the Perl Multicore Specification and Implementation |
18 | perlmulticore.h - implements the Perl Multicore Specification |
19 | |
19 | |
20 | =head1 SYNOPSIS |
20 | =head1 SYNOPSIS |
21 | |
21 | |
22 | #include "perlmultiore.h" |
22 | #include "perlmultiore.h" |
23 | |
23 | |
… | |
… | |
143 | |
143 | |
144 | #define perlinterp_release() do { } while (0) |
144 | #define perlinterp_release() do { } while (0) |
145 | #define perlinterp_acquire() do { } while (0) |
145 | #define perlinterp_acquire() do { } while (0) |
146 | |
146 | |
147 | #else |
147 | #else |
|
|
148 | |
|
|
149 | START_EXTERN_C |
148 | |
150 | |
149 | /* this struct is shared between all modules, and currently */ |
151 | /* this struct is shared between all modules, and currently */ |
150 | /* contain only the two function pointers for release/acquire */ |
152 | /* contain only the two function pointers for release/acquire */ |
151 | struct perl_multicore_api |
153 | struct perl_multicore_api |
152 | { |
154 | { |
… | |
… | |
154 | void (*pmapi_acquire)(void); |
156 | void (*pmapi_acquire)(void); |
155 | }; |
157 | }; |
156 | |
158 | |
157 | static void perl_multicore_init (void); |
159 | static void perl_multicore_init (void); |
158 | |
160 | |
159 | const struct perl_multicore_api perl_multicore_api_init = { perl_multicore_init, 0 }; |
161 | static const struct perl_multicore_api perl_multicore_api_init |
|
|
162 | = { perl_multicore_init, 0 }; |
160 | |
163 | |
161 | static struct perl_multicore_api *perl_multicore_api |
164 | static struct perl_multicore_api *perl_multicore_api |
162 | = (struct perl_multicore_api *)&perl_multicore_api_init; |
165 | = (struct perl_multicore_api *)&perl_multicore_api_init; |
163 | |
166 | |
164 | #define perlinterp_release() perl_multicore_api->pmapi_release () |
167 | #define perlinterp_release() perl_multicore_api->pmapi_release () |
… | |
… | |
167 | /* this is the release/acquire implementation used as fallback */ |
170 | /* this is the release/acquire implementation used as fallback */ |
168 | static void |
171 | static void |
169 | perl_multicore_nop (void) |
172 | perl_multicore_nop (void) |
170 | { |
173 | { |
171 | } |
174 | } |
|
|
175 | |
|
|
176 | static const char perl_multicore_api_key[] = "perl_multicore_api"; |
172 | |
177 | |
173 | /* this is the initial implementation of "release" - it initialises */ |
178 | /* this is the initial implementation of "release" - it initialises */ |
174 | /* the api and then calls the real release function */ |
179 | /* the api and then calls the real release function */ |
175 | static void |
180 | static void |
176 | perl_multicore_init (void) |
181 | perl_multicore_init (void) |
177 | { |
182 | { |
178 | dTHX; |
183 | dTHX; |
179 | |
184 | |
180 | /* check for existing API struct in PL_modglobal */ |
185 | /* check for existing API struct in PL_modglobal */ |
181 | SV **api_svp = hv_fetch (PL_modglobal, "perl_multicore_api", sizeof ("perl_multicore_api") - 1, 1); |
186 | SV **api_svp = hv_fetch (PL_modglobal, perl_multicore_api_key, |
|
|
187 | sizeof (perl_multicore_api_key) - 1, 1); |
182 | |
188 | |
183 | if (SvPOKp (*api_svp)) |
189 | if (SvPOKp (*api_svp)) |
184 | perl_multicore_api = (struct perl_multicore_api *)SvPVX (*api_svp); /* we have one, use the existing one */ |
190 | perl_multicore_api = (struct perl_multicore_api *)SvPVX (*api_svp); /* we have one, use the existing one */ |
185 | else |
191 | else |
186 | { |
192 | { |
… | |
… | |
196 | |
202 | |
197 | /* call the real (or dummy) implementation now */ |
203 | /* call the real (or dummy) implementation now */ |
198 | perlinterp_release (); |
204 | perlinterp_release (); |
199 | } |
205 | } |
200 | |
206 | |
|
|
207 | END_EXTERN_C |
|
|
208 | |
201 | #endif |
209 | #endif |
202 | |
210 | |
203 | #endif |
211 | #endif |