From: Ivan Maidanski Date: Thu, 8 Nov 2012 16:48:17 +0000 (+0400) Subject: Avoid LOCK/UNLOCK hard-coding in gc_locks.h for PS3 target X-Git-Tag: gc7_4_0~166 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9a2053581358e80ef11fb7b6df605eea46aa069d;p=gc Avoid LOCK/UNLOCK hard-coding in gc_locks.h for PS3 target * include/private/gc_locks.h (USE_PTHREAD_LOCKS): Define for SN_TARGET_PS3 target. * include/private/gcconfig.h (NO_PTHREAD_TRYLOCK): Likewise. * include/private/gc_locks.h (GC_allocate_ml, LOCK, UNLOCK): Remove explicit definition for SN_TARGET_PS3. * include/private/gc_locks.h (UNCOND_LOCK): Define as pthread_mutex_lock(...) instead of GC_lock() (which calls pthread_mutex_lock) if USE_PTHREAD_LOCKS but not GC_ASSERTIONS and not USE_SPIN_LOCK. --- diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h index f3b19e33..743fb090 100644 --- a/include/private/gc_locks.h +++ b/include/private/gc_locks.h @@ -43,7 +43,8 @@ # endif # if (!defined(AO_HAVE_test_and_set_acquire) || defined(GC_RTEMS_PTHREADS) \ - || defined(GC_WIN32_THREADS)) && defined(GC_PTHREADS) + || defined(SN_TARGET_PS3) || defined(GC_WIN32_THREADS)) \ + && defined(GC_PTHREADS) # define USE_PTHREAD_LOCKS # endif @@ -73,11 +74,6 @@ || GC_lock_holder == GetCurrentThreadId()) # define I_DONT_HOLD_LOCK() (!GC_need_to_lock \ || GC_lock_holder != GetCurrentThreadId()) -# elif defined(SN_TARGET_PS3) -# include - GC_EXTERN pthread_mutex_t GC_allocate_ml; -# define LOCK() pthread_mutex_lock(&GC_allocate_ml) -# define UNLOCK() pthread_mutex_unlock(&GC_allocate_ml) # elif defined(GC_PTHREADS) # include @@ -132,11 +128,11 @@ GC_lock(); } # define UNCOND_UNLOCK() AO_CLEAR(&GC_allocate_lock) # endif /* !GC_ASSERTIONS */ -# else /* THREAD_LOCAL_ALLOC || USE_PTHREAD_LOCKS */ +# else /* THREAD_LOCAL_ALLOC || USE_PTHREAD_LOCKS */ # ifndef USE_PTHREAD_LOCKS # define USE_PTHREAD_LOCKS # endif -# endif /* THREAD_LOCAL_ALLOC || USE_PTHREAD_LOCK */ +# endif /* THREAD_LOCAL_ALLOC || USE_PTHREAD_LOCKS */ # ifdef USE_PTHREAD_LOCKS # include GC_EXTERN pthread_mutex_t GC_allocate_ml; @@ -147,11 +143,15 @@ pthread_mutex_unlock(&GC_allocate_ml); } # else /* !GC_ASSERTIONS */ # if defined(NO_PTHREAD_TRYLOCK) -# define UNCOND_LOCK() GC_lock() -# else /* !defined(NO_PTHREAD_TRYLOCK) */ -# define UNCOND_LOCK() \ - { if (0 != pthread_mutex_trylock(&GC_allocate_ml)) \ - GC_lock(); } +# ifdef USE_SPIN_LOCK +# define UNCOND_LOCK() GC_lock() +# else +# define UNCOND_LOCK() pthread_mutex_lock(&GC_allocate_ml) +# endif +# else +# define UNCOND_LOCK() \ + { if (0 != pthread_mutex_trylock(&GC_allocate_ml)) \ + GC_lock(); } # endif # define UNCOND_UNLOCK() pthread_mutex_unlock(&GC_allocate_ml) # endif /* !GC_ASSERTIONS */ diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index d90ddadb..a35f4edb 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -928,6 +928,9 @@ # define DATAEND (ptr_t)(_end) # define DATASTART (ptr_t)(__bss_start) # define STACKBOTTOM ((ptr_t)ps3_get_stack_bottom()) +# define NO_PTHREAD_TRYLOCK + /* Current GC LOCK() implementation for PS3 explicitly */ + /* use pthread_mutex_lock for some reason. */ # endif # ifdef AIX # define OS_TYPE "AIX"