SaveError("%s",dlerror()) ;
Note that SaveError() takes a printf format string. Use a "%s" as
- the first parameter if the error may contain and % characters.
+ the first parameter if the error may contain any % characters.
*/
(void)dl_private_init(aTHX);
-void *
+void
dl_load_file(filename, flags=0)
char * filename
int flags
PREINIT:
int mode = RTLD_LAZY;
+ void *handle;
CODE:
{
#if defined(DLOPEN_WONT_DO_RELATIVE_PATHS)
}
#endif
#ifdef RTLD_NOW
- if (dl_nonlazy)
- mode = RTLD_NOW;
+ {
+ dMY_CXT;
+ if (dl_nonlazy)
+ mode = RTLD_NOW;
+ }
#endif
if (flags & 0x01)
#ifdef RTLD_GLOBAL
Perl_warn(aTHX_ "Can't make loaded symbols global on this platform while loading %s",filename);
#endif
DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s,%x):\n", filename,flags));
- RETVAL = dlopen(filename, mode) ;
- DLDEBUG(2,PerlIO_printf(Perl_debug_log, " libref=%lx\n", (unsigned long) RETVAL));
+ handle = dlopen(filename, mode) ;
+ DLDEBUG(2,PerlIO_printf(Perl_debug_log, " libref=%lx\n", (unsigned long) handle));
ST(0) = sv_newmortal() ;
- if (RETVAL == NULL)
+ if (handle == NULL)
SaveError(aTHX_ "%s",dlerror()) ;
else
- sv_setiv( ST(0), PTR2IV(RETVAL));
+ sv_setiv( ST(0), PTR2IV(handle));
}
dl_unload_file(libref)
void * libref
CODE:
- DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_unload_file(%lx):\n", libref));
+ DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_unload_file(%lx):\n", PTR2ul(libref)));
RETVAL = (dlclose(libref) == 0 ? 1 : 0);
- if (!RETVAL);
+ if (!RETVAL)
SaveError(aTHX_ "%s", dlerror()) ;
DLDEBUG(2,PerlIO_printf(Perl_debug_log, " retval = %d\n", RETVAL));
OUTPUT:
RETVAL
-void *
+void
dl_find_symbol(libhandle, symbolname)
void * libhandle
char * symbolname
+ PREINIT:
+ void *sym;
CODE:
#ifdef DLSYM_NEEDS_UNDERSCORE
symbolname = Perl_form_nocontext("_%s", symbolname);
DLDEBUG(2, PerlIO_printf(Perl_debug_log,
"dl_find_symbol(handle=%lx, symbol=%s)\n",
(unsigned long) libhandle, symbolname));
- RETVAL = dlsym(libhandle, symbolname);
+ sym = dlsym(libhandle, symbolname);
DLDEBUG(2, PerlIO_printf(Perl_debug_log,
- " symbolref = %lx\n", (unsigned long) RETVAL));
+ " symbolref = %lx\n", (unsigned long) sym));
ST(0) = sv_newmortal() ;
- if (RETVAL == NULL)
+ if (sym == NULL)
SaveError(aTHX_ "%s",dlerror()) ;
else
- sv_setiv( ST(0), PTR2IV(RETVAL));
+ sv_setiv( ST(0), PTR2IV(sym));
void
dl_undef_symbols()
- PPCODE:
+ CODE:
dl_install_xsub(perl_name, symref, filename="$Package")
char * perl_name
void * symref
- char * filename
+ const char * filename
CODE:
- DLDEBUG(2,PerlIO_printf(Perl_debug_log, "dl_install_xsub(name=%s, symref=%lx)\n",
- perl_name, (unsigned long) symref));
- ST(0) = sv_2mortal(newRV((SV*)newXS(perl_name,
- (void(*)(pTHX_ CV *))symref,
- filename)));
+ DLDEBUG(2,PerlIO_printf(Perl_debug_log, "dl_install_xsub(name=%s, symref=%"UVxf")\n",
+ perl_name, PTR2UV(symref)));
+ ST(0) = sv_2mortal(newRV((SV*)newXS_flags(perl_name,
+ DPTR2FPTR(XSUBADDR_t, symref),
+ filename, NULL,
+ XS_DYNAMIC_FILENAME)));
char *
dl_error()
CODE:
- RETVAL = LastError ;
+ dMY_CXT;
+ RETVAL = dl_last_error ;
OUTPUT:
RETVAL
+#if defined(USE_ITHREADS)
+
+void
+CLONE(...)
+ CODE:
+ MY_CXT_CLONE;
+
+ /* MY_CXT_CLONE just does a memcpy on the whole structure, so to avoid
+ * using Perl variables that belong to another thread, we create our
+ * own for this thread.
+ */
+ MY_CXT.x_dl_last_error = newSVpvn("", 0);
+
+#endif
+
# end.