summaryrefslogtreecommitdiff
path: root/gc_dlopen.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2011-07-26 17:28:12 +0400
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 17:28:12 +0400
commit111a44f98adde07d205c92656ad9b935ca2a39a8 (patch)
tree8a0cb4e60f636fd09dd0d2e1a3a7f3a4ac0a1bb0 /gc_dlopen.c
parentf3632431e72d48bc7772b0752e29bb1e2a0901c6 (diff)
downloadbdwgc-111a44f98adde07d205c92656ad9b935ca2a39a8.tar.gz
gc6.2 tarball importgc6_2
Diffstat (limited to 'gc_dlopen.c')
-rw-r--r--gc_dlopen.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/gc_dlopen.c b/gc_dlopen.c
index eafaa2b1..4c690edc 100644
--- a/gc_dlopen.c
+++ b/gc_dlopen.c
@@ -19,12 +19,14 @@
/*
* This used to be in dyn_load.c. It was extracted into a separate file
* to avoid having to link against libdl.{a,so} if the client doesn't call
- * dlopen. -HB
+ * dlopen. Of course this fails if the collector is in a dynamic
+ * library. -HB
*/
#include "private/gc_priv.h"
-# if defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS)
+# if (defined(GC_PTHREADS) && !defined(GC_DARWIN_THREADS)) \
+ || defined(GC_SOLARIS_THREADS)
# if defined(dlopen) && !defined(GC_USE_LD_WRAP)
/* To support various threads pkgs, gc.h interposes on dlopen by */
@@ -44,19 +46,14 @@
/* calls in either a multithreaded environment, or if the library */
/* initialization code allocates substantial amounts of GC'ed memory. */
/* But I don't know of a better solution. */
- /* This can still deadlock if the client explicitly starts a GC */
- /* during the dlopen. He shouldn't do that. */
- static GC_bool disable_gc_for_dlopen()
+ static void disable_gc_for_dlopen()
{
- GC_bool result;
LOCK();
- result = GC_dont_gc;
while (GC_incremental && GC_collection_in_progress()) {
GC_collect_a_little_inner(1000);
}
- GC_dont_gc = TRUE;
+ ++GC_dont_gc;
UNLOCK();
- return(result);
}
/* Redefine dlopen to guarantee mutual exclusion with */
@@ -74,10 +71,9 @@
#endif
{
void * result;
- GC_bool dont_gc_save;
# ifndef USE_PROC_FOR_LIBRARIES
- dont_gc_save = disable_gc_for_dlopen();
+ disable_gc_for_dlopen();
# endif
# ifdef GC_USE_LD_WRAP
result = (void *)__real_dlopen(path, mode);
@@ -85,7 +81,7 @@
result = dlopen(path, mode);
# endif
# ifndef USE_PROC_FOR_LIBRARIES
- GC_dont_gc = dont_gc_save;
+ GC_enable(); /* undoes disable_gc_for_dlopen */
# endif
return(result);
}