Current Path : /usr/opt/perl530/man/man3/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //usr/opt/perl530/man/man3/XSLoader.3 |
.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .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" '' . ds C` . ds C' '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 >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" 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 "2020-04-14" "perl v5.30.2" "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.30 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& package YourPackage; \& require XSLoader; \& \& XSLoader::load(_\|_PACKAGE_\|_, $VERSION); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module defines a standard \fIsimplified\fR interface to the dynamic linking mechanisms available on many platforms. Its primary purpose is to implement cheap automatic dynamic loading of Perl modules. .PP For 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 for example the \f(CW\*(C`dl_load_flags\*(C'\fR, not honored by \f(CW\*(C`XSLoader\*(C'\fR. .ie n .SS "Migration from ""DynaLoader""" .el .SS "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; \& _\|_PACKAGE_\|_\->bootstrap($VERSION); .Ve .PP Change this to .PP .Vb 2 \& package YourPackage; \& use XSLoader; \& \& our @ISA = qw( OnePackage OtherPackage ); \& our $VERSION = \*(Aq0.01\*(Aq; \& XSLoader::load(_\|_PACKAGE_\|_, $VERSION); .Ve .PP In 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 not forget 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). .PP Of course, if \f(CW@ISA\fR contained only \f(CW\*(C`DynaLoader\*(C'\fR, there is no need to have the \f(CW@ISA\fR assignment at all; moreover, if instead of \f(CW\*(C`our\*(C'\fR one uses the more backward-compatible .PP .Vb 1 \& use vars qw($VERSION @ISA); .Ve .PP one can remove this reference to \f(CW@ISA\fR together with the \f(CW@ISA\fR assignment. .PP If 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(_\|_PACKAGE_\|_); .Ve .PP in which case it can be further simplified to .PP .Vb 1 \& XSLoader::load(); .Ve .PP as \f(CW\*(C`load\*(C'\fR will use \f(CW\*(C`caller\*(C'\fR to determine the package. .SS "Backward compatible boilerplate" .IX Subsection "Backward compatible boilerplate" If you want to have your cake and eat it too, you need a more complicated boilerplate. .PP .Vb 1 \& package YourPackage; \& \& our @ISA = qw( OnePackage OtherPackage ); \& our $VERSION = \*(Aq0.01\*(Aq; \& eval { \& require XSLoader; \& XSLoader::load(_\|_PACKAGE_\|_, $VERSION); \& 1; \& } or do { \& require DynaLoader; \& push @ISA, \*(AqDynaLoader\*(Aq; \& _\|_PACKAGE_\|_\->bootstrap($VERSION); \& }; .Ve .PP The 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. .PP This boilerplate uses the low-overhead \f(CW\*(C`XSLoader\*(C'\fR if present; if used with an antique 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 \fBload()\fP" .IX Header "Order of initialization: early load()" \&\fISkip this section if the \s-1XSUB\s0 functions are supposed to be called from other modules 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 DynaLoader interface.\fR .PP A sufficiently complicated module using \s-1XS\s0 would have both Perl code (defined in \fIYourPackage.pm\fR) and \s-1XS\s0 code (defined in \fIYourPackage.xs\fR). If this Perl code makes calls into this \s-1XS\s0 code, and/or this \s-1XS\s0 code makes calls to the Perl code, one should be careful with the order of initialization. .PP The call to \f(CW\*(C`XSLoader::load()\*(C'\fR (or \f(CW\*(C`bootstrap()\*(C'\fR) calls the module's bootstrap code. For modules build by \fIxsubpp\fR (nearly all modules) this has three side effects: .IP "\(bu" 4 A sanity check is done to ensure that the versions of the \fI.pm\fR and the (compiled) \fI.xs\fR parts are compatible. If \f(CW$VERSION\fR was specified, this is used for the check. If not specified, it defaults to \&\f(CW\*(C`$XS_VERSION // $VERSION\*(C'\fR (in the module's namespace) .IP "\(bu" 4 the XSUBs are made accessible from Perl .IP "\(bu" 4 if a \f(CW\*(C`BOOT:\*(C'\fR section was present in the \fI.xs\fR file, the code there is called. .PP Consequently, if the code in the \fI.pm\fR file makes calls to these XSUBs, it is convenient to have XSUBs installed before the Perl code is defined; for example, 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 (or uses Perl variables) defined in the \fI.pm\fR file, they must be defined prior to the call to \f(CW\*(C`XSLoader::load()\*(C'\fR (or \f(CW\*(C`bootstrap()\*(C'\fR). .PP The first situation being much more frequent, it makes sense to rewrite the boilerplate as .PP .Vb 3 \& package YourPackage; \& use XSLoader; \& our ($VERSION, @ISA); \& \& BEGIN { \& @ISA = qw( OnePackage OtherPackage ); \& $VERSION = \*(Aq0.01\*(Aq; \& \& # Put Perl code used in the BOOT: section here \& \& XSLoader::load(_\|_PACKAGE_\|_, $VERSION); \& } \& \& # Put Perl code making calls into XSUBs here .Ve .SS "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 is more complicated than this (e.g., the \f(CW\*(C`BOOT:\*(C'\fR section makes calls to Perl functions which make calls to XSUBs with prototypes), get rid of the \f(CW\*(C`BOOT:\*(C'\fR section altogether. Replace it with a function \f(CW\*(C`onBOOT()\*(C'\fR, and call it like this: .PP .Vb 3 \& package YourPackage; \& use XSLoader; \& our ($VERSION, @ISA); \& \& BEGIN { \& @ISA = qw( OnePackage OtherPackage ); \& $VERSION = \*(Aq0.01\*(Aq; \& XSLoader::load(_\|_PACKAGE_\|_, $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 the extension module was correctly loaded and initialised. The list of undefined symbols follows. .SH "LIMITATIONS" .IX Header "LIMITATIONS" To reduce the overhead as much as possible, only one possible location is checked to find the extension \s-1DLL\s0 (this location is where \f(CW\*(C`make install\*(C'\fR would put the \s-1DLL\s0). If not found, the search for the \s-1DLL\s0 is transparently delegated to \f(CW\*(C`DynaLoader\*(C'\fR, which looks for the \s-1DLL\s0 along the \f(CW@INC\fR list. .PP In particular, this is applicable to the structure of \f(CW@INC\fR used for testing not-yet-installed extensions. This means that running uninstalled extensions may have much more overhead than running the same extensions after \&\f(CW\*(C`make install\*(C'\fR. .SH "KNOWN BUGS" .IX Header "KNOWN BUGS" The new simpler way to call \f(CW\*(C`XSLoader::load()\*(C'\fR with no arguments at all does not work on Perl 5.8.4 and 5.8.5. .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests via the \fBperlbug\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>. .PP Previous maintainer was Michael G Schwern <schwern@pobox.com>. .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright (C) 1990\-2011 by Larry Wall and others. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.