| 1 | # Generated from XSLoader.pm.PL (resolved %Config::Config value) | ||
| 2 | |||
| 3 | package XSLoader; | ||
| 4 | |||
| 5 | $VERSION = "0.20"; | ||
| 6 | |||
| 7 | #use strict; | ||
| 8 | |||
| 9 | package DynaLoader; | ||
| 10 | |||
| 11 | # No prizes for guessing why we don't say 'bootstrap DynaLoader;' here. | ||
| 12 | # NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB | ||
| 13 | boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) && | ||
| 14 | !defined(&dl_error); | ||
| 15 | package XSLoader; | ||
| 16 | |||
| 17 | sub load { | ||
| 18 | package DynaLoader; | ||
| 19 | |||
| 20 | my ($caller, $modlibname) = caller(); | ||
| 21 | my $module = $caller; | ||
| 22 | |||
| 23 | if (@_) { | ||
| 24 | $module = $_[0]; | ||
| 25 | } else { | ||
| 26 | $_[0] = $module; | ||
| 27 | } | ||
| 28 | |||
| 29 | # work with static linking too | ||
| 30 | my $boots = "$module\::bootstrap"; | ||
| 31 | goto &$boots if defined &$boots; | ||
| 32 | |||
| 33 | goto \&XSLoader::bootstrap_inherit unless $module and defined &dl_load_file; | ||
| 34 | |||
| 35 | my @modparts = split(/::/,$module); | ||
| 36 | my $modfname = $modparts[-1]; | ||
| 37 | |||
| 38 | my $modpname = join('/',@modparts); | ||
| 39 | my $c = () = split(/::/,$caller,-1); | ||
| 40 | $modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename | ||
| 41 | my $file = "$modlibname/auto/$modpname/$modfname.so"; | ||
| 42 | |||
| 43 | # print STDERR "XSLoader::load for $module ($file)\n" if $dl_debug; | ||
| 44 | |||
| 45 | my $bs = $file; | ||
| 46 | $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library | ||
| 47 | |||
| 48 | if (-s $bs) { # only read file if it's not empty | ||
| 49 | # print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug; | ||
| 50 | eval { do $bs; }; | ||
| 51 | warn "$bs: $@\n" if $@; | ||
| 52 | goto \&XSLoader::bootstrap_inherit; | ||
| 53 | } | ||
| 54 | |||
| 55 | goto \&XSLoader::bootstrap_inherit if not -f $file; | ||
| 56 | |||
| 57 | my $bootname = "boot_$module"; | ||
| 58 | $bootname =~ s/\W/_/g; | ||
| 59 | @DynaLoader::dl_require_symbols = ($bootname); | ||
| 60 | |||
| 61 | my $boot_symbol_ref; | ||
| 62 | |||
| 63 | # Many dynamic extension loading problems will appear to come from | ||
| 64 | # this section of code: XYZ failed at line 123 of DynaLoader.pm. | ||
| 65 | # Often these errors are actually occurring in the initialisation | ||
| 66 | # C code of the extension XS file. Perl reports the error as being | ||
| 67 | # in this perl code simply because this was the last perl code | ||
| 68 | # it executed. | ||
| 69 | |||
| 70 | my $libref = dl_load_file($file, 0) or do { | ||
| 71 | require Carp; | ||
| 72 | Carp::croak("Can't load '$file' for module $module: " . dl_error()); | ||
| 73 | }; | ||
| 74 | push(@DynaLoader::dl_librefs,$libref); # record loaded object | ||
| 75 | |||
| 76 | my @unresolved = dl_undef_symbols(); | ||
| 77 | if (@unresolved) { | ||
| 78 | require Carp; | ||
| 79 | Carp::carp("Undefined symbols present after loading $file: @unresolved\n"); | ||
| 80 | } | ||
| 81 | |||
| 82 | $boot_symbol_ref = dl_find_symbol($libref, $bootname) or do { | ||
| 83 | require Carp; | ||
| 84 | Carp::croak("Can't find '$bootname' symbol in $file\n"); | ||
| 85 | }; | ||
| 86 | |||
| 87 | push(@DynaLoader::dl_modules, $module); # record loaded module | ||
| 88 | |||
| 89 | boot: | ||
| 90 | my $xs = dl_install_xsub($boots, $boot_symbol_ref, $file); | ||
| 91 | |||
| 92 | # See comment block above | ||
| 93 | push(@DynaLoader::dl_shared_objects, $file); # record files loaded | ||
| 94 | return &$xs(@_); | ||
| 95 | } | ||
| 96 | |||
| 97 | sub bootstrap_inherit { | ||
| 98 | require DynaLoader; | ||
| 99 | goto \&DynaLoader::bootstrap_inherit; | ||
| 100 | } | ||
| 101 | |||
| 102 | 1; | ||
| 103 | |||
| 104 | |||
| 105 | __END__ |