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() \
# 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(); }
# 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))
}
}
-#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