diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-10-18 08:07:53 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-10-19 11:10:59 +0300 |
commit | 96be49adeb05f935382ebf64e6342ca26922d3f0 (patch) | |
tree | 26cd49e547d596c07124316a914a9035d8a14fd5 /pthread_support.c | |
parent | d171840b93b1c85f475c9ceed4e50ab7548c3cdc (diff) | |
download | bdwgc-96be49adeb05f935382ebf64e6342ca26922d3f0.tar.gz |
Do not free entry in GC_delete_gc_thread to match that on Win32
(refactoring)
* pthread_support.c [!SN_TARGET_ORBIS && !SN_TARGET_PSP2]
(GC_delete_gc_thread): Update comment; rename to
GC_delete_gc_thread_no_free; do not call GC_INTERNAL_FREE().
* pthread_support.c [!SN_TARGET_ORBIS && !SN_TARGET_PSP2]
(pthread_join, pthread_detach): Call GC_delete_gc_thread_no_free() and
GC_INTERNAL_FREE() instead of GC_delete_gc_thread().
Diffstat (limited to 'pthread_support.c')
-rw-r--r-- | pthread_support.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/pthread_support.c b/pthread_support.c index 437470ff..04615ce2 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -675,7 +675,8 @@ STATIC void GC_delete_thread(thread_id_t id) /* been notified, then there may be more than one thread */ /* in the table with the same thread id. */ /* This is OK, but we need a way to delete a specific one. */ - STATIC void GC_delete_gc_thread(GC_thread t) + /* Does not actually free GC_thread entry, only unlinks it. */ + STATIC void GC_delete_gc_thread_no_free(GC_thread t) { thread_id_t id = t -> id; int hv = THREAD_TABLE_INDEX(id); @@ -687,7 +688,7 @@ STATIC void GC_delete_thread(thread_id_t id) prev = p; p = p -> tm.next; } - if (prev == 0) { + if (NULL == prev) { GC_threads[hv] = p -> tm.next; } else { GC_ASSERT(prev != &first_thread); @@ -697,8 +698,6 @@ STATIC void GC_delete_thread(thread_id_t id) # ifdef GC_DARWIN_THREADS mach_port_deallocate(mach_task_self(), p -> mach_thread); # endif - GC_INTERNAL_FREE(p); - # ifdef DEBUG_THREADS GC_log_printf("Deleted thread %p, n_threads= %d\n", (void *)id, GC_count_threads()); @@ -2081,8 +2080,10 @@ GC_API int GC_CALL GC_register_my_thread(const struct GC_stack_base *sb) /* Here the pthread id may have been recycled. Delete the thread */ /* from GC_threads (unless it has been registered again from the */ /* client thread key destructor). */ - if (KNOWN_FINISHED(t)) - GC_delete_gc_thread(t); + if (KNOWN_FINISHED(t)) { + GC_delete_gc_thread_no_free(t); + GC_INTERNAL_FREE(t); + } UNLOCK(); } return result; @@ -2104,7 +2105,8 @@ GC_API int GC_CALL GC_register_my_thread(const struct GC_stack_base *sb) t -> flags |= DETACHED; /* Here the pthread id may have been recycled. */ if (KNOWN_FINISHED(t)) { - GC_delete_gc_thread(t); + GC_delete_gc_thread_no_free(t); + GC_INTERNAL_FREE(t); } UNLOCK(); } |