From 25882d984559dcf6fe7381fa7e05a41b3e39e2c3 Mon Sep 17 00:00:00 2001 From: green Date: Sun, 9 Apr 2000 05:41:56 +0000 Subject: 2000-04-08 Anthony Green * posix-threads.cc (_Jv_MutexLock): Moved back to posix-threads.h. (_Jv_MutexUnlock): Ditto. * include/posix-threads.h (_Jv_MutexLock): From posix-threads.cc. (_Jv_MutexUnlock): Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33037 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/include/posix-threads.h | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'libjava/include/posix-threads.h') diff --git a/libjava/include/posix-threads.h b/libjava/include/posix-threads.h index 22f6717e82d..03a43906bd6 100644 --- a/libjava/include/posix-threads.h +++ b/libjava/include/posix-threads.h @@ -115,8 +115,38 @@ _Jv_MutexInit (_Jv_Mutex_t *mu) mu->owner = 0; } -int _Jv_MutexLock (_Jv_Mutex_t *mu); -int _Jv_MutexUnlock (_Jv_Mutex_t *mu); +inline int +_Jv_MutexLock (_Jv_Mutex_t *mu) +{ + pthread_t self = pthread_self (); + if (mu->owner == self) + { + mu->count++; + } + else + { + pthread_mutex_lock (&mu->mutex); + mu->count = 1; + mu->owner = self; + } + return 0; +} + +inline int +_Jv_MutexUnlock (_Jv_Mutex_t *mu) +{ + if (_Jv_PthreadCheckMonitor (mu)) + return _JV_NOT_OWNER; + + mu->count--; + + if (mu->count == 0) + { + mu->owner = 0; + pthread_mutex_unlock (&mu->mutex); + } + return 0; +} #ifndef LINUX_THREADS -- cgit v1.2.1