2 * dl_beos.xs, by Tom Spindler
3 * based on dl_dlopen.xs, by Paul Marquess
10 #include <be/kernel/image.h>
15 #define dlerror() strerror(errno)
17 #include "dlutils.c" /* SaveError() etc */
22 (void)dl_generic_private_init(aTHX);
25 MODULE = DynaLoader PACKAGE = DynaLoader
28 (void)dl_private_init(aTHX);
32 dl_load_file(filename, flags=0)
38 path = malloc(PATH_MAX);
39 if (*filename != '/') {
40 getcwd(path, PATH_MAX);
42 strcat(path, filename);
44 strcpy(path, filename);
47 DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s,%x):\n", path, flags));
48 bogo = load_add_on(path);
49 DLDEBUG(2,PerlIO_printf(Perl_debug_log, " libref=%lx\n", (unsigned long) RETVAL));
50 ST(0) = sv_newmortal() ;
52 SaveError(aTHX_ "%s", strerror(bogo));
53 PerlIO_printf(Perl_debug_log, "load_add_on(%s) : %d (%s)\n", path, bogo, strerror(bogo));
55 RETVAL = (void *) bogo;
56 sv_setiv( ST(0), PTR2IV(RETVAL) );
62 dl_find_symbol(libhandle, symbolname)
68 #ifdef DLSYM_NEEDS_UNDERSCORE
69 symbolname = Perl_form_nocontext("_%s", symbolname);
72 DLDEBUG(2, PerlIO_printf(Perl_debug_log,
73 "dl_find_symbol(handle=%lx, symbol=%s)\n",
74 (unsigned long) libhandle, symbolname));
75 retcode = get_image_symbol((image_id) libhandle, symbolname,
76 B_SYMBOL_TYPE_TEXT, (void **) &adr);
78 DLDEBUG(2, PerlIO_printf(Perl_debug_log,
79 " symbolref = %lx\n", (unsigned long) RETVAL));
80 ST(0) = sv_newmortal() ;
82 SaveError(aTHX_ "%s", strerror(retcode)) ;
83 PerlIO_printf(Perl_debug_log, "retcode = %p (%s)\n", retcode, strerror(retcode));
85 sv_setiv( ST(0), PTR2IV(RETVAL));
94 # These functions should not need changing on any platform:
97 dl_install_xsub(perl_name, symref, filename="$Package")
100 const char * filename
102 DLDEBUG(2,PerlIO_printf(Perl_debug_log, "dl_install_xsub(name=%s, symref=%lx)\n",
103 perl_name, (unsigned long) symref));
104 ST(0) = sv_2mortal(newRV((SV*)newXS_flags(perl_name,
105 (void(*)(pTHX_ CV *))symref,
107 XS_DYNAMIC_FILENAME)));
114 RETVAL = dl_last_error ;
118 #if defined(USE_ITHREADS)
125 /* MY_CXT_CLONE just does a memcpy on the whole structure, so to avoid
126 * using Perl variables that belong to another thread, we create our
127 * own for this thread.
129 MY_CXT.x_dl_last_error = newSVpvn("", 0);