← Index
NYTProf Performance Profile
«
line view
»
For /usr/local/libexec/sympa/task_manager-debug.pl
Run on Tue Jun 1 22:32:51 2021
Reported on Tue Jun 1 22:35:15 2021
Filename
/usr/local/lib/perl5/5.32/XSLoader.pm
Statements
Executed 0 statements in 0s
Subroutines
Calls
P
F
Exclusive
Time
Inclusive
Time
Subroutine
0
0
0
0s
0s
XSLoader::::bootstrap_inherit
XSLoader::
bootstrap_inherit
0
0
0
0s
0s
XSLoader::::load
XSLoader::
load
Call graph for these subroutines as a
Graphviz
dot language file
.
Line
State
ments
Time
on line
Calls
Time
in subs
Code
1
# Generated from XSLoader_pm.PL (resolved %Config::Config value)
2
# This file is unique for every OS
3
4
package XSLoader;
5
6
$VERSION = "0.30"; # remember to update version in POD!
7
8
#use strict;
9
10
package DynaLoader;
11
12
# No prizes for guessing why we don't say 'bootstrap DynaLoader;' here.
13
# NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB
14
boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) &&
15
!defined(&dl_error);
16
package XSLoader;
17
18
sub load {
19
package DynaLoader;
20
21
my ($caller, $modlibname) = caller();
22
my $module = $caller;
23
24
if (@_) {
25
$module = $_[0];
26
} else {
27
$_[0] = $module;
28
}
29
30
# work with static linking too
31
my $boots = "$module\::bootstrap";
32
goto &$boots if defined &$boots;
33
34
goto \&XSLoader::bootstrap_inherit unless $module and defined &dl_load_file;
35
36
my @modparts = split(/::/,$module);
37
my $modfname = $modparts[-1];
38
my $modfname_orig = $modfname; # For .bs file search
39
40
my $modpname = join('/',@modparts);
41
my $c = () = split(/::/,$caller,-1);
42
$modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename
43
# Does this look like a relative path?
44
if ($modlibname !~ m{^/}) {
45
# Someone may have a #line directive that changes the file name, or
46
# may be calling XSLoader::load from inside a string eval. We cer-
47
# tainly do not want to go loading some code that is not in @INC,
48
# as it could be untrusted.
49
#
50
# We could just fall back to DynaLoader here, but then the rest of
51
# this function would go untested in the perl core, since all @INC
52
# paths are relative during testing. That would be a time bomb
53
# waiting to happen, since bugs could be introduced into the code.
54
#
55
# So look through @INC to see if $modlibname is in it. A rela-
56
# tive $modlibname is not a common occurrence, so this block is
57
# not hot code.
58
FOUND: {
59
for (@INC) {
60
if ($_ eq $modlibname) {
61
last FOUND;
62
}
63
}
64
# Not found. Fall back to DynaLoader.
65
goto \&XSLoader::bootstrap_inherit;
66
}
67
}
68
my $file = "$modlibname/auto/$modpname/$modfname.so";
69
70
# print STDERR "XSLoader::load for $module ($file)\n" if $dl_debug;
71
72
# N.B. The .bs file does not following the naming convention used
73
# by mod2fname, so use the unedited version of the name.
74
75
my $bs = "$modlibname/auto/$modpname/$modfname_orig.bs";
76
77
# This calls DynaLoader::bootstrap, which will load the .bs file if present
78
goto \&XSLoader::bootstrap_inherit if not -f $file or -s $bs;
79
80
my $bootname = "boot_$module";
81
$bootname =~ s/\W/_/g;
82
@DynaLoader::dl_require_symbols = ($bootname);
83
84
my $boot_symbol_ref;
85
86
# Many dynamic extension loading problems will appear to come from
87
# this section of code: XYZ failed at line 123 of DynaLoader.pm.
88
# Often these errors are actually occurring in the initialisation
89
# C code of the extension XS file. Perl reports the error as being
90
# in this perl code simply because this was the last perl code
91
# it executed.
92
93
my $libref = dl_load_file($file, 0) or do {
94
require Carp;
95
Carp::croak("Can't load '$file' for module $module: " . dl_error());
96
};
97
push(@DynaLoader::dl_librefs,$libref); # record loaded object
98
99
$boot_symbol_ref = dl_find_symbol($libref, $bootname) or do {
100
require Carp;
101
Carp::croak("Can't find '$bootname' symbol in $file\n");
102
};
103
104
push(@DynaLoader::dl_modules, $module); # record loaded module
105
106
boot:
107
my $xs = dl_install_xsub($boots, $boot_symbol_ref, $file);
108
109
# See comment block above
110
push(@DynaLoader::dl_shared_objects, $file); # record files loaded
111
return &$xs(@_);
112
}
113
114
sub bootstrap_inherit {
115
require DynaLoader;
116
goto \&DynaLoader::bootstrap_inherit;
117
}
118
119
1;
120
121
122
__END__
123
124
=head1 NAME
125
126
XSLoader - Dynamically load C libraries into Perl code
127
128
=head1 VERSION
129
130
Version 0.30
131
132
=head1 SYNOPSIS
133
134
package YourPackage;
135
require XSLoader;
136
137
XSLoader::load(__PACKAGE__, $VERSION);
138
139
=head1 DESCRIPTION
140
141
This module defines a standard I<simplified> interface to the dynamic
142
linking mechanisms available on many platforms. Its primary purpose is
143
to implement cheap automatic dynamic loading of Perl modules.
144
145
For a more complicated interface, see L<DynaLoader>. Many (most)
146
features of C<DynaLoader> are not implemented in C<XSLoader>, like for
147
example the C<dl_load_flags>, not honored by C<XSLoader>.
148
149
=head2 Migration from C<DynaLoader>
150
151
A typical module using L<DynaLoader|DynaLoader> starts like this:
152
153
package YourPackage;
154
require DynaLoader;
155
156
our @ISA = qw( OnePackage OtherPackage DynaLoader );
157
our $VERSION = '0.01';
158
__PACKAGE__->bootstrap($VERSION);
159
160
Change this to
161
162
package YourPackage;
163
use XSLoader;
164
165
our @ISA = qw( OnePackage OtherPackage );
166
our $VERSION = '0.01';
167
XSLoader::load(__PACKAGE__, $VERSION);
168
169
In other words: replace C<require DynaLoader> by C<use XSLoader>, remove
170
C<DynaLoader> from C<@ISA>, change C<bootstrap> by C<XSLoader::load>. Do not
171
forget to quote the name of your package on the C<XSLoader::load> line,
172
and add comma (C<,>) before the arguments (C<$VERSION> above).
173
174
Of course, if C<@ISA> contained only C<DynaLoader>, there is no need to have
175
the C<@ISA> assignment at all; moreover, if instead of C<our> one uses the
176
more backward-compatible
177
178
use vars qw($VERSION @ISA);
179
180
one can remove this reference to C<@ISA> together with the C<@ISA> assignment.
181
182
If no C<$VERSION> was specified on the C<bootstrap> line, the last line becomes
183
184
XSLoader::load(__PACKAGE__);
185
186
in which case it can be further simplified to
187
188
XSLoader::load();
189
190
as C<load> will use C<caller> to determine the package.
191
192
=head2 Backward compatible boilerplate
193
194
If you want to have your cake and eat it too, you need a more complicated
195
boilerplate.
196
197
package YourPackage;
198
199
our @ISA = qw( OnePackage OtherPackage );
200
our $VERSION = '0.01';
201
eval {
202
require XSLoader;
203
XSLoader::load(__PACKAGE__, $VERSION);
204
1;
205
} or do {
206
require DynaLoader;
207
push @ISA, 'DynaLoader';
208
__PACKAGE__->bootstrap($VERSION);
209
};
210
211
The parentheses about C<XSLoader::load()> arguments are needed since we replaced
212
C<use XSLoader> by C<require>, so the compiler does not know that a function
213
C<XSLoader::load()> is present.
214
215
This boilerplate uses the low-overhead C<XSLoader> if present; if used with
216
an antique Perl which has no C<XSLoader>, it falls back to using C<DynaLoader>.
217
218
=head1 Order of initialization: early load()
219
220
I<Skip this section if the XSUB functions are supposed to be called from other
221
modules only; read it only if you call your XSUBs from the code in your module,
222
or have a C<BOOT:> section in your XS file (see L<perlxs/"The BOOT: Keyword">).
223
What is described here is equally applicable to the L<DynaLoader|DynaLoader>
224
interface.>
225
226
A sufficiently complicated module using XS would have both Perl code (defined
227
in F<YourPackage.pm>) and XS code (defined in F<YourPackage.xs>). If this
228
Perl code makes calls into this XS code, and/or this XS code makes calls to
229
the Perl code, one should be careful with the order of initialization.
230
231
The call to C<XSLoader::load()> (or C<bootstrap()>) calls the module's
232
bootstrap code. For modules build by F<xsubpp> (nearly all modules) this
233
has three side effects:
234
235
=over
236
237
=item *
238
239
A sanity check is done to ensure that the versions of the F<.pm> and the
240
(compiled) F<.xs> parts are compatible. If C<$VERSION> was specified, this
241
is used for the check. If not specified, it defaults to
242
C<$XS_VERSION // $VERSION> (in the module's namespace)
243
244
=item *
245
246
the XSUBs are made accessible from Perl
247
248
=item *
249
250
if a C<BOOT:> section was present in the F<.xs> file, the code there is called.
251
252
=back
253
254
Consequently, if the code in the F<.pm> file makes calls to these XSUBs, it is
255
convenient to have XSUBs installed before the Perl code is defined; for
256
example, this makes prototypes for XSUBs visible to this Perl code.
257
Alternatively, if the C<BOOT:> section makes calls to Perl functions (or
258
uses Perl variables) defined in the F<.pm> file, they must be defined prior to
259
the call to C<XSLoader::load()> (or C<bootstrap()>).
260
261
The first situation being much more frequent, it makes sense to rewrite the
262
boilerplate as
263
264
package YourPackage;
265
use XSLoader;
266
our ($VERSION, @ISA);
267
268
BEGIN {
269
@ISA = qw( OnePackage OtherPackage );
270
$VERSION = '0.01';
271
272
# Put Perl code used in the BOOT: section here
273
274
XSLoader::load(__PACKAGE__, $VERSION);
275
}
276
277
# Put Perl code making calls into XSUBs here
278
279
=head2 The most hairy case
280
281
If the interdependence of your C<BOOT:> section and Perl code is
282
more complicated than this (e.g., the C<BOOT:> section makes calls to Perl
283
functions which make calls to XSUBs with prototypes), get rid of the C<BOOT:>
284
section altogether. Replace it with a function C<onBOOT()>, and call it like
285
this:
286
287
package YourPackage;
288
use XSLoader;
289
our ($VERSION, @ISA);
290
291
BEGIN {
292
@ISA = qw( OnePackage OtherPackage );
293
$VERSION = '0.01';
294
XSLoader::load(__PACKAGE__, $VERSION);
295
}
296
297
# Put Perl code used in onBOOT() function here; calls to XSUBs are
298
# prototype-checked.
299
300
onBOOT;
301
302
# Put Perl initialization code assuming that XS is initialized here
303
304
305
=head1 DIAGNOSTICS
306
307
=over
308
309
=item C<Can't find '%s' symbol in %s>
310
311
B<(F)> The bootstrap symbol could not be found in the extension module.
312
313
=item C<Can't load '%s' for module %s: %s>
314
315
B<(F)> The loading or initialisation of the extension module failed.
316
The detailed error follows.
317
318
=item C<Undefined symbols present after loading %s: %s>
319
320
B<(W)> As the message says, some symbols stay undefined although the
321
extension module was correctly loaded and initialised. The list of undefined
322
symbols follows.
323
324
=back
325
326
=head1 LIMITATIONS
327
328
To reduce the overhead as much as possible, only one possible location
329
is checked to find the extension DLL (this location is where C<make install>
330
would put the DLL). If not found, the search for the DLL is transparently
331
delegated to C<DynaLoader>, which looks for the DLL along the C<@INC> list.
332
333
In particular, this is applicable to the structure of C<@INC> used for testing
334
not-yet-installed extensions. This means that running uninstalled extensions
335
may have much more overhead than running the same extensions after
336
C<make install>.
337
338
339
=head1 KNOWN BUGS
340
341
The new simpler way to call C<XSLoader::load()> with no arguments at all
342
does not work on Perl 5.8.4 and 5.8.5.
343
344
345
=head1 BUGS
346
347
Please report any bugs or feature requests via the perlbug(1) utility.
348
349
350
=head1 SEE ALSO
351
352
L<DynaLoader>
353
354
355
=head1 AUTHORS
356
357
Ilya Zakharevich originally extracted C<XSLoader> from C<DynaLoader>.
358
359
CPAN version is currently maintained by SE<eacute>bastien Aperghis-Tramoni
360
E<lt>sebastien@aperghis.netE<gt>.
361
362
Previous maintainer was Michael G Schwern <schwern@pobox.com>.
363
364
365
=head1 COPYRIGHT & LICENSE
366
367
Copyright (C) 1990-2011 by Larry Wall and others.
368
369
This program is free software; you can redistribute it and/or modify
370
it under the same terms as Perl itself.
371
372
=cut