From 20a581dfd50a4de4b4d1935893aa41e5ea64d32f Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 18 Jan 2017 11:58:42 +0300 Subject: [PATCH] Eliminate 'GC_collecting is set but never used' code defect (Win32) * include/private/gc_locks.h [USE_PTHREAD_LOCKS && GC_PTHREADS] (GC_collecting): Do not declare if GC_WIN32_THREADS. * include/private/gc_locks.h [USE_PTHREAD_LOCKS && GC_PTHREADS] (ENTER_GC, EXIT_GC): Do not define if GC_WIN32_THREADS; remove trailing ';', add cast to void. * win32_threads.c [USE_PTHREAD_LOCKS] (GC_collecting): Remove definition. --- include/private/gc_locks.h | 8 +++++--- win32_threads.c | 5 ----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h index 8cc1b83..0062c79 100644 --- a/include/private/gc_locks.h +++ b/include/private/gc_locks.h @@ -187,9 +187,11 @@ || GC_lock_holder != NUMERIC_THREAD_ID(pthread_self())) # endif # endif /* GC_ASSERTIONS */ - GC_EXTERN volatile GC_bool GC_collecting; -# define ENTER_GC() GC_collecting = 1; -# define EXIT_GC() GC_collecting = 0; +# ifndef GC_WIN32_THREADS + GC_EXTERN volatile GC_bool GC_collecting; +# define ENTER_GC() (void)(GC_collecting = TRUE) +# define EXIT_GC() (void)(GC_collecting = FALSE) +# endif GC_INNER void GC_lock(void); # endif /* GC_PTHREADS */ # if defined(GC_ALWAYS_MULTITHREADED) \ diff --git a/win32_threads.c b/win32_threads.c index 1527ba3..263ba58 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -2838,11 +2838,6 @@ GC_INNER void GC_init_parallel(void) /* pthread_mutex_trylock may not win here, */ /* due to builtin support for spinning first? */ - GC_INNER volatile GC_bool GC_collecting = 0; - /* A hint that we're in the collector and */ - /* holding the allocation lock for an */ - /* extended period. */ - GC_INNER void GC_lock(void) { pthread_mutex_lock(&GC_allocate_ml); -- 2.7.4