| Filename | /usr/share/perl/5.20/XSLoader.pm |
| Statements | Executed 2 statements in 158µs |
| 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.17"; | ||||
| 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 ($module, $modlibname) = caller(); | ||||
| 21 | |||||
| 22 | if (@_) { | ||||
| 23 | $module = $_[0]; | ||||
| 24 | } else { | ||||
| 25 | $_[0] = $module; | ||||
| 26 | } | ||||
| 27 | |||||
| 28 | # work with static linking too | ||||
| 29 | my $boots = "$module\::bootstrap"; | ||||
| 30 | goto &$boots if defined &$boots; | ||||
| 31 | |||||
| 32 | goto \&XSLoader::bootstrap_inherit unless $module and defined &dl_load_file; | ||||
| 33 | |||||
| 34 | my @modparts = split(/::/,$module); | ||||
| 35 | my $modfname = $modparts[-1]; | ||||
| 36 | |||||
| 37 | my $modpname = join('/',@modparts); | ||||
| 38 | my $c = @modparts; | ||||
| 39 | $modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename | ||||
| 40 | my $file = "$modlibname/auto/$modpname/$modfname.so"; | ||||
| 41 | |||||
| 42 | # print STDERR "XSLoader::load for $module ($file)\n" if $dl_debug; | ||||
| 43 | |||||
| 44 | my $bs = $file; | ||||
| 45 | $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library | ||||
| 46 | |||||
| 47 | if (-s $bs) { # only read file if it's not empty | ||||
| 48 | # print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug; | ||||
| 49 | eval { do $bs; }; | ||||
| 50 | warn "$bs: $@\n" if $@; | ||||
| 51 | } | ||||
| 52 | |||||
| 53 | goto \&XSLoader::bootstrap_inherit if not -f $file or -s $bs; | ||||
| 54 | |||||
| 55 | my $bootname = "boot_$module"; | ||||
| 56 | $bootname =~ s/\W/_/g; | ||||
| 57 | @DynaLoader::dl_require_symbols = ($bootname); | ||||
| 58 | |||||
| 59 | my $boot_symbol_ref; | ||||
| 60 | |||||
| 61 | # Many dynamic extension loading problems will appear to come from | ||||
| 62 | # this section of code: XYZ failed at line 123 of DynaLoader.pm. | ||||
| 63 | # Often these errors are actually occurring in the initialisation | ||||
| 64 | # C code of the extension XS file. Perl reports the error as being | ||||
| 65 | # in this perl code simply because this was the last perl code | ||||
| 66 | # it executed. | ||||
| 67 | |||||
| 68 | my $libref = dl_load_file($file, 0) or do { | ||||
| 69 | require Carp; | ||||
| 70 | Carp::croak("Can't load '$file' for module $module: " . dl_error()); | ||||
| 71 | }; | ||||
| 72 | push(@DynaLoader::dl_librefs,$libref); # record loaded object | ||||
| 73 | |||||
| 74 | my @unresolved = dl_undef_symbols(); | ||||
| 75 | if (@unresolved) { | ||||
| 76 | require Carp; | ||||
| 77 | Carp::carp("Undefined symbols present after loading $file: @unresolved\n"); | ||||
| 78 | } | ||||
| 79 | |||||
| 80 | $boot_symbol_ref = dl_find_symbol($libref, $bootname) or do { | ||||
| 81 | require Carp; | ||||
| 82 | Carp::croak("Can't find '$bootname' symbol in $file\n"); | ||||
| 83 | }; | ||||
| 84 | |||||
| 85 | push(@DynaLoader::dl_modules, $module); # record loaded module | ||||
| 86 | |||||
| 87 | boot: | ||||
| 88 | my $xs = dl_install_xsub($boots, $boot_symbol_ref, $file); | ||||
| 89 | |||||
| 90 | # See comment block above | ||||
| 91 | push(@DynaLoader::dl_shared_objects, $file); # record files loaded | ||||
| 92 | 2 | 158µs | 1 | 36µs | return &$xs(@_); # spent 36µs making 1 call to attributes::import |
| 93 | } | ||||
| 94 | |||||
| 95 | sub bootstrap_inherit { | ||||
| 96 | require DynaLoader; | ||||
| 97 | goto \&DynaLoader::bootstrap_inherit; | ||||
| 98 | } | ||||
| 99 | |||||
| 100 | 1; | ||||
| 101 | |||||
| 102 | __END__ | ||||
| 103 |