Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

350 lines
10 KiB

  1. # Generated from XSLoader.pm.PL (resolved %Config::Config value)
  2. package XSLoader;
  3. $VERSION = "0.08";
  4. #use strict;
  5. # enable debug/trace messages from DynaLoader perl code
  6. # $dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug;
  7. my $dl_dlext = 'dll';
  8. package DynaLoader;
  9. # No prizes for guessing why we don't say 'bootstrap DynaLoader;' here.
  10. # NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB
  11. boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) &&
  12. !defined(&dl_error);
  13. package XSLoader;
  14. sub load {
  15. package DynaLoader;
  16. die q{XSLoader::load('Your::Module', $Your::Module::VERSION)} unless @_;
  17. my($module) = $_[0];
  18. # work with static linking too
  19. my $b = "$module\::bootstrap";
  20. goto &$b if defined &$b;
  21. goto retry unless $module and defined &dl_load_file;
  22. my @modparts = split(/::/,$module);
  23. my $modfname = $modparts[-1];
  24. my $modpname = join('/',@modparts);
  25. my $modlibname = (caller())[1];
  26. my $c = @modparts;
  27. $modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename
  28. my $file = "$modlibname/auto/$modpname/$modfname.$dl_dlext";
  29. # print STDERR "XSLoader::load for $module ($file)\n" if $dl_debug;
  30. my $bs = $file;
  31. $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library
  32. goto retry if not -f $file or -s $bs;
  33. my $bootname = "boot_$module";
  34. $bootname =~ s/\W/_/g;
  35. @DynaLoader::dl_require_symbols = ($bootname);
  36. my $boot_symbol_ref;
  37. # Many dynamic extension loading problems will appear to come from
  38. # this section of code: XYZ failed at line 123 of DynaLoader.pm.
  39. # Often these errors are actually occurring in the initialisation
  40. # C code of the extension XS file. Perl reports the error as being
  41. # in this perl code simply because this was the last perl code
  42. # it executed.
  43. my $libref = dl_load_file($file, 0) or do {
  44. require Carp;
  45. Carp::croak("Can't load '$file' for module $module: " . dl_error());
  46. };
  47. push(@DynaLoader::dl_librefs,$libref); # record loaded object
  48. my @unresolved = dl_undef_symbols();
  49. if (@unresolved) {
  50. require Carp;
  51. Carp::carp("Undefined symbols present after loading $file: @unresolved\n");
  52. }
  53. $boot_symbol_ref = dl_find_symbol($libref, $bootname) or do {
  54. require Carp;
  55. Carp::croak("Can't find '$bootname' symbol in $file\n");
  56. };
  57. push(@DynaLoader::dl_modules, $module); # record loaded module
  58. boot:
  59. my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file);
  60. # See comment block above
  61. push(@DynaLoader::dl_shared_objects, $file); # record files loaded
  62. return &$xs(@_);
  63. retry:
  64. my $bootstrap_inherit = DynaLoader->can('bootstrap_inherit') ||
  65. XSLoader->can('bootstrap_inherit');
  66. goto &$bootstrap_inherit;
  67. }
  68. # Versions of DynaLoader prior to 5.6.0 don't have this function.
  69. sub bootstrap_inherit {
  70. package DynaLoader;
  71. my $module = $_[0];
  72. local *DynaLoader::isa = *{"$module\::ISA"};
  73. local @DynaLoader::isa = (@DynaLoader::isa, 'DynaLoader');
  74. # Cannot goto due to delocalization. Will report errors on a wrong line?
  75. require DynaLoader;
  76. DynaLoader::bootstrap(@_);
  77. }
  78. 1;
  79. __END__
  80. =head1 NAME
  81. XSLoader - Dynamically load C libraries into Perl code
  82. =head1 VERSION
  83. Version 0.08
  84. =head1 SYNOPSIS
  85. package YourPackage;
  86. use XSLoader;
  87. XSLoader::load 'YourPackage', $YourPackage::VERSION;
  88. =head1 DESCRIPTION
  89. This module defines a standard I<simplified> interface to the dynamic
  90. linking mechanisms available on many platforms. Its primary purpose is
  91. to implement cheap automatic dynamic loading of Perl modules.
  92. For a more complicated interface, see L<DynaLoader>. Many (most)
  93. features of C<DynaLoader> are not implemented in C<XSLoader>, like for
  94. example the C<dl_load_flags>, not honored by C<XSLoader>.
  95. =head2 Migration from C<DynaLoader>
  96. A typical module using L<DynaLoader|DynaLoader> starts like this:
  97. package YourPackage;
  98. require DynaLoader;
  99. our @ISA = qw( OnePackage OtherPackage DynaLoader );
  100. our $VERSION = '0.01';
  101. bootstrap YourPackage $VERSION;
  102. Change this to
  103. package YourPackage;
  104. use XSLoader;
  105. our @ISA = qw( OnePackage OtherPackage );
  106. our $VERSION = '0.01';
  107. XSLoader::load 'YourPackage', $VERSION;
  108. In other words: replace C<require DynaLoader> by C<use XSLoader>, remove
  109. C<DynaLoader> from C<@ISA>, change C<bootstrap> by C<XSLoader::load>. Do not
  110. forget to quote the name of your package on the C<XSLoader::load> line,
  111. and add comma (C<,>) before the arguments (C<$VERSION> above).
  112. Of course, if C<@ISA> contained only C<DynaLoader>, there is no need to have
  113. the C<@ISA> assignment at all; moreover, if instead of C<our> one uses the
  114. more backward-compatible
  115. use vars qw($VERSION @ISA);
  116. one can remove this reference to C<@ISA> together with the C<@ISA> assignment.
  117. If no C<$VERSION> was specified on the C<bootstrap> line, the last line becomes
  118. XSLoader::load 'YourPackage';
  119. =head2 Backward compatible boilerplate
  120. If you want to have your cake and eat it too, you need a more complicated
  121. boilerplate.
  122. package YourPackage;
  123. use vars qw($VERSION @ISA);
  124. @ISA = qw( OnePackage OtherPackage );
  125. $VERSION = '0.01';
  126. eval {
  127. require XSLoader;
  128. XSLoader::load('YourPackage', $VERSION);
  129. 1;
  130. } or do {
  131. require DynaLoader;
  132. push @ISA, 'DynaLoader';
  133. bootstrap YourPackage $VERSION;
  134. };
  135. The parentheses about C<XSLoader::load()> arguments are needed since we replaced
  136. C<use XSLoader> by C<require>, so the compiler does not know that a function
  137. C<XSLoader::load()> is present.
  138. This boilerplate uses the low-overhead C<XSLoader> if present; if used with
  139. an antic Perl which has no C<XSLoader>, it falls back to using C<DynaLoader>.
  140. =head1 Order of initialization: early load()
  141. I<Skip this section if the XSUB functions are supposed to be called from other
  142. modules only; read it only if you call your XSUBs from the code in your module,
  143. or have a C<BOOT:> section in your XS file (see L<perlxs/"The BOOT: Keyword">).
  144. What is described here is equally applicable to the L<DynaLoader|DynaLoader>
  145. interface.>
  146. A sufficiently complicated module using XS would have both Perl code (defined
  147. in F<YourPackage.pm>) and XS code (defined in F<YourPackage.xs>). If this
  148. Perl code makes calls into this XS code, and/or this XS code makes calls to
  149. the Perl code, one should be careful with the order of initialization.
  150. The call to C<XSLoader::load()> (or C<bootstrap()>) has three side effects:
  151. =over
  152. =item *
  153. if C<$VERSION> was specified, a sanity check is done to ensure that the
  154. versions of the F<.pm> and the (compiled) F<.xs> parts are compatible;
  155. =item *
  156. the XSUBs are made accessible from Perl;
  157. =item *
  158. if a C<BOOT:> section was present in the F<.xs> file, the code there is called.
  159. =back
  160. Consequently, if the code in the F<.pm> file makes calls to these XSUBs, it is
  161. convenient to have XSUBs installed before the Perl code is defined; for
  162. example, this makes prototypes for XSUBs visible to this Perl code.
  163. Alternatively, if the C<BOOT:> section makes calls to Perl functions (or
  164. uses Perl variables) defined in the F<.pm> file, they must be defined prior to
  165. the call to C<XSLoader::load()> (or C<bootstrap()>).
  166. The first situation being much more frequent, it makes sense to rewrite the
  167. boilerplate as
  168. package YourPackage;
  169. use XSLoader;
  170. use vars qw($VERSION @ISA);
  171. BEGIN {
  172. @ISA = qw( OnePackage OtherPackage );
  173. $VERSION = '0.01';
  174. # Put Perl code used in the BOOT: section here
  175. XSLoader::load 'YourPackage', $VERSION;
  176. }
  177. # Put Perl code making calls into XSUBs here
  178. =head2 The most hairy case
  179. If the interdependence of your C<BOOT:> section and Perl code is
  180. more complicated than this (e.g., the C<BOOT:> section makes calls to Perl
  181. functions which make calls to XSUBs with prototypes), get rid of the C<BOOT:>
  182. section altogether. Replace it with a function C<onBOOT()>, and call it like
  183. this:
  184. package YourPackage;
  185. use XSLoader;
  186. use vars qw($VERSION @ISA);
  187. BEGIN {
  188. @ISA = qw( OnePackage OtherPackage );
  189. $VERSION = '0.01';
  190. XSLoader::load 'YourPackage', $VERSION;
  191. }
  192. # Put Perl code used in onBOOT() function here; calls to XSUBs are
  193. # prototype-checked.
  194. onBOOT;
  195. # Put Perl initialization code assuming that XS is initialized here
  196. =head1 DIAGNOSTICS
  197. =over
  198. =item C<Can't find '%s' symbol in %s>
  199. B<(F)> The bootstrap symbol could not be found in the extension module.
  200. =item C<Can't load '%s' for module %s: %s>
  201. B<(F)> The loading or initialisation of the extension module failed.
  202. The detailed error follows.
  203. =item C<Undefined symbols present after loading %s: %s>
  204. B<(W)> As the message says, some symbols stay undefined although the
  205. extension module was correctly loaded and initialised. The list of undefined
  206. symbols follows.
  207. =item C<XSLoader::load('Your::Module', $Your::Module::VERSION)>
  208. B<(F)> You tried to invoke C<load()> without any argument. You must supply
  209. a module name, and optionally its version.
  210. =back
  211. =head1 LIMITATIONS
  212. To reduce the overhead as much as possible, only one possible location
  213. is checked to find the extension DLL (this location is where C<make install>
  214. would put the DLL). If not found, the search for the DLL is transparently
  215. delegated to C<DynaLoader>, which looks for the DLL along the C<@INC> list.
  216. In particular, this is applicable to the structure of C<@INC> used for testing
  217. not-yet-installed extensions. This means that running uninstalled extensions
  218. may have much more overhead than running the same extensions after
  219. C<make install>.
  220. =head1 BUGS
  221. Please report any bugs or feature requests via the perlbug(1) utility.
  222. =head1 SEE ALSO
  223. L<DynaLoader>
  224. =head1 AUTHORS
  225. Ilya Zakharevich originally extracted C<XSLoader> from C<DynaLoader>.
  226. CPAN version is currently maintained by SE<eacute>bastien Aperghis-Tramoni
  227. E<lt>sebastien@aperghis.netE<gt>.
  228. Previous maintainer was Michael G Schwern <[email protected]>.
  229. =head1 COPYRIGHT
  230. This program is free software; you can redistribute it and/or modify
  231. it under the same terms as Perl itself.
  232. =cut