Patch: inline posix mutex code
Anthony Green
green@cygnus.com
Sat Apr 8 22:42:00 GMT 2000
This patch makes the posix _Jv_MutexLock and _Jv_MutexUnlock functions
inline.
2000-04-08 Anthony Green <green@cygnus.com>
* 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.
Index: libjava/posix-threads.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/posix-threads.cc,v
retrieving revision 1.18
diff -c -r1.18 posix-threads.cc
*** posix-threads.cc 2000/03/28 02:22:23 1.18
--- posix-threads.cc 2000/04/09 05:39:15
***************
*** 402,440 ****
}
}
- 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;
- }
-
- 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;
- }
-
void
_Jv_ThreadWait (void)
{
--- 402,407 ----
Index: libjava/include/posix-threads.h
===================================================================
RCS file: /cvs/java/libgcj/libjava/include/posix-threads.h,v
retrieving revision 1.13
diff -c -r1.13 posix-threads.h
*** posix-threads.h 2000/03/28 02:22:24 1.13
--- posix-threads.h 2000/04/09 05:39:15
***************
*** 115,122 ****
mu->owner = 0;
}
! int _Jv_MutexLock (_Jv_Mutex_t *mu);
! int _Jv_MutexUnlock (_Jv_Mutex_t *mu);
#ifndef LINUX_THREADS
--- 115,152 ----
mu->owner = 0;
}
! 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
More information about the Java-patches
mailing list