home *** CD-ROM | disk | FTP | other *** search
/ Chip: Windows 2000 Professional Resource Kit / W2KPRK.iso / apps / perl / ActivePerl.exe / data.z / DynaLoader.pm < prev    next >
Encoding:
Perl POD Document  |  1999-10-16  |  23.8 KB  |  697 lines

  1.  
  2. # Generated from DynaLoader.pm.PL (resolved %Config::Config values)
  3.  
  4. package DynaLoader;
  5.  
  6. #   And Gandalf said: 'Many folk like to know beforehand what is to
  7. #   be set on the table; but those who have laboured to prepare the
  8. #   feast like to keep their secret; for wonder makes the words of
  9. #   praise louder.'
  10.  
  11. #   (Quote from Tolkien sugested by Anno Siegel.)
  12. #
  13. # See pod text at end of file for documentation.
  14. # See also ext/DynaLoader/README in source tree for other information.
  15. #
  16. # Tim.Bunce@ig.co.uk, August 1994
  17.  
  18. $VERSION = $VERSION = "1.03";    # avoid typo warning
  19.  
  20. require AutoLoader;
  21. *AUTOLOAD = \&AutoLoader::AUTOLOAD;
  22.  
  23. # The following require can't be removed during maintenance
  24. # releases, sadly, because of the risk of buggy code that does 
  25. # require Carp; Carp::croak "..."; without brackets dying 
  26. # if Carp hasn't been loaded in earlier compile time. :-( 
  27. # We'll let those bugs get found on the development track.
  28. require Carp if $] < 5.00450; 
  29.  
  30.  
  31. # enable debug/trace messages from DynaLoader perl code
  32. $dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug;
  33.  
  34. #
  35. # Flags to alter dl_load_file behaviour.  Assigned bits:
  36. #   0x01  make symbols available for linking later dl_load_file's.
  37. #         (only known to work on Solaris 2 using dlopen(RTLD_GLOBAL))
  38. #         (ignored under VMS; effect is built-in to image linking)
  39. #
  40. # This is called as a class method $module->dl_load_flags.  The
  41. # definition here will be inherited and result on "default" loading
  42. # behaviour unless a sub-class of DynaLoader defines its own version.
  43. #
  44.  
  45. sub dl_load_flags { 0x00 }
  46.  
  47. # ($dl_dlext, $dlsrc)
  48. #         = @Config::Config{'dlext', 'dlsrc'};
  49.   ($dl_dlext, $dlsrc) = ('dll','dl_win32.xs')
  50. ;
  51. # Some systems need special handling to expand file specifications
  52. # (VMS support by Charles Bailey <bailey@HMIVAX.HUMGEN.UPENN.EDU>)
  53. # See dl_expandspec() for more details. Should be harmless but
  54. # inefficient to define on systems that don't need it.
  55. $do_expand = $Is_VMS = $^O eq 'VMS';
  56.  
  57. @dl_require_symbols = ();       # names of symbols we need
  58. @dl_resolve_using   = ();       # names of files to link with
  59. @dl_library_path    = ();       # path to look for files
  60. @dl_librefs         = ();       # things we have loaded
  61. @dl_modules         = ();       # Modules we have loaded
  62.  
  63. # This is a fix to support DLD's unfortunate desire to relink -lc
  64. @dl_resolve_using = dl_findfile('-lc') if $dlsrc eq "dl_dld.xs";
  65.  
  66. # Initialise @dl_library_path with the 'standard' library path
  67. # for this platform as determined by Configure
  68.  
  69. # push(@dl_library_path, split(' ', $Config::Config{'libpth'});
  70. push(@dl_library_path, split(' ', '"C:\\\'Program Files\\\'DevStudio\\\'VC\\\'lib"'));
  71.  
  72. # Add to @dl_library_path any extra directories we can gather from
  73. # environment variables. So far LD_LIBRARY_PATH is the only known
  74. # variable used for this purpose. Others may be added later.
  75. push(@dl_library_path, split(/:/, $ENV{LD_LIBRARY_PATH}))
  76.     if $ENV{LD_LIBRARY_PATH};
  77.  
  78.  
  79. # No prizes for guessing why we don't say 'bootstrap DynaLoader;' here.
  80. boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) &&
  81.                                 !defined(&dl_load_file);
  82.  
  83.  
  84. if ($dl_debug) {
  85.     print STDERR "DynaLoader.pm loaded (@INC, @dl_library_path)\n";
  86.     print STDERR "DynaLoader not linked into this perl\n"
  87.         unless defined(&boot_DynaLoader);
  88. }
  89.  
  90. 1; # End of main code
  91.  
  92.  
  93. sub croak   { require Carp; Carp::croak(@_)   }
  94.  
  95. # The bootstrap function cannot be autoloaded (without complications)
  96. # so we define it here:
  97.  
  98. sub bootstrap {
  99.     # use local vars to enable $module.bs script to edit values
  100.     local(@args) = @_;
  101.     local($module) = $args[0];
  102.     local(@dirs, $file);
  103.  
  104.     unless ($module) {
  105.     require Carp;
  106.     Carp::confess("Usage: DynaLoader::bootstrap(module)");
  107.     }
  108.  
  109.     # A common error on platforms which don't support dynamic loading.
  110.     # Since it's fatal and potentially confusing we give a detailed message.
  111.     croak("Can't load module $module, dynamic loading not available in this perl.\n".
  112.     "  (You may need to build a new perl executable which either supports\n".
  113.     "  dynamic loading or has the $module module statically linked into it.)\n")
  114.     unless defined(&dl_load_file);
  115.  
  116.     my @modparts = split(/::/,$module);
  117.     my $modfname = $modparts[-1];
  118.  
  119.     # Some systems have restrictions on files names for DLL's etc.
  120.     # mod2fname returns appropriate file base name (typically truncated)
  121.     # It may also edit @modparts if required.
  122.     $modfname = &mod2fname(\@modparts) if defined &mod2fname;
  123.  
  124.     my $modpname = join('/',@modparts);
  125.  
  126.     print STDERR "DynaLoader::bootstrap for $module ",
  127.         "(auto/$modpname/$modfname.$dl_dlext)\n" if $dl_debug;
  128.  
  129.     foreach (@INC) {
  130.     chop($_ = VMS::Filespec::unixpath($_)) if $Is_VMS;
  131.     my $dir = "$_/auto/$modpname";
  132.     next unless -d $dir; # skip over uninteresting directories
  133.  
  134.     # check for common cases to avoid autoload of dl_findfile
  135.     my $try = "$dir/$modfname.$dl_dlext";
  136.     last if $file = ($do_expand) ? dl_expandspec($try) : (-f $try && $try);
  137.  
  138.     # no luck here, save dir for possible later dl_findfile search
  139.     push @dirs, $dir;
  140.     }
  141.     # last resort, let dl_findfile have a go in all known locations
  142.     $file = dl_findfile(map("-L$_",@dirs,@INC), $modfname) unless $file;
  143.  
  144.     croak("Can't locate loadable object for module $module in \@INC (\@INC contains: @INC)")
  145.     unless $file;    # wording similar to error from 'require'
  146.  
  147.     my $bootname = "boot_$module";
  148.     $bootname =~ s/\W/_/g;
  149.     @dl_require_symbols = ($bootname);
  150.  
  151.     # Execute optional '.bootstrap' perl script for this module.
  152.     # The .bs file can be used to configure @dl_resolve_using etc to
  153.     # match the needs of the individual module on this architecture.
  154.     my $bs = $file;
  155.     $bs =~ s/(\.\w+)?$/\.bs/; # look for .bs 'beside' the library
  156.     if (-s $bs) { # only read file if it's not empty
  157.         print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug;
  158.         eval { do $bs; };
  159.         warn "$bs: $@\n" if $@;
  160.     }
  161.  
  162.     # Many dynamic extension loading problems will appear to come from
  163.     # this section of code: XYZ failed at line 123 of DynaLoader.pm.
  164.     # Often these errors are actually occurring in the initialisation
  165.     # C code of the extension XS file. Perl reports the error as being
  166.     # in this perl code simply because this was the last perl code
  167.     # it executed.
  168.  
  169.     my $libref = dl_load_file($file, $module->dl_load_flags) or
  170.     croak("Can't load '$file' for module $module: ".dl_error()."\n");
  171.  
  172.     push(@dl_librefs,$libref);  # record loaded object
  173.  
  174.     my @unresolved = dl_undef_symbols();
  175.     if (@unresolved) {
  176.     require Carp;
  177.     Carp::carp("Undefined symbols present after loading $file: @unresolved\n");
  178.     }
  179.  
  180.     my $boot_symbol_ref = dl_find_symbol($libref, $bootname) or
  181.          croak("Can't find '$bootname' symbol in $file\n");
  182.  
  183.     my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file);
  184.  
  185.     push(@dl_modules, $module); # record loaded module
  186.  
  187.     # See comment block above
  188.     &$xs(@args);
  189. }
  190.  
  191.  
  192. #sub _check_file {   # private utility to handle dl_expandspec vs -f tests
  193. #    my($file) = @_;
  194. #    return $file if (!$do_expand && -f $file); # the common case
  195. #    return $file if ( $do_expand && ($file=dl_expandspec($file)));
  196. #    return undef;
  197. #}
  198.  
  199.  
  200. # Let autosplit and the autoloader deal with these functions:
  201. __END__
  202.  
  203.  
  204. sub dl_findfile {
  205.     # Read ext/DynaLoader/DynaLoader.doc for detailed information.
  206.     # This function does not automatically consider the architecture
  207.     # or the perl library auto directories.
  208.     my (@args) = @_;
  209.     my (@dirs,  $dir);   # which directories to search
  210.     my (@found);         # full paths to real files we have found
  211.     my $dl_ext= 'dll'; # $Config::Config{'dlext'} suffix for perl extensions
  212.     my $dl_so = 'dll'; # $Config::Config{'so'} suffix for shared libraries
  213.  
  214.     print STDERR "dl_findfile(@args)\n" if $dl_debug;
  215.  
  216.     # accumulate directories but process files as they appear
  217.     arg: foreach(@args) {
  218.         #  Special fast case: full filepath requires no search
  219.         if ($Is_VMS && m%[:>/\]]% && -f $_) {
  220.         push(@found,dl_expandspec(VMS::Filespec::vmsify($_)));
  221.         last arg unless wantarray;
  222.         next;
  223.         }
  224.         elsif (m:/: && -f $_ && !$do_expand) {
  225.         push(@found,$_);
  226.         last arg unless wantarray;
  227.         next;
  228.     }
  229.  
  230.         # Deal with directories first:
  231.         #  Using a -L prefix is the preferred option (faster and more robust)
  232.         if (m:^-L:) { s/^-L//; push(@dirs, $_); next; }
  233.  
  234.         #  Otherwise we try to try to spot directories by a heuristic
  235.         #  (this is a more complicated issue than it first appears)
  236.         if (m:/: && -d $_) {   push(@dirs, $_); next; }
  237.  
  238.         # VMS: we may be using native VMS directry syntax instead of
  239.         # Unix emulation, so check this as well
  240.         if ($Is_VMS && /[:>\]]/ && -d $_) {   push(@dirs, $_); next; }
  241.  
  242.         #  Only files should get this far...
  243.         my(@names, $name);    # what filenames to look for
  244.         if (m:-l: ) {          # convert -lname to appropriate library name
  245.             s/-l//;
  246.             push(@names,"lib$_.$dl_so");
  247.             push(@names,"lib$_.a");
  248.         } else {                # Umm, a bare name. Try various alternatives:
  249.             # these should be ordered with the most likely first
  250.             push(@names,"$_.$dl_ext")    unless m/\.$dl_ext$/o;
  251.             push(@names,"$_.$dl_so")     unless m/\.$dl_so$/o;
  252.             push(@names,"lib$_.$dl_so")  unless m:/:;
  253.             push(@names,"$_.a")          if !m/\.a$/ and $dlsrc eq "dl_dld.xs";
  254.             push(@names, $_);
  255.         }
  256.         foreach $dir (@dirs, @dl_library_path) {
  257.             next unless -d $dir;
  258.             chop($dir = VMS::Filespec::unixpath($dir)) if $Is_VMS;
  259.             foreach $name (@names) {
  260.         my($file) = "$dir/$name";
  261.                 print STDERR " checking in $dir for $name\n" if $dl_debug;
  262.         $file = ($do_expand) ? dl_expandspec($file) : (-f $file && $file);
  263.         #$file = _check_file($file);
  264.         if ($file) {
  265.                     push(@found, $file);
  266.                     next arg; # no need to look any further
  267.                 }
  268.             }
  269.         }
  270.     }
  271.     if ($dl_debug) {
  272.         foreach(@dirs) {
  273.             print STDERR " dl_findfile ignored non-existent directory: $_\n" unless -d $_;
  274.         }
  275.         print STDERR "dl_findfile found: @found\n";
  276.     }
  277.     return $found[0] unless wantarray;
  278.     @found;
  279. }
  280.  
  281.  
  282. sub dl_expandspec {
  283.     my($spec) = @_;
  284.     # Optional function invoked if DynaLoader.pm sets $do_expand.
  285.     # Most systems do not require or use this function.
  286.     # Some systems may implement it in the dl_*.xs file in which case
  287.     # this autoload version will not be called but is harmless.
  288.  
  289.     # This function is designed to deal with systems which treat some
  290.     # 'filenames' in a special way. For example VMS 'Logical Names'
  291.     # (something like unix environment variables - but different).
  292.     # This function should recognise such names and expand them into
  293.     # full file paths.
  294.     # Must return undef if $spec is invalid or file does not exist.
  295.  
  296.     my $file = $spec; # default output to input
  297.  
  298.     if ($Is_VMS) { # dl_expandspec should be defined in dl_vms.xs
  299.     require Carp;
  300.     Carp::croak("dl_expandspec: should be defined in XS file!\n");
  301.     } else {
  302.     return undef unless -f $file;
  303.     }
  304.     print STDERR "dl_expandspec($spec) => $file\n" if $dl_debug;
  305.     $file;
  306. }
  307.  
  308. sub dl_find_symbol_anywhere
  309. {
  310.     my $sym = shift;
  311.     my $libref;
  312.     foreach $libref (@dl_librefs) {
  313.     my $symref = dl_find_symbol($libref,$sym);
  314.     return $symref if $symref;
  315.     }
  316.     return undef;
  317. }
  318.  
  319. =head1 NAME
  320.  
  321. DynaLoader - Dynamically load C libraries into Perl code
  322.  
  323. dl_error(), dl_findfile(), dl_expandspec(), dl_load_file(), dl_find_symbol(), dl_find_symbol_anywhere(), dl_undef_symbols(), dl_install_xsub(), dl_load_flags(), bootstrap() - routines used by DynaLoader modules
  324.  
  325. =head1 SYNOPSIS
  326.  
  327.     package YourPackage;
  328.     require DynaLoader;
  329.     @ISA = qw(... DynaLoader ...);
  330.     bootstrap YourPackage;
  331.  
  332.     # optional method for 'global' loading
  333.     sub dl_load_flags { 0x01 }     
  334.  
  335.  
  336. =head1 DESCRIPTION
  337.  
  338. This document defines a standard generic interface to the dynamic
  339. linking mechanisms available on many platforms.  Its primary purpose is
  340. to implement automatic dynamic loading of Perl modules.
  341.  
  342. This document serves as both a specification for anyone wishing to
  343. implement the DynaLoader for a new platform and as a guide for
  344. anyone wishing to use the DynaLoader directly in an application.
  345.  
  346. The DynaLoader is designed to be a very simple high-level
  347. interface that is sufficiently general to cover the requirements
  348. of SunOS, HP-UX, NeXT, Linux, VMS and other platforms.
  349.  
  350. It is also hoped that the interface will cover the needs of OS/2, NT
  351. etc and also allow pseudo-dynamic linking (using C<ld -A> at runtime).
  352.  
  353. It must be stressed that the DynaLoader, by itself, is practically
  354. useless for accessing non-Perl libraries because it provides almost no
  355. Perl-to-C 'glue'.  There is, for example, no mechanism for calling a C
  356. library function or supplying arguments.  A C::DynaLib module
  357. is available from CPAN sites which performs that function for some
  358. common system types.
  359.  
  360. DynaLoader Interface Summary
  361.  
  362.   @dl_library_path
  363.   @dl_resolve_using
  364.   @dl_require_symbols
  365.   $dl_debug
  366.   @dl_librefs
  367.   @dl_modules
  368.                                                   Implemented in:
  369.   bootstrap($modulename)                               Perl
  370.   @filepaths = dl_findfile(@names)                     Perl
  371.   $flags = $modulename->dl_load_flags                  Perl
  372.   $symref  = dl_find_symbol_anywhere($symbol)          Perl
  373.  
  374.   $libref  = dl_load_file($filename, $flags)           C
  375.   $symref  = dl_find_symbol($libref, $symbol)          C
  376.   @symbols = dl_undef_symbols()                        C
  377.   dl_install_xsub($name, $symref [, $filename])        C
  378.   $message = dl_error                                  C
  379.  
  380. =over 4
  381.  
  382. =item @dl_library_path
  383.  
  384. The standard/default list of directories in which dl_findfile() will
  385. search for libraries etc.  Directories are searched in order:
  386. $dl_library_path[0], [1], ... etc
  387.  
  388. @dl_library_path is initialised to hold the list of 'normal' directories
  389. (F</usr/lib>, etc) determined by B<Configure> (C<$Config{'libpth'}>).  This should
  390. ensure portability across a wide range of platforms.
  391.  
  392. @dl_library_path should also be initialised with any other directories
  393. that can be determined from the environment at runtime (such as
  394. LD_LIBRARY_PATH for SunOS).
  395.  
  396. After initialisation @dl_library_path can be manipulated by an
  397. application using push and unshift before calling dl_findfile().
  398. Unshift can be used to add directories to the front of the search order
  399. either to save search time or to override libraries with the same name
  400. in the 'normal' directories.
  401.  
  402. The load function that dl_load_file() calls may require an absolute
  403. pathname.  The dl_findfile() function and @dl_library_path can be
  404. used to search for and return the absolute pathname for the
  405. library/object that you wish to load.
  406.  
  407. =item @dl_resolve_using
  408.  
  409. A list of additional libraries or other shared objects which can be
  410. used to resolve any undefined symbols that might be generated by a
  411. later call to load_file().
  412.  
  413. This is only required on some platforms which do not handle dependent
  414. libraries automatically.  For example the Socket Perl extension
  415. library (F<auto/Socket/Socket.so>) contains references to many socket
  416. functions which need to be resolved when it's loaded.  Most platforms
  417. will automatically know where to find the 'dependent' library (e.g.,
  418. F</usr/lib/libsocket.so>).  A few platforms need to be told the
  419. location of the dependent library explicitly.  Use @dl_resolve_using
  420. for this.
  421.  
  422. Example usage:
  423.  
  424.     @dl_resolve_using = dl_findfile('-lsocket');
  425.  
  426. =item @dl_require_symbols
  427.  
  428. A list of one or more symbol names that are in the library/object file
  429. to be dynamically loaded.  This is only required on some platforms.
  430.  
  431. =item @dl_librefs
  432.  
  433. An array of the handles returned by successful calls to dl_load_file(),
  434. made by bootstrap, in the order in which they were loaded.
  435. Can be used with dl_find_symbol() to look for a symbol in any of
  436. the loaded files.
  437.  
  438. =item @dl_modules
  439.  
  440. An array of module (package) names that have been bootstrap'ed.
  441.  
  442. =item dl_error()
  443.  
  444. Syntax:
  445.  
  446.     $message = dl_error();
  447.  
  448. Error message text from the last failed DynaLoader function.  Note
  449. that, similar to errno in unix, a successful function call does not
  450. reset this message.
  451.  
  452. Implementations should detect the error as soon as it occurs in any of
  453. the other functions and save the corresponding message for later
  454. retrieval.  This will avoid problems on some platforms (such as SunOS)
  455. where the error message is very temporary (e.g., dlerror()).
  456.  
  457. =item $dl_debug
  458.  
  459. Internal debugging messages are enabled when $dl_debug is set true.
  460. Currently setting $dl_debug only affects the Perl side of the
  461. DynaLoader.  These messages should help an application developer to
  462. resolve any DynaLoader usage problems.
  463.  
  464. $dl_debug is set to C<$ENV{'PERL_DL_DEBUG'}> if defined.
  465.  
  466. For the DynaLoader developer/porter there is a similar debugging
  467. variable added to the C code (see dlutils.c) and enabled if Perl was
  468. built with the B<-DDEBUGGING> flag.  This can also be set via the
  469. PERL_DL_DEBUG environment variable.  Set to 1 for minimal information or
  470. higher for more.
  471.  
  472. =item dl_findfile()
  473.  
  474. Syntax:
  475.  
  476.     @filepaths = dl_findfile(@names)
  477.  
  478. Determine the full paths (including file suffix) of one or more
  479. loadable files given their generic names and optionally one or more
  480. directories.  Searches directories in @dl_library_path by default and
  481. returns an empty list if no files were found.
  482.  
  483. Names can be specified in a variety of platform independent forms.  Any
  484. names in the form B<-lname> are converted into F<libname.*>, where F<.*> is
  485. an appropriate suffix for the platform.
  486.  
  487. If a name does not already have a suitable prefix and/or suffix then
  488. the corresponding file will be searched for by trying combinations of
  489. prefix and suffix appropriate to the platform: "$name.o", "lib$name.*"
  490. and "$name".
  491.  
  492. If any directories are included in @names they are searched before
  493. @dl_library_path.  Directories may be specified as B<-Ldir>.  Any other
  494. names are treated as filenames to be searched for.
  495.  
  496. Using arguments of the form C<-Ldir> and C<-lname> is recommended.
  497.  
  498. Example: 
  499.  
  500.     @dl_resolve_using = dl_findfile(qw(-L/usr/5lib -lposix));
  501.  
  502.  
  503. =item dl_expandspec()
  504.  
  505. Syntax:
  506.  
  507.     $filepath = dl_expandspec($spec)
  508.  
  509. Some unusual systems, such as VMS, require special filename handling in
  510. order to deal with symbolic names for files (i.e., VMS's Logical Names).
  511.  
  512. To support these systems a dl_expandspec() function can be implemented
  513. either in the F<dl_*.xs> file or code can be added to the autoloadable
  514. dl_expandspec() function in F<DynaLoader.pm>.  See F<DynaLoader.pm> for
  515. more information.
  516.  
  517. =item dl_load_file()
  518.  
  519. Syntax:
  520.  
  521.     $libref = dl_load_file($filename, $flags)
  522.  
  523. Dynamically load $filename, which must be the path to a shared object
  524. or library.  An opaque 'library reference' is returned as a handle for
  525. the loaded object.  Returns undef on error.
  526.  
  527. The $flags argument to alters dl_load_file behaviour.  
  528. Assigned bits:
  529.  
  530.  0x01  make symbols available for linking later dl_load_file's.
  531.        (only known to work on Solaris 2 using dlopen(RTLD_GLOBAL))
  532.        (ignored under VMS; this is a normal part of image linking)
  533.  
  534. (On systems that provide a handle for the loaded object such as SunOS
  535. and HPUX, $libref will be that handle.  On other systems $libref will
  536. typically be $filename or a pointer to a buffer containing $filename.
  537. The application should not examine or alter $libref in any way.)
  538.  
  539. This is the function that does the real work.  It should use the
  540. current values of @dl_require_symbols and @dl_resolve_using if required.
  541.  
  542.     SunOS: dlopen($filename)
  543.     HP-UX: shl_load($filename)
  544.     Linux: dld_create_reference(@dl_require_symbols); dld_link($filename)
  545.     NeXT:  rld_load($filename, @dl_resolve_using)
  546.     VMS:   lib$find_image_symbol($filename,$dl_require_symbols[0])
  547.  
  548. (The dlopen() function is also used by Solaris and some versions of
  549. Linux, and is a common choice when providing a "wrapper" on other
  550. mechanisms as is done in the OS/2 port.)
  551.  
  552. =item dl_loadflags()
  553.  
  554. Syntax:
  555.  
  556.     $flags = dl_loadflags $modulename;
  557.  
  558. Designed to be a method call, and to be overridden by a derived class
  559. (i.e. a class which has DynaLoader in its @ISA).  The definition in
  560. DynaLoader itself returns 0, which produces standard behavior from
  561. dl_load_file().
  562.  
  563. =item dl_find_symbol()
  564.  
  565. Syntax:
  566.  
  567.     $symref = dl_find_symbol($libref, $symbol)
  568.  
  569. Return the address of the symbol $symbol or C<undef> if not found.  If the
  570. target system has separate functions to search for symbols of different
  571. types then dl_find_symbol() should search for function symbols first and
  572. then other types.
  573.  
  574. The exact manner in which the address is returned in $symref is not
  575. currently defined.  The only initial requirement is that $symref can
  576. be passed to, and understood by, dl_install_xsub().
  577.  
  578.     SunOS: dlsym($libref, $symbol)
  579.     HP-UX: shl_findsym($libref, $symbol)
  580.     Linux: dld_get_func($symbol) and/or dld_get_symbol($symbol)
  581.     NeXT:  rld_lookup("_$symbol")
  582.     VMS:   lib$find_image_symbol($libref,$symbol)
  583.  
  584.  
  585. =item dl_find_symbol_anywhere()
  586.  
  587. Syntax:
  588.  
  589.     $symref = dl_find_symbol_anywhere($symbol)
  590.  
  591. Applies dl_find_symbol() to the members of @dl_librefs and returns
  592. the first match found.
  593.  
  594. =item dl_undef_symbols()
  595.  
  596. Example
  597.  
  598.     @symbols = dl_undef_symbols()
  599.  
  600. Return a list of symbol names which remain undefined after load_file().
  601. Returns C<()> if not known.  Don't worry if your platform does not provide
  602. a mechanism for this.  Most do not need it and hence do not provide it,
  603. they just return an empty list.
  604.  
  605.  
  606. =item dl_install_xsub()
  607.  
  608. Syntax:
  609.  
  610.     dl_install_xsub($perl_name, $symref [, $filename])
  611.  
  612. Create a new Perl external subroutine named $perl_name using $symref as
  613. a pointer to the function which implements the routine.  This is simply
  614. a direct call to newXSUB().  Returns a reference to the installed
  615. function.
  616.  
  617. The $filename parameter is used by Perl to identify the source file for
  618. the function if required by die(), caller() or the debugger.  If
  619. $filename is not defined then "DynaLoader" will be used.
  620.  
  621.  
  622. =item bootstrap()
  623.  
  624. Syntax:
  625.  
  626. bootstrap($module)
  627.  
  628. This is the normal entry point for automatic dynamic loading in Perl.
  629.  
  630. It performs the following actions:
  631.  
  632. =over 8
  633.  
  634. =item *
  635.  
  636. locates an auto/$module directory by searching @INC
  637.  
  638. =item *
  639.  
  640. uses dl_findfile() to determine the filename to load
  641.  
  642. =item *
  643.  
  644. sets @dl_require_symbols to C<("boot_$module")>
  645.  
  646. =item *
  647.  
  648. executes an F<auto/$module/$module.bs> file if it exists
  649. (typically used to add to @dl_resolve_using any files which
  650. are required to load the module on the current platform)
  651.  
  652. =item *
  653.  
  654. calls dl_load_flags() to determine how to load the file.
  655.  
  656. =item *
  657.  
  658. calls dl_load_file() to load the file
  659.  
  660. =item *
  661.  
  662. calls dl_undef_symbols() and warns if any symbols are undefined
  663.  
  664. =item *
  665.  
  666. calls dl_find_symbol() for "boot_$module"
  667.  
  668. =item *
  669.  
  670. calls dl_install_xsub() to install it as "${module}::bootstrap"
  671.  
  672. =item *
  673.  
  674. calls &{"${module}::bootstrap"} to bootstrap the module (actually
  675. it uses the function reference returned by dl_install_xsub for speed)
  676.  
  677. =back
  678.  
  679. =back
  680.  
  681.  
  682. =head1 AUTHOR
  683.  
  684. Tim Bunce, 11 August 1994.
  685.  
  686. This interface is based on the work and comments of (in no particular
  687. order): Larry Wall, Robert Sanders, Dean Roehrich, Jeff Okamoto, Anno
  688. Siegel, Thomas Neumann, Paul Marquess, Charles Bailey, myself and others.
  689.  
  690. Larry Wall designed the elegant inherited bootstrap mechanism and
  691. implemented the first Perl 5 dynamic loader using it.
  692.  
  693. Solaris global loading added by Nick Ing-Simmons with design/coding
  694. assistance from Tim Bunce, January 1996.
  695.  
  696. =cut
  697.