ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/perlmulticore/perlmulticore.h
(Generate patch)

Comparing perlmulticore/perlmulticore.h (file contents):
Revision 1.1 by root, Thu Jul 2 22:39:56 2015 UTC vs.
Revision 1.3 by root, Fri Jul 3 02:37:19 2015 UTC

13 13
14/* 14/*
15 15
16=head1 NAME 16=head1 NAME
17 17
18perlmulticore.h - the Perl Multicore Specification and Implementation 18perlmulticore.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
149START_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 */
151struct perl_multicore_api 153struct perl_multicore_api
152{ 154{
154 void (*pmapi_acquire)(void); 156 void (*pmapi_acquire)(void);
155}; 157};
156 158
157static void perl_multicore_init (void); 159static void perl_multicore_init (void);
158 160
159const struct perl_multicore_api perl_multicore_api_init = { perl_multicore_init, 0 }; 161static const struct perl_multicore_api perl_multicore_api_init
162 = { perl_multicore_init, 0 };
160 163
161static struct perl_multicore_api *perl_multicore_api 164static 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 */
168static void 171static void
169perl_multicore_nop (void) 172perl_multicore_nop (void)
170{ 173{
171} 174}
175
176static 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 */
175static void 180static void
176perl_multicore_init (void) 181perl_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
207END_EXTERN_C
208
201#endif 209#endif
202 210
203#endif 211#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines