diff options
| author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-09-01 18:29:39 +0000 |
|---|---|---|
| committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-09-01 18:29:39 +0000 |
| commit | 95d0972a456a74932b8b6d9903a9b6298135fa74 (patch) | |
| tree | 6fb15ec8b692fb14a98a2eaba9879e17e7f496a6 /libjava/include | |
| parent | 48fed70da8535477f34246665e74452c895ffa51 (diff) | |
| download | ppe42-gcc-95d0972a456a74932b8b6d9903a9b6298135fa74.tar.gz ppe42-gcc-95d0972a456a74932b8b6d9903a9b6298135fa74.zip | |
* posix-threads.cc (_Jv_CondWait): Call _Jv_PthreadCheckMonitor.
* include/posix-threads.h (_Jv_PthreadCheckMonitor): New
function.
(_Jv_CondNotify): Use it.
(_Jv_CondNotifyAll): Likewise.
* java/lang/Class.h (JV_STATE_NOTHING): Correct misspelling.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@29030 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/include')
| -rw-r--r-- | libjava/include/posix-threads.h | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/libjava/include/posix-threads.h b/libjava/include/posix-threads.h index 6e4cc70c020..2ad6c06e047 100644 --- a/libjava/include/posix-threads.h +++ b/libjava/include/posix-threads.h @@ -65,6 +65,25 @@ typedef struct typedef void _Jv_ThreadStartFunc (java::lang::Thread *); +// This is a convenience function used only by the pthreads thread +// implementation. This is slow, but that's too bad -- we need to do +// the checks for correctness. It might be nice to be able to compile +// this out. +inline int _Jv_PthreadCheckMonitor (_Jv_Mutex_t *mu) +{ + pthread_mutex_t *pmu; +#ifdef HAVE_RECURSIVE_MUTEX + pmu = mu; +#else + pmu = &mu->mutex2; +#endif + // See if the mutex is locked by this thread. + if (pthread_mutex_trylock (pmu)) + return 1; + pthread_mutex_unlock (pmu); + return 0; +} + // // Condition variables. // @@ -94,17 +113,15 @@ int _Jv_CondWait (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu, jlong millis, jint nanos); inline int -_Jv_CondNotify (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *) +_Jv_CondNotify (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu) { - // FIXME: check to see if mutex is held by current thread. - return pthread_cond_signal (cv); + return _Jv_PthreadCheckMonitor (mu) || pthread_cond_signal (cv); } inline int -_Jv_CondNotifyAll (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *) +_Jv_CondNotifyAll (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu) { - // FIXME: check to see if mutex is held by current thread. - return pthread_cond_broadcast (cv); + return _Jv_PthreadCheckMonitor (mu) || pthread_cond_broadcast (cv); } |

