perl 5.0 alpha 9
[p5sagit/p5-mst-13.2.git] / ext / dl / dl_hpux.c
CommitLineData
85e6fe83 1/*
2Date: Mon, 25 Apr 94 14:15:30 PDT
3From: Jeff Okamoto <okamoto@hpcc101.corp.hp.com>
4To: doughera@lafcol.lafayette.edu
5Cc: okamoto@hpcc101.corp.hp.com, Jarkko.Hietaniemi@hut.fi, ram@acri.fr,
6 john@WPI.EDU, k@franz.ww.TU-Berlin.DE, dmm0t@rincewind.mech.virginia.edu,
7 lwall@netlabs.com
8Subject: dl.c.hpux
9
10This is what I hacked around and came up with for HP-UX. (Or maybe it should
11be called dl_hpux.c). Notice the change in suffix from .so to .sl (the
12default suffix for HP-UX shared libraries).
13
14Jeff
15*/
16#include <dl.h>
17
18#include "EXTERN.h"
19#include "perl.h"
20#include "XSUB.h"
21
22static int
23XS_DynamicLoader_bootstrap(ix, ax, items)
24register int ix;
25register int ax;
26register int items;
27{
28 if (items < 1 || items > 1) {
29 croak("Usage: DynamicLoader::bootstrap(package)");
30 }
31 {
32 char* package = SvPV(ST(1),na);
33 shl_t obj = NULL;
34 int (*bootproc)();
35 char tmpbuf[1024];
36 char tmpbuf2[128];
37 AV *av = GvAVn(incgv);
38 I32 i;
39
40 for (i = 0; i <= AvFILL(av); i++) {
41 (void)sprintf(tmpbuf, "%s/auto/%s/%s.sl",
42 SvPVx(*av_fetch(av, i, TRUE), na), package, package);
43 if (obj = shl_load(tmpbuf,
44 BIND_IMMEDIATE | BIND_NONFATAL | BIND_NOSTART,0L))
45 break;
46 }
47 if (obj != (shl_t) NULL)
48 croak("Can't find loadable object for package %s in @INC", package);
49
50 sprintf(tmpbuf2, "boot_%s", package);
51 i = shl_findsym(&obj, tmpbuf2, TYPE_PROCEDURE, &bootproc);
52 if (i == -1)
53 croak("Shared object %s contains no %s function", tmpbuf, tmpbuf2);
54 bootproc();
55
56 ST(0) = sv_mortalcopy(&sv_yes);
57 }
58 return ax;
59}
60
61int
62boot_DynamicLoader(ix,sp,items)
63int ix;
64int sp;
65int items;
66{
67 char* file = __FILE__;
68
69 newXSUB("DynamicLoader::bootstrap", 0, XS_DynamicLoader_bootstrap, file);
70}
71