From: Ivan Maidanski Date: Thu, 8 Nov 2012 17:19:02 +0000 (+0400) Subject: Simplify LOCK/UNLOCK macro definition for static code analysis tools X-Git-Tag: gc7_4_0~165 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3ae3bfe965926c3fd940bcef4bfe8dcdf1613ddc;p=gc Simplify LOCK/UNLOCK macro definition for static code analysis tools * 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. --- diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h index 743fb090..7c3e9c89 100644 --- a/include/private/gc_locks.h +++ b/include/private/gc_locks.h @@ -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 @@ -193,9 +193,16 @@ # 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