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

Comparing perlmulticore/perlmulticore.h (file contents):
Revision 1.5 by root, Mon Aug 13 10:55:30 2018 UTC vs.
Revision 1.6 by root, Sun Mar 3 13:06:01 2019 UTC

25 25
26 perlinterp_release (); 26 perlinterp_release ();
27 do_the_C_thing (); 27 do_the_C_thing ();
28 perlinterp_acquire (); 28 perlinterp_acquire ();
29 29
30 // optional, in BOOT section:
31
32 perlmulticore_advertise ();
33
30=head1 DESCRIPTION 34=head1 DESCRIPTION
31 35
32This documentation is the abridged version of the full documention at 36This documentation is the abridged version of the full documention at
33L<http://perlmulticore.schmorp.de/>. It's recommended to go there instead 37L<http://perlmulticore.schmorp.de/>. It's recommended to go there instead
34of reading this document. 38of reading this document.
118 122
119This could be added to perl's C<CPPFLAGS> when configuring perl on 123This could be added to perl's C<CPPFLAGS> when configuring perl on
120platforms that do not support threading at all for example. 124platforms that do not support threading at all for example.
121 125
122 126
127=head1 ADVERTISING MULTICORE API SUPPORT
128
129To help users find out whether a particular build of your module is, in
130fact, multicore enabled, you can invoke the C<perlmulticore_advertise>
131macro in your C<BOOT:> section, e.g.:
132
133
134 MODULE = My::Mod PACKAGE = My::Mod::Pkg
135
136 BOOT:
137 perlmulticore_advertise ();
138
139What this does is set the C<$My::Mod::PERLMULTICORE_SUPPORT> variable to
140the major API version * 1000 + minor version, for example, version C<1002>
141introduced this feature.
142
143For this to work, the C<cv> parameter passed to C<BOOT:> must still be
144in scope. To ensure this, either invoke the macro early in your C<BOOT:>
145section, or don't declare a local variable called C<cv>, either of which
146should be easy to do.
147
148Note that this is I<optional>, so you don't have to do that.
149
150
123=head1 AUTHOR 151=head1 AUTHOR
124 152
125 Marc A. Lehmann <perlmulticore@schmorp.de> 153 Marc A. Lehmann <perlmulticore@schmorp.de>
126 http://perlmulticore.schmorp.de/ 154 http://perlmulticore.schmorp.de/
127 155
135=cut 163=cut
136 164
137*/ 165*/
138 166
139#define PERL_MULTICORE_MAJOR 1 /* bumped on incompatible changes */ 167#define PERL_MULTICORE_MAJOR 1 /* bumped on incompatible changes */
140#define PERL_MULTICORE_MINOR 1 /* bumped on every change */ 168#define PERL_MULTICORE_MINOR 2 /* bumped on every change */
141 169
142#if PERL_MULTICORE_DISABLE 170#if PERL_MULTICORE_DISABLE
143 171
144#define perlinterp_release() do { } while (0) 172#define perlinterp_release() do { } while (0)
145#define perlinterp_acquire() do { } while (0) 173#define perlinterp_acquire() do { } while (0)
174#define perlmulticore_advertise() do { } while (0)
146 175
147#else 176#else
148 177
149START_EXTERN_C 178START_EXTERN_C
150 179
206 235
207 /* call the real (or dummy) implementation now */ 236 /* call the real (or dummy) implementation now */
208 perlinterp_release (); 237 perlinterp_release ();
209} 238}
210 239
240#define perlmulticore_advertise() \
241 sv_setiv (get_sv ( \
242 form ("%s::PERLMULTICORE_SUPPORT", HvNAME (GvSTASH (CvGV (cv)))), \
243 GV_ADD | GV_ADDMULTI), \
244 PERL_MULTICORE_MAJOR * 1000 + PERL_MULTICORE_MINOR); \
245
211END_EXTERN_C 246END_EXTERN_C
212 247
213#endif 248#endif
214 249
215#endif 250#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines