summaryrefslogtreecommitdiff
path: root/libjava/include/posix-threads.h
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2007-01-09 19:58:05 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2007-01-09 19:58:05 +0000
commit65bf3316cf384588453604be6b4f0ed3751a8b0f (patch)
tree996a5f57d4a68c53473382e45cb22f574cb3e4db /libjava/include/posix-threads.h
parent8fc56618a84446beccd45b80381cdfe0e94050df (diff)
downloadgcc-65bf3316cf384588453604be6b4f0ed3751a8b0f.tar.gz
Merged gcj-eclipse branch to trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120621 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/include/posix-threads.h')
-rw-r--r--libjava/include/posix-threads.h56
1 files changed, 31 insertions, 25 deletions
diff --git a/libjava/include/posix-threads.h b/libjava/include/posix-threads.h
index 1f06fc3be18..d5f64957c22 100644
--- a/libjava/include/posix-threads.h
+++ b/libjava/include/posix-threads.h
@@ -19,6 +19,7 @@ details. */
#include <pthread.h>
#include <sched.h>
+#include <sysdep/locks.h>
//
// Typedefs.
@@ -131,31 +132,7 @@ _Jv_MutexInit (_Jv_Mutex_t *mu)
mu->owner = 0;
}
-inline int
-_Jv_MutexLock (_Jv_Mutex_t *mu)
-{
- pthread_t self = pthread_self ();
- if (mu->owner == self)
- {
- mu->count++;
- }
- else
- {
-# ifdef LOCK_DEBUG
- int result = pthread_mutex_lock (&mu->mutex);
- if (0 != result)
- {
- fprintf(stderr, "Pthread_mutex_lock returned %d\n", result);
- for (;;) {}
- }
-# else
- pthread_mutex_lock (&mu->mutex);
-# endif
- mu->count = 1;
- mu->owner = self;
- }
- return 0;
-}
+extern int _Jv_MutexLock (_Jv_Mutex_t *);
inline int
_Jv_MutexUnlock (_Jv_Mutex_t *mu)
@@ -374,4 +351,33 @@ void _Jv_ThreadWait (void);
void _Jv_ThreadInterrupt (_Jv_Thread_t *data);
+// park() / unpark() support
+
+struct ParkHelper
+{
+ volatile obj_addr_t permit;
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+
+ void init ();
+ void deactivate ();
+ void destroy ();
+ void park (jboolean isAbsolute, jlong time);
+ void unpark ();
+};
+
+inline void
+ParkHelper::init ()
+{
+ pthread_mutex_init (&mutex, NULL);
+ pthread_cond_init (&cond, NULL);
+}
+
+inline void
+ParkHelper::destroy ()
+{
+ pthread_mutex_destroy (&mutex);
+ pthread_cond_destroy (&cond);
+}
+
#endif /* __JV_POSIX_THREADS__ */