summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2013-12-01 19:01:46 +0400
committerIvan Maidanski <ivmai@mail.ru>2013-12-01 19:02:35 +0400
commitd5c65315be6b19becc29afe0f020ad9618e9fdff (patch)
treefcee8a006a4d987cb2ef1c9e68ef370d5d5003e0 /misc.c
parente741b4525ca2d1b89de57205b5e7e8058988703a (diff)
downloadbdwgc-d5c65315be6b19becc29afe0f020ad9618e9fdff.tar.gz
New macro (GC_ALWAYS_MULTITHREADED) to set multi-threaded mode implicitly
* darwin_stop_world.c (GC_use_threads_discovery): Skip assertion on GC_need_to_lock if GC_ALWAYS_MULTITHREADED. * misc.c (GC_init): Likewise. * doc/README.macros (GC_ALWAYS_MULTITHREADED): Document. * include/gc.h (GC_allow_register_threads): Update comment (regarding GC_ALWAYS_MULTITHREADED). * include/private/gc_locks.h (I_HOLD_LOCK): Reformat code. * include/private/gc_locks.h (GC_need_to_lock): Define as macro (to TRUE) if GC_ALWAYS_MULTITHREADED defined. * include/private/gc_locks.h (LOCK, UNLOCK): Define to UNCOND_[UN]LOCK if GC_ALWAYS_MULTITHREADED. * misc.c (GC_init): Call GC_init_parallel() if GC_ALWAYS_MULTITHREADED but not GC_NO_THREADS_DISCOVERY (only for Win32, needed since GC_allow_register_threads does nothing if GC_ALWAYS_MULTITHREADED). * misc.c (IF_NEED_TO_LOCK): Ignore GC_parallel if GC_ALWAYS_MULTITHREADED (since GC_need_to_lock is always true). * pthread_support.c (GC_need_to_lock): Do not define varaible if GC_ALWAYS_MULTITHREADED (since defined as a macro). * win32_threads.c (GC_need_to_lock): Likewise. * pthread_support.c (GC_allow_register_threads, pthread_create): Do not alter value of GC_need_to_lock if GC_ALWAYS_MULTITHREADED. * win32_threads.c (GC_allow_register_threads, GC_CreateThread, GC_beginthreadex, GC_pthread_create, GC_init_parallel): Likewise. * win32_threads.c (GC_allow_register_threads): Do not alter "parallel_initialized" value if GC_ALWAYS_MULTITHREADED (so that GC_allow_register_threads is a no-op if the macro defined).
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/misc.c b/misc.c
index c0ba6f4d..3ca8ad94 100644
--- a/misc.c
+++ b/misc.c
@@ -853,7 +853,9 @@ GC_API void GC_CALL GC_init(void)
/* then. Thus we really don't hold any locks, and can */
/* in fact safely initialize them here. */
# ifdef THREADS
- GC_ASSERT(!GC_need_to_lock);
+# ifndef GC_ALWAYS_MULTITHREADED
+ GC_ASSERT(!GC_need_to_lock);
+# endif
# ifdef SN_TARGET_PS3
{
pthread_mutexattr_t mattr;
@@ -1214,7 +1216,9 @@ GC_API void GC_CALL GC_init(void)
/* The rest of this again assumes we don't really hold */
/* the allocation lock. */
-# if defined(PARALLEL_MARK) || defined(THREAD_LOCAL_ALLOC)
+# if defined(PARALLEL_MARK) || defined(THREAD_LOCAL_ALLOC) \
+ || (defined(GC_ALWAYS_MULTITHREADED) && defined(GC_WIN32_THREADS) \
+ && !defined(GC_NO_THREADS_DISCOVERY))
/* Make sure marker threads are started and thread local */
/* allocation is initialized, in case we didn't get */
/* called from GC_init_parallel. */
@@ -1293,7 +1297,7 @@ GC_API void GC_CALL GC_enable_incremental(void)
}
# ifdef THREADS
-# ifdef PARALLEL_MARK
+# if defined(PARALLEL_MARK) && !defined(GC_ALWAYS_MULTITHREADED)
# define IF_NEED_TO_LOCK(x) if (GC_parallel || GC_need_to_lock) x
# else
# define IF_NEED_TO_LOCK(x) if (GC_need_to_lock) x