*** empty log message ***
[bpt/guile.git] / libguile / dynl-dl.c
index d8fb0c4..72fba6a 100644 (file)
@@ -1,6 +1,6 @@
 /* dynl-dl.c - dynamic linking for dlopen/dlsym
  *
- * Copyright (C) 1990-1997 Free Software Foundation, Inc.
+ * Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
  * 
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #endif
 
 static void *
-sysdep_dynl_link (fname, subr)
-     char *fname;
-     char *subr;
+sysdep_dynl_link (fname, flags, subr)
+     const char *fname;
+     int flags;
+     const char *subr;
 {
-    void *handle = dlopen (fname, DLOPEN_MODE);
+    void *handle = dlopen (fname, (DLOPEN_MODE 
+                                  | ((flags & DYNL_GLOBAL)? RTLD_GLOBAL : 0)));
     if (NULL == handle)
       {
        SCM_ALLOW_INTS;
@@ -70,7 +72,7 @@ sysdep_dynl_link (fname, subr)
 static void
 sysdep_dynl_unlink (handle, subr)
      void *handle;
-     char *subr;
+     const char *subr;
 {
     if (dlclose (handle))
       {
@@ -81,14 +83,26 @@ sysdep_dynl_unlink (handle, subr)
    
 static void *
 sysdep_dynl_func (symb, handle, subr)
-     char *symb;
+     const char *symb;
      void *handle;
-     char *subr;
+     const char *subr;
 {
     void *fptr;
     char *err;
+#if defined(USCORE) && !defined(DLSYM_ADDS_USCORE)
+    char *usymb;
+#endif
 
+#if defined(USCORE) && !defined(DLSYM_ADDS_USCORE)
+    usymb = (char *) malloc (strlen (symb) + 2);
+    *usymb = '_';
+    strcpy (usymb + 1, symb);
+    fptr = dlsym (handle, usymb);
+    free (usymb);
+#else
     fptr = dlsym (handle, symb);
+#endif
+
     err = (char *)dlerror ();
     if (!fptr)
       {