From d6f2674f15e848495b2ed9db1689e425cd2e1115 Mon Sep 17 00:00:00 2001 From: ivmai Date: Tue, 17 May 2011 06:45:30 +0000 Subject: [PATCH] 2011-05-17 Ivan Maidanski * pthread_support.c (GC_delete_gc_thread): Rename "gc_id" local variable to "t". * win32_threads.c (GC_delete_gc_thread): Ditto. * pthread_support.c (pthread_join, pthread_detach, pthread_cancel): Rename "thread_gc_id" local variable to "t". * win32_threads.c (GC_pthread_detach): Ditto. * win32_threads.c (GC_delete_gc_thread): Remove "gc_nvid" local variable. * win32_threads.c (GC_pthread_join): Rename "joinee" local variable to "t". --- ChangeLog | 13 +++++++++++++ pthread_support.c | 35 +++++++++++++++++------------------ win32_threads.c | 40 ++++++++++++++++++++-------------------- 3 files changed, 50 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3eef929..e7cd2c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2011-05-17 Ivan Maidanski + + * pthread_support.c (GC_delete_gc_thread): Rename "gc_id" local + variable to "t". + * win32_threads.c (GC_delete_gc_thread): Ditto. + * pthread_support.c (pthread_join, pthread_detach, + pthread_cancel): Rename "thread_gc_id" local variable to "t". + * win32_threads.c (GC_pthread_detach): Ditto. + * win32_threads.c (GC_delete_gc_thread): Remove "gc_nvid" local + variable. + * win32_threads.c (GC_pthread_join): Rename "joinee" local + variable to "t". + 2011-05-16 Ivan Maidanski * pthread_stop_world.c (pthread_sigmask): Undefine even if not diff --git a/pthread_support.c b/pthread_support.c index 4f3be43..58d515d 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -534,15 +534,15 @@ STATIC void GC_delete_thread(pthread_t id) /* been notified, then there may be more than one thread */ /* in the table with the same pthread id. */ /* This is OK, but we need a way to delete a specific one. */ -STATIC void GC_delete_gc_thread(GC_thread gc_id) +STATIC void GC_delete_gc_thread(GC_thread t) { - pthread_t id = gc_id -> id; + pthread_t id = t -> id; int hv = NUMERIC_THREAD_ID(id) % THREAD_TABLE_SZ; register GC_thread p = GC_threads[hv]; register GC_thread prev = 0; GC_ASSERT(I_HOLD_LOCK()); - while (p != gc_id) { + while (p != t) { prev = p; p = p -> next; } @@ -1226,12 +1226,12 @@ GC_INNER void GC_thread_exit_proc(void *arg) GC_API int WRAP_FUNC(pthread_join)(pthread_t thread, void **retval) { int result; - GC_thread thread_gc_id; + GC_thread t; DCL_LOCK_STATE; INIT_REAL_SYMS(); LOCK(); - thread_gc_id = GC_lookup_thread(thread); + t = GC_lookup_thread(thread); /* This is guaranteed to be the intended one, since the thread id */ /* can't have been recycled by pthreads. */ UNLOCK(); @@ -1250,7 +1250,7 @@ GC_API int WRAP_FUNC(pthread_join)(pthread_t thread, void **retval) if (result == 0) { LOCK(); /* Here the pthread thread id may have been recycled. */ - GC_delete_gc_thread(thread_gc_id); + GC_delete_gc_thread(t); UNLOCK(); } return result; @@ -1259,20 +1259,20 @@ GC_API int WRAP_FUNC(pthread_join)(pthread_t thread, void **retval) GC_API int WRAP_FUNC(pthread_detach)(pthread_t thread) { int result; - GC_thread thread_gc_id; + GC_thread t; DCL_LOCK_STATE; INIT_REAL_SYMS(); LOCK(); - thread_gc_id = GC_lookup_thread(thread); + t = GC_lookup_thread(thread); UNLOCK(); result = REAL_FUNC(pthread_detach)(thread); if (result == 0) { LOCK(); - thread_gc_id -> flags |= DETACHED; + t -> flags |= DETACHED; /* Here the pthread thread id may have been recycled. */ - if (thread_gc_id -> flags & FINISHED) { - GC_delete_gc_thread(thread_gc_id); + if ((t -> flags & FINISHED) != 0) { + GC_delete_gc_thread(t); } UNLOCK(); } @@ -1292,20 +1292,19 @@ GC_API int WRAP_FUNC(pthread_detach)(pthread_t thread) GC_API int WRAP_FUNC(pthread_cancel)(pthread_t thread) { # ifdef CANCEL_SAFE - GC_thread thread_gc_id; + GC_thread t; DCL_LOCK_STATE; # endif INIT_REAL_SYMS(); # ifdef CANCEL_SAFE LOCK(); - thread_gc_id = GC_lookup_thread(thread); + t = GC_lookup_thread(thread); /* We test DISABLED_GC because pthread_exit could be called at */ - /* the same time. (If thread_gc_id is NULL then pthread_cancel */ - /* should return ESRCH.) */ - if (thread_gc_id != 0 - && (thread_gc_id -> flags & DISABLED_GC) == 0) { - thread_gc_id -> flags |= DISABLED_GC; + /* the same time. (If t is NULL then pthread_cancel should */ + /* return ESRCH.) */ + if (t != NULL && (t -> flags & DISABLED_GC) == 0) { + t -> flags |= DISABLED_GC; GC_dont_gc++; } UNLOCK(); diff --git a/win32_threads.c b/win32_threads.c index 8e0bcc5..cd8e8e8 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -616,37 +616,36 @@ GC_INNER unsigned char *GC_check_finalizer_nested(void) /* GC_win32_dll_threads is set. */ /* If GC_win32_dll_threads is set it should be called from the */ /* thread being deleted. */ -STATIC void GC_delete_gc_thread(GC_vthread gc_id) +STATIC void GC_delete_gc_thread(GC_vthread t) { # ifndef MSWINCE - CloseHandle(gc_id->handle); + CloseHandle(t->handle); # endif # ifndef GC_NO_THREADS_DISCOVERY if (GC_win32_dll_threads) { /* This is intended to be lock-free. */ /* It is either called synchronously from the thread being */ /* deleted, or by the joining thread. */ - /* In this branch asynchronous changes to *gc_id are possible. */ + /* In this branch asynchronous changes to (*t) are possible. */ /* It's not allowed to call GC_printf (and the friends) here, */ /* see GC_stop_world() for the information. */ - gc_id -> stack_base = 0; - gc_id -> id = 0; + t -> stack_base = 0; + t -> id = 0; # ifdef GC_PTHREADS - GC_PTHREAD_PTRVAL(gc_id->pthread_id) = 0; + GC_PTHREAD_PTRVAL(t->pthread_id) = 0; # endif - AO_store_release(&gc_id->tm.in_use, FALSE); + AO_store_release(&t->tm.in_use, FALSE); } else # endif /* else */ { - /* Cast away volatile qualifier, since we have lock. */ - GC_thread gc_nvid = (GC_thread)gc_id; - DWORD id = gc_nvid -> id; + DWORD id = ((GC_thread)t) -> id; + /* Cast away volatile qualifier, since we have lock. */ word hv = THREAD_TABLE_INDEX(id); register GC_thread p = GC_threads[hv]; register GC_thread prev = 0; GC_ASSERT(I_HOLD_LOCK()); - while (p != gc_nvid) { + while (p != (GC_thread)t) { prev = p; p = p -> tm.next; } @@ -2349,7 +2348,7 @@ GC_INNER void GC_thr_init(void) GC_API int GC_pthread_join(pthread_t pthread_id, void **retval) { int result; - GC_thread joinee; + GC_thread t; # ifdef DEBUG_THREADS GC_log_printf("thread %p(0x%lx) is joining thread %p\n", @@ -2364,21 +2363,22 @@ GC_INNER void GC_thr_init(void) /* FIXME: It would be better if this worked more like */ /* pthread_support.c. */ # ifndef GC_WIN32_PTHREADS - while ((joinee = GC_lookup_pthread(pthread_id)) == 0) Sleep(10); + while ((t = GC_lookup_pthread(pthread_id)) == 0) + Sleep(10); # endif result = pthread_join(pthread_id, retval); # ifdef GC_WIN32_PTHREADS /* win32_pthreads id are unique */ - joinee = GC_lookup_pthread(pthread_id); + t = GC_lookup_pthread(pthread_id); # endif if (!GC_win32_dll_threads) { DCL_LOCK_STATE; LOCK(); - GC_delete_gc_thread(joinee); + GC_delete_gc_thread(t); UNLOCK(); } /* otherwise DllMain handles it. */ @@ -2524,20 +2524,20 @@ GC_INNER void GC_thr_init(void) GC_API int GC_pthread_detach(pthread_t thread) { int result; - GC_thread thread_gc_id; + GC_thread t; DCL_LOCK_STATE; if (!parallel_initialized) GC_init_parallel(); LOCK(); - thread_gc_id = GC_lookup_pthread(thread); + t = GC_lookup_pthread(thread); UNLOCK(); result = pthread_detach(thread); if (result == 0) { LOCK(); - thread_gc_id -> flags |= DETACHED; + t -> flags |= DETACHED; /* Here the pthread thread id may have been recycled. */ - if (thread_gc_id -> flags & FINISHED) { - GC_delete_gc_thread(thread_gc_id); + if ((t -> flags & FINISHED) != 0) { + GC_delete_gc_thread(t); } UNLOCK(); } -- 2.7.4