Patch: dlopen -vs- Linux

Tom Tromey tromey@cygnus.com
Mon Feb 14 13:51:00 GMT 2000


I'm committing the appended patch to the GC.
I implemented it following the comment in README.linux.

I haven't tested this in a situation where it would really matter.
Hans, feel free to tell me if you'd like the patch done differently.

2000-02-14  Tom Tromey  <tromey@cygnus.com>

	* gc.h (dlopen): Define as GC_dlopen on Linux.
	(GC_dlopen): Declare on Linux.
	* dyn_load.c (GC_dlopen): Define for Linux.

Tom

Index: gc.h
===================================================================
RCS file: /cvs/java/libgcj/boehm-gc/gc.h,v
retrieving revision 1.4
diff -u -r1.4 gc.h
--- gc.h	1999/11/01 23:15:51	1.4
+++ gc.h	2000/02/14 21:49:40
@@ -712,6 +712,10 @@
 
 # endif /* SOLARIS_THREADS */
 
+#if defined(LINUX_THREADS)
+  void * GC_dlopen(const char *path, int mode);
+# define dlopen GC_dlopen
+#endif
 
 #if defined(IRIX_THREADS) || defined(LINUX_THREADS) || defined(HPUX_THREADS)
 /* We treat these similarly. */
Index: dyn_load.c
===================================================================
RCS file: /cvs/java/libgcj/boehm-gc/dyn_load.c,v
retrieving revision 1.6
diff -u -r1.6 dyn_load.c
--- dyn_load.c	1999/11/04 17:25:07	1.6
+++ dyn_load.c	2000/02/14 21:49:45
@@ -32,7 +32,7 @@
 #include "gc_priv.h"
 
 /* BTL: avoid circular redefinition of dlopen if SOLARIS_THREADS defined */
-# if defined(SOLARIS_THREADS) && defined(dlopen)
+# if (defined(SOLARIS_THREADS) || defined(LINUX_THREADS)) && defined(dlopen)
     /* To support threads in Solaris, gc.h interposes on dlopen by       */
     /* defining "dlopen" to be "GC_dlopen", which is implemented below.  */
     /* However, both GC_FirstDLOpenedLinkMap() and GC_dlopen() use the   */
@@ -190,11 +190,6 @@
 }
 # endif  /* SOLARIS_THREADS */
 
-/* BTL: added to fix circular dlopen definition if SOLARIS_THREADS defined */
-# if defined(GC_must_restore_redefined_dlopen)
-#   define dlopen GC_dlopen
-# endif
-
 # ifndef USE_PROC_FOR_LIBRARIES
 void GC_register_dynamic_libraries()
 {
@@ -259,6 +254,25 @@
 
 # endif /* !USE_PROC ... */
 # endif /* SUNOS */
+
+#ifdef LINUX_THREADS
+#include <dlfcn.h>
+
+void * GC_dlopen(const char *path, int mode)
+{
+    void * result;
+    
+    LOCK();
+    result = dlopen(path, mode);
+    UNLOCK();
+    return(result);
+}
+#endif  /* LINUX_THREADS */
+
+/* BTL: added to fix circular dlopen definition if SOLARIS_THREADS defined */
+#if defined(GC_must_restore_redefined_dlopen)
+# define dlopen GC_dlopen
+#endif
 
 #if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF)
 


More information about the Java-patches mailing list