OSDN Git Service

Regenerate tree using Autoconf 2.64 and Automake 1.11.
[pf3gnuchains/gcc-fork.git] / libjava / include / posix-threads.h
index 8d69652..806ee55 100644 (file)
@@ -19,6 +19,7 @@ details.  */
 
 #include <pthread.h>
 #include <sched.h>
+#include <sysdep/locks.h>
 
 //
 // Typedefs.
@@ -91,6 +92,14 @@ _Jv_GetPlatformThreadID(_Jv_Thread_t *t)
 }
 
 //
+// Signal helpers.
+//
+
+void _Jv_BlockSigchld();
+void _Jv_UnBlockSigchld();
+
+
+//
 // Condition variables.
 //
 
@@ -131,31 +140,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,18 +359,33 @@ void _Jv_ThreadWait (void);
 
 void _Jv_ThreadInterrupt (_Jv_Thread_t *data);
 
-// Increases a thread's suspend count. If the thread's previous
-// suspend count was zero, i.e., it is not suspended, this function
-// will suspend the thread. This function may be used to suspend
-// any thread from any other thread (or suspend itself).
-void _Jv_ThreadDebugSuspend (_Jv_Thread_t *data);
+// park() / unpark() support
 
-// Decreases a thread's suspend count. If the thread's new thread
-// count is zero, the thread is resumed. This function may be used
-// by any thread to resume any other thread.
-void _Jv_ThreadDebugResume (_Jv_Thread_t *data);
+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 ();
+};
 
-// Get the suspend count for a thread
-jint _Jv_ThreadDebugSuspendCount (_Jv_Thread_t *data);
+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__ */