Leaked source code of windows server 2003
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.

129 lines
3.7 KiB

  1. # Generated from XSLoader.pm.PL (resolved %Config::Config value)
  2. package XSLoader;
  3. # And Gandalf said: 'Many folk like to know beforehand what is to
  4. # be set on the table; but those who have laboured to prepare the
  5. # feast like to keep their secret; for wonder makes the words of
  6. # praise louder.'
  7. # (Quote from Tolkien sugested by Anno Siegel.)
  8. #
  9. # See pod text at end of file for documentation.
  10. # See also ext/DynaLoader/README in source tree for other information.
  11. #
  12. # [email protected], August 1994
  13. $VERSION = "0.01"; # avoid typo warning
  14. # enable debug/trace messages from DynaLoader perl code
  15. # $dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug;
  16. my $dl_dlext = 'dll';
  17. package DynaLoader;
  18. # No prizes for guessing why we don't say 'bootstrap DynaLoader;' here.
  19. # NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB
  20. boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) &&
  21. !defined(&dl_error);
  22. package XSLoader;
  23. 1; # End of main code
  24. # The bootstrap function cannot be autoloaded (without complications)
  25. # so we define it here:
  26. sub load {
  27. package DynaLoader;
  28. my($module) = $_[0];
  29. # work with static linking too
  30. my $b = "$module\::bootstrap";
  31. goto &$b if defined &$b;
  32. goto retry unless $module and defined &dl_load_file;
  33. my @modparts = split(/::/,$module);
  34. my $modfname = $modparts[-1];
  35. my $modpname = join('/',@modparts);
  36. my $modlibname = (caller())[1];
  37. my $c = @modparts;
  38. $modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename
  39. my $file = "$modlibname/auto/$modpname/$modfname.$dl_dlext";
  40. # print STDERR "XSLoader::load for $module ($file)\n" if $dl_debug;
  41. my $bs = $file;
  42. $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library
  43. goto retry if not -f $file or -s $bs;
  44. my $bootname = "boot_$module";
  45. $bootname =~ s/\W/_/g;
  46. @dl_require_symbols = ($bootname);
  47. # Many dynamic extension loading problems will appear to come from
  48. # this section of code: XYZ failed at line 123 of DynaLoader.pm.
  49. # Often these errors are actually occurring in the initialisation
  50. # C code of the extension XS file. Perl reports the error as being
  51. # in this perl code simply because this was the last perl code
  52. # it executed.
  53. my $libref = dl_load_file($file, 0) or do {
  54. require Carp;
  55. Carp::croak("Can't load '$file' for module $module: " . dl_error());
  56. };
  57. push(@dl_librefs,$libref); # record loaded object
  58. my @unresolved = dl_undef_symbols();
  59. if (@unresolved) {
  60. require Carp;
  61. Carp::carp("Undefined symbols present after loading $file: @unresolved\n");
  62. }
  63. my $boot_symbol_ref = dl_find_symbol($libref, $bootname) or do {
  64. require Carp;
  65. Carp::croak("Can't find '$bootname' symbol in $file\n");
  66. };
  67. my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file);
  68. push(@dl_modules, $module); # record loaded module
  69. # See comment block above
  70. return &$xs(@_);
  71. retry:
  72. require DynaLoader;
  73. goto &DynaLoader::bootstrap_inherit;
  74. }
  75. __END__
  76. =head1 NAME
  77. XSLoader - Dynamically load C libraries into Perl code
  78. =head1 SYNOPSIS
  79. package YourPackage;
  80. use XSLoader;
  81. XSLoader::load 'YourPackage', @args;
  82. =head1 DESCRIPTION
  83. This module defines a standard I<simplified> interface to the dynamic
  84. linking mechanisms available on many platforms. Its primary purpose is
  85. to implement cheap automatic dynamic loading of Perl modules.
  86. For more complicated interface see L<DynaLoader>.
  87. =head1 AUTHOR
  88. Ilya Zakharevich: extraction from DynaLoader.
  89. =cut