perl5.004 on AIX: Patches
[p5sagit/p5-mst-13.2.git] / ext / DynaLoader / dl_aix.xs
index 68831ed..7466666 100644 (file)
 #include <a.out.h>
 #include <ldfcn.h>
 
+/* If using PerlIO, redefine these macros from <ldfcn.h> */
+#ifdef USE_PERLIO
+#define FSEEK(ldptr,o,p)        PerlIO_seek(IOPTR(ldptr),(p==BEGINNING)?(OFFSET(ldptr)+o):o,p)
+#define FREAD(p,s,n,ldptr)      PerlIO_read(IOPTR(ldptr),p,s*n)
+#endif
+
 /*
  * We simulate dlopen() et al. through a call to load. Because AIX has
  * no call to find an exported symbol we read the loader section of the
@@ -389,7 +395,13 @@ static int readExports(ModulePtr mp)
                        ;
                return -1;
        }
+/* This first case is a hack, since it assumes that the 3rd parameter to
+   FREAD is 1. See the redefinition of FREAD above to see how this works. */
+#ifdef USE_PERLIO
+       if (FREAD(ldbuf, sh.s_size, 1, ldp) != sh.s_size) {
+#else
        if (FREAD(ldbuf, sh.s_size, 1, ldp) != 1) {
+#endif
                errvalid++;
                strcpy(errbuf, "readExports: cannot read loader section");
                safefree(ldbuf);
@@ -524,10 +536,13 @@ BOOT:
 
 
 void *
-dl_load_file(filename)
-       char *          filename
+dl_load_file(filename, flags=0)
+       char *  filename
+       int     flags
        CODE:
-       DLDEBUG(1,PerlIO_printf(PerlIO_stderr(), "dl_load_file(%s):\n", filename));
+       DLDEBUG(1,PerlIO_printf(PerlIO_stderr(), "dl_load_file(%s,%x):\n", filename,flags));
+       if (flags & 0x01)
+           warn("Can't make loaded symbols global on this platform while loading %s",filename);
        RETVAL = dlopen(filename, 1) ;
        DLDEBUG(2,PerlIO_printf(PerlIO_stderr(), " libref=%x\n", RETVAL));
        ST(0) = sv_newmortal() ;