]> granicus.if.org Git - gc/commitdiff
Code refactoring of GC_destroy_thread_local (move assertion on 'tlfs'
authorIvan Maidanski <ivmai@mail.ru>
Sat, 25 Feb 2012 18:57:58 +0000 (22:57 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 25 Feb 2012 18:57:58 +0000 (22:57 +0400)
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
thread_local_alloc.c
win32_threads.c

index e43f20a0856a9f280a0a16d7324d92c6d6662c39..e1bfc945fd88ca9528e4882b7d915798a4fed1b4 100644 (file)
@@ -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)
index d7031e3b4bceb4f97ea9d73432e7eba171b312ac..362891017c062a0f3be8b5e92ff0f91eb142f5cf 100644 (file)
@@ -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
index 1682b2ccc3ea96dbad87b9bf5f2462a70f77fed3..c1bbc0fad6acac42fe0025ab70a7f8e9e2c1c8dd 100644 (file)
@@ -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) {