OSDN Git Service

Bug 15093
[pf3gnuchains/gcc-fork.git] / libjava / posix-threads.cc
index f068fba..03ae453 100644 (file)
@@ -24,6 +24,9 @@ details.  */
 #include <signal.h>
 #include <errno.h>
 #include <limits.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>    // To test for _POSIX_THREAD_PRIORITY_SCHEDULING
+#endif
 
 #include <gcj/cni.h>
 #include <jvm.h>
@@ -190,7 +193,7 @@ _Jv_CondWait (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu,
 int
 _Jv_CondNotify (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu)
 {
-  if (_Jv_PthreadCheckMonitor (mu))
+  if (_Jv_MutexCheckMonitor (mu))
     return _JV_NOT_OWNER;
 
   _Jv_Thread_t *target;
@@ -229,7 +232,7 @@ _Jv_CondNotify (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu)
 int
 _Jv_CondNotifyAll (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu)
 {
-  if (_Jv_PthreadCheckMonitor (mu))
+  if (_Jv_MutexCheckMonitor (mu))
     return _JV_NOT_OWNER;
 
   _Jv_Thread_t *target;
@@ -318,6 +321,7 @@ _Jv_ThreadDestroyData (_Jv_Thread_t *data)
 void
 _Jv_ThreadSetPriority (_Jv_Thread_t *data, jint prio)
 {
+#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
   if (data->flags & FLAG_START)
     {
       struct sched_param param;
@@ -325,6 +329,7 @@ _Jv_ThreadSetPriority (_Jv_Thread_t *data, jint prio)
       param.sched_priority = prio;
       pthread_setschedparam (data->thread, SCHED_RR, &param);
     }
+#endif
 }
 
 void
@@ -438,18 +443,17 @@ _Jv_ThreadWait (void)
 
 #if defined(SLOW_PTHREAD_SELF)
 
-// Support for pthread_self() lookup cache.
+#include "sysdep/locks.h"
 
+// Support for pthread_self() lookup cache.
 volatile self_cache_entry _Jv_self_cache[SELF_CACHE_SIZE];
 
-
 _Jv_ThreadId_t
 _Jv_ThreadSelf_out_of_line(volatile self_cache_entry *sce, size_t high_sp_bits)
 {
   pthread_t self = pthread_self();
-  // The ordering between the following writes matters.
-  // On Alpha, we probably need a memory barrier in the middle.
   sce -> high_sp_bits = high_sp_bits;
+  write_barrier();
   sce -> self = self;
   return self;
 }