From af628c6871ad11deaef903d6fe06293f123c6369 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 25 Feb 2012 22:57:58 +0400 Subject: [PATCH] Code refactoring of GC_destroy_thread_local (move assertion on 'tlfs' out of function since otherwise assertion is skipped if HANDLE_FORK) * pthread_support.c (GC_unregister_my_thread_inner): Add assertion on "tlfs" value before GC_destroy_thread_local() invocation. * win32_threads.c (GC_unregister_my_thread, GC_thread_exit_proc): Likewise. * thread_local_alloc.c (GC_destroy_thread_local): Remove assertion on "tlfs" value (since it was skipped if HANDLE_FORK because of the function invocation from GC_remove_all_threads_but_me). --- pthread_support.c | 1 + thread_local_alloc.c | 3 --- win32_threads.c | 2 ++ 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pthread_support.c b/pthread_support.c index e43f20a0..e1bfc945 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -1264,6 +1264,7 @@ STATIC void GC_unregister_my_thread_inner(GC_thread me) # endif GC_ASSERT(!(me -> flags & FINISHED)); # if defined(THREAD_LOCAL_ALLOC) + GC_ASSERT(GC_getspecific(GC_thread_key) == &me->tlfs); GC_destroy_thread_local(&(me->tlfs)); # endif # if defined(GC_PTHREAD_EXIT_ATTRIBUTE) || !defined(GC_NO_PTHREAD_CANCEL) diff --git a/thread_local_alloc.c b/thread_local_alloc.c index d7031e3b..36289101 100644 --- a/thread_local_alloc.c +++ b/thread_local_alloc.c @@ -128,9 +128,6 @@ GC_INNER void GC_destroy_thread_local(GC_tlfs p) { /* We currently only do this from the thread itself or from */ /* the fork handler for a child process. */ -# ifndef HANDLE_FORK - GC_ASSERT(GC_getspecific(GC_thread_key) == (void *)p); -# endif return_freelists(p -> ptrfree_freelists, GC_aobjfreelist); return_freelists(p -> normal_freelists, GC_objfreelist); # ifdef GC_GCJ_SUPPORT diff --git a/win32_threads.c b/win32_threads.c index 1682b2cc..c1bbc0fa 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -819,6 +819,7 @@ GC_API int GC_CALL GC_unregister_my_thread(void) GC_ASSERT(!KNOWN_FINISHED(me)); # endif # if defined(THREAD_LOCAL_ALLOC) + GC_ASSERT(GC_getspecific(GC_thread_key) == &me->tlfs); GC_destroy_thread_local(&(me->tlfs)); # endif # ifdef GC_PTHREADS @@ -2633,6 +2634,7 @@ GC_INNER void GC_thr_init(void) LOCK(); GC_wait_for_gc_completion(FALSE); # if defined(THREAD_LOCAL_ALLOC) + GC_ASSERT(GC_getspecific(GC_thread_key) == &me->tlfs); GC_destroy_thread_local(&(me->tlfs)); # endif if (me -> flags & DETACHED) { -- 2.40.0