+2011-05-17 Ivan Maidanski <ivmai@mail.ru>
+
+ * 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 <ivmai@mail.ru>
* pthread_stop_world.c (pthread_sigmask): Undefine even if not
/* 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;
}
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();
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;
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();
}
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();
/* 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;
}
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",
/* 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. */
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();
}