Commit | Line | Data |
85e6fe83 |
1 | /* |
2 | Date: Mon, 25 Apr 94 14:15:30 PDT |
3 | From: Jeff Okamoto <okamoto@hpcc101.corp.hp.com> |
4 | To: doughera@lafcol.lafayette.edu |
5 | Cc: 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 |
8 | Subject: dl.c.hpux |
9 | |
10 | This is what I hacked around and came up with for HP-UX. (Or maybe it should |
11 | be called dl_hpux.c). Notice the change in suffix from .so to .sl (the |
12 | default suffix for HP-UX shared libraries). |
13 | |
14 | Jeff |
15 | */ |
16 | #include <dl.h> |
17 | |
18 | #include "EXTERN.h" |
19 | #include "perl.h" |
20 | #include "XSUB.h" |
21 | |
22 | static int |
23 | XS_DynamicLoader_bootstrap(ix, ax, items) |
24 | register int ix; |
25 | register int ax; |
26 | register 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 | |
61 | int |
62 | boot_DynamicLoader(ix,sp,items) |
63 | int ix; |
64 | int sp; |
65 | int items; |
66 | { |
67 | char* file = __FILE__; |
68 | |
69 | newXSUB("DynamicLoader::bootstrap", 0, XS_DynamicLoader_bootstrap, file); |
70 | } |
71 | |