posix-threads.h (PTHREAD_MUTEX_IS_STRUCT): New define.

* include/posix-threads.h (PTHREAD_MUTEX_IS_STRUCT): New define.
	(_Jv_PthreadGetMutex): Use it.
	(_Jv_PthreadCheckMonitor): Use new M_COUNT macros.
	(_Jv_MutexInit): Use PTHREAD_MUTEX_IS_STRUCT.
	(_Jv_MutexLock): Likewise.
	(_Jv_MutexUnlock): Likewise.
	* include/config.h.in: Rebuilt.
	* acconfig.h (PTHREAD_MUTEX_HAVE_M_COUNT,
	PTHREAD_MUTEX_HAVE___M_COUNT): New undefs.
	* configure: Rebuilt.
	* libgcj.spec.in: Don't mention INTERPSPEC.
	* configure.in (INTERPSPEC): Removed.
	Only run pthreads-related checks when using POSIX threads.  Check
	for m_count and __m_count in mutex structure.

From-SVN: r29048
This commit is contained in:
Tom Tromey 1999-09-02 06:27:00 +00:00 committed by Tom Tromey
parent 2598e85aad
commit bc5afba452
10 changed files with 1399 additions and 358 deletions

View file

@ -31,9 +31,7 @@ details. */
typedef pthread_cond_t _Jv_ConditionVariable_t;
// FIXME: it is ugly to use LINUX_THREADS as the define. Instead
// think of a better scheme.
#ifdef LINUX_THREADS
#if defined (PTHREAD_MUTEX_HAVE_M_COUNT) || defined (PTHREAD_MUTEX_HAVE___M_COUNT)
// On Linux we use implementation details of mutexes in order to get
// faster results.
@ -41,6 +39,8 @@ typedef pthread_mutex_t _Jv_Mutex_t;
#else /* LINUX_THREADS */
#define PTHREAD_MUTEX_IS_STRUCT
typedef struct
{
// Mutex used when locking this structure transiently.
@ -67,7 +67,7 @@ typedef struct
int count;
} _Jv_Mutex_t;
#endif /* LINUX_THREADS */
#endif
typedef struct
{
@ -88,7 +88,7 @@ typedef void _Jv_ThreadStartFunc (java::lang::Thread *);
inline pthread_mutex_t *
_Jv_PthreadGetMutex (_Jv_Mutex_t *mu)
{
#if defined (LINUX_THREADS)
#if ! defined (PTHREAD_MUTEX_IS_STRUCT)
return mu;
#elif defined (HAVE_RECURSIVE_MUTEX)
return &mu->mutex;
@ -110,9 +110,11 @@ _Jv_PthreadCheckMonitor (_Jv_Mutex_t *mu)
// See if the mutex is locked by this thread.
if (pthread_mutex_trylock (pmu))
return 1;
#ifdef LINUX_THREADS
#if defined (PTHREAD_MUTEX_HAVE_M_COUNT)
// On Linux we exploit knowledge of the implementation.
int r = pmu->m_count == 1;
#elif defined (PTHREAD_MUTEX_HAVE___M_COUNT)
int r = pmu->__m_count == 1;
#else
int r = mu->count == 0;
#endif
@ -170,7 +172,7 @@ inline void
_Jv_MutexInit (_Jv_Mutex_t *mu)
{
pthread_mutex_init (_Jv_PthreadGetMutex (mu), NULL);
#ifndef LINUX_THREADS
#ifdef PTHREAD_MUTEX_IS_STRUCT
mu->count = 0;
#endif
}
@ -206,7 +208,7 @@ inline int
_Jv_MutexLock (_Jv_Mutex_t *mu)
{
int r = pthread_mutex_lock (mu);
#ifndef LINUX_THREADS
#ifdef PTHREAD_MUTEX_IS_STRUCT
if (! r)
++mu->count;
#endif
@ -217,7 +219,7 @@ inline int
_Jv_MutexUnlock (_Jv_Mutex_t *mu)
{
int r = pthread_mutex_unlock (mu);
#ifndef LINUX_THREADS
#ifdef PTHREAD_MUTEX_IS_STRUCT
if (! r)
--mu->count;
#endif