summaryrefslogtreecommitdiff
path: root/libjava/include
diff options
context:
space:
mode:
authorjlquinn <jlquinn@138bc75d-0d04-0410-961f-82ee72b054a4>2003-10-21 04:46:19 +0000
committerjlquinn <jlquinn@138bc75d-0d04-0410-961f-82ee72b054a4>2003-10-21 04:46:19 +0000
commit7c2ddf15e59cec9fe51ad7eeac50ecb31762bc4c (patch)
treeb5325b3608586fc1cc0a4882b22a1fee0f1262bb /libjava/include
parentd80ce0591091c7dc6de461afc7beeb435f718018 (diff)
downloadgcc-7c2ddf15e59cec9fe51ad7eeac50ecb31762bc4c.tar.gz
2003-10-21 Jerry Quinn <jlquinn@optonline.net>
* posix-threads.cc (_Jv_CondNotify,_Jv_CondNotifyAll): Rename _Jv_PthreadCheckMonitor to _Jv_MutexCheckMonitor. * include/no-threads.h (_Jv_MutexCheckMonitor): New. * include/posix-threads.h (_Jv_MutexCheckMonitor): Rename from _Jv_PthreadCheckMonitor. Simplify code. (_Jv_MutexUnlock): Use _Jv_MutexCheckMonitor. * include/win32-threads.h (_Jv_MutexCheckMonitor): New. * java/lang/Object.h (_Jv_ObjectCheckMonitor): Declare. * java/lang/Thread.java (holdsLock): New. * java/lang/natObject.cc (_Jv_ObjectCheckMonitor): New, with and without JV_HASH_SYNCHRONIZATION. * java/lang/natThread.cc (java::lang::Thread::holdsLock): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72741 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/include')
-rw-r--r--libjava/include/no-threads.h5
-rw-r--r--libjava/include/posix-threads.h9
-rw-r--r--libjava/include/win32-threads.h6
3 files changed, 14 insertions, 6 deletions
diff --git a/libjava/include/no-threads.h b/libjava/include/no-threads.h
index 1cd2471b8cf..793cfadbf1b 100644
--- a/libjava/include/no-threads.h
+++ b/libjava/include/no-threads.h
@@ -75,6 +75,11 @@ _Jv_CondNotifyAll (_Jv_ConditionVariable_t *, _Jv_Mutex_t *)
// Mutexes.
//
+inline int _Jv_MutexCheckMonitor (_Jv_Mutex_t *mu)
+{
+ return 0;
+}
+
inline void
_Jv_MutexInit (_Jv_Mutex_t *)
{
diff --git a/libjava/include/posix-threads.h b/libjava/include/posix-threads.h
index 6c8dcec933c..01606df021f 100644
--- a/libjava/include/posix-threads.h
+++ b/libjava/include/posix-threads.h
@@ -77,12 +77,9 @@ typedef struct
// this out. Returns 0 if the lock is held by the current thread, and
// 1 otherwise.
inline int
-_Jv_PthreadCheckMonitor (_Jv_Mutex_t *mu)
+_Jv_MutexCheckMonitor (_Jv_Mutex_t *mu)
{
- pthread_t self = pthread_self();
- if (mu->owner == self)
- return 0;
- else return 1;
+ return (mu->owner != pthread_self());
}
//
@@ -155,7 +152,7 @@ _Jv_MutexLock (_Jv_Mutex_t *mu)
inline int
_Jv_MutexUnlock (_Jv_Mutex_t *mu)
{
- if (_Jv_PthreadCheckMonitor (mu))
+ if (_Jv_MutexCheckMonitor (mu))
{
# ifdef LOCK_DEBUG
fprintf(stderr, "_Jv_MutexUnlock: Not owner\n");
diff --git a/libjava/include/win32-threads.h b/libjava/include/win32-threads.h
index ed5eb0047e0..fdd21c541b4 100644
--- a/libjava/include/win32-threads.h
+++ b/libjava/include/win32-threads.h
@@ -86,6 +86,12 @@ int _Jv_CondNotifyAll (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *);
// We use CRITICAL_SECTIONs instead of CreateMutex() for better performance
//
+// Returns 0 if the mutex lock is held by the current thread, and 1 otherwise.
+inline int _Jv_MutexCheckMonitor (_Jv_Mutex_t *mu)
+{
+ return (mu->owner != GetCurrentThreadId ( ));
+}
+
inline void _Jv_MutexInit (_Jv_Mutex_t *mu)
{
mu->owner = 0UL;