]> granicus.if.org Git - gc/commitdiff
Simplify LOCK/UNLOCK macro definition for static code analysis tools
authorIvan Maidanski <ivmai@mail.ru>
Thu, 8 Nov 2012 17:19:02 +0000 (21:19 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 8 Nov 2012 17:20:53 +0000 (21:20 +0400)
* include/private/gc_locks.h (USE_PTHREAD_LOCKS): Explicitly define
if LINT2 and GC_PTHREADS.
* include/private/gc_locks.h (LOCK, UNLOCK): Redirect to
UNCOND_[UN]LOCK (omitting GC_need_to_lock check) if LINT2.

include/private/gc_locks.h

index 743fb090b525fe8f0eebd815e2fee71e385204f5..7c3e9c8983ab6845c6c43da9f4d6e25d88e5cdb8 100644 (file)
@@ -43,8 +43,8 @@
 #  endif
 
 #  if (!defined(AO_HAVE_test_and_set_acquire) || defined(GC_RTEMS_PTHREADS) \
-       || defined(SN_TARGET_PS3) || defined(GC_WIN32_THREADS)) \
-      && defined(GC_PTHREADS)
+       || defined(SN_TARGET_PS3) || defined(GC_WIN32_THREADS) \
+       || defined(LINT2)) && defined(GC_PTHREADS)
 #    define USE_PTHREAD_LOCKS
 #  endif
 
 # endif /* !THREADS */
 
 #if defined(UNCOND_LOCK) && !defined(LOCK)
+# ifdef LINT2
+    /* Instruct code analysis tools not to care about GC_need_to_lock   */
+    /* influence to LOCK/UNLOCK semantic.                               */
+#   define LOCK() UNCOND_LOCK()
+#   define UNLOCK() UNCOND_UNLOCK()
+# else
                 /* At least two thread running; need to lock.   */
-#    define LOCK() { if (GC_need_to_lock) UNCOND_LOCK(); }
-#    define UNLOCK() { if (GC_need_to_lock) UNCOND_UNLOCK(); }
+#   define LOCK() { if (GC_need_to_lock) UNCOND_LOCK(); }
+#   define UNLOCK() { if (GC_need_to_lock) UNCOND_UNLOCK(); }
+# endif
 #endif
 
 # ifndef ENTER_GC