diff options
author | Tom Tromey <tromey@cygnus.com> | 1999-09-02 06:27:00 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 1999-09-02 06:27:00 +0000 |
commit | bc5afba452d4accc25fdd53739c58a14ed93c91e (patch) | |
tree | 282214e0286d55d7b11ec4b353396c0078e937b6 /libjava/include/posix-threads.h | |
parent | 2598e85aadb5a53abd3cb7b5e846d4d4bfcdd495 (diff) | |
download | gcc-bc5afba452d4accc25fdd53739c58a14ed93c91e.zip gcc-bc5afba452d4accc25fdd53739c58a14ed93c91e.tar.gz gcc-bc5afba452d4accc25fdd53739c58a14ed93c91e.tar.bz2 |
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
Diffstat (limited to 'libjava/include/posix-threads.h')
-rw-r--r-- | libjava/include/posix-threads.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/libjava/include/posix-threads.h b/libjava/include/posix-threads.h index e3b3f4f..053a45c 100644 --- a/libjava/include/posix-threads.h +++ b/libjava/include/posix-threads.h @@ -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 |