summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivmai <ivmai>2011-01-07 18:10:01 +0100
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:55 +0200
commit2425c85c5845f968c5125455c3b218441a57fd9b (patch)
tree1f0d50f5f4815b671edcb3af17088836683d93f0
parentff1f125eef0e2e9fc2bafbd094af1857ef7c438f (diff)
2011-01-07 Ivan Maidanski <ivmai@mail.ru>gc7_2alpha5-20110107
* gc_dlopen.c: Reformat the comments and adjust code indentation.
-rw-r--r--ChangeLog4
-rw-r--r--gc_dlopen.c116
-rw-r--r--include/private/gcconfig.h2
3 files changed, 62 insertions, 60 deletions
diff --git a/ChangeLog b/ChangeLog
index b6021b6..0cbec48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2011-01-07 Ivan Maidanski <ivmai@mail.ru>
+ * gc_dlopen.c: Reformat the comments and adjust code indentation.
+
+2011-01-07 Ivan Maidanski <ivmai@mail.ru>
+
* include/private/gc_priv.h (THREAD_FLD, MAX_HEAP_SECTS,
_GC_arrays, GC_push_all_stack_sections, PRINT_BLACK_LIST,
GC_add_to_black_list_stack, GC_ASSERT, SIG_SUSPEND,
diff --git a/gc_dlopen.c b/gc_dlopen.c
index 156b1e6..6d886fd 100644
--- a/gc_dlopen.c
+++ b/gc_dlopen.c
@@ -18,76 +18,74 @@
#include "private/gc_priv.h"
-/*
- * 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. Of course this fails if the collector is in a dynamic
- * library. -HB
- */
+/* 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. Of course this fails if the collector is in */
+/* a dynamic library. -HB */
-# if defined(GC_PTHREADS) && !defined(GC_DARWIN_THREADS) \
- && !defined(GC_WIN32_PTHREADS)
+#if defined(GC_PTHREADS) && !defined(GC_DARWIN_THREADS) \
+ && !defined(GC_WIN32_PTHREADS)
-# undef GC_MUST_RESTORE_REDEFINED_DLOPEN
-# if defined(dlopen) && !defined(GC_USE_LD_WRAP)
- /* To support various threads pkgs, 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 */
- /* real system dlopen() in their implementation. We first remove */
- /* gc.h's dlopen definition and restore it later, after GC_dlopen(). */
-# undef dlopen
-# define GC_MUST_RESTORE_REDEFINED_DLOPEN
-# endif
+#undef GC_MUST_RESTORE_REDEFINED_DLOPEN
+#if defined(dlopen) && !defined(GC_USE_LD_WRAP)
+ /* To support various threads pkgs, 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 */
+ /* real system dlopen() in their implementation. We first remove */
+ /* gc.h's dlopen definition and restore it later, after GC_dlopen(). */
+# undef dlopen
+# define GC_MUST_RESTORE_REDEFINED_DLOPEN
+#endif
- /* Make sure we're not in the middle of a collection, and make */
- /* sure we don't start any. */
- /* This is invoked prior to a dlopen call to avoid synchronization */
- /* issues. We can't just acquire the allocation lock, since startup */
- /* code in dlopen may try to allocate. This solution risks heap */
- /* growth (or, even, heap overflow) in the presence of many dlopen */
- /* calls in either a multi-threaded environment, or if the library */
- /* initialization code allocates substantial amounts of GC'ed memory. */
- static void disable_gc_for_dlopen(void)
- {
- DCL_LOCK_STATE;
- LOCK();
- while (GC_incremental && GC_collection_in_progress()) {
- GC_collect_a_little_inner(1000);
- }
- ++GC_dont_gc;
- UNLOCK();
+/* Make sure we're not in the middle of a collection, and make sure we */
+/* don't start any. This is invoked prior to a dlopen call to avoid */
+/* synchronization issues. We can't just acquire the allocation lock, */
+/* since startup code in dlopen may try to allocate. This solution */
+/* risks heap growth (or, even, heap overflow) in the presence of many */
+/* dlopen calls in either a multi-threaded environment, or if the */
+/* library initialization code allocates substantial amounts of GC'ed */
+/* memory. */
+static void disable_gc_for_dlopen(void)
+{
+ DCL_LOCK_STATE;
+ LOCK();
+ while (GC_incremental && GC_collection_in_progress()) {
+ GC_collect_a_little_inner(1000);
}
+ ++GC_dont_gc;
+ UNLOCK();
+}
- /* Redefine dlopen to guarantee mutual exclusion with */
- /* GC_register_dynamic_libraries. */
- /* Should probably happen for other operating systems, too. */
+/* Redefine dlopen to guarantee mutual exclusion with */
+/* GC_register_dynamic_libraries. Should probably happen for */
+/* other operating systems, too. */
#include <dlfcn.h>
-/* This is similar to WRAP/REAL_FUNC() in pthread_support.c. */
+/* This is similar to WRAP/REAL_FUNC() in pthread_support.c. */
#ifdef GC_USE_LD_WRAP
-# define WRAP_DLFUNC(f) __wrap_##f
-# define REAL_DLFUNC(f) __real_##f
- void * REAL_DLFUNC(dlopen)(const char *, int);
+# define WRAP_DLFUNC(f) __wrap_##f
+# define REAL_DLFUNC(f) __real_##f
+ void * REAL_DLFUNC(dlopen)(const char *, int);
#else
-# define WRAP_DLFUNC(f) GC_##f
-# define REAL_DLFUNC(f) f
+# define WRAP_DLFUNC(f) GC_##f
+# define REAL_DLFUNC(f) f
#endif
GC_API void * WRAP_DLFUNC(dlopen)(const char *path, int mode)
{
- void * result;
+ void * result;
-# ifndef USE_PROC_FOR_LIBRARIES
- /* Disable collections. This solution risks heap growth (or, */
- /* even, heap overflow) but there seems no better solutions. */
- disable_gc_for_dlopen();
-# endif
- result = REAL_DLFUNC(dlopen)(path, mode);
-# ifndef USE_PROC_FOR_LIBRARIES
- GC_enable(); /* undoes disable_gc_for_dlopen */
-# endif
- return(result);
+# ifndef USE_PROC_FOR_LIBRARIES
+ /* Disable collections. This solution risks heap growth (or, */
+ /* even, heap overflow) but there seems no better solutions. */
+ disable_gc_for_dlopen();
+# endif
+ result = REAL_DLFUNC(dlopen)(path, mode);
+# ifndef USE_PROC_FOR_LIBRARIES
+ GC_enable(); /* undoes disable_gc_for_dlopen */
+# endif
+ return(result);
}
#ifdef GC_USE_LD_WRAP
@@ -98,10 +96,10 @@ GC_API void * WRAP_DLFUNC(dlopen)(const char *path, int mode)
{
return dlopen(path, mode);
}
-#endif /* Linker-based interception. */
+#endif /* GC_USE_LD_WRAP */
-# ifdef GC_MUST_RESTORE_REDEFINED_DLOPEN
-# define dlopen GC_dlopen
-# endif
+#ifdef GC_MUST_RESTORE_REDEFINED_DLOPEN
+# define dlopen GC_dlopen
+#endif
#endif /* GC_PTHREADS */
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
index 653416f..0561236 100644
--- a/include/private/gcconfig.h
+++ b/include/private/gcconfig.h
@@ -648,7 +648,7 @@
* The first and second one may be combined, in which case a runtime
* selection will be made, based on GetWriteWatch availability.
*
- * An architecture may define DYNAMIC_LOADING if dynamic_load.c
+ * An architecture may define DYNAMIC_LOADING if dyn_load.c
* defined GC_register_dynamic_libraries() for the architecture.
*
* An architecture may define PREFETCH(x) to preload the cache with *x.