Eliminate 'GC_collecting is set but never used' code defect (Win32)
authorIvan Maidanski <ivmai@mail.ru>
Wed, 18 Jan 2017 08:58:42 +0000 (11:58 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 18 Jan 2017 08:58:42 +0000 (11:58 +0300)
* 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
win32_threads.c

index 8cc1b83..0062c79 100644 (file)
                  || 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) \
index 1527ba3..263ba58 100644 (file)
@@ -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);