From: Ivan Maidanski Date: Wed, 29 May 2019 08:16:04 +0000 (+0300) Subject: Fix 'unused function GC_lock' compiler warning X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93a426f6b0cca88ba6526ad63fae69848963d6b6;p=gc Fix 'unused function GC_lock' compiler warning * include/private/gc_locks.h [GC_PTHREADS && !USE_SPIN_LOCK] (GC_lock): Declare only if USE_PTHREAD_LOCKS and (GC_ASSERTIONS or not NO_PTHREAD_TRYLOCK). * pthread_support.c [!USE_SPIN_LOCK] (GC_lock): Define only if USE_PTHREAD_LOCKS and (not NO_PTHREAD_TRYLOCK or GC_ASSERTIONS). --- diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h index 152ad9d3..5b9ef4f3 100644 --- a/include/private/gc_locks.h +++ b/include/private/gc_locks.h @@ -183,6 +183,7 @@ EXTERN_C_BEGIN GC_EXTERN pthread_mutex_t GC_allocate_ml; # ifdef GC_ASSERTIONS + GC_INNER void GC_lock(void); # define UNCOND_LOCK() { GC_ASSERT(I_DONT_HOLD_LOCK()); \ GC_lock(); SET_LOCK_HOLDER(); } # define UNCOND_UNLOCK() \ @@ -192,6 +193,7 @@ # if defined(NO_PTHREAD_TRYLOCK) # define UNCOND_LOCK() pthread_mutex_lock(&GC_allocate_ml) # else + GC_INNER void GC_lock(void); # define UNCOND_LOCK() \ { if (0 != pthread_mutex_trylock(&GC_allocate_ml)) \ GC_lock(); } @@ -225,7 +227,6 @@ # define EXIT_GC() (void)(GC_collecting = FALSE) # endif # endif - GC_INNER void GC_lock(void); # endif /* GC_PTHREADS */ # if defined(GC_ALWAYS_MULTITHREADED) \ && (defined(USE_PTHREAD_LOCKS) || defined(USE_SPIN_LOCK)) diff --git a/pthread_support.c b/pthread_support.c index 0b2af4ac..ae1c7f30 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -2176,22 +2176,25 @@ yield: } } -#else /* !USE_SPIN_LOCK */ +#elif defined(USE_PTHREAD_LOCKS) -GC_INNER void GC_lock(void) -{ -#ifndef NO_PTHREAD_TRYLOCK - if (1 == GC_nprocs || is_collecting()) { +# ifndef NO_PTHREAD_TRYLOCK + GC_INNER void GC_lock(void) + { + if (1 == GC_nprocs || is_collecting()) { pthread_mutex_lock(&GC_allocate_ml); - } else { + } else { GC_generic_lock(&GC_allocate_ml); + } } -#else /* !NO_PTHREAD_TRYLOCK */ - pthread_mutex_lock(&GC_allocate_ml); -#endif /* !NO_PTHREAD_TRYLOCK */ -} +# elif defined(GC_ASSERTIONS) + GC_INNER void GC_lock(void) + { + pthread_mutex_lock(&GC_allocate_ml); + } +# endif -#endif /* !USE_SPIN_LOCK */ +#endif /* !USE_SPIN_LOCK && USE_PTHREAD_LOCKS */ #ifdef PARALLEL_MARK