📄 xsloader.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "XSLoader 3".TH XSLoader 3 "2008-01-23" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"XSLoader \- Dynamically load C libraries into Perl code.SH "VERSION".IX Header "VERSION"Version 0.08.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 2\& package YourPackage;\& use XSLoader;\&\& XSLoader::load \*(AqYourPackage\*(Aq, $YourPackage::VERSION;.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"This module defines a standard \fIsimplified\fR interface to the dynamiclinking mechanisms available on many platforms. Its primary purpose isto implement cheap automatic dynamic loading of Perl modules..PPFor a more complicated interface, see DynaLoader. Many (most)features of \f(CW\*(C`DynaLoader\*(C'\fR are not implemented in \f(CW\*(C`XSLoader\*(C'\fR, like forexample the \f(CW\*(C`dl_load_flags\*(C'\fR, not honored by \f(CW\*(C`XSLoader\*(C'\fR..ie n .Sh "Migration from ""DynaLoader""".el .Sh "Migration from \f(CWDynaLoader\fP".IX Subsection "Migration from DynaLoader"A typical module using DynaLoader starts like this:.PP.Vb 2\& package YourPackage;\& require DynaLoader;\&\& our @ISA = qw( OnePackage OtherPackage DynaLoader );\& our $VERSION = \*(Aq0.01\*(Aq;\& bootstrap YourPackage $VERSION;.Ve.PPChange this to.PP.Vb 2\& package YourPackage;\& use XSLoader;\&\& our @ISA = qw( OnePackage OtherPackage );\& our $VERSION = \*(Aq0.01\*(Aq;\& XSLoader::load \*(AqYourPackage\*(Aq, $VERSION;.Ve.PPIn other words: replace \f(CW\*(C`require DynaLoader\*(C'\fR by \f(CW\*(C`use XSLoader\*(C'\fR, remove\&\f(CW\*(C`DynaLoader\*(C'\fR from \f(CW@ISA\fR, change \f(CW\*(C`bootstrap\*(C'\fR by \f(CW\*(C`XSLoader::load\*(C'\fR. Do notforget to quote the name of your package on the \f(CW\*(C`XSLoader::load\*(C'\fR line,and add comma (\f(CW\*(C`,\*(C'\fR) before the arguments (\f(CW$VERSION\fR above)..PPOf course, if \f(CW@ISA\fR contained only \f(CW\*(C`DynaLoader\*(C'\fR, there is no need to havethe \f(CW@ISA\fR assignment at all; moreover, if instead of \f(CW\*(C`our\*(C'\fR one uses themore backward-compatible.PP.Vb 1\& use vars qw($VERSION @ISA);.Ve.PPone can remove this reference to \f(CW@ISA\fR together with the \f(CW@ISA\fR assignment..PPIf no \f(CW$VERSION\fR was specified on the \f(CW\*(C`bootstrap\*(C'\fR line, the last line becomes.PP.Vb 1\& XSLoader::load \*(AqYourPackage\*(Aq;.Ve.Sh "Backward compatible boilerplate".IX Subsection "Backward compatible boilerplate"If you want to have your cake and eat it too, you need a more complicatedboilerplate..PP.Vb 2\& package YourPackage;\& use vars qw($VERSION @ISA);\&\& @ISA = qw( OnePackage OtherPackage );\& $VERSION = \*(Aq0.01\*(Aq;\& eval {\& require XSLoader;\& XSLoader::load(\*(AqYourPackage\*(Aq, $VERSION);\& 1;\& } or do {\& require DynaLoader;\& push @ISA, \*(AqDynaLoader\*(Aq;\& bootstrap YourPackage $VERSION;\& };.Ve.PPThe parentheses about \f(CW\*(C`XSLoader::load()\*(C'\fR arguments are needed since we replaced\&\f(CW\*(C`use XSLoader\*(C'\fR by \f(CW\*(C`require\*(C'\fR, so the compiler does not know that a function\&\f(CW\*(C`XSLoader::load()\*(C'\fR is present..PPThis boilerplate uses the low-overhead \f(CW\*(C`XSLoader\*(C'\fR if present; if used withan antic Perl which has no \f(CW\*(C`XSLoader\*(C'\fR, it falls back to using \f(CW\*(C`DynaLoader\*(C'\fR..SH "Order of initialization: early \fIload()\fP".IX Header "Order of initialization: early load()"\&\fISkip this section if the \s-1XSUB\s0 functions are supposed to be called from othermodules only; read it only if you call your XSUBs from the code in your module,or have a \f(CI\*(C`BOOT:\*(C'\fI section in your \s-1XS\s0 file (see \*(L"The \s-1BOOT:\s0 Keyword\*(R" in perlxs).What is described here is equally applicable to the DynaLoaderinterface.\fR.PPA sufficiently complicated module using \s-1XS\s0 would have both Perl code (definedin \fIYourPackage.pm\fR) and \s-1XS\s0 code (defined in \fIYourPackage.xs\fR). If thisPerl code makes calls into this \s-1XS\s0 code, and/or this \s-1XS\s0 code makes calls tothe Perl code, one should be careful with the order of initialization..PPThe call to \f(CW\*(C`XSLoader::load()\*(C'\fR (or \f(CW\*(C`bootstrap()\*(C'\fR) has three side effects:.IP "\(bu" 4if \f(CW$VERSION\fR was specified, a sanity check is done to ensure that theversions of the \fI.pm\fR and the (compiled) \fI.xs\fR parts are compatible;.IP "\(bu" 4the XSUBs are made accessible from Perl;.IP "\(bu" 4if a \f(CW\*(C`BOOT:\*(C'\fR section was present in the \fI.xs\fR file, the code there is called..PPConsequently, if the code in the \fI.pm\fR file makes calls to these XSUBs, it isconvenient to have XSUBs installed before the Perl code is defined; forexample, this makes prototypes for XSUBs visible to this Perl code.Alternatively, if the \f(CW\*(C`BOOT:\*(C'\fR section makes calls to Perl functions (oruses Perl variables) defined in the \fI.pm\fR file, they must be defined prior tothe call to \f(CW\*(C`XSLoader::load()\*(C'\fR (or \f(CW\*(C`bootstrap()\*(C'\fR)..PPThe first situation being much more frequent, it makes sense to rewrite theboilerplate as.PP.Vb 3\& package YourPackage;\& use XSLoader;\& use vars qw($VERSION @ISA);\&\& BEGIN {\& @ISA = qw( OnePackage OtherPackage );\& $VERSION = \*(Aq0.01\*(Aq;\&\& # Put Perl code used in the BOOT: section here\&\& XSLoader::load \*(AqYourPackage\*(Aq, $VERSION;\& }\&\& # Put Perl code making calls into XSUBs here.Ve.Sh "The most hairy case".IX Subsection "The most hairy case"If the interdependence of your \f(CW\*(C`BOOT:\*(C'\fR section and Perl code ismore complicated than this (e.g., the \f(CW\*(C`BOOT:\*(C'\fR section makes calls to Perlfunctions which make calls to XSUBs with prototypes), get rid of the \f(CW\*(C`BOOT:\*(C'\fRsection altogether. Replace it with a function \f(CW\*(C`onBOOT()\*(C'\fR, and call it likethis:.PP.Vb 3\& package YourPackage;\& use XSLoader;\& use vars qw($VERSION @ISA);\&\& BEGIN {\& @ISA = qw( OnePackage OtherPackage );\& $VERSION = \*(Aq0.01\*(Aq;\& XSLoader::load \*(AqYourPackage\*(Aq, $VERSION;\& }\&\& # Put Perl code used in onBOOT() function here; calls to XSUBs are\& # prototype\-checked.\&\& onBOOT;\&\& # Put Perl initialization code assuming that XS is initialized here.Ve.SH "DIAGNOSTICS".IX Header "DIAGNOSTICS".ie n .IP """Can\*(Aqt find \*(Aq%s\*(Aq symbol in %s""" 4.el .IP "\f(CWCan\*(Aqt find \*(Aq%s\*(Aq symbol in %s\fR" 4.IX Item "Cant find %s symbol in %s"\&\fB(F)\fR The bootstrap symbol could not be found in the extension module..ie n .IP """Can\*(Aqt load \*(Aq%s\*(Aq for module %s: %s""" 4.el .IP "\f(CWCan\*(Aqt load \*(Aq%s\*(Aq for module %s: %s\fR" 4.IX Item "Cant load %s for module %s: %s"\&\fB(F)\fR The loading or initialisation of the extension module failed.The detailed error follows..ie n .IP """Undefined symbols present after loading %s: %s""" 4.el .IP "\f(CWUndefined symbols present after loading %s: %s\fR" 4.IX Item "Undefined symbols present after loading %s: %s"\&\fB(W)\fR As the message says, some symbols stay undefined although theextension module was correctly loaded and initialised. The list of undefinedsymbols follows..ie n .IP """XSLoader::load(\*(AqYour::Module\*(Aq, $Your::Module::VERSION)""" 4.el .IP "\f(CWXSLoader::load(\*(AqYour::Module\*(Aq, $Your::Module::VERSION)\fR" 4.IX Item "XSLoader::load(Your::Module, $Your::Module::VERSION)"\&\fB(F)\fR You tried to invoke \f(CW\*(C`load()\*(C'\fR without any argument. You must supplya module name, and optionally its version..SH "LIMITATIONS".IX Header "LIMITATIONS"To reduce the overhead as much as possible, only one possible locationis checked to find the extension \s-1DLL\s0 (this location is where \f(CW\*(C`make install\*(C'\fRwould put the \s-1DLL\s0). If not found, the search for the \s-1DLL\s0 is transparentlydelegated to \f(CW\*(C`DynaLoader\*(C'\fR, which looks for the \s-1DLL\s0 along the \f(CW@INC\fR list..PPIn particular, this is applicable to the structure of \f(CW@INC\fR used for testingnot-yet-installed extensions. This means that running uninstalled extensionsmay have much more overhead than running the same extensions after\&\f(CW\*(C`make install\*(C'\fR..SH "BUGS".IX Header "BUGS"Please report any bugs or feature requests via the \fIperlbug\fR\|(1) utility..SH "SEE ALSO".IX Header "SEE ALSO"DynaLoader.SH "AUTHORS".IX Header "AUTHORS"Ilya Zakharevich originally extracted \f(CW\*(C`XSLoader\*(C'\fR from \f(CW\*(C`DynaLoader\*(C'\fR..PP\&\s-1CPAN\s0 version is currently maintained by Se\*'bastien Aperghis-Tramoni<sebastien@aperghis.net>..PPPrevious maintainer was Michael G Schwern <schwern@pobox.com>..SH "COPYRIGHT".IX Header "COPYRIGHT"This program is free software; you can redistribute it and/or modifyit under the same terms as Perl itself.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -