Disable implicit multi-threaded mode for Win32 to avoid LOCK crash
authorIvan Maidanski <ivmai@mail.ru>
Sat, 17 Dec 2016 15:15:02 +0000 (18:15 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 17 Dec 2016 15:15:02 +0000 (18:15 +0300)
(fix commit d5c6531)

* include/private/gc_locks.h [GC_ALWAYS_MULTITHREADED] (GC_need_to_lock):
Do not define to TRUE unless USE_PTHREAD_LOCKS or USE_SPIN_LOCK; issue
#error otherwise (excluding CPPCHECK case) as PCR and Windows-based
lock implementation requires it to be initialized first.
* include/private/gc_locks.h [UNCOND_LOCK && !LOCK && LINT2] (LOCK,
UNLOCK): Define (to UNCOND_[UN]LOCK) only if USE_PTHREAD_LOCKS.

include/private/gc_locks.h

index 38c7350..8cc1b83 100644 (file)
@@ -36,7 +36,7 @@
 #    include <base/PCR_Base.h>
 #    include <th/PCR_Th.h>
      GC_EXTERN PCR_Th_ML GC_allocate_ml;
-#    if  defined(CPPCHECK)
+#    if defined(CPPCHECK)
 #      define DCL_LOCK_STATE /* empty */
 #    else
 #      define DCL_LOCK_STATE \
 #    define EXIT_GC() GC_collecting = 0;
      GC_INNER void GC_lock(void);
 #  endif /* GC_PTHREADS */
-#  ifdef GC_ALWAYS_MULTITHREADED
+#  if defined(GC_ALWAYS_MULTITHREADED) \
+      && (defined(USE_PTHREAD_LOCKS) || defined(USE_SPIN_LOCK))
 #    define GC_need_to_lock TRUE
 #  else
+#    if defined(GC_ALWAYS_MULTITHREADED) && !defined(CPPCHECK)
+#      error Runtime initialization of GC lock is needed!
+#    endif
+#    undef GC_ALWAYS_MULTITHREADED
      GC_EXTERN GC_bool GC_need_to_lock;
 #  endif
 
 # endif /* !THREADS */
 
 #if defined(UNCOND_LOCK) && !defined(LOCK)
-# if defined(LINT2) || defined(GC_ALWAYS_MULTITHREADED)
+# if (defined(LINT2) && defined(USE_PTHREAD_LOCKS)) \
+     || defined(GC_ALWAYS_MULTITHREADED)
     /* Instruct code analysis tools not to care about GC_need_to_lock   */
     /* influence to LOCK/UNLOCK semantic.                               */
 #   define LOCK() UNCOND_LOCK()