summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-11-11 16:29:09 +0400
committerIvan Maidanski <ivmai@mail.ru>2012-11-11 16:29:09 +0400
commitb4ba527cd4094eaf9ab8e698a85231a3de36dc49 (patch)
tree196e7bfdd2ac6071f81b1bbf2393410148643e47
parent653fb51a5a9d45b7833d5b3a09d8d2fa596125a3 (diff)
downloadbdwgc-b4ba527cd4094eaf9ab8e698a85231a3de36dc49.tar.gz
Replace Win32 GC_delete_gc_thread with GC_delete_gc_thread_no_free
* win32_threads.c (GC_delete_gc_thread): Rename to GC_delete_gc_thread_no_free; remove GC_INTERNAL_FREE call; update comment. * win32_threads.c (GC_delete_thread, GC_suspend, GC_DllMain): Replace GC_delete_gc_thread call with GC_delete_gc_thread_no_free one (since GC_win32_dll_threads is true thus there is no entry to free). * win32_threads.c (GC_delete_thread): Change type of "t" local variable from GC_thread to GC_vthread. * win32_threads.c (GC_stop_world): Update comment. * win32_threads.c (GC_pthread_join, GC_pthread_detach): Replace GC_delete_gc_thread call with GC_delete_gc_thread_no_free and GC_INTERNAL_FREE calls (since GC_win32_dll_threads is false). * win32_threads.c (GC_pthread_detach): Add assertion that GC_win32_dll_threads is false.
-rw-r--r--win32_threads.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/win32_threads.c b/win32_threads.c
index 96f62ed0..44f01b00 100644
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -631,10 +631,11 @@ GC_API int GC_CALL GC_thread_is_registered(void)
/* in the table with the same win32 id. */
/* This is OK, but we need a way to delete a specific one. */
/* Assumes we hold the allocation lock unless */
-/* GC_win32_dll_threads is set. */
+/* GC_win32_dll_threads is set. Does not actually free */
+/* GC_thread entry (only unlinks it). */
/* If GC_win32_dll_threads is set it should be called from the */
/* thread being deleted. */
-STATIC void GC_delete_gc_thread(GC_vthread t)
+STATIC void GC_delete_gc_thread_no_free(GC_vthread t)
{
# ifndef MSWINCE
CloseHandle(t->handle);
@@ -669,7 +670,6 @@ STATIC void GC_delete_gc_thread(GC_vthread t)
} else {
prev -> tm.next = p -> tm.next;
}
- GC_INTERNAL_FREE(p);
}
}
@@ -682,12 +682,12 @@ STATIC void GC_delete_gc_thread(GC_vthread t)
STATIC void GC_delete_thread(DWORD id)
{
if (GC_win32_dll_threads) {
- GC_thread t = GC_lookup_thread_inner(id);
+ GC_vthread t = GC_lookup_thread_inner(id);
if (0 == t) {
WARN("Removing nonexistent thread, id = %" WARN_PRIdPTR "\n", id);
} else {
- GC_delete_gc_thread(t);
+ GC_delete_gc_thread_no_free(t);
}
} else {
word hv = THREAD_TABLE_INDEX(id);
@@ -1131,7 +1131,7 @@ STATIC void GC_suspend(GC_thread t)
/* this breaks pthread_join on Cygwin, which is guaranteed to */
/* only see user pthreads */
GC_ASSERT(GC_win32_dll_threads);
- GC_delete_gc_thread(t);
+ GC_delete_gc_thread_no_free(t);
# endif
return;
}
@@ -1188,10 +1188,9 @@ GC_INNER void GC_stop_world(void)
GC_ASSERT(!GC_write_disabled);
EnterCriticalSection(&GC_write_cs);
/* It's not allowed to call GC_printf() (and friends) here down to */
- /* LeaveCriticalSection (same applies recursively to */
- /* GC_get_max_thread_index(), GC_suspend(), GC_delete_gc_thread() */
- /* (only if GC_win32_dll_threads), GC_size() and */
- /* GC_remove_protection()). */
+ /* LeaveCriticalSection (same applies recursively to GC_suspend, */
+ /* GC_delete_gc_thread_no_free, GC_get_max_thread_index, GC_size */
+ /* and GC_remove_protection). */
# ifdef GC_ASSERTIONS
GC_write_disabled = TRUE;
# endif
@@ -2534,7 +2533,8 @@ GC_INNER void GC_thr_init(void)
if (NULL == t) ABORT("Thread not registered");
# endif
LOCK();
- GC_delete_gc_thread(t);
+ GC_delete_gc_thread_no_free(t);
+ GC_INTERNAL_FREE(t);
UNLOCK();
# ifdef DEBUG_THREADS
@@ -2686,6 +2686,7 @@ GC_INNER void GC_thr_init(void)
GC_thread t;
DCL_LOCK_STATE;
+ GC_ASSERT(!GC_win32_dll_threads);
LOCK();
t = GC_lookup_pthread(thread);
UNLOCK();
@@ -2696,7 +2697,8 @@ GC_INNER void GC_thr_init(void)
t -> flags |= DETACHED;
/* Here the pthread thread id may have been recycled. */
if ((t -> flags & FINISHED) != 0) {
- GC_delete_gc_thread(t);
+ GC_delete_gc_thread_no_free(t);
+ GC_INTERNAL_FREE(t);
}
UNLOCK();
}
@@ -2770,7 +2772,7 @@ GC_INNER void GC_thr_init(void)
for (i = 0; i <= my_max; ++i) {
if (AO_load(&(dll_thread_table[i].tm.in_use)))
- GC_delete_gc_thread(dll_thread_table + i);
+ GC_delete_gc_thread_no_free(&dll_thread_table[i]);
}
GC_deinit();
DeleteCriticalSection(&GC_allocate_ml);