Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / man / man3 / XSLoader.3
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\"
.\" 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. | will give a
.\" real vertical bar. \*(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-|\(bv\*(Tr
.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\}
.\"
.\" 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.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" 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 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide"
.SH "NAME"
XSLoader \- Dynamically load C libraries into Perl code
.SH "VERSION"
.IX Header "VERSION"
Version 0.06
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\& package YourPackage;
\& use XSLoader;
.Ve
.PP
.Vb 1
\& XSLoader::load 'YourPackage', $YourPackage::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 .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;
.Ve
.PP
.Vb 3
\& our @ISA = qw( OnePackage OtherPackage DynaLoader );
\& our $VERSION = '0.01';
\& bootstrap YourPackage $VERSION;
.Ve
.PP
Change this to
.PP
.Vb 2
\& package YourPackage;
\& use XSLoader;
.Ve
.PP
.Vb 3
\& our @ISA = qw( OnePackage OtherPackage );
\& our $VERSION = '0.01';
\& XSLoader::load 'YourPackage', $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 'YourPackage';
.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 complicated
boilerplate.
.PP
.Vb 2
\& package YourPackage;
\& use vars qw($VERSION @ISA);
.Ve
.PP
.Vb 11
\& @ISA = qw( OnePackage OtherPackage );
\& $VERSION = '0.01';
\& eval {
\& require XSLoader;
\& XSLoader::load('YourPackage', $VERSION);
\& 1;
\& } or do {
\& require DynaLoader;
\& push @ISA, 'DynaLoader';
\& bootstrap YourPackage $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 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 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) has three side effects:
.IP "\(bu" 4
if \f(CW$VERSION\fR was specified, a sanity check is done to ensure that the
versions of the \fI.pm\fR and the (compiled) \fI.xs\fR parts are compatible;
.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;
\& use vars qw($VERSION @ISA);
.Ve
.PP
.Vb 3
\& BEGIN {
\& @ISA = qw( OnePackage OtherPackage );
\& $VERSION = '0.01';
.Ve
.PP
.Vb 1
\& # Put Perl code used in the BOOT: section here
.Ve
.PP
.Vb 2
\& XSLoader::load 'YourPackage', $VERSION;
\& }
.Ve
.PP
.Vb 1
\& # 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 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;
\& use vars qw($VERSION @ISA);
.Ve
.PP
.Vb 5
\& BEGIN {
\& @ISA = qw( OnePackage OtherPackage );
\& $VERSION = '0.01';
\& XSLoader::load 'YourPackage', $VERSION;
\& }
.Ve
.PP
.Vb 2
\& # Put Perl code used in onBOOT() function here; calls to XSUBs are
\& # prototype-checked.
.Ve
.PP
.Vb 1
\& onBOOT;
.Ve
.PP
.Vb 1
\& # Put Perl initialization code assuming that XS is initialized here
.Ve
.SH "DIAGNOSTICS"
.IX Header "DIAGNOSTICS"
.ie n .IP "Can't find '%s' symbol in %s" 4
.el .IP "Can't find '%s' symbol in \f(CW%s\fR" 4
.IX Item "Can't find '%s' symbol in %s"
\&\fB(F)\fR The bootstrap symbol could not be found in the extension module.
.ie n .IP "Can't load '%s' for module %s:\fR \f(CW%s" 4
.el .IP "Can't load '%s' for module \f(CW%s:\fR \f(CW%s\fR" 4
.IX Item "Can't 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:\fR \f(CW%s" 4
.el .IP "Undefined symbols present after loading \f(CW%s:\fR \f(CW%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.
.ie n .IP "XSLoader::load('Your::Module', $Your::Module::VERSION)" 4
.el .IP "XSLoader::load('Your::Module', \f(CW$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 supply
a module name, and optionally its version.
.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 "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>
.PP
Previous maintainer was Michael G Schwern <schwern@pobox.com>
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.