From: Ivan Maidanski Date: Wed, 23 Aug 2017 08:46:41 +0000 (+0300) Subject: Change type of THREAD_TABLE_INDEX result to int in win32_threads.c X-Git-Tag: v8.0.0~597 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6d7f13f0aa8f3f52fa19d52c0744176c06df1114;p=gc Change type of THREAD_TABLE_INDEX result to int in win32_threads.c (code refactoring) * win32_threads.c (THREAD_TABLE_INDEX): Cast result to int; remove cast of argument to word type; add comment. * win32_threads.c (GC_new_thread, GC_delete_gc_thread_no_free, GC_delete_thread): Change type of hv local variable from word to int. * win32_threads.c (GC_lookup_thread_inner): Remove hv local variable; remove "register" keyword for p local variable. * win32_threads.c (GC_lookup_pthread): Change type of hv_guess local variable from word to int. --- diff --git a/win32_threads.c b/win32_threads.c index 9f724675..eaf30e47 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -320,7 +320,8 @@ STATIC volatile LONG GC_max_thread_index = 0; #ifndef THREAD_TABLE_SZ # define THREAD_TABLE_SZ 256 /* Power of 2 (for speed). */ #endif -#define THREAD_TABLE_INDEX(id) (((word)(id) >> 2) % THREAD_TABLE_SZ) +#define THREAD_TABLE_INDEX(id) /* id is of DWORD type */ \ + (int)(((id) >> 2) % THREAD_TABLE_SZ) STATIC GC_thread GC_threads[THREAD_TABLE_SZ]; /* It may not be safe to allocate when we register the first thread. */ @@ -334,7 +335,7 @@ static GC_bool first_thread_used = FALSE; /* Unlike the pthreads version, the id field is set by the caller. */ STATIC GC_thread GC_new_thread(DWORD id) { - word hv = THREAD_TABLE_INDEX(id); + int hv = THREAD_TABLE_INDEX(id); GC_thread result; GC_ASSERT(I_HOLD_LOCK()); @@ -526,8 +527,7 @@ STATIC GC_thread GC_lookup_thread_inner(DWORD thread_id) } else # endif /* else */ { - word hv = THREAD_TABLE_INDEX(thread_id); - register GC_thread p = GC_threads[hv]; + GC_thread p = GC_threads[THREAD_TABLE_INDEX(thread_id)]; GC_ASSERT(I_HOLD_LOCK()); while (p != 0 && p -> id != thread_id) p = p -> tm.next; @@ -665,7 +665,7 @@ STATIC void GC_delete_gc_thread_no_free(GC_vthread t) /* else */ { DWORD id = ((GC_thread)t) -> id; /* Cast away volatile qualifier, since we have lock. */ - word hv = THREAD_TABLE_INDEX(id); + int hv = THREAD_TABLE_INDEX(id); register GC_thread p = GC_threads[hv]; register GC_thread prev = 0; @@ -699,7 +699,7 @@ STATIC void GC_delete_thread(DWORD id) GC_delete_gc_thread_no_free(t); } } else { - word hv = THREAD_TABLE_INDEX(id); + int hv = THREAD_TABLE_INDEX(id); register GC_thread p = GC_threads[hv]; register GC_thread prev = 0; @@ -987,7 +987,7 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn, /* else */ { /* We first try the cache. If that fails, we use a very slow */ /* approach. */ - word hv_guess = THREAD_TABLE_INDEX(GET_PTHREAD_MAP_CACHE(id)); + int hv_guess = THREAD_TABLE_INDEX(GET_PTHREAD_MAP_CACHE(id)); int hv; GC_thread p; DCL_LOCK_STATE;