diff options
-rw-r--r-- | pthread_support.c | 8 | ||||
-rw-r--r-- | win32_threads.c | 10 |
2 files changed, 15 insertions, 3 deletions
diff --git a/pthread_support.c b/pthread_support.c index f18a154f..ec2b5f64 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -2048,9 +2048,15 @@ STATIC GC_thread GC_register_my_thread_inner(const struct GC_stack_base *sb, GC_API void GC_CALL GC_allow_register_threads(void) { +# ifdef GC_ASSERTIONS + DCL_LOCK_STATE; + /* Check GC is initialized and the current thread is registered. */ + LOCK(); /* just to match that in win32_threads.c */ GC_ASSERT(GC_lookup_thread(pthread_self()) != 0); - set_need_to_lock(); + UNLOCK(); +# endif + set_need_to_lock(); } GC_API int GC_CALL GC_register_my_thread(const struct GC_stack_base *sb) diff --git a/win32_threads.c b/win32_threads.c index 972b02c1..cc0ccefc 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -769,8 +769,14 @@ STATIC void GC_delete_thread(DWORD id) GC_API void GC_CALL GC_allow_register_threads(void) { - /* Check GC is initialized and the current thread is registered. */ - GC_ASSERT(GC_lookup_thread_inner(GetCurrentThreadId()) != 0); +# ifdef GC_ASSERTIONS + DCL_LOCK_STATE; + + /* Check GC is initialized and the current thread is registered. */ + LOCK(); + GC_ASSERT(GC_lookup_thread_inner(GetCurrentThreadId()) != 0); + UNLOCK(); +# endif # if !defined(GC_ALWAYS_MULTITHREADED) && !defined(PARALLEL_MARK) \ && !defined(GC_NO_THREADS_DISCOVERY) /* GC_init() does not call GC_init_parallel() in this case. */ |