2 * Author: Jeff Okamoto (okamoto@corp.hp.com)
3 * Version: 2.1, 1995/1/25
6 /* o Added BIND_VERBOSE to dl_nonlazy condition to add names of missing
7 * symbols to stderr message on fatal error.
9 * o Added BIND_NONFATAL comment to default condition.
11 * Chuck Phillips (cdp@fc.hp.com)
12 * Version: 2.2, 1997/5/4 */
15 #define magic hpux_magic
16 #define MAGIC HPUX_MAGIC
27 #define PERL_IN_DL_HPUX_XS
33 } my_cxtx_t; /* this *must* be named my_cxtx_t */
35 #define DL_CXT_EXTRA /* ask for dl_cxtx to be defined in dlutils.c */
36 #include "dlutils.c" /* for SaveError() etc */
38 #define dl_resolve_using (dl_cxtx.x_resolve_using)
43 (void)dl_generic_private_init(aTHX);
46 dl_resolve_using = get_av("DynaLoader::dl_resolve_using", GV_ADDMULTI);
50 MODULE = DynaLoader PACKAGE = DynaLoader
53 (void)dl_private_init(aTHX);
57 dl_load_file(filename, flags=0)
62 int i, max, bind_type;
65 DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s,%x):\n", filename,flags));
67 Perl_warn(aTHX_ "Can't make loaded symbols global on this platform while loading %s",filename);
69 bind_type = BIND_IMMEDIATE|BIND_VERBOSE;
71 bind_type = BIND_DEFERRED;
72 /* For certain libraries, like DCE, deferred binding often causes run
73 * time problems. Adding BIND_NONFATAL to BIND_IMMEDIATE still allows
74 * unresolved references in situations like this. */
75 /* bind_type = BIND_IMMEDIATE|BIND_NONFATAL; */
77 /* BIND_NOSTART removed from bind_type because it causes the shared library's */
78 /* initialisers not to be run. This causes problems with all of the static objects */
82 bind_type |= BIND_VERBOSE;
83 #endif /* DEBUGGING */
85 max = AvFILL(dl_resolve_using);
86 for (i = 0; i <= max; i++) {
87 char *sym = SvPVX(*av_fetch(dl_resolve_using, i, 0));
88 DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s) (dependent)\n", sym));
89 obj = shl_load(sym, bind_type, 0L);
95 DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s): ", filename));
96 obj = shl_load(filename, bind_type, 0L);
98 DLDEBUG(2,PerlIO_printf(Perl_debug_log, " libref=%p\n", (void*)obj));
100 ST(0) = sv_newmortal() ;
102 SaveError(aTHX_ "%s",Strerror(errno));
104 sv_setiv( ST(0), PTR2IV(obj) );
108 dl_unload_file(libref)
111 DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_unload_file(%lx):\n", PTR2ul(libref)));
112 RETVAL = (shl_unload((shl_t)libref) == 0 ? 1 : 0);
114 SaveError(aTHX_ "%s", Strerror(errno));
115 DLDEBUG(2,PerlIO_printf(Perl_debug_log, " retval = %d\n", RETVAL));
121 dl_find_symbol(libhandle, symbolname, ign_err=0)
126 shl_t obj = (shl_t) libhandle;
127 void *symaddr = NULL;
131 symbolname = Perl_form_nocontext("_%s", symbolname);
133 DLDEBUG(2, PerlIO_printf(Perl_debug_log,
134 "dl_find_symbol(handle=%lx, symbol=%s)\n",
135 (unsigned long) libhandle, symbolname));
137 ST(0) = sv_newmortal() ;
140 status = shl_findsym(&obj, symbolname, TYPE_PROCEDURE, &symaddr);
141 DLDEBUG(2,PerlIO_printf(Perl_debug_log, " symbolref(PROCEDURE) = %p\n", (void*)symaddr));
143 if (status == -1 && errno == 0) { /* try TYPE_DATA instead */
144 status = shl_findsym(&obj, symbolname, TYPE_DATA, &symaddr);
145 DLDEBUG(2,PerlIO_printf(Perl_debug_log, " symbolref(DATA) = %p\n", (void*)symaddr));
149 if (!ign_err) SaveError(aTHX_ "%s",(errno) ? Strerror(errno) : "Symbol not found") ;
151 sv_setiv( ST(0), PTR2IV(symaddr) );
161 # These functions should not need changing on any platform:
164 dl_install_xsub(perl_name, symref, filename="$Package")
167 const char * filename
169 DLDEBUG(2,PerlIO_printf(Perl_debug_log, "dl_install_xsub(name=%s, symref=%p)\n",
170 perl_name, (void*)symref));
171 ST(0) = sv_2mortal(newRV((SV*)newXS_flags(perl_name,
172 (void(*)(pTHX_ CV *))symref,
174 XS_DYNAMIC_FILENAME)));
180 RETVAL = newSVsv(MY_CXT.x_dl_last_error);
184 #if defined(USE_ITHREADS)
191 PERL_UNUSED_VAR(items);
193 /* MY_CXT_CLONE just does a memcpy on the whole structure, so to avoid
194 * using Perl variables that belong to another thread, we create our
195 * own for this thread.
197 MY_CXT.x_dl_last_error = newSVpvs("");
198 dl_resolve_using = get_av("DynaLoader::dl_resolve_using", GV_ADDMULTI);