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