diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-12-31 13:55:42 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-12-31 17:45:24 +0300 |
commit | fefb50b9cdac116158faf0f99b3ba3f321004463 (patch) | |
tree | 303f295200af13731bc47cb0fb48dad43c6d96db /win32_threads.c | |
parent | c0d8ed6209df01a5c22ca16082f9ba073c1c4c4e (diff) | |
download | bdwgc-fefb50b9cdac116158faf0f99b3ba3f321004463.tar.gz |
Use GC_delete_thread instead of GC_delete_gc_thread_no_free
(refactoring)
This commit removes GC_delete_gc_thread_no_free, thus eliminating code
duplication between GC_delete_thread and GC_delete_gc_thread_no_free.
* include/private/pthread_support.h [GC_WIN32_THREADS && !GC_PTHREADS]
(GC_delete_gc_thread_no_free): Rename to GC_delete_thread.
* pthread_support.c [CAN_HANDLE_FORK] (GC_remove_all_threads_but_me):
Add TODO item.
* pthread_support.c (GC_delete_thread): Change argument from
thread_id_t to GC_thread; update comment (copy it from
GC_delete_gc_thread_no_free); change STATIC to GC_INNER_WIN32THREAD;
define id as local variable; iterate over GC_threads[hv] chain until
t is found.
* pthread_support.c [GC_WIN32_THREADS && !MSWINCE] (GC_delete_thread):
Move CloseHandle() call to the beginning of function.
* pthread_support.c [!GC_NO_THREADS_DISCOVERY && GC_WIN32_THREADS]
(GC_delete_thread): Do not call GC_win32_dll_lookup_thread; expand code
of GC_delete_gc_thread_no_free.
* pthread_support.c [!SN_TARGET_ORBIS && !SN_TARGET_PSP2]
(GC_delete_gc_thread_no_free): Remove.
* pthread_support.c [!THREAD_LOCAL_ALLOC]
(GC_unregister_my_thread_inner): Do not cast me to void.
* pthread_support.c (GC_unregister_my_thread_inner): Pass me (instead
of thread_id_self()) to GC_delete_thread().
* pthread_support.c [GC_PTHREADS && !SN_TARGET_ORBIS
&& !SN_TARGET_PSP2] (GC_pthread_join, GC_pthread_detach): Call
GC_delete_thread() instead of GC_delete_gc_thread_no_free(),
GC_INTERNAL_FREE(t->crtn) and GC_INTERNAL_FREE(t).
* pthread_support.c [GC_PTHREADS && !SN_TARGET_ORBIS
&& !SN_TARGET_PSP2] (GC_pthread_detach): Do not set DETACHED in
t->flags if KNOWN_FINISHED(t).
* win32_threads.c [!MSWINCE && !GC_PTHREADS] (GC_suspend): Remove
assertion about GC_win32_dll_threads.
* win32_threads.c [!MSWINCE && !GC_PTHREADS] (GC_suspend): Call
GC_delete_thread() instead of GC_delete_gc_thread_no_free().
* win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_DllMain): Likewise.
* win32_threads.c [MSWIN32 && !CONSOLE_LOG || MSWINCE] (GC_stop_world):
Update comment.
Diffstat (limited to 'win32_threads.c')
-rw-r--r-- | win32_threads.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/win32_threads.c b/win32_threads.c index 39b96e39..46bc62e5 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -434,8 +434,7 @@ STATIC void GC_suspend(GC_thread t) # else /* This breaks pthread_join on Cygwin, which is guaranteed to */ /* only see user threads. */ - GC_ASSERT(GC_win32_dll_threads); - GC_delete_gc_thread_no_free(t); + GC_delete_thread(t); # endif return; } @@ -470,8 +469,7 @@ STATIC void GC_suspend(GC_thread t) # ifdef GC_PTHREADS t -> crtn -> stack_end = NULL; /* prevent stack from being pushed */ # else - GC_ASSERT(GC_win32_dll_threads); - GC_delete_gc_thread_no_free(t); + GC_delete_thread(t); # endif return; } @@ -514,8 +512,8 @@ GC_INNER void GC_stop_world(void) EnterCriticalSection(&GC_write_cs); /* It's not allowed to call GC_printf() (and friends) here down to */ /* LeaveCriticalSection (same applies recursively to GC_suspend, */ - /* GC_delete_gc_thread_no_free, GC_get_max_thread_index, GC_size */ - /* and GC_remove_protection). */ + /* GC_delete_thread, GC_get_max_thread_index, GC_size and */ + /* GC_remove_protection). */ # ifdef GC_ASSERTIONS GC_write_disabled = TRUE; # endif @@ -1772,7 +1770,7 @@ GC_INNER void GC_thr_init(void) if (GC_win32_dll_threads) { GC_thread t = GC_win32_dll_lookup_thread(GetCurrentThreadId()); - if (EXPECT(t != NULL, TRUE)) GC_delete_gc_thread_no_free(t); + if (EXPECT(t != NULL, TRUE)) GC_delete_thread(t); } break; @@ -1783,7 +1781,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_no_free((GC_thread)&dll_thread_table[i]); + GC_delete_thread((GC_thread)&dll_thread_table[i]); } GC_deinit(); } |